import{F as Y,ag as j,bt as x,m as l,M as S,L as Z,aD as ee,K as $,J as ae,P as c,_ as f,R as g,a1 as p,T as se,X as m,Q as le,W as k,e,Y as C,a2 as T,a0 as A}from"./vendor-d3O24IFR.js";import{w as ie,cb as te,a4 as oe,cL as i}from"./index-DtNTt4xe.js";const de={class:"space-y-4"},ne={key:0,class:"space-y-4"},I=250,pe=Y({__name:"add-or-update-wishlist-modal",props:{list:{}},setup(M){const d=M,{t:_}=j(),{copy:U,isSupported:B}=x(),L=ie(),D=l(()=>d.list?.name),O=l(()=>d.list?.description),P=l(()=>d.list?.sharingSetting?.scope),{loading:h,createWishlist:W,updateWishlist:z}=te(),{isCorporateMember:E}=oe(),K=l(()=>[{id:i.Private,label:_(`shared.wishlists.add_or_update_wishlist_modal.sharing_scope.${i.Private}`)},{id:i.AnyoneAnonymous,label:_(`shared.wishlists.add_or_update_wishlist_modal.sharing_scope.${i.AnyoneAnonymous}`)},{id:i.Organization,label:_(`shared.wishlists.add_or_update_wishlist_modal.sharing_scope.${i.Organization}`)}]),q=l(()=>o.value==i.AnyoneAnonymous||o.value==i.Organization),b=l(()=>d.list?.sharingSetting?.id??crypto.randomUUID()),w=l(()=>`${location.protocol}//${location.host}/shared-list/${b.value}`),F=Z(ee({name:$().required().max(25),description:$().max(I),sharingScope:$().required()})),{errors:v,meta:n}=ae({validationSchema:F,initialValues:{name:D.value,description:O.value??"",sharingScope:P.value??i.Private},validateOnMount:!0}),{value:r}=S("name"),{value:u}=S("description"),{value:o}=S("sharingScope"),y=l(()=>!!d.list),R=l(()=>n.value.dirty&&n.value.valid);async function X(a){n.value.valid&&(y.value?await z({listId:d.list.id,listName:r.value?.trim(),description:u.value?.trim(),scope:o.value,sharingKey:b.value}):await W({listName:r.value?.trim(),description:u.value?.trim(),scope:o.value,sharingKey:b.value}),a())}async function G(){await U(w.value),L.success({text:_("shared.wishlists.add_or_update_wishlist_modal.clipboard_success"),duration:4e3,single:!0})}return(a,t)=>{const N=c("VcInput"),H=c("VcTextarea"),J=c("VcSelect"),V=c("VcButton"),Q=c("VcModal");return g(),f(Q,{title:y.value?a.$t("shared.wishlists.add_or_update_wishlist_modal.edit_mode_title"):a.$t("shared.wishlists.add_or_update_wishlist_modal.title"),dividers:"","is-mobile-fullscreen":""},{actions:p(({close:s})=>[m(V,{color:"secondary",variant:"outline",onClick:s},{default:p(()=>[T(A(a.$t("shared.wishlists.add_or_update_wishlist_modal.cancel_button")),1)]),_:1},8,["onClick"]),m(V,{loading:e(h),disabled:!R.value,class:"ms-auto",onClick:re=>X(s)},{default:p(()=>[T(A(y.value?a.$t("shared.wishlists.add_or_update_wishlist_modal.save_button"):a.$t("shared.wishlists.add_or_update_wishlist_modal.create_button")),1)]),_:1},8,["loading","disabled","onClick"])]),default:p(()=>[se("div",de,[m(N,{modelValue:e(r),"onUpdate:modelValue":t[0]||(t[0]=s=>C(r)?r.value=s:null),label:a.$t("shared.wishlists.add_or_update_wishlist_modal.list_name_label"),placeholder:a.$t("shared.wishlists.add_or_update_wishlist_modal.list_name_placeholder"),disabled:e(h),message:e(v).name,error:!!e(v).name&&e(n).dirty,required:""},null,8,["modelValue","label","placeholder","disabled","message","error"]),m(H,{modelValue:e(u),"onUpdate:modelValue":t[1]||(t[1]=s=>C(u)?u.value=s:null),label:a.$t("common.labels.description"),disabled:e(h),message:e(v).description,error:!!e(v).description&&e(n).dirty,rows:"4",counter:"","max-length":I},null,8,["modelValue","label","disabled","message","error"]),e(E)?(g(),le("div",ne,[m(J,{modelValue:e(o),"onUpdate:modelValue":t[2]||(t[2]=s=>C(o)?o.value=s:null),label:a.$t("shared.wishlists.add_or_update_wishlist_modal.sharing_scope_label"),placeholder:a.$t("shared.wishlists.add_or_update_wishlist_modal.sharing_scope_placeholder"),disabled:e(h),items:K.value,"text-field":"label","value-field":"id"},null,8,["modelValue","label","placeholder","disabled","items"]),q.value?(g(),f(N,{key:0,modelValue:w.value,"onUpdate:modelValue":t[3]||(t[3]=s=>w.value=s),label:a.$t("shared.wishlists.add_or_update_wishlist_modal.sharing_link_label"),readonly:""},{append:p(()=>[e(B)?(g(),f(V,{key:0,color:"secondary",variant:"solid-light",icon:"document-duplicate","icon-size":"1.25rem",onClick:G})):k("",!0)]),_:1},8,["modelValue","label"])):k("",!0)])):k("",!0)])]),_:1},8,["title"])}}});export{pe as _};
//# sourceMappingURL=add-or-update-wishlist-modal.vue_vue_type_script_setup_true_lang-tVP_nGbN.js.map
