@oneclick.dev/cms-core-modules 0.0.104 → 0.0.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Acquisition-CPlZzUBo.mjs → Acquisition-B2pM5vSp.mjs} +2 -2
- package/dist/{Acquisition-Br1Pfny3.js → Acquisition-Dt2rREU8.js} +1 -1
- package/dist/{Audience-BfkrmBuQ.js → Audience-Bs7b0TNm.js} +1 -1
- package/dist/{Audience-DTblSAiL.mjs → Audience-VLnUsQvW.mjs} +2 -2
- package/dist/{ContentEditor-B1nfKG_5.mjs → ContentEditor-BNLEv-qJ.mjs} +3119 -3098
- package/dist/{ContentEditor-DdFU8piH.js → ContentEditor-BUvvqfG1.js} +36 -36
- package/dist/{Create-qPeQxkdl.js → Create-89z41K73.js} +1 -1
- package/dist/{Create-BRBh0xjM.mjs → Create-Cn_Eufga.mjs} +5 -1
- package/dist/{Entries-C8UJkrVC.mjs → Entries-BdhUyJR5.mjs} +1 -1
- package/dist/{Entries-BaS6H6ak.js → Entries-CEXM_SkO.js} +1 -1
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Ceoje52V.js +1 -0
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-DMGcRmm-.mjs +1255 -0
- package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-COrK1j0S.js +1 -0
- package/dist/OrderDetailDialog.vue_vue_type_script_setup_true_lang-Vb3q8EVv.mjs +330 -0
- package/dist/{Overview-CpHhuiaV.js → Overview-Bn1Xx3_j.js} +1 -1
- package/dist/{Overview-BrCwozey.js → Overview-DC9io1bk.js} +1 -1
- package/dist/Overview-Di84CsR5.mjs +476 -0
- package/dist/Overview-UoZHUMUz.js +1 -0
- package/dist/{Overview-kaMhsIUq.mjs → Overview-ejh4vUMT.mjs} +3 -3
- package/dist/{Overview-D_T3K6aq.mjs → Overview-lWAyyenp.mjs} +1 -1
- package/dist/ReservationDetailDialog.vue_vue_type_script_setup_true_lang-CuwREvXD.js +349 -0
- package/dist/ReservationDetailDialog.vue_vue_type_script_setup_true_lang-GYNZ_yhD.mjs +3077 -0
- package/dist/{SeoHealth-BzcWd_w7.mjs → SeoHealth-DsbVdd2l.mjs} +3 -3
- package/dist/SeoHealth-az1YuNF2.js +1 -0
- package/dist/{TableView-DXmEF6pY.mjs → TableView-Bm6HaRHm.mjs} +1 -1
- package/dist/{TableView-CPAw3h8g.js → TableView-DQW0A1oG.js} +1 -1
- package/dist/agenda-IOqtALWf.js +1 -0
- package/dist/agenda-neyeLWv-.mjs +1165 -0
- package/dist/cms-core-modules.css +1 -1
- package/dist/{index-C4YUVWzJ.js → index-A2kp8Isi.js} +6 -6
- package/dist/{index-BuzLn4Km.js → index-B5aBwdxY.js} +2 -2
- package/dist/{index-p5Uqu8c2.mjs → index-BRdCrvcz.mjs} +52 -47
- package/dist/{index-D3L8WAJI.js → index-BiT55eU0.js} +2 -2
- package/dist/{index-CMk3uhUt.mjs → index-Bvxc5xv_.mjs} +153 -147
- package/dist/{index-DQYBP8Js.js → index-G7cIlnGN.js} +4 -4
- package/dist/{index-DjDCYQ_6.mjs → index-X6LV64jK.mjs} +102 -101
- package/dist/{index-_2lRVt_k.mjs → index-uOkqO74I.mjs} +105 -107
- package/dist/index-unsDfNYv.mjs +1187 -0
- package/dist/index-vHmvbEwa.js +35 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +14 -14
- package/dist/interpolation-CHn59tIC.js +1 -0
- package/dist/interpolation-w7IRDJwK.mjs +180 -0
- package/dist/orders-C65SlpJy.mjs +618 -0
- package/dist/orders-XVzWAgG1.js +1 -0
- package/dist/src/appointments/components/edit/EventDialog/BookingsList.vue.d.ts +11 -2
- package/dist/src/appointments/components/edit/EventDialog/OrderDetailDialog.vue.d.ts +55 -0
- package/dist/src/appointments/components/edit/EventDialog/ReservationDetailDialog.vue.d.ts +6 -1
- package/dist/src/appointments/components/edit/NewReservationDialog/CustomerInformation.vue.d.ts +10 -0
- package/dist/src/appointments/components/edit/NewReservationDialog/NewReservationDialog.vue.d.ts +25 -1
- package/dist/src/appointments/components/edit/NewReservationDialog/QuickReservationAdder.vue.d.ts +26 -0
- package/dist/src/appointments/components/edit/NewReservationDialog/ReservationLines.vue.d.ts +31 -0
- package/dist/src/appointments/components/edit/dashboard/Timeline.vue.d.ts +3 -1
- package/dist/src/appointments/composables/useHorizontalScroll.d.ts +20 -0
- package/dist/src/lib/interpolation.d.ts +6 -0
- package/package.json +2 -2
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-9Q7TMm4u.mjs +0 -401
- package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-DiNzGl-q.js +0 -1
- package/dist/Overview-BYMrsZjM.mjs +0 -332
- package/dist/Overview-t0pG5xjA.js +0 -1
- package/dist/ReservationDetailDialog.vue_vue_type_script_setup_true_lang-Cz_22Oce.mjs +0 -2927
- package/dist/ReservationDetailDialog.vue_vue_type_script_setup_true_lang-DPPNc-Z5.js +0 -349
- package/dist/SeoHealth-09sEOu3G.js +0 -1
- package/dist/agenda-BNG05SAq.js +0 -1
- package/dist/agenda-D1RxMxBS.mjs +0 -1152
- package/dist/index-BtujSJeg.js +0 -35
- package/dist/index-dOdMm1pV.mjs +0 -1105
- package/dist/interpolation-DEDSLETn.mjs +0 -128
- package/dist/interpolation-DERg6Lwt.js +0 -1
- package/dist/orders-CzzcFQha.mjs +0 -559
- package/dist/orders-ETtbA4aQ.js +0 -1
- package/dist/src/appointments/components/edit/dashboard/BookingsList.vue.d.ts +0 -110
- package/dist/src/appointments/pages/edit/orders.vue.d.ts +0 -98
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),v=require("lucide-vue-next"),w=require("@oneclick.dev/cms-kit"),h=require("./utils-Yd6F5mea.js"),$=require("./DateFormatter-CYAD4GBN.js"),T=require("./index-ijdf0d9-.js"),I=e.defineComponent({__name:"SingleCode",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("Label"),i=e.resolveComponent("Input");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(s,{class:"text-muted-foreground mb-2",for:"code"},{default:e.withCtx(()=>[...a[1]||(a[1]=[e.createTextVNode("Enter the coupon code",-1)])]),_:1}),e.createVNode(i,{modelValue:e.unref(n).code,"onUpdate:modelValue":a[0]||(a[0]=o=>e.unref(n).code=o),id:"code"},null,8,["modelValue"])],64)}}}),L={class:"flex items-center space-x-2"},z={class:"flex items-center space-x-2"},O={key:0,class:"flex items-end w-full gap-4"},j={class:"relative w-full"},G={key:1},R=e.defineComponent({__name:"MultiCodes",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("RadioGroupItem"),i=e.resolveComponent("Label"),o=e.resolveComponent("RadioGroup"),m=e.resolveComponent("NumberFieldDecrement"),g=e.resolveComponent("NumberFieldInput"),u=e.resolveComponent("NumberFieldIncrement"),l=e.resolveComponent("NumberFieldContent"),p=e.resolveComponent("NumberField"),V=e.resolveComponent("Input"),r=e.resolveComponent("Textarea");return e.openBlock(),e.createElementBlock(e.Fragment,null,[a[8]||(a[8]=e.createElementVNode("p",{class:"text-sm text-muted-foreground mb-2"},"How do you want to create the codes?",-1)),e.createVNode(o,{modelValue:e.unref(n).generationMode,"onUpdate:modelValue":a[0]||(a[0]=N=>e.unref(n).generationMode=N),orientation:"vertical",class:"mb-6"},{default:e.withCtx(()=>[e.createElementVNode("div",L,[e.createVNode(s,{id:"generation_mode_generate",value:"generate"}),e.createVNode(i,{for:"generation_mode_generate"},{default:e.withCtx(()=>[...a[3]||(a[3]=[e.createTextVNode("Generate random codes",-1)])]),_:1})]),e.createElementVNode("div",z,[e.createVNode(s,{id:"generation_mode_input",value:"input"}),e.createVNode(i,{for:"generation_mode_input"},{default:e.withCtx(()=>[...a[4]||(a[4]=[e.createTextVNode("Provide specific codes",-1)])]),_:1})])]),_:1},8,["modelValue"]),e.unref(n).generationMode=="generate"?(e.openBlock(),e.createElementBlock("div",O,[e.createVNode(p,{id:"age","default-value":1,min:1,class:"w-full"},{default:e.withCtx(()=>[e.createVNode(i,{for:"age",class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...a[5]||(a[5]=[e.createTextVNode("Number of codes to generate",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m),e.createVNode(g),e.createVNode(u)]),_:1})]),_:1}),e.createElementVNode("div",j,[e.createVNode(V,{modelValue:e.unref(n).prefix,"onUpdate:modelValue":a[1]||(a[1]=N=>e.unref(n).prefix=N),placeholder:"Prefix",class:"pr-42"},null,8,["modelValue"]),a[6]||(a[6]=e.createElementVNode("span",{class:"absolute right-2 top-1/2 transform -translate-y-1/2 text-muted-foreground/80 pointer-events-none"},"- GENERATED CODE",-1))])])):(e.openBlock(),e.createElementBlock("div",G,[e.createVNode(i,{class:"text-muted-foreground mb-2",for:"codes"},{default:e.withCtx(()=>[...a[7]||(a[7]=[e.createTextVNode("Enter the codes you want to create (one per line)",-1)])]),_:1}),e.createVNode(r,{modelValue:e.unref(n).codes,"onUpdate:modelValue":a[2]||(a[2]=N=>e.unref(n).codes=N),id:"codes",class:"max-h-48"},null,8,["modelValue"])]))],64)}}}),J={class:"grid gap-6 py-4"},q={class:"flex items-center"},H={class:"flex items-center gap-2"},Y={class:"flex items-center gap-2"},K={class:"flex items-center gap-2"},W={class:"flex items-center gap-2"},Q={class:"flex items-center space-x-2 mb-2"},X={key:0,class:"text-xs text-blue-600 bg-blue-500/10 p-2 rounded border border-blue-500 mt-1 flex items-start gap-1"},Z={class:"flex items-center space-x-2 mb-2"},ee=e.defineComponent({__name:"TypeDetailDialog",setup(b,{expose:n}){const{isAdmin:_}=w.useModulePermissions(),{getModuleData:a,setModuleData:s}=w.useModuleStorage(),i=e.inject("promoTypes",e.ref([])),o=e.ref({id:"",label:"",key:"",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""}),m=e.ref(!1),g=e.ref("add"),u=e.ref(!1),l=f=>{m.value=!0,u.value=!1,f?(g.value="edit",o.value=JSON.parse(JSON.stringify(f))):(g.value="add",o.value={id:crypto.randomUUID(),label:"",key:"",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""})},p=f=>{m.value=!0,u.value=!1,g.value="add",N(f)},V=async()=>{u.value=!0;let f=await a("promo-types")||[];f.push(JSON.parse(JSON.stringify(o.value))),s("promo-types",f),i.value=JSON.parse(JSON.stringify(f)),m.value=!1},r=async()=>{u.value=!0;let f=await a("promo-types")||[];f=f.map(t=>t.id===o.value.id?o.value:t),s("promo-types",f),i.value=JSON.parse(JSON.stringify(f)),m.value=!1},N=f=>{switch(f){case"fixed":o.value={id:crypto.randomUUID(),label:"Fixed Amount",key:"fixed",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Amount",valuePrefix:"$",valueSuffix:""};break;case"percentage":o.value={id:crypto.randomUUID(),label:"Percentage",key:"percentage",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Percentage",valuePrefix:"",valueSuffix:"%"};break;case"free_shipping":o.value={id:crypto.randomUUID(),label:"Free Shipping",key:"free_shipping",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""};break}};return n({open:l,openFromTemplate:p}),(f,t)=>{const x=e.resolveComponent("DialogTitle"),c=e.resolveComponent("DialogHeader"),k=e.resolveComponent("Button"),U=e.resolveComponent("DropdownMenuTrigger"),y=e.resolveComponent("DropdownMenuItem"),E=e.resolveComponent("DropdownMenuContent"),S=e.resolveComponent("DropdownMenu"),C=e.resolveComponent("Label"),D=e.resolveComponent("Input"),B=e.resolveComponent("Switch"),P=e.resolveComponent("DialogFooter"),F=e.resolveComponent("DialogScrollContent"),M=e.resolveComponent("Dialog");return e.openBlock(),e.createBlock(M,{open:m.value,"onUpdate:open":t[11]||(t[11]=d=>m.value=d)},{default:e.withCtx(()=>[e.unref(_)()?(e.openBlock(),e.createBlock(F,{key:0,class:"sm:max-w-[475px]"},{default:e.withCtx(()=>[e.createVNode(c,null,{default:e.withCtx(()=>[e.createVNode(x,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(g.value==="add"?"Add Promo Type":"Edit Promo Type"),1)]),_:1})]),_:1}),e.createElementVNode("div",J,[e.createElementVNode("div",q,[g.value==="add"?(e.openBlock(),e.createBlock(S,{key:0},{default:e.withCtx(()=>[e.createVNode(U,null,{default:e.withCtx(()=>[e.createVNode(k,{variant:"outline"},{default:e.withCtx(()=>[e.createElementVNode("div",H,[e.createVNode(e.unref(v.Import),{class:"size-4"}),t[12]||(t[12]=e.createTextVNode(" Load pre-defined type ",-1))])]),_:1})]),_:1}),e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(y,{onClick:t[0]||(t[0]=d=>N("fixed"))},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.createVNode(e.unref(v.DollarSign),{class:"size-4"}),t[13]||(t[13]=e.createTextVNode(" Fixed Amount ",-1))])]),_:1}),e.createVNode(y,{onClick:t[1]||(t[1]=d=>N("percentage"))},{default:e.withCtx(()=>[e.createElementVNode("div",K,[e.createVNode(e.unref(v.Percent),{class:"size-4"}),t[14]||(t[14]=e.createTextVNode(" Percentage ",-1))])]),_:1}),e.createVNode(y,{onClick:t[2]||(t[2]=d=>N("free_shipping"))},{default:e.withCtx(()=>[e.createElementVNode("div",W,[e.createVNode(e.unref(v.Truck),{class:"size-4"}),t[15]||(t[15]=e.createTextVNode(" Free Shipping ",-1))])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0)]),e.createElementVNode("div",null,[e.createVNode(C,{for:"label",class:"mb-2"},{default:e.withCtx(()=>[...t[16]||(t[16]=[e.createTextVNode("Display Name",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.label,"onUpdate:modelValue":t[3]||(t[3]=d=>o.value.label=d),id:"label"},null,8,["modelValue"]),t[17]||(t[17]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'Shown in the Studio UI. e.g. "VIP Shipping"',-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"key",class:"mb-2"},{default:e.withCtx(()=>[...t[18]||(t[18]=[e.createTextVNode("Internal Key",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.key,"onUpdate:modelValue":t[4]||(t[4]=d=>o.value.key=d),id:"key"},null,8,["modelValue"]),t[19]||(t[19]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},[e.createTextVNode("Used in logic. Must be unique, lowercase, no spaces. e.g. "),e.createElementVNode("span",{class:"font-mono bg-muted-foreground/20 px-1 py-0.5 rounded"},"vip_shipping")],-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"allowUnlimitedUses",class:"mb-4"},{default:e.withCtx(()=>[...t[20]||(t[20]=[e.createTextVNode("Allow Unlimited Uses",-1)])]),_:1}),e.createElementVNode("div",Q,[e.createVNode(B,{id:"allowUnlimitedUses",modelValue:o.value.allowUnlimitedUses,"onUpdate:modelValue":t[5]||(t[5]=d=>o.value.allowUnlimitedUses=d)},null,8,["modelValue"]),e.createVNode(C,{for:"allowUnlimitedUses"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.value.allowUnlimitedUses?"Yes":"No"),1)]),_:1})]),t[22]||(t[22]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'Show the "Unlimited uses" toggle when creating a promo code.',-1)),o.value.allowUnlimitedUses?(e.openBlock(),e.createElementBlock("p",X,[e.createVNode(e.unref(v.Info),{class:"size-4"}),t[21]||(t[21]=e.createTextVNode(" This option is always hidden when generating multiple codes. ",-1))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",null,[e.createVNode(C,{for:"hasValueField",class:"mb-4"},{default:e.withCtx(()=>[...t[23]||(t[23]=[e.createTextVNode("Has Value Field",-1)])]),_:1}),e.createElementVNode("div",Z,[e.createVNode(B,{id:"hasValueField",modelValue:o.value.hasValueField,"onUpdate:modelValue":t[6]||(t[6]=d=>o.value.hasValueField=d)},null,8,["modelValue"]),e.createVNode(C,{for:"hasValueField"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.value.hasValueField?"Yes":"No"),1)]),_:1})]),t[24]||(t[24]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"Show a numeric value input when using this type.",-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valueLabel",class:"mb-2"},{default:e.withCtx(()=>[...t[25]||(t[25]=[e.createTextVNode("Value Field Label",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valueLabel,"onUpdate:modelValue":t[7]||(t[7]=d=>o.value.valueLabel=d),id:"valueLabel"},null,8,["modelValue"]),t[26]||(t[26]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'e.g. "Gift amount", "Shipping cost"',-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valuePrefix",class:"mb-2"},{default:e.withCtx(()=>[...t[27]||(t[27]=[e.createTextVNode("Value Field Prefix",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valuePrefix,"onUpdate:modelValue":t[8]||(t[8]=d=>o.value.valuePrefix=d),id:"valuePrefix"},null,8,["modelValue"]),t[28]||(t[28]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"e.g. € or $",-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valueSuffix",class:"mb-2"},{default:e.withCtx(()=>[...t[29]||(t[29]=[e.createTextVNode("Value Field Suffix",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valueSuffix,"onUpdate:modelValue":t[9]||(t[9]=d=>o.value.valueSuffix=d),id:"valueSuffix"},null,8,["modelValue"]),t[30]||(t[30]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"e.g. %, credits",-1))])]),e.createVNode(P,null,{default:e.withCtx(()=>[e.createVNode(k,{variant:"outline",onClick:t[10]||(t[10]=d=>m.value=!1)},{default:e.withCtx(()=>[...t[31]||(t[31]=[e.createTextVNode("Cancel",-1)])]),_:1}),g.value==="add"?(e.openBlock(),e.createBlock(k,{key:0,disabled:u.value,onClick:V},{default:e.withCtx(()=>[u.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),t[32]||(t[32]=e.createTextVNode(" Add Type ",-1))]),_:1},8,["disabled"])):(e.openBlock(),e.createBlock(k,{key:1,disabled:u.value,onClick:r},{default:e.withCtx(()=>[u.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),t[33]||(t[33]=e.createTextVNode(" Save Changes ",-1))]),_:1},8,["disabled"]))]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:1},8,["open"])}}}),te={class:"grid gap-4 py-4"},oe={key:0,class:"flex flex-col gap-2 items-center text-muted-foreground border rounded p-4"},le={class:"flex gap-2 items-center"},ne={key:1},ae={class:"flex justify-end w-full mb-2"},re={class:"flex items-center gap-2"},se={class:"flex items-center gap-2"},de={class:"flex items-center gap-2"},ie={class:"flex items-center gap-2"},ue={class:"flex items-center gap-2"},ce={class:"font-mono bg-muted-foreground/20 px-1 py-0.5 rounded"},me=e.defineComponent({__name:"TypeManageDialog",setup(b){const{isAdmin:n}=w.useModulePermissions(),{getModuleData:_,setModuleData:a}=w.useModuleStorage(),{confirm:s}=w.useConfirmation(),i=e.inject("promoTypes",e.ref([])),o=e.useTemplateRef("typeDetailDialog"),m=async u=>{if(!await s(`Are you sure you want to delete the type "${u.label}"?`))return;let p=await _("promo-types")||[];p=p.filter(V=>V.id!==u.id),a("promo-types",p),i.value=JSON.parse(JSON.stringify(p))},g=async()=>{const u=[{id:crypto.randomUUID(),label:"Fixed Amount",key:"fixed",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Amount",valuePrefix:"$",valueSuffix:""},{id:crypto.randomUUID(),label:"Percentage",key:"percentage",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Percentage",valuePrefix:"",valueSuffix:"%"},{id:crypto.randomUUID(),label:"Free Shipping",key:"free_shipping",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""}];a("promo-types",u),i.value=JSON.parse(JSON.stringify(u))};return(u,l)=>{const p=e.resolveComponent("Button"),V=e.resolveComponent("DialogTrigger"),r=e.resolveComponent("DialogTitle"),N=e.resolveComponent("DialogDescription"),f=e.resolveComponent("DialogHeader"),t=e.resolveComponent("DropdownMenuTrigger"),x=e.resolveComponent("DropdownMenuItem"),c=e.resolveComponent("DropdownMenuSeparator"),k=e.resolveComponent("DropdownMenuContent"),U=e.resolveComponent("DropdownMenu"),y=e.resolveComponent("TableHead"),E=e.resolveComponent("TableRow"),S=e.resolveComponent("TableHeader"),C=e.resolveComponent("TableCell"),D=e.resolveComponent("TableBody"),B=e.resolveComponent("Table"),P=e.resolveComponent("DialogFooter"),F=e.resolveComponent("DialogScrollContent"),M=e.resolveComponent("Dialog");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(M,null,{default:e.withCtx(()=>[e.createVNode(V,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[e.createVNode(e.unref(v.UserCog),{class:"size-4"}),l[6]||(l[6]=e.createTextVNode(" Edit Promo Types ",-1))]),_:1})]),_:1}),e.unref(n)()?(e.openBlock(),e.createBlock(F,{key:0,class:"sm:max-w-2xl"},{default:e.withCtx(()=>[e.createVNode(f,null,{default:e.withCtx(()=>[e.createVNode(r,null,{default:e.withCtx(()=>[...l[7]||(l[7]=[e.createTextVNode("Edit Promo Types",-1)])]),_:1}),e.createVNode(N,null,{default:e.withCtx(()=>[...l[8]||(l[8]=[e.createTextVNode(" Define reusable custom promo types to use in discount codes. You can configure how they behave and what fields are shown. ",-1)])]),_:1})]),_:1}),e.createElementVNode("div",te,[e.unref(i).length===0?(e.openBlock(),e.createElementBlock("div",oe,[l[12]||(l[12]=e.createElementVNode("p",null,"You haven't created any custom types yet.",-1)),e.createElementVNode("p",le,[e.createVNode(p,{variant:"link",onClick:l[0]||(l[0]=d=>o.value?.open())},{default:e.withCtx(()=>[...l[9]||(l[9]=[e.createTextVNode("Create a custom type",-1)])]),_:1}),l[11]||(l[11]=e.createTextVNode(" or ",-1)),e.createVNode(p,{variant:"link",onClick:l[1]||(l[1]=d=>g())},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("Import Default Types",-1)])]),_:1})])])):(e.openBlock(),e.createElementBlock("div",ne,[e.createElementVNode("div",ae,[e.createVNode(U,null,{default:e.withCtx(()=>[e.createVNode(t,null,{default:e.withCtx(()=>[e.createVNode(p,{variant:"outline"},{default:e.withCtx(()=>[e.createElementVNode("div",re,[e.createVNode(e.unref(v.Plus),{class:"size-4"}),l[13]||(l[13]=e.createTextVNode(" Create new Promo Type ",-1))])]),_:1})]),_:1}),e.createVNode(k,null,{default:e.withCtx(()=>[e.createVNode(x,{onClick:l[2]||(l[2]=d=>o.value?.open())},{default:e.withCtx(()=>[e.createElementVNode("div",se,[e.createVNode(e.unref(v.Plus),{class:"size-4"}),l[14]||(l[14]=e.createTextVNode(" New Type ",-1))])]),_:1}),e.createVNode(c),e.createVNode(x,{onClick:l[3]||(l[3]=d=>o.value?.openFromTemplate("fixed"))},{default:e.withCtx(()=>[e.createElementVNode("div",de,[e.createVNode(e.unref(v.DollarSign),{class:"size-4"}),l[15]||(l[15]=e.createTextVNode(" Fixed Amount ",-1))])]),_:1}),e.createVNode(x,{onClick:l[4]||(l[4]=d=>o.value?.openFromTemplate("percentage"))},{default:e.withCtx(()=>[e.createElementVNode("div",ie,[e.createVNode(e.unref(v.Percent),{class:"size-4"}),l[16]||(l[16]=e.createTextVNode(" Percentage ",-1))])]),_:1}),e.createVNode(x,{onClick:l[5]||(l[5]=d=>o.value?.openFromTemplate("free_shipping"))},{default:e.withCtx(()=>[e.createElementVNode("div",ue,[e.createVNode(e.unref(v.Truck),{class:"size-4"}),l[17]||(l[17]=e.createTextVNode(" Free Shipping ",-1))])]),_:1})]),_:1})]),_:1})]),e.createVNode(B,null,{default:e.withCtx(()=>[e.createVNode(S,null,{default:e.withCtx(()=>[e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(y,null,{default:e.withCtx(()=>[...l[18]||(l[18]=[e.createTextVNode("Name (label)",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[19]||(l[19]=[e.createTextVNode("Key",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[20]||(l[20]=[e.createTextVNode("Value Field",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[21]||(l[21]=[e.createTextVNode("Unlimited Uses",-1)])]),_:1}),e.createVNode(y,{class:"text-right"},{default:e.withCtx(()=>[...l[22]||(l[22]=[e.createTextVNode("Actions",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(D,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),d=>(e.openBlock(),e.createBlock(E,{key:d.key},{default:e.withCtx(()=>[e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.label),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createElementVNode("span",ce,e.toDisplayString(d.key),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.hasValueField?"Yes":"No"),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.allowUnlimitedUses?"Yes":"No"),1)]),_:2},1024),e.createVNode(C,{class:"text-right"},{default:e.withCtx(()=>[e.createVNode(p,{variant:"ghost",size:"icon",onClick:A=>o.value?.open(d)},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Pencil),{class:"size-4"})]),_:1},8,["onClick"]),e.createVNode(p,{variant:"ghost",size:"icon",onClick:A=>m(d)},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Trash2),{class:"size-4 text-red-500"})]),_:1},8,["onClick"])]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})]))]),e.createVNode(P,null,{default:e.withCtx(()=>[e.createVNode(p,{variant:"outline",disabled:""},{default:e.withCtx(()=>[...l[23]||(l[23]=[e.createTextVNode(" Auto-saved ",-1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:1}),e.createVNode(ee,{ref_key:"typeDetailDialog",ref:o},null,512)],64)}}}),pe={class:"flex justify-between items-center"},fe={class:"grid gap-2"},Ve={class:"flex flex-wrap gap-12"},xe={key:0,class:"grid gap-2"},ve={class:"flex items-center gap-2"},Ne={key:1,class:"grid gap-2"},Ce={class:"flex items-center space-x-2"},ge=e.defineComponent({__name:"index",setup(b){const n=e.inject("newCoupon"),_=e.inject("promoTypes",e.ref([])),a=e.computed(()=>_.value.find(i=>i.key===n.value?.type)||null),{isAdmin:s}=w.useModulePermissions();return(i,o)=>{const m=e.resolveComponent("Label"),g=e.resolveComponent("SelectValue"),u=e.resolveComponent("SelectTrigger"),l=e.resolveComponent("SelectItem"),p=e.resolveComponent("SelectGroup"),V=e.resolveComponent("SelectContent"),r=e.resolveComponent("Select"),N=e.resolveComponent("Input"),f=e.resolveComponent("Switch"),t=e.resolveComponent("Card");return e.openBlock(),e.createBlock(t,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",pe,[o[3]||(o[3]=e.createElementVNode("h2",{class:"font-medium"},"Value",-1)),e.unref(s)()?(e.openBlock(),e.createBlock(me,{key:0})):e.createCommentVNode("",!0)]),e.createElementVNode("div",fe,[e.createVNode(m,{class:"text-muted-foreground"},{default:e.withCtx(()=>[...o[4]||(o[4]=[e.createTextVNode("Promo Type",-1)])]),_:1}),e.createVNode(r,{modelValue:e.unref(n).type,"onUpdate:modelValue":o[0]||(o[0]=x=>e.unref(n).type=x)},{default:e.withCtx(()=>[e.createVNode(u,{class:"w-[200px]"},{default:e.withCtx(()=>[e.createVNode(g,{placeholder:"Select a promo type"})]),_:1}),e.createVNode(V,null,{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),x=>(e.openBlock(),e.createBlock(l,{key:x.key,value:x.key},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.label),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})]),_:1},8,["modelValue"])]),e.createElementVNode("div",Ve,[a.value?.hasValueField?(e.openBlock(),e.createElementBlock("div",xe,[e.createVNode(m,{for:"discountValue",class:"text-muted-foreground"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valueLabel||"Value"),1)]),_:1}),e.createElementVNode("div",ve,[a.value?.valuePrefix?(e.openBlock(),e.createBlock(m,{key:0,for:"discountValue",class:"text-lg"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valuePrefix),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(N,{modelValue:e.unref(n).value,"onUpdate:modelValue":o[1]||(o[1]=x=>e.unref(n).value=x),id:"discountValue"},null,8,["modelValue"]),a.value?.valueSuffix?(e.openBlock(),e.createBlock(m,{key:1,for:"discountValue",class:"text-lg"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valueSuffix),1)]),_:1})):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),a.value?.allowUnlimitedUses&&e.unref(n).creationMode!=="multi"?(e.openBlock(),e.createElementBlock("div",Ne,[e.createVNode(m,{for:"unlimitedUses",class:"text-muted-foreground"},{default:e.withCtx(()=>[...o[5]||(o[5]=[e.createTextVNode("Unlimited Uses",-1)])]),_:1}),e.createElementVNode("div",Ce,[e.createVNode(f,{id:"unlimitedUses",modelValue:e.unref(n).unlimitedUses,"onUpdate:modelValue":o[2]||(o[2]=x=>e.unref(n).unlimitedUses=x)},null,8,["modelValue"]),e.createVNode(m,{for:"unlimitedUses"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n).unlimitedUses?"Yes":"No"),1)]),_:1})])])):e.createCommentVNode("",!0)])]),_:1})}}}),_e={class:"flex gap-4"},we={class:"flex flex-col"},ye={key:0,class:"-ml-2"},ke={key:1,class:"text-xs text-muted-foreground mt-2"},be={class:"flex flex-col"},Te={key:0,class:"-ml-2"},De={key:1,class:"text-xs text-muted-foreground mt-2"},Ue=e.defineComponent({__name:"DateRange",setup(b){const n=e.inject("newCoupon"),_=new $.$12a3c853105e5a70$export$ad991b66133851cf("en-US",{dateStyle:"long"});return(a,s)=>{const i=e.resolveComponent("Label"),o=e.resolveComponent("Button"),m=e.resolveComponent("PopoverTrigger"),g=e.resolveComponent("Calendar"),u=e.resolveComponent("PopoverContent"),l=e.resolveComponent("Popover"),p=e.resolveComponent("Card");return e.openBlock(),e.createBlock(p,{class:"p-4"},{default:e.withCtx(()=>[s[8]||(s[8]=e.createElementVNode("div",null,[e.createElementVNode("h2",{class:"font-medium mb-2"},"Availability"),e.createElementVNode("p",{class:"text-muted-foreground"},"When will this code be available?")],-1)),e.createElementVNode("div",_e,[e.createElementVNode("div",we,[e.createVNode(i,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...s[4]||(s[4]=[e.createTextVNode("Available from",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(o,{variant:"outline",class:e.normalizeClass(e.unref(h.classNames)("w-[280px] justify-start text-left font-normal",!e.unref(n).startsAt&&"text-muted-foreground"))},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(n).startsAt?e.unref(_).format(e.unref(n).startsAt.toDate(e.unref($.$ad063034c8620db8$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class"])]),_:1}),e.createVNode(u,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:e.unref(n).startsAt,"onUpdate:modelValue":s[0]||(s[0]=V=>e.unref(n).startsAt=V),"initial-focus":"",minValue:e.unref($.$ad063034c8620db8$export$d0bdf45af03a6ea3)()},null,8,["modelValue","minValue"])]),_:1})]),_:1}),e.unref(n).startsAt?(e.openBlock(),e.createElementBlock("div",ye,[e.createVNode(o,{onClick:s[1]||(s[1]=V=>e.unref(n).startsAt=void 0),variant:"link"},{default:e.withCtx(()=>[...s[5]||(s[5]=[e.createTextVNode("Clear",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("p",ke,"Not set - codes will be available immediately"))]),e.createElementVNode("div",be,[e.createVNode(i,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...s[6]||(s[6]=[e.createTextVNode("Until",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(o,{variant:"outline",class:e.normalizeClass(e.unref(h.classNames)("w-[280px] justify-start text-left font-normal",!e.unref(n).expiresAt&&"text-muted-foreground"))},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(n).expiresAt?e.unref(_).format(e.unref(n).expiresAt.toDate(e.unref($.$ad063034c8620db8$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class"])]),_:1}),e.createVNode(u,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:e.unref(n).expiresAt,"onUpdate:modelValue":s[2]||(s[2]=V=>e.unref(n).expiresAt=V),"initial-focus":"",minValue:e.unref(n).startsAt},null,8,["modelValue","minValue"])]),_:1})]),_:1}),e.unref(n).expiresAt?(e.openBlock(),e.createElementBlock("div",Te,[e.createVNode(o,{onClick:s[3]||(s[3]=V=>e.unref(n).expiresAt=void 0),variant:"link"},{default:e.withCtx(()=>[...s[7]||(s[7]=[e.createTextVNode("Clear",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("p",De,"Not set - codes will never expire"))])])]),_:1})}}}),Ee=e.defineComponent({__name:"Note",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("Textarea"),i=e.resolveComponent("Card");return e.openBlock(),e.createBlock(i,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",null,[a[1]||(a[1]=e.createElementVNode("h2",{class:"font-medium mb-2"},"Note",-1)),a[2]||(a[2]=e.createElementVNode("p",{class:"text-sm text-muted-foreground mb-2"},"Used internally. It's a good idea to write down why you're creating this promo code.",-1)),e.createVNode(s,{modelValue:e.unref(n).note,"onUpdate:modelValue":a[0]||(a[0]=o=>e.unref(n).note=o)},null,8,["modelValue"])])]),_:1})}}}),Se={class:"relative"},Be={ref:"container",class:"flex flex-col gap-4 w-full max-w-5xl mx-auto"},$e={class:"flex justify-between items-center mb-4"},Pe={class:"w-full max-w-2xl"},Fe={class:"flex items-center space-x-2"},Me={class:"flex items-center space-x-2"},he={class:"flex justify-end w-full"},Ae=e.defineComponent({__name:"Create",props:{config:{type:Object,required:!0}},async setup(b){let n,_;const a=b,{hasPermission:s}=w.useModulePermissions(),{navigateTo:i}=w.useModuleRoute(),{getTimezone:o}=w.useProjectSettings(),{log:m,logError:g}=w.useLogs(),{getModuleData:u,setModuleData:l}=w.useModuleStorage();w.useModuleBreadcrumbs(()=>[]);const p=w.useFirebaseIntegration(a.config.project),V=e.ref(!1),r=e.ref({creationMode:"single",generationMode:"generate",quantity:1,prefix:"",codes:"",code:"",type:void 0,value:void 0,unlimitedUses:!1,startsAt:void 0,expiresAt:void 0,minOrderAmount:0,note:""}),N=e.ref([]);N.value=([n,_]=e.withAsyncContext(()=>u("promo-types")),n=await n,_(),n||[]),e.provide("newCoupon",r),e.provide("promoTypes",N);const f=()=>{if(r.value.creationMode=="single"){if(r.value.code=r.value.code?.trim().toUpperCase(),!r.value.code)return T.toast.error("Please enter a code"),!1}else if(r.value.generationMode=="generate"){if(r.value.prefix=r.value.prefix?.trim().toUpperCase(),!r.value.prefix)return T.toast.error("Please enter a prefix"),!1;if(!r.value.quantity||r.value.quantity<1)return T.toast.error("Generate at least 1 code"),!1}else if(r.value.generationMode=="input"&&(r.value.codes=r.value.codes?.trim().toUpperCase(),!r.value.codes||r.value.codes.length<1))return T.toast.error("Please enter some codes"),!1;return r.value.type?N.value.find(x=>x.key===r.value.type)?.hasValueField&&!r.value.value?(T.toast.error("Please enter a value"),!1):(r.value.creationMode==="multi"&&(r.value.unlimitedUses=!1),!0):(T.toast.error("Please select a type"),!1)},t=async()=>{try{if(!f())return;if(V.value=!0,r.value.creationMode=="single"){let x={code:r.value.code,type:r.value.type,value:r.value.value,minOrderAmount:r.value.minOrderAmount,usageLimit:r.value.unlimitedUses?0:1,usageCount:0,lastUsedAt:null,startsAt:r.value.startsAt?r.value.startsAt.toDate(o()):null,expiresAt:r.value.expiresAt?r.value.expiresAt.toDate(o()):null,disabled:!1,note:r.value.note,createdAt:new Date,updatedAt:new Date};const c=await p.add(a.config.promoCodeCollection,x);m("Promo code created",{id:c.id,code:c.code,note:c.note}),T.toast.success("Promo code created")}}catch{g("Failed to create promo code"),T.toast.error("Failed to create promo code")}finally{V.value=!1}};return(x,c)=>{const k=e.resolveComponent("Button"),U=e.resolveComponent("RadioGroupItem"),y=e.resolveComponent("Label"),E=e.resolveComponent("RadioGroup"),S=e.resolveComponent("Card");return e.openBlock(),e.createElementBlock("div",Se,[e.createElementVNode("div",Be,[e.createElementVNode("div",$e,[c[3]||(c[3]=e.createElementVNode("h1",{class:"text-2xl font-bold"},"New Promo Code",-1)),e.createVNode(k,{onClick:c[0]||(c[0]=C=>e.unref(i)("promo-codes")),variant:"outline",disabled:V.value},{default:e.withCtx(()=>[e.createVNode(e.unref(v.List),{class:"size-4"}),c[2]||(c[2]=e.createTextVNode(" View Promo Codes ",-1))]),_:1},8,["disabled"])]),e.createVNode(S,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",Pe,[c[6]||(c[6]=e.createElementVNode("h2",{class:"font-medium mb-4"},"Codes",-1)),e.createVNode(E,{modelValue:r.value.creationMode,"onUpdate:modelValue":c[1]||(c[1]=C=>r.value.creationMode=C),orientation:"horizontal",class:"mb-6"},{default:e.withCtx(()=>[e.createElementVNode("div",Fe,[e.createVNode(U,{id:"creation_mode_single",value:"single"}),e.createVNode(y,{for:"creation_mode_single"},{default:e.withCtx(()=>[...c[4]||(c[4]=[e.createTextVNode("Create 1 code",-1)])]),_:1})]),e.createElementVNode("div",Me,[e.createVNode(U,{id:"creation_mode_multi",value:"multi"}),e.createVNode(y,{for:"creation_mode_multi"},{default:e.withCtx(()=>[...c[5]||(c[5]=[e.createTextVNode("Create multiple codes",-1)])]),_:1})])]),_:1},8,["modelValue"]),r.value.creationMode=="single"?(e.openBlock(),e.createBlock(I,{key:0})):(e.openBlock(),e.createBlock(R,{key:1}))])]),_:1}),e.createVNode(ge),e.createVNode(Ue),e.createVNode(Ee),e.createElementVNode("div",he,[e.createVNode(k,{disabled:V.value,onClick:t},{default:e.withCtx(()=>[V.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),c[7]||(c[7]=e.createTextVNode(" Create Promo Code ",-1))]),_:1},8,["disabled"])])],512)])}}});exports.default=Ae;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),v=require("lucide-vue-next"),w=require("@oneclick.dev/cms-kit"),h=require("./utils-Yd6F5mea.js"),$=require("./DateFormatter-CYAD4GBN.js"),T=require("./index-ijdf0d9-.js"),I=e.defineComponent({__name:"SingleCode",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("Label"),i=e.resolveComponent("Input");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(s,{class:"text-muted-foreground mb-2",for:"code"},{default:e.withCtx(()=>[...a[1]||(a[1]=[e.createTextVNode("Enter the coupon code",-1)])]),_:1}),e.createVNode(i,{modelValue:e.unref(n).code,"onUpdate:modelValue":a[0]||(a[0]=o=>e.unref(n).code=o),id:"code"},null,8,["modelValue"])],64)}}}),L={class:"flex items-center space-x-2"},z={class:"flex items-center space-x-2"},O={key:0,class:"flex items-end w-full gap-4"},j={class:"relative w-full"},G={key:1},R=e.defineComponent({__name:"MultiCodes",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("RadioGroupItem"),i=e.resolveComponent("Label"),o=e.resolveComponent("RadioGroup"),m=e.resolveComponent("NumberFieldDecrement"),g=e.resolveComponent("NumberFieldInput"),u=e.resolveComponent("NumberFieldIncrement"),l=e.resolveComponent("NumberFieldContent"),p=e.resolveComponent("NumberField"),V=e.resolveComponent("Input"),r=e.resolveComponent("Textarea");return e.openBlock(),e.createElementBlock(e.Fragment,null,[a[8]||(a[8]=e.createElementVNode("p",{class:"text-sm text-muted-foreground mb-2"},"How do you want to create the codes?",-1)),e.createVNode(o,{modelValue:e.unref(n).generationMode,"onUpdate:modelValue":a[0]||(a[0]=N=>e.unref(n).generationMode=N),orientation:"vertical",class:"mb-6"},{default:e.withCtx(()=>[e.createElementVNode("div",L,[e.createVNode(s,{id:"generation_mode_generate",value:"generate"}),e.createVNode(i,{for:"generation_mode_generate"},{default:e.withCtx(()=>[...a[3]||(a[3]=[e.createTextVNode("Generate random codes",-1)])]),_:1})]),e.createElementVNode("div",z,[e.createVNode(s,{id:"generation_mode_input",value:"input"}),e.createVNode(i,{for:"generation_mode_input"},{default:e.withCtx(()=>[...a[4]||(a[4]=[e.createTextVNode("Provide specific codes",-1)])]),_:1})])]),_:1},8,["modelValue"]),e.unref(n).generationMode=="generate"?(e.openBlock(),e.createElementBlock("div",O,[e.createVNode(p,{id:"age","default-value":1,min:1,class:"w-full"},{default:e.withCtx(()=>[e.createVNode(i,{for:"age",class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...a[5]||(a[5]=[e.createTextVNode("Number of codes to generate",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m),e.createVNode(g),e.createVNode(u)]),_:1})]),_:1}),e.createElementVNode("div",j,[e.createVNode(V,{modelValue:e.unref(n).prefix,"onUpdate:modelValue":a[1]||(a[1]=N=>e.unref(n).prefix=N),placeholder:"Prefix",class:"pr-42"},null,8,["modelValue"]),a[6]||(a[6]=e.createElementVNode("span",{class:"absolute right-2 top-1/2 transform -translate-y-1/2 text-muted-foreground/80 pointer-events-none"},"- GENERATED CODE",-1))])])):(e.openBlock(),e.createElementBlock("div",G,[e.createVNode(i,{class:"text-muted-foreground mb-2",for:"codes"},{default:e.withCtx(()=>[...a[7]||(a[7]=[e.createTextVNode("Enter the codes you want to create (one per line)",-1)])]),_:1}),e.createVNode(r,{modelValue:e.unref(n).codes,"onUpdate:modelValue":a[2]||(a[2]=N=>e.unref(n).codes=N),id:"codes",class:"max-h-48"},null,8,["modelValue"])]))],64)}}}),J={class:"grid gap-6 py-4"},q={class:"flex items-center"},H={class:"flex items-center gap-2"},Y={class:"flex items-center gap-2"},K={class:"flex items-center gap-2"},W={class:"flex items-center gap-2"},Q={class:"flex items-center space-x-2 mb-2"},X={key:0,class:"text-xs text-blue-600 bg-blue-500/10 p-2 rounded border border-blue-500 mt-1 flex items-start gap-1"},Z={class:"flex items-center space-x-2 mb-2"},ee=e.defineComponent({__name:"TypeDetailDialog",setup(b,{expose:n}){const{isAdmin:_}=w.useModulePermissions(),{getModuleData:a,setModuleData:s}=w.useModuleStorage(),i=e.inject("promoTypes",e.ref([])),o=e.ref({id:"",label:"",key:"",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""}),m=e.ref(!1),g=e.ref("add"),u=e.ref(!1),l=f=>{m.value=!0,u.value=!1,f?(g.value="edit",o.value=JSON.parse(JSON.stringify(f))):(g.value="add",o.value={id:crypto.randomUUID(),label:"",key:"",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""})},p=f=>{m.value=!0,u.value=!1,g.value="add",N(f)},V=async()=>{u.value=!0;let f=await a("promo-types")||[];f.push(JSON.parse(JSON.stringify(o.value))),s("promo-types",f),i.value=JSON.parse(JSON.stringify(f)),m.value=!1},r=async()=>{u.value=!0;let f=await a("promo-types")||[];f=f.map(t=>t.id===o.value.id?o.value:t),s("promo-types",f),i.value=JSON.parse(JSON.stringify(f)),m.value=!1},N=f=>{switch(f){case"fixed":o.value={id:crypto.randomUUID(),label:"Fixed Amount",key:"fixed",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Amount",valuePrefix:"$",valueSuffix:""};break;case"percentage":o.value={id:crypto.randomUUID(),label:"Percentage",key:"percentage",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Percentage",valuePrefix:"",valueSuffix:"%"};break;case"free_shipping":o.value={id:crypto.randomUUID(),label:"Free Shipping",key:"free_shipping",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""};break}};return n({open:l,openFromTemplate:p}),(f,t)=>{const x=e.resolveComponent("DialogTitle"),c=e.resolveComponent("DialogHeader"),k=e.resolveComponent("Button"),U=e.resolveComponent("DropdownMenuTrigger"),y=e.resolveComponent("DropdownMenuItem"),E=e.resolveComponent("DropdownMenuContent"),S=e.resolveComponent("DropdownMenu"),C=e.resolveComponent("Label"),D=e.resolveComponent("Input"),B=e.resolveComponent("Switch"),P=e.resolveComponent("DialogFooter"),F=e.resolveComponent("DialogScrollContent"),M=e.resolveComponent("Dialog");return e.openBlock(),e.createBlock(M,{open:m.value,"onUpdate:open":t[11]||(t[11]=d=>m.value=d)},{default:e.withCtx(()=>[e.unref(_)()?(e.openBlock(),e.createBlock(F,{key:0,class:"sm:max-w-[475px]"},{default:e.withCtx(()=>[e.createVNode(c,null,{default:e.withCtx(()=>[e.createVNode(x,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(g.value==="add"?"Add Promo Type":"Edit Promo Type"),1)]),_:1})]),_:1}),e.createElementVNode("div",J,[e.createElementVNode("div",q,[g.value==="add"?(e.openBlock(),e.createBlock(S,{key:0},{default:e.withCtx(()=>[e.createVNode(U,null,{default:e.withCtx(()=>[e.createVNode(k,{variant:"outline"},{default:e.withCtx(()=>[e.createElementVNode("div",H,[e.createVNode(e.unref(v.Import),{class:"size-4"}),t[12]||(t[12]=e.createTextVNode(" Load pre-defined type ",-1))])]),_:1})]),_:1}),e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(y,{onClick:t[0]||(t[0]=d=>N("fixed"))},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.createVNode(e.unref(v.DollarSign),{class:"size-4"}),t[13]||(t[13]=e.createTextVNode(" Fixed Amount ",-1))])]),_:1}),e.createVNode(y,{onClick:t[1]||(t[1]=d=>N("percentage"))},{default:e.withCtx(()=>[e.createElementVNode("div",K,[e.createVNode(e.unref(v.Percent),{class:"size-4"}),t[14]||(t[14]=e.createTextVNode(" Percentage ",-1))])]),_:1}),e.createVNode(y,{onClick:t[2]||(t[2]=d=>N("free_shipping"))},{default:e.withCtx(()=>[e.createElementVNode("div",W,[e.createVNode(e.unref(v.Truck),{class:"size-4"}),t[15]||(t[15]=e.createTextVNode(" Free Shipping ",-1))])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0)]),e.createElementVNode("div",null,[e.createVNode(C,{for:"label",class:"mb-2"},{default:e.withCtx(()=>[...t[16]||(t[16]=[e.createTextVNode("Display Name",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.label,"onUpdate:modelValue":t[3]||(t[3]=d=>o.value.label=d),id:"label"},null,8,["modelValue"]),t[17]||(t[17]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'Shown in the Studio UI. e.g. "VIP Shipping"',-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"key",class:"mb-2"},{default:e.withCtx(()=>[...t[18]||(t[18]=[e.createTextVNode("Internal Key",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.key,"onUpdate:modelValue":t[4]||(t[4]=d=>o.value.key=d),id:"key"},null,8,["modelValue"]),t[19]||(t[19]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},[e.createTextVNode("Used in logic. Must be unique, lowercase, no spaces. e.g. "),e.createElementVNode("span",{class:"font-mono bg-muted-foreground/20 px-1 py-0.5 rounded"},"vip_shipping")],-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"allowUnlimitedUses",class:"mb-4"},{default:e.withCtx(()=>[...t[20]||(t[20]=[e.createTextVNode("Allow Unlimited Uses",-1)])]),_:1}),e.createElementVNode("div",Q,[e.createVNode(B,{id:"allowUnlimitedUses",modelValue:o.value.allowUnlimitedUses,"onUpdate:modelValue":t[5]||(t[5]=d=>o.value.allowUnlimitedUses=d)},null,8,["modelValue"]),e.createVNode(C,{for:"allowUnlimitedUses"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.value.allowUnlimitedUses?"Yes":"No"),1)]),_:1})]),t[22]||(t[22]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'Show the "Unlimited uses" toggle when creating a promo code.',-1)),o.value.allowUnlimitedUses?(e.openBlock(),e.createElementBlock("p",X,[e.createVNode(e.unref(v.Info),{class:"size-4"}),t[21]||(t[21]=e.createTextVNode(" This option is always hidden when generating multiple codes. ",-1))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",null,[e.createVNode(C,{for:"hasValueField",class:"mb-4"},{default:e.withCtx(()=>[...t[23]||(t[23]=[e.createTextVNode("Has Value Field",-1)])]),_:1}),e.createElementVNode("div",Z,[e.createVNode(B,{id:"hasValueField",modelValue:o.value.hasValueField,"onUpdate:modelValue":t[6]||(t[6]=d=>o.value.hasValueField=d)},null,8,["modelValue"]),e.createVNode(C,{for:"hasValueField"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.value.hasValueField?"Yes":"No"),1)]),_:1})]),t[24]||(t[24]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"Show a numeric value input when using this type.",-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valueLabel",class:"mb-2"},{default:e.withCtx(()=>[...t[25]||(t[25]=[e.createTextVNode("Value Field Label",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valueLabel,"onUpdate:modelValue":t[7]||(t[7]=d=>o.value.valueLabel=d),id:"valueLabel"},null,8,["modelValue"]),t[26]||(t[26]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'e.g. "Gift amount", "Shipping cost"',-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valuePrefix",class:"mb-2"},{default:e.withCtx(()=>[...t[27]||(t[27]=[e.createTextVNode("Value Field Prefix",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valuePrefix,"onUpdate:modelValue":t[8]||(t[8]=d=>o.value.valuePrefix=d),id:"valuePrefix"},null,8,["modelValue"]),t[28]||(t[28]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"e.g. € or $",-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valueSuffix",class:"mb-2"},{default:e.withCtx(()=>[...t[29]||(t[29]=[e.createTextVNode("Value Field Suffix",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valueSuffix,"onUpdate:modelValue":t[9]||(t[9]=d=>o.value.valueSuffix=d),id:"valueSuffix"},null,8,["modelValue"]),t[30]||(t[30]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"e.g. %, credits",-1))])]),e.createVNode(P,null,{default:e.withCtx(()=>[e.createVNode(k,{variant:"outline",onClick:t[10]||(t[10]=d=>m.value=!1)},{default:e.withCtx(()=>[...t[31]||(t[31]=[e.createTextVNode("Cancel",-1)])]),_:1}),g.value==="add"?(e.openBlock(),e.createBlock(k,{key:0,disabled:u.value,onClick:V},{default:e.withCtx(()=>[u.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),t[32]||(t[32]=e.createTextVNode(" Add Type ",-1))]),_:1},8,["disabled"])):(e.openBlock(),e.createBlock(k,{key:1,disabled:u.value,onClick:r},{default:e.withCtx(()=>[u.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),t[33]||(t[33]=e.createTextVNode(" Save Changes ",-1))]),_:1},8,["disabled"]))]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:1},8,["open"])}}}),te={class:"grid gap-4 py-4"},oe={key:0,class:"flex flex-col gap-2 items-center text-muted-foreground border rounded p-4"},le={class:"flex gap-2 items-center"},ne={key:1},ae={class:"flex justify-end w-full mb-2"},re={class:"flex items-center gap-2"},se={class:"flex items-center gap-2"},de={class:"flex items-center gap-2"},ie={class:"flex items-center gap-2"},ue={class:"flex items-center gap-2"},ce={class:"font-mono bg-muted-foreground/20 px-1 py-0.5 rounded"},me=e.defineComponent({__name:"TypeManageDialog",setup(b){const{isAdmin:n}=w.useModulePermissions(),{getModuleData:_,setModuleData:a}=w.useModuleStorage(),{confirm:s}=w.useConfirmation(),i=e.inject("promoTypes",e.ref([])),o=e.useTemplateRef("typeDetailDialog"),m=async u=>{if(!await s(`Are you sure you want to delete the type "${u.label}"?`))return;let p=await _("promo-types")||[];p=p.filter(V=>V.id!==u.id),a("promo-types",p),i.value=JSON.parse(JSON.stringify(p))},g=async()=>{const u=[{id:crypto.randomUUID(),label:"Fixed Amount",key:"fixed",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Amount",valuePrefix:"$",valueSuffix:""},{id:crypto.randomUUID(),label:"Percentage",key:"percentage",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Percentage",valuePrefix:"",valueSuffix:"%"},{id:crypto.randomUUID(),label:"Free Shipping",key:"free_shipping",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""}];a("promo-types",u),i.value=JSON.parse(JSON.stringify(u))};return(u,l)=>{const p=e.resolveComponent("Button"),V=e.resolveComponent("DialogTrigger"),r=e.resolveComponent("DialogTitle"),N=e.resolveComponent("DialogDescription"),f=e.resolveComponent("DialogHeader"),t=e.resolveComponent("DropdownMenuTrigger"),x=e.resolveComponent("DropdownMenuItem"),c=e.resolveComponent("DropdownMenuSeparator"),k=e.resolveComponent("DropdownMenuContent"),U=e.resolveComponent("DropdownMenu"),y=e.resolveComponent("TableHead"),E=e.resolveComponent("TableRow"),S=e.resolveComponent("TableHeader"),C=e.resolveComponent("TableCell"),D=e.resolveComponent("TableBody"),B=e.resolveComponent("Table"),P=e.resolveComponent("DialogFooter"),F=e.resolveComponent("DialogScrollContent"),M=e.resolveComponent("Dialog");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(M,null,{default:e.withCtx(()=>[e.createVNode(V,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[e.createVNode(e.unref(v.UserCog),{class:"size-4"}),l[6]||(l[6]=e.createTextVNode(" Edit Promo Types ",-1))]),_:1})]),_:1}),e.unref(n)()?(e.openBlock(),e.createBlock(F,{key:0,class:"sm:max-w-2xl"},{default:e.withCtx(()=>[e.createVNode(f,null,{default:e.withCtx(()=>[e.createVNode(r,null,{default:e.withCtx(()=>[...l[7]||(l[7]=[e.createTextVNode("Edit Promo Types",-1)])]),_:1}),e.createVNode(N,null,{default:e.withCtx(()=>[...l[8]||(l[8]=[e.createTextVNode(" Define reusable custom promo types to use in discount codes. You can configure how they behave and what fields are shown. ",-1)])]),_:1})]),_:1}),e.createElementVNode("div",te,[e.unref(i).length===0?(e.openBlock(),e.createElementBlock("div",oe,[l[12]||(l[12]=e.createElementVNode("p",null,"You haven't created any custom types yet.",-1)),e.createElementVNode("p",le,[e.createVNode(p,{variant:"link",onClick:l[0]||(l[0]=d=>o.value?.open())},{default:e.withCtx(()=>[...l[9]||(l[9]=[e.createTextVNode("Create a custom type",-1)])]),_:1}),l[11]||(l[11]=e.createTextVNode(" or ",-1)),e.createVNode(p,{variant:"link",onClick:l[1]||(l[1]=d=>g())},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("Import Default Types",-1)])]),_:1})])])):(e.openBlock(),e.createElementBlock("div",ne,[e.createElementVNode("div",ae,[e.createVNode(U,null,{default:e.withCtx(()=>[e.createVNode(t,null,{default:e.withCtx(()=>[e.createVNode(p,{variant:"outline"},{default:e.withCtx(()=>[e.createElementVNode("div",re,[e.createVNode(e.unref(v.Plus),{class:"size-4"}),l[13]||(l[13]=e.createTextVNode(" Create new Promo Type ",-1))])]),_:1})]),_:1}),e.createVNode(k,null,{default:e.withCtx(()=>[e.createVNode(x,{onClick:l[2]||(l[2]=d=>o.value?.open())},{default:e.withCtx(()=>[e.createElementVNode("div",se,[e.createVNode(e.unref(v.Plus),{class:"size-4"}),l[14]||(l[14]=e.createTextVNode(" New Type ",-1))])]),_:1}),e.createVNode(c),e.createVNode(x,{onClick:l[3]||(l[3]=d=>o.value?.openFromTemplate("fixed"))},{default:e.withCtx(()=>[e.createElementVNode("div",de,[e.createVNode(e.unref(v.DollarSign),{class:"size-4"}),l[15]||(l[15]=e.createTextVNode(" Fixed Amount ",-1))])]),_:1}),e.createVNode(x,{onClick:l[4]||(l[4]=d=>o.value?.openFromTemplate("percentage"))},{default:e.withCtx(()=>[e.createElementVNode("div",ie,[e.createVNode(e.unref(v.Percent),{class:"size-4"}),l[16]||(l[16]=e.createTextVNode(" Percentage ",-1))])]),_:1}),e.createVNode(x,{onClick:l[5]||(l[5]=d=>o.value?.openFromTemplate("free_shipping"))},{default:e.withCtx(()=>[e.createElementVNode("div",ue,[e.createVNode(e.unref(v.Truck),{class:"size-4"}),l[17]||(l[17]=e.createTextVNode(" Free Shipping ",-1))])]),_:1})]),_:1})]),_:1})]),e.createVNode(B,null,{default:e.withCtx(()=>[e.createVNode(S,null,{default:e.withCtx(()=>[e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(y,null,{default:e.withCtx(()=>[...l[18]||(l[18]=[e.createTextVNode("Name (label)",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[19]||(l[19]=[e.createTextVNode("Key",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[20]||(l[20]=[e.createTextVNode("Value Field",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[21]||(l[21]=[e.createTextVNode("Unlimited Uses",-1)])]),_:1}),e.createVNode(y,{class:"text-right"},{default:e.withCtx(()=>[...l[22]||(l[22]=[e.createTextVNode("Actions",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(D,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),d=>(e.openBlock(),e.createBlock(E,{key:d.key},{default:e.withCtx(()=>[e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.label),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createElementVNode("span",ce,e.toDisplayString(d.key),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.hasValueField?"Yes":"No"),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.allowUnlimitedUses?"Yes":"No"),1)]),_:2},1024),e.createVNode(C,{class:"text-right"},{default:e.withCtx(()=>[e.createVNode(p,{variant:"ghost",size:"icon",onClick:A=>o.value?.open(d)},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Pencil),{class:"size-4"})]),_:1},8,["onClick"]),e.createVNode(p,{variant:"ghost",size:"icon",onClick:A=>m(d)},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Trash2),{class:"size-4 text-red-500"})]),_:1},8,["onClick"])]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})]))]),e.createVNode(P,null,{default:e.withCtx(()=>[e.createVNode(p,{variant:"outline",disabled:""},{default:e.withCtx(()=>[...l[23]||(l[23]=[e.createTextVNode(" Auto-saved ",-1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:1}),e.createVNode(ee,{ref_key:"typeDetailDialog",ref:o},null,512)],64)}}}),pe={class:"flex justify-between items-center"},fe={class:"grid gap-2"},Ve={class:"flex flex-wrap gap-12"},xe={key:0,class:"grid gap-2"},ve={class:"flex items-center gap-2"},Ne={key:1,class:"grid gap-2"},Ce={class:"flex items-center space-x-2"},ge=e.defineComponent({__name:"index",setup(b){const n=e.inject("newCoupon"),_=e.inject("promoTypes",e.ref([])),a=e.computed(()=>_.value.find(i=>i.key===n.value?.type)||null),{isAdmin:s}=w.useModulePermissions();return(i,o)=>{const m=e.resolveComponent("Label"),g=e.resolveComponent("SelectValue"),u=e.resolveComponent("SelectTrigger"),l=e.resolveComponent("SelectItem"),p=e.resolveComponent("SelectGroup"),V=e.resolveComponent("SelectContent"),r=e.resolveComponent("Select"),N=e.resolveComponent("Input"),f=e.resolveComponent("Switch"),t=e.resolveComponent("Card");return e.openBlock(),e.createBlock(t,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",pe,[o[3]||(o[3]=e.createElementVNode("h2",{class:"font-medium"},"Value",-1)),e.unref(s)()?(e.openBlock(),e.createBlock(me,{key:0})):e.createCommentVNode("",!0)]),e.createElementVNode("div",fe,[e.createVNode(m,{class:"text-muted-foreground"},{default:e.withCtx(()=>[...o[4]||(o[4]=[e.createTextVNode("Promo Type",-1)])]),_:1}),e.createVNode(r,{modelValue:e.unref(n).type,"onUpdate:modelValue":o[0]||(o[0]=x=>e.unref(n).type=x)},{default:e.withCtx(()=>[e.createVNode(u,{class:"w-[200px]"},{default:e.withCtx(()=>[e.createVNode(g,{placeholder:"Select a promo type"})]),_:1}),e.createVNode(V,null,{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),x=>(e.openBlock(),e.createBlock(l,{key:x.key,value:x.key},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.label),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})]),_:1},8,["modelValue"])]),e.createElementVNode("div",Ve,[a.value?.hasValueField?(e.openBlock(),e.createElementBlock("div",xe,[e.createVNode(m,{for:"discountValue",class:"text-muted-foreground"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valueLabel||"Value"),1)]),_:1}),e.createElementVNode("div",ve,[a.value?.valuePrefix?(e.openBlock(),e.createBlock(m,{key:0,for:"discountValue",class:"text-lg"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valuePrefix),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(N,{modelValue:e.unref(n).value,"onUpdate:modelValue":o[1]||(o[1]=x=>e.unref(n).value=x),modelModifiers:{number:!0},id:"discountValue",type:"number",class:"no-spinner",min:"0"},null,8,["modelValue"]),a.value?.valueSuffix?(e.openBlock(),e.createBlock(m,{key:1,for:"discountValue",class:"text-lg"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valueSuffix),1)]),_:1})):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),a.value?.allowUnlimitedUses&&e.unref(n).creationMode!=="multi"?(e.openBlock(),e.createElementBlock("div",Ne,[e.createVNode(m,{for:"unlimitedUses",class:"text-muted-foreground"},{default:e.withCtx(()=>[...o[5]||(o[5]=[e.createTextVNode("Unlimited Uses",-1)])]),_:1}),e.createElementVNode("div",Ce,[e.createVNode(f,{id:"unlimitedUses",modelValue:e.unref(n).unlimitedUses,"onUpdate:modelValue":o[2]||(o[2]=x=>e.unref(n).unlimitedUses=x)},null,8,["modelValue"]),e.createVNode(m,{for:"unlimitedUses"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n).unlimitedUses?"Yes":"No"),1)]),_:1})])])):e.createCommentVNode("",!0)])]),_:1})}}}),_e={class:"flex gap-4"},we={class:"flex flex-col"},ye={key:0,class:"-ml-2"},ke={key:1,class:"text-xs text-muted-foreground mt-2"},be={class:"flex flex-col"},Te={key:0,class:"-ml-2"},De={key:1,class:"text-xs text-muted-foreground mt-2"},Ue=e.defineComponent({__name:"DateRange",setup(b){const n=e.inject("newCoupon"),_=new $.$12a3c853105e5a70$export$ad991b66133851cf("en-US",{dateStyle:"long"});return(a,s)=>{const i=e.resolveComponent("Label"),o=e.resolveComponent("Button"),m=e.resolveComponent("PopoverTrigger"),g=e.resolveComponent("Calendar"),u=e.resolveComponent("PopoverContent"),l=e.resolveComponent("Popover"),p=e.resolveComponent("Card");return e.openBlock(),e.createBlock(p,{class:"p-4"},{default:e.withCtx(()=>[s[8]||(s[8]=e.createElementVNode("div",null,[e.createElementVNode("h2",{class:"font-medium mb-2"},"Availability"),e.createElementVNode("p",{class:"text-muted-foreground"},"When will this code be available?")],-1)),e.createElementVNode("div",_e,[e.createElementVNode("div",we,[e.createVNode(i,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...s[4]||(s[4]=[e.createTextVNode("Available from",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(o,{variant:"outline",class:e.normalizeClass(e.unref(h.classNames)("w-[280px] justify-start text-left font-normal",!e.unref(n).startsAt&&"text-muted-foreground"))},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(n).startsAt?e.unref(_).format(e.unref(n).startsAt.toDate(e.unref($.$ad063034c8620db8$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class"])]),_:1}),e.createVNode(u,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:e.unref(n).startsAt,"onUpdate:modelValue":s[0]||(s[0]=V=>e.unref(n).startsAt=V),"initial-focus":"",minValue:e.unref($.$ad063034c8620db8$export$d0bdf45af03a6ea3)()},null,8,["modelValue","minValue"])]),_:1})]),_:1}),e.unref(n).startsAt?(e.openBlock(),e.createElementBlock("div",ye,[e.createVNode(o,{onClick:s[1]||(s[1]=V=>e.unref(n).startsAt=void 0),variant:"link"},{default:e.withCtx(()=>[...s[5]||(s[5]=[e.createTextVNode("Clear",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("p",ke,"Not set - codes will be available immediately"))]),e.createElementVNode("div",be,[e.createVNode(i,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...s[6]||(s[6]=[e.createTextVNode("Until",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(o,{variant:"outline",class:e.normalizeClass(e.unref(h.classNames)("w-[280px] justify-start text-left font-normal",!e.unref(n).expiresAt&&"text-muted-foreground"))},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(n).expiresAt?e.unref(_).format(e.unref(n).expiresAt.toDate(e.unref($.$ad063034c8620db8$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class"])]),_:1}),e.createVNode(u,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:e.unref(n).expiresAt,"onUpdate:modelValue":s[2]||(s[2]=V=>e.unref(n).expiresAt=V),"initial-focus":"",minValue:e.unref(n).startsAt},null,8,["modelValue","minValue"])]),_:1})]),_:1}),e.unref(n).expiresAt?(e.openBlock(),e.createElementBlock("div",Te,[e.createVNode(o,{onClick:s[3]||(s[3]=V=>e.unref(n).expiresAt=void 0),variant:"link"},{default:e.withCtx(()=>[...s[7]||(s[7]=[e.createTextVNode("Clear",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("p",De,"Not set - codes will never expire"))])])]),_:1})}}}),Ee=e.defineComponent({__name:"Note",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("Textarea"),i=e.resolveComponent("Card");return e.openBlock(),e.createBlock(i,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",null,[a[1]||(a[1]=e.createElementVNode("h2",{class:"font-medium mb-2"},"Note",-1)),a[2]||(a[2]=e.createElementVNode("p",{class:"text-sm text-muted-foreground mb-2"},"Used internally. It's a good idea to write down why you're creating this promo code.",-1)),e.createVNode(s,{modelValue:e.unref(n).note,"onUpdate:modelValue":a[0]||(a[0]=o=>e.unref(n).note=o)},null,8,["modelValue"])])]),_:1})}}}),Se={class:"relative"},Be={ref:"container",class:"flex flex-col gap-4 w-full max-w-5xl mx-auto"},$e={class:"flex justify-between items-center mb-4"},Pe={class:"w-full max-w-2xl"},Fe={class:"flex items-center space-x-2"},Me={class:"flex items-center space-x-2"},he={class:"flex justify-end w-full"},Ae=e.defineComponent({__name:"Create",props:{config:{type:Object,required:!0}},async setup(b){let n,_;const a=b,{hasPermission:s}=w.useModulePermissions(),{navigateTo:i}=w.useModuleRoute(),{getTimezone:o}=w.useProjectSettings(),{log:m,logError:g}=w.useLogs(),{getModuleData:u,setModuleData:l}=w.useModuleStorage();w.useModuleBreadcrumbs(()=>[]);const p=w.useFirebaseIntegration(a.config.project),V=e.ref(!1),r=e.ref({creationMode:"single",generationMode:"generate",quantity:1,prefix:"",codes:"",code:"",type:void 0,value:void 0,unlimitedUses:!1,startsAt:void 0,expiresAt:void 0,minOrderAmount:0,note:""}),N=e.ref([]);N.value=([n,_]=e.withAsyncContext(()=>u("promo-types")),n=await n,_(),n||[]),e.provide("newCoupon",r),e.provide("promoTypes",N);const f=()=>{if(r.value.creationMode=="single"){if(r.value.code=r.value.code?.trim().toUpperCase(),!r.value.code)return T.toast.error("Please enter a code"),!1}else if(r.value.generationMode=="generate"){if(r.value.prefix=r.value.prefix?.trim().toUpperCase(),!r.value.prefix)return T.toast.error("Please enter a prefix"),!1;if(!r.value.quantity||r.value.quantity<1)return T.toast.error("Generate at least 1 code"),!1}else if(r.value.generationMode=="input"&&(r.value.codes=r.value.codes?.trim().toUpperCase(),!r.value.codes||r.value.codes.length<1))return T.toast.error("Please enter some codes"),!1;return r.value.type?N.value.find(x=>x.key===r.value.type)?.hasValueField&&!r.value.value?(T.toast.error("Please enter a value"),!1):(r.value.creationMode==="multi"&&(r.value.unlimitedUses=!1),!0):(T.toast.error("Please select a type"),!1)},t=async()=>{try{if(!f())return;if(V.value=!0,r.value.creationMode=="single"){let x={code:r.value.code,type:r.value.type,value:r.value.value,minOrderAmount:r.value.minOrderAmount,usageLimit:r.value.unlimitedUses?0:1,usageCount:0,lastUsedAt:null,startsAt:r.value.startsAt?r.value.startsAt.toDate(o()):null,expiresAt:r.value.expiresAt?r.value.expiresAt.toDate(o()):null,disabled:!1,note:r.value.note,createdAt:new Date,updatedAt:new Date};const c=await p.add(a.config.promoCodeCollection,x);m("Promo code created",{id:c.id,code:c.code,note:c.note}),T.toast.success("Promo code created")}}catch{g("Failed to create promo code"),T.toast.error("Failed to create promo code")}finally{V.value=!1}};return(x,c)=>{const k=e.resolveComponent("Button"),U=e.resolveComponent("RadioGroupItem"),y=e.resolveComponent("Label"),E=e.resolveComponent("RadioGroup"),S=e.resolveComponent("Card");return e.openBlock(),e.createElementBlock("div",Se,[e.createElementVNode("div",Be,[e.createElementVNode("div",$e,[c[3]||(c[3]=e.createElementVNode("h1",{class:"text-2xl font-bold"},"New Promo Code",-1)),e.createVNode(k,{onClick:c[0]||(c[0]=C=>e.unref(i)("promo-codes")),variant:"outline",disabled:V.value},{default:e.withCtx(()=>[e.createVNode(e.unref(v.List),{class:"size-4"}),c[2]||(c[2]=e.createTextVNode(" View Promo Codes ",-1))]),_:1},8,["disabled"])]),e.createVNode(S,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",Pe,[c[6]||(c[6]=e.createElementVNode("h2",{class:"font-medium mb-4"},"Codes",-1)),e.createVNode(E,{modelValue:r.value.creationMode,"onUpdate:modelValue":c[1]||(c[1]=C=>r.value.creationMode=C),orientation:"horizontal",class:"mb-6"},{default:e.withCtx(()=>[e.createElementVNode("div",Fe,[e.createVNode(U,{id:"creation_mode_single",value:"single"}),e.createVNode(y,{for:"creation_mode_single"},{default:e.withCtx(()=>[...c[4]||(c[4]=[e.createTextVNode("Create 1 code",-1)])]),_:1})]),e.createElementVNode("div",Me,[e.createVNode(U,{id:"creation_mode_multi",value:"multi"}),e.createVNode(y,{for:"creation_mode_multi"},{default:e.withCtx(()=>[...c[5]||(c[5]=[e.createTextVNode("Create multiple codes",-1)])]),_:1})])]),_:1},8,["modelValue"]),r.value.creationMode=="single"?(e.openBlock(),e.createBlock(I,{key:0})):(e.openBlock(),e.createBlock(R,{key:1}))])]),_:1}),e.createVNode(ge),e.createVNode(Ue),e.createVNode(Ee),e.createElementVNode("div",he,[e.createVNode(k,{disabled:V.value,onClick:t},{default:e.withCtx(()=>[V.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),c[7]||(c[7]=e.createTextVNode(" Create Promo Code ",-1))]),_:1},8,["disabled"])])],512)])}}});exports.default=Ae;
|
|
@@ -883,7 +883,11 @@ const Ce = /* @__PURE__ */ z({
|
|
|
883
883
|
e(C, {
|
|
884
884
|
modelValue: n(d).value,
|
|
885
885
|
"onUpdate:modelValue": u[1] || (u[1] = (V) => n(d).value = V),
|
|
886
|
-
|
|
886
|
+
modelModifiers: { number: !0 },
|
|
887
|
+
id: "discountValue",
|
|
888
|
+
type: "number",
|
|
889
|
+
class: "no-spinner",
|
|
890
|
+
min: "0"
|
|
887
891
|
}, null, 8, ["modelValue"]),
|
|
888
892
|
r.value?.valueSuffix ? (p(), U(x, {
|
|
889
893
|
key: 1,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as Q, inject as H, computed as O, resolveComponent as a, openBlock as d, createBlock as x, withCtx as n, createVNode as t, unref as s, createCommentVNode as E, createTextVNode as m, toDisplayString as w, createElementBlock as S, Fragment as G, renderList as le, withModifiers as X, createElementVNode as u, ref as N, renderSlot as de, watch as ce, onMounted as pe, onUnmounted as fe, provide as W, withKeys as me } from "vue";
|
|
2
2
|
import { Globe as ge, Pencil as ve, Filter as _e, RotateCcw as be, ExternalLink as ye, ChevronLeft as Ce, Search as xe, Plus as we } from "lucide-vue-next";
|
|
3
3
|
import { useModule as he, useModuleRoute as Y, useModulePermissions as Z, useFirebaseIntegration as J, useConfirmation as ke, useModuleBreadcrumbs as Pe } from "@oneclick.dev/cms-kit";
|
|
4
|
-
import { i as Ee } from "./interpolation-
|
|
4
|
+
import { i as Ee } from "./interpolation-w7IRDJwK.mjs";
|
|
5
5
|
import { t as L } from "./index-RLz1QPrf.mjs";
|
|
6
6
|
const $e = { class: "flex items-center gap-2" }, Se = {
|
|
7
7
|
key: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),P=require("lucide-vue-next"),V=require("@oneclick.dev/cms-kit"),H=require("./interpolation-DERg6Lwt.js"),_=require("./index-ijdf0d9-.js"),O={class:"flex items-center gap-2"},W={key:0,class:"bg-green-500 text-green-950 px-2 py-1 rounded-lg text-xs"},G={key:0},Q={key:1},X={key:1,class:"bg-blue-500 text-blue-950 px-2 py-1 rounded-lg text-xs"},J={key:2,class:"bg-gray-500 text-gray-950 px-2 py-1 rounded-lg text-xs"},Y=["href"],Z=["href"],ee=e.defineComponent({__name:"ListView",props:{entries:{type:Array,required:!0}},setup(D){const r=e.inject("selection"),v=e.inject("collection"),b=D,{config:c}=V.useModule(),{navigateTo:a,params:E}=V.useModuleRoute(),{hasPermission:N}=V.useModulePermissions(),s=(l,t)=>{l?r.value.push(t):r.value=r.value.filter(i=>i!==t)},g=l=>{if(!v.value)return"about:blank";let t=c.domain?.trim(),i=v.value.defaultLanguageRoutePattern?.trim();if(!t||!i)return"about:blank";t.endsWith("/")&&(t=t.slice(0,-1)),i.startsWith("/")||(i="/"+i);const m=l.liveByLocale.find(u=>u.locale===c.defaultLanguage)?.slug;return H.interpolateTemplateFromVariableContext(t+i,[{name:"slug",value:m},{name:"id",value:l.id},{name:"lang",value:c.defaultLanguage||"en"}])},y=l=>`${(window.location.origin+window.location.pathname).replace(/\/$/,"")}/${l.id}`,x=e.computed(()=>b.entries?.map(l=>({...l,status:l.archived?"archived":l.liveByLocale&&l.liveByLocale.length>0?"published":"draft",publishProgress:{completed:l.liveByLocale.length,total:c.supportedLanguages?.length||1}}))||[]);return(l,t)=>{const i=e.resolveComponent("TableHead"),m=e.resolveComponent("TableRow"),u=e.resolveComponent("TableHeader"),C=e.resolveComponent("Checkbox"),w=e.resolveComponent("TableCell"),T=e.resolveComponent("Button"),h=e.resolveComponent("TableBody"),$=e.resolveComponent("Table"),M=e.resolveComponent("Card");return e.openBlock(),e.createBlock(M,{class:"w-full py-4 px-4"},{default:e.withCtx(()=>[e.createVNode($,{class:"rounded overflow-hidden"},{default:e.withCtx(()=>[e.createVNode(u,null,{default:e.withCtx(()=>[e.createVNode(m,null,{default:e.withCtx(()=>[e.unref(r)?.length>0?(e.openBlock(),e.createBlock(i,{key:0})):e.createCommentVNode("",!0),e.createVNode(i,{class:"capitalize"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(v)?.contentEntryName||"entry"),1)]),_:1}),e.createVNode(i,null,{default:e.withCtx(()=>[...t[3]||(t[3]=[e.createTextVNode("Last updated at",-1)])]),_:1}),e.createVNode(i,null,{default:e.withCtx(()=>[...t[4]||(t[4]=[e.createTextVNode("Status",-1)])]),_:1}),e.createVNode(i,{class:"text-right"},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("Edit",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(h,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,d=>(e.openBlock(),e.createBlock(m,{key:d.id,onClick:f=>e.unref(a)("collections/"+e.unref(E).collectionId+"/"+d.id),class:"cursor-pointer"},{default:e.withCtx(()=>[e.unref(r)?.length>0?(e.openBlock(),e.createBlock(w,{key:0},{default:e.withCtx(()=>[e.createVNode(C,{"model-value":e.unref(r)?.includes(d.id),"onUpdate:modelValue":f=>s(f,d.id),onClick:t[0]||(t[0]=e.withModifiers(()=>{},["prevent","stop"]))},null,8,["model-value","onUpdate:modelValue"])]),_:2},1024)):e.createCommentVNode("",!0),e.createVNode(w,{class:"font-medium"},{default:e.withCtx(()=>[e.createElementVNode("div",O,[e.createElementVNode("span",null,e.toDisplayString(d.title),1)])]),_:2},1024),e.createVNode(w,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.updated?.at?new Date(d.updated.at).toLocaleString():"N/A"),1)]),_:2},1024),e.createVNode(w,null,{default:e.withCtx(()=>[d.status==="published"?(e.openBlock(),e.createElementBlock("span",W,[d.publishProgress.completed===d.publishProgress.total?(e.openBlock(),e.createElementBlock("span",G,"Published")):(e.openBlock(),e.createElementBlock("span",Q,"Partly Published ("+e.toDisplayString(d.publishProgress.completed)+"/"+e.toDisplayString(d.publishProgress.total)+")",1))])):d.status==="draft"?(e.openBlock(),e.createElementBlock("span",X,"Draft")):d.status==="archived"?(e.openBlock(),e.createElementBlock("span",J,"Archived")):e.createCommentVNode("",!0)]),_:2},1024),e.createVNode(w,{class:"text-right"},{default:e.withCtx(()=>[d.status==="published"?(e.openBlock(),e.createElementBlock("a",{key:0,href:g(d),target:"_blank",rel:"noreferrer",onClick:t[1]||(t[1]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(T,{variant:"ghost",size:"icon"},{default:e.withCtx(()=>[e.createVNode(e.unref(P.Globe),{class:"size-4"})]),_:1})],8,Y)):e.createCommentVNode("",!0),e.createElementVNode("a",{href:y(d),rel:"noreferrer",onClick:t[2]||(t[2]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(T,{variant:"ghost",size:"icon"},{default:e.withCtx(()=>[e.createVNode(e.unref(P.Pencil),{class:"size-4"})]),_:1})],8,Z)]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1})]),_:1})}}}),te={class:"flex items-center space-x-2 mb-4"},oe={for:"chk_published_entries",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"},ne={class:"flex items-center space-x-2 mb-4"},le={for:"chk_draft_entries",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"},re={class:"flex items-center space-x-2 mb-4"},ae={for:"chk_archived_entries",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"},se=e.defineComponent({__name:"FilterPopover",setup(D){const r=e.inject("filter"),v=e.ref(""),b=()=>{r.value={published:!0,draft:!0,archived:!1}};return(c,a)=>{const E=e.resolveComponent("Button"),N=e.resolveComponent("PopoverTrigger"),s=e.resolveComponent("Checkbox"),g=e.resolveComponent("PopoverContent"),y=e.resolveComponent("Popover");return e.openBlock(),e.createBlock(y,null,{default:e.withCtx(()=>[e.createVNode(N,{asChild:""},{default:e.withCtx(()=>[e.createVNode(E,{variant:"outline"},{default:e.withCtx(()=>[e.createVNode(e.unref(P.Filter),{class:"size-4"}),a[3]||(a[3]=e.createTextVNode(" Filter ",-1))]),_:1})]),_:1}),e.createVNode(g,{class:"w-64"},{default:e.withCtx(()=>[a[5]||(a[5]=e.createElementVNode("p",{class:"text-sm font-medium text-muted-foreground mb-4"}," Filter by Status ",-1)),e.createElementVNode("div",te,[e.createVNode(s,{id:"chk_published_entries",modelValue:e.unref(r).published,"onUpdate:modelValue":a[0]||(a[0]=x=>e.unref(r).published=x)},null,8,["modelValue"]),e.createElementVNode("label",oe," Show published "+e.toDisplayString(v.value||"entries"),1)]),e.createElementVNode("div",ne,[e.createVNode(s,{id:"chk_draft_entries",modelValue:e.unref(r).draft,"onUpdate:modelValue":a[1]||(a[1]=x=>e.unref(r).draft=x)},null,8,["modelValue"]),e.createElementVNode("label",le," Show draft "+e.toDisplayString(v.value||"entries"),1)]),e.createElementVNode("div",re,[e.createVNode(s,{id:"chk_archived_entries",modelValue:e.unref(r).archived,"onUpdate:modelValue":a[2]||(a[2]=x=>e.unref(r).archived=x)},null,8,["modelValue"]),e.createElementVNode("label",ae," Show archived "+e.toDisplayString(v.value||"entries"),1)]),!e.unref(r).published||!e.unref(r).draft||e.unref(r).archived?(e.openBlock(),e.createBlock(E,{key:0,variant:"secondary",class:"ml-auto my-2",size:"sm",onClick:b},{default:e.withCtx(()=>[e.createVNode(e.unref(P.RotateCcw),{class:"size-3"}),a[4]||(a[4]=e.createElementVNode("span",{class:"ml-0.5 text-xs"},"Reset filters",-1))]),_:1})):e.createCommentVNode("",!0)]),_:1})]),_:1})}}}),ie=e.defineComponent({__name:"ContentEntryContextMenu",emits:["selectAll","duplicateEntry","deleteEntry","deleteSelection"],setup(D,{emit:r}){const v=r,b=e.inject("entries"),c=e.inject("selection"),a=e.inject("config"),{hasPermission:E}=V.useModulePermissions(),{navigateTo:N}=V.useModuleRoute(),s=e.computed(()=>c.value?.length!==1?null:b.value?.find(l=>l.id===c.value[0])),g=l=>{let t=a.previewUrl;t=t.replace("{{ id","{{id"),t=t.replace("id }}","id}}"),t=t.replace("{{id}}",l.id),t=t.replace("{{ slug","{{slug"),t=t.replace("slug }}","slug}}"),t=t.replace("{{slug}}",l.slug),window.open(t,"_blank")},y=async(l,t)=>{try{if(!["draft","published","archived"].includes(t))return;await V.useFirebaseIntegration(a.project).update(a.contentCollection,l.id,{status:t}),l.status=t,_.toast.success("Entry status changed")}catch{_.toast.error("Failed to change entry status")}},x=async l=>{try{if(!["draft","published","archived"].includes(l))return;const t=V.useFirebaseIntegration(a.project),i=[];c.value.forEach(async m=>{i.push(t.update(a.contentCollection,m,{status:l}))}),_.toast.promise(Promise.all(i),{loading:`Changing status of ${c.value.length} entries...`,success:()=>{const m=c.value.length;return c.value.forEach(u=>{b.value.find(C=>C.id==u).status=l}),c.value=[],`Entry status changed for ${m} entries`},error:m=>"Failed to change entry status"})}catch{_.toast.error("Failed to change entry status")}};return(l,t)=>{const i=e.resolveComponent("ContextMenuTrigger"),m=e.resolveComponent("ContextMenuShortcut"),u=e.resolveComponent("ContextMenuItem"),C=e.resolveComponent("ContextMenuContent"),w=e.resolveComponent("ContextMenuSeparator"),T=e.resolveComponent("ContextMenuSubTrigger"),h=e.resolveComponent("ContextMenuCheckboxItem"),$=e.resolveComponent("ContextMenuSubContent"),M=e.resolveComponent("ContextMenuSub"),d=e.resolveComponent("ContextMenu");return e.openBlock(),e.createBlock(d,null,{default:e.withCtx(()=>[e.createVNode(i,{class:"flex flex-1"},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"default")]),_:3}),e.unref(c).length===0?(e.openBlock(),e.createBlock(C,{key:0,class:"w-64"},{default:e.withCtx(()=>[e.createVNode(u,{inset:"",onClick:t[0]||(t[0]=f=>v("selectAll"))},{default:e.withCtx(()=>[t[13]||(t[13]=e.createTextVNode(" Select all ",-1)),e.createVNode(m,null,{default:e.withCtx(()=>[...t[12]||(t[12]=[e.createTextVNode("⌘ + A",-1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0),e.unref(c).length===1&&s.value?(e.openBlock(),e.createBlock(C,{key:1,class:"w-64"},{default:e.withCtx(()=>[e.createVNode(u,{inset:"",onClick:t[1]||(t[1]=f=>e.unref(N)(s.value.id))},{default:e.withCtx(()=>[...t[14]||(t[14]=[e.createTextVNode(" Edit entry ",-1)])]),_:1}),e.createVNode(w),e.unref(a).previewUrl?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(u,{inset:"",onClick:t[2]||(t[2]=f=>g(s.value))},{default:e.withCtx(()=>[t[15]||(t[15]=e.createTextVNode(" Preview entry ",-1)),e.createVNode(m,null,{default:e.withCtx(()=>[e.createVNode(e.unref(P.ExternalLink),{class:"size-4"})]),_:1})]),_:1}),e.createVNode(w)],64)):e.createCommentVNode("",!0),e.createVNode(u,{inset:"",onClick:t[3]||(t[3]=f=>v("duplicateEntry",s.value))},{default:e.withCtx(()=>[...t[16]||(t[16]=[e.createTextVNode(" Duplicate entry ",-1)])]),_:1}),e.createVNode(M,null,{default:e.withCtx(()=>[e.createVNode(T,{inset:""},{default:e.withCtx(()=>[...t[17]||(t[17]=[e.createTextVNode(" Change status ",-1)])]),_:1}),e.createVNode($,{class:"w-48"},{default:e.withCtx(()=>[e.createVNode(h,{onClick:t[4]||(t[4]=f=>y(s.value,"draft")),modelValue:s.value.status==="draft"},{default:e.withCtx(()=>[...t[18]||(t[18]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-blue-500"},null,-1),e.createTextVNode(" Draft ",-1)])]),_:1},8,["modelValue"]),e.createVNode(h,{onClick:t[5]||(t[5]=f=>y(s.value,"published")),modelValue:s.value.status==="published"},{default:e.withCtx(()=>[...t[19]||(t[19]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-green-500"},null,-1),e.createTextVNode(" Published ",-1)])]),_:1},8,["modelValue"]),e.createVNode(h,{onClick:t[6]||(t[6]=f=>y(s.value,"archived")),modelValue:s.value.status==="archived"},{default:e.withCtx(()=>[...t[20]||(t[20]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-gray-300"},null,-1),e.createTextVNode(" Archived ",-1)])]),_:1},8,["modelValue"])]),_:1})]),_:1}),e.createVNode(u,{inset:"",variant:"destructive",onClick:t[7]||(t[7]=f=>v("deleteEntry",s.value))},{default:e.withCtx(()=>[...t[21]||(t[21]=[e.createTextVNode(" Delete entry ",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.unref(c).length>1?(e.openBlock(),e.createBlock(C,{key:2,class:"w-64"},{default:e.withCtx(()=>[e.createVNode(M,null,{default:e.withCtx(()=>[e.createVNode(T,{inset:""},{default:e.withCtx(()=>[e.createTextVNode(" Change status ("+e.toDisplayString(e.unref(c).length)+") ",1)]),_:1}),e.createVNode($,{class:"w-48"},{default:e.withCtx(()=>[e.createVNode(h,{onClick:t[8]||(t[8]=f=>x("draft"))},{default:e.withCtx(()=>[...t[22]||(t[22]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-blue-500"},null,-1),e.createTextVNode(" Draft ",-1)])]),_:1}),e.createVNode(h,{onClick:t[9]||(t[9]=f=>x("published"))},{default:e.withCtx(()=>[...t[23]||(t[23]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-green-500"},null,-1),e.createTextVNode(" Published ",-1)])]),_:1}),e.createVNode(h,{onClick:t[10]||(t[10]=f=>x("archived"))},{default:e.withCtx(()=>[...t[24]||(t[24]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-gray-300"},null,-1),e.createTextVNode(" Archived ",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(u,{inset:"",variant:"destructive",onClick:t[11]||(t[11]=f=>v("deleteSelection"))},{default:e.withCtx(()=>[e.createTextVNode(" Delete entries ("+e.toDisplayString(e.unref(c).length)+") ",1)]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:3})}}}),ce={key:0,class:"relative flex flex-col flex-1"},de={class:"flex items-center justify-between gap-4 w-full my-4"},ue={ref:"container",class:"flex items-center justify-between gap-4 w-full mb-8"},pe={class:"flex items-center gap-4"},me={class:"text-lg whitespace-nowrap"},fe={class:"relative w-full max-w-sm items-center"},ve={class:"absolute start-0 inset-y-0 flex items-center justify-center px-2"},ge={class:"flex items-center gap-4"},Ce={class:"capitalize"},xe={class:"flex mb-4"},Ve=e.defineComponent({__name:"Entries",props:{config:{type:Object,required:!0}},setup(D){const r=D,{hasPermission:v,isAdmin:b}=V.useModulePermissions(),{params:c,navigateTo:a}=V.useModuleRoute(),{confirm:E}=V.useConfirmation(),N=V.useFirebaseIntegration(r.config.project),s=e.ref(null),g=e.ref([]);V.useModuleBreadcrumbs(()=>[{text:s.value?.name??""}]);const y=async()=>{const n=await N.get(r.config.collectionsCollection,c.value.collectionId);n?s.value=n:(a("/"),_.toast.error("Collection not found"))},x=async()=>{const n=await N.find(r.config.contentCollection,{filters:[{field:"collectionId",operator:"==",value:c.value.collectionId}]});g.value=n||[]},l=e.ref(1),t=e.ref([]),i=e.ref(""),m=e.ref(10),u=n=>{if(!n)return 0;if(typeof n?.toDate=="function")return n.toDate().getTime();const o=n instanceof Date?n:new Date(n);return Number.isNaN(o.getTime())?0:o.getTime()},C=e.computed(()=>{const n=i.value.trim().toLowerCase();return[...n?g.value.filter(p=>{const k=String(p?.title??"").toLowerCase(),S=String(p?.slug??"").toLowerCase();return k.includes(n)||S.includes(n)||p?.id===n}):g.value].sort((p,k)=>{const S=u(p?.updated?.at)||u(p?.updatedAt)||u(p?.createdAt);return(u(k?.updated?.at)||u(k?.updatedAt)||u(k?.createdAt))-S})}),w=e.computed(()=>{if(C.value.length<=m.value)return C.value;const n=(l.value-1)*m.value,o=n+m.value;return C.value.slice(n,o)});async function T(n){return(await N.find(r.config.contentCollection,{filters:[{field:"slug",operator:"==",value:n}]})).length>0}const h=()=>{t.value=w.value.map(n=>n.id)},$=async n=>{try{let o={...n},p=o.slug+"-copy",k=2;for(;await T(p);)p=o.slug+"-copy-"+k,k++;o.id=void 0,o.createdAt=new Date,o.updatedAt=new Date,o.slug=p,o.status="draft",o.title=o.title+" (copy)";const S=await N.add(r.config.contentCollection,o);a(S.id),_.toast.success("Entry duplicated")}catch{_.toast.error("Failed to duplicate entry")}},M=async n=>{if(await E(`Are you sure you want to delete "${n.title}"?`))try{await N.remove(r.config.contentCollection,n.id),g.value=g.value.filter(p=>p.id!==n.id),t.value=[],_.toast.success("Entry deleted")}catch{_.toast.error("Failed to delete entry")}},d=async()=>{if(await E(`Are you sure you want to delete all selected ${s?.contentEntryNamePlural||"entries"} (${t.value.length})?`))try{t.value.forEach(async o=>{await N.remove(r.config.contentCollection,o)}),g.value=g.value.filter(o=>!t.value.includes(o.id)),t.value=[],_.toast.success("Entries deleted")}catch{_.toast.error("Failed to delete entries")}},f=e.ref({published:!0,draft:!0,archived:!1});e.watch(f,()=>{l.value=1});const A=n=>{n.target?.matches("input, textarea")||n.target?.isContentEditable||(n.key==="Escape"&&(t.value=[]),(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()==="a"&&(n.preventDefault(),h()))};return e.onMounted(()=>{y(),x(),window.addEventListener("keydown",A)}),e.onUnmounted(()=>{window.removeEventListener("keydown",A)}),e.provide("config",r.config),e.provide("filter",f),e.provide("entries",g),e.provide("selection",t),e.provide("collection",s),(n,o)=>{const p=e.resolveComponent("Button"),k=e.resolveComponent("Input"),S=e.resolveComponent("PaginationFirst"),F=e.resolveComponent("PaginationPrev"),I=e.resolveComponent("PaginationListItem"),U=e.resolveComponent("PaginationEllipsis"),j=e.resolveComponent("PaginationNext"),R=e.resolveComponent("PaginationLast"),q=e.resolveComponent("PaginationList"),K=e.resolveComponent("Pagination");return s.value?(e.openBlock(),e.createElementBlock("div",ce,[e.createElementVNode("div",de,[e.createVNode(p,{onClick:o[0]||(o[0]=B=>e.unref(a)("/")),variant:"link",class:"!pl-0"},{default:e.withCtx(()=>[e.createVNode(e.unref(P.ChevronLeft),{class:"size-4"}),o[5]||(o[5]=e.createTextVNode(" Collections ",-1))]),_:1})]),e.createElementVNode("div",ue,[e.createElementVNode("div",pe,[e.createElementVNode("p",me,e.toDisplayString(C.value?.length)+" "+e.toDisplayString(s.value?.contentEntryNamePlural||"entries"),1),e.createElementVNode("div",fe,[e.createVNode(k,{id:"search",type:"text",placeholder:"Search...",class:"pl-8",onKeydown:o[1]||(o[1]=e.withKeys(B=>i.value="",["escape"])),modelValue:i.value,"onUpdate:modelValue":o[2]||(o[2]=B=>i.value=B)},null,8,["modelValue"]),e.createElementVNode("span",ve,[e.createVNode(e.unref(P.Search),{class:"size-4 text-muted-foreground"})])])]),e.createElementVNode("div",ge,[t.value.length>0?(e.openBlock(),e.createBlock(p,{key:0,variant:"destructive",onClick:d},{default:e.withCtx(()=>[e.createTextVNode(" Delete Selection ("+e.toDisplayString(t.value.length)+") ",1)]),_:1})):e.createCommentVNode("",!0),e.unref(b)()||e.unref(v)("create-entry")&&s.value?.allowUserEntryManagement?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.unref(c)?.collectionId?(e.openBlock(),e.createBlock(p,{key:0,variant:"outline",onClick:o[3]||(o[3]=B=>e.unref(a)(`collections/${e.unref(c).collectionId}/new`))},{default:e.withCtx(()=>[e.createVNode(e.unref(P.Plus),{class:"size-4"}),e.createElementVNode("span",null,[o[6]||(o[6]=e.createTextVNode(" New ",-1)),e.createElementVNode("span",Ce,e.toDisplayString(s.value?.contentEntryName||"entry"),1)])]),_:1})):e.createCommentVNode("",!0),o[7]||(o[7]=e.createElementVNode("div",{class:"w-[1px] h-8 bg-border"},null,-1))],64)):e.createCommentVNode("",!0),e.createVNode(se)])],512),e.createElementVNode("div",xe,[e.createVNode(ie,{onSelectAll:h,onDuplicateEntry:$,onDeleteEntry:M,onDeleteSelection:d},{default:e.withCtx(()=>[e.createVNode(ee,{entries:w.value},null,8,["entries"])]),_:1})]),C.value?.length>m.value?(e.openBlock(),e.createBlock(K,{key:0,page:l.value,"onUpdate:page":o[4]||(o[4]=B=>l.value=B),"items-per-page":m.value,total:C.value?.length,"sibling-count":1,"show-edges":""},{default:e.withCtx(()=>[e.createVNode(q,{class:"flex items-center gap-1"},{default:e.withCtx(({items:B})=>[e.createVNode(S),e.createVNode(F),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B,(L,z)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[L.type==="page"?(e.openBlock(),e.createBlock(I,{key:z,value:L.value,"as-child":""},{default:e.withCtx(()=>[e.createVNode(p,{class:"size-10 p-0",variant:L.value===l.value?"default":"outline"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(L.value),1)]),_:2},1032,["variant"])]),_:2},1032,["value"])):(e.openBlock(),e.createBlock(U,{key:L.type,index:z},null,8,["index"]))],64))),256)),e.createVNode(j),e.createVNode(R)]),_:1})]),_:1},8,["page","items-per-page","total"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}});exports.default=Ve;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),P=require("lucide-vue-next"),V=require("@oneclick.dev/cms-kit"),H=require("./interpolation-CHn59tIC.js"),_=require("./index-ijdf0d9-.js"),O={class:"flex items-center gap-2"},W={key:0,class:"bg-green-500 text-green-950 px-2 py-1 rounded-lg text-xs"},G={key:0},Q={key:1},X={key:1,class:"bg-blue-500 text-blue-950 px-2 py-1 rounded-lg text-xs"},J={key:2,class:"bg-gray-500 text-gray-950 px-2 py-1 rounded-lg text-xs"},Y=["href"],Z=["href"],ee=e.defineComponent({__name:"ListView",props:{entries:{type:Array,required:!0}},setup(D){const r=e.inject("selection"),v=e.inject("collection"),b=D,{config:c}=V.useModule(),{navigateTo:a,params:E}=V.useModuleRoute(),{hasPermission:N}=V.useModulePermissions(),s=(l,t)=>{l?r.value.push(t):r.value=r.value.filter(i=>i!==t)},g=l=>{if(!v.value)return"about:blank";let t=c.domain?.trim(),i=v.value.defaultLanguageRoutePattern?.trim();if(!t||!i)return"about:blank";t.endsWith("/")&&(t=t.slice(0,-1)),i.startsWith("/")||(i="/"+i);const m=l.liveByLocale.find(u=>u.locale===c.defaultLanguage)?.slug;return H.interpolateTemplateFromVariableContext(t+i,[{name:"slug",value:m},{name:"id",value:l.id},{name:"lang",value:c.defaultLanguage||"en"}])},y=l=>`${(window.location.origin+window.location.pathname).replace(/\/$/,"")}/${l.id}`,x=e.computed(()=>b.entries?.map(l=>({...l,status:l.archived?"archived":l.liveByLocale&&l.liveByLocale.length>0?"published":"draft",publishProgress:{completed:l.liveByLocale.length,total:c.supportedLanguages?.length||1}}))||[]);return(l,t)=>{const i=e.resolveComponent("TableHead"),m=e.resolveComponent("TableRow"),u=e.resolveComponent("TableHeader"),C=e.resolveComponent("Checkbox"),w=e.resolveComponent("TableCell"),T=e.resolveComponent("Button"),h=e.resolveComponent("TableBody"),$=e.resolveComponent("Table"),M=e.resolveComponent("Card");return e.openBlock(),e.createBlock(M,{class:"w-full py-4 px-4"},{default:e.withCtx(()=>[e.createVNode($,{class:"rounded overflow-hidden"},{default:e.withCtx(()=>[e.createVNode(u,null,{default:e.withCtx(()=>[e.createVNode(m,null,{default:e.withCtx(()=>[e.unref(r)?.length>0?(e.openBlock(),e.createBlock(i,{key:0})):e.createCommentVNode("",!0),e.createVNode(i,{class:"capitalize"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(v)?.contentEntryName||"entry"),1)]),_:1}),e.createVNode(i,null,{default:e.withCtx(()=>[...t[3]||(t[3]=[e.createTextVNode("Last updated at",-1)])]),_:1}),e.createVNode(i,null,{default:e.withCtx(()=>[...t[4]||(t[4]=[e.createTextVNode("Status",-1)])]),_:1}),e.createVNode(i,{class:"text-right"},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("Edit",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(h,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,d=>(e.openBlock(),e.createBlock(m,{key:d.id,onClick:f=>e.unref(a)("collections/"+e.unref(E).collectionId+"/"+d.id),class:"cursor-pointer"},{default:e.withCtx(()=>[e.unref(r)?.length>0?(e.openBlock(),e.createBlock(w,{key:0},{default:e.withCtx(()=>[e.createVNode(C,{"model-value":e.unref(r)?.includes(d.id),"onUpdate:modelValue":f=>s(f,d.id),onClick:t[0]||(t[0]=e.withModifiers(()=>{},["prevent","stop"]))},null,8,["model-value","onUpdate:modelValue"])]),_:2},1024)):e.createCommentVNode("",!0),e.createVNode(w,{class:"font-medium"},{default:e.withCtx(()=>[e.createElementVNode("div",O,[e.createElementVNode("span",null,e.toDisplayString(d.title),1)])]),_:2},1024),e.createVNode(w,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.updated?.at?new Date(d.updated.at).toLocaleString():"N/A"),1)]),_:2},1024),e.createVNode(w,null,{default:e.withCtx(()=>[d.status==="published"?(e.openBlock(),e.createElementBlock("span",W,[d.publishProgress.completed===d.publishProgress.total?(e.openBlock(),e.createElementBlock("span",G,"Published")):(e.openBlock(),e.createElementBlock("span",Q,"Partly Published ("+e.toDisplayString(d.publishProgress.completed)+"/"+e.toDisplayString(d.publishProgress.total)+")",1))])):d.status==="draft"?(e.openBlock(),e.createElementBlock("span",X,"Draft")):d.status==="archived"?(e.openBlock(),e.createElementBlock("span",J,"Archived")):e.createCommentVNode("",!0)]),_:2},1024),e.createVNode(w,{class:"text-right"},{default:e.withCtx(()=>[d.status==="published"?(e.openBlock(),e.createElementBlock("a",{key:0,href:g(d),target:"_blank",rel:"noreferrer",onClick:t[1]||(t[1]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(T,{variant:"ghost",size:"icon"},{default:e.withCtx(()=>[e.createVNode(e.unref(P.Globe),{class:"size-4"})]),_:1})],8,Y)):e.createCommentVNode("",!0),e.createElementVNode("a",{href:y(d),rel:"noreferrer",onClick:t[2]||(t[2]=e.withModifiers(()=>{},["stop"]))},[e.createVNode(T,{variant:"ghost",size:"icon"},{default:e.withCtx(()=>[e.createVNode(e.unref(P.Pencil),{class:"size-4"})]),_:1})],8,Z)]),_:2},1024)]),_:2},1032,["onClick"]))),128))]),_:1})]),_:1})]),_:1})}}}),te={class:"flex items-center space-x-2 mb-4"},oe={for:"chk_published_entries",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"},ne={class:"flex items-center space-x-2 mb-4"},le={for:"chk_draft_entries",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"},re={class:"flex items-center space-x-2 mb-4"},ae={for:"chk_archived_entries",class:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"},se=e.defineComponent({__name:"FilterPopover",setup(D){const r=e.inject("filter"),v=e.ref(""),b=()=>{r.value={published:!0,draft:!0,archived:!1}};return(c,a)=>{const E=e.resolveComponent("Button"),N=e.resolveComponent("PopoverTrigger"),s=e.resolveComponent("Checkbox"),g=e.resolveComponent("PopoverContent"),y=e.resolveComponent("Popover");return e.openBlock(),e.createBlock(y,null,{default:e.withCtx(()=>[e.createVNode(N,{asChild:""},{default:e.withCtx(()=>[e.createVNode(E,{variant:"outline"},{default:e.withCtx(()=>[e.createVNode(e.unref(P.Filter),{class:"size-4"}),a[3]||(a[3]=e.createTextVNode(" Filter ",-1))]),_:1})]),_:1}),e.createVNode(g,{class:"w-64"},{default:e.withCtx(()=>[a[5]||(a[5]=e.createElementVNode("p",{class:"text-sm font-medium text-muted-foreground mb-4"}," Filter by Status ",-1)),e.createElementVNode("div",te,[e.createVNode(s,{id:"chk_published_entries",modelValue:e.unref(r).published,"onUpdate:modelValue":a[0]||(a[0]=x=>e.unref(r).published=x)},null,8,["modelValue"]),e.createElementVNode("label",oe," Show published "+e.toDisplayString(v.value||"entries"),1)]),e.createElementVNode("div",ne,[e.createVNode(s,{id:"chk_draft_entries",modelValue:e.unref(r).draft,"onUpdate:modelValue":a[1]||(a[1]=x=>e.unref(r).draft=x)},null,8,["modelValue"]),e.createElementVNode("label",le," Show draft "+e.toDisplayString(v.value||"entries"),1)]),e.createElementVNode("div",re,[e.createVNode(s,{id:"chk_archived_entries",modelValue:e.unref(r).archived,"onUpdate:modelValue":a[2]||(a[2]=x=>e.unref(r).archived=x)},null,8,["modelValue"]),e.createElementVNode("label",ae," Show archived "+e.toDisplayString(v.value||"entries"),1)]),!e.unref(r).published||!e.unref(r).draft||e.unref(r).archived?(e.openBlock(),e.createBlock(E,{key:0,variant:"secondary",class:"ml-auto my-2",size:"sm",onClick:b},{default:e.withCtx(()=>[e.createVNode(e.unref(P.RotateCcw),{class:"size-3"}),a[4]||(a[4]=e.createElementVNode("span",{class:"ml-0.5 text-xs"},"Reset filters",-1))]),_:1})):e.createCommentVNode("",!0)]),_:1})]),_:1})}}}),ie=e.defineComponent({__name:"ContentEntryContextMenu",emits:["selectAll","duplicateEntry","deleteEntry","deleteSelection"],setup(D,{emit:r}){const v=r,b=e.inject("entries"),c=e.inject("selection"),a=e.inject("config"),{hasPermission:E}=V.useModulePermissions(),{navigateTo:N}=V.useModuleRoute(),s=e.computed(()=>c.value?.length!==1?null:b.value?.find(l=>l.id===c.value[0])),g=l=>{let t=a.previewUrl;t=t.replace("{{ id","{{id"),t=t.replace("id }}","id}}"),t=t.replace("{{id}}",l.id),t=t.replace("{{ slug","{{slug"),t=t.replace("slug }}","slug}}"),t=t.replace("{{slug}}",l.slug),window.open(t,"_blank")},y=async(l,t)=>{try{if(!["draft","published","archived"].includes(t))return;await V.useFirebaseIntegration(a.project).update(a.contentCollection,l.id,{status:t}),l.status=t,_.toast.success("Entry status changed")}catch{_.toast.error("Failed to change entry status")}},x=async l=>{try{if(!["draft","published","archived"].includes(l))return;const t=V.useFirebaseIntegration(a.project),i=[];c.value.forEach(async m=>{i.push(t.update(a.contentCollection,m,{status:l}))}),_.toast.promise(Promise.all(i),{loading:`Changing status of ${c.value.length} entries...`,success:()=>{const m=c.value.length;return c.value.forEach(u=>{b.value.find(C=>C.id==u).status=l}),c.value=[],`Entry status changed for ${m} entries`},error:m=>"Failed to change entry status"})}catch{_.toast.error("Failed to change entry status")}};return(l,t)=>{const i=e.resolveComponent("ContextMenuTrigger"),m=e.resolveComponent("ContextMenuShortcut"),u=e.resolveComponent("ContextMenuItem"),C=e.resolveComponent("ContextMenuContent"),w=e.resolveComponent("ContextMenuSeparator"),T=e.resolveComponent("ContextMenuSubTrigger"),h=e.resolveComponent("ContextMenuCheckboxItem"),$=e.resolveComponent("ContextMenuSubContent"),M=e.resolveComponent("ContextMenuSub"),d=e.resolveComponent("ContextMenu");return e.openBlock(),e.createBlock(d,null,{default:e.withCtx(()=>[e.createVNode(i,{class:"flex flex-1"},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"default")]),_:3}),e.unref(c).length===0?(e.openBlock(),e.createBlock(C,{key:0,class:"w-64"},{default:e.withCtx(()=>[e.createVNode(u,{inset:"",onClick:t[0]||(t[0]=f=>v("selectAll"))},{default:e.withCtx(()=>[t[13]||(t[13]=e.createTextVNode(" Select all ",-1)),e.createVNode(m,null,{default:e.withCtx(()=>[...t[12]||(t[12]=[e.createTextVNode("⌘ + A",-1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0),e.unref(c).length===1&&s.value?(e.openBlock(),e.createBlock(C,{key:1,class:"w-64"},{default:e.withCtx(()=>[e.createVNode(u,{inset:"",onClick:t[1]||(t[1]=f=>e.unref(N)(s.value.id))},{default:e.withCtx(()=>[...t[14]||(t[14]=[e.createTextVNode(" Edit entry ",-1)])]),_:1}),e.createVNode(w),e.unref(a).previewUrl?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(u,{inset:"",onClick:t[2]||(t[2]=f=>g(s.value))},{default:e.withCtx(()=>[t[15]||(t[15]=e.createTextVNode(" Preview entry ",-1)),e.createVNode(m,null,{default:e.withCtx(()=>[e.createVNode(e.unref(P.ExternalLink),{class:"size-4"})]),_:1})]),_:1}),e.createVNode(w)],64)):e.createCommentVNode("",!0),e.createVNode(u,{inset:"",onClick:t[3]||(t[3]=f=>v("duplicateEntry",s.value))},{default:e.withCtx(()=>[...t[16]||(t[16]=[e.createTextVNode(" Duplicate entry ",-1)])]),_:1}),e.createVNode(M,null,{default:e.withCtx(()=>[e.createVNode(T,{inset:""},{default:e.withCtx(()=>[...t[17]||(t[17]=[e.createTextVNode(" Change status ",-1)])]),_:1}),e.createVNode($,{class:"w-48"},{default:e.withCtx(()=>[e.createVNode(h,{onClick:t[4]||(t[4]=f=>y(s.value,"draft")),modelValue:s.value.status==="draft"},{default:e.withCtx(()=>[...t[18]||(t[18]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-blue-500"},null,-1),e.createTextVNode(" Draft ",-1)])]),_:1},8,["modelValue"]),e.createVNode(h,{onClick:t[5]||(t[5]=f=>y(s.value,"published")),modelValue:s.value.status==="published"},{default:e.withCtx(()=>[...t[19]||(t[19]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-green-500"},null,-1),e.createTextVNode(" Published ",-1)])]),_:1},8,["modelValue"]),e.createVNode(h,{onClick:t[6]||(t[6]=f=>y(s.value,"archived")),modelValue:s.value.status==="archived"},{default:e.withCtx(()=>[...t[20]||(t[20]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-gray-300"},null,-1),e.createTextVNode(" Archived ",-1)])]),_:1},8,["modelValue"])]),_:1})]),_:1}),e.createVNode(u,{inset:"",variant:"destructive",onClick:t[7]||(t[7]=f=>v("deleteEntry",s.value))},{default:e.withCtx(()=>[...t[21]||(t[21]=[e.createTextVNode(" Delete entry ",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.unref(c).length>1?(e.openBlock(),e.createBlock(C,{key:2,class:"w-64"},{default:e.withCtx(()=>[e.createVNode(M,null,{default:e.withCtx(()=>[e.createVNode(T,{inset:""},{default:e.withCtx(()=>[e.createTextVNode(" Change status ("+e.toDisplayString(e.unref(c).length)+") ",1)]),_:1}),e.createVNode($,{class:"w-48"},{default:e.withCtx(()=>[e.createVNode(h,{onClick:t[8]||(t[8]=f=>x("draft"))},{default:e.withCtx(()=>[...t[22]||(t[22]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-blue-500"},null,-1),e.createTextVNode(" Draft ",-1)])]),_:1}),e.createVNode(h,{onClick:t[9]||(t[9]=f=>x("published"))},{default:e.withCtx(()=>[...t[23]||(t[23]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-green-500"},null,-1),e.createTextVNode(" Published ",-1)])]),_:1}),e.createVNode(h,{onClick:t[10]||(t[10]=f=>x("archived"))},{default:e.withCtx(()=>[...t[24]||(t[24]=[e.createElementVNode("span",{class:"size-2 rounded-full bg-gray-300"},null,-1),e.createTextVNode(" Archived ",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(u,{inset:"",variant:"destructive",onClick:t[11]||(t[11]=f=>v("deleteSelection"))},{default:e.withCtx(()=>[e.createTextVNode(" Delete entries ("+e.toDisplayString(e.unref(c).length)+") ",1)]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:3})}}}),ce={key:0,class:"relative flex flex-col flex-1"},de={class:"flex items-center justify-between gap-4 w-full my-4"},ue={ref:"container",class:"flex items-center justify-between gap-4 w-full mb-8"},pe={class:"flex items-center gap-4"},me={class:"text-lg whitespace-nowrap"},fe={class:"relative w-full max-w-sm items-center"},ve={class:"absolute start-0 inset-y-0 flex items-center justify-center px-2"},ge={class:"flex items-center gap-4"},Ce={class:"capitalize"},xe={class:"flex mb-4"},Ve=e.defineComponent({__name:"Entries",props:{config:{type:Object,required:!0}},setup(D){const r=D,{hasPermission:v,isAdmin:b}=V.useModulePermissions(),{params:c,navigateTo:a}=V.useModuleRoute(),{confirm:E}=V.useConfirmation(),N=V.useFirebaseIntegration(r.config.project),s=e.ref(null),g=e.ref([]);V.useModuleBreadcrumbs(()=>[{text:s.value?.name??""}]);const y=async()=>{const n=await N.get(r.config.collectionsCollection,c.value.collectionId);n?s.value=n:(a("/"),_.toast.error("Collection not found"))},x=async()=>{const n=await N.find(r.config.contentCollection,{filters:[{field:"collectionId",operator:"==",value:c.value.collectionId}]});g.value=n||[]},l=e.ref(1),t=e.ref([]),i=e.ref(""),m=e.ref(10),u=n=>{if(!n)return 0;if(typeof n?.toDate=="function")return n.toDate().getTime();const o=n instanceof Date?n:new Date(n);return Number.isNaN(o.getTime())?0:o.getTime()},C=e.computed(()=>{const n=i.value.trim().toLowerCase();return[...n?g.value.filter(p=>{const k=String(p?.title??"").toLowerCase(),S=String(p?.slug??"").toLowerCase();return k.includes(n)||S.includes(n)||p?.id===n}):g.value].sort((p,k)=>{const S=u(p?.updated?.at)||u(p?.updatedAt)||u(p?.createdAt);return(u(k?.updated?.at)||u(k?.updatedAt)||u(k?.createdAt))-S})}),w=e.computed(()=>{if(C.value.length<=m.value)return C.value;const n=(l.value-1)*m.value,o=n+m.value;return C.value.slice(n,o)});async function T(n){return(await N.find(r.config.contentCollection,{filters:[{field:"slug",operator:"==",value:n}]})).length>0}const h=()=>{t.value=w.value.map(n=>n.id)},$=async n=>{try{let o={...n},p=o.slug+"-copy",k=2;for(;await T(p);)p=o.slug+"-copy-"+k,k++;o.id=void 0,o.createdAt=new Date,o.updatedAt=new Date,o.slug=p,o.status="draft",o.title=o.title+" (copy)";const S=await N.add(r.config.contentCollection,o);a(S.id),_.toast.success("Entry duplicated")}catch{_.toast.error("Failed to duplicate entry")}},M=async n=>{if(await E(`Are you sure you want to delete "${n.title}"?`))try{await N.remove(r.config.contentCollection,n.id),g.value=g.value.filter(p=>p.id!==n.id),t.value=[],_.toast.success("Entry deleted")}catch{_.toast.error("Failed to delete entry")}},d=async()=>{if(await E(`Are you sure you want to delete all selected ${s?.contentEntryNamePlural||"entries"} (${t.value.length})?`))try{t.value.forEach(async o=>{await N.remove(r.config.contentCollection,o)}),g.value=g.value.filter(o=>!t.value.includes(o.id)),t.value=[],_.toast.success("Entries deleted")}catch{_.toast.error("Failed to delete entries")}},f=e.ref({published:!0,draft:!0,archived:!1});e.watch(f,()=>{l.value=1});const A=n=>{n.target?.matches("input, textarea")||n.target?.isContentEditable||(n.key==="Escape"&&(t.value=[]),(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()==="a"&&(n.preventDefault(),h()))};return e.onMounted(()=>{y(),x(),window.addEventListener("keydown",A)}),e.onUnmounted(()=>{window.removeEventListener("keydown",A)}),e.provide("config",r.config),e.provide("filter",f),e.provide("entries",g),e.provide("selection",t),e.provide("collection",s),(n,o)=>{const p=e.resolveComponent("Button"),k=e.resolveComponent("Input"),S=e.resolveComponent("PaginationFirst"),F=e.resolveComponent("PaginationPrev"),I=e.resolveComponent("PaginationListItem"),U=e.resolveComponent("PaginationEllipsis"),j=e.resolveComponent("PaginationNext"),R=e.resolveComponent("PaginationLast"),q=e.resolveComponent("PaginationList"),K=e.resolveComponent("Pagination");return s.value?(e.openBlock(),e.createElementBlock("div",ce,[e.createElementVNode("div",de,[e.createVNode(p,{onClick:o[0]||(o[0]=B=>e.unref(a)("/")),variant:"link",class:"!pl-0"},{default:e.withCtx(()=>[e.createVNode(e.unref(P.ChevronLeft),{class:"size-4"}),o[5]||(o[5]=e.createTextVNode(" Collections ",-1))]),_:1})]),e.createElementVNode("div",ue,[e.createElementVNode("div",pe,[e.createElementVNode("p",me,e.toDisplayString(C.value?.length)+" "+e.toDisplayString(s.value?.contentEntryNamePlural||"entries"),1),e.createElementVNode("div",fe,[e.createVNode(k,{id:"search",type:"text",placeholder:"Search...",class:"pl-8",onKeydown:o[1]||(o[1]=e.withKeys(B=>i.value="",["escape"])),modelValue:i.value,"onUpdate:modelValue":o[2]||(o[2]=B=>i.value=B)},null,8,["modelValue"]),e.createElementVNode("span",ve,[e.createVNode(e.unref(P.Search),{class:"size-4 text-muted-foreground"})])])]),e.createElementVNode("div",ge,[t.value.length>0?(e.openBlock(),e.createBlock(p,{key:0,variant:"destructive",onClick:d},{default:e.withCtx(()=>[e.createTextVNode(" Delete Selection ("+e.toDisplayString(t.value.length)+") ",1)]),_:1})):e.createCommentVNode("",!0),e.unref(b)()||e.unref(v)("create-entry")&&s.value?.allowUserEntryManagement?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.unref(c)?.collectionId?(e.openBlock(),e.createBlock(p,{key:0,variant:"outline",onClick:o[3]||(o[3]=B=>e.unref(a)(`collections/${e.unref(c).collectionId}/new`))},{default:e.withCtx(()=>[e.createVNode(e.unref(P.Plus),{class:"size-4"}),e.createElementVNode("span",null,[o[6]||(o[6]=e.createTextVNode(" New ",-1)),e.createElementVNode("span",Ce,e.toDisplayString(s.value?.contentEntryName||"entry"),1)])]),_:1})):e.createCommentVNode("",!0),o[7]||(o[7]=e.createElementVNode("div",{class:"w-[1px] h-8 bg-border"},null,-1))],64)):e.createCommentVNode("",!0),e.createVNode(se)])],512),e.createElementVNode("div",xe,[e.createVNode(ie,{onSelectAll:h,onDuplicateEntry:$,onDeleteEntry:M,onDeleteSelection:d},{default:e.withCtx(()=>[e.createVNode(ee,{entries:w.value},null,8,["entries"])]),_:1})]),C.value?.length>m.value?(e.openBlock(),e.createBlock(K,{key:0,page:l.value,"onUpdate:page":o[4]||(o[4]=B=>l.value=B),"items-per-page":m.value,total:C.value?.length,"sibling-count":1,"show-edges":""},{default:e.withCtx(()=>[e.createVNode(q,{class:"flex items-center gap-1"},{default:e.withCtx(({items:B})=>[e.createVNode(S),e.createVNode(F),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B,(L,z)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[L.type==="page"?(e.openBlock(),e.createBlock(I,{key:z,value:L.value,"as-child":""},{default:e.withCtx(()=>[e.createVNode(p,{class:"size-10 p-0",variant:L.value===l.value?"default":"outline"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(L.value),1)]),_:2},1032,["variant"])]),_:2},1032,["value"])):(e.openBlock(),e.createBlock(U,{key:L.type,index:z},null,8,["index"]))],64))),256)),e.createVNode(j),e.createVNode(R)]),_:1})]),_:1},8,["page","items-per-page","total"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)}}});exports.default=Ve;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("vue"),M=require("lucide-vue-next"),W=require("@oneclick.dev/cms-kit"),Z=require("./utils-Yd6F5mea.js"),Y=require("./DateFormatter-CYAD4GBN.js"),te=require("./_plugin-vue_export-helper-BHFhmbuH.js"),ne={class:"space-y-3"},ae={class:"grid gap-4 @md/modal:grid-cols-2 @2xl/modal:grid-cols-3 @4xl/modal:grid-cols-4 overflow-hidden p-1"},re={key:0,class:"flex items-center gap-3 min-h-9"},le={key:0,class:"italic text-xs opacity-50"},se={key:0,class:"italic text-xs opacity-50"},ie={key:0,class:"italic text-xs opacity-50"},ce={key:0,class:"italic text-xs opacity-50"},de={key:0,class:"text-red-400"},ue={class:"list-disc pl-4"},me=e.defineComponent({__name:"CustomerInformation",props:{agendaData:{}},setup(w,{expose:B}){const y=[{id:"firstName",fieldName:"First Name",fieldType:"text",required:!0,visible:!0},{id:"lastName",fieldName:"Last Name",fieldType:"text",required:!0,visible:!0},{id:"phone",fieldName:"Phone No",fieldType:"tel",required:!0,visible:!0},{id:"email",fieldName:"Email",fieldType:"email",required:!0,visible:!0},{id:"birthdate",fieldName:"Birthdate",fieldType:"date",required:!0,visible:!0}],E=new Set(["firstName","email"]),D=w,T=e.ref([]),p=e.reactive({}),V=e.computed(()=>{const d=D.agendaData?.customerInformationFields,u=(Array.isArray(d)&&d.length>0?d:y).filter(b=>b?.id&&(b.visible!==!1||E.has(b.id))).map(b=>({...b,required:E.has(b.id),visible:!0})),h=y.filter(b=>E.has(b.id)&&!u.some(P=>P.id===b.id)).map(b=>({...b,required:!0,visible:!0}));return[...u,...h]}),N=d=>d.fieldName||d.id,R=d=>d.replace(/[^A-Za-z0-9_-]/g,"-"),f=(d,v)=>["new-res-customer-info",d.id,v].filter(Boolean).map(h=>R(h)).join("-"),k=d=>d.fieldType==="email"||d.fieldType==="tel"||d.fieldType==="date"?d.fieldType:"text",g=d=>Array.isArray(d.options)?d.options.filter(Boolean):[],$=d=>d.fieldType==="checkbox"?!1:"",I=(d=!1)=>{const v=new Set(V.value.map(u=>u.id));Object.keys(p).forEach(u=>{v.has(u)||delete p[u]}),V.value.forEach(u=>{const h=$(u);(d||p[u.id]===void 0||typeof p[u.id]!=typeof h)&&(p[u.id]=h)})},O=()=>{const d=V.value.reduce((v,u)=>{const h=p[u.id];return v[u.id]=typeof h=="string"?h.trim():!!h,v},{});return Object.entries(d).forEach(([v,u])=>{p[v]=u}),d},F=(d,v)=>d.fieldType==="checkbox"?v===!0:typeof v=="string"?v.trim().length>0:v!=null,z=()=>{T.value=[],I(!0)},L=()=>{const d=[],v=O();return V.value.forEach(u=>{const h=v[u.id],b=N(u);u.required&&!F(u,h)&&d.push(`Please fill in ${b}.`),u.fieldType==="email"&&F(u,h)&&typeof h=="string"&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h)===!1&&d.push(`Please fill in a correct ${b}.`)}),T.value=d,d.length===0};return e.watch(V,()=>{I()},{immediate:!0}),B({getCustomerInfo:O,reset:z,validateForm:L}),(d,v)=>{const u=e.resolveComponent("Checkbox"),h=e.resolveComponent("Label"),b=e.resolveComponent("SelectValue"),P=e.resolveComponent("SelectTrigger"),A=e.resolveComponent("SelectItem"),q=e.resolveComponent("SelectGroup"),j=e.resolveComponent("SelectContent"),U=e.resolveComponent("Select"),s=e.resolveComponent("RadioGroupItem"),t=e.resolveComponent("RadioGroup"),a=e.resolveComponent("Input");return e.openBlock(),e.createElementBlock("div",ne,[v[0]||(v[0]=e.createElementVNode("h2",{class:"text-sm font-medium"},"Customer Information",-1)),e.createElementVNode("div",ae,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,n=>(e.openBlock(),e.createElementBlock("div",{key:n.id,class:e.normalizeClass(["grid gap-2",n.fieldType==="checkbox"?"@md/modal:col-span-2":""])},[n.fieldType==="checkbox"?(e.openBlock(),e.createElementBlock("div",re,[e.createVNode(u,{id:f(n),modelValue:p[n.id],"onUpdate:modelValue":r=>p[n.id]=r},null,8,["id","modelValue","onUpdate:modelValue"]),e.createVNode(h,{for:f(n),class:"font-normal cursor-pointer"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(N(n))+" ",1),n.required?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",le,"optional"))]),_:2},1032,["for"])])):n.fieldType==="select"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(h,{for:f(n)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(N(n))+" ",1),n.required?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",se,"optional"))]),_:2},1032,["for"]),e.createVNode(U,{modelValue:p[n.id],"onUpdate:modelValue":r=>p[n.id]=r},{default:e.withCtx(()=>[e.createVNode(P,{id:f(n),class:"w-full"},{default:e.withCtx(()=>[e.createVNode(b,{placeholder:`Select ${N(n)}`},null,8,["placeholder"])]),_:2},1032,["id"]),e.createVNode(j,null,{default:e.withCtx(()=>[e.createVNode(q,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g(n),r=>(e.openBlock(),e.createBlock(A,{key:r,value:r},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r),1)]),_:2},1032,["value"]))),128))]),_:2},1024)]),_:2},1024)]),_:2},1032,["modelValue","onUpdate:modelValue"])],64)):n.fieldType==="radio"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createVNode(h,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(N(n))+" ",1),n.required?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",ie,"optional"))]),_:2},1024),e.createVNode(t,{modelValue:p[n.id],"onUpdate:modelValue":r=>p[n.id]=r,class:"grid gap-2"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g(n),r=>(e.openBlock(),e.createElementBlock("div",{key:r,class:"flex items-center gap-2"},[e.createVNode(s,{id:f(n,r),value:r},null,8,["id","value"]),e.createVNode(h,{for:f(n,r),class:"font-normal cursor-pointer"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r),1)]),_:2},1032,["for"])]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createVNode(h,{for:f(n)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(N(n))+" ",1),n.required?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",ce,"optional"))]),_:2},1032,["for"]),e.createVNode(a,{modelValue:p[n.id],"onUpdate:modelValue":r=>p[n.id]=r,id:f(n),type:k(n),autocomplete:"off"},null,8,["modelValue","onUpdate:modelValue","id","type"])],64))],2))),128))]),T.value.length>0?(e.openBlock(),e.createElementBlock("div",de,[e.createElementVNode("ul",ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(T.value,n=>(e.openBlock(),e.createElementBlock("li",{key:n},e.toDisplayString(n),1))),128))])])):e.createCommentVNode("",!0)])}}});function pe(w={}){const B=e.ref(null),y=e.ref(!1),E=e.ref(!1),D=e.ref(!1),T=e.ref(!1),p=w.dragSpeed??1.1,V=w.dragThreshold??10,N=w.edgeThreshold??10,R=w.ignoreDragSelector??'input, select, textarea, [contenteditable="true"], [data-horizontal-scroll-ignore-drag]';let f=null,k=0,g=0,$=!1,I=null,O=null,F=null;const z=()=>{I===null||typeof window>"u"||(window.clearTimeout(I),I=null)},L=()=>{const o=B.value;if(!o){E.value=!1,D.value=!1,T.value=!1;return}const c=Math.max(o.scrollWidth-o.clientWidth,0);E.value=c>N,D.value=E.value&&o.scrollLeft>N,T.value=E.value&&o.scrollLeft<c-N},d=()=>{e.nextTick(()=>{if(typeof window>"u"){L();return}window.requestAnimationFrame(()=>L())})},v=()=>{if(typeof w.scrollStep=="number")return w.scrollStep;const o=B.value;return o?Math.max(Math.floor(o.clientWidth*.72),180):240},u=(o,c="smooth")=>{const l=B.value;if(l){if(l.scrollBy({left:o,behavior:c}),c==="auto"){L();return}d()}},h=()=>{u(-v())},b=()=>{u(v())},P=()=>{const o=B.value;f!==null&&o?.hasPointerCapture?.(f)&&o.releasePointerCapture(f),y.value&&($=!0,z(),typeof window<"u"&&(I=window.setTimeout(()=>{$=!1,I=null},0))),f=null,y.value=!1,o&&(o.style.userSelect="",o.style.cursor=""),L()},A=()=>{L()},q=o=>{const c=B.value;if(!c||!E.value||Math.abs(o.deltaY)<=Math.abs(o.deltaX))return;const l=o.deltaY<0,C=o.deltaY>0;l&&!D.value||C&&!T.value||(o.preventDefault(),c.scrollLeft+=o.deltaY,L())},j=o=>o instanceof Element?!!o.closest(R):!1,U=o=>{const c=B.value;!c||!E.value||o.pointerType!=="touch"&&o.button===0&&(j(o.target)||(f=o.pointerId,k=o.clientX,g=c.scrollLeft,$=!1))},s=o=>{const c=B.value;if(!c||f!==o.pointerId)return;const l=o.clientX-k;!y.value&&Math.abs(l)<V||(y.value||(y.value=!0,c.style.userSelect="none",c.style.cursor="grabbing",c.setPointerCapture?.(o.pointerId)),o.preventDefault(),c.scrollLeft=g-l*p,L())},t=o=>{f===o.pointerId&&P()},a=()=>{f!==null&&P()},n=o=>{$&&(o.preventDefault(),o.stopPropagation(),$=!1)},r=o=>{typeof ResizeObserver<"u"&&(O=new ResizeObserver(()=>L()),O.observe(o)),w.observeMutations!==!1&&typeof MutationObserver<"u"&&(F=new MutationObserver(()=>d()),F.observe(o,{childList:!0,subtree:!0,characterData:!0}))},S=()=>{O?.disconnect(),F?.disconnect(),O=null,F=null},_=o=>{o.addEventListener("scroll",A),o.addEventListener("wheel",q,{passive:!1}),o.addEventListener("pointerdown",U),o.addEventListener("pointermove",s),o.addEventListener("pointerup",t),o.addEventListener("pointercancel",a),o.addEventListener("lostpointercapture",a),o.addEventListener("click",n,!0),r(o),d()},i=o=>{o.removeEventListener("scroll",A),o.removeEventListener("wheel",q),o.removeEventListener("pointerdown",U),o.removeEventListener("pointermove",s),o.removeEventListener("pointerup",t),o.removeEventListener("pointercancel",a),o.removeEventListener("lostpointercapture",a),o.removeEventListener("click",n,!0),S()};return e.watch(B,(o,c)=>{c&&i(c),o?_(o):L()}),e.onMounted(()=>{d()}),e.onBeforeUnmount(()=>{z(),B.value&&i(B.value),$=!1,P()}),{canScrollLeft:e.computed(()=>D.value),canScrollRight:e.computed(()=>T.value),containerRef:B,isDragging:y,isScrollable:E,refresh:d,scrollNext:b,scrollPrev:h,showLeftShadow:D,showRightShadow:T}}const fe={class:"flex items-start justify-between gap-3"},ge={class:"text-sm font-medium"},ve={key:0,class:"mt-1 text-xs text-muted-foreground"},he={class:"grid gap-4 @md/quick-adder:grid-cols-2 @2xl/quick-adder:grid-cols-3 @4xl/quick-adder:grid-cols-4"},_e={class:"grid gap-2"},ke={key:0,class:"grid gap-2"},Ne={key:1,class:"grid gap-2"},xe={key:2,class:"grid gap-2"},Ve={class:"grid gap-2"},be={key:0,class:"rounded-md border border-dashed bg-muted/20 px-4 py-4 text-sm text-muted-foreground"},ye={key:1,class:"relative flex items-center gap-2 overflow-hidden"},Ce={class:"relative min-w-0 flex-1 overflow-hidden"},we={key:0,class:"pointer-events-none absolute inset-y-0 left-0 z-10 w-10 md:w-20 bg-gradient-to-r from-background via-background/95 to-transparent"},Se={key:1,class:"pointer-events-none absolute inset-y-0 right-0 z-10 w-10 md:w-20 bg-gradient-to-l from-background via-background/95 to-transparent"},Ee={key:0,class:"absolute -top-1 -right-1 flex items-center justify-center bg-primary rounded-full text-background size-4"},Te={class:"flex flex-wrap gap-2"},Be=["onClick"],De={key:0},$e={key:1},Re={key:2},Ie=e.defineComponent({__name:"QuickReservationAdder",props:{agendaData:{},surface:{default:"card"}},emits:["add"],setup(w,{emit:B}){const y=w,E=B,D=new Y.$12a3c853105e5a70$export$ad991b66133851cf("en-US",{dateStyle:"long"}),T=Y.$ad063034c8620db8$export$d0bdf45af03a6ea3(Y.$ad063034c8620db8$export$aa8b41735afcabd2()),p=e.computed(()=>y.surface==="popover"),V=e.ref(""),N=e.ref(void 0),R=e.ref(""),f=e.ref(""),k=e.ref([]),g=e.ref(1),$=e.computed(()=>y.agendaData?.resources?.find(i=>i.id===R.value)),I=i=>{const[o,c]=i.split(":").map(Number);return o*60+c},O=i=>{const o=Math.floor(i/60),c=i%60;return`${o.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`},F=()=>{if(!$.value)return[];const i=$.value.interval||60;let o=null,c=null;for(const C of Object.values($.value.openingHours||{}))for(const m of C){const H=I(m.start),Q=I(m.end);(o===null||H<o)&&(o=H),(c===null||Q>c)&&(c=Q)}if(o===null||c===null)return[];const l=[];for(let C=o;C<c;C+=i)l.push(O(C));return l},z=e.computed(()=>N.value&&R.value&&f.value&&k.value.length>0),L=e.computed(()=>F()),{canScrollLeft:d,canScrollRight:v,containerRef:u,isDragging:h,isScrollable:b,scrollNext:P,scrollPrev:A,showLeftShadow:q,showRightShadow:j}=pe(),U=i=>k.value.includes(i),s=i=>{if(U(i)){k.value=k.value.filter(o=>o!==i);return}k.value=[...k.value,i].sort((o,c)=>I(o)-I(c))},t=(i,o)=>{N.value=i?e.markRaw(i):void 0,V.value=i?`${i}`:"",o()},a=e.ref(""),n=e.ref(""),r=e.ref([]),S=()=>{E("add",{date:N.value,resourceId:R.value,pricingOptionId:f.value,startTimes:k.value,spots:g.value}),k.value=[],r.value=[],n.value="",a.value=""},_=()=>{V.value=T.toString(),N.value=T,R.value=y.agendaData?.resources?.[0]?.id||"",f.value=y.agendaData?.pricingOptions?.find(i=>i.isDefault)?.id||y.agendaData?.pricingOptions?.[0]?.id||"",k.value=[],g.value=1,a.value=""};return e.onMounted(()=>{_()}),(i,o)=>{const c=e.resolveComponent("Label"),l=e.resolveComponent("Button"),C=e.resolveComponent("PopoverTrigger"),m=e.resolveComponent("Calendar"),H=e.resolveComponent("PopoverContent"),Q=e.resolveComponent("Popover"),K=e.resolveComponent("DynamicSelectOption"),J=e.resolveComponent("DynamicSelect"),oe=e.resolveComponent("Input");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(Z.classNames)("@container/quick-adder grid gap-4 overflow-hidden bg-background",e.unref(p)?"p-5 sm:p-6":"rounded-md border p-4"))},[e.createElementVNode("div",fe,[e.createElementVNode("div",null,[e.createElementVNode("h3",ge,e.toDisplayString(e.unref(p)?"Quick add reservations":"Add reservations"),1),e.unref(p)?(e.openBlock(),e.createElementBlock("p",ve," Choose one date and add multiple timeslots in one pass. ")):e.createCommentVNode("",!0)])]),e.createElementVNode("div",he,[e.createElementVNode("div",_e,[e.createVNode(c,null,{default:e.withCtx(()=>[...o[3]||(o[3]=[e.createTextVNode("Date",-1)])]),_:1}),e.createVNode(Q,null,{default:e.withCtx(({close:x})=>[e.createVNode(C,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(l,{type:"button",variant:"outline",class:e.normalizeClass(e.unref(Z.classNames)("w-full justify-start text-left font-normal",!e.unref(N)&&"text-muted-foreground"))},{default:e.withCtx(()=>[e.createVNode(e.unref(M.CalendarIcon)),e.createTextVNode(" "+e.toDisplayString(e.unref(N)?e.unref(D).format(e.unref(N).toDate(e.unref(Y.$ad063034c8620db8$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class"])]),_:1}),e.createVNode(H,{class:"w-auto p-0",align:"start"},{default:e.withCtx(()=>[e.createVNode(m,{"model-value":e.unref(N),"default-placeholder":e.unref(T),layout:"month-and-year","initial-focus":"","onUpdate:modelValue":G=>t(G,x),minValue:e.unref(Y.$ad063034c8620db8$export$d0bdf45af03a6ea3)(e.unref(Y.$ad063034c8620db8$export$aa8b41735afcabd2)())},null,8,["model-value","default-placeholder","onUpdate:modelValue","minValue"])]),_:2},1024)]),_:1})]),w.agendaData.resources?.length>1?(e.openBlock(),e.createElementBlock("div",ke,[e.createVNode(c,null,{default:e.withCtx(()=>[...o[4]||(o[4]=[e.createTextVNode("Resource",-1)])]),_:1}),e.createVNode(J,{modelValue:e.unref(R),"onUpdate:modelValue":o[0]||(o[0]=x=>e.isRef(R)?R.value=x:null),"wrapper-class":"w-full",class:"w-full",placeholder:"Select resource"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.agendaData.resources||[],x=>(e.openBlock(),e.createBlock(K,{key:x.id,value:x.id},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])])):e.createCommentVNode("",!0),w.agendaData.pricingOptions?.length>1?(e.openBlock(),e.createElementBlock("div",Ne,[e.createVNode(c,null,{default:e.withCtx(()=>[...o[5]||(o[5]=[e.createTextVNode("Type",-1)])]),_:1}),e.createVNode(J,{modelValue:e.unref(f),"onUpdate:modelValue":o[1]||(o[1]=x=>e.isRef(f)?f.value=x:null),"wrapper-class":"w-full",class:"w-full",placeholder:"Select type"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.agendaData.pricingOptions||[],x=>(e.openBlock(),e.createBlock(K,{key:x.id,value:x.id},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.name)+" ("+e.toDisplayString(x.duration)+"min) ",1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"])])):e.createCommentVNode("",!0),w.agendaData?.maxTicketsPerReservation>1?(e.openBlock(),e.createElementBlock("div",xe,[e.createVNode(c,null,{default:e.withCtx(()=>[...o[6]||(o[6]=[e.createTextVNode("Spots/tickets",-1)])]),_:1}),e.createVNode(oe,{modelValue:e.unref(g),"onUpdate:modelValue":o[2]||(o[2]=x=>e.isRef(g)?g.value=x:null),modelModifiers:{number:!0},type:"number",min:"1",class:"no-spinner",autocomplete:"off"},null,8,["modelValue"])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Ve,[e.createVNode(c,null,{default:e.withCtx(()=>[...o[7]||(o[7]=[e.createTextVNode("Available hours",-1)])]),_:1}),e.unref(L).length===0?(e.openBlock(),e.createElementBlock("div",be," No preset hours are available for this resource. You can still add a custom time below. ")):(e.openBlock(),e.createElementBlock("div",ye,[e.unref(d)?(e.openBlock(),e.createBlock(l,{key:0,type:"button",size:"icon",variant:"outline",class:"hidden absolute size-8 shrink-0 rounded-full shadow-sm md:inline-flex z-[11] left-0.5",onClick:e.unref(A)},{default:e.withCtx(()=>[e.createVNode(e.unref(M.ChevronLeft),{class:"size-4"})]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.createElementVNode("div",Ce,[e.unref(q)?(e.openBlock(),e.createElementBlock("div",we)):e.createCommentVNode("",!0),e.unref(j)?(e.openBlock(),e.createElementBlock("div",Se)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"hourScrollContainer",ref:u,class:e.normalizeClass(e.unref(Z.classNames)("hour-scroll-track flex w-full min-w-0 gap-2 overflow-x-auto overscroll-contain py-2",e.unref(b)&&!e.unref(h)&&"cursor-grab",e.unref(h)&&"cursor-grabbing select-none"))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(L),x=>(e.openBlock(),e.createBlock(l,{key:x,type:"button",variant:"outline",class:e.normalizeClass(["relative h-12 shrink-0",U(x)?"border-primary!":""]),onClick:G=>s(x)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x)+" ",1),U(x)?(e.openBlock(),e.createElementBlock("div",Ee,[e.createVNode(e.unref(M.Check),{class:"size-3"})])):e.createCommentVNode("",!0)]),_:2},1032,["class","onClick"]))),128))],2)]),e.unref(v)?(e.openBlock(),e.createBlock(l,{key:1,type:"button",size:"icon",variant:"outline",class:"hidden absolute size-8 shrink-0 rounded-full shadow-sm md:inline-flex z-[11] right-0.5",onClick:e.unref(P)},{default:e.withCtx(()=>[e.createVNode(e.unref(M.ChevronRight),{class:"size-4"})]),_:1},8,["onClick"])):e.createCommentVNode("",!0)])),e.createElementVNode("div",Te,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r),x=>(e.openBlock(),e.createElementBlock("div",{key:x,class:"relative"},[e.createVNode(l,{type:"button",variant:"outline",class:"h-12 px-4 py-2"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x),1)]),_:2},1024),e.createElementVNode("div",{class:"absolute -top-1 -right-1 flex items-center justify-center bg-red-500 rounded-full text-white size-4 cursor-pointer",onClick:G=>{r.value=e.unref(r).filter(X=>X!==x),k.value=e.unref(k).filter(X=>X!==x)}},[e.createVNode(e.unref(M.X),{class:"size-3"})],8,Be)]))),128))])]),e.createElementVNode("div",null,[e.createVNode(l,{disabled:!e.unref(z),onClick:S},{default:e.withCtx(()=>[e.unref(k).length===0?(e.openBlock(),e.createElementBlock("span",De,"Select at least one timeslot")):e.unref(k).length===1?(e.openBlock(),e.createElementBlock("span",$e,"Add 1 reservation")):(e.openBlock(),e.createElementBlock("span",Re,"Add "+e.toDisplayString(e.unref(k).length)+" reservations",1))]),_:1},8,["disabled"])])],2)}}}),Le=te._export_sfc(Ie,[["__scopeId","data-v-c7529556"]]),Fe={class:"space-y-3"},Oe={class:"flex flex-wrap items-center justify-between gap-3"},Pe={class:"text-xs text-muted-foreground"},Me={class:"flex flex-wrap items-center gap-2"},Ue={key:0,class:"rounded-md border border-dashed bg-muted/20 px-4 py-6 text-sm text-muted-foreground"},ze={key:1,class:"space-y-3"},Ae={class:"flex items-start gap-2 p-3 md:hidden"},qe=["aria-expanded","onClick"],je={class:"mt-0.5 flex size-10 shrink-0 items-center justify-center rounded-full bg-muted text-sm font-semibold text-muted-foreground"},He={class:"min-w-0 flex-1"},Qe={class:"flex items-start justify-between gap-3"},Ye={class:"min-w-0"},Ge={class:"block truncate text-base font-semibold"},Xe={class:"mt-1 block truncate text-xs text-muted-foreground"},We={class:"mt-1 block truncate text-xs text-muted-foreground"},Ze={class:"flex size-10 shrink-0 items-center justify-center rounded-xl border border-border/70 text-muted-foreground"},Ke={class:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-muted-foreground"},Je={class:"inline-flex items-center gap-1.5"},et={class:"inline-flex items-center gap-1.5"},tt={class:"hidden items-start justify-between gap-3 p-4 pb-0 md:flex"},ot={class:"text-sm font-medium"},nt={class:"text-xs text-muted-foreground"},at={class:"grid gap-4 border-t pt-3 md:grid-cols-2 md:border-0 md:pt-4 xl:grid-cols-5"},rt={class:"grid gap-2"},lt={key:0,class:"text-xs text-orange-500"},st={class:"grid gap-2"},it={class:"grid gap-2"},ct={class:"grid gap-2"},dt={key:0,class:"grid gap-2"},ut=e.defineComponent({__name:"ReservationLines",props:{modelValue:{},agendaData:{}},emits:["add","quick-add","update:modelValue"],setup(w,{emit:B}){const y=w,E=B,D=e.computed(()=>y.modelValue??[]),T=e.computed(()=>Number(y.agendaData?.maxTicketsPerReservation)>1),p=e.ref(null),V=e.ref(!1),N=e.computed(()=>String(y.agendaData?.currency||"EUR").toUpperCase()),R=e.computed(()=>{try{return new Intl.NumberFormat("en-US",{style:"currency",currency:N.value,minimumFractionDigits:2,maximumFractionDigits:2})}catch{return new Intl.NumberFormat("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}}),f=s=>{E("update:modelValue",s)},k=(s,t,a)=>{f(D.value.map(n=>n.id!==s?n:t==="date"?{...n,date:String(a??""),dateValue:a||void 0}:{...n,[t]:a}))},g=(s,t)=>{const a=Number(t);k(s,"paid",Number.isFinite(a)?a:0)},$=(s,t)=>{const a=Number(t);k(s,"spots",Number.isFinite(a)&&a>0?a:1)},I=s=>{f(D.value.filter(t=>t.id!==s))},O=s=>{E("quick-add",s),V.value=!1},F=s=>y.agendaData?.pricingOptions?.find(t=>t.id===s.pricingOption),z=s=>{const t=F(s);return t?t.duration?`${t.name} (${t.duration}min)`:t.name:"Reservation"},L=s=>y.agendaData?.resources?.find(t=>t.id===s.resourceId),d=s=>L(s)?.name||"Unknown resource",v=s=>{if(!s.startTime)return"";const t=Number(F(s)?.duration);if(!Number.isFinite(t)||t<=0)return"";const[a,n]=s.startTime.split(":").map(Number);if(!Number.isFinite(a)||!Number.isFinite(n))return"";const r=a*60+n+t,S=Math.floor(r/60)%24,_=r%60;return`${S.toString().padStart(2,"0")}:${_.toString().padStart(2,"0")}`},u=s=>{if(!s.startTime)return"Select time";const t=v(s);return t?`${s.startTime} - ${t}`:s.startTime},h=s=>{const t=Number(s);if(!Number.isFinite(t))return N.value==="EUR"?"€0.00":"0.00";try{return R.value.format(t)}catch{return`${t.toFixed(2)}`}},b=s=>{const t=Number(s.spots),a=Number.isFinite(t)&&t>0?t:1;return a===1?"1 spot":`${a} spots`},P=s=>{if(!/^\d{4}-\d{2}-\d{2}$/.test(s))return null;const[t,a,n]=s.split("-").map(Number),r=new Date(t,a-1,n);return Number.isNaN(r.getTime())||r.getFullYear()!==t||r.getMonth()!==a-1||r.getDate()!==n?null:(r.setHours(0,0,0,0),r)},A=s=>{const t=P(String(s.date||"").trim());if(!t)return"";const a=new Date;if(a.setHours(0,0,0,0),t<a)return"This date is in the past. Double-check it before saving.";const n=new Date(a);return n.setFullYear(n.getFullYear()+1),t>n?"This date is more than a year ahead. Double-check it before saving.":""},q=s=>!s.date||!s.startTime||!s.resourceId||!s.pricingOption,j=s=>p.value===s,U=s=>{p.value=p.value===s?null:s};return e.watch(D,s=>{const t=new Set(s.map(a=>a.id));if(p.value&&!t.has(p.value)&&(p.value=null),!p.value){const a=s.find(q);a&&(p.value=a.id)}},{immediate:!0}),(s,t)=>{const a=e.resolveComponent("Button"),n=e.resolveComponent("PopoverTrigger"),r=e.resolveComponent("PopoverContent"),S=e.resolveComponent("Popover"),_=e.resolveComponent("Label"),i=e.resolveComponent("Input"),o=e.resolveComponent("DynamicSelectOption"),c=e.resolveComponent("DynamicSelect");return e.openBlock(),e.createElementBlock("div",Fe,[e.createElementVNode("div",Oe,[e.createElementVNode("p",Pe,e.toDisplayString(D.value.length===1?"1 reservation line":`${D.value.length} reservation lines`),1),e.createElementVNode("div",Me,[e.createVNode(S,{open:V.value,"onUpdate:open":t[0]||(t[0]=l=>V.value=l)},{default:e.withCtx(()=>[e.createVNode(n,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(a,{type:"button",variant:"outline",size:"sm",class:"gap-2"},{default:e.withCtx(()=>[e.createVNode(e.unref(M.Zap),{class:"size-4 text-primary"}),t[2]||(t[2]=e.createTextVNode(" Quick add ",-1))]),_:1})]),_:1}),e.createVNode(r,{align:"end",class:"max-h-[80vh] w-[min(34rem,calc(100vw-2rem))] overflow-y-auto p-0"},{default:e.withCtx(()=>[V.value?(e.openBlock(),e.createBlock(Le,{key:0,surface:"popover",agendaData:w.agendaData,onAdd:O},null,8,["agendaData"])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["open"]),e.createVNode(a,{type:"button",variant:"outline",size:"sm",onClick:t[1]||(t[1]=l=>E("add"))},{default:e.withCtx(()=>[e.createVNode(e.unref(M.Plus),{class:"size-4"}),t[3]||(t[3]=e.createTextVNode(" Add line ",-1))]),_:1})])]),D.value.length===0?(e.openBlock(),e.createElementBlock("div",Ue," Use Quick add to create filled reservation lines, or add an empty line manually. ")):(e.openBlock(),e.createElementBlock("div",ze,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(D.value,(l,C)=>(e.openBlock(),e.createElementBlock("div",{key:l.id,class:"rounded-xl border bg-background"},[e.createElementVNode("div",Ae,[e.createElementVNode("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-3 rounded-lg px-1 py-1 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring/50","aria-expanded":j(l.id),onClick:m=>U(l.id)},[e.createElementVNode("span",je,e.toDisplayString(C+1),1),e.createElementVNode("span",He,[e.createElementVNode("span",Qe,[e.createElementVNode("span",Ye,[e.createElementVNode("span",Ge,e.toDisplayString(u(l)),1),e.createElementVNode("span",Xe,e.toDisplayString(l.date||"No date selected"),1),e.createElementVNode("span",We,e.toDisplayString(d(l))+" · "+e.toDisplayString(z(l)),1)]),e.createElementVNode("span",Ze,[e.createVNode(e.unref(M.Pencil),{class:"size-4"})])]),e.createElementVNode("span",Ke,[e.createElementVNode("span",Je,[e.createVNode(e.unref(M.Users),{class:"size-4"}),e.createTextVNode(" "+e.toDisplayString(b(l)),1)]),e.createElementVNode("span",et,[e.createVNode(e.unref(M.Tag),{class:"size-4"}),e.createTextVNode(" "+e.toDisplayString(h(l.paid)),1)])])])],8,qe),e.createVNode(a,{type:"button",variant:"ghost",size:"icon",class:"mt-1 shrink-0",onClick:m=>I(l.id)},{default:e.withCtx(()=>[e.createVNode(e.unref(M.Trash2),{class:"size-4"})]),_:1},8,["onClick"])]),e.createElementVNode("div",tt,[e.createElementVNode("div",null,[e.createElementVNode("p",ot,"Reservation "+e.toDisplayString(C+1),1),e.createElementVNode("p",nt,e.toDisplayString(d(l))+" · "+e.toDisplayString(z(l)),1)]),e.createVNode(a,{type:"button",variant:"ghost",size:"icon",class:"shrink-0",onClick:m=>I(l.id)},{default:e.withCtx(()=>[e.createVNode(e.unref(M.Trash2),{class:"size-4"})]),_:1},8,["onClick"])]),e.createElementVNode("div",{class:e.normalizeClass(["px-3 pb-3 md:px-4 md:pb-4 overflow-hidden",j(l.id)?"block":"hidden md:block"])},[e.createElementVNode("div",at,[e.createElementVNode("div",rt,[e.createVNode(_,null,{default:e.withCtx(()=>[...t[4]||(t[4]=[e.createTextVNode("Date",-1)])]),_:1}),e.createVNode(i,{"model-value":l.date,type:"date","onUpdate:modelValue":m=>k(l.id,"date",String(m??""))},null,8,["model-value","onUpdate:modelValue"]),A(l)?(e.openBlock(),e.createElementBlock("p",lt,e.toDisplayString(A(l)),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",st,[e.createVNode(_,{for:`new_reservation_res_line_${C}_time`},{default:e.withCtx(()=>[...t[5]||(t[5]=[e.createTextVNode("Time",-1)])]),_:1},8,["for"]),e.createVNode(i,{id:`new_reservation_res_line_${C}_time`,"model-value":l.startTime,type:"time",class:"reservation-time-input","onUpdate:modelValue":m=>k(l.id,"startTime",String(m??""))},null,8,["id","model-value","onUpdate:modelValue"])]),e.createElementVNode("div",it,[e.createVNode(_,null,{default:e.withCtx(()=>[...t[6]||(t[6]=[e.createTextVNode("Resource",-1)])]),_:1}),e.createVNode(c,{"model-value":l.resourceId,"wrapper-class":"w-full",class:"w-full",placeholder:"Select resource","onUpdate:modelValue":m=>k(l.id,"resourceId",String(m??""))},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.agendaData?.resources||[],m=>(e.openBlock(),e.createBlock(o,{key:m.id,value:m.id},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["model-value","onUpdate:modelValue"])]),e.createElementVNode("div",ct,[e.createVNode(_,null,{default:e.withCtx(()=>[...t[7]||(t[7]=[e.createTextVNode("Type",-1)])]),_:1}),e.createVNode(c,{"model-value":l.pricingOption,"wrapper-class":"w-full",class:"w-full",placeholder:"Select type","onUpdate:modelValue":m=>k(l.id,"pricingOption",String(m??""))},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.agendaData?.pricingOptions||[],m=>(e.openBlock(),e.createBlock(o,{key:m.id,value:m.id},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["model-value","onUpdate:modelValue"])]),e.createElementVNode("div",{class:e.normalizeClass(["grid gap-4",T.value?"md:grid-cols-2 xl:grid-cols-2 xl:col-span-1":""])},[T.value?(e.openBlock(),e.createElementBlock("div",dt,[e.createVNode(_,null,{default:e.withCtx(()=>[...t[8]||(t[8]=[e.createTextVNode("Spots",-1)])]),_:1}),e.createVNode(i,{"model-value":l.spots,type:"number",min:"1",class:"no-spinner","onUpdate:modelValue":m=>$(l.id,m)},null,8,["model-value","onUpdate:modelValue"])])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["grid gap-2",T.value?"":"md:col-span-2 xl:col-span-1"])},[e.createVNode(_,null,{default:e.withCtx(()=>[...t[9]||(t[9]=[e.createTextVNode("Paid",-1)])]),_:1}),e.createVNode(i,{"model-value":l.paid,type:"number",min:"0",step:"1",class:"no-spinner","onUpdate:modelValue":m=>g(l.id,m)},null,8,["model-value","onUpdate:modelValue"])],2)],2)])],2)]))),128))]))])}}}),mt=te._export_sfc(ut,[["__scopeId","data-v-9b860aae"]]),pt={class:"space-y-5 md:mt-5"},ft={class:"space-y-3"},gt={class:"mt-4 text-red-400"},vt={class:"list-disc pl-4"},ht={key:0},_t={key:1},ee="00:00",kt=e.defineComponent({__name:"NewReservationDialog",props:{agendaData:{}},setup(w){const B=w,{params:y}=W.useModuleRoute(),{config:E}=W.useModule(),D=W.useFirebaseIntegration(E.project),T=e.computed(()=>y.value?.id??y.id??""),p=e.inject("agendaData",e.ref({})),V=e.computed(()=>B.agendaData??p.value??{}),N=e.ref(!1),R=e.ref(!1),f=e.ref([]),k=/^([01]\d|2[0-3]):[0-5]\d$/,g=e.ref([]),$=e.ref(null),I=()=>V.value?.resources?.[0]?.id??"",O=()=>V.value?.pricingOptions?.find(t=>t.isDefault===!0)?.id??V.value?.pricingOptions?.[0]?.id??"",F=t=>{let a=t?.pricingOption??O(),n=V.value?.pricingOptions?.find(S=>S.id===a)?.price??0;typeof n=="string"&&(n=Number(n));let r=t?.paid??n;return typeof r=="string"&&(r=Number(r)),{id:`reservation_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,spots:Number(t?.spots)||1,paid:Number.isFinite(r)?r:0,resourceId:t?.resourceId??I(),pricingOption:a,date:t?.date??"",dateValue:t?.dateValue,startTime:t?.startTime??ee}},z=()=>{g.value=[F()]},L=t=>!t.date&&t.startTime===ee,d=()=>{const t=g.value[g.value.length-1];g.value=[...g.value,F(t?{...t}:void 0)]},v=t=>V.value?.pricingOptions?.find(a=>a.id===t.pricingOption),u=t=>V.value?.resources?.find(a=>a.id===t.resourceId),h=()=>{const t=Number(V.value?.maxTicketsPerReservation);return Number.isFinite(t)&&t>0?t:null},b=t=>`Reservation ${t+1}`,P=t=>{const a=String(t.date||"").trim(),n=String(t.startTime||"").trim(),r=String(t.resourceId||"").trim();return!a||!n||!r?"":`${r}_${a}_${n}`},A=()=>{const t=[],a=new Map,n=h();return g.value.forEach((r,S)=>{const _=b(S),i=String(r.date||"").trim(),o=String(r.startTime||"").trim(),c=String(r.resourceId||"").trim(),l=String(r.pricingOption||"").trim(),C=Number(r.spots),m=Number(r.paid);i||t.push(`${_}: please select a date.`),o?k.test(o)||t.push(`${_}: please enter a valid time.`):t.push(`${_}: please select a time.`),c?u(r)||t.push(`${_}: the selected resource is no longer available.`):t.push(`${_}: please select a resource.`),l?v(r)||t.push(`${_}: the selected type is no longer available.`):t.push(`${_}: please select a type.`),!Number.isFinite(C)||C<=0?t.push(`${_}: spots must be at least 1.`):n!==null&&C>n&&t.push(`${_}: spots cannot be more than ${n}.`),(!Number.isFinite(m)||m<0)&&t.push(`${_}: paid amount must be 0 or higher.`);const H=P(r);if(H){const Q=a.get(H);Q!==void 0?t.push(`${_}: duplicate of ${b(Q).toLowerCase()}.`):a.set(H,S)}}),t},q=t=>{const a=t.startTimes.map(n=>F({date:t.date?`${t.date}`:"",dateValue:t.date,pricingOption:t.pricingOptionId,resourceId:t.resourceId,spots:t.spots,startTime:n}));if(a.length!==0){if(g.value.length===1&&L(g.value[0])){g.value=a;return}g.value=[...g.value,...a]}},j=t=>{if(!t.startTime||!t.pricingOption)return"";const a=v(t);if(!a?.duration)return t.startTime;const[n,r]=t.startTime.split(":").map(Number);if(isNaN(n)||isNaN(r))return"";const S=n*60+r+a.duration,_=Math.floor(S/60)%24,i=S%60;return`${_.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`};e.watch(N,async t=>{t&&(f.value=[],z(),await e.nextTick(),$.value?.reset())});const U=()=>{const t=[];f.value=[];const a=$.value,n=a?a.validateForm():!1;return a||t.push("Customer information form is unavailable."),g.value.length===0&&t.push("Please add at least one reservation."),t.push(...A()),f.value=t,t.length===0&&n},s=async()=>{const t=$.value;if(!t||!U())return;let a=!1;try{R.value=!0;const n=t.getCustomerInfo(),r=g.value.map(i=>{const o=Number(i.paid)||0,c=Number(i.spots)||1,l=v(i),C=u(i),m=i.date;return{paidAmount:o,flattenedReservationDate:`${i.resourceId}_${m}`,flattenedReservation:`${i.resourceId}_${m}_${i.startTime.replace(":","")}`,reservation:{status:"approved",totalPrice:Number(o.toFixed(2)),basePrice:Number((o/c).toFixed(2)),addOnsPrice:0,addOns:[],date:m,id:`res_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,pricingOption:{duration:l?.duration||"",id:l?.id||"",name:l?.name||"",price:l?.price||""},pricingOptionId:i.pricingOption,resource:{avatarLabel:C?.avatarLabel||"",color:C?.color||"",description:C?.description||"",id:C?.id||"",name:C?.name||""},resourceId:i.resourceId,spots:c,timeslot:{startTime:i.startTime,endTime:j(i)}}}}),S=Number(r.reduce((i,o)=>i+o.paidAmount,0).toFixed(2)),_={agendaId:T.value,customerInfo:n,metadata:{},amountPaid:S,amountDue:0,subtotal:S,total:S,createdAt:new Date,updatedAt:new Date,discount:0,flattenedReservationDates:Array.from(new Set(r.map(i=>i.flattenedReservationDate))),flattenedReservations:r.map(i=>i.flattenedReservation),paymentStatus:"paid",paymentType:"full",reservations:r.map(i=>i.reservation),status:"confirmed"};await D.add(E.reservationsCollection,_),a=!0}catch(n){console.error("Error creating reservation:",n)}finally{R.value=!1,a&&(N.value=!1)}};return(t,a)=>{const n=e.resolveComponent("Button"),r=e.resolveComponent("ResponsiveModalTrigger"),S=e.resolveComponent("ResponsiveModalTitle"),_=e.resolveComponent("ResponsiveModalHeader"),i=e.resolveComponent("ResponsiveModalFooter"),o=e.resolveComponent("ResponsiveModalScrollContent"),c=e.resolveComponent("ResponsiveModal");return e.openBlock(),e.createBlock(c,{open:N.value,"onUpdate:open":a[1]||(a[1]=l=>N.value=l)},{default:e.withCtx(()=>[e.createVNode(r,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(n,null,{default:e.withCtx(()=>[e.createVNode(e.unref(M.Plus),{class:"size-4"}),a[2]||(a[2]=e.createTextVNode(" Add Reservation ",-1))]),_:1})]),_:1}),e.createVNode(o,{class:"@container/modal sm:max-w-7xl"},{default:e.withCtx(()=>[e.createVNode(_,null,{default:e.withCtx(()=>[e.createVNode(S,null,{default:e.withCtx(()=>[...a[3]||(a[3]=[e.createTextVNode("Create new reservation",-1)])]),_:1})]),_:1}),e.createElementVNode("div",pt,[e.createVNode(me,{ref_key:"customerInformationRef",ref:$,agendaData:V.value},null,8,["agendaData"]),a[5]||(a[5]=e.createElementVNode("div",{class:"w-full h-[1px] bg-border my-8"},null,-1)),e.createElementVNode("div",ft,[a[4]||(a[4]=e.createElementVNode("div",{class:"flex items-center justify-between gap-3"},[e.createElementVNode("h2",{class:"text-sm font-medium"},"Reservations")],-1)),e.createVNode(mt,{modelValue:g.value,"onUpdate:modelValue":a[0]||(a[0]=l=>g.value=l),agendaData:V.value,onAdd:d,onQuickAdd:q},null,8,["modelValue","agendaData"])]),e.createElementVNode("div",gt,[e.createElementVNode("ul",vt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,l=>(e.openBlock(),e.createElementBlock("li",{key:l},e.toDisplayString(l),1))),128))])])]),e.createVNode(i,{class:"gap-2"},{default:e.withCtx(()=>[e.createVNode(n,{onClick:s,disabled:R.value},{default:e.withCtx(()=>[R.value?(e.openBlock(),e.createElementBlock("span",ht,"Creating...")):(e.openBlock(),e.createElementBlock("span",_t,e.toDisplayString(g.value.length>1?`Create ${g.value.length} reservations`:"Create reservation"),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["open"])}}});exports._sfc_main=kt;
|