@oneclick.dev/cms-core-modules 0.0.66 → 0.0.68
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/{ContentEditor-owdOIage.mjs → ContentEditor-B7IYLH91.mjs} +6914 -6399
- package/dist/ContentEditor-LOn09n7N.js +307 -0
- package/dist/{Create-Lnus48i-.mjs → Create-BDiyCtrp.mjs} +1 -1
- package/dist/{Create-Up0iauPG.js → Create-D8NBEkJU.js} +1 -1
- package/dist/DateFormatter-Bw-SCfUS.js +1 -0
- package/dist/{DateFormatter-CxPCk9KT.mjs → DateFormatter-DAZP9a6L.mjs} +16 -10
- package/dist/{Detail-Bz2rvLw7.mjs → Detail-CxUU6BpO.mjs} +1 -1
- package/dist/{Detail-BPSuxN2J.js → Detail-DTHaYmyl.js} +1 -1
- package/dist/Entries-BPkZ7Jg5.js +1 -0
- package/dist/Entries-D7MHylQE.mjs +728 -0
- package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-DMnulmdl.js → NewReservationDialog.vue_vue_type_script_setup_true_lang-B-ZhMrMu.js} +1 -1
- package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-CZmLnut_.mjs → NewReservationDialog.vue_vue_type_script_setup_true_lang-CJ7hh7ug.mjs} +1 -1
- package/dist/{TableView-ifyIKxNm.js → TableView-COZzD0d0.js} +394 -100
- package/dist/{TableView-DnQLQHx6.mjs → TableView-Caa3Siid.mjs} +23994 -21142
- package/dist/{agenda-By_hEZ4I.mjs → agenda-CTG6N_Lt.mjs} +2 -2
- package/dist/{agenda-D4jdNRbI.js → agenda-OSkAh0Oa.js} +1 -1
- package/dist/cms-core-modules.css +1 -1
- package/dist/{exceptions-DGnziH-3.js → exceptions-BvMTqtof.js} +1 -1
- package/dist/{exceptions-B0kOmB-_.mjs → exceptions-CEXIFw47.mjs} +1 -1
- package/dist/{index-DIg9ePkI.js → index-D4GKxWP-.js} +32 -32
- package/dist/index-DuEgvvLH-BMcm6MOv.js +88 -0
- package/dist/{index-CzoYAqKd-iAfM7ky8.mjs → index-DuEgvvLH-DYNxw0e-.mjs} +1461 -1341
- package/dist/{index--0-qy_7x.mjs → index-J5jtsMas.mjs} +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +8 -8
- package/dist/src/content-manager/components/content-editor/tiptap-extensions/{Columns.d.ts → Row.d.ts} +2 -2
- package/dist/src/content-manager/components/content-editor/tiptap-extensions/Stack.d.ts +14 -0
- package/dist/src/content-manager/components/content-editor/tiptap-extensions/Stack.vue.d.ts +115 -0
- package/dist/src/content-manager/components/content-editor/tiptap-extensions/helpers/TopMarginDragger.vue.d.ts +11 -1
- package/dist/src/content-manager/components/content-editor/tiptap-menus/element-editor-views/RowMenu.vue.d.ts +13 -0
- package/dist/src/content-manager/components/content-editor/tiptap-menus/element-editor-views/StackMenu.vue.d.ts +13 -0
- package/dist/src/content-manager/components/content-editor/tiptap-menus/element-editor-views/index.d.ts +30 -2
- package/package.json +2 -2
- package/dist/ContentEditor-DKFCmfOs.js +0 -307
- package/dist/DateFormatter-DKlDa1Jq.js +0 -1
- package/dist/Entries-C6Di46My.mjs +0 -713
- package/dist/Entries-DlFiZ8EU.js +0 -1
- package/dist/index-CzoYAqKd-rheC_QgC.js +0 -88
- /package/dist/src/content-manager/components/content-editor/tiptap-extensions/{Columns.vue.d.ts → Row.vue.d.ts} +0 -0
- /package/dist/src/content-manager/components/content-editor/tiptap-menus/element-editor-views/{ColumnsMenu.vue.d.ts → DividerMenu.vue.d.ts} +0 -0
|
@@ -2,7 +2,7 @@ import { defineComponent as z, inject as L, resolveComponent as o, openBlock as
|
|
|
2
2
|
import { Import as re, DollarSign as oe, Percent as ne, Truck as se, Info as me, Loader2 as K, UserCog as pe, Plus as Z, Pencil as fe, Trash2 as ve, CalendarIcon as h, List as ce } from "lucide-vue-next";
|
|
3
3
|
import { useModulePermissions as j, useModuleStorage as W, useConfirmation as _e, useModuleRoute as ge, useProjectSettings as xe, useLogs as ye, useModuleBreadcrumbs as be, useFirebaseIntegration as we } from "@oneclick.dev/cms-kit";
|
|
4
4
|
import { c as ee } from "./utils-BVKy9S2J.mjs";
|
|
5
|
-
import { h as Ve, g as te, o as Ue } from "./DateFormatter-
|
|
5
|
+
import { h as Ve, g as te, o as Ue } from "./DateFormatter-DAZP9a6L.mjs";
|
|
6
6
|
import { t as I } from "./index-RLz1QPrf.mjs";
|
|
7
7
|
const Ce = /* @__PURE__ */ z({
|
|
8
8
|
__name: "SingleCode",
|
|
@@ -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-D6CaKJbp.js"),$=require("./DateFormatter-DKlDa1Jq.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 $.$fb18d541ea1ad717$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($.$14e0f24ef4ac5c92$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($.$14e0f24ef4ac5c92$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($.$14e0f24ef4ac5c92$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-D6CaKJbp.js"),$=require("./DateFormatter-Bw-SCfUS.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 $.$fb18d541ea1ad717$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($.$14e0f24ef4ac5c92$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($.$14e0f24ef4ac5c92$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($.$14e0f24ef4ac5c92$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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function U(e,t){return e-t*Math.floor(e/t)}const te=1721426;function E(e,t,r,n){t=A(e,t);let a=t-1,o=-2;return r<=2?o=0:Y(t)&&(o=-1),te-1+365*a+Math.floor(a/4)-Math.floor(a/100)+Math.floor(a/400)+Math.floor((367*r-362)/12+o+n)}function Y(e){return e%4===0&&(e%100!==0||e%400===0)}function A(e,t){return e==="BC"?1-t:t}function re(e){let t="AD";return e<=0&&(t="BC",e=1-e),[t,e]}const Me={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]};class b{fromJulianDay(t){let r=t,n=r-te,a=Math.floor(n/146097),o=U(n,146097),c=Math.floor(o/36524),i=U(o,36524),f=Math.floor(i/1461),h=U(i,1461),w=Math.floor(h/365),x=a*400+c*100+f*4+w+(c!==4&&w!==4?1:0),[g,m]=re(x),y=r-E(g,m,1,1),O=2;r<E(g,m,3,1)?O=0:Y(m)&&(O=1);let G=Math.floor(((y+O)*12+373)/367),pe=r-E(g,m,G,1)+1;return new M(g,m,G,pe)}toJulianDay(t){return E(t.era,t.year,t.month,t.day)}getDaysInMonth(t){return Me[Y(t.year)?"leapyear":"standard"][t.month-1]}getMonthsInYear(t){return 12}getDaysInYear(t){return Y(t.year)?366:365}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 31}getYearsInEra(t){return 9999}getEras(){return["BC","AD"]}isInverseEra(t){return t.era==="BC"}balanceDate(t){t.year<=0&&(t.era=t.era==="BC"?"AD":"BC",t.year=1-t.year)}constructor(){this.identifier="gregory"}}function J(e,t){return t=l(t,e.calendar),e.era===t.era&&e.year===t.year&&e.month===t.month&&e.day===t.day}function ne(e,t){return t=l(t,e.calendar),e=F(e),t=F(t),e.era===t.era&&e.year===t.year&&e.month===t.month}function we(e,t){return W(e.calendar,t.calendar)&&J(e,t)}function xe(e,t){return W(e.calendar,t.calendar)&&ne(e,t)}function W(e,t){var r,n,a,o;return(o=(a=(r=e.isEqual)===null||r===void 0?void 0:r.call(e,t))!==null&&a!==void 0?a:(n=t.isEqual)===null||n===void 0?void 0:n.call(t,e))!==null&&o!==void 0?o:e.identifier===t.identifier}function ge(e,t){return J(e,ae(t))}const ve={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6};function De(e,t,r){let n=e.calendar.toJulianDay(e),a=ve[r],o=Math.ceil(n+1-a)%7;return o<0&&(o+=7),o}function Ie(e){return u(Date.now(),e)}function ae(e){return Te(Ie(e))}function oe(e,t){return e.calendar.toJulianDay(e)-t.calendar.toJulianDay(t)}function Se(e,t){return Q(e)-Q(t)}function Q(e){return e.hour*36e5+e.minute*6e4+e.second*1e3+e.millisecond}let P=null;function N(){return P==null&&(P=new Intl.DateTimeFormat().resolvedOptions().timeZone),P}function F(e){return e.subtract({days:e.day-1})}function Ce(e){return e.add({days:e.calendar.getDaysInMonth(e)-e.day})}function v(e){e=l(e,new b);let t=A(e.era,e.year);return ce(t,e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function ce(e,t,r,n,a,o,c){let i=new Date;return i.setUTCHours(n,a,o,c),i.setUTCFullYear(e,t-1,r),i.getTime()}function j(e,t){if(t==="UTC")return 0;if(e>0&&t===N())return new Date(e).getTimezoneOffset()*-6e4;let{year:r,month:n,day:a,hour:o,minute:c,second:i}=ie(e,t);return ce(r,n,a,o,c,i,0)-Math.floor(e/1e3)*1e3}const X=new Map;function ie(e,t){let r=X.get(t);r||(r=new Intl.DateTimeFormat("en-US",{timeZone:t,hour12:!1,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),X.set(t,r));let n=r.formatToParts(new Date(e)),a={};for(let o of n)o.type!=="literal"&&(a[o.type]=o.value);return{year:a.era==="BC"||a.era==="B"?-a.year+1:+a.year,month:+a.month,day:+a.day,hour:a.hour==="24"?0:+a.hour,minute:+a.minute,second:+a.second}}const ee=864e5;function Ee(e,t,r,n){return(r===n?[r]:[r,n]).filter(o=>Ye(e,t,o))}function Ye(e,t,r){let n=ie(r,t);return e.year===n.year&&e.month===n.month&&e.day===n.day&&e.hour===n.hour&&e.minute===n.minute&&e.second===n.second}function d(e,t,r="compatible"){let n=D(e);if(t==="UTC")return v(n);if(t===N()&&r==="compatible"){n=l(n,new b);let f=new Date,h=A(n.era,n.year);return f.setFullYear(h,n.month-1,n.day),f.setHours(n.hour,n.minute,n.second,n.millisecond),f.getTime()}let a=v(n),o=j(a-ee,t),c=j(a+ee,t),i=Ee(n,t,a-o,a-c);if(i.length===1)return i[0];if(i.length>1)switch(r){case"compatible":case"earlier":return i[0];case"later":return i[i.length-1];case"reject":throw new RangeError("Multiple possible absolute times found")}switch(r){case"earlier":return Math.min(a-o,a-c);case"compatible":case"later":return Math.max(a-o,a-c);case"reject":throw new RangeError("No such absolute time found")}}function fe(e,t,r="compatible"){return new Date(d(e,t,r))}function u(e,t){let r=j(e,t),n=new Date(e+r),a=n.getUTCFullYear(),o=n.getUTCMonth()+1,c=n.getUTCDate(),i=n.getUTCHours(),f=n.getUTCMinutes(),h=n.getUTCSeconds(),w=n.getUTCMilliseconds();return new S(a<1?"BC":"AD",a<1?-a+1:a,o,c,t,r,i,f,h,w)}function Te(e){return new M(e.calendar,e.era,e.year,e.month,e.day)}function D(e,t){let r=0,n=0,a=0,o=0;if("timeZone"in e)({hour:r,minute:n,second:a,millisecond:o}=e);else if("hour"in e&&!t)return e;return t&&({hour:r,minute:n,second:a,millisecond:o}=t),new I(e.calendar,e.era,e.year,e.month,e.day,r,n,a,o)}function l(e,t){if(W(e.calendar,t))return e;let r=t.fromJulianDay(e.calendar.toJulianDay(e)),n=e.copy();return n.calendar=t,n.era=r.era,n.year=r.year,n.month=r.month,n.day=r.day,p(n),n}function Ue(e,t,r){if(e instanceof S)return e.timeZone===t?e:Ae(e,t);let n=d(e,t,r);return u(n,t)}function ke(e){let t=v(e)-e.offset;return new Date(t)}function Ae(e,t){let r=v(e)-e.offset;return l(u(r,t),e.calendar)}const C=36e5;function B(e,t){let r=e.copy(),n="hour"in r?Re(r,t):0;q(r,t.years||0),r.calendar.balanceYearMonth&&r.calendar.balanceYearMonth(r,e),r.month+=t.months||0,_(r),le(r),r.day+=(t.weeks||0)*7,r.day+=t.days||0,r.day+=n,Be(r),r.calendar.balanceDate&&r.calendar.balanceDate(r),r.year<1&&(r.year=1,r.month=1,r.day=1);let a=r.calendar.getYearsInEra(r);if(r.year>a){var o,c;let f=(o=(c=r.calendar).isInverseEra)===null||o===void 0?void 0:o.call(c,r);r.year=a,r.month=f?1:r.calendar.getMonthsInYear(r),r.day=f?1:r.calendar.getDaysInMonth(r)}r.month<1&&(r.month=1,r.day=1);let i=r.calendar.getMonthsInYear(r);return r.month>i&&(r.month=i,r.day=r.calendar.getDaysInMonth(r)),r.day=Math.max(1,Math.min(r.calendar.getDaysInMonth(r),r.day)),r}function q(e,t){var r,n;!((r=(n=e.calendar).isInverseEra)===null||r===void 0)&&r.call(n,e)&&(t=-t),e.year+=t}function _(e){for(;e.month<1;)q(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,q(e,1)}function Be(e){for(;e.day<1;)e.month--,_(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,_(e)}function le(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function p(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),le(e)}function se(e){let t={};for(let r in e)typeof e[r]=="number"&&(t[r]=-e[r]);return t}function he(e,t){return B(e,se(t))}function V(e,t){let r=e.copy();return t.era!=null&&(r.era=t.era),t.year!=null&&(r.year=t.year),t.month!=null&&(r.month=t.month),t.day!=null&&(r.day=t.day),p(r),r}function k(e,t){let r=e.copy();return t.hour!=null&&(r.hour=t.hour),t.minute!=null&&(r.minute=t.minute),t.second!=null&&(r.second=t.second),t.millisecond!=null&&(r.millisecond=t.millisecond),Pe(r),r}function Oe(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=T(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=T(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=T(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=T(e.hour,24),t}function Pe(e){e.millisecond=Math.max(0,Math.min(e.millisecond,1e3)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function T(e,t){let r=e%t;return r<0&&(r+=t),r}function Re(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,Oe(e)}function z(e,t,r,n){let a=e.copy();switch(t){case"era":{let i=e.calendar.getEras(),f=i.indexOf(e.era);if(f<0)throw new Error("Invalid era: "+e.era);f=$(f,r,0,i.length-1,n?.round),a.era=i[f],p(a);break}case"year":var o,c;!((o=(c=a.calendar).isInverseEra)===null||o===void 0)&&o.call(c,a)&&(r=-r),a.year=$(e.year,r,-1/0,9999,n?.round),a.year===-1/0&&(a.year=1),a.calendar.balanceYearMonth&&a.calendar.balanceYearMonth(a,e);break;case"month":a.month=$(e.month,r,1,e.calendar.getMonthsInYear(e),n?.round);break;case"day":a.day=$(e.day,r,1,e.calendar.getDaysInMonth(e),n?.round);break;default:throw new Error("Unsupported field "+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(a),p(a),a}function de(e,t,r,n){let a=e.copy();switch(t){case"hour":{let o=e.hour,c=0,i=23;if(n?.hourCycle===12){let f=o>=12;c=f?12:0,i=f?23:11}a.hour=$(o,r,c,i,n?.round);break}case"minute":a.minute=$(e.minute,r,0,59,n?.round);break;case"second":a.second=$(e.second,r,0,59,n?.round);break;case"millisecond":a.millisecond=$(e.millisecond,r,0,999,n?.round);break;default:throw new Error("Unsupported field "+t)}return a}function $(e,t,r,n,a=!1){if(a){e+=Math.sign(t),e<r&&(e=n);let o=Math.abs(t);t>0?e=Math.ceil(e/o)*o:e=Math.floor(e/o)*o,e>n&&(e=r)}else e+=t,e<r?e=n-(r-e-1):e>n&&(e=r+(e-n-1));return e}function ue(e,t){let r;if(t.years!=null&&t.years!==0||t.months!=null&&t.months!==0||t.weeks!=null&&t.weeks!==0||t.days!=null&&t.days!==0){let a=B(D(e),{years:t.years,months:t.months,weeks:t.weeks,days:t.days});r=d(a,e.timeZone)}else r=v(e)-e.offset;r+=t.milliseconds||0,r+=(t.seconds||0)*1e3,r+=(t.minutes||0)*6e4,r+=(t.hours||0)*36e5;let n=u(r,e.timeZone);return l(n,e.calendar)}function He(e,t){return ue(e,se(t))}function Ze(e,t,r,n){switch(t){case"hour":{let a=0,o=23;if(n?.hourCycle===12){let y=e.hour>=12;a=y?12:0,o=y?23:11}let c=D(e),i=l(k(c,{hour:a}),new b),f=[d(i,e.timeZone,"earlier"),d(i,e.timeZone,"later")].filter(y=>u(y,e.timeZone).day===i.day)[0],h=l(k(c,{hour:o}),new b),w=[d(h,e.timeZone,"earlier"),d(h,e.timeZone,"later")].filter(y=>u(y,e.timeZone).day===h.day).pop(),x=v(e)-e.offset,g=Math.floor(x/C),m=x%C;return x=$(g,r,Math.floor(f/C),Math.floor(w/C),n?.round)*C+m,l(u(x,e.timeZone),e.calendar)}case"minute":case"second":case"millisecond":return de(e,t,r,n);case"era":case"year":case"month":case"day":{let a=z(D(e),t,r,n),o=d(a,e.timeZone);return l(u(o,e.timeZone),e.calendar)}default:throw new Error("Unsupported field "+t)}}function Fe(e,t,r){let n=D(e),a=k(V(n,t),t);if(a.compare(n)===0)return e;let o=d(a,e.timeZone,r);return l(u(o,e.timeZone),e.calendar)}const je=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/,qe=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?$/,$e=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;function _e(e){let t=e.match(je);if(!t)throw $e.test(e)?new Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date string: "+e);let r=new M(s(t[1],0,9999),s(t[2],1,12),1);return r.day=s(t[3],1,r.calendar.getDaysInMonth(r)),r}function Je(e){let t=e.match(qe);if(!t)throw $e.test(e)?new Error(`Invalid ISO 8601 date time string: ${e}. Use parseAbsolute() instead.`):new Error("Invalid ISO 8601 date time string: "+e);let r=s(t[1],-9999,9999),n=r<1?"BC":"AD",a=new I(n,r<1?-r+1:r,s(t[2],1,12),1,t[4]?s(t[4],0,23):0,t[5]?s(t[5],0,59):0,t[6]?s(t[6],0,59):0,t[7]?s(t[7],0,1/0)*1e3:0);return a.day=s(t[3],0,a.calendar.getDaysInMonth(a)),a}function s(e,t,r){let n=Number(e);if(n<t||n>r)throw new RangeError(`Value out of range: ${t} <= ${n} <= ${r}`);return n}function We(e){return`${String(e.hour).padStart(2,"0")}:${String(e.minute).padStart(2,"0")}:${String(e.second).padStart(2,"0")}${e.millisecond?String(e.millisecond/1e3).slice(1):""}`}function ye(e){let t=l(e,new b),r;return t.era==="BC"?r=t.year===1?"0000":"-"+String(Math.abs(1-t.year)).padStart(6,"00"):r=String(t.year).padStart(4,"0"),`${r}-${String(t.month).padStart(2,"0")}-${String(t.day).padStart(2,"0")}`}function me(e){return`${ye(e)}T${We(e)}`}function Ne(e){let t=Math.sign(e)<0?"-":"+";e=Math.abs(e);let r=Math.floor(e/36e5),n=Math.floor(e%36e5/6e4),a=Math.floor(e%36e5%6e4/1e3),o=`${t}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`;return a!==0&&(o+=`:${String(a).padStart(2,"0")}`),o}function Ve(e){return`${me(e)}${Ne(e.offset)}[${e.timeZone}]`}function ze(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function L(e,t,r){ze(e,t),t.set(e,r)}function K(e){let t=typeof e[0]=="object"?e.shift():new b,r;if(typeof e[0]=="string")r=e.shift();else{let c=t.getEras();r=c[c.length-1]}let n=e.shift(),a=e.shift(),o=e.shift();return[t,r,n,a,o]}var Le=new WeakMap;class M{copy(){return this.era?new M(this.calendar,this.era,this.year,this.month,this.day):new M(this.calendar,this.year,this.month,this.day)}add(t){return B(this,t)}subtract(t){return he(this,t)}set(t){return V(this,t)}cycle(t,r,n){return z(this,t,r,n)}toDate(t){return fe(this,t)}toString(){return ye(this)}compare(t){return oe(this,t)}constructor(...t){L(this,Le,{writable:!0,value:void 0});let[r,n,a,o,c]=K(t);this.calendar=r,this.era=n,this.year=a,this.month=o,this.day=c,p(this)}}var Ke=new WeakMap;class I{copy(){return this.era?new I(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new I(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(t){return B(this,t)}subtract(t){return he(this,t)}set(t){return V(k(this,t),t)}cycle(t,r,n){switch(t){case"era":case"year":case"month":case"day":return z(this,t,r,n);default:return de(this,t,r,n)}}toDate(t,r){return fe(this,t,r)}toString(){return me(this)}compare(t){let r=oe(this,t);return r===0?Se(this,D(t)):r}constructor(...t){L(this,Ke,{writable:!0,value:void 0});let[r,n,a,o,c]=K(t);this.calendar=r,this.era=n,this.year=a,this.month=o,this.day=c,this.hour=t.shift()||0,this.minute=t.shift()||0,this.second=t.shift()||0,this.millisecond=t.shift()||0,p(this)}}var Ge=new WeakMap;class S{copy(){return this.era?new S(this.calendar,this.era,this.year,this.month,this.day,this.timeZone,this.offset,this.hour,this.minute,this.second,this.millisecond):new S(this.calendar,this.year,this.month,this.day,this.timeZone,this.offset,this.hour,this.minute,this.second,this.millisecond)}add(t){return ue(this,t)}subtract(t){return He(this,t)}set(t,r){return Fe(this,t,r)}cycle(t,r,n){return Ze(this,t,r,n)}toDate(){return ke(this)}toString(){return Ve(this)}toAbsoluteString(){return this.toDate().toISOString()}compare(t){return this.toDate().getTime()-Ue(t,this.timeZone).toDate().getTime()}constructor(...t){L(this,Ge,{writable:!0,value:void 0});let[r,n,a,o,c]=K(t),i=t.shift(),f=t.shift();this.calendar=r,this.era=n,this.year=a,this.month=o,this.day=c,this.timeZone=i,this.offset=f,this.hour=t.shift()||0,this.minute=t.shift()||0,this.second=t.shift()||0,this.millisecond=t.shift()||0,p(this)}}let R=new Map;class Qe{format(t){return this.formatter.format(t)}formatToParts(t){return this.formatter.formatToParts(t)}formatRange(t,r){if(typeof this.formatter.formatRange=="function")return this.formatter.formatRange(t,r);if(r<t)throw new RangeError("End date must be >= start date");return`${this.formatter.format(t)} – ${this.formatter.format(r)}`}formatRangeToParts(t,r){if(typeof this.formatter.formatRangeToParts=="function")return this.formatter.formatRangeToParts(t,r);if(r<t)throw new RangeError("End date must be >= start date");let n=this.formatter.formatToParts(t),a=this.formatter.formatToParts(r);return[...n.map(o=>({...o,source:"startRange"})),{type:"literal",value:" – ",source:"shared"},...a.map(o=>({...o,source:"endRange"}))]}resolvedOptions(){let t=this.formatter.resolvedOptions();return tt()&&(this.resolvedHourCycle||(this.resolvedHourCycle=rt(t.locale,this.options)),t.hourCycle=this.resolvedHourCycle,t.hour12=this.resolvedHourCycle==="h11"||this.resolvedHourCycle==="h12"),t.calendar==="ethiopic-amete-alem"&&(t.calendar="ethioaa"),t}constructor(t,r={}){this.formatter=be(t,r),this.options=r}}const Xe={true:{ja:"h11"},false:{}};function be(e,t={}){if(typeof t.hour12=="boolean"&&et()){t={...t};let a=Xe[String(t.hour12)][e.split("-")[0]],o=t.hour12?"h12":"h23";t.hourCycle=a??o,delete t.hour12}let r=e+(t?Object.entries(t).sort((a,o)=>a[0]<o[0]?-1:1).join():"");if(R.has(r))return R.get(r);let n=new Intl.DateTimeFormat(e,t);return R.set(r,n),n}let H=null;function et(){return H==null&&(H=new Intl.DateTimeFormat("en-US",{hour:"numeric",hour12:!1}).format(new Date(2020,2,3,0))==="24"),H}let Z=null;function tt(){return Z==null&&(Z=new Intl.DateTimeFormat("fr",{hour:"numeric",hour12:!1}).resolvedOptions().hourCycle==="h12"),Z}function rt(e,t){if(!t.timeStyle&&!t.hour)return;e=e.replace(/(-u-)?-nu-[a-zA-Z0-9]+/,""),e+=(e.includes("-u-")?"":"-u")+"-nu-latn";let r=be(e,{...t,timeZone:void 0}),n=parseInt(r.formatToParts(new Date(2020,2,3,0)).find(o=>o.type==="hour").value,10),a=parseInt(r.formatToParts(new Date(2020,2,3,23)).find(o=>o.type==="hour").value,10);if(n===0&&a===23)return"h23";if(n===24&&a===23)return"h24";if(n===0&&a===11)return"h11";if(n===12&&a===11)return"h12";throw new Error("Unexpected hour cycle result")}exports.$11d87f3f76e88657$export$b4a036af3fc0b032=l;exports.$14e0f24ef4ac5c92$export$2061056d06d7cdf7=De;exports.$14e0f24ef4ac5c92$export$5a8da0c44a3afdf2=xe;exports.$14e0f24ef4ac5c92$export$629b0a497aa65267=ge;exports.$14e0f24ef4ac5c92$export$91b62ebf2ba703ee=we;exports.$14e0f24ef4ac5c92$export$a18c89cbd24170ff=ne;exports.$14e0f24ef4ac5c92$export$a2258d9c4118825c=Ce;exports.$14e0f24ef4ac5c92$export$a5a3b454ada2268e=F;exports.$14e0f24ef4ac5c92$export$aa8b41735afcabd2=N;exports.$14e0f24ef4ac5c92$export$d0bdf45af03a6ea3=ae;exports.$14e0f24ef4ac5c92$export$ea39ec197993aef0=J;exports.$2b4dce13dd5a17fa$export$842a2cf37af977e1=U;exports.$35ea8db9cb2ccb90$export$99faa760c7908e4f=M;exports.$35ea8db9cb2ccb90$export$ca871e8dbb80966f=I;exports.$35ea8db9cb2ccb90$export$d3b7288e7994edea=S;exports.$3b62074eb05584b2$export$4475b7e617eb123c=re;exports.$3b62074eb05584b2$export$553d7fa8e3805fc0=Y;exports.$3b62074eb05584b2$export$80ee6245ec4f29ec=b;exports.$3b62074eb05584b2$export$c36e0ecb2d4fa69d=A;exports.$3b62074eb05584b2$export$f297eb839006d339=E;exports.$fae977aafc393c5c$export$588937bcd60ade55=Je;exports.$fae977aafc393c5c$export$6b862160d295c8e=_e;exports.$fb18d541ea1ad717$export$ad991b66133851cf=Qe;
|
|
@@ -52,10 +52,10 @@ const be = {
|
|
|
52
52
|
};
|
|
53
53
|
class g {
|
|
54
54
|
fromJulianDay(t) {
|
|
55
|
-
let r = t, n = r - X, a = Math.floor(n / 146097), o = B(n, 146097), c = Math.floor(o / 36524), i = B(o, 36524), l = Math.floor(i / 1461), h = B(i, 1461), p = Math.floor(h / 365),
|
|
56
|
-
r < E(
|
|
57
|
-
let z = Math.floor(((y + A) * 12 + 373) / 367), ye = r - E(
|
|
58
|
-
return new x(
|
|
55
|
+
let r = t, n = r - X, a = Math.floor(n / 146097), o = B(n, 146097), c = Math.floor(o / 36524), i = B(o, 36524), l = Math.floor(i / 1461), h = B(i, 1461), p = Math.floor(h / 365), M = a * 400 + c * 100 + l * 4 + p + (c !== 4 && p !== 4 ? 1 : 0), [w, m] = me(M), y = r - E(w, m, 1, 1), A = 2;
|
|
56
|
+
r < E(w, m, 3, 1) ? A = 0 : T(m) && (A = 1);
|
|
57
|
+
let z = Math.floor(((y + A) * 12 + 373) / 367), ye = r - E(w, m, z, 1) + 1;
|
|
58
|
+
return new x(w, m, z, ye);
|
|
59
59
|
}
|
|
60
60
|
toJulianDay(t) {
|
|
61
61
|
return E(t.era, t.year, t.month, t.day);
|
|
@@ -70,6 +70,12 @@ class g {
|
|
|
70
70
|
getDaysInYear(t) {
|
|
71
71
|
return T(t.year) ? 366 : 365;
|
|
72
72
|
}
|
|
73
|
+
getMaximumMonthsInYear() {
|
|
74
|
+
return 12;
|
|
75
|
+
}
|
|
76
|
+
getMaximumDaysInMonth() {
|
|
77
|
+
return 31;
|
|
78
|
+
}
|
|
73
79
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
74
80
|
getYearsInEra(t) {
|
|
75
81
|
return 9999;
|
|
@@ -109,7 +115,7 @@ function _(e, t) {
|
|
|
109
115
|
function Ge(e, t) {
|
|
110
116
|
return ee(e, ge(t));
|
|
111
117
|
}
|
|
112
|
-
const
|
|
118
|
+
const Me = {
|
|
113
119
|
sun: 0,
|
|
114
120
|
mon: 1,
|
|
115
121
|
tue: 2,
|
|
@@ -119,14 +125,14 @@ const we = {
|
|
|
119
125
|
sat: 6
|
|
120
126
|
};
|
|
121
127
|
function Qe(e, t, r) {
|
|
122
|
-
let n = e.calendar.toJulianDay(e), a =
|
|
128
|
+
let n = e.calendar.toJulianDay(e), a = Me[r], o = Math.ceil(n + 1 - a) % 7;
|
|
123
129
|
return o < 0 && (o += 7), o;
|
|
124
130
|
}
|
|
125
|
-
function
|
|
131
|
+
function we(e) {
|
|
126
132
|
return d(Date.now(), e);
|
|
127
133
|
}
|
|
128
134
|
function ge(e) {
|
|
129
|
-
return Ie(
|
|
135
|
+
return Ie(we(e));
|
|
130
136
|
}
|
|
131
137
|
function te(e, t) {
|
|
132
138
|
return e.calendar.toJulianDay(e) - t.calendar.toJulianDay(t);
|
|
@@ -435,8 +441,8 @@ function Be(e, t, r, n) {
|
|
|
435
441
|
}), new g()), p = [
|
|
436
442
|
u(h, e.timeZone, "earlier"),
|
|
437
443
|
u(h, e.timeZone, "later")
|
|
438
|
-
].filter((y) => d(y, e.timeZone).day === h.day).pop(),
|
|
439
|
-
return
|
|
444
|
+
].filter((y) => d(y, e.timeZone).day === h.day).pop(), M = v(e) - e.offset, w = Math.floor(M / I), m = M % I;
|
|
445
|
+
return M = $(w, r, Math.floor(l / I), Math.floor(p / I), n?.round) * I + m, s(d(M, e.timeZone), e.calendar);
|
|
440
446
|
}
|
|
441
447
|
case "minute":
|
|
442
448
|
case "second":
|
|
@@ -2,7 +2,7 @@ import { defineComponent as oe, ref as k, withAsyncContext as le, computed as L,
|
|
|
2
2
|
import { Tag as ne, ChevronRight as de, CalendarIcon as j } from "lucide-vue-next";
|
|
3
3
|
import { c as z } from "./utils-BVKy9S2J.mjs";
|
|
4
4
|
import { useLogs as ue, useModuleRoute as ie, useModuleStorage as re, useFirebaseIntegration as me, useModuleBreadcrumbs as pe } from "@oneclick.dev/cms-kit";
|
|
5
|
-
import { h as ve, g as E, o as fe, u as M } from "./DateFormatter-
|
|
5
|
+
import { h as ve, g as E, o as fe, u as M } from "./DateFormatter-DAZP9a6L.mjs";
|
|
6
6
|
const ce = { class: "relative @container" }, xe = {
|
|
7
7
|
key: 0,
|
|
8
8
|
class: "max-w-5xl mx-auto mt-4"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),c=require("lucide-vue-next"),B=require("./utils-D6CaKJbp.js"),u=require("@oneclick.dev/cms-kit"),d=require("./DateFormatter-DKlDa1Jq.js"),G={class:"relative @container"},O={key:0,class:"max-w-5xl mx-auto mt-4"},R={class:"flex flex-row gap-4 justify-between mb-6"},W={class:"flex items-center"},Z={class:"text-lg font-semibold mx-2 uppercase"},K={key:0,class:"bg-green-500 text-green-950 px-2 py-1 rounded-lg text-xs"},Y={key:1,class:"bg-gray-500 text-gray-950 px-2 py-1 rounded-lg text-xs"},H={class:"font-medium mb-2 uppercase"},J={class:"mb-6"},Q={key:0},X={key:1},ee={key:2},te={class:"flex flex-wrap gap-12 mb-6"},oe={key:0,class:"grid gap-2"},le={class:"flex items-center gap-2"},ae={key:0,class:"text-lg"},ne={key:1,class:"text-lg"},se={key:1,class:"grid gap-2"},re={class:"flex items-center space-x-2"},de={class:"flex gap-4 mb-6"},ue={class:"flex flex-col"},ie={key:0,class:"-ml-2"},ce={key:1,class:"text-xs text-muted-foreground mt-2"},me={class:"flex flex-col"},pe={key:0,class:"-ml-2"},ve={key:1,class:"text-xs text-muted-foreground mt-2"},fe={class:"flex justify-end gap-2 mt-6"},xe=e.defineComponent({__name:"Detail",props:{config:{type:Object,required:!0}},async setup(E){let i,x;const m=E,{log:Ve,logWarning:Ce,logError:Ne}=u.useLogs(),{params:V,navigateTo:C}=u.useModuleRoute(),{getModuleData:S}=u.useModuleStorage(),{confirm:T}=useConfirmation(),p=e.ref([]);p.value=([i,x]=e.withAsyncContext(()=>S("promo-types")),i=await i,x(),i||[]);const N=u.useFirebaseIntegration(m.config.project),o=e.ref(null),v=e.ref(!1),a=e.computed(()=>(o.value?.usageCount??0)>0),s=e.computed(()=>p.value.find(f=>f.key===o.value?.type)||null);u.useModuleBreadcrumbs(()=>[{text:"Promo codes list",href:o.value?.code?"/promo-codes":""},{text:o.value?.code||""}]);const g=new d.$fb18d541ea1ad717$export$ad991b66133851cf("en-US",{dateStyle:"long"}),A=async()=>{o.value=await N.get(m.config.promoCodeCollection,V.value.promoCodeId),o.value.startsAt=d.$fae977aafc393c5c$export$588937bcd60ade55(o.value?.startsAt?.replace(/\.\d{3}Z$/,"")),o.value.expiresAt=d.$fae977aafc393c5c$export$588937bcd60ade55(o.value?.expiresAt?.replace(/\.\d{3}Z$/,""))},$=async()=>{await T(`Are you sure you want to delete the code "${o.value?.code}"?`)&&(await N.remove(m.config.promoCodeCollection,V.value.promoCodeId),C("/promo-codes"))};return A(),(f,t)=>{const r=e.resolveComponent("Button"),n=e.resolveComponent("Label"),k=e.resolveComponent("Input"),h=e.resolveComponent("SelectValue"),U=e.resolveComponent("SelectTrigger"),D=e.resolveComponent("SelectItem"),P=e.resolveComponent("SelectGroup"),I=e.resolveComponent("SelectContent"),L=e.resolveComponent("Select"),j=e.resolveComponent("Switch"),_=e.resolveComponent("PopoverTrigger"),b=e.resolveComponent("Calendar"),y=e.resolveComponent("PopoverContent"),w=e.resolveComponent("Popover"),q=e.resolveComponent("Textarea"),z=e.resolveComponent("Loader2"),M=e.resolveComponent("CardContent"),F=e.resolveComponent("Card");return e.openBlock(),e.createElementBlock("div",G,[o.value?(e.openBlock(),e.createElementBlock("div",O,[e.createElementVNode("div",R,[e.createElementVNode("div",W,[e.createVNode(r,{variant:"ghost",onClick:t[0]||(t[0]=l=>e.unref(C)("/promo-codes"))},{default:e.withCtx(()=>[e.createVNode(e.unref(c.Tag),{class:"size-4"})]),_:1}),e.createVNode(e.unref(c.ChevronRight),{class:"size-3"}),e.createElementVNode("h1",Z,e.toDisplayString(o.value.code),1),o.value.expiresAt>new Date?(e.openBlock(),e.createElementBlock("span",K,"Active")):(e.openBlock(),e.createElementBlock("span",Y,"Expired"))])]),e.createVNode(F,null,{default:e.withCtx(()=>[e.createVNode(M,null,{default:e.withCtx(()=>[e.createElementVNode("h3",H,e.toDisplayString(o.value.code),1),e.createElementVNode("p",J,[t[14]||(t[14]=e.createTextVNode(" This promo code has been created on ",-1)),e.createElementVNode("strong",null,e.toDisplayString(new Date(o.value.createdAt).toLocaleString()),1),t[15]||(t[15]=e.createTextVNode(".",-1)),t[16]||(t[16]=e.createElementVNode("br",null,null,-1)),o.value.usageCount===1?(e.openBlock(),e.createElementBlock("span",Q,[...t[11]||(t[11]=[e.createTextVNode("It has been used ",-1),e.createElementVNode("strong",null,"1 time",-1),e.createTextVNode(", so you can't edit it.",-1)])])):o.value.usageCount>1?(e.openBlock(),e.createElementBlock("span",X,[t[12]||(t[12]=e.createTextVNode("It has been used ",-1)),e.createElementVNode("strong",null,e.toDisplayString(o.value.usageCount)+" times",1),t[13]||(t[13]=e.createTextVNode(", so you can't edit it.",-1))])):(e.openBlock(),e.createElementBlock("span",ee,"It has not been used yet."))]),e.createVNode(n,{for:"code",class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...t[17]||(t[17]=[e.createTextVNode("Promo Code",-1)])]),_:1}),e.createVNode(k,{id:"code",modelValue:o.value.code,"onUpdate:modelValue":t[1]||(t[1]=l=>o.value.code=l),disabled:a.value,class:"mb-6 uppercase"},null,8,["modelValue","disabled"]),e.createElementVNode("div",null,[t[27]||(t[27]=e.createElementVNode("h3",{class:"font-medium mb-2"},"Value",-1)),e.createVNode(L,{modelValue:o.value.type,"onUpdate:modelValue":t[2]||(t[2]=l=>o.value.type=l)},{default:e.withCtx(()=>[e.createVNode(U,{class:"w-[200px] mb-4",disabled:a.value},{default:e.withCtx(()=>[e.createVNode(h,{placeholder:"Select a promo type"})]),_:1},8,["disabled"]),e.createVNode(I,null,{default:e.withCtx(()=>[e.createVNode(P,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,l=>(e.openBlock(),e.createBlock(D,{key:l.key,value:l.key},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.label),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})]),_:1},8,["modelValue"]),e.createElementVNode("div",te,[s.value?.hasValueField?(e.openBlock(),e.createElementBlock("div",oe,[e.createVNode(n,{for:"discountValue",class:"text-muted-foreground"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value?.valueLabel||"Value"),1)]),_:1}),e.createElementVNode("div",le,[s.value?.valuePrefix?(e.openBlock(),e.createElementBlock("span",ae,e.toDisplayString(s.value?.valuePrefix),1)):e.createCommentVNode("",!0),e.createVNode(k,{modelValue:o.value.value,"onUpdate:modelValue":t[3]||(t[3]=l=>o.value.value=l),id:"discountValue",disabled:a.value},null,8,["modelValue","disabled"]),s.value?.valueSuffix?(e.openBlock(),e.createElementBlock("span",ne,e.toDisplayString(s.value?.valueSuffix),1)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),s.value?.allowUnlimitedUses?(e.openBlock(),e.createElementBlock("div",se,[e.createVNode(n,{for:"unlimitedUses",class:"text-muted-foreground"},{default:e.withCtx(()=>[...t[18]||(t[18]=[e.createTextVNode("Unlimited Uses",-1)])]),_:1}),e.createElementVNode("div",re,[e.createVNode(j,{id:"unlimitedUses",modelValue:o.value.unlimitedUses,"onUpdate:modelValue":t[4]||(t[4]=l=>o.value.unlimitedUses=l),disabled:a.value},null,8,["modelValue","disabled"]),e.createVNode(n,{for:"unlimitedUses"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.value.unlimitedUses?"Yes":"No"),1)]),_:1})])])):e.createCommentVNode("",!0)]),t[28]||(t[28]=e.createElementVNode("h3",{class:"font-medium"},"Availability",-1)),t[29]||(t[29]=e.createElementVNode("p",{class:"text-sm text-muted-foreground mb-4"},"When will this code be available?",-1)),e.createElementVNode("div",de,[e.createElementVNode("div",ue,[e.createVNode(n,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...t[19]||(t[19]=[e.createTextVNode("Available from",-1)])]),_:1}),e.createVNode(w,null,{default:e.withCtx(()=>[e.createVNode(_,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(r,{variant:"outline",class:e.normalizeClass(e.unref(B.classNames)("w-[280px] justify-start text-left font-normal",!o.value.startsAt&&"text-muted-foreground")),disabled:a.value},{default:e.withCtx(()=>[e.createVNode(e.unref(c.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(o.value.startsAt?e.unref(g).format(o.value.startsAt.toDate(e.unref(d.$14e0f24ef4ac5c92$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class","disabled"])]),_:1}),e.createVNode(y,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(b,{modelValue:o.value.startsAt,"onUpdate:modelValue":t[5]||(t[5]=l=>o.value.startsAt=l),"initial-focus":"",minValue:e.unref(d.$14e0f24ef4ac5c92$export$d0bdf45af03a6ea3)()},null,8,["modelValue","minValue"])]),_:1})]),_:1}),o.value.startsAt?(e.openBlock(),e.createElementBlock("div",ie,[a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(r,{key:0,onClick:t[6]||(t[6]=l=>o.value.startsAt=void 0),variant:"link"},{default:e.withCtx(()=>[...t[20]||(t[20]=[e.createTextVNode("Clear",-1)])]),_:1}))])):(e.openBlock(),e.createElementBlock("p",ce,"Not set - codes will be available immediately"))]),e.createElementVNode("div",me,[e.createVNode(n,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...t[21]||(t[21]=[e.createTextVNode("Until",-1)])]),_:1}),e.createVNode(w,null,{default:e.withCtx(()=>[e.createVNode(_,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(r,{variant:"outline",class:e.normalizeClass(e.unref(B.classNames)("w-[280px] justify-start text-left font-normal",!o.value.expiresAt&&"text-muted-foreground")),disabled:a.value},{default:e.withCtx(()=>[e.createVNode(e.unref(c.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(o.value.expiresAt?e.unref(g).format(o.value.expiresAt.toDate(e.unref(d.$14e0f24ef4ac5c92$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class","disabled"])]),_:1}),e.createVNode(y,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(b,{modelValue:o.value.expiresAt,"onUpdate:modelValue":t[7]||(t[7]=l=>o.value.expiresAt=l),"initial-focus":"",minValue:o.value.startsAt},null,8,["modelValue","minValue"])]),_:1})]),_:1}),o.value.expiresAt?(e.openBlock(),e.createElementBlock("div",pe,[a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(r,{key:0,onClick:t[8]||(t[8]=l=>o.value.expiresAt=void 0),variant:"link"},{default:e.withCtx(()=>[...t[22]||(t[22]=[e.createTextVNode("Clear",-1)])]),_:1}))])):(e.openBlock(),e.createElementBlock("p",ve,"Not set - codes will never expire"))])]),e.createVNode(n,{for:"note",class:"text-lg font-medium"},{default:e.withCtx(()=>[...t[23]||(t[23]=[e.createTextVNode("Note",-1)])]),_:1}),e.createVNode(n,{for:"note",class:"font-normal text-sm text-muted-foreground mb-2"},{default:e.withCtx(()=>[...t[24]||(t[24]=[e.createTextVNode("Internal note, you can always edit this later",-1)])]),_:1}),e.createVNode(q,{modelValue:o.value.note,"onUpdate:modelValue":t[9]||(t[9]=l=>o.value.note=l),id:"note"},null,8,["modelValue"]),e.createElementVNode("div",fe,[e.createVNode(r,{variant:"destructive",onClick:t[10]||(t[10]=l=>$()),disabled:v.value},{default:e.withCtx(()=>[...t[25]||(t[25]=[e.createTextVNode(" Delete Code ",-1)])]),_:1},8,["disabled"]),e.createVNode(r,{disabled:v.value},{default:e.withCtx(()=>[v.value?(e.openBlock(),e.createBlock(z,{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),t[26]||(t[26]=e.createTextVNode(" Update Code ",-1))]),_:1},8,["disabled"])])])]),_:1})]),_:1}),e.createTextVNode(" "+e.toDisplayString(o.value),1)])):e.createCommentVNode("",!0)])}}});exports.default=xe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),c=require("lucide-vue-next"),B=require("./utils-D6CaKJbp.js"),u=require("@oneclick.dev/cms-kit"),d=require("./DateFormatter-Bw-SCfUS.js"),G={class:"relative @container"},O={key:0,class:"max-w-5xl mx-auto mt-4"},R={class:"flex flex-row gap-4 justify-between mb-6"},W={class:"flex items-center"},Z={class:"text-lg font-semibold mx-2 uppercase"},K={key:0,class:"bg-green-500 text-green-950 px-2 py-1 rounded-lg text-xs"},Y={key:1,class:"bg-gray-500 text-gray-950 px-2 py-1 rounded-lg text-xs"},H={class:"font-medium mb-2 uppercase"},J={class:"mb-6"},Q={key:0},X={key:1},ee={key:2},te={class:"flex flex-wrap gap-12 mb-6"},oe={key:0,class:"grid gap-2"},le={class:"flex items-center gap-2"},ae={key:0,class:"text-lg"},ne={key:1,class:"text-lg"},se={key:1,class:"grid gap-2"},re={class:"flex items-center space-x-2"},de={class:"flex gap-4 mb-6"},ue={class:"flex flex-col"},ie={key:0,class:"-ml-2"},ce={key:1,class:"text-xs text-muted-foreground mt-2"},me={class:"flex flex-col"},pe={key:0,class:"-ml-2"},ve={key:1,class:"text-xs text-muted-foreground mt-2"},fe={class:"flex justify-end gap-2 mt-6"},xe=e.defineComponent({__name:"Detail",props:{config:{type:Object,required:!0}},async setup(E){let i,x;const m=E,{log:Ve,logWarning:Ce,logError:Ne}=u.useLogs(),{params:V,navigateTo:C}=u.useModuleRoute(),{getModuleData:S}=u.useModuleStorage(),{confirm:T}=useConfirmation(),p=e.ref([]);p.value=([i,x]=e.withAsyncContext(()=>S("promo-types")),i=await i,x(),i||[]);const N=u.useFirebaseIntegration(m.config.project),o=e.ref(null),v=e.ref(!1),a=e.computed(()=>(o.value?.usageCount??0)>0),s=e.computed(()=>p.value.find(f=>f.key===o.value?.type)||null);u.useModuleBreadcrumbs(()=>[{text:"Promo codes list",href:o.value?.code?"/promo-codes":""},{text:o.value?.code||""}]);const g=new d.$fb18d541ea1ad717$export$ad991b66133851cf("en-US",{dateStyle:"long"}),A=async()=>{o.value=await N.get(m.config.promoCodeCollection,V.value.promoCodeId),o.value.startsAt=d.$fae977aafc393c5c$export$588937bcd60ade55(o.value?.startsAt?.replace(/\.\d{3}Z$/,"")),o.value.expiresAt=d.$fae977aafc393c5c$export$588937bcd60ade55(o.value?.expiresAt?.replace(/\.\d{3}Z$/,""))},$=async()=>{await T(`Are you sure you want to delete the code "${o.value?.code}"?`)&&(await N.remove(m.config.promoCodeCollection,V.value.promoCodeId),C("/promo-codes"))};return A(),(f,t)=>{const r=e.resolveComponent("Button"),n=e.resolveComponent("Label"),k=e.resolveComponent("Input"),h=e.resolveComponent("SelectValue"),U=e.resolveComponent("SelectTrigger"),D=e.resolveComponent("SelectItem"),P=e.resolveComponent("SelectGroup"),I=e.resolveComponent("SelectContent"),L=e.resolveComponent("Select"),j=e.resolveComponent("Switch"),_=e.resolveComponent("PopoverTrigger"),b=e.resolveComponent("Calendar"),y=e.resolveComponent("PopoverContent"),w=e.resolveComponent("Popover"),q=e.resolveComponent("Textarea"),z=e.resolveComponent("Loader2"),M=e.resolveComponent("CardContent"),F=e.resolveComponent("Card");return e.openBlock(),e.createElementBlock("div",G,[o.value?(e.openBlock(),e.createElementBlock("div",O,[e.createElementVNode("div",R,[e.createElementVNode("div",W,[e.createVNode(r,{variant:"ghost",onClick:t[0]||(t[0]=l=>e.unref(C)("/promo-codes"))},{default:e.withCtx(()=>[e.createVNode(e.unref(c.Tag),{class:"size-4"})]),_:1}),e.createVNode(e.unref(c.ChevronRight),{class:"size-3"}),e.createElementVNode("h1",Z,e.toDisplayString(o.value.code),1),o.value.expiresAt>new Date?(e.openBlock(),e.createElementBlock("span",K,"Active")):(e.openBlock(),e.createElementBlock("span",Y,"Expired"))])]),e.createVNode(F,null,{default:e.withCtx(()=>[e.createVNode(M,null,{default:e.withCtx(()=>[e.createElementVNode("h3",H,e.toDisplayString(o.value.code),1),e.createElementVNode("p",J,[t[14]||(t[14]=e.createTextVNode(" This promo code has been created on ",-1)),e.createElementVNode("strong",null,e.toDisplayString(new Date(o.value.createdAt).toLocaleString()),1),t[15]||(t[15]=e.createTextVNode(".",-1)),t[16]||(t[16]=e.createElementVNode("br",null,null,-1)),o.value.usageCount===1?(e.openBlock(),e.createElementBlock("span",Q,[...t[11]||(t[11]=[e.createTextVNode("It has been used ",-1),e.createElementVNode("strong",null,"1 time",-1),e.createTextVNode(", so you can't edit it.",-1)])])):o.value.usageCount>1?(e.openBlock(),e.createElementBlock("span",X,[t[12]||(t[12]=e.createTextVNode("It has been used ",-1)),e.createElementVNode("strong",null,e.toDisplayString(o.value.usageCount)+" times",1),t[13]||(t[13]=e.createTextVNode(", so you can't edit it.",-1))])):(e.openBlock(),e.createElementBlock("span",ee,"It has not been used yet."))]),e.createVNode(n,{for:"code",class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...t[17]||(t[17]=[e.createTextVNode("Promo Code",-1)])]),_:1}),e.createVNode(k,{id:"code",modelValue:o.value.code,"onUpdate:modelValue":t[1]||(t[1]=l=>o.value.code=l),disabled:a.value,class:"mb-6 uppercase"},null,8,["modelValue","disabled"]),e.createElementVNode("div",null,[t[27]||(t[27]=e.createElementVNode("h3",{class:"font-medium mb-2"},"Value",-1)),e.createVNode(L,{modelValue:o.value.type,"onUpdate:modelValue":t[2]||(t[2]=l=>o.value.type=l)},{default:e.withCtx(()=>[e.createVNode(U,{class:"w-[200px] mb-4",disabled:a.value},{default:e.withCtx(()=>[e.createVNode(h,{placeholder:"Select a promo type"})]),_:1},8,["disabled"]),e.createVNode(I,null,{default:e.withCtx(()=>[e.createVNode(P,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,l=>(e.openBlock(),e.createBlock(D,{key:l.key,value:l.key},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.label),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})]),_:1},8,["modelValue"]),e.createElementVNode("div",te,[s.value?.hasValueField?(e.openBlock(),e.createElementBlock("div",oe,[e.createVNode(n,{for:"discountValue",class:"text-muted-foreground"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value?.valueLabel||"Value"),1)]),_:1}),e.createElementVNode("div",le,[s.value?.valuePrefix?(e.openBlock(),e.createElementBlock("span",ae,e.toDisplayString(s.value?.valuePrefix),1)):e.createCommentVNode("",!0),e.createVNode(k,{modelValue:o.value.value,"onUpdate:modelValue":t[3]||(t[3]=l=>o.value.value=l),id:"discountValue",disabled:a.value},null,8,["modelValue","disabled"]),s.value?.valueSuffix?(e.openBlock(),e.createElementBlock("span",ne,e.toDisplayString(s.value?.valueSuffix),1)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),s.value?.allowUnlimitedUses?(e.openBlock(),e.createElementBlock("div",se,[e.createVNode(n,{for:"unlimitedUses",class:"text-muted-foreground"},{default:e.withCtx(()=>[...t[18]||(t[18]=[e.createTextVNode("Unlimited Uses",-1)])]),_:1}),e.createElementVNode("div",re,[e.createVNode(j,{id:"unlimitedUses",modelValue:o.value.unlimitedUses,"onUpdate:modelValue":t[4]||(t[4]=l=>o.value.unlimitedUses=l),disabled:a.value},null,8,["modelValue","disabled"]),e.createVNode(n,{for:"unlimitedUses"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.value.unlimitedUses?"Yes":"No"),1)]),_:1})])])):e.createCommentVNode("",!0)]),t[28]||(t[28]=e.createElementVNode("h3",{class:"font-medium"},"Availability",-1)),t[29]||(t[29]=e.createElementVNode("p",{class:"text-sm text-muted-foreground mb-4"},"When will this code be available?",-1)),e.createElementVNode("div",de,[e.createElementVNode("div",ue,[e.createVNode(n,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...t[19]||(t[19]=[e.createTextVNode("Available from",-1)])]),_:1}),e.createVNode(w,null,{default:e.withCtx(()=>[e.createVNode(_,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(r,{variant:"outline",class:e.normalizeClass(e.unref(B.classNames)("w-[280px] justify-start text-left font-normal",!o.value.startsAt&&"text-muted-foreground")),disabled:a.value},{default:e.withCtx(()=>[e.createVNode(e.unref(c.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(o.value.startsAt?e.unref(g).format(o.value.startsAt.toDate(e.unref(d.$14e0f24ef4ac5c92$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class","disabled"])]),_:1}),e.createVNode(y,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(b,{modelValue:o.value.startsAt,"onUpdate:modelValue":t[5]||(t[5]=l=>o.value.startsAt=l),"initial-focus":"",minValue:e.unref(d.$14e0f24ef4ac5c92$export$d0bdf45af03a6ea3)()},null,8,["modelValue","minValue"])]),_:1})]),_:1}),o.value.startsAt?(e.openBlock(),e.createElementBlock("div",ie,[a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(r,{key:0,onClick:t[6]||(t[6]=l=>o.value.startsAt=void 0),variant:"link"},{default:e.withCtx(()=>[...t[20]||(t[20]=[e.createTextVNode("Clear",-1)])]),_:1}))])):(e.openBlock(),e.createElementBlock("p",ce,"Not set - codes will be available immediately"))]),e.createElementVNode("div",me,[e.createVNode(n,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...t[21]||(t[21]=[e.createTextVNode("Until",-1)])]),_:1}),e.createVNode(w,null,{default:e.withCtx(()=>[e.createVNode(_,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(r,{variant:"outline",class:e.normalizeClass(e.unref(B.classNames)("w-[280px] justify-start text-left font-normal",!o.value.expiresAt&&"text-muted-foreground")),disabled:a.value},{default:e.withCtx(()=>[e.createVNode(e.unref(c.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(o.value.expiresAt?e.unref(g).format(o.value.expiresAt.toDate(e.unref(d.$14e0f24ef4ac5c92$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class","disabled"])]),_:1}),e.createVNode(y,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(b,{modelValue:o.value.expiresAt,"onUpdate:modelValue":t[7]||(t[7]=l=>o.value.expiresAt=l),"initial-focus":"",minValue:o.value.startsAt},null,8,["modelValue","minValue"])]),_:1})]),_:1}),o.value.expiresAt?(e.openBlock(),e.createElementBlock("div",pe,[a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(r,{key:0,onClick:t[8]||(t[8]=l=>o.value.expiresAt=void 0),variant:"link"},{default:e.withCtx(()=>[...t[22]||(t[22]=[e.createTextVNode("Clear",-1)])]),_:1}))])):(e.openBlock(),e.createElementBlock("p",ve,"Not set - codes will never expire"))])]),e.createVNode(n,{for:"note",class:"text-lg font-medium"},{default:e.withCtx(()=>[...t[23]||(t[23]=[e.createTextVNode("Note",-1)])]),_:1}),e.createVNode(n,{for:"note",class:"font-normal text-sm text-muted-foreground mb-2"},{default:e.withCtx(()=>[...t[24]||(t[24]=[e.createTextVNode("Internal note, you can always edit this later",-1)])]),_:1}),e.createVNode(q,{modelValue:o.value.note,"onUpdate:modelValue":t[9]||(t[9]=l=>o.value.note=l),id:"note"},null,8,["modelValue"]),e.createElementVNode("div",fe,[e.createVNode(r,{variant:"destructive",onClick:t[10]||(t[10]=l=>$()),disabled:v.value},{default:e.withCtx(()=>[...t[25]||(t[25]=[e.createTextVNode(" Delete Code ",-1)])]),_:1},8,["disabled"]),e.createVNode(r,{disabled:v.value},{default:e.withCtx(()=>[v.value?(e.openBlock(),e.createBlock(z,{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),t[26]||(t[26]=e.createTextVNode(" Update Code ",-1))]),_:1},8,["disabled"])])])]),_:1})]),_:1}),e.createTextVNode(" "+e.toDisplayString(o.value),1)])):e.createCommentVNode("",!0)])}}});exports.default=xe;
|
|
@@ -0,0 +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-We8hT28L.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(console.log("waza",{domain:t,pattern:i,entry:l}),!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 z=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",z)}),e.onUnmounted(()=>{window.removeEventListener("keydown",z)}),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"),A=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(A),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B,(L,F)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[L.type==="page"?(e.openBlock(),e.createBlock(I,{key:F,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:F},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;
|