import{M as j,$ as x,bs as J,E as l,aw as S,av as Q,aC as ee,au as $,at as ae,U as c,R as f,O as g,V as p,W as se,X as m,N as le,a8 as k,e,az as C,Z as I,Y as T}from"./vendor-CsGITfgk.js";import{w as ie,c7 as te,a4 as oe,cI as i}from"./index-GCDRvGOr.js";const de={class:"space-y-4"},ne={key:0,class:"space-y-4"},U=250,pe=j({__name:"add-or-update-wishlist-modal",props:{list:{}},setup(A){const d=A,{t:_}=x(),{copy:M,isSupported:B}=J(),O=ie(),z=l(()=>d.list?.name),E=l(()=>d.list?.description),W=l(()=>d.list?.sharingSetting?.scope),{loading:h,createWishlist:D,updateWishlist:L}=te(),{isCorporateMember:P}=oe(),q=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}`)}]),K=l(()=>o.value==i.AnyoneAnonymous||o.value==i.Organization),w=l(()=>d.list?.sharingSetting?.id??crypto.randomUUID()),b=l(()=>`${location.protocol}//${location.host}/shared-list/${w.value}`),R=Q(ee({name:$().required().max(25),description:$().max(U),sharingScope:$().required()})),{errors:v,meta:n}=ae({validationSchema:R,initialValues:{name:z.value,description:E.value??"",sharingScope:W.value??i.Private},validateOnMount:!0}),{value:r}=S("name"),{value:u}=S("description"),{value:o}=S("sharingScope"),y=l(()=>!!d.list),F=l(()=>n.value.dirty&&n.value.valid);async function X(a){n.value.valid&&(y.value?await L({listId:d.list.id,listName:r.value?.trim(),description:u.value?.trim(),scope:o.value,sharingKey:w.value}):await D({listName:r.value?.trim(),description:u.value?.trim(),scope:o.value,sharingKey:w.value}),a())}async function G(){await M(b.value),O.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"),Y=c("VcSelect"),V=c("VcButton"),Z=c("VcModal");return g(),f(Z,{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(()=>[I(T(a.$t("shared.wishlists.add_or_update_wishlist_modal.cancel_button")),1)]),_:1},8,["onClick"]),m(V,{loading:e(h),disabled:!F.value,class:"ms-auto",onClick:re=>X(s)},{default:p(()=>[I(T(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":U},null,8,["modelValue","label","disabled","message","error"]),e(P)?(g(),le("div",ne,[m(Y,{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:q.value,"text-field":"label","value-field":"id"},null,8,["modelValue","label","placeholder","disabled","items"]),K.value?(g(),f(N,{key:0,modelValue:b.value,"onUpdate:modelValue":t[3]||(t[3]=s=>b.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-BKqXJDdj.js.map
