import{F as J,ai as Q,bx as Y,L as Z,aE as ee,M as S,J as ae,m as i,K as $,P as c,_ as f,R as g,a1 as p,T as se,X as m,Q as ie,W as k,e,Y as C,a2 as T,a0 as M}from"./vendor-D8NNcBCx.js";import{a6 as le,cj as l,bM as te,x as oe}from"./index-C3Ufbmof.js";const de={class:"space-y-4"},ne={key:0,class:"space-y-4"},A=250,pe=J({__name:"add-or-update-wishlist-modal",props:{list:{}},setup(I){const d=I,{t:_}=Q(),{copy:U,isSupported:B}=Y(),E=oe(),L=i(()=>d.list?.name),O=i(()=>d.list?.description),P=i(()=>d.list?.sharingSetting?.scope),{loading:h,createWishlist:W,updateWishlist:z}=te(),{isCorporateMember:D}=le(),K=i(()=>[{id:l.Private,label:_(`shared.wishlists.add_or_update_wishlist_modal.sharing_scope.${l.Private}`)},{id:l.AnyoneAnonymous,label:_(`shared.wishlists.add_or_update_wishlist_modal.sharing_scope.${l.AnyoneAnonymous}`)},{id:l.Organization,label:_(`shared.wishlists.add_or_update_wishlist_modal.sharing_scope.${l.Organization}`)}]),q=i(()=>o.value==l.AnyoneAnonymous||o.value==l.Organization),b=i(()=>d.list?.sharingSetting?.id??crypto.randomUUID()),w=i(()=>`${location.protocol}//${location.host}/shared-list/${b.value}`),F=Z(ee({name:S().trim().required().max(25),description:S().max(A),sharingScope:S().required()})),{errors:v,meta:n}=ae({validationSchema:F,initialValues:{name:L.value,description:O.value??"",sharingScope:P.value??l.Private},validateOnMount:!0}),{value:r}=$("name"),{value:u}=$("description"),{value:o}=$("sharingScope"),y=i(()=>!!d.list),R=i(()=>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 X(){await U(w.value),E.success({text:_("shared.wishlists.add_or_update_wishlist_modal.clipboard_success"),duration:4e3,single:!0})}return(a,t)=>{const N=c("VcInput"),j=c("VcTextarea"),G=c("VcSelect"),V=c("VcButton"),H=c("VcModal");return g(),f(H,{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(M(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(M(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(j,{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":A},null,8,["modelValue","label","disabled","message","error"]),e(D)?(g(),ie("div",ne,[m(G,{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:X})):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-B_yXZ19z.js.map
