import{K as q,B as r,at as F,aB as L,cf as R,as as C,ar as X,au as f,S as u,P as A,M as k,T as c,U as G,V as m,L as H,a7 as K,b as a,az as S,X as $,W as g}from"./vendor-bSWkQivH.js";import{b$ as y,aD as Q,Q as j}from"./index-Dqv5IkpS.js";const x={class:"space-y-4"},J={key:0},N=250,ae=q({__name:"add-or-update-wishlist-modal",props:{list:{}},setup(B){const l=B,T=r(()=>{var e;return(e=l.list)==null?void 0:e.name}),M=r(()=>{var e;return(e=l.list)==null?void 0:e.description}),I=r(()=>{var e;return((e=l.list)==null?void 0:e.scope)===y.Organization}),{loading:w,createWishlist:U,updateWishlist:W}=Q(),{isCorporateMember:D}=j(),E=F(L({name:C().required().max(25),description:C().max(N),isShared:R()})),{errors:p,meta:i}=X({validationSchema:E,initialValues:{name:T.value,description:M.value??"",isShared:I.value},validateOnMount:!0}),{value:o}=f("name"),{value:d}=f("description"),{value:_}=f("isShared"),b=r(()=>!!l.list),O=r(()=>i.value.dirty&&i.value.valid);async function z(e){var h,v,V,n;if(!i.value.valid)return;const s=_.value?y.Organization:y.Private;b.value?await W({listId:l.list.id,listName:(h=o.value)==null?void 0:h.trim(),description:(v=d.value)==null?void 0:v.trim(),scope:s}):await U({listName:(V=o.value)==null?void 0:V.trim(),description:(n=d.value)==null?void 0:n.trim(),scope:s}),e()}return(e,s)=>{const h=u("VcInput"),v=u("VcTextarea"),V=u("VcSwitch"),n=u("VcButton"),P=u("VcModal");return k(),A(P,{title:b.value?e.$t("shared.wishlists.add_or_update_wishlist_modal.edit_mode_title"):e.$t("shared.wishlists.add_or_update_wishlist_modal.title"),dividers:"","is-mobile-fullscreen":""},{actions:c(({close:t})=>[m(n,{color:"secondary",variant:"outline",onClick:t},{default:c(()=>[$(g(e.$t("shared.wishlists.add_or_update_wishlist_modal.cancel_button")),1)]),_:2},1032,["onClick"]),m(n,{loading:a(w),disabled:!O.value,class:"ms-auto",onClick:Y=>z(t)},{default:c(()=>[$(g(b.value?e.$t("shared.wishlists.add_or_update_wishlist_modal.save_button"):e.$t("shared.wishlists.add_or_update_wishlist_modal.create_button")),1)]),_:2},1032,["loading","disabled","onClick"])]),default:c(()=>[G("div",x,[m(h,{modelValue:a(o),"onUpdate:modelValue":s[0]||(s[0]=t=>S(o)?o.value=t:null),label:e.$t("shared.wishlists.add_or_update_wishlist_modal.list_name_label"),placeholder:e.$t("shared.wishlists.add_or_update_wishlist_modal.list_name_placeholder"),disabled:a(w),message:a(p).name,error:!!a(p).name&&a(i).dirty,required:""},null,8,["modelValue","label","placeholder","disabled","message","error"]),m(v,{modelValue:a(d),"onUpdate:modelValue":s[1]||(s[1]=t=>S(d)?d.value=t:null),label:e.$t("common.labels.description"),disabled:a(w),message:a(p).description,error:!!a(p).description&&a(i).dirty,rows:"4",counter:"","max-length":N},null,8,["modelValue","label","disabled","message","error"]),a(D)?(k(),H("div",J,[m(V,{modelValue:a(_),"onUpdate:modelValue":s[2]||(s[2]=t=>S(_)?_.value=t:null),"label-position":"right"},{default:c(()=>[$(g(e.$t("shared.wishlists.add_or_update_wishlist_modal.make_shared")),1)]),_:1},8,["modelValue"])])):K("",!0)])]),_:1},8,["title"])}}});export{ae as _};
//# sourceMappingURL=add-or-update-wishlist-modal.vue_vue_type_script_setup_true_lang-5VuaMEGR.js.map
