@oneclick.dev/cms-core-modules 0.0.53 → 0.0.55

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.
Files changed (136) hide show
  1. package/dist/CalendarDate-CRT2Viyt.mjs +830 -0
  2. package/dist/CalendarDate-CWtpXgpD.js +1 -0
  3. package/dist/Components-D9yIIosM.mjs +623 -0
  4. package/dist/Components-DXbx0RLV.js +1 -0
  5. package/dist/ContentEditor-BBdzuTJJ.js +290 -0
  6. package/dist/ContentEditor-HwHspQO1.mjs +35302 -0
  7. package/dist/Create-BP8TX6rj.js +1 -0
  8. package/dist/Create-Bwf1RXdG.mjs +1248 -0
  9. package/dist/DateFormatter-BbcSwTs4.js +1 -0
  10. package/dist/DateFormatter-CbO0PVUK.mjs +99 -0
  11. package/dist/Detail-B-PnkcXD.mjs +3473 -0
  12. package/dist/Detail-BVlGSjOq.mjs +380 -0
  13. package/dist/Detail-C4E1T87K.mjs +26 -0
  14. package/dist/Detail-CNfTDUE5.js +1 -0
  15. package/dist/Detail-Cd5CBVN0.js +1 -0
  16. package/dist/Detail-CpfOQChd.mjs +585 -0
  17. package/dist/Detail-CwagT6gQ.mjs +650 -0
  18. package/dist/Detail-DUo6qKqO.js +1 -0
  19. package/dist/Detail-Dd_OkpcN.js +1 -0
  20. package/dist/Detail-mvSGbnFU.js +1 -0
  21. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-BWuKVkvV.js +1 -0
  22. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-D0-EcU0_.mjs +55 -0
  23. package/dist/Entries-DcpPvlYj.js +1 -0
  24. package/dist/Entries-QLMtTYLX.mjs +713 -0
  25. package/dist/Find-BPR0uU-Z.mjs +229 -0
  26. package/dist/Find-BidEQJxT.js +1 -0
  27. package/dist/GlobalStyling-BLQ_1W2y.mjs +1588 -0
  28. package/dist/GlobalStyling-CnSlXkZc.js +25 -0
  29. package/dist/Overview-BDlBCUI_.js +1 -0
  30. package/dist/Overview-BH3NwvNX.mjs +26 -0
  31. package/dist/Overview-BLsZMHNW.mjs +178 -0
  32. package/dist/Overview-BNMZ9MUK.js +1 -0
  33. package/dist/Overview-BbvfH1u-.js +1 -0
  34. package/dist/Overview-CDN88OSM.mjs +190 -0
  35. package/dist/Overview-CEPodGCn.mjs +311 -0
  36. package/dist/Overview-CvquDPhB.js +1 -0
  37. package/dist/Overview-D54pjmI6.mjs +633 -0
  38. package/dist/Overview-D67UjG6n.mjs +947 -0
  39. package/dist/Overview-KT2Mgfh5.js +1 -0
  40. package/dist/Overview-T-lsy3UZ.js +1 -0
  41. package/dist/RegularSlotEditor.vue_vue_type_script_setup_true_lang-0xZSq0rx.js +1 -0
  42. package/dist/RegularSlotEditor.vue_vue_type_script_setup_true_lang-Bj_PVLLV.mjs +392 -0
  43. package/dist/TableView-CpO53xcX.js +111 -0
  44. package/dist/TableView-D9J5rUls.mjs +72921 -0
  45. package/dist/TemplateList.vue_vue_type_script_setup_true_lang-B_AtWnHa.js +1 -0
  46. package/dist/TemplateList.vue_vue_type_script_setup_true_lang-BiLAkhIA.mjs +40 -0
  47. package/dist/View-DlHBZbFu.js +1 -0
  48. package/dist/View-Dv5QMrSn.mjs +25 -0
  49. package/dist/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
  50. package/dist/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
  51. package/dist/agenda-B49oKGeh.mjs +706 -0
  52. package/dist/agenda-DipQ5IWP.js +1 -0
  53. package/dist/availability-C7q9tq6l.js +1 -0
  54. package/dist/availability-DeCkqiu8.mjs +613 -0
  55. package/dist/cms-core-modules.css +1 -1
  56. package/dist/countries-BTPvmrsb.mjs +4 -0
  57. package/dist/countries-CgZ081No.js +1 -0
  58. package/dist/exceptions-D3b18TiY.mjs +647 -0
  59. package/dist/exceptions-DJ9zWX3k.js +1 -0
  60. package/dist/floating-ui.dom-C82nbomj.js +1 -0
  61. package/dist/floating-ui.dom-ouSgPqty.mjs +1133 -0
  62. package/dist/google-CvtuJwgk.mjs +4 -0
  63. package/dist/google-D4N3gb01.js +1 -0
  64. package/dist/index--jjEzba7.mjs +24 -0
  65. package/dist/index-9HVlmvK3.js +1 -0
  66. package/dist/index-BEGU8Kme.mjs +12 -0
  67. package/dist/index-Bwi1mtkq.mjs +24 -0
  68. package/dist/index-BzuHN-r8.mjs +24 -0
  69. package/dist/index-CImCyE3L.mjs +24 -0
  70. package/dist/index-CKPshlZ8-BQiiP6r_.mjs +1264 -0
  71. package/dist/index-CKPshlZ8-CIz1tDwX.js +1 -0
  72. package/dist/index-CQiY-oTN.mjs +24 -0
  73. package/dist/index-CSxYBeVA.js +1 -0
  74. package/dist/index-CkiNvRzs.js +1 -0
  75. package/dist/index-Co4ON2Di.js +1 -0
  76. package/dist/index-CwqrAU-H.js +1 -0
  77. package/dist/index-Cz-baGax.js +1 -0
  78. package/dist/index-D2a6wEPh.js +1 -0
  79. package/dist/index-DFQGVHTs.js +1 -0
  80. package/dist/index-DI6mydpm.mjs +138 -0
  81. package/dist/index-DMoyoaks.mjs +22 -0
  82. package/dist/index-DT1wWnUk.mjs +24 -0
  83. package/dist/index-DUeFrD-B.js +1 -0
  84. package/dist/index-DsnoK4ia.mjs +579 -0
  85. package/dist/index-R2oUDsjx.js +1 -0
  86. package/dist/index-RLz1QPrf.mjs +203 -0
  87. package/dist/index-UtjLbLw-.js +1 -0
  88. package/dist/index-_mG-aU3Z.mjs +87 -0
  89. package/dist/index-_sQDF1pH.js +1 -0
  90. package/dist/index-ijdf0d9-.js +1 -0
  91. package/dist/index-klI238nT.mjs +24 -0
  92. package/dist/index.cjs.js +1 -330
  93. package/dist/index.mjs +287 -69051
  94. package/dist/interpolation-BNUjI7LH.js +1 -0
  95. package/dist/interpolation-BpGXqOz8.mjs +59 -0
  96. package/dist/payment-kTjsV0Jj.js +1 -0
  97. package/dist/payment-zpCM0LD-.mjs +981 -0
  98. package/dist/regular-C4_3YXqx.mjs +602 -0
  99. package/dist/regular-DFwPEbZO.js +1 -0
  100. package/dist/regular-slots-4ooEpICB.mjs +67 -0
  101. package/dist/regular-slots-BAVGbomI.js +1 -0
  102. package/dist/resources-MpQkSstv.mjs +563 -0
  103. package/dist/resources-iM28T3dD.js +1 -0
  104. package/dist/src/appointments/index.d.ts +4 -28
  105. package/dist/src/appointments/routes.d.ts +3 -9
  106. package/dist/src/content-manager/components/content-editor/ContentLayout.vue.d.ts +8 -0
  107. package/dist/src/content-manager/components/content-editor/NewSectionDialog.vue.d.ts +5 -1
  108. package/dist/src/content-manager/components/content-editor/tiptap-extensions/Card.d.ts +6 -0
  109. package/dist/src/content-manager/components/content-editor/tiptap-extensions/ScopedSelectAll.d.ts +7 -0
  110. package/dist/src/content-manager/components/content-editor/tiptap-menus/NewNodeView.vue.d.ts +16 -2
  111. package/dist/src/content-manager/components/content-editor/tiptap-menus/element-editor-views/CardMenu.vue.d.ts +13 -0
  112. package/dist/src/content-manager/components/content-editor/tiptap-menus/element-editor-views/index.d.ts +14 -0
  113. package/dist/src/content-manager/components/styling/ButtonStyleDialog.vue.d.ts +7 -7
  114. package/dist/src/content-manager/components/styling/CardStyleDialog.vue.d.ts +24 -0
  115. package/dist/src/content-manager/index.d.ts +5 -147
  116. package/dist/src/content-manager/pages/GlobalStyling.vue.d.ts +46 -8
  117. package/dist/src/content-manager/routes.d.ts +4 -128
  118. package/dist/src/custom/index.d.ts +2 -2
  119. package/dist/src/custom/routes.d.ts +1 -1
  120. package/dist/src/mail-templates/index.d.ts +2 -30
  121. package/dist/src/mail-templates/routes.d.ts +1 -11
  122. package/dist/src/product-collections/index.d.ts +2 -30
  123. package/dist/src/product-collections/routes.d.ts +1 -11
  124. package/dist/src/products/index.d.ts +2 -30
  125. package/dist/src/products/routes.d.ts +1 -11
  126. package/dist/src/promo-codes/index.d.ts +2 -30
  127. package/dist/src/promo-codes/routes.d.ts +1 -11
  128. package/dist/src/shipping-options/index.d.ts +2 -30
  129. package/dist/src/shipping-options/routes.d.ts +1 -11
  130. package/dist/src/table/index.d.ts +2 -70
  131. package/dist/src/table/routes.d.ts +1 -51
  132. package/dist/utils-BVKy9S2J.mjs +29 -0
  133. package/dist/utils-D6CaKJbp.js +2 -0
  134. package/dist/vee-validate-zod-BPQyEfpF.js +1 -0
  135. package/dist/vee-validate-zod-IXkfh-6Q.mjs +4402 -0
  136. package/package.json +4 -4
@@ -0,0 +1,3473 @@
1
+ import { defineComponent as ne, inject as tt, resolveComponent as v, createBlock as L, openBlock as h, withCtx as f, createVNode as s, createElementVNode as u, createElementBlock as w, createCommentVNode as M, createTextVNode as V, unref as m, isRef as Y, toDisplayString as F, computed as de, watch as re, useTemplateRef as Ee, ref as X, nextTick as Te, Fragment as q, renderList as ie, withModifiers as fe, onMounted as lt, normalizeClass as $e, withKeys as Yt, provide as dt, withAsyncContext as Kt } from "vue";
2
+ import { u as xe, a as U, t as Jt, o as Se, b as ve, s as H, d as ut, p as Ne, c as Ie, e as be, f as qt } from "./vee-validate-zod-IXkfh-6Q.mjs";
3
+ import { Info as Wt, GripVertical as Qe, CircleX as Gt, Trash2 as Zt, PlusCircle as ct, Search as ft, ListFilter as Qt, ChevronDown as pt, X as en, ImagePlus as gt, Plus as tn, Tag as nn, ChevronRight as on, Archive as ln, Trash as rn, Loader2 as mt } from "lucide-vue-next";
4
+ import { animations as yt } from "@formkit/drag-and-drop";
5
+ import { useConfirmation as Dt, useModuleRoute as St, useFirebaseIntegration as Ct, useModulePermissions as an, useModuleBreadcrumbs as sn } from "@oneclick.dev/cms-kit";
6
+ import { g as dn } from "./google-CvtuJwgk.mjs";
7
+ import { t as se } from "./index-RLz1QPrf.mjs";
8
+ const un = { class: "flex flex-col gap-4" }, cn = { class: "flex flex-col" }, fn = {
9
+ key: 0,
10
+ class: "text-red-500 text-sm mt-1"
11
+ }, pn = { class: "flex flex-col gap-4" }, gn = { class: "flex flex-col" }, mn = {
12
+ key: 0,
13
+ class: "text-red-500 text-sm mt-1"
14
+ }, vn = { class: "flex flex-col gap-4" }, bn = { class: "flex flex-col" }, hn = {
15
+ key: 0,
16
+ class: "text-red-500 text-sm mt-1"
17
+ }, _n = /* @__PURE__ */ ne({
18
+ __name: "Main",
19
+ setup(e) {
20
+ const t = tt("sources"), n = tt("defaultSource"), { errors: o } = xe(), { value: l } = U("title"), { value: a } = U("description"), { value: i } = U("media");
21
+ return (d, r) => {
22
+ const b = v("Label"), x = v("Input"), c = v("Textarea"), D = v("MediaPicker"), T = v("CardContent"), N = v("Card");
23
+ return h(), L(N, null, {
24
+ default: f(() => [
25
+ s(T, { class: "flex flex-col gap-4" }, {
26
+ default: f(() => [
27
+ u("div", un, [
28
+ u("div", cn, [
29
+ s(b, {
30
+ for: "title",
31
+ class: "text-sm mb-2"
32
+ }, {
33
+ default: f(() => [...r[3] || (r[3] = [
34
+ V("Title", -1)
35
+ ])]),
36
+ _: 1
37
+ }),
38
+ s(x, {
39
+ type: "text",
40
+ id: "title",
41
+ placeholder: "T-shirt with red heart",
42
+ modelValue: m(l),
43
+ "onUpdate:modelValue": r[0] || (r[0] = (I) => Y(l) ? l.value = I : null)
44
+ }, null, 8, ["modelValue"]),
45
+ m(o).title ? (h(), w("p", fn, F(m(o).title), 1)) : M("", !0)
46
+ ])
47
+ ]),
48
+ u("div", pn, [
49
+ u("div", gn, [
50
+ s(b, {
51
+ for: "description",
52
+ class: "text-sm mb-2"
53
+ }, {
54
+ default: f(() => [...r[4] || (r[4] = [
55
+ V("Description", -1)
56
+ ])]),
57
+ _: 1
58
+ }),
59
+ s(c, {
60
+ id: "description",
61
+ placeholder: "Lovely T-shirt featuring a red heart",
62
+ modelValue: m(a),
63
+ "onUpdate:modelValue": r[1] || (r[1] = (I) => Y(a) ? a.value = I : null)
64
+ }, null, 8, ["modelValue"]),
65
+ m(o).description ? (h(), w("p", mn, F(m(o).description), 1)) : M("", !0)
66
+ ])
67
+ ]),
68
+ u("div", vn, [
69
+ u("div", bn, [
70
+ s(b, {
71
+ for: "media",
72
+ class: "text-sm mb-2"
73
+ }, {
74
+ default: f(() => [...r[5] || (r[5] = [
75
+ V("Media", -1)
76
+ ])]),
77
+ _: 1
78
+ }),
79
+ s(D, {
80
+ id: "media",
81
+ modelValue: m(i),
82
+ "onUpdate:modelValue": r[2] || (r[2] = (I) => Y(i) ? i.value = I : null),
83
+ sources: m(t),
84
+ defaultSource: m(n)
85
+ }, null, 8, ["modelValue", "sources", "defaultSource"]),
86
+ m(o).media ? (h(), w("p", hn, F(m(o).media), 1)) : M("", !0)
87
+ ])
88
+ ])
89
+ ]),
90
+ _: 1
91
+ })
92
+ ]),
93
+ _: 1
94
+ });
95
+ };
96
+ }
97
+ }), xn = { class: "grid grid-cols-2 gap-4 mb-4" }, yn = { class: "relative" }, Dn = {
98
+ key: 0,
99
+ class: "text-red-500 text-sm mt-1"
100
+ }, Sn = { class: "relative" }, Cn = { class: "absolute right-2 top-1/2 -translate-y-1/2" }, wn = {
101
+ key: 0,
102
+ class: "text-red-500 text-sm mt-1"
103
+ }, kn = { class: "flex items-center gap-2 mb-4" }, Pn = { class: "flex items-center border-t mt-4 pt-4" }, Vn = { class: "relative" }, Nn = {
104
+ key: 0,
105
+ class: "text-red-500 text-sm mt-1"
106
+ }, In = /* @__PURE__ */ ne({
107
+ __name: "Price",
108
+ setup(e) {
109
+ const { errors: t } = xe(), { value: n } = U("price"), { value: o } = U("compareAtPrice"), { value: l } = U("isTaxable"), { value: a } = U("costPerItem");
110
+ return de(() => Number(n.value) > 0), (i, d) => {
111
+ const r = v("Label"), b = v("Input"), x = v("TooltipTrigger"), c = v("TooltipContent"), D = v("Tooltip"), T = v("Checkbox"), N = v("CardContent"), I = v("Card");
112
+ return h(), L(I, null, {
113
+ default: f(() => [
114
+ s(N, null, {
115
+ default: f(() => [
116
+ d[12] || (d[12] = u("h3", { class: "text-lg font-semibold mb-4" }, "Pricing", -1)),
117
+ u("div", xn, [
118
+ u("div", null, [
119
+ s(r, {
120
+ for: "price",
121
+ class: "text-sm mb-2"
122
+ }, {
123
+ default: f(() => [...d[4] || (d[4] = [
124
+ V("Price", -1)
125
+ ])]),
126
+ _: 1
127
+ }),
128
+ u("div", yn, [
129
+ s(b, {
130
+ type: "number",
131
+ id: "price",
132
+ class: "pl-10 no-spinner",
133
+ modelValue: m(n),
134
+ "onUpdate:modelValue": d[0] || (d[0] = (A) => Y(n) ? n.value = A : null)
135
+ }, null, 8, ["modelValue"]),
136
+ d[5] || (d[5] = u("span", { class: "absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" }, "€", -1))
137
+ ]),
138
+ m(t).price ? (h(), w("p", Dn, F(m(t).price), 1)) : M("", !0)
139
+ ]),
140
+ u("div", null, [
141
+ s(r, {
142
+ for: "compare-at-price",
143
+ class: "text-sm mb-2"
144
+ }, {
145
+ default: f(() => [...d[6] || (d[6] = [
146
+ V("Compare-at price", -1)
147
+ ])]),
148
+ _: 1
149
+ }),
150
+ u("div", Sn, [
151
+ s(b, {
152
+ type: "number",
153
+ id: "compare-at-price",
154
+ class: "pl-10 no-spinner",
155
+ modelValue: m(o),
156
+ "onUpdate:modelValue": d[1] || (d[1] = (A) => Y(o) ? o.value = A : null)
157
+ }, null, 8, ["modelValue"]),
158
+ d[8] || (d[8] = u("span", { class: "absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" }, "€", -1)),
159
+ s(D, null, {
160
+ default: f(() => [
161
+ s(x, { "as-child": "" }, {
162
+ default: f(() => [
163
+ u("button", Cn, [
164
+ s(m(Wt), { class: "size-4 text-muted-foreground" })
165
+ ])
166
+ ]),
167
+ _: 1
168
+ }),
169
+ s(c, null, {
170
+ default: f(() => [...d[7] || (d[7] = [
171
+ u("p", null, [
172
+ V(" To display a markdown, enter a value higher than your price."),
173
+ u("br"),
174
+ V(" Often shown with a strikethrough (e.g. "),
175
+ u("span", { class: "font-semibold line-through" }, "€25,00"),
176
+ V("). ")
177
+ ], -1)
178
+ ])]),
179
+ _: 1
180
+ })
181
+ ]),
182
+ _: 1
183
+ })
184
+ ]),
185
+ m(t).compareAtPrice ? (h(), w("p", wn, F(m(t).compareAtPrice), 1)) : M("", !0)
186
+ ])
187
+ ]),
188
+ u("div", kn, [
189
+ s(T, {
190
+ id: "charge-tax",
191
+ modelValue: m(l),
192
+ "onUpdate:modelValue": d[2] || (d[2] = (A) => Y(l) ? l.value = A : null)
193
+ }, null, 8, ["modelValue"]),
194
+ s(r, {
195
+ for: "charge-tax",
196
+ class: "text-sm"
197
+ }, {
198
+ default: f(() => [...d[9] || (d[9] = [
199
+ V("Charge tax on this product", -1)
200
+ ])]),
201
+ _: 1
202
+ })
203
+ ]),
204
+ u("div", Pn, [
205
+ u("div", null, [
206
+ s(r, {
207
+ for: "cost-per-item",
208
+ class: "text-sm mb-2"
209
+ }, {
210
+ default: f(() => [...d[10] || (d[10] = [
211
+ V("Cost per item", -1)
212
+ ])]),
213
+ _: 1
214
+ }),
215
+ u("div", Vn, [
216
+ s(b, {
217
+ type: "number",
218
+ id: "cost-per-item",
219
+ class: "pl-10 no-spinner",
220
+ modelValue: m(a),
221
+ "onUpdate:modelValue": d[3] || (d[3] = (A) => Y(a) ? a.value = A : null)
222
+ }, null, 8, ["modelValue"]),
223
+ d[11] || (d[11] = u("span", { class: "absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" }, "€", -1))
224
+ ]),
225
+ m(t).costPerItem ? (h(), w("p", Nn, F(m(t).costPerItem), 1)) : M("", !0)
226
+ ])
227
+ ])
228
+ ]),
229
+ _: 1
230
+ })
231
+ ]),
232
+ _: 1
233
+ });
234
+ };
235
+ }
236
+ }), Tn = { class: "grid grid-cols-2 gap-4 mb-4" }, $n = { class: "flex items-center gap-2 mb-4" }, En = {
237
+ key: 0,
238
+ class: "grid grid-cols-2 gap-4 mb-4"
239
+ }, An = { class: "flex items-center gap-2" }, zn = /* @__PURE__ */ ne({
240
+ __name: "Inventory",
241
+ setup(e) {
242
+ const { errors: t } = xe(), { value: n } = U("sku"), { value: o } = U("barcode"), { value: l } = U("trackInventory"), { value: a } = U("allowBackorder"), { value: i } = U("stock"), { value: d } = U("options"), { value: r } = U("variants"), b = de(() => r.value.reduce((x, c) => c.stock < 0 ? x : x + c.stock, 0));
243
+ return (x, c) => {
244
+ const D = v("Label"), T = v("Input"), N = v("Checkbox"), I = v("TooltipTrigger"), A = v("TooltipContent"), z = v("Tooltip"), _ = v("CardContent"), S = v("Card");
245
+ return h(), L(S, null, {
246
+ default: f(() => [
247
+ s(_, null, {
248
+ default: f(() => [
249
+ c[12] || (c[12] = u("h3", { class: "text-lg font-semibold mb-4" }, "Inventory", -1)),
250
+ u("div", Tn, [
251
+ u("div", null, [
252
+ s(D, {
253
+ for: "sku",
254
+ class: "text-sm mb-2"
255
+ }, {
256
+ default: f(() => [...c[6] || (c[6] = [
257
+ V("SKU (Stock Keeping Unit)", -1)
258
+ ])]),
259
+ _: 1
260
+ }),
261
+ s(T, {
262
+ id: "sku",
263
+ modelValue: m(n),
264
+ "onUpdate:modelValue": c[0] || (c[0] = (B) => Y(n) ? n.value = B : null)
265
+ }, null, 8, ["modelValue"])
266
+ ]),
267
+ u("div", null, [
268
+ s(D, {
269
+ for: "barcode",
270
+ class: "text-sm mb-2"
271
+ }, {
272
+ default: f(() => [...c[7] || (c[7] = [
273
+ V("Barcode (ISBN, UPC, GTIN, etc.)", -1)
274
+ ])]),
275
+ _: 1
276
+ }),
277
+ s(T, {
278
+ id: "barcode",
279
+ modelValue: m(o),
280
+ "onUpdate:modelValue": c[1] || (c[1] = (B) => Y(o) ? o.value = B : null)
281
+ }, null, 8, ["modelValue"])
282
+ ])
283
+ ]),
284
+ u("div", $n, [
285
+ s(N, {
286
+ id: "track-quantity",
287
+ modelValue: m(l),
288
+ "onUpdate:modelValue": c[2] || (c[2] = (B) => Y(l) ? l.value = B : null)
289
+ }, null, 8, ["modelValue"]),
290
+ s(D, {
291
+ for: "track-quantity",
292
+ class: "text-sm"
293
+ }, {
294
+ default: f(() => [...c[8] || (c[8] = [
295
+ V("Track quantity", -1)
296
+ ])]),
297
+ _: 1
298
+ })
299
+ ]),
300
+ m(l) ? (h(), w("div", En, [
301
+ u("div", null, [
302
+ s(D, {
303
+ for: "stock",
304
+ class: "text-sm mb-2"
305
+ }, {
306
+ default: f(() => [...c[9] || (c[9] = [
307
+ V("Stock", -1)
308
+ ])]),
309
+ _: 1
310
+ }),
311
+ !m(d) || m(d)?.length === 0 ? (h(), L(T, {
312
+ key: 0,
313
+ id: "stock",
314
+ type: "number",
315
+ modelValue: m(i),
316
+ "onUpdate:modelValue": c[3] || (c[3] = (B) => Y(i) ? i.value = B : null),
317
+ class: "no-spinner"
318
+ }, null, 8, ["modelValue"])) : (h(), L(z, { key: 1 }, {
319
+ default: f(() => [
320
+ s(I, { class: "cursor-not-allowed" }, {
321
+ default: f(() => [
322
+ s(T, {
323
+ modelValue: b.value,
324
+ "onUpdate:modelValue": c[4] || (c[4] = (B) => b.value = B),
325
+ disabled: "",
326
+ class: "no-spinner"
327
+ }, null, 8, ["modelValue"])
328
+ ]),
329
+ _: 1
330
+ }),
331
+ s(A, null, {
332
+ default: f(() => [...c[10] || (c[10] = [
333
+ u("p", null, "Total stock of all variants", -1)
334
+ ])]),
335
+ _: 1
336
+ })
337
+ ]),
338
+ _: 1
339
+ }))
340
+ ])
341
+ ])) : M("", !0),
342
+ u("div", An, [
343
+ s(N, {
344
+ id: "continue-selling",
345
+ modelValue: m(a),
346
+ "onUpdate:modelValue": c[5] || (c[5] = (B) => Y(a) ? a.value = B : null)
347
+ }, null, 8, ["modelValue"]),
348
+ s(D, {
349
+ for: "continue-selling",
350
+ class: "text-sm"
351
+ }, {
352
+ default: f(() => [...c[11] || (c[11] = [
353
+ V("Continue selling when out of stock", -1)
354
+ ])]),
355
+ _: 1
356
+ })
357
+ ])
358
+ ]),
359
+ _: 1
360
+ })
361
+ ]),
362
+ _: 1
363
+ });
364
+ };
365
+ }
366
+ }), On = { class: "flex items-center gap-2 mb-4" }, Mn = {
367
+ key: 0,
368
+ class: "grid grid-cols-2 gap-4 mb-4"
369
+ }, Fn = /* @__PURE__ */ ne({
370
+ __name: "Shipping",
371
+ setup(e) {
372
+ const { errors: t } = xe(), { value: n } = U("isPhysicalProduct"), { value: o } = U("weight"), { value: l } = U("weightUnit");
373
+ return (a, i) => {
374
+ const d = v("Checkbox"), r = v("Label"), b = v("Input"), x = v("SelectValue"), c = v("SelectTrigger"), D = v("SelectItem"), T = v("SelectGroup"), N = v("SelectContent"), I = v("Select"), A = v("CardContent"), z = v("Card");
375
+ return h(), L(z, null, {
376
+ default: f(() => [
377
+ s(A, null, {
378
+ default: f(() => [
379
+ i[10] || (i[10] = u("h3", { class: "text-lg font-semibold mb-4" }, "Shipping", -1)),
380
+ u("div", On, [
381
+ s(d, {
382
+ id: "is-physical-product",
383
+ modelValue: m(n),
384
+ "onUpdate:modelValue": i[0] || (i[0] = (_) => Y(n) ? n.value = _ : null)
385
+ }, null, 8, ["modelValue"]),
386
+ s(r, {
387
+ for: "is-physical-product",
388
+ class: "text-sm"
389
+ }, {
390
+ default: f(() => [...i[3] || (i[3] = [
391
+ V("This is a physical product", -1)
392
+ ])]),
393
+ _: 1
394
+ })
395
+ ]),
396
+ m(n) ? (h(), w("div", Mn, [
397
+ u("div", null, [
398
+ s(r, {
399
+ for: "weight",
400
+ class: "text-sm mb-2"
401
+ }, {
402
+ default: f(() => [...i[4] || (i[4] = [
403
+ V("Weight", -1)
404
+ ])]),
405
+ _: 1
406
+ }),
407
+ s(b, {
408
+ id: "weight",
409
+ type: "number",
410
+ modelValue: m(o),
411
+ "onUpdate:modelValue": i[1] || (i[1] = (_) => Y(o) ? o.value = _ : null),
412
+ class: "no-spinner"
413
+ }, null, 8, ["modelValue"])
414
+ ]),
415
+ u("div", null, [
416
+ s(r, {
417
+ for: "weight-unit",
418
+ class: "text-sm mb-2"
419
+ }, {
420
+ default: f(() => [...i[5] || (i[5] = [
421
+ V("Weight unit", -1)
422
+ ])]),
423
+ _: 1
424
+ }),
425
+ s(I, {
426
+ modelValue: m(l),
427
+ "onUpdate:modelValue": i[2] || (i[2] = (_) => Y(l) ? l.value = _ : null)
428
+ }, {
429
+ default: f(() => [
430
+ s(c, null, {
431
+ default: f(() => [
432
+ s(x, { placeholder: "Select unit" })
433
+ ]),
434
+ _: 1
435
+ }),
436
+ s(N, null, {
437
+ default: f(() => [
438
+ s(T, null, {
439
+ default: f(() => [
440
+ s(D, { value: "lb" }, {
441
+ default: f(() => [...i[6] || (i[6] = [
442
+ V(" lb ", -1)
443
+ ])]),
444
+ _: 1
445
+ }),
446
+ s(D, { value: "oz" }, {
447
+ default: f(() => [...i[7] || (i[7] = [
448
+ V(" oz ", -1)
449
+ ])]),
450
+ _: 1
451
+ }),
452
+ s(D, { value: "kg" }, {
453
+ default: f(() => [...i[8] || (i[8] = [
454
+ V(" kg ", -1)
455
+ ])]),
456
+ _: 1
457
+ }),
458
+ s(D, { value: "g" }, {
459
+ default: f(() => [...i[9] || (i[9] = [
460
+ V(" g ", -1)
461
+ ])]),
462
+ _: 1
463
+ })
464
+ ]),
465
+ _: 1
466
+ })
467
+ ]),
468
+ _: 1
469
+ })
470
+ ]),
471
+ _: 1
472
+ }, 8, ["modelValue"])
473
+ ])
474
+ ])) : M("", !0)
475
+ ]),
476
+ _: 1
477
+ })
478
+ ]),
479
+ _: 1
480
+ });
481
+ };
482
+ }
483
+ });
484
+ function G(e) {
485
+ e.preventDefault();
486
+ }
487
+ function me(e) {
488
+ e.stopPropagation();
489
+ }
490
+ function wt() {
491
+ const e = /* @__PURE__ */ new Map();
492
+ return [function(o, l) {
493
+ e.get(o) && e.get(o).forEach((a) => {
494
+ a(l);
495
+ });
496
+ }, function(o, l) {
497
+ const a = e.get(o) ?? [];
498
+ a.push(l), e.set(o, a);
499
+ }];
500
+ }
501
+ var [kt, Pt] = wt();
502
+ function Ln(e, t) {
503
+ return e.source === t.source && e.flags.split("").sort().join("") === t.flags.split("").sort().join("");
504
+ }
505
+ function Ae(e, t, n = !0, o = ["__key"]) {
506
+ if (e === t) return !0;
507
+ if (typeof t == "object" && typeof e == "object" && e !== null && t !== null) {
508
+ if (e instanceof Map || e instanceof Set) return !1;
509
+ if (e instanceof Date && t instanceof Date)
510
+ return e.getTime() === t.getTime();
511
+ if (e instanceof RegExp && t instanceof RegExp)
512
+ return Ln(e, t);
513
+ if (e === null || t === null) return !1;
514
+ const l = e, a = t;
515
+ if (Object.keys(l).length !== Object.keys(a).length) return !1;
516
+ for (const i of o)
517
+ if ((i in l || i in a) && l[i] !== a[i]) return !1;
518
+ for (const i in l)
519
+ if (!(i in a) || l[i] !== a[i] && !n || n && !Ae(l[i], a[i], n, o)) return !1;
520
+ return !0;
521
+ }
522
+ return !1;
523
+ }
524
+ function Vt(e) {
525
+ return e.split(" ").filter((t) => t);
526
+ }
527
+ function ke(e) {
528
+ return { x: e.clientX, y: e.clientY };
529
+ }
530
+ Array();
531
+ var rt = typeof window < "u", W = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap();
532
+ function Nt() {
533
+ if (!rt) return !1;
534
+ if ("userAgentData" in navigator)
535
+ return navigator.userAgentData.mobile === !0;
536
+ const e = navigator.userAgent, t = /android|iphone|ipod/i.test(e), n = /iPad/.test(e) || e.includes("Macintosh") && navigator.maxTouchPoints > 1;
537
+ return t || n;
538
+ }
539
+ var Bn = {
540
+ affectedNodes: [],
541
+ coordinates: {
542
+ x: 0,
543
+ y: 0
544
+ },
545
+ currentTargetValue: void 0,
546
+ on: Pt,
547
+ emit: kt,
548
+ originalZIndex: void 0,
549
+ pointerSelection: !1,
550
+ preventEnter: !1,
551
+ rootUserSelect: void 0,
552
+ nodePointerdown: void 0,
553
+ longPress: !1,
554
+ scrolling: !1,
555
+ longPressTimeout: void 0,
556
+ remapJustFinished: !1,
557
+ selectedNodes: [],
558
+ selectedParent: void 0,
559
+ preventSynthDrag: !1,
560
+ pointerDown: void 0,
561
+ lastScrollContainerX: null,
562
+ lastScrollContainerY: null,
563
+ rootScrollWidth: void 0,
564
+ rootScrollHeight: void 0,
565
+ dragItemRect: void 0,
566
+ windowScrollX: void 0,
567
+ windowScrollY: void 0,
568
+ lastScrollDirectionX: void 0,
569
+ lastScrollDirectionY: void 0,
570
+ scrollDebounceTimeout: void 0,
571
+ frameIdX: void 0,
572
+ frameIdY: void 0
573
+ }, g = Bn, ge = !1, vt, et;
574
+ function Rn() {
575
+ g.scrollDebounceTimeout && clearTimeout(g.scrollDebounceTimeout), g.longPressTimeout && clearTimeout(g.longPressTimeout), g.frameIdX !== void 0 && cancelAnimationFrame(g.frameIdX), g.frameIdY !== void 0 && cancelAnimationFrame(g.frameIdY), g = { ...{
576
+ affectedNodes: [],
577
+ coordinates: {
578
+ x: 0,
579
+ y: 0
580
+ },
581
+ on: Pt,
582
+ emit: kt,
583
+ currentTargetValue: void 0,
584
+ originalZIndex: void 0,
585
+ pointerId: void 0,
586
+ preventEnter: !1,
587
+ remapJustFinished: !1,
588
+ selectedNodes: [],
589
+ nodePointerdown: void 0,
590
+ rootUserSelect: void 0,
591
+ preventSynthDrag: !1,
592
+ scrolling: !1,
593
+ selectedParent: void 0,
594
+ pointerSelection: !1,
595
+ synthScrollDirection: void 0,
596
+ draggedNodeDisplay: void 0,
597
+ synthDragScrolling: !1,
598
+ longPress: !1,
599
+ pointerDown: void 0,
600
+ longPressTimeout: void 0,
601
+ lastScrollContainerX: null,
602
+ lastScrollContainerY: null,
603
+ rootScrollWidth: void 0,
604
+ rootScrollHeight: void 0,
605
+ dragItemRect: void 0,
606
+ windowScrollX: void 0,
607
+ windowScrollY: void 0,
608
+ lastScrollDirectionX: void 0,
609
+ lastScrollDirectionY: void 0,
610
+ scrollDebounceTimeout: void 0,
611
+ frameIdX: void 0,
612
+ frameIdY: void 0
613
+ } };
614
+ }
615
+ function It(e) {
616
+ return Object.assign(g, e), e.initialParent.data.emit("dragStarted", g), ge = !1, g.emit("dragStarted", g), g;
617
+ }
618
+ function Un() {
619
+ g.activeState && _e(g.activeState.parent, void 0, g), g.selectedState && he(g.selectedState.nodes, g.selectedState.parent, g), g.selectedState = g.activeState = void 0;
620
+ }
621
+ function jn() {
622
+ if (g.pointerDown && (g.pointerDown.node.el.draggable = !0), g.pointerDown = void 0, !te(g)) return;
623
+ const e = g.currentParent.data.config;
624
+ te(g) && e.handleEnd(g);
625
+ }
626
+ function Hn(e) {
627
+ e.key === "Escape" && (g.selectedState && he(g.selectedState.nodes, g.selectedState.parent, g), g.activeState && _e(g.activeState.parent, void 0, g), g.selectedState = g.activeState = void 0);
628
+ }
629
+ function Xn(e) {
630
+ if (!Z(g)) return;
631
+ ge = !0;
632
+ const t = g.initialParent.data.config.handleEnd;
633
+ t(g);
634
+ }
635
+ function Yn(e) {
636
+ if (!Z(g)) return;
637
+ G(e);
638
+ const { x: t, y: n } = ke(e);
639
+ Z(g) && Re({ x: t, y: n }, e, g);
640
+ }
641
+ function Kn(e) {
642
+ if (!g.pointerDown || !g.pointerDown.validated) return;
643
+ const t = g.pointerDown.parent.data.config;
644
+ if (!(e.pointerType === "mouse" && !Nt()))
645
+ if (te(g))
646
+ te(g) && bt(e, g);
647
+ else {
648
+ if (G(e), t.longPress && !g.longPress) {
649
+ clearTimeout(g.longPressTimeout), g.longPress = !1;
650
+ return;
651
+ }
652
+ const n = t.draggedNodes(g.pointerDown);
653
+ t.dragstartClasses(g.pointerDown.node, n, t, !0);
654
+ const o = g.pointerDown.node.el.getBoundingClientRect(), l = Co(
655
+ g.pointerDown.node,
656
+ g.pointerDown.parent,
657
+ e,
658
+ g,
659
+ n,
660
+ o
661
+ );
662
+ bt(e, l, !0);
663
+ }
664
+ }
665
+ function Jn({
666
+ parent: e,
667
+ getValues: t,
668
+ setValues: n,
669
+ config: o = {}
670
+ }) {
671
+ if (!rt) return;
672
+ vt || (vt = Fe(document, {
673
+ dragover: Yn,
674
+ pointerdown: Un,
675
+ pointerup: jn,
676
+ keydown: Hn,
677
+ drop: Xn,
678
+ pointermove: Kn,
679
+ pointercancel: ee(o.handlePointercancel),
680
+ touchmove: (r) => {
681
+ Z(g) && r.cancelable && G(r);
682
+ },
683
+ contextmenu: (r) => {
684
+ te(g) && G(r);
685
+ }
686
+ })), Qn(e);
687
+ const [l, a] = wt(), i = {
688
+ getValues: t,
689
+ setValues: n,
690
+ config: {
691
+ dragDropEffect: o.dragDropEffect ?? "move",
692
+ dragEffectAllowed: o.dragEffectAllowed ?? "move",
693
+ draggedNodes: io,
694
+ dragstartClasses: po,
695
+ handleNodeKeydown: mo,
696
+ handleDragstart: co,
697
+ handleNodeDragover: ko,
698
+ handleParentDragover: Po,
699
+ handleNodeDrop: bo,
700
+ handleNodeFocus: ho,
701
+ handleNodeBlur: _o,
702
+ handlePointercancel: yo,
703
+ handleEnd: Do,
704
+ handleDragend: xo,
705
+ handleParentFocus: Wn,
706
+ handleNodePointerup: So,
707
+ handleNodePointerover: vo,
708
+ handleParentPointerover: Vo,
709
+ handleParentScroll: uo,
710
+ handleNodePointerdown: fo,
711
+ handleNodeDragenter: Io,
712
+ handleNodeDragleave: To,
713
+ handleParentDrop: Zn,
714
+ multiDrag: o.multiDrag ?? !1,
715
+ nativeDrag: o.nativeDrag ?? !0,
716
+ performSort: qn,
717
+ performTransfer: Gn,
718
+ root: o.root ?? document,
719
+ setupNode: to,
720
+ setupNodeRemap: $t,
721
+ reapplyDragClasses: no,
722
+ tearDownNode: lo,
723
+ tearDownNodeRemap: oo,
724
+ remapFinished: ao,
725
+ threshold: {
726
+ horizontal: 0,
727
+ vertical: 0
728
+ },
729
+ ...o
730
+ },
731
+ enabledNodes: [],
732
+ abortControllers: {},
733
+ privateClasses: [],
734
+ on: a,
735
+ emit: l
736
+ };
737
+ new MutationObserver(ro).observe(e, { childList: !0 }), W.set(e, i), o.plugins?.forEach((r) => {
738
+ r(e)?.tearDown?.();
739
+ }), o.plugins?.forEach((r) => {
740
+ r(e)?.tearDown?.();
741
+ }), o.plugins?.forEach((r) => {
742
+ r(e)?.setup?.();
743
+ }), eo(e, i), Le(e, !0);
744
+ }
745
+ function Tt(e, t, n, o, l, a) {
746
+ const { x: i, y: d } = ke(n), r = e.el.getBoundingClientRect();
747
+ return {
748
+ affectedNodes: [],
749
+ ascendingDirection: !1,
750
+ clonedDraggedEls: [],
751
+ coordinates: {
752
+ x: i,
753
+ y: d
754
+ },
755
+ draggedNode: {
756
+ el: e.el,
757
+ data: e.data
758
+ },
759
+ draggedNodes: o,
760
+ incomingDirection: void 0,
761
+ initialIndex: e.data.index,
762
+ initialParent: {
763
+ el: t.el,
764
+ data: t.data
765
+ },
766
+ currentParent: {
767
+ el: t.el,
768
+ data: t.data
769
+ },
770
+ longPress: t.data.config.longPress ?? !1,
771
+ longPressTimeout: void 0,
772
+ currentTargetValue: e.data.value,
773
+ scrollEls: [],
774
+ startLeft: l || i - (r?.left ?? 0),
775
+ startTop: a || d - (r?.top ?? 0),
776
+ targetIndex: e.data.index,
777
+ transferred: !1
778
+ };
779
+ }
780
+ function qn({
781
+ parent: e,
782
+ draggedNodes: t,
783
+ targetNodes: n
784
+ }) {
785
+ Le(e.el);
786
+ const o = t.map((r) => r.data.value), l = we(e.el, e.data), a = t[0].data.index, i = [...e.data.enabledNodes], d = [
787
+ ...l.filter((r) => !o.some((b) => Ae(r, b)))
788
+ ];
789
+ d.splice(n[0].data.index, 0, ...o), "draggedNode" in g && (g.currentTargetValue = n[0].data.value), nt(e.el, e.data, [...d]), e.data.config.onSort && e.data.config.onSort({
790
+ parent: {
791
+ el: e.el,
792
+ data: e.data
793
+ },
794
+ previousValues: [...l],
795
+ previousNodes: [...i],
796
+ nodes: [...e.data.enabledNodes],
797
+ values: [...d],
798
+ draggedNodes: t,
799
+ previousPosition: a,
800
+ position: n[0].data.index,
801
+ targetNodes: n,
802
+ state: g
803
+ });
804
+ }
805
+ function _e(e, t, n) {
806
+ if (!t) {
807
+ n.activeState = void 0;
808
+ return;
809
+ }
810
+ n.activeState = {
811
+ node: t,
812
+ parent: e
813
+ };
814
+ }
815
+ function he(e, t, n) {
816
+ const o = t.data.config.selectedClass;
817
+ if (!n.selectedState) return;
818
+ const l = Array.from(e);
819
+ pe(
820
+ e.map((a) => a.el),
821
+ o
822
+ );
823
+ for (const a of l) {
824
+ a.el.setAttribute("aria-selected", "false");
825
+ const i = n.selectedState.nodes.findIndex((d) => d.el === a.el);
826
+ i !== -1 && n.selectedState.nodes.splice(i, 1);
827
+ }
828
+ }
829
+ function Oe(e, t, n, o, l = !1) {
830
+ o.pointerSelection = l;
831
+ for (const a of t)
832
+ a.el.setAttribute("aria-selected", "true"), Ce([a.el], e.data.config.selectedClass, !0);
833
+ o.selectedState = {
834
+ nodes: t,
835
+ parent: e
836
+ }, _e(e, n, o);
837
+ }
838
+ function Wn(e, t) {
839
+ const n = e.targetData.parent.data.enabledNodes[0];
840
+ n && (t.selectedState && t.selectedState.parent.el !== e.targetData.parent.el ? _e(e.targetData.parent, n, t) : t.selectedState || _e(e.targetData.parent, n, t));
841
+ }
842
+ function Gn({
843
+ currentParent: e,
844
+ targetParent: t,
845
+ initialParent: n,
846
+ draggedNodes: o,
847
+ initialIndex: l,
848
+ targetNodes: a,
849
+ state: i
850
+ }) {
851
+ Le(n.el);
852
+ const d = o.map((D) => D.data.value), r = [
853
+ ...we(e.el, e.data).filter(
854
+ (D) => !d.some((T) => Ae(D, T))
855
+ )
856
+ ], b = we(t.el, t.data), x = n.el === t.el && t.data.config.sortable === !1;
857
+ let c;
858
+ a.length ? (x ? c = l : t.data.config.sortable === !1 ? c = t.data.enabledNodes.length : c = a[0].data.index, b.splice(c, 0, ...d)) : (c = x ? l : t.data.enabledNodes.length, b.splice(c, 0, ...d)), nt(e.el, e.data, r), nt(t.el, t.data, b), t.data.config.onTransfer && t.data.config.onTransfer({
859
+ sourceParent: e,
860
+ targetParent: t,
861
+ initialParent: n,
862
+ draggedNodes: o,
863
+ targetIndex: c,
864
+ state: i,
865
+ targetNodes: a
866
+ }), e.data.config.onTransfer && e.data.config.onTransfer({
867
+ sourceParent: e,
868
+ targetParent: t,
869
+ initialParent: n,
870
+ draggedNodes: o,
871
+ targetIndex: c,
872
+ state: i,
873
+ targetNodes: a || []
874
+ });
875
+ }
876
+ function we(e, t) {
877
+ return [...t.getValues(e)];
878
+ }
879
+ function nt(e, t, n) {
880
+ t.setValues(n, e);
881
+ }
882
+ function Zn(e, t) {
883
+ me(e.e), ge = !0;
884
+ const n = t.initialParent.data.config.handleEnd;
885
+ n(t);
886
+ }
887
+ function Qn(e) {
888
+ const t = W.get(e);
889
+ t && t.abortControllers.mainParent && t.abortControllers.mainParent.abort();
890
+ }
891
+ function Z(e) {
892
+ return "draggedNode" in e && !!e.draggedNode;
893
+ }
894
+ function te(e) {
895
+ return "synthDragging" in e && !!e.synthDragging;
896
+ }
897
+ function eo(e, t) {
898
+ t.abortControllers.mainParent = Fe(e, {
899
+ dragover: Me(t.config.handleParentDragover),
900
+ handleParentPointerover: t.config.handleParentPointerover,
901
+ scroll: Me(t.config.handleParentScroll),
902
+ drop: Me(t.config.handleParentDrop),
903
+ hasNestedParent: (n) => {
904
+ const o = W.get(n.target);
905
+ o && (o.nestedParent = n.detail.parent);
906
+ },
907
+ focus: Me(t.config.handleParentFocus)
908
+ }), t.config.externalDragHandle && t.config.externalDragHandle.el && t.config.externalDragHandle.callback && (t.abortControllers.externalDragHandle = Fe(
909
+ t.config.externalDragHandle.el,
910
+ {
911
+ pointerdown: (n) => {
912
+ if (!t.config.externalDragHandle || !t.config.externalDragHandle.callback)
913
+ return;
914
+ const o = t.config.externalDragHandle.callback();
915
+ if (!Ue(o)) {
916
+ console.warn(
917
+ "No draggable item found from external drag handle callback"
918
+ );
919
+ return;
920
+ }
921
+ const l = ue.get(o);
922
+ if (!l) return;
923
+ const a = o.parentNode;
924
+ if (!(a instanceof HTMLElement)) return;
925
+ const i = W.get(a);
926
+ i && (g.pointerDown = {
927
+ parent: {
928
+ el: a,
929
+ data: i
930
+ },
931
+ node: {
932
+ el: o,
933
+ data: l
934
+ },
935
+ validated: !0
936
+ }, o.draggable = !0);
937
+ }
938
+ }
939
+ ));
940
+ }
941
+ function to(e) {
942
+ const t = e.parent.data.config;
943
+ e.node.data.abortControllers.mainNode = Fe(e.node.el, {
944
+ keydown: ee(t.handleNodeKeydown),
945
+ dragstart: ee(t.handleDragstart),
946
+ dragover: ee(t.handleNodeDragover),
947
+ dragenter: ee(t.handleNodeDragenter),
948
+ dragleave: ee(t.handleNodeDragleave),
949
+ dragend: ee(t.handleDragend),
950
+ drop: ee(t.handleNodeDrop),
951
+ focus: ee(t.handleNodeFocus),
952
+ blur: ee(t.handleNodeBlur),
953
+ pointerup: ee(t.handleNodePointerup),
954
+ pointercancel: ee(t.handlePointercancel),
955
+ pointerdown: ee(t.handleNodePointerdown),
956
+ handleNodePointerover: t.handleNodePointerover,
957
+ touchmove: (n) => {
958
+ Z(g) && n.cancelable && G(n);
959
+ },
960
+ contextmenu: (n) => {
961
+ te(g) && G(n);
962
+ }
963
+ }), e.node.el.draggable = !0, t.reapplyDragClasses(e.node.el, e.parent.data), e.parent.data.config.plugins?.forEach((n) => {
964
+ n(e.parent.el)?.setupNode?.(e);
965
+ });
966
+ }
967
+ function $t(e) {
968
+ ue.set(e.node.el, e.node.data), e.parent.data.config.plugins?.forEach((t) => {
969
+ t(e.parent.el)?.setupNodeRemap?.(e);
970
+ });
971
+ }
972
+ function no(e, t) {
973
+ if (!Z(g)) return;
974
+ const n = te(g) ? t.config.synthDropZoneClass : t.config.dropZoneClass;
975
+ g.draggedNode.el === e && Ce([e], n, !0);
976
+ }
977
+ function oo(e) {
978
+ e.parent.data.config.plugins?.forEach((t) => {
979
+ t(e.parent.el)?.tearDownNodeRemap?.(e);
980
+ });
981
+ }
982
+ function lo(e) {
983
+ e.parent.data.config.plugins?.forEach((t) => {
984
+ t(e.parent.el)?.tearDownNode?.(e);
985
+ }), e.node.el.draggable = !1, e.node.data?.abortControllers?.mainNode && e.node.data?.abortControllers?.mainNode.abort();
986
+ }
987
+ function ro(e) {
988
+ if (e.length === 1 && e[0].addedNodes.length === 1 && !(e[0].addedNodes[0] instanceof HTMLElement))
989
+ return;
990
+ const t = e[0].target;
991
+ !(t instanceof HTMLElement) || !W.get(t) || Le(t);
992
+ }
993
+ function Le(e, t) {
994
+ const n = W.get(e);
995
+ if (!n) return;
996
+ n.privateClasses = Array.from(e.classList);
997
+ const o = [], l = n.config;
998
+ for (let d = 0; d < e.children.length; d++) {
999
+ const r = e.children[d];
1000
+ if (!Ue(r) || r.id === "dnd-dragged-node-clone") continue;
1001
+ const b = ue.get(r);
1002
+ (t || !b) && l.tearDownNode({
1003
+ parent: {
1004
+ el: e,
1005
+ data: n
1006
+ },
1007
+ node: {
1008
+ el: r,
1009
+ data: b
1010
+ }
1011
+ }), !l.disabled && (!l.draggable || l.draggable && l.draggable(r)) && o.push(r);
1012
+ }
1013
+ if (o.length !== n.getValues(e).length && !l.disabled) {
1014
+ console.warn(
1015
+ "The number of draggable items defined in the parent element does not match the number of values. This may cause unexpected behavior."
1016
+ );
1017
+ return;
1018
+ }
1019
+ const a = n.getValues(e), i = [];
1020
+ for (let d = 0; d < o.length; d++) {
1021
+ const r = o[d], b = ue.get(r);
1022
+ if (l.draggableValue && !l.draggableValue(a[d])) continue;
1023
+ const x = Object.assign(
1024
+ b ?? {
1025
+ privateClasses: [],
1026
+ abortControllers: {}
1027
+ },
1028
+ {
1029
+ value: a[d],
1030
+ index: d
1031
+ }
1032
+ );
1033
+ if (!Z(g) && g.activeState && Ae(g.activeState.node.data.value, x.value) && _e(
1034
+ {
1035
+ data: n,
1036
+ el: e
1037
+ },
1038
+ {
1039
+ el: r,
1040
+ data: x
1041
+ },
1042
+ g
1043
+ ), Z(g) && Ae(g.draggedNode.data.value, x.value)) {
1044
+ g.draggedNode.data = x, g.draggedNode.el = r;
1045
+ const c = g.draggedNodes.find(
1046
+ (D) => D.data.value === x.value
1047
+ );
1048
+ c && (c.el = r);
1049
+ }
1050
+ i.push({
1051
+ el: r,
1052
+ data: x
1053
+ }), (t || !b) && l.setupNode({
1054
+ parent: {
1055
+ el: e,
1056
+ data: n
1057
+ },
1058
+ node: {
1059
+ el: r,
1060
+ data: x
1061
+ }
1062
+ }), $t({
1063
+ parent: {
1064
+ el: e,
1065
+ data: n
1066
+ },
1067
+ node: {
1068
+ el: r,
1069
+ data: x
1070
+ }
1071
+ });
1072
+ }
1073
+ W.set(e, { ...n, enabledNodes: i }), l.remapFinished(n), n.config.plugins?.forEach((d) => {
1074
+ d(e)?.remapFinished?.();
1075
+ });
1076
+ }
1077
+ function ao() {
1078
+ g.remapJustFinished = !0, "draggedNode" in g && (g.affectedNodes = []);
1079
+ }
1080
+ function so(e) {
1081
+ return !!e.targetData.parent.data.config.nativeDrag;
1082
+ }
1083
+ function io(e) {
1084
+ if (e.parent.data.config.multiDrag) {
1085
+ if (g.selectedState)
1086
+ return [
1087
+ e.node,
1088
+ ...g.selectedState?.nodes.filter(
1089
+ (t) => t.el !== e.node.el
1090
+ )
1091
+ ];
1092
+ } else return [e.node];
1093
+ return [];
1094
+ }
1095
+ function uo(e) {
1096
+ Z(g) && (g.emit("scrollStarted", g), !te(g) && (g.preventEnter = !0, et && clearTimeout(et), et = setTimeout(() => {
1097
+ g.preventEnter = !1, g.emit("scrollEnded", g);
1098
+ }, 100)));
1099
+ }
1100
+ function co(e, t) {
1101
+ const n = e.targetData.parent.data.config;
1102
+ if (!n.nativeDrag || !so(e) || !Et({
1103
+ x: e.e.clientX,
1104
+ y: e.e.clientY,
1105
+ node: e.targetData.node,
1106
+ config: n
1107
+ })) {
1108
+ G(e.e);
1109
+ return;
1110
+ }
1111
+ let o = n.draggedNodes({
1112
+ parent: e.targetData.parent,
1113
+ node: e.targetData.node
1114
+ });
1115
+ o.length === 0 && (o = [e.targetData.node]), n.dragstartClasses(e.targetData.node, o, n);
1116
+ const l = go(e, o);
1117
+ if (n.onDragstart) {
1118
+ const a = {
1119
+ parent: e.targetData.parent,
1120
+ values: we(
1121
+ e.targetData.parent.el,
1122
+ e.targetData.parent.data
1123
+ ),
1124
+ draggedNode: l.draggedNode,
1125
+ draggedNodes: l.draggedNodes,
1126
+ position: l.initialIndex,
1127
+ state: l
1128
+ };
1129
+ n.onDragstart(a);
1130
+ }
1131
+ }
1132
+ function fo(e, t) {
1133
+ if (me(e.e), t.pointerDown = {
1134
+ parent: e.targetData.parent,
1135
+ node: e.targetData.node,
1136
+ validated: !1
1137
+ }, !Et({
1138
+ x: e.e.clientX,
1139
+ y: e.e.clientY,
1140
+ node: e.targetData.node,
1141
+ config: e.targetData.parent.data.config
1142
+ }))
1143
+ return;
1144
+ t.pointerDown.validated = !0, wo(e, t, e.targetData.node);
1145
+ const n = e.targetData.parent.data;
1146
+ let o = [e.targetData.node];
1147
+ const l = e.e.ctrlKey || e.e.metaKey, a = e.e.shiftKey, i = e.targetData.node;
1148
+ if (l && n.config.multiDrag) {
1149
+ t.selectedState ? t.selectedState.nodes.findIndex(
1150
+ (r) => r.el === i.el
1151
+ ) === -1 ? o = [...t.selectedState.nodes, i] : o = t.selectedState.nodes.filter(
1152
+ (r) => r.el !== i.el
1153
+ ) : o = [i], Oe(
1154
+ e.targetData.parent,
1155
+ o,
1156
+ e.targetData.node,
1157
+ t,
1158
+ !0
1159
+ );
1160
+ return;
1161
+ }
1162
+ if (a && n.config.multiDrag) {
1163
+ const d = e.targetData.parent.data.enabledNodes;
1164
+ if (t.selectedState && t.activeState)
1165
+ if (t.selectedState.parent.el !== e.targetData.parent.el) {
1166
+ he(t.selectedState.nodes, t.selectedState.parent, t), t.selectedState = void 0;
1167
+ for (let r = 0; r <= i.data.index; r++)
1168
+ o.push(d[r]);
1169
+ } else {
1170
+ const [r, b] = t.activeState.node.data.index < e.targetData.node.data.index ? [
1171
+ t.activeState.node.data.index,
1172
+ e.targetData.node.data.index
1173
+ ] : [
1174
+ e.targetData.node.data.index,
1175
+ t.activeState.node.data.index
1176
+ ];
1177
+ o = d.slice(r, b + 1);
1178
+ }
1179
+ else
1180
+ for (let r = 0; r <= i.data.index; r++)
1181
+ o.push(d[r]);
1182
+ Oe(
1183
+ e.targetData.parent,
1184
+ o,
1185
+ e.targetData.node,
1186
+ t,
1187
+ !0
1188
+ );
1189
+ return;
1190
+ }
1191
+ t.selectedState?.nodes?.length ? t.selectedState.nodes.findIndex(
1192
+ (r) => r.el === e.targetData.node.el
1193
+ ) === -1 && (t.selectedState.parent.el !== e.targetData.parent.el ? he(t.selectedState.nodes, e.targetData.parent, t) : n.config.multiDrag && Nt() ? o.push(...t.selectedState.nodes) : he(t.selectedState.nodes, e.targetData.parent, t), Oe(
1194
+ e.targetData.parent,
1195
+ o,
1196
+ e.targetData.node,
1197
+ t,
1198
+ !0
1199
+ )) : Oe(
1200
+ e.targetData.parent,
1201
+ [e.targetData.node],
1202
+ e.targetData.node,
1203
+ t,
1204
+ !0
1205
+ );
1206
+ }
1207
+ function po(e, t, n, o = !1) {
1208
+ Ce(
1209
+ t.map((l) => l.el),
1210
+ o ? n.synthDraggingClass : n.draggingClass
1211
+ ), setTimeout(() => {
1212
+ pe(
1213
+ t.map((l) => l.el),
1214
+ o ? n.synthDraggingClass : n.draggingClass
1215
+ ), Ce(
1216
+ t.map((l) => l.el),
1217
+ o ? n.synthDragPlaceholderClass : n.dragPlaceholderClass
1218
+ ), Ce(
1219
+ t.map((l) => l.el),
1220
+ o ? n.synthDropZoneClass : n.dropZoneClass
1221
+ ), pe(
1222
+ t.map((l) => l.el),
1223
+ n.selectedClass
1224
+ );
1225
+ });
1226
+ }
1227
+ function go(e, t) {
1228
+ me(e.e);
1229
+ const n = It(
1230
+ Tt(
1231
+ e.targetData.node,
1232
+ e.targetData.parent,
1233
+ e.e,
1234
+ t
1235
+ )
1236
+ );
1237
+ if (e.e.dataTransfer) {
1238
+ const o = e.targetData.parent.data.config;
1239
+ e.e.dataTransfer.dropEffect = o.dragDropEffect, e.e.dataTransfer.effectAllowed = o.dragEffectAllowed;
1240
+ let l;
1241
+ if (e.e.dataTransfer.setData("text/plain", ""), o.dragImage)
1242
+ l = o.dragImage(e, t);
1243
+ else {
1244
+ if (!o.multiDrag || t.length === 1)
1245
+ return e.targetData.node.el.style.zIndex = "9999", e.targetData.node.el.style.boxSizing = "border-box", e.e.dataTransfer.setDragImage(
1246
+ e.targetData.node.el,
1247
+ e.e.offsetX,
1248
+ e.e.offsetY
1249
+ ), n.originalZIndex = e.targetData.node.el.style.zIndex, n;
1250
+ {
1251
+ const a = document.createElement("div");
1252
+ a.setAttribute("id", "dnd-dragged-node-clone"), a.setAttribute("popover", "manual");
1253
+ for (const d of t) {
1254
+ const r = d.el.cloneNode(!0);
1255
+ r.id = d.el.id + "-clone", r.style.pointerEvents = "none", a.appendChild(r);
1256
+ }
1257
+ const { width: i } = t[0].el.getBoundingClientRect();
1258
+ Object.assign(a.style, {
1259
+ display: "flex",
1260
+ flexDirection: "column",
1261
+ width: `${i}px`,
1262
+ position: "absolute",
1263
+ pointerEvents: "none",
1264
+ zIndex: "9999",
1265
+ left: "-9999px",
1266
+ boxSizing: "border-box",
1267
+ background: "transparent",
1268
+ overflow: "hidden"
1269
+ }), e.targetData.parent.el.appendChild(a), a.showPopover(), a.getBoundingClientRect(), l = a, e.e.dataTransfer.setDragImage(
1270
+ l,
1271
+ e.e.offsetX,
1272
+ e.e.offsetY
1273
+ );
1274
+ }
1275
+ }
1276
+ setTimeout(() => {
1277
+ l?.remove();
1278
+ });
1279
+ }
1280
+ return n;
1281
+ }
1282
+ function Et({
1283
+ x: e,
1284
+ y: t,
1285
+ node: n,
1286
+ config: o
1287
+ }) {
1288
+ if (o.externalDragHandle) return !1;
1289
+ if (!o.dragHandle) return !0;
1290
+ const l = n.el.querySelectorAll(o.dragHandle);
1291
+ if (!l) return !1;
1292
+ const a = o.root.elementFromPoint(e, t);
1293
+ if (!a) return !1;
1294
+ for (const i of Array.from(l))
1295
+ if (a === i || i.contains(a)) return !0;
1296
+ return !1;
1297
+ }
1298
+ function mo(e) {
1299
+ }
1300
+ function vo(e) {
1301
+ e.detail.targetData.parent.el === e.detail.state.currentParent.el ? zt(e.detail, e.detail.state) : Be(e.detail, e.detail.state);
1302
+ }
1303
+ function bo(e, t) {
1304
+ const n = e.targetData.parent.data.config;
1305
+ n.nativeDrag && (me(e.e), ge = !0, n.handleEnd(t));
1306
+ }
1307
+ function ho(e) {
1308
+ e.e.target !== e.e.currentTarget && g.pointerDown && (g.pointerDown.node.el.draggable = !1);
1309
+ }
1310
+ function _o(e) {
1311
+ e.e.target !== e.e.currentTarget && g.pointerDown && (g.pointerDown.node.el.draggable = !0);
1312
+ }
1313
+ function xo(e, t) {
1314
+ const n = e.targetData.parent.data.config;
1315
+ if (n.nativeDrag) {
1316
+ if (G(e.e), me(e.e), ge) {
1317
+ ge = !1;
1318
+ return;
1319
+ }
1320
+ n.handleEnd(t);
1321
+ }
1322
+ }
1323
+ function yo(e, t) {
1324
+ if (!te(t)) return;
1325
+ if (G(e.e), ge) {
1326
+ ge = !1;
1327
+ return;
1328
+ }
1329
+ const n = W.get(t.initialParent.el)?.config;
1330
+ n?.onDragend && n.onDragend({
1331
+ parent: t.currentParent,
1332
+ values: we(t.currentParent.el, t.currentParent.data),
1333
+ draggedNode: t.draggedNode,
1334
+ draggedNodes: t.draggedNodes,
1335
+ state: t
1336
+ }), n?.handleEnd(t);
1337
+ }
1338
+ function Do(e) {
1339
+ e.draggedNode && (e.draggedNode.el.draggable = !0);
1340
+ const t = e.draggedNodes.map((x) => x.el), n = e.initialParent.data, o = te(e), l = W.get(e.initialParent.el)?.config, a = o ? l?.synthDropZoneClass : l?.dropZoneClass, i = n?.config?.longPressClass, d = o ? n?.config?.synthDragPlaceholderClass : n?.config?.dragPlaceholderClass, r = e.originalZIndex;
1341
+ te(e) && (e.clonedDraggedNode && e.clonedDraggedNode.remove(), e.longPressTimeout && clearTimeout(e.longPressTimeout)), ot(e), e.lastScrollDirectionX = void 0, e.lastScrollDirectionY = void 0, e.preventEnter = !1, e.scrollDebounceTimeout && (clearTimeout(e.scrollDebounceTimeout), e.scrollDebounceTimeout = void 0), r !== void 0 && e.draggedNode && (e.draggedNode.el.style.zIndex = r), requestAnimationFrame(() => {
1342
+ pe(t, a), pe(t, i), pe(t, d);
1343
+ }), he(e.draggedNodes, e.currentParent, e), _e(e.currentParent, void 0, e);
1344
+ const b = { ...e };
1345
+ l?.onDragend?.({
1346
+ parent: b.currentParent,
1347
+ values: we(
1348
+ b.currentParent.el,
1349
+ b.currentParent.data
1350
+ ),
1351
+ draggedNode: b.draggedNode,
1352
+ draggedNodes: b.draggedNodes,
1353
+ state: b
1354
+ }), e.emit("dragEnded", b), Rn();
1355
+ }
1356
+ function So(e, t) {
1357
+ me(e.e), !t.pointerSelection && t.selectedState && he(t.selectedState.nodes, e.targetData.parent, t);
1358
+ const n = e.targetData.parent.data.config;
1359
+ t.pointerSelection = !1, "longPressTimeout" in t && t.longPressTimeout && clearTimeout(t.longPressTimeout), t.longPress = !1, pe(
1360
+ e.targetData.parent.data.enabledNodes.map((o) => o.el),
1361
+ n.longPressClass
1362
+ ), Z(t) && n.handleEnd(t);
1363
+ }
1364
+ function Co(e, t, n, o, l, a) {
1365
+ const i = t.data.config;
1366
+ let d, r;
1367
+ const b = [
1368
+ "display",
1369
+ "flexDirection",
1370
+ "alignItems",
1371
+ "justifyContent",
1372
+ "padding",
1373
+ "paddingTop",
1374
+ "margin",
1375
+ "marginTop",
1376
+ "marginBottom",
1377
+ "marginLeft",
1378
+ "marginRight",
1379
+ "paddingBottom",
1380
+ "paddingLeft",
1381
+ "paddingRight",
1382
+ "border",
1383
+ "borderRadius",
1384
+ "background",
1385
+ "backgroundColor",
1386
+ "boxShadow",
1387
+ "font",
1388
+ "color",
1389
+ "lineHeight",
1390
+ "gap",
1391
+ "width",
1392
+ "height",
1393
+ "boxSizing",
1394
+ "overflow"
1395
+ ], x = (N, I) => {
1396
+ const A = window.getComputedStyle(N);
1397
+ b.forEach((z) => {
1398
+ I.style[z] = A[z];
1399
+ });
1400
+ }, c = (N, I = {}) => {
1401
+ Object.assign(N.style, {
1402
+ position: "absolute",
1403
+ zIndex: "9999",
1404
+ pointerEvents: "none",
1405
+ willChange: "transform",
1406
+ boxSizing: "border-box",
1407
+ opacity: "0",
1408
+ overflow: "hidden",
1409
+ width: `${a.width}px`,
1410
+ height: `${a.height}px`,
1411
+ ...I
1412
+ });
1413
+ };
1414
+ if (i.synthDragImage)
1415
+ r = i.synthDragImage(e, t, n, l), d = r.dragImage, d.setAttribute("popover", "manual"), c(d);
1416
+ else if (!i.multiDrag || l.length === 1)
1417
+ d = e.el.cloneNode(!0), x(e.el, d), d.setAttribute("popover", "manual"), c(d);
1418
+ else {
1419
+ const N = document.createElement("div");
1420
+ N.setAttribute("popover", "manual"), l.forEach((I) => {
1421
+ const A = I.el.cloneNode(!0);
1422
+ x(I.el, A), A.style.pointerEvents = "none", A.style.margin = "0", N.append(A);
1423
+ }), N.style.display = "flex", N.style.flexDirection = "column", N.style.padding = "0", N.style.margin = "0", N.style.position = "absolute", N.style.zIndex = "9999", N.style.pointerEvents = "none", d = N;
1424
+ }
1425
+ d.id = "dnd-dragged-node-clone", t.el.appendChild(d), d.showPopover();
1426
+ const D = {
1427
+ clonedDraggedEls: [],
1428
+ clonedDraggedNode: d,
1429
+ synthDragScrolling: !1,
1430
+ synthDragging: !0,
1431
+ rootScrollWidth: document.scrollingElement?.scrollWidth,
1432
+ rootScrollHeight: document.scrollingElement?.scrollHeight
1433
+ };
1434
+ return It({
1435
+ ...Tt(
1436
+ e,
1437
+ t,
1438
+ n,
1439
+ l,
1440
+ r?.offsetX,
1441
+ r?.offsetY
1442
+ ),
1443
+ ...D
1444
+ });
1445
+ }
1446
+ function wo(e, t, n) {
1447
+ const o = e.targetData.parent.data.config;
1448
+ t.longPressTimeout = setTimeout(() => {
1449
+ t && (t.longPress = !0, o.longPressClass && e.e.cancelable && Ce([n.el], o.longPressClass), G(e.e));
1450
+ }, o.longPressDuration || 1e3);
1451
+ }
1452
+ function ot(e, t = !0, n = !0) {
1453
+ t && (e.frameIdX !== void 0 && (cancelAnimationFrame(e.frameIdX), e.frameIdX = void 0), e.lastScrollDirectionX = void 0), n && (e.frameIdY !== void 0 && (cancelAnimationFrame(e.frameIdY), e.frameIdY = void 0), e.lastScrollDirectionY = void 0), !e.frameIdX && !e.frameIdY && (e.preventEnter = !1);
1454
+ }
1455
+ function At(e, t = !1) {
1456
+ const { x: n, y: o } = e.coordinates, l = e.startLeft ?? 0, a = e.startTop ?? 0, i = window.scrollX ?? 0, d = window.scrollY ?? 0, r = n - l + i, b = o - a + d;
1457
+ e.clonedDraggedNode.style.transform = `translate3d(${r}px, ${b}px, 0px)`, t && (e.clonedDraggedNode.style.opacity = "1", pe(
1458
+ e.draggedNodes.map((x) => x.el),
1459
+ e.initialParent.data.config?.longPressClass
1460
+ ));
1461
+ }
1462
+ function bt(e, t, n = !1) {
1463
+ const o = ke(e);
1464
+ t.coordinates.x = o.x, t.coordinates.y = o.y, At(t, n), t.scrollDebounceTimeout && (clearTimeout(t.scrollDebounceTimeout), t.scrollDebounceTimeout = void 0), t.scrollDebounceTimeout = setTimeout(() => {
1465
+ te(t) && Re(t.coordinates, e, t);
1466
+ }, 16);
1467
+ const l = zo(o);
1468
+ if (!l) {
1469
+ document.dispatchEvent(
1470
+ new CustomEvent("handleRootPointerover", {
1471
+ detail: {
1472
+ e,
1473
+ state: t
1474
+ }
1475
+ })
1476
+ );
1477
+ return;
1478
+ }
1479
+ const a = {
1480
+ e,
1481
+ targetData: l,
1482
+ state: t
1483
+ };
1484
+ "node" in l ? l.node.el.dispatchEvent(
1485
+ new CustomEvent("handleNodePointerover", {
1486
+ detail: a
1487
+ })
1488
+ ) : l.parent.el.dispatchEvent(
1489
+ new CustomEvent("handleParentPointerover", {
1490
+ detail: a
1491
+ })
1492
+ );
1493
+ }
1494
+ function ko(e, t) {
1495
+ if (!e.targetData.parent.data.config.nativeDrag) return;
1496
+ const { x: o, y: l } = ke(e.e);
1497
+ t.coordinates.y = l, t.coordinates.x = o, G(e.e), me(e.e), Z(t) && Re({ x: o, y: l }, e.e, t), e.targetData.parent.el === t.currentParent?.el ? zt(e, t) : Be(e, t);
1498
+ }
1499
+ function Po(e, t) {
1500
+ if (!e.targetData.parent.data.config.nativeDrag) return;
1501
+ G(e.e), me(e.e);
1502
+ const { x: o, y: l } = ke(e.e);
1503
+ Z(t) && Re({ x: o, y: l }, e.e, t), Be(e, t);
1504
+ }
1505
+ function Vo(e) {
1506
+ e.detail.targetData.parent.el !== e.detail.state.currentParent.el && Be(e.detail, e.detail.state);
1507
+ }
1508
+ function No({
1509
+ currentParent: e,
1510
+ targetParent: t,
1511
+ initialParent: n,
1512
+ draggedNodes: o,
1513
+ state: l
1514
+ }) {
1515
+ if (t.el === e.el) return !1;
1516
+ const a = t.data.config;
1517
+ if (o[0].el.contains(t.el) || a.dropZone === !1) return !1;
1518
+ const i = n.data.config;
1519
+ return a.accepts ? a.accepts(
1520
+ t,
1521
+ n,
1522
+ e,
1523
+ l
1524
+ ) : !(!a.group || a.group !== i.group);
1525
+ }
1526
+ function Io(e, t) {
1527
+ G(e.e);
1528
+ }
1529
+ function To(e, t) {
1530
+ G(e.e);
1531
+ }
1532
+ function $o(e, t, n, o) {
1533
+ if (t.affectedNodes.map((x) => x.data.value).includes(e.targetData.node.data.value))
1534
+ return !1;
1535
+ if (t.remapJustFinished)
1536
+ return t.remapJustFinished = !1, (e.targetData.node.data.value === t.currentTargetValue || t.draggedNodes.map((x) => x.el).includes(e.targetData.node.el)) && (t.currentTargetValue = e.targetData.node.data.value), !1;
1537
+ if (t.preventEnter) return !1;
1538
+ if (t.draggedNodes.map((x) => x.el).includes(e.targetData.node.el))
1539
+ return t.currentTargetValue = void 0, !1;
1540
+ if (e.targetData.node.data.value === t.currentTargetValue || e.targetData.parent.el !== t.currentParent?.el || e.targetData.parent.data.config.sortable === !1 || e.targetData.node.el.contains(t.draggedNodes[0].el)) return !1;
1541
+ const l = e.targetData.node.el.getBoundingClientRect(), a = t.draggedNode.el.getBoundingClientRect(), i = l.y - a.y, d = l.x - a.x;
1542
+ let r;
1543
+ Math.abs(i) > Math.abs(d) ? r = i > 0 ? "above" : "below" : r = d > 0 ? "left" : "right";
1544
+ const b = t.currentParent.data.config.threshold;
1545
+ switch (r) {
1546
+ case "left":
1547
+ if (n > l.x + l.width * b.horizontal)
1548
+ return t.incomingDirection = "left", !0;
1549
+ break;
1550
+ case "right":
1551
+ if (n < l.x + l.width * (1 - b.horizontal))
1552
+ return t.incomingDirection = "right", !0;
1553
+ break;
1554
+ case "above":
1555
+ if (o > l.y + l.height * b.vertical)
1556
+ return t.incomingDirection = "above", !0;
1557
+ break;
1558
+ case "below":
1559
+ if (o < l.y + l.height * (1 - b.vertical))
1560
+ return t.incomingDirection = "below", !0;
1561
+ break;
1562
+ }
1563
+ return !1;
1564
+ }
1565
+ function zt(e, t) {
1566
+ const { x: n, y: o } = ke(e.e);
1567
+ if (!$o(e, t, n, o))
1568
+ return;
1569
+ const l = t.draggedNode.data.index > e.targetData.node.data.index ? [e.targetData.node.data.index, t.draggedNode.data.index] : [t.draggedNode.data.index, e.targetData.node.data.index];
1570
+ t.targetIndex = e.targetData.node.data.index, t.affectedNodes = e.targetData.parent.data.enabledNodes.filter(
1571
+ (a) => l[0] <= a.data.index && a.data.index <= l[1] && a.el !== t.draggedNode.el
1572
+ ), e.targetData.parent.data.config.performSort({
1573
+ parent: e.targetData.parent,
1574
+ draggedNodes: t.draggedNodes,
1575
+ targetNodes: [e.targetData.node]
1576
+ });
1577
+ }
1578
+ function ee(e) {
1579
+ function t(n) {
1580
+ const o = ue.get(n);
1581
+ if (!o) return;
1582
+ const l = W.get(n.parentNode);
1583
+ if (l)
1584
+ return {
1585
+ node: {
1586
+ el: n,
1587
+ data: o
1588
+ },
1589
+ parent: {
1590
+ el: n.parentNode,
1591
+ data: l
1592
+ }
1593
+ };
1594
+ }
1595
+ return (n) => {
1596
+ const o = t(n.currentTarget);
1597
+ if (o)
1598
+ return e(
1599
+ {
1600
+ e: n,
1601
+ targetData: o
1602
+ },
1603
+ g
1604
+ );
1605
+ };
1606
+ }
1607
+ function Be(e, t) {
1608
+ G(e.e), No({
1609
+ currentParent: t.currentParent,
1610
+ targetParent: e.targetData.parent,
1611
+ initialParent: t.initialParent,
1612
+ draggedNodes: t.draggedNodes,
1613
+ state: t
1614
+ }) && (e.targetData.parent.data.config.performTransfer({
1615
+ currentParent: t.currentParent,
1616
+ targetParent: e.targetData.parent,
1617
+ initialParent: t.initialParent,
1618
+ draggedNodes: t.draggedNodes,
1619
+ initialIndex: t.initialIndex,
1620
+ state: t,
1621
+ targetNodes: "node" in e.targetData ? [e.targetData.node] : []
1622
+ }), t.currentParent = e.targetData.parent, t.transferred = !0);
1623
+ }
1624
+ function Me(e) {
1625
+ function t(n) {
1626
+ const o = W.get(n);
1627
+ if (o)
1628
+ return {
1629
+ parent: {
1630
+ el: n,
1631
+ data: o
1632
+ }
1633
+ };
1634
+ }
1635
+ return (n) => {
1636
+ const o = t(n.currentTarget);
1637
+ if (o)
1638
+ return e(
1639
+ {
1640
+ e: n,
1641
+ targetData: o
1642
+ },
1643
+ g
1644
+ );
1645
+ };
1646
+ }
1647
+ function Ce(e, t, n = !1) {
1648
+ function o(l, a) {
1649
+ ue.set(l, a);
1650
+ }
1651
+ for (const l of e) {
1652
+ const a = ue.get(l), i = Eo(l, t, a, n);
1653
+ i && o(l, i);
1654
+ }
1655
+ }
1656
+ function Eo(e, t, n, o = !1) {
1657
+ if (!t) return;
1658
+ const l = Vt(t);
1659
+ if (!l.length) return;
1660
+ if (!n) {
1661
+ e.classList.add(...l);
1662
+ return;
1663
+ }
1664
+ const a = [];
1665
+ for (const i of l)
1666
+ e.classList.contains(i) ? (
1667
+ // Only add to privateClasses if the element already had the class
1668
+ // AND omitAppendPrivateClass is specifically false for THIS call.
1669
+ e.classList.contains(i) && o === !1 && a.push(i)
1670
+ ) : e.classList.add(i);
1671
+ return n.privateClasses = a, n;
1672
+ }
1673
+ function pe(e, t) {
1674
+ if (!t) return;
1675
+ const n = Vt(t);
1676
+ if (n.length)
1677
+ for (const o of e) {
1678
+ if (!Ue(o)) {
1679
+ o.classList.remove(...n);
1680
+ continue;
1681
+ }
1682
+ const l = ue.get(o) || W.get(o);
1683
+ if (l)
1684
+ for (const a of n)
1685
+ l.privateClasses.includes(a) || o.classList.remove(a);
1686
+ }
1687
+ }
1688
+ function ht(e, t, n, o, l) {
1689
+ const i = l.axis === "x", d = e === document.scrollingElement, r = i ? "scrollLeft" : "scrollTop", b = i ? "clientWidth" : "clientHeight", x = i ? "offsetWidth" : "offsetHeight", c = i ? "scrollWidth" : "scrollHeight", D = i ? t.clientX : t.clientY, T = i ? o.left : o.top, N = i ? n.overflowX : n.overflowY;
1690
+ if (d) {
1691
+ const I = e[r], A = e[b], z = I > 0, _ = I + A < (i ? l.state.rootScrollWidth || 0 : e[c]);
1692
+ return i ? {
1693
+ left: z && D < A * 0.075,
1694
+ right: _ && D > A * (1 - 0.075)
1695
+ } : {
1696
+ up: z && D < A * 0.075,
1697
+ down: _ && D > A * (1 - 0.075)
1698
+ };
1699
+ }
1700
+ if ((N === "auto" || N === "scroll") && e !== document.body && e !== document.documentElement) {
1701
+ const I = e[c], A = e[x], z = e[r], _ = z > 0, S = z < I - A;
1702
+ return i ? {
1703
+ left: _ && D < T + A * 0.075,
1704
+ right: S && D > T + A * (1 - 0.075)
1705
+ } : {
1706
+ up: _ && D < T + A * 0.075,
1707
+ down: S && D > T + A * (1 - 0.075)
1708
+ };
1709
+ }
1710
+ return i ? { left: !1, right: !1 } : { up: !1, down: !1 };
1711
+ }
1712
+ function Ao(e, t, n, o) {
1713
+ if (!Z(n) || !n.draggedNode)
1714
+ return;
1715
+ n.preventEnter = !0;
1716
+ const l = o.axis === "x", a = o.direction === "positive" ? 1 : -1, i = 20, d = l ? "lastScrollDirectionX" : "lastScrollDirectionY", r = l ? "frameIdX" : "frameIdY";
1717
+ n[r] !== void 0 && (cancelAnimationFrame(n[r]), n[r] = void 0), n[d] = o.direction;
1718
+ const b = () => {
1719
+ if (!Z(n) || !n.draggedNode) {
1720
+ n[r] !== void 0 && (cancelAnimationFrame(n[r]), n[r] = void 0);
1721
+ return;
1722
+ }
1723
+ const x = l ? "scrollLeft" : "scrollTop", c = l ? "clientWidth" : "clientHeight", D = l ? "scrollWidth" : "scrollHeight", T = e[x], N = e[c], I = e[D];
1724
+ if (!(a > 0 ? T + N < I : T > 0)) {
1725
+ n[r] = void 0, n[d] = void 0;
1726
+ return;
1727
+ }
1728
+ e[x] += i * a, te(n) && At(n), n[r] = requestAnimationFrame(b);
1729
+ };
1730
+ n[r] = requestAnimationFrame(b);
1731
+ }
1732
+ function _t(e, t, n) {
1733
+ const o = e.getBoundingClientRect();
1734
+ return t >= o.left && t <= o.right && n >= o.top && n <= o.bottom;
1735
+ }
1736
+ function Re(e, t, n) {
1737
+ if (!Z(n) || !n.draggedNode)
1738
+ return;
1739
+ ot(n);
1740
+ const { x: o, y: l } = e;
1741
+ let a = !1;
1742
+ const i = (r, b, x) => {
1743
+ Ao(x, t, n, { axis: r, direction: b }), a = !0;
1744
+ }, d = (r) => {
1745
+ const b = window.getComputedStyle(r), x = r.getBoundingClientRect(), c = ht(r, t, b, x, {
1746
+ axis: "x",
1747
+ state: n
1748
+ }), D = ht(r, t, b, x, { axis: "y" });
1749
+ (c.left || c.right) && (n.lastScrollContainerX = r, i("x", c.right ? "positive" : "negative", r)), (D.up || D.down) && (n.lastScrollContainerY = r, i("y", D.down ? "positive" : "negative", r));
1750
+ };
1751
+ if (n.lastScrollContainerX && _t(n.lastScrollContainerX, o, l) && d(n.lastScrollContainerX), !a && n.lastScrollContainerY && _t(n.lastScrollContainerY, o, l) && d(n.lastScrollContainerY), !a) {
1752
+ let r = document.elementFromPoint(o, l);
1753
+ for (; r && !(a && n.lastScrollContainerX && n.lastScrollContainerY); )
1754
+ r instanceof HTMLElement && d(r), r = r.parentElement;
1755
+ }
1756
+ if (!a) {
1757
+ const r = document.scrollingElement;
1758
+ r instanceof HTMLElement && d(r);
1759
+ }
1760
+ a || ot(n);
1761
+ }
1762
+ function zo(e) {
1763
+ let t = document.elementFromPoint(e.x, e.y);
1764
+ if (!Ue(t)) return;
1765
+ let n, o = !0;
1766
+ for (; t && o; ) {
1767
+ if (ue.has(t) || W.has(t)) {
1768
+ o = !1, n = W.has(t);
1769
+ break;
1770
+ }
1771
+ t = t.parentNode;
1772
+ }
1773
+ if (n) {
1774
+ const l = W.get(t);
1775
+ return l ? {
1776
+ parent: {
1777
+ el: t,
1778
+ data: l
1779
+ }
1780
+ } : void 0;
1781
+ } else {
1782
+ const l = ue.get(t);
1783
+ if (!l) return;
1784
+ const a = W.get(t.parentNode);
1785
+ return a ? {
1786
+ node: {
1787
+ el: t,
1788
+ data: l
1789
+ },
1790
+ parent: {
1791
+ el: t.parentNode,
1792
+ data: a
1793
+ }
1794
+ } : void 0;
1795
+ }
1796
+ }
1797
+ function Ue(e) {
1798
+ return e instanceof HTMLElement && e.parentNode instanceof HTMLElement;
1799
+ }
1800
+ function Fe(e, t) {
1801
+ const n = new AbortController();
1802
+ for (const o in t) {
1803
+ const l = t[o];
1804
+ e.addEventListener(o, l, {
1805
+ signal: n.signal,
1806
+ passive: !1,
1807
+ capture: o === "focus" || o === "blur"
1808
+ });
1809
+ }
1810
+ return n;
1811
+ }
1812
+ function xt(e) {
1813
+ if (e instanceof HTMLElement) return e;
1814
+ if (e.value instanceof HTMLElement) return e.value;
1815
+ if ("$el" in e && e.$el instanceof HTMLElement)
1816
+ return e.$el;
1817
+ }
1818
+ function Oo(e, t) {
1819
+ Array.isArray(e) || (e = [e]);
1820
+ for (const n of e) {
1821
+ const o = xt(n);
1822
+ if (o) return t(o);
1823
+ const l = re(n, (a) => {
1824
+ if (!a) return;
1825
+ const i = xt(a);
1826
+ i ? t(i) : console.warn("Invalid parent element", a), l();
1827
+ });
1828
+ }
1829
+ }
1830
+ var at = /* @__PURE__ */ new WeakMap();
1831
+ function Mo(e) {
1832
+ const t = at.get(e);
1833
+ return t ? "value" in t ? t.value : t : (console.warn("No values found for parent element"), []);
1834
+ }
1835
+ function Fo(e, t) {
1836
+ const n = at.get(t);
1837
+ n && "value" in n && (n.value = e);
1838
+ }
1839
+ function Ot(e) {
1840
+ rt && (Array.isArray(e) || (e = [e]), e.forEach((t) => {
1841
+ const { parent: n, values: o, ...l } = t;
1842
+ Oo(n, Lo(l, o));
1843
+ }));
1844
+ }
1845
+ function Lo(e, t) {
1846
+ return (n) => {
1847
+ at.set(n, t), Jn({
1848
+ parent: n,
1849
+ getValues: Mo,
1850
+ setValues: Fo,
1851
+ config: {
1852
+ ...e
1853
+ }
1854
+ });
1855
+ };
1856
+ }
1857
+ const Bo = {
1858
+ key: 0,
1859
+ class: "flex gap-4 p-6 border-b last:border-b-0"
1860
+ }, Ro = { class: "option-drag-handle flex-none mt-9.5 cursor-grab" }, Uo = { class: "flex-1" }, jo = { class: "mb-3" }, Ho = { class: "flex items-center" }, Xo = {
1861
+ key: 0,
1862
+ class: "mt-1 text-sm text-red-600"
1863
+ }, Yo = { class: "flex items-center gap-1" }, Ko = { class: "mb-2" }, Jo = {
1864
+ key: 0,
1865
+ class: "option-value-drag-handle absolute -left-7 top-1/2 -translate-y-1/2 flex-none mr-2 cursor-grab"
1866
+ }, qo = ["onClick"], Wo = { class: "flex justify-between" }, Go = { class: "flex-1" }, Zo = { class: "text-sm mb-2" }, Qo = { class: "flex flex-wrap gap-2" }, el = {
1867
+ key: 0,
1868
+ class: "px-2 py-1 border rounded-full bg-muted text-muted-foreground text-sm"
1869
+ }, tl = /* @__PURE__ */ ne({
1870
+ __name: "Option",
1871
+ props: {
1872
+ option: {
1873
+ type: Object,
1874
+ required: !0
1875
+ }
1876
+ },
1877
+ emits: ["update:option", "remove"],
1878
+ setup(e, { expose: t, emit: n }) {
1879
+ const o = e, { confirm: l } = Dt(), a = n, i = de({
1880
+ get() {
1881
+ return o.option;
1882
+ },
1883
+ set(_) {
1884
+ a("update:option", _);
1885
+ }
1886
+ }), d = de({
1887
+ get() {
1888
+ return i.value.values;
1889
+ },
1890
+ set(_) {
1891
+ i.value.values = _;
1892
+ }
1893
+ }), r = Ee("valueListRef"), b = X(!1);
1894
+ re(b, async (_) => {
1895
+ console.log("minified", _), _ || (await Te(), Ot({
1896
+ parent: r?.value,
1897
+ values: d,
1898
+ group: "valueList",
1899
+ dragHandle: ".option-value-drag-handle",
1900
+ plugins: [yt()]
1901
+ }));
1902
+ }, { immediate: !0 });
1903
+ const x = () => Math.random().toString(36).substring(2, 15), c = () => {
1904
+ i.value.values.push({ id: x(), value: "" });
1905
+ }, D = async () => {
1906
+ (i.value.name.trim() || i.value.values.filter((_) => _.value.trim() !== "").length > 0) && !await l("Are you sure you want to remove this option?") || a("remove");
1907
+ }, T = (_) => {
1908
+ i.value.values.splice(_, 1);
1909
+ }, N = (_) => {
1910
+ _.name.trim() ? _.nameError = void 0 : _.nameError = "Option name is required.";
1911
+ }, I = (_, S) => {
1912
+ const B = _.target, K = i.value.values;
1913
+ if (_.key === "Backspace" && B.value === "" && K?.length > 2) {
1914
+ T(S);
1915
+ return;
1916
+ }
1917
+ }, A = (_, S) => {
1918
+ _.target;
1919
+ const B = i.value.values, K = B?.[S];
1920
+ K.touched = !0, B?.every((Q) => Q.value.trim() !== "") && c();
1921
+ }, z = (_) => {
1922
+ const S = i.value, B = S?.values.every((K, j) => K.value.trim() !== "" || j === _);
1923
+ S && S.values[_].value.trim() === "" && !B && T(_);
1924
+ };
1925
+ return t({
1926
+ minified: b
1927
+ }), (_, S) => {
1928
+ const B = v("Input"), K = v("Button");
1929
+ return b.value ? (h(), w("div", {
1930
+ key: 1,
1931
+ class: "flex gap-4 p-6 border-b last:border-b-0 hover:bg-accent dark:hover:bg-accent/50 cursor-pointer transition-colors duration-200",
1932
+ onClick: S[5] || (S[5] = (j) => b.value = !1)
1933
+ }, [
1934
+ u("div", null, [
1935
+ u("div", {
1936
+ class: "option-drag-handle flex-none mt-5 cursor-grab",
1937
+ onClick: S[4] || (S[4] = fe(() => {
1938
+ }, ["stop"]))
1939
+ }, [
1940
+ s(m(Qe), { class: "size-4 text-gray-400" })
1941
+ ])
1942
+ ]),
1943
+ u("div", Go, [
1944
+ u("p", Zo, F(i.value.name), 1),
1945
+ u("div", Qo, [
1946
+ (h(!0), w(q, null, ie(d.value, (j) => (h(), w(q, {
1947
+ key: j.id
1948
+ }, [
1949
+ j.value ? (h(), w("span", el, F(j.value), 1)) : M("", !0)
1950
+ ], 64))), 128))
1951
+ ])
1952
+ ])
1953
+ ])) : (h(), w("div", Bo, [
1954
+ u("div", null, [
1955
+ u("div", Ro, [
1956
+ s(m(Qe), { class: "size-4 text-gray-400" })
1957
+ ])
1958
+ ]),
1959
+ u("div", Uo, [
1960
+ u("div", jo, [
1961
+ S[6] || (S[6] = u("label", { class: "block text-sm mb-2" }, "Option name", -1)),
1962
+ u("div", Ho, [
1963
+ s(B, {
1964
+ modelValue: i.value.name,
1965
+ "onUpdate:modelValue": S[0] || (S[0] = (j) => i.value.name = j),
1966
+ onBlur: S[1] || (S[1] = (j) => N(i.value)),
1967
+ "aria-invalid": i.value.nameError ? "true" : "false",
1968
+ placeholder: "Color",
1969
+ spellcheck: "false"
1970
+ }, null, 8, ["modelValue", "aria-invalid"])
1971
+ ]),
1972
+ i.value.nameError ? (h(), w("p", Xo, [
1973
+ u("span", Yo, [
1974
+ s(m(Gt), { class: "size-4" }),
1975
+ V(" " + F(i.value.nameError), 1)
1976
+ ])
1977
+ ])) : M("", !0)
1978
+ ]),
1979
+ u("div", Ko, [
1980
+ S[7] || (S[7] = u("label", { class: "block text-sm mb-2" }, "Option values", -1)),
1981
+ u("div", {
1982
+ ref_key: "valueListRef",
1983
+ ref: r
1984
+ }, [
1985
+ d.value ? (h(!0), w(q, { key: 0 }, ie(d.value, (j, Q) => (h(), w("div", {
1986
+ key: j.id,
1987
+ class: "relative flex items-center mb-2"
1988
+ }, [
1989
+ j.touched ? (h(), w("div", Jo, [
1990
+ s(m(Qe), { class: "size-4 text-gray-400" })
1991
+ ])) : M("", !0),
1992
+ s(B, {
1993
+ modelValue: j.value,
1994
+ "onUpdate:modelValue": (oe) => j.value = oe,
1995
+ placeholder: "Option value",
1996
+ class: "pr-12",
1997
+ onKeydown: (oe) => I(oe, Q),
1998
+ onKeyup: (oe) => A(oe, Q),
1999
+ onBlur: (oe) => z(Q),
2000
+ spellcheck: "false"
2001
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "onKeydown", "onKeyup", "onBlur"]),
2002
+ d.value.length > 2 && j.touched ? (h(), w("button", {
2003
+ key: 1,
2004
+ onClick: (oe) => T(Q),
2005
+ class: "absolute right-2 top-1/2 -translate-y-1/2 ml-2 p-2 text-muted-foreground/50 hover:text-muted-foreground",
2006
+ type: "button"
2007
+ }, [
2008
+ s(m(Zt), { class: "size-4" })
2009
+ ], 8, qo)) : M("", !0)
2010
+ ]))), 128)) : M("", !0)
2011
+ ], 512)
2012
+ ]),
2013
+ u("div", Wo, [
2014
+ s(K, {
2015
+ size: "sm",
2016
+ variant: "outline",
2017
+ onClick: S[2] || (S[2] = (j) => D()),
2018
+ class: "text-red-500 hover:text-red-600"
2019
+ }, {
2020
+ default: f(() => [...S[8] || (S[8] = [
2021
+ V("Delete", -1)
2022
+ ])]),
2023
+ _: 1
2024
+ }),
2025
+ s(K, {
2026
+ size: "sm",
2027
+ onClick: S[3] || (S[3] = (j) => b.value = !0),
2028
+ disabled: i.value.name.trim() === ""
2029
+ }, {
2030
+ default: f(() => [...S[9] || (S[9] = [
2031
+ V("Done", -1)
2032
+ ])]),
2033
+ _: 1
2034
+ }, 8, ["disabled"])
2035
+ ])
2036
+ ])
2037
+ ]));
2038
+ };
2039
+ }
2040
+ }), nl = /* @__PURE__ */ ne({
2041
+ __name: "Options",
2042
+ props: {
2043
+ modelValue: {
2044
+ type: Array,
2045
+ default: () => []
2046
+ }
2047
+ },
2048
+ emits: ["update:modelValue"],
2049
+ setup(e, { expose: t, emit: n }) {
2050
+ const o = e, l = n, a = X([]), i = Ee("optionsListRefElement"), d = Ee("optionRefs"), r = de({
2051
+ get() {
2052
+ return o.modelValue;
2053
+ },
2054
+ set(z) {
2055
+ l("update:modelValue", z);
2056
+ }
2057
+ }), b = X(!1);
2058
+ re(r, (z) => {
2059
+ console.log("mutableOptions2", z ? JSON.parse(JSON.stringify(z)) : []), !b.value && (!a.value || a.value.length === 0 && z.length > 0) && (b.value = !0, a.value = z ? JSON.parse(JSON.stringify(z)) : []);
2060
+ }, { deep: !0 }), re(a, (z) => {
2061
+ r.value = z?.map((_) => ({
2062
+ ..._,
2063
+ values: _.values.filter((S) => S.value.trim() !== "")
2064
+ })), !I.value && z.length > 0 && A();
2065
+ }, { deep: !0 });
2066
+ const x = () => Math.random().toString(36).substring(2, 15), c = () => {
2067
+ const _ = {
2068
+ id: x(),
2069
+ name: "",
2070
+ values: [{ id: x(), value: "" }],
2071
+ nameError: void 0
2072
+ };
2073
+ a.value.push(_);
2074
+ }, D = () => {
2075
+ d.value?.forEach((z) => {
2076
+ z && (z.minified = !0);
2077
+ });
2078
+ }, T = (z) => {
2079
+ const _ = a.value.findIndex((S) => S.id === z.id);
2080
+ _ !== -1 && (a.value[_] = z);
2081
+ }, N = (z) => {
2082
+ const _ = a.value.findIndex((S) => S.id === z.id);
2083
+ _ !== -1 && a.value.splice(_, 1);
2084
+ }, I = X(!1), A = () => {
2085
+ try {
2086
+ I.value = !0, Ot({
2087
+ parent: i?.value,
2088
+ values: a,
2089
+ group: "optionsList",
2090
+ dragHandle: ".option-drag-handle",
2091
+ plugins: [yt()]
2092
+ });
2093
+ } catch (z) {
2094
+ console.error(z);
2095
+ }
2096
+ };
2097
+ return lt(() => {
2098
+ a.value = o.modelValue ? JSON.parse(JSON.stringify(o.modelValue)) : [], console.log("mutableOptions", o.modelValue ? JSON.parse(JSON.stringify(o.modelValue)) : []), a.value.length > 0 && A();
2099
+ }), t({
2100
+ minifyAll: D
2101
+ }), (z, _) => {
2102
+ const S = v("Button");
2103
+ return h(), w("div", null, [
2104
+ u("div", {
2105
+ class: $e(["rounded-lg", a.value.length > 0 ? "border mb-6" : ""])
2106
+ }, [
2107
+ u("div", {
2108
+ ref_key: "optionsListRefElement",
2109
+ ref: i
2110
+ }, [
2111
+ (h(!0), w(q, null, ie(a.value, (B) => (h(), L(tl, {
2112
+ ref_for: !0,
2113
+ ref_key: "optionRefs",
2114
+ ref: d,
2115
+ key: B.id,
2116
+ option: B,
2117
+ "onUpdate:option": _[0] || (_[0] = (K) => T(K)),
2118
+ onRemove: (K) => N(B)
2119
+ }, null, 8, ["option", "onRemove"]))), 128))
2120
+ ], 512),
2121
+ a.value && a.value.length < 3 ? (h(), w("div", {
2122
+ key: 0,
2123
+ class: $e(a.value.length > 0 ? "border-t" : "")
2124
+ }, [
2125
+ a.value.length === 0 ? (h(), L(S, {
2126
+ key: 0,
2127
+ onClick: c,
2128
+ variant: "outline"
2129
+ }, {
2130
+ default: f(() => [
2131
+ s(m(ct), { class: "size-4" }),
2132
+ _[1] || (_[1] = V(" Add options like size or color ", -1))
2133
+ ]),
2134
+ _: 1
2135
+ })) : (h(), L(S, {
2136
+ key: 1,
2137
+ onClick: c,
2138
+ variant: "ghost",
2139
+ class: "w-full justify-start pl-2 rounded-t-none"
2140
+ }, {
2141
+ default: f(() => [
2142
+ s(m(ct), { class: "size-4" }),
2143
+ _[2] || (_[2] = V(" Add another option ", -1))
2144
+ ]),
2145
+ _: 1
2146
+ }))
2147
+ ], 2)) : M("", !0)
2148
+ ], 2)
2149
+ ]);
2150
+ };
2151
+ }
2152
+ }), ol = { key: 0 }, ll = { class: "flex items-center justify-between gap-2 mb-2" }, rl = {
2153
+ key: 0,
2154
+ class: "flex items-center gap-2"
2155
+ }, al = {
2156
+ key: 0,
2157
+ class: "mb-4"
2158
+ }, sl = { class: "flex flex-wrap gap-2" }, il = ["onClick"], dl = { class: "-mx-6 w-[calc(100%+3rem)]" }, ul = { class: "text-muted-foreground text-xs" }, cl = { class: "z-[101] sticky -top-4 py-2 font-normal bg-accent dark:bg-border" }, fl = { class: "z-[101] sticky -top-4 py-2 font-normal whitespace-nowrap bg-accent dark:bg-border" }, pl = { class: "flex items-center gap-2" }, gl = { class: "z-[101] sticky -top-4 py-2 pr-6 font-normal bg-accent dark:bg-border" }, ml = { class: "text-sm" }, vl = ["onClick"], bl = { class: "w-10 p-2" }, hl = { class: "p-2" }, _l = { class: "flex items-stretch gap-2" }, xl = ["src"], yl = {
2159
+ key: 2,
2160
+ class: "relative"
2161
+ }, Dl = ["src"], Sl = ["src"], Cl = { class: "flex flex-col justify-center px-2" }, wl = { class: "text-md mb-0.5 hover:underline select-none" }, kl = { class: "flex items-center gap-1 text-xs text-muted-foreground hover:opacity-70 transition-opacity duration-200 cursor-pointer select-none" }, Pl = { class: "p-2 w-[30%]" }, Vl = { class: "relative" }, Nl = { key: 0 }, Il = { key: 1 }, Tl = {
2162
+ key: 0,
2163
+ class: "absolute inset-0 top-1/2 -translate-y-1/2 px-2 truncate text-sm text-muted-foreground w-full text-center pointer-events-none"
2164
+ }, $l = { class: "p-2 w-[18%]" }, El = { class: "w-10" }, Al = { class: "w-10 p-2 translate-x-10" }, zl = { class: "p-2 pl-12" }, Ol = { class: "flex items-stretch gap-2" }, Ml = ["src"], Fl = { class: "flex flex-col justify-center px-2" }, Ll = { class: "p-2 w-[30%]" }, Bl = { class: "p-2 w-[18%] group" }, Rl = { class: "text-center text-sm text-muted-foreground bg-accent dark:bg-border p-3 -mx-6 -mb-6 rounded-b-lg" }, Ul = { key: 0 }, jl = /* @__PURE__ */ ne({
2165
+ __name: "VariantList",
2166
+ props: {
2167
+ options: {
2168
+ type: Object,
2169
+ required: !0
2170
+ },
2171
+ modelValue: {
2172
+ type: Array,
2173
+ required: !0
2174
+ },
2175
+ hide: {
2176
+ type: Boolean,
2177
+ default: !1
2178
+ }
2179
+ },
2180
+ emits: ["update:modelValue"],
2181
+ setup(e, { expose: t, emit: n }) {
2182
+ const o = e, l = n, a = de({
2183
+ get() {
2184
+ return o.modelValue;
2185
+ },
2186
+ set(k) {
2187
+ l("update:modelValue", k);
2188
+ }
2189
+ }), i = tt("sources"), d = X(""), r = X(""), b = X(!1), x = X([]), c = X({}), D = () => {
2190
+ Object.keys(o.options).length > 0 && (r.value = Object.keys(o.options)[0]);
2191
+ };
2192
+ re(() => o.options, () => {
2193
+ r.value === "" && D();
2194
+ }, { immediate: !0, deep: !0 }), re(c, (k) => {
2195
+ T();
2196
+ }, { deep: !0 }), re(() => o.hide, (k) => {
2197
+ k || (D(), T());
2198
+ });
2199
+ function T() {
2200
+ if (!c.value) {
2201
+ a.value = [];
2202
+ return;
2203
+ }
2204
+ let k = [];
2205
+ Object.keys(c.value)?.forEach((p) => {
2206
+ k.push({
2207
+ combinedOptions: p,
2208
+ name: A(p),
2209
+ disabled: !1,
2210
+ price: c.value[p].price,
2211
+ stock: c.value[p].stock,
2212
+ image: c.value[p].image,
2213
+ options: z(p)
2214
+ });
2215
+ }), a.value = k.filter((p) => p.options?.length === Object.keys(o.options).length && p.options?.every((y) => Object.entries(o.options).find(([$, R]) => R.id === y.optionId)));
2216
+ }
2217
+ function N(k) {
2218
+ return k.reduce(
2219
+ (p, y) => p.flatMap(($) => y.map((R) => [...$, R])),
2220
+ [[]]
2221
+ );
2222
+ }
2223
+ function I(k) {
2224
+ return k.slice().sort((p, y) => p.optionId.localeCompare(y.optionId)).map(({ optionId: p, valueId: y }) => `${p}:${y}`).join("|");
2225
+ }
2226
+ const A = (k) => k.split("|").map((y) => {
2227
+ const [$, R] = y.split(":");
2228
+ return { optionId: $, valueId: R };
2229
+ }).map((y) => o.options?.[y.optionId]?.values?.find((ae) => ae.id === y.valueId)?.value || "").join(" "), z = (k) => k.split("|").map((y) => {
2230
+ const [$, R] = y.split(":");
2231
+ return { optionId: $, valueId: R };
2232
+ }).map((y) => {
2233
+ const $ = o.options?.[y.optionId], R = $?.values?.find((ae) => ae.id === y.valueId);
2234
+ return {
2235
+ optionId: $?.id,
2236
+ option: $?.name,
2237
+ valueId: R?.id,
2238
+ value: R?.value
2239
+ };
2240
+ }), _ = de(() => {
2241
+ const k = Object.values(o.options).map(
2242
+ (y) => y.values.map(($) => ({
2243
+ optionId: y.id,
2244
+ optionName: y.name,
2245
+ valueId: $.id,
2246
+ value: $.value
2247
+ }))
2248
+ );
2249
+ return N(k).map((y) => {
2250
+ const $ = I(y);
2251
+ return c.value[$] || (c.value[$] = { price: 0, stock: 0 }), {
2252
+ key: $,
2253
+ options: y,
2254
+ ...c.value[$]
2255
+ };
2256
+ });
2257
+ }), S = de(() => {
2258
+ let k = [..._.value];
2259
+ return d.value && (k = k.filter((p) => p.options?.find((y) => y.value.toLowerCase().includes(d.value.toLowerCase())))), k;
2260
+ }), B = (k, p) => {
2261
+ const y = S.value.filter(($) => $.options?.find((R) => R.optionId === r.value)?.valueId === p);
2262
+ y && y.forEach(($) => {
2263
+ c.value[I($.options)].image = k;
2264
+ });
2265
+ }, K = (k) => _.value.filter((y) => y.options?.find(($) => $.optionId === r.value)?.valueId === k).every((y) => !y.image), j = (k) => {
2266
+ const p = _.value.filter(($) => $.options?.find((R) => R.optionId === r.value)?.valueId === k);
2267
+ return p.filter(($, R) => $.image && p.findIndex((ae) => ae.image === $.image) === R).length === 1;
2268
+ }, Q = (k) => _.value.filter((y) => y.options?.find(($) => $.optionId === r.value)?.valueId === k).filter((y) => y.image)[0]?.image, oe = (k) => _.value.filter((y) => y.options?.find(($) => $.optionId === r.value)?.valueId === k).filter((y) => y.image)[1]?.image, je = (k) => {
2269
+ const p = _.value.filter(($) => $.options?.find((R) => R.valueId === k));
2270
+ if (p.length === 0) return "0";
2271
+ const y = p.map(($) => $.price);
2272
+ return Math.min(...y) === Math.max(...y) ? y[0]?.toString() || "0" : `${Math.min(...y)} - ${Math.max(...y)}`;
2273
+ }, Pe = (k) => _.value.filter((p) => p.options?.find((y) => y.valueId === k)).reduce((p, y) => y.stock > 0 ? p + y.stock : p, 0), He = (k) => _.value.filter((p) => p.options?.find((y) => y.valueId === k)).reduce((p, y) => y.stock < 0 ? p + y.stock : p, 0), Xe = () => {
2274
+ let k = 0;
2275
+ return o.options?.[r.value]?.values?.forEach((p) => {
2276
+ k += Pe(p.id);
2277
+ }), k;
2278
+ }, ze = () => {
2279
+ let k = 0;
2280
+ return o.options?.[r.value]?.values?.forEach((p) => {
2281
+ k += He(p.id);
2282
+ }), k;
2283
+ }, ye = X(null), ce = X(""), Ve = async (k, p) => {
2284
+ k.preventDefault();
2285
+ const y = S?.value?.filter((R) => R.options?.find((ae) => ae.optionId === r.value)?.valueId === p.id).map((R) => R.price), $ = y.length === 0 ? !0 : y.every((R) => R === y[0]);
2286
+ ye.value = p.id, ce.value = $ ? y[0].toString() : "", await Te(), document.getElementById(`variant-price-${p.id}`)?.focus(), document.getElementById(`variant-price-${p.id}`)?.select();
2287
+ }, C = (k) => {
2288
+ E(k), ye.value = null, ce.value = "";
2289
+ }, E = (k) => {
2290
+ if (ce.value.trim() && Number(ce.value.trim().replace(",", ".")) > 0) {
2291
+ const p = Number(ce.value.trim().replace(",", "."));
2292
+ S?.value?.filter((y) => y.options?.find(($) => $.optionId === r.value)?.valueId === k).forEach((y) => {
2293
+ c.value[I(y.options)].price = p;
2294
+ });
2295
+ }
2296
+ }, le = (k) => {
2297
+ c.value = k.reduce((p, y) => (p[y.combinedOptions] = {
2298
+ price: y.price,
2299
+ stock: y.stock,
2300
+ image: y.image
2301
+ }, p), {});
2302
+ };
2303
+ return lt(() => {
2304
+ D();
2305
+ }), t({
2306
+ setVariantMap: le,
2307
+ refreshVariants: T
2308
+ }), (k, p) => {
2309
+ const y = v("SelectValue"), $ = v("SelectTrigger"), R = v("SelectItem"), ae = v("SelectContent"), Mt = v("Select"), De = v("Button"), st = v("Input"), Ft = v("PopoverTrigger"), Lt = v("RadioGroupItem"), Bt = v("Label"), Rt = v("RadioGroup"), Ut = v("PopoverContent"), jt = v("Popover"), Ye = v("Checkbox"), Ke = v("TooltipTrigger"), Je = v("TooltipContent"), qe = v("Tooltip"), it = v("MediaPickerDialog"), We = v("NumberFieldInput"), Ge = v("NumberFieldContent"), Ze = v("NumberField"), Ht = v("NumberFieldDecrement"), Xt = v("NumberFieldIncrement");
2310
+ return e.hide ? M("", !0) : (h(), w("div", ol, [
2311
+ u("div", ll, [
2312
+ Object.keys(e.options).length > 1 ? (h(), w("div", rl, [
2313
+ p[13] || (p[13] = u("p", null, "Group by", -1)),
2314
+ s(Mt, {
2315
+ modelValue: r.value,
2316
+ "onUpdate:modelValue": p[0] || (p[0] = (P) => r.value = P)
2317
+ }, {
2318
+ default: f(() => [
2319
+ s($, { size: "sm" }, {
2320
+ default: f(() => [
2321
+ s(y, { placeholder: "Option" })
2322
+ ]),
2323
+ _: 1
2324
+ }),
2325
+ s(ae, null, {
2326
+ default: f(() => [
2327
+ (h(!0), w(q, null, ie(e.options, (P) => (h(), L(R, {
2328
+ key: P.id,
2329
+ value: P.id
2330
+ }, {
2331
+ default: f(() => [
2332
+ V(F(P.name), 1)
2333
+ ]),
2334
+ _: 2
2335
+ }, 1032, ["value"]))), 128))
2336
+ ]),
2337
+ _: 1
2338
+ })
2339
+ ]),
2340
+ _: 1
2341
+ }, 8, ["modelValue"])
2342
+ ])) : M("", !0),
2343
+ b.value ? (h(), L(De, {
2344
+ key: 2,
2345
+ variant: "outline",
2346
+ onClick: p[2] || (p[2] = (P) => b.value = !1),
2347
+ size: "sm",
2348
+ class: "ml-auto"
2349
+ }, {
2350
+ default: f(() => [...p[14] || (p[14] = [
2351
+ V(" Cancel ", -1)
2352
+ ])]),
2353
+ _: 1
2354
+ })) : (h(), L(De, {
2355
+ key: 1,
2356
+ variant: "outline",
2357
+ onClick: p[1] || (p[1] = (P) => b.value = !0),
2358
+ size: "sm",
2359
+ class: "ml-auto"
2360
+ }, {
2361
+ default: f(() => [
2362
+ s(m(ft), { class: "size-4" }),
2363
+ s(m(Qt), { class: "size-4" })
2364
+ ]),
2365
+ _: 1
2366
+ }))
2367
+ ]),
2368
+ b.value ? (h(), w("div", al, [
2369
+ u("div", {
2370
+ class: $e(["relative", { "mb-4": Object.keys(e.options).length > 0 }])
2371
+ }, [
2372
+ s(st, {
2373
+ placeholder: "Search",
2374
+ class: "pl-10",
2375
+ modelValue: d.value,
2376
+ "onUpdate:modelValue": p[3] || (p[3] = (P) => d.value = P)
2377
+ }, null, 8, ["modelValue"]),
2378
+ s(m(ft), { class: "size-4 absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none" })
2379
+ ], 2),
2380
+ u("div", sl, [
2381
+ (h(!0), w(q, null, ie(e.options, (P) => (h(), L(jt, {
2382
+ key: P.id
2383
+ }, {
2384
+ default: f(() => [
2385
+ s(Ft, { asChild: "" }, {
2386
+ default: f(() => [
2387
+ s(De, {
2388
+ variant: "outline",
2389
+ size: "sm",
2390
+ class: "border-dashed"
2391
+ }, {
2392
+ default: f(() => [
2393
+ P.groupBy ? (h(), w(q, { key: 1 }, [
2394
+ V(F(P.name) + " is " + F(P.values.find((O) => O.id === P.groupBy)?.value) + " ", 1),
2395
+ u("div", {
2396
+ class: "p-2",
2397
+ onClick: fe((O) => P.groupBy = "", ["stop"])
2398
+ }, [
2399
+ s(m(en), { class: "size-3" })
2400
+ ], 8, il)
2401
+ ], 64)) : (h(), w(q, { key: 0 }, [
2402
+ V(F(P.name) + " ", 1),
2403
+ s(m(pt), { class: "size-3" })
2404
+ ], 64))
2405
+ ]),
2406
+ _: 2
2407
+ }, 1024)
2408
+ ]),
2409
+ _: 2
2410
+ }, 1024),
2411
+ s(Ut, null, {
2412
+ default: f(() => [
2413
+ s(Rt, {
2414
+ modelValue: P.groupBy,
2415
+ "onUpdate:modelValue": (O) => P.groupBy = O,
2416
+ class: "mb-4"
2417
+ }, {
2418
+ default: f(() => [
2419
+ (h(!0), w(q, null, ie(P.values, (O) => (h(), w("div", {
2420
+ class: "flex items-center space-x-2",
2421
+ key: O.id
2422
+ }, [
2423
+ s(Lt, {
2424
+ id: O.id,
2425
+ value: O.id,
2426
+ class: "border-ring"
2427
+ }, null, 8, ["id", "value"]),
2428
+ s(Bt, {
2429
+ for: O.id
2430
+ }, {
2431
+ default: f(() => [
2432
+ V(F(O.value), 1)
2433
+ ]),
2434
+ _: 2
2435
+ }, 1032, ["for"])
2436
+ ]))), 128))
2437
+ ]),
2438
+ _: 2
2439
+ }, 1032, ["modelValue", "onUpdate:modelValue"]),
2440
+ s(De, {
2441
+ variant: "ghost",
2442
+ onClick: (O) => P.groupBy = "",
2443
+ size: "sm",
2444
+ class: "ml-auto",
2445
+ disabled: !P.groupBy
2446
+ }, {
2447
+ default: f(() => [...p[15] || (p[15] = [
2448
+ V(" Clear ", -1)
2449
+ ])]),
2450
+ _: 1
2451
+ }, 8, ["onClick", "disabled"])
2452
+ ]),
2453
+ _: 2
2454
+ }, 1024)
2455
+ ]),
2456
+ _: 2
2457
+ }, 1024))), 128))
2458
+ ])
2459
+ ])) : M("", !0),
2460
+ r.value ? (h(), w(q, { key: 1 }, [
2461
+ u("table", dl, [
2462
+ u("thead", ul, [
2463
+ u("tr", null, [
2464
+ u("th", cl, [
2465
+ s(Ye, { class: "border-muted-foreground translate-y-0.5" })
2466
+ ]),
2467
+ u("th", fl, [
2468
+ u("div", pl, [
2469
+ p[16] || (p[16] = u("span", null, "Variant", -1)),
2470
+ p[17] || (p[17] = u("span", null, "·", -1)),
2471
+ x.value.length > 0 ? (h(), w("button", {
2472
+ key: 0,
2473
+ class: "hover:underline cursor-pointer",
2474
+ onClick: p[4] || (p[4] = (P) => x.value = [])
2475
+ }, "Collapse all")) : (h(), w("button", {
2476
+ key: 1,
2477
+ class: "hover:underline cursor-pointer",
2478
+ onClick: p[5] || (p[5] = (P) => x.value = e.options[r.value].values.map((O) => O.id))
2479
+ }, "Expand all"))
2480
+ ])
2481
+ ]),
2482
+ p[20] || (p[20] = u("th", { class: "z-[101] sticky -top-4 py-2 font-normal bg-accent dark:bg-border" }, "Price", -1)),
2483
+ u("th", gl, [
2484
+ s(qe, null, {
2485
+ default: f(() => [
2486
+ s(Ke, { class: "underline decoration-dashed underline-offset-4" }, {
2487
+ default: f(() => [...p[18] || (p[18] = [
2488
+ V("Available", -1)
2489
+ ])]),
2490
+ _: 1
2491
+ }),
2492
+ s(Je, null, {
2493
+ default: f(() => [...p[19] || (p[19] = [
2494
+ u("p", null, "Inventory at your store that can be sold.", -1)
2495
+ ])]),
2496
+ _: 1
2497
+ })
2498
+ ]),
2499
+ _: 1
2500
+ })
2501
+ ])
2502
+ ])
2503
+ ]),
2504
+ u("tbody", ml, [
2505
+ (h(!0), w(q, null, ie(e.options[r.value].values, (P) => (h(), w(q, {
2506
+ key: P.id
2507
+ }, [
2508
+ u("tr", {
2509
+ class: "hover:bg-accent/50 cursor-pointer transition-colors duration-200 border-b border-input",
2510
+ onClick: (O) => x.value.includes(P.id) ? x.value.splice(x.value.indexOf(P.id), 1) : x.value.push(P.id)
2511
+ }, [
2512
+ u("td", bl, [
2513
+ s(Ye, {
2514
+ class: "border-muted-foreground translate-y-0.5",
2515
+ onClick: p[6] || (p[6] = fe(() => {
2516
+ }, ["stop"]))
2517
+ })
2518
+ ]),
2519
+ u("td", hl, [
2520
+ u("div", _l, [
2521
+ u("div", null, [
2522
+ s(it, {
2523
+ sources: m(i),
2524
+ maxFiles: 1,
2525
+ "initial-value": K(P.id) ? [] : j(P.id) ? [Q(P.id)] : [Q(P.id), oe(P.id)],
2526
+ onSubmit: (O) => B(O, P.id)
2527
+ }, {
2528
+ default: f(() => [
2529
+ u("button", {
2530
+ onClick: p[7] || (p[7] = fe(() => {
2531
+ }, ["stop"])),
2532
+ tabindex: "-1",
2533
+ class: "cursor-pointer"
2534
+ }, [
2535
+ K(P.id) ? (h(), L(De, {
2536
+ key: 0,
2537
+ variant: "outline",
2538
+ class: "size-15 border-dashed cursor-pointer"
2539
+ }, {
2540
+ default: f(() => [
2541
+ s(m(gt))
2542
+ ]),
2543
+ _: 1
2544
+ })) : j(P.id) ? (h(), w("img", {
2545
+ key: 1,
2546
+ src: Q(P.id),
2547
+ class: "size-15 rounded-md object-cover",
2548
+ draggable: "false"
2549
+ }, null, 8, xl)) : (h(), w("div", yl, [
2550
+ u("img", {
2551
+ src: oe(P.id),
2552
+ class: "absolute rotate-[12deg] size-15 rounded-md object-cover",
2553
+ draggable: "false"
2554
+ }, null, 8, Dl),
2555
+ u("img", {
2556
+ src: Q(P.id),
2557
+ class: "relative size-15 rounded-md shadow object-cover",
2558
+ draggable: "false"
2559
+ }, null, 8, Sl)
2560
+ ]))
2561
+ ])
2562
+ ]),
2563
+ _: 2
2564
+ }, 1032, ["sources", "initial-value", "onSubmit"])
2565
+ ]),
2566
+ u("div", Cl, [
2567
+ u("p", wl, F(P.value), 1),
2568
+ u("button", kl, [
2569
+ V(F(S.value?.filter((O) => O.options?.find((J) => J.optionId === r.value)?.valueId === P.id).length) + " variants ", 1),
2570
+ s(m(pt), {
2571
+ class: $e(["size-3 transition-transform duration-200", x.value.includes(P.id) ? "rotate-180" : ""])
2572
+ }, null, 8, ["class"])
2573
+ ])
2574
+ ])
2575
+ ])
2576
+ ]),
2577
+ u("td", Pl, [
2578
+ u("div", Vl, [
2579
+ s(qe, null, {
2580
+ default: f(() => [
2581
+ s(Ke, {
2582
+ class: "w-full",
2583
+ asChild: ""
2584
+ }, {
2585
+ default: f(() => [
2586
+ s(st, {
2587
+ id: `variant-price-${P.id}`,
2588
+ modelValue: ce.value,
2589
+ "onUpdate:modelValue": p[8] || (p[8] = (O) => ce.value = O),
2590
+ class: $e(["dark:bg-transparent dark:border-ring/50 text-center", ye.value === P.id ? "" : "text-transparent"]),
2591
+ onClick: p[9] || (p[9] = fe(() => {
2592
+ }, ["stop"])),
2593
+ onFocus: (O) => Ve(O, P),
2594
+ onBlur: (O) => C(P.id),
2595
+ onKeydown: Yt((O) => E(P.id), ["enter"])
2596
+ }, null, 8, ["id", "modelValue", "class", "onFocus", "onBlur", "onKeydown"])
2597
+ ]),
2598
+ _: 2
2599
+ }, 1024),
2600
+ s(Je, null, {
2601
+ default: f(() => [
2602
+ S.value?.filter((O) => O.options?.find((J) => J.optionId === r.value)?.valueId === P.id).length === 1 ? (h(), w("p", Nl, "Applies to 1 variant")) : (h(), w("p", Il, "Applies to all " + F(S.value?.filter((O) => O.options?.find((J) => J.optionId === r.value)?.valueId === P.id).length) + " variants", 1))
2603
+ ]),
2604
+ _: 2
2605
+ }, 1024)
2606
+ ]),
2607
+ _: 2
2608
+ }, 1024),
2609
+ ye.value !== P.id ? (h(), w("span", Tl, F(je(P.id)), 1)) : M("", !0)
2610
+ ])
2611
+ ]),
2612
+ u("td", $l, [
2613
+ s(qe, null, {
2614
+ default: f(() => [
2615
+ s(Ke, {
2616
+ class: "w-full focus-visible:outline-none",
2617
+ onClick: p[10] || (p[10] = fe(() => {
2618
+ }, ["stop"]))
2619
+ }, {
2620
+ default: f(() => [
2621
+ s(Ze, null, {
2622
+ default: f(() => [
2623
+ s(Ge, null, {
2624
+ default: f(() => [
2625
+ s(We, {
2626
+ value: Pe(P.id),
2627
+ class: "dark:border-ring/50",
2628
+ disabled: ""
2629
+ }, null, 8, ["value"])
2630
+ ]),
2631
+ _: 2
2632
+ }, 1024)
2633
+ ]),
2634
+ _: 2
2635
+ }, 1024)
2636
+ ]),
2637
+ _: 2
2638
+ }, 1024),
2639
+ s(Je, null, {
2640
+ default: f(() => [...p[21] || (p[21] = [
2641
+ u("p", null, "Update for individual variants only", -1)
2642
+ ])]),
2643
+ _: 1
2644
+ })
2645
+ ]),
2646
+ _: 2
2647
+ }, 1024)
2648
+ ])
2649
+ ], 8, vl),
2650
+ x.value.includes(P.id) ? (h(!0), w(q, { key: 0 }, ie(S.value?.filter((O) => O.options?.find((J) => J.optionId === r.value)?.valueId === P.id), (O) => (h(), w("tr", {
2651
+ key: O.id,
2652
+ class: "hover:bg-accent/50 cursor-pointer transition-colors duration-200 border-b border-input"
2653
+ }, [
2654
+ u("td", El, [
2655
+ u("div", Al, [
2656
+ s(Ye, {
2657
+ class: "border-muted-foreground translate-y-0.5",
2658
+ onClick: p[11] || (p[11] = fe(() => {
2659
+ }, ["stop"]))
2660
+ })
2661
+ ])
2662
+ ]),
2663
+ u("td", zl, [
2664
+ u("div", Ol, [
2665
+ u("div", null, [
2666
+ s(it, {
2667
+ sources: m(i),
2668
+ maxFiles: 1,
2669
+ "initial-value": c.value[I(O.options)].image ? [c.value[I(O.options)].image] : [],
2670
+ onSubmit: (J) => c.value[I(O.options)].image = J
2671
+ }, {
2672
+ default: f(() => [
2673
+ u("button", {
2674
+ onClick: p[12] || (p[12] = fe(() => {
2675
+ }, ["stop"])),
2676
+ tabindex: "-1",
2677
+ class: "cursor-pointer"
2678
+ }, [
2679
+ c.value[I(O.options)].image ? (h(), w("img", {
2680
+ key: 0,
2681
+ src: c.value[I(O.options)].image,
2682
+ class: "size-10 object-cover rounded-md",
2683
+ draggable: "false"
2684
+ }, null, 8, Ml)) : (h(), L(De, {
2685
+ key: 1,
2686
+ variant: "outline",
2687
+ class: "size-10 border-dashed cursor-pointer"
2688
+ }, {
2689
+ default: f(() => [
2690
+ s(m(gt))
2691
+ ]),
2692
+ _: 1
2693
+ }))
2694
+ ])
2695
+ ]),
2696
+ _: 2
2697
+ }, 1032, ["sources", "initial-value", "onSubmit"])
2698
+ ]),
2699
+ u("div", Fl, [
2700
+ u("p", null, F(O.options.filter((J) => J.optionId !== r.value).map((J) => J.value).join(" / ")), 1)
2701
+ ])
2702
+ ])
2703
+ ]),
2704
+ u("td", Ll, [
2705
+ s(Ze, {
2706
+ "format-options": {
2707
+ style: "currency",
2708
+ currency: "EUR",
2709
+ currencyDisplay: "symbol",
2710
+ currencySign: "standard"
2711
+ },
2712
+ modelValue: c.value[I(O.options)].price,
2713
+ "onUpdate:modelValue": (J) => c.value[I(O.options)].price = J,
2714
+ min: 0
2715
+ }, {
2716
+ default: f(() => [
2717
+ s(Ge, null, {
2718
+ default: f(() => [
2719
+ s(We, { class: "dark:border-ring/50" })
2720
+ ]),
2721
+ _: 1
2722
+ })
2723
+ ]),
2724
+ _: 1
2725
+ }, 8, ["modelValue", "onUpdate:modelValue"])
2726
+ ]),
2727
+ u("td", Bl, [
2728
+ s(Ze, {
2729
+ modelValue: c.value[I(O.options)].stock,
2730
+ "onUpdate:modelValue": (J) => c.value[I(O.options)].stock = J
2731
+ }, {
2732
+ default: f(() => [
2733
+ s(Ge, null, {
2734
+ default: f(() => [
2735
+ s(Ht, { class: "group-hover:opacity-100 opacity-0 transition-opacity duration-200" }),
2736
+ s(We, { class: "dark:border-ring/50" }),
2737
+ s(Xt, { class: "group-hover:opacity-100 opacity-0 transition-opacity duration-200" })
2738
+ ]),
2739
+ _: 1
2740
+ })
2741
+ ]),
2742
+ _: 1
2743
+ }, 8, ["modelValue", "onUpdate:modelValue"])
2744
+ ])
2745
+ ]))), 128)) : M("", !0)
2746
+ ], 64))), 128))
2747
+ ])
2748
+ ]),
2749
+ u("div", Rl, [
2750
+ V(" Total inventory at Webshop: " + F(Xe()) + " ", 1),
2751
+ ze() < 0 ? (h(), w("span", Ul, "(" + F(ze()) + ")", 1)) : M("", !0),
2752
+ p[22] || (p[22] = V(" available ", -1))
2753
+ ])
2754
+ ], 64)) : M("", !0)
2755
+ ]));
2756
+ };
2757
+ }
2758
+ }), Hl = /* @__PURE__ */ ne({
2759
+ __name: "Variants",
2760
+ setup(e) {
2761
+ const { params: t } = St(), { value: n } = U("options"), { value: o } = U("variants"), l = X([]), a = X([]), i = Ee("optionsEl"), d = Ee("variantsEl");
2762
+ re(l, async (c) => {
2763
+ n.value = c ? JSON.parse(JSON.stringify(c)) : [], await Te(), d.value?.refreshVariants();
2764
+ }, { deep: !0 }), re(a, (c) => {
2765
+ o.value = c ? JSON.parse(JSON.stringify(c)) : [];
2766
+ }, { deep: !0 });
2767
+ const r = X(!1), b = X(!1);
2768
+ re(n, async (c) => {
2769
+ t.value.productId == "new" || !c || Array.isArray(c) && c.length === 0 || r.value || (r.value = !0, l.value = JSON.parse(JSON.stringify(c)), await Te(), c.length > 1 && i.value?.minifyAll());
2770
+ }, { deep: !0, immediate: !0 }), re(o, async (c) => {
2771
+ t.value.productId == "new" || !c || Array.isArray(c) && c.length === 0 || b.value || (b.value = !0, a.value = JSON.parse(JSON.stringify(c)), await Te(), d.value?.setVariantMap(c));
2772
+ }, { deep: !0, immediate: !0 });
2773
+ const x = de(() => {
2774
+ let c = l.value || [], D = {};
2775
+ return !c || !Array.isArray(c) || c.forEach((T) => {
2776
+ !T.name.trim() || T.values?.filter((N) => N.value.trim() !== "")?.length === 0 || (D[T.id] = {
2777
+ id: T.id,
2778
+ name: T.name,
2779
+ values: T.values?.map((N) => ({ id: N.id, value: N.value }))?.filter((N) => N.value.trim() !== "") || []
2780
+ });
2781
+ }), D;
2782
+ });
2783
+ return (c, D) => {
2784
+ const T = v("CardContent"), N = v("Card");
2785
+ return h(), L(N, null, {
2786
+ default: f(() => [
2787
+ s(T, null, {
2788
+ default: f(() => [
2789
+ D[2] || (D[2] = u("h3", { class: "text-lg font-semibold mb-4" }, "Variants", -1)),
2790
+ s(nl, {
2791
+ modelValue: l.value,
2792
+ "onUpdate:modelValue": D[0] || (D[0] = (I) => l.value = I),
2793
+ ref_key: "optionsEl",
2794
+ ref: i
2795
+ }, null, 8, ["modelValue"]),
2796
+ s(jl, {
2797
+ ref_key: "variantsEl",
2798
+ ref: d,
2799
+ options: x.value,
2800
+ modelValue: a.value,
2801
+ "onUpdate:modelValue": D[1] || (D[1] = (I) => a.value = I),
2802
+ hide: Object.keys(x.value).length === 0
2803
+ }, null, 8, ["options", "modelValue", "hide"])
2804
+ ]),
2805
+ _: 1
2806
+ })
2807
+ ]),
2808
+ _: 1
2809
+ });
2810
+ };
2811
+ }
2812
+ }), Xl = { class: "bg-white dark:bg-gray-50 border-4 dark:border-gray-600 p-4 rounded-lg mb-4" }, Yl = { class: "flex items-center gap-2 mb-2" }, Kl = ["src"], Jl = { class: "text-[#1a0dab] text-lg" }, ql = { class: "text-[#006621] text-[13px]" }, Wl = { class: "text-[#545454] text-[13px]" }, Gl = { class: "flex flex-col gap-4 mb-4" }, Zl = { class: "flex flex-col" }, Ql = {
2813
+ key: 0,
2814
+ class: "text-red-500 text-sm mt-1"
2815
+ }, er = { class: "flex flex-col gap-4 mb-4" }, tr = { class: "flex flex-col" }, nr = {
2816
+ key: 0,
2817
+ class: "text-red-500 text-sm mt-1"
2818
+ }, or = { class: "flex flex-col gap-4" }, lr = { class: "flex flex-col" }, rr = { class: "flex gap-2" }, ar = {
2819
+ key: 0,
2820
+ class: "text-red-500 text-sm mt-1"
2821
+ }, sr = {
2822
+ key: 1,
2823
+ class: "text-[#545454] text-[13px]"
2824
+ }, ir = {
2825
+ key: 2,
2826
+ class: "text-orange-500 text-[13px]"
2827
+ }, dr = /* @__PURE__ */ ne({
2828
+ __name: "SEO",
2829
+ setup(e) {
2830
+ const { errors: t } = xe(), { value: n } = U("title"), { value: o } = U("slug"), { value: l } = U("seo");
2831
+ function a(i) {
2832
+ return i ? i.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^\w\s-]/g, "").trim().replace(/[-\s]+/g, "-") : "";
2833
+ }
2834
+ return re(n, (i, d) => {
2835
+ (!o.value || a(d) === o.value) && (o.value = a(i)), (!l.value.title || d === l.value.title) && (l.value.title = i);
2836
+ }), (i, d) => {
2837
+ const r = v("Label"), b = v("Input"), x = v("Textarea"), c = v("ProgressCircle"), D = v("CardContent"), T = v("Card");
2838
+ return h(), L(T, null, {
2839
+ default: f(() => [
2840
+ s(D, null, {
2841
+ default: f(() => [
2842
+ d[7] || (d[7] = u("h3", { class: "text-lg font-semibold mb-4" }, "Search engine listing", -1)),
2843
+ u("div", Xl, [
2844
+ u("div", Yl, [
2845
+ u("img", {
2846
+ src: m(dn),
2847
+ alt: "Google",
2848
+ class: "w-16 pointer-events-none",
2849
+ draggable: "false"
2850
+ }, null, 8, Kl),
2851
+ d[3] || (d[3] = u("span", { class: "text-[#4186f5] font-medium text-xs" }, "Preview", -1))
2852
+ ]),
2853
+ u("p", Jl, F(m(l).title), 1),
2854
+ u("p", ql, F(m(o)), 1),
2855
+ u("p", Wl, F(m(l).description?.slice(0, 155)) + F(m(l).description?.length > 155 ? " ..." : ""), 1)
2856
+ ]),
2857
+ u("div", Gl, [
2858
+ u("div", Zl, [
2859
+ s(r, {
2860
+ for: "slug",
2861
+ class: "text-sm mb-2"
2862
+ }, {
2863
+ default: f(() => [...d[4] || (d[4] = [
2864
+ V("Slug", -1)
2865
+ ])]),
2866
+ _: 1
2867
+ }),
2868
+ s(b, {
2869
+ id: "slug",
2870
+ placeholder: "t-shirt-with-red-heart",
2871
+ modelValue: m(o),
2872
+ "onUpdate:modelValue": d[0] || (d[0] = (N) => Y(o) ? o.value = N : null)
2873
+ }, null, 8, ["modelValue"]),
2874
+ m(t).slug ? (h(), w("p", Ql, F(m(t).slug), 1)) : M("", !0)
2875
+ ])
2876
+ ]),
2877
+ u("div", er, [
2878
+ u("div", tr, [
2879
+ s(r, {
2880
+ for: "meta-title",
2881
+ class: "text-sm mb-2"
2882
+ }, {
2883
+ default: f(() => [...d[5] || (d[5] = [
2884
+ V("Title", -1)
2885
+ ])]),
2886
+ _: 1
2887
+ }),
2888
+ s(b, {
2889
+ id: "meta-title",
2890
+ placeholder: "T-shirt with red heart",
2891
+ modelValue: m(l).title,
2892
+ "onUpdate:modelValue": d[1] || (d[1] = (N) => m(l).title = N)
2893
+ }, null, 8, ["modelValue"]),
2894
+ m(t).seo?.title ? (h(), w("p", nr, F(m(t).seo.title), 1)) : M("", !0)
2895
+ ])
2896
+ ]),
2897
+ u("div", or, [
2898
+ u("div", lr, [
2899
+ s(r, {
2900
+ for: "meta-description",
2901
+ class: "text-sm mb-2"
2902
+ }, {
2903
+ default: f(() => [...d[6] || (d[6] = [
2904
+ V("Description", -1)
2905
+ ])]),
2906
+ _: 1
2907
+ }),
2908
+ s(x, {
2909
+ id: "meta-description",
2910
+ placeholder: "Lovely T-shirt featuring a red heart",
2911
+ modelValue: m(l).description,
2912
+ "onUpdate:modelValue": d[2] || (d[2] = (N) => m(l).description = N),
2913
+ class: "mb-2 resize-none"
2914
+ }, null, 8, ["modelValue"]),
2915
+ u("div", rr, [
2916
+ s(c, {
2917
+ progress: (m(l).description?.length ?? 0) / 155
2918
+ }, null, 8, ["progress"]),
2919
+ m(t).seo?.description ? (h(), w("p", ar, F(m(t).seo.description), 1)) : m(l).description?.length < 155 ? (h(), w("p", sr, F(m(l).description.length) + " characters", 1)) : (h(), w("p", ir, "Please keep it under 155 characters"))
2920
+ ])
2921
+ ])
2922
+ ])
2923
+ ]),
2924
+ _: 1
2925
+ })
2926
+ ]),
2927
+ _: 1
2928
+ });
2929
+ };
2930
+ }
2931
+ }), ur = /* @__PURE__ */ ne({
2932
+ __name: "NewSection",
2933
+ setup(e) {
2934
+ return (t, n) => {
2935
+ const o = v("Button"), l = v("CardContent"), a = v("Card");
2936
+ return h(), w(q, null, [
2937
+ n[3] || (n[3] = u("hr", { class: "my-4" }, null, -1)),
2938
+ s(a, null, {
2939
+ default: f(() => [
2940
+ s(l, null, {
2941
+ default: f(() => [
2942
+ n[1] || (n[1] = u("h2", { class: "text-lg font-medium" }, "New Section", -1)),
2943
+ n[2] || (n[2] = u("p", { class: "text-sm text-muted-foreground mb-4" }, "As an admin, you can define new sections within the product detail page.", -1)),
2944
+ s(o, null, {
2945
+ default: f(() => [
2946
+ s(m(tn), { class: "size-4" }),
2947
+ n[0] || (n[0] = V(" Create new section ", -1))
2948
+ ]),
2949
+ _: 1
2950
+ })
2951
+ ]),
2952
+ _: 1
2953
+ })
2954
+ ]),
2955
+ _: 1
2956
+ })
2957
+ ], 64);
2958
+ };
2959
+ }
2960
+ }), cr = { class: "flex items-center gap-2" }, fr = {
2961
+ key: 0,
2962
+ class: "size-3 rounded-full bg-green-500"
2963
+ }, pr = {
2964
+ key: 1,
2965
+ class: "size-3 rounded-full bg-blue-500"
2966
+ }, gr = {
2967
+ key: 2,
2968
+ class: "size-3 rounded-full bg-gray-300"
2969
+ }, mr = /* @__PURE__ */ ne({
2970
+ __name: "Status",
2971
+ setup(e) {
2972
+ const { errors: t } = xe(), { value: n } = U("status");
2973
+ return (o, l) => {
2974
+ const a = v("SelectValue"), i = v("SelectTrigger"), d = v("SelectItem"), r = v("SelectGroup"), b = v("SelectContent"), x = v("Select"), c = v("CardContent"), D = v("Card");
2975
+ return h(), L(D, null, {
2976
+ default: f(() => [
2977
+ s(c, null, {
2978
+ default: f(() => [
2979
+ l[4] || (l[4] = u("h3", { class: "text-lg font-semibold mb-4" }, "Status", -1)),
2980
+ s(x, {
2981
+ modelValue: m(n),
2982
+ "onUpdate:modelValue": l[0] || (l[0] = (T) => Y(n) ? n.value = T : null),
2983
+ class: "w-full"
2984
+ }, {
2985
+ default: f(() => [
2986
+ s(i, { class: "w-full" }, {
2987
+ default: f(() => [
2988
+ u("div", cr, [
2989
+ m(n) === "published" ? (h(), w("span", fr)) : m(n) === "draft" ? (h(), w("span", pr)) : m(n) === "archived" ? (h(), w("span", gr)) : M("", !0),
2990
+ s(a, { placeholder: "Status" })
2991
+ ])
2992
+ ]),
2993
+ _: 1
2994
+ }),
2995
+ s(b, null, {
2996
+ default: f(() => [
2997
+ s(r, null, {
2998
+ default: f(() => [
2999
+ s(d, { value: "published" }, {
3000
+ default: f(() => [...l[1] || (l[1] = [
3001
+ u("span", { class: "size-3 rounded-full bg-green-500" }, null, -1),
3002
+ V(" Published ", -1)
3003
+ ])]),
3004
+ _: 1
3005
+ }),
3006
+ s(d, { value: "draft" }, {
3007
+ default: f(() => [...l[2] || (l[2] = [
3008
+ u("span", { class: "size-3 rounded-full bg-blue-500" }, null, -1),
3009
+ V(" Draft ", -1)
3010
+ ])]),
3011
+ _: 1
3012
+ }),
3013
+ s(d, { value: "archived" }, {
3014
+ default: f(() => [...l[3] || (l[3] = [
3015
+ u("span", { class: "size-3 rounded-full bg-gray-300" }, null, -1),
3016
+ V(" Archived ", -1)
3017
+ ])]),
3018
+ _: 1
3019
+ })
3020
+ ]),
3021
+ _: 1
3022
+ })
3023
+ ]),
3024
+ _: 1
3025
+ })
3026
+ ]),
3027
+ _: 1
3028
+ }, 8, ["modelValue"])
3029
+ ]),
3030
+ _: 1
3031
+ })
3032
+ ]),
3033
+ _: 1
3034
+ });
3035
+ };
3036
+ }
3037
+ }), vr = { class: "flex items-center gap-2 truncate" }, br = /* @__PURE__ */ ne({
3038
+ __name: "Collections",
3039
+ props: {
3040
+ config: {
3041
+ type: Object,
3042
+ required: !0
3043
+ }
3044
+ },
3045
+ setup(e) {
3046
+ const t = e, n = Ct(t.config.project), o = async () => {
3047
+ if (!t.config.collectionsCollection) return [];
3048
+ const r = t.config.collectionsCollection.split(":");
3049
+ return r.length !== 2 ? [] : (await n.get(r[0]))?.[r[1]] || [];
3050
+ }, l = X([]);
3051
+ (async () => {
3052
+ const r = await o();
3053
+ l.value = r;
3054
+ })();
3055
+ const { errors: i } = xe(), { value: d } = U("collections");
3056
+ return (r, b) => {
3057
+ const x = v("SelectValue"), c = v("SelectTrigger"), D = v("SelectLabel"), T = v("SelectItem"), N = v("SelectGroup"), I = v("SelectContent"), A = v("Select"), z = v("CardContent"), _ = v("Card");
3058
+ return h(), L(_, null, {
3059
+ default: f(() => [
3060
+ s(z, null, {
3061
+ default: f(() => [
3062
+ b[5] || (b[5] = u("h3", { class: "text-lg font-semibold mb-4" }, "Collections", -1)),
3063
+ s(A, {
3064
+ modelValue: m(d),
3065
+ "onUpdate:modelValue": b[0] || (b[0] = (S) => Y(d) ? d.value = S : null),
3066
+ class: "w-full",
3067
+ multiple: !0
3068
+ }, {
3069
+ default: f(() => [
3070
+ s(c, { class: "w-full" }, {
3071
+ default: f(() => [
3072
+ u("div", vr, [
3073
+ s(x, { placeholder: "Collections" })
3074
+ ])
3075
+ ]),
3076
+ _: 1
3077
+ }),
3078
+ s(I, null, {
3079
+ default: f(() => [
3080
+ s(N, null, {
3081
+ default: f(() => [
3082
+ s(D, null, {
3083
+ default: f(() => [...b[1] || (b[1] = [
3084
+ V("Active collections", -1)
3085
+ ])]),
3086
+ _: 1
3087
+ }),
3088
+ (h(!0), w(q, null, ie(l.value.filter((S) => S.status === "published"), (S) => (h(), L(T, {
3089
+ key: S.id,
3090
+ value: S.id
3091
+ }, {
3092
+ default: f(() => [
3093
+ b[2] || (b[2] = u("div", { class: "size-2 rounded-full bg-green-500" }, null, -1)),
3094
+ V(" " + F(S.title), 1)
3095
+ ]),
3096
+ _: 2
3097
+ }, 1032, ["value"]))), 128))
3098
+ ]),
3099
+ _: 1
3100
+ }),
3101
+ s(N, null, {
3102
+ default: f(() => [
3103
+ s(D, null, {
3104
+ default: f(() => [...b[3] || (b[3] = [
3105
+ V("Drafts", -1)
3106
+ ])]),
3107
+ _: 1
3108
+ }),
3109
+ (h(!0), w(q, null, ie(l.value.filter((S) => S.status === "draft"), (S) => (h(), L(T, {
3110
+ key: S.id,
3111
+ value: S.id
3112
+ }, {
3113
+ default: f(() => [
3114
+ b[4] || (b[4] = u("div", { class: "size-2 rounded-full bg-blue-500" }, null, -1)),
3115
+ V(" " + F(S.title), 1)
3116
+ ]),
3117
+ _: 2
3118
+ }, 1032, ["value"]))), 128))
3119
+ ]),
3120
+ _: 1
3121
+ })
3122
+ ]),
3123
+ _: 1
3124
+ })
3125
+ ]),
3126
+ _: 1
3127
+ }, 8, ["modelValue"])
3128
+ ]),
3129
+ _: 1
3130
+ })
3131
+ ]),
3132
+ _: 1
3133
+ });
3134
+ };
3135
+ }
3136
+ }), hr = { class: "relative @container" }, _r = { class: "flex flex-row gap-4 justify-between max-w-5xl mx-auto mt-4 mb-6" }, xr = { class: "flex items-center" }, yr = { class: "text-lg font-semibold mx-2" }, Dr = {
3137
+ key: 0,
3138
+ class: "bg-green-500 text-green-950 px-2 py-1 rounded-lg text-xs"
3139
+ }, Sr = {
3140
+ key: 1,
3141
+ class: "bg-blue-500 text-blue-950 px-2 py-1 rounded-lg text-xs"
3142
+ }, Cr = {
3143
+ key: 2,
3144
+ class: "bg-gray-300 dark:bg-gray-500 text-gray-950 px-2 py-1 rounded-lg text-xs"
3145
+ }, wr = { class: "flex flex-col @3xl:flex-row gap-4 max-w-5xl mx-auto pb-24" }, kr = { class: "flex flex-col gap-4 w-full @3xl:w-2/3" }, Pr = { class: "flex flex-col gap-4 w-full @3xl:w-1/3" }, Vr = {
3146
+ key: 0,
3147
+ class: "fixed bottom-4 left-0 md:left-12 right-0 min-w-xs max-w-5xl w-[calc(100%-2rem)] md:w-[calc(100%-5rem)] xl:w-[calc(100%-2rem)] h-16 border border-white/10 backdrop-blur-sm border-t border-border flex items-center justify-center px-4 mx-auto z-[9999] rounded-xl overflow-hidden shadow bg-[radial-gradient(#ffffff80,transparent)] dark:bg-[radial-gradient(#00000080,transparent)]"
3148
+ }, Nr = { class: "w-full max-w-5xl flex items-center justify-end mx-auto" }, Mr = /* @__PURE__ */ ne({
3149
+ __name: "Detail",
3150
+ props: {
3151
+ config: {
3152
+ type: Object,
3153
+ required: !0
3154
+ }
3155
+ },
3156
+ async setup(e) {
3157
+ let t, n;
3158
+ const o = e, { hasPermission: l, hasAnyPermission: a, isAdmin: i } = an(), { params: d, navigateTo: r } = St(), { confirm: b } = Dt(), x = Ct(o.config.project);
3159
+ dt("sources", o.config.allowedMediaSources), dt("defaultSource", o.config.defaultUploadMediaSource);
3160
+ const c = X(!1), D = de(() => !d.value.productId || d.value.productId === "new"), T = X(""), N = X([]);
3161
+ N.value = ([t, n] = Kt(() => ce()), t = await t, n(), t);
3162
+ const I = Jt(Se({
3163
+ title: H().min(1, "Title is required"),
3164
+ description: H().optional(),
3165
+ media: ve(H()).optional(),
3166
+ price: be.number().positive("Must be positive"),
3167
+ compareAtPrice: Ne(
3168
+ (C) => C === "" ? void 0 : C,
3169
+ be.number().positive("Must be positive").optional()
3170
+ ),
3171
+ isTaxable: Ie().optional(),
3172
+ costPerItem: Ne(
3173
+ (C) => C === "" ? void 0 : C,
3174
+ be.number().positive("Must be positive").optional()
3175
+ ),
3176
+ currency: H(),
3177
+ stock: Ne(
3178
+ (C) => C === "" ? void 0 : C,
3179
+ be.number().optional()
3180
+ ),
3181
+ trackInventory: Ie().optional(),
3182
+ allowBackorder: Ie().optional(),
3183
+ isPhysicalProduct: Ie().optional(),
3184
+ weight: Ne(
3185
+ (C) => C === "" ? void 0 : C,
3186
+ be.number().optional()
3187
+ ),
3188
+ weightUnit: H().optional(),
3189
+ slug: H(),
3190
+ seo: Se({
3191
+ title: H().optional(),
3192
+ description: H().optional()
3193
+ }).optional(),
3194
+ createdAt: ut(),
3195
+ updatedAt: ut(),
3196
+ status: H(),
3197
+ options: ve(Se({
3198
+ id: H(),
3199
+ name: H().min(1),
3200
+ values: ve(Se({
3201
+ id: H(),
3202
+ value: H()
3203
+ }))
3204
+ })).optional(),
3205
+ variants: ve(Se({
3206
+ combinedOptions: H().min(1),
3207
+ name: H().min(1),
3208
+ disabled: Ie().optional(),
3209
+ price: be.number().positive("Must be positive"),
3210
+ stock: Ne(
3211
+ (C) => C === "" ? void 0 : C,
3212
+ be.number().optional()
3213
+ ),
3214
+ image: H().optional(),
3215
+ options: ve(Se({
3216
+ optionId: H(),
3217
+ option: H(),
3218
+ valueId: H(),
3219
+ value: H()
3220
+ }))
3221
+ })).optional(),
3222
+ tags: ve(H()).optional(),
3223
+ collections: ve(H()).optional()
3224
+ })), { handleSubmit: A, errors: z, values: _, setValues: S } = qt({
3225
+ validationSchema: I,
3226
+ initialValues: {
3227
+ createdAt: /* @__PURE__ */ new Date(),
3228
+ updatedAt: /* @__PURE__ */ new Date(),
3229
+ status: "draft",
3230
+ options: [],
3231
+ variants: [],
3232
+ media: [],
3233
+ isTaxable: !1,
3234
+ trackInventory: !1,
3235
+ allowBackorder: !1,
3236
+ isPhysicalProduct: !0,
3237
+ weight: 0,
3238
+ weightUnit: "kg",
3239
+ tags: [],
3240
+ collections: [],
3241
+ currency: o.config.defaultCurrency || "USD",
3242
+ price: 1,
3243
+ stock: 0,
3244
+ seo: {
3245
+ title: "",
3246
+ description: ""
3247
+ }
3248
+ }
3249
+ });
3250
+ sn(() => [
3251
+ { text: D.value ? "New Product" : _.title || "Product" }
3252
+ ]);
3253
+ const B = (C) => {
3254
+ let E = {
3255
+ ...C,
3256
+ maxPrice: K(),
3257
+ minPrice: j(),
3258
+ maxCompareAtPrice: oe(),
3259
+ minCompareAtPrice: Q(),
3260
+ isSingleVariant: !C.variants || C.variants.length === 0,
3261
+ variantsTotal: C.variants?.length || 1,
3262
+ stock: je(),
3263
+ featuredMedia: C.media?.[0]
3264
+ };
3265
+ return E.isPhysicalProduct ? E.type = "physical" : (E.weight = 0, E.weightUnit = "kg", E.type = "digital"), E;
3266
+ }, K = () => !_.variants || _.variants.length === 0 ? _.price : Math.max(..._.variants.map((C) => C.price)), j = () => !_.variants || _.variants.length === 0 ? _.price : Math.min(..._.variants.map((C) => C.price)), Q = () => _.compareAtPrice, oe = () => _.compareAtPrice, je = () => !_.variants || _.variants.length === 0 ? _.stock : _.variants.reduce((C, E) => E.stock < 0 ? C : C + E.stock, 0), Pe = A(async (C) => {
3267
+ c.value = !0;
3268
+ let E = B(C);
3269
+ if (D.value) {
3270
+ if (await Ve(E.slug)) {
3271
+ se.error("Product slug already exists");
3272
+ return;
3273
+ }
3274
+ E.createdAt = /* @__PURE__ */ new Date(), E.updatedAt = /* @__PURE__ */ new Date();
3275
+ const le = await x.add(o.config.productCollection, E);
3276
+ r(le.id), se.success("Product created");
3277
+ } else {
3278
+ if (T.value !== E.slug && await Ve(E.slug)) {
3279
+ se.error("Product slug already exists");
3280
+ return;
3281
+ }
3282
+ E.updatedAt = /* @__PURE__ */ new Date(), await x.update(o.config.productCollection, d.value.productId, E), r(`${d.value.productId}`), se.success("Product updated");
3283
+ }
3284
+ c.value = !1;
3285
+ }), He = async () => {
3286
+ const C = await x.get(o.config.productCollection, d.value.productId);
3287
+ C.createdAt = new Date(C.createdAt), C.updatedAt = new Date(C.updatedAt), C.options?.forEach((E) => {
3288
+ E.values.forEach((le) => {
3289
+ le.touched = !0;
3290
+ }), E.values.push({ id: Math.random().toString(36).substring(2, 15), value: "" });
3291
+ }), S(C), T.value = C.slug;
3292
+ }, Xe = async () => {
3293
+ try {
3294
+ let C = { ..._ }, E = C.slug + "-copy", le = 2;
3295
+ for (; await Ve(E); )
3296
+ E = C.slug + "-copy-" + le, le++;
3297
+ C.id = void 0, C.createdAt = /* @__PURE__ */ new Date(), C.updatedAt = /* @__PURE__ */ new Date(), C.slug = E, C.status = "draft", C.title = C.title + " (copy)";
3298
+ const k = await x.add(o.config.productCollection, C);
3299
+ r(k.id), se.success("Product duplicated");
3300
+ } catch {
3301
+ se.error("Failed to duplicate product");
3302
+ }
3303
+ }, ze = async () => {
3304
+ try {
3305
+ await x.update(o.config.productCollection, d.value.productId, { status: "archived" }), S({ status: "archived" }, { force: !1 }), se.success("Product archived");
3306
+ } catch {
3307
+ se.error("Failed to archive product");
3308
+ }
3309
+ }, ye = async () => {
3310
+ if (await b("Are you sure you want to delete this product?"))
3311
+ try {
3312
+ await x.remove(o.config.productCollection, d.value.productId), r(""), se.success("Product deleted");
3313
+ } catch {
3314
+ se.error("Failed to delete product");
3315
+ }
3316
+ };
3317
+ async function ce() {
3318
+ if (!o.config.collectionsCollection) return [];
3319
+ const C = o.config.collectionsCollection.split(":");
3320
+ return C.length !== 2 ? [] : (await x.get(C[0]))?.[C[1]] || [];
3321
+ }
3322
+ async function Ve(C) {
3323
+ return (await x.find(o.config.productCollection, {
3324
+ filters: [
3325
+ {
3326
+ field: "slug",
3327
+ operator: "==",
3328
+ value: C
3329
+ }
3330
+ ]
3331
+ })).length > 0;
3332
+ }
3333
+ return lt(() => {
3334
+ D.value || He();
3335
+ }), (C, E) => {
3336
+ const le = v("Button"), k = v("MenubarTrigger"), p = v("MenubarMenu"), y = v("MenubarItem"), $ = v("MenubarContent"), R = v("Menubar");
3337
+ return h(), w("div", hr, [
3338
+ u("div", _r, [
3339
+ u("div", xr, [
3340
+ s(le, {
3341
+ variant: "ghost",
3342
+ onClick: E[0] || (E[0] = (ae) => m(r)(""))
3343
+ }, {
3344
+ default: f(() => [
3345
+ s(m(nn), { class: "size-4" })
3346
+ ]),
3347
+ _: 1
3348
+ }),
3349
+ s(m(on), { class: "size-3" }),
3350
+ u("h1", yr, F(D.value ? "New Product" : m(_).title), 1),
3351
+ m(_).status === "published" ? (h(), w("span", Dr, "Published")) : m(_).status === "draft" ? (h(), w("span", Sr, "Draft")) : m(_).status === "archived" ? (h(), w("span", Cr, "Archived")) : M("", !0)
3352
+ ]),
3353
+ D.value ? M("", !0) : (h(), L(R, {
3354
+ key: 0,
3355
+ class: "rounded-lg shadow-xs"
3356
+ }, {
3357
+ default: f(() => [
3358
+ m(l)("create-product") ? (h(), L(p, { key: 0 }, {
3359
+ default: f(() => [
3360
+ s(k, { onClick: Xe }, {
3361
+ default: f(() => [...E[1] || (E[1] = [
3362
+ V("Duplicate", -1)
3363
+ ])]),
3364
+ _: 1
3365
+ })
3366
+ ]),
3367
+ _: 1
3368
+ })) : M("", !0),
3369
+ s(p, null, {
3370
+ default: f(() => [
3371
+ s(k, null, {
3372
+ default: f(() => [...E[2] || (E[2] = [
3373
+ V("Preview", -1)
3374
+ ])]),
3375
+ _: 1
3376
+ })
3377
+ ]),
3378
+ _: 1
3379
+ }),
3380
+ m(a)("edit-product", "delete-product") ? (h(), L(p, { key: 1 }, {
3381
+ default: f(() => [
3382
+ s(k, null, {
3383
+ default: f(() => [...E[3] || (E[3] = [
3384
+ V("More actions", -1)
3385
+ ])]),
3386
+ _: 1
3387
+ }),
3388
+ s($, null, {
3389
+ default: f(() => [
3390
+ m(l)("edit-product") ? (h(), L(y, {
3391
+ key: 0,
3392
+ onClick: ze
3393
+ }, {
3394
+ default: f(() => [
3395
+ s(m(ln), { class: "size-4" }),
3396
+ E[4] || (E[4] = V(" Archive product ", -1))
3397
+ ]),
3398
+ _: 1
3399
+ })) : M("", !0),
3400
+ m(l)("delete-product") ? (h(), L(y, {
3401
+ key: 1,
3402
+ variant: "destructive",
3403
+ onClick: ye
3404
+ }, {
3405
+ default: f(() => [
3406
+ s(m(rn), { class: "size-4" }),
3407
+ E[5] || (E[5] = V(" Delete product ", -1))
3408
+ ]),
3409
+ _: 1
3410
+ })) : M("", !0)
3411
+ ]),
3412
+ _: 1
3413
+ })
3414
+ ]),
3415
+ _: 1
3416
+ })) : M("", !0)
3417
+ ]),
3418
+ _: 1
3419
+ }))
3420
+ ]),
3421
+ u("div", wr, [
3422
+ u("div", kr, [
3423
+ s(_n),
3424
+ s(In),
3425
+ s(zn),
3426
+ s(Fn),
3427
+ s(Hl),
3428
+ s(dr),
3429
+ m(i)() ? (h(), L(ur, { key: 0 })) : M("", !0)
3430
+ ]),
3431
+ u("div", Pr, [
3432
+ s(mr),
3433
+ s(br, { config: e.config }, null, 8, ["config"])
3434
+ ])
3435
+ ]),
3436
+ m(a)("create-product", "edit-product") ? (h(), w("div", Vr, [
3437
+ u("div", Nr, [
3438
+ D.value && m(l)("create-product") ? (h(), L(le, {
3439
+ key: 0,
3440
+ onClick: m(Pe),
3441
+ disabled: c.value
3442
+ }, {
3443
+ default: f(() => [
3444
+ c.value ? (h(), L(m(mt), {
3445
+ key: 0,
3446
+ class: "size-4 animate-spin"
3447
+ })) : M("", !0),
3448
+ V(" " + F(c.value ? "Creating" : "Create") + " New Product ", 1)
3449
+ ]),
3450
+ _: 1
3451
+ }, 8, ["onClick", "disabled"])) : m(l)("edit-product") ? (h(), L(le, {
3452
+ key: 1,
3453
+ onClick: m(Pe),
3454
+ disabled: c.value
3455
+ }, {
3456
+ default: f(() => [
3457
+ c.value ? (h(), L(m(mt), {
3458
+ key: 0,
3459
+ class: "size-4 animate-spin"
3460
+ })) : M("", !0),
3461
+ V(" " + F(c.value ? "Saving" : "Save") + " Changes ", 1)
3462
+ ]),
3463
+ _: 1
3464
+ }, 8, ["onClick", "disabled"])) : M("", !0)
3465
+ ])
3466
+ ])) : M("", !0)
3467
+ ]);
3468
+ };
3469
+ }
3470
+ });
3471
+ export {
3472
+ Mr as default
3473
+ };