@develemit/commerce-admin 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import { a as e, c as t, d as n, f as r, i, l as a, m as o, o as s, p as c, r as l, s as u, u as d } from "./client--_j5r8ag.js";
3
- import { createContext as f, useCallback as p, useContext as m, useEffect as h, useRef as g, useState as _ } from "react";
4
- import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
5
- import { adminProductInputSchema as x, shippingRatesInputSchema as S } from "@develemit/commerce-contracts";
2
+ import { a as e, c as t, d as n, f as r, h as i, i as a, l as o, m as s, o as c, p as l, r as u, s as d, u as f } from "./client-CSjuKdIE.js";
3
+ import { createContext as p, useCallback as m, useContext as h, useEffect as g, useRef as _, useState as v } from "react";
4
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
5
+ import { adminProductInputSchema as S, shippingRatesInputSchema as C } from "@develemit/commerce-contracts";
6
6
  // src/lib/order-labels.ts
7
- var C = {
7
+ var w = {
8
8
  title: "Orders",
9
9
  searchLabel: "Search orders",
10
10
  searchPlaceholder: "Search by email or order id",
@@ -104,7 +104,7 @@ var C = {
104
104
  resolved: "Order resolved.",
105
105
  restockThenResolve: "Restock, then resolve"
106
106
  }
107
- }, w = {
107
+ }, T = {
108
108
  title: "Shipping rates",
109
109
  loading: "Loading shipping rates…",
110
110
  empty: "No shipping rates yet. Add one so customers can check out.",
@@ -135,7 +135,7 @@ var C = {
135
135
  daysInvalid: "Use a whole number of days, or leave blank.",
136
136
  daysOrder: "Fastest cannot be more than slowest.",
137
137
  rowInvalid: "These details are not valid."
138
- }, T = {
138
+ }, E = {
139
139
  title: "Discounts",
140
140
  newDiscount: "New discount",
141
141
  searchLabel: "Search discounts",
@@ -198,7 +198,7 @@ var C = {
198
198
  invalid: "This value is not valid."
199
199
  },
200
200
  orderRow: "Discount"
201
- }, E = {
201
+ }, D = {
202
202
  title: "Products",
203
203
  newProduct: "New product",
204
204
  searchLabel: "Search products",
@@ -283,7 +283,7 @@ var C = {
283
283
  price: "Enter a price like 48 or 48.50.",
284
284
  quantity: "Enter a whole number, zero or more."
285
285
  }
286
- }, D = {
286
+ }, O = {
287
287
  loading: "Loading…",
288
288
  empty: "Nothing here yet.",
289
289
  save: "Save",
@@ -326,14 +326,14 @@ var C = {
326
326
  imageTooLarge: "That image is too large. Choose a smaller one.",
327
327
  generic: "Something went wrong. Try again."
328
328
  },
329
- products: E,
330
- orders: C,
331
- shipping: w,
332
- discounts: T
329
+ products: D,
330
+ orders: w,
331
+ shipping: T,
332
+ discounts: E
333
333
  };
334
334
  // src/lib/merge-labels.ts
335
- function O(e) {
336
- let t = C;
335
+ function k(e) {
336
+ let t = w;
337
337
  return {
338
338
  ...t,
339
339
  ...e,
@@ -371,8 +371,8 @@ function O(e) {
371
371
  }
372
372
  };
373
373
  }
374
- function k(e) {
375
- let t = E;
374
+ function A(e) {
375
+ let t = D;
376
376
  return {
377
377
  ...t,
378
378
  ...e,
@@ -402,8 +402,8 @@ function k(e) {
402
402
  }
403
403
  };
404
404
  }
405
- function A(e) {
406
- let t = T;
405
+ function j(e) {
406
+ let t = E;
407
407
  return {
408
408
  ...t,
409
409
  ...e,
@@ -433,8 +433,8 @@ function A(e) {
433
433
  }
434
434
  };
435
435
  }
436
- function j(e) {
437
- let t = D;
436
+ function ee(e) {
437
+ let t = O;
438
438
  return {
439
439
  ...t,
440
440
  ...e,
@@ -450,23 +450,23 @@ function j(e) {
450
450
  ...t.errors,
451
451
  ...e?.errors
452
452
  },
453
- products: k(e?.products),
454
- orders: O(e?.orders),
453
+ products: A(e?.products),
454
+ orders: k(e?.orders),
455
455
  shipping: {
456
- ...w,
456
+ ...T,
457
457
  ...e?.shipping
458
458
  },
459
- discounts: A(e?.discounts)
459
+ discounts: j(e?.discounts)
460
460
  };
461
461
  }
462
462
  // src/lib/provider.tsx
463
463
  var M = {
464
- renderLink: ({ href: e, children: t, className: n }) => /* @__PURE__ */ y("a", {
464
+ renderLink: ({ href: e, children: t, className: n }) => /* @__PURE__ */ b("a", {
465
465
  href: e,
466
466
  className: n,
467
467
  children: t
468
468
  }),
469
- renderImage: ({ src: e, alt: t, sizes: n, className: r, priority: i }) => /* @__PURE__ */ y("img", {
469
+ renderImage: ({ src: e, alt: t, sizes: n, className: r, priority: i }) => /* @__PURE__ */ b("img", {
470
470
  src: e,
471
471
  alt: t,
472
472
  sizes: n,
@@ -489,9 +489,9 @@ var M = {
489
489
  newDiscount: "/admin/discounts/new"
490
490
  },
491
491
  client: null,
492
- labels: D
493
- }, N = f(M);
494
- function ee({ children: e, hrefs: t, labels: n, ...r }) {
492
+ labels: O
493
+ }, N = p(M);
494
+ function te({ children: e, hrefs: t, labels: n, ...r }) {
495
495
  let i = {
496
496
  ...M,
497
497
  ...r,
@@ -499,15 +499,15 @@ function ee({ children: e, hrefs: t, labels: n, ...r }) {
499
499
  ...M.hrefs,
500
500
  ...t
501
501
  },
502
- labels: j(n)
502
+ labels: ee(n)
503
503
  };
504
- return /* @__PURE__ */ y(N.Provider, {
504
+ return /* @__PURE__ */ b(N.Provider, {
505
505
  value: i,
506
506
  children: e
507
507
  });
508
508
  }
509
509
  function P() {
510
- return m(N);
510
+ return h(N);
511
511
  }
512
512
  function F() {
513
513
  let { client: e } = P();
@@ -516,16 +516,16 @@ function F() {
516
516
  }
517
517
  // src/lib/use-admin-query.ts
518
518
  function I(e, t) {
519
- let n = g(t);
520
- h(() => {
519
+ let n = _(t);
520
+ g(() => {
521
521
  n.current = t;
522
522
  });
523
- let [r, i] = _(0), [a, o] = _({
523
+ let [r, i] = v(0), [a, o] = v({
524
524
  request: "",
525
525
  data: void 0,
526
526
  error: void 0
527
527
  }), s = `${JSON.stringify(e)}#${r}`;
528
- h(() => {
528
+ g(() => {
529
529
  let e = new AbortController();
530
530
  return n.current(e.signal).then((t) => {
531
531
  e.signal.aborted || o({
@@ -541,7 +541,7 @@ function I(e, t) {
541
541
  }));
542
542
  }), () => e.abort();
543
543
  }, [s]);
544
- let c = p(() => i((e) => e + 1), []), l = a.request === s;
544
+ let c = m(() => i((e) => e + 1), []), l = a.request === s;
545
545
  return {
546
546
  data: a.data,
547
547
  error: l ? a.error : void 0,
@@ -551,13 +551,13 @@ function I(e, t) {
551
551
  }
552
552
  // src/lib/use-admin-mutation.ts
553
553
  function L(e) {
554
- let t = g(e);
555
- h(() => {
554
+ let t = _(e);
555
+ g(() => {
556
556
  t.current = e;
557
557
  });
558
- let [n, r] = _(!1), [i, a] = _(void 0);
558
+ let [n, r] = v(!1), [i, a] = v(void 0);
559
559
  return {
560
- run: p(async (...e) => {
560
+ run: m(async (...e) => {
561
561
  r(!0), a(void 0);
562
562
  try {
563
563
  return await t.current(...e);
@@ -570,11 +570,11 @@ function L(e) {
570
570
  }, []),
571
571
  pending: n,
572
572
  error: i,
573
- reset: p(() => a(void 0), [])
573
+ reset: m(() => a(void 0), [])
574
574
  };
575
575
  }
576
576
  // src/components/admin-layout/admin-layout.tsx
577
- function te({ children: e, extraNav: t = [], header: n, footer: r }) {
577
+ function ne({ children: e, extraNav: t = [], header: n, footer: r }) {
578
578
  let { hrefs: i, labels: a, renderLink: o } = P(), s = [
579
579
  {
580
580
  href: i.products,
@@ -593,27 +593,27 @@ function te({ children: e, extraNav: t = [], header: n, footer: r }) {
593
593
  ...s,
594
594
  ...t.filter((e) => e.position !== "start")
595
595
  ];
596
- return /* @__PURE__ */ b("div", {
596
+ return /* @__PURE__ */ x("div", {
597
597
  className: "sfa-root sfa-layout",
598
598
  children: [
599
- n ? /* @__PURE__ */ y("header", {
599
+ n ? /* @__PURE__ */ b("header", {
600
600
  className: "sfa-layout__header",
601
601
  children: n
602
602
  }) : null,
603
- /* @__PURE__ */ y("nav", {
603
+ /* @__PURE__ */ b("nav", {
604
604
  className: "sfa-nav",
605
605
  "aria-label": a.navLabel,
606
- children: /* @__PURE__ */ y("ul", { children: c.map((e) => /* @__PURE__ */ y("li", { children: o({
606
+ children: /* @__PURE__ */ b("ul", { children: c.map((e) => /* @__PURE__ */ b("li", { children: o({
607
607
  href: e.href,
608
608
  className: "sfa-nav__link",
609
609
  children: e.label
610
610
  }) }, e.href)) })
611
611
  }),
612
- /* @__PURE__ */ y("main", {
612
+ /* @__PURE__ */ b("main", {
613
613
  className: "sfa-layout__content",
614
614
  children: e
615
615
  }),
616
- r ? /* @__PURE__ */ y("footer", {
616
+ r ? /* @__PURE__ */ b("footer", {
617
617
  className: "sfa-layout__footer",
618
618
  children: r
619
619
  }) : null
@@ -623,18 +623,18 @@ function te({ children: e, extraNav: t = [], header: n, footer: r }) {
623
623
  // src/components/admin-table/admin-table.tsx
624
624
  function R({ columns: e, rows: t, rowKey: n, caption: r }) {
625
625
  let { labels: i } = P();
626
- return t.length === 0 ? /* @__PURE__ */ y("p", {
626
+ return t.length === 0 ? /* @__PURE__ */ b("p", {
627
627
  className: "sfa-empty",
628
628
  children: i.empty
629
- }) : /* @__PURE__ */ b("table", {
629
+ }) : /* @__PURE__ */ x("table", {
630
630
  className: "sfa-table sfa-table--stacked",
631
631
  children: [
632
- r ? /* @__PURE__ */ y("caption", { children: r }) : null,
633
- /* @__PURE__ */ y("thead", { children: /* @__PURE__ */ y("tr", { children: e.map((e) => /* @__PURE__ */ y("th", {
632
+ r ? /* @__PURE__ */ b("caption", { children: r }) : null,
633
+ /* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { children: e.map((e) => /* @__PURE__ */ b("th", {
634
634
  scope: "col",
635
635
  children: e.header
636
636
  }, e.key)) }) }),
637
- /* @__PURE__ */ y("tbody", { children: t.map((t) => /* @__PURE__ */ y("tr", { children: e.map((e) => /* @__PURE__ */ y("td", {
637
+ /* @__PURE__ */ b("tbody", { children: t.map((t) => /* @__PURE__ */ b("tr", { children: e.map((e) => /* @__PURE__ */ b("td", {
638
638
  "data-label": e.header,
639
639
  children: e.render(t)
640
640
  }, e.key)) }, n(t))) })
@@ -644,7 +644,7 @@ function R({ columns: e, rows: t, rowKey: n, caption: r }) {
644
644
  // src/components/status-badge/status-badge.tsx
645
645
  function z({ status: e }) {
646
646
  let { labels: t } = P();
647
- return /* @__PURE__ */ y("span", {
647
+ return /* @__PURE__ */ b("span", {
648
648
  className: `sfa-badge sfa-badge--${e.replace(/_/g, "-")}`,
649
649
  children: t.statuses[e] ?? e
650
650
  });
@@ -655,20 +655,20 @@ function B({ cents: e, currency: t }) {
655
655
  style: "currency",
656
656
  currency: t
657
657
  }).format(e / 100);
658
- return /* @__PURE__ */ y("span", {
658
+ return /* @__PURE__ */ b("span", {
659
659
  className: "sfa-money",
660
660
  children: r
661
661
  });
662
662
  }
663
663
  // src/components/confirm-dialog/confirm-dialog.tsx
664
- var ne = "button:not([disabled]), [href], input:not([disabled]), select, textarea, [tabindex]:not([tabindex=\"-1\"])";
664
+ var re = "button:not([disabled]), [href], input:not([disabled]), select, textarea, [tabindex]:not([tabindex=\"-1\"])";
665
665
  function V({ open: e, title: t, children: n, confirmLabel: r, destructive: i = !1, pending: a = !1, onConfirm: o, onCancel: s }) {
666
- let { labels: c } = P(), l = g(null);
667
- return h(() => {
666
+ let { labels: c } = P(), l = _(null);
667
+ return g(() => {
668
668
  if (!e) return;
669
669
  let t = document.activeElement;
670
- return l.current?.querySelector(ne)?.focus(), () => t?.focus();
671
- }, [e]), e ? /* @__PURE__ */ y("div", {
670
+ return l.current?.querySelector(re)?.focus(), () => t?.focus();
671
+ }, [e]), e ? /* @__PURE__ */ b("div", {
672
672
  className: "sfa-dialog-backdrop",
673
673
  onKeyDown: (e) => {
674
674
  if (e.key === "Escape") {
@@ -676,31 +676,31 @@ function V({ open: e, title: t, children: n, confirmLabel: r, destructive: i = !
676
676
  return;
677
677
  }
678
678
  if (e.key !== "Tab") return;
679
- let t = Array.from(l.current?.querySelectorAll(ne) ?? []);
679
+ let t = Array.from(l.current?.querySelectorAll(re) ?? []);
680
680
  if (t.length === 0) return;
681
681
  let n = t[0], r = t[t.length - 1];
682
682
  e.shiftKey && document.activeElement === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && document.activeElement === r && (e.preventDefault(), n.focus());
683
683
  },
684
- children: /* @__PURE__ */ b("div", {
684
+ children: /* @__PURE__ */ x("div", {
685
685
  ref: l,
686
686
  role: "dialog",
687
687
  "aria-modal": "true",
688
688
  "aria-label": t,
689
689
  className: "sfa-dialog",
690
690
  children: [
691
- /* @__PURE__ */ y("h2", {
691
+ /* @__PURE__ */ b("h2", {
692
692
  className: "sfa-dialog__title",
693
693
  children: t
694
694
  }),
695
695
  n,
696
- /* @__PURE__ */ b("div", {
696
+ /* @__PURE__ */ x("div", {
697
697
  className: "sfa-dialog__actions",
698
- children: [/* @__PURE__ */ y("button", {
698
+ children: [/* @__PURE__ */ b("button", {
699
699
  type: "button",
700
700
  className: "sfa-btn",
701
701
  onClick: s,
702
702
  children: c.cancel
703
- }), /* @__PURE__ */ y("button", {
703
+ }), /* @__PURE__ */ b("button", {
704
704
  type: "button",
705
705
  className: `sfa-btn ${i ? "sfa-btn--danger" : "sfa-btn--primary"}`,
706
706
  disabled: a,
@@ -715,7 +715,7 @@ function V({ open: e, title: t, children: n, confirmLabel: r, destructive: i = !
715
715
  // src/components/notice/notice.tsx
716
716
  function H({ variant: e, children: t, toast: n = !1, duration: r = 4e3, onDismiss: i }) {
717
717
  let { labels: a } = P();
718
- h(() => {
718
+ g(() => {
719
719
  if (!n || !i) return;
720
720
  let e = setTimeout(i, r);
721
721
  return () => clearTimeout(e);
@@ -725,13 +725,13 @@ function H({ variant: e, children: t, toast: n = !1, duration: r = 4e3, onDismis
725
725
  i
726
726
  ]);
727
727
  let o = e === "error" ? "alert" : "status", s = `sfa-notice sfa-notice--${e}${n ? " sfa-notice--toast" : ""}`;
728
- return /* @__PURE__ */ b("div", {
728
+ return /* @__PURE__ */ x("div", {
729
729
  role: o,
730
730
  className: s,
731
- children: [/* @__PURE__ */ y("span", {
731
+ children: [/* @__PURE__ */ b("span", {
732
732
  className: "sfa-notice__body",
733
733
  children: t
734
- }), i && !n ? /* @__PURE__ */ y("button", {
734
+ }), i && !n ? /* @__PURE__ */ b("button", {
735
735
  type: "button",
736
736
  className: "sfa-btn",
737
737
  onClick: i,
@@ -740,38 +740,38 @@ function H({ variant: e, children: t, toast: n = !1, duration: r = 4e3, onDismis
740
740
  });
741
741
  }
742
742
  // src/components/error-message/error-message.tsx
743
- var re = [
743
+ var ie = [
744
744
  [e, "unauthorized"],
745
- [i, "notFound"],
746
- [l, "invalidInput"],
745
+ [a, "notFound"],
746
+ [u, "invalidInput"],
747
747
  [n, "invalidOrderState"],
748
- [a, "insufficientStock"],
749
- [r, "refundExceedsBalance"],
750
- [c, "refundGateway"],
751
- [o, "refundOutcomeUnknown"],
752
- [s, "discountCodeTaken"],
753
- [u, "discountInUse"],
748
+ [o, "insufficientStock"],
749
+ [l, "refundExceedsBalance"],
750
+ [s, "refundGateway"],
751
+ [i, "refundOutcomeUnknown"],
752
+ [c, "discountCodeTaken"],
753
+ [d, "discountInUse"],
754
754
  [t, "imageTooLarge"],
755
- [d, "imageInvalid"]
755
+ [f, "imageInvalid"]
756
756
  ];
757
- function ie(e) {
758
- return re.find(([t]) => e instanceof t)?.[1] ?? "generic";
757
+ function ae(e) {
758
+ return ie.find(([t]) => e instanceof t)?.[1] ?? "generic";
759
759
  }
760
760
  function U({ error: e }) {
761
761
  let { labels: t } = P();
762
- return e ? /* @__PURE__ */ y(H, {
762
+ return e ? /* @__PURE__ */ b(H, {
763
763
  variant: "error",
764
- children: t.errors[ie(e)]
764
+ children: t.errors[ae(e)]
765
765
  }) : null;
766
766
  }
767
767
  // src/lib/product-filter.ts
768
- function ae(e) {
769
- return e.status === "active" && e.quantity === 0;
770
- }
771
768
  function oe(e) {
772
- return ae(e) ? "sold" : e.status;
769
+ return e.status === "active" && e.quantity === 0;
773
770
  }
774
771
  function se(e) {
772
+ return oe(e) ? "sold" : e.status;
773
+ }
774
+ function ce(e) {
775
775
  switch (e) {
776
776
  case "live":
777
777
  case "sold": return "active";
@@ -780,29 +780,26 @@ function se(e) {
780
780
  case "all": return;
781
781
  }
782
782
  }
783
- function ce(e) {
783
+ function le(e) {
784
784
  if (e === "live") return "in";
785
785
  if (e === "sold") return "sold";
786
786
  }
787
787
  // src/lib/use-debounced.ts
788
788
  function W(e, t) {
789
- let [n, r] = _(e);
790
- return h(() => {
789
+ let [n, r] = v(e);
790
+ return g(() => {
791
791
  let n = setTimeout(() => r(e), t);
792
792
  return () => clearTimeout(n);
793
793
  }, [e, t]), n;
794
794
  }
795
- // src/lib/use-product-pages.ts
796
- function le(e) {
797
- let t = F(), n = I(["admin-products", e], () => t.listProducts(e)), [r, i] = _(null), a = L(async (n, r) => {
798
- let a = await t.listProducts({
799
- ...e,
800
- cursor: n
801
- });
795
+ // src/lib/use-paged-list.ts
796
+ function G(e, t) {
797
+ let n = I(e, () => t()), [r, i] = v(null), a = L(async (e, n) => {
798
+ let r = await t(e);
802
799
  i((e) => ({
803
- base: r,
804
- items: [...e?.base === r ? e.items : [], ...a.items],
805
- nextCursor: a.nextCursor
800
+ base: n,
801
+ items: [...e?.base === n ? e.items : [], ...r.items],
802
+ nextCursor: r.nextCursor
806
803
  }));
807
804
  }), o = n.data, s = r && r.base === o ? r : null, c = s ? s.nextCursor : o?.nextCursor ?? null;
808
805
  return {
@@ -818,34 +815,42 @@ function le(e) {
818
815
  }
819
816
  };
820
817
  }
818
+ // src/lib/use-product-pages.ts
819
+ function ue(e) {
820
+ let t = F();
821
+ return G(["admin-products", e], (n) => t.listProducts(n ? {
822
+ ...e,
823
+ cursor: n
824
+ } : e));
825
+ }
821
826
  // src/views/products/admin-product-list.tsx
822
- var ue = [
827
+ var de = [
823
828
  "all",
824
829
  "live",
825
830
  "sold",
826
831
  "draft",
827
832
  "archived"
828
833
  ];
829
- function de() {
830
- let e = F(), { labels: t, hrefs: n, renderLink: r } = P(), i = t.products, [a, o] = _("all"), [s, c] = _(""), l = W(s.trim(), 300), u = se(a), d = ce(a), f = le({
834
+ function fe() {
835
+ let e = F(), { labels: t, hrefs: n, renderLink: r } = P(), i = t.products, [a, o] = v("all"), [s, c] = v(""), l = W(s.trim(), 300), u = ce(a), d = le(a), f = ue({
831
836
  ...u ? { status: u } : {},
832
837
  ...d ? { stock: d } : {},
833
838
  ...l ? { q: l } : {}
834
- }), [p, m] = _(null), [h, g] = _(!1), v = L(({ kind: t, product: n }) => e.updateProduct(n.id, t === "sold" ? { sold: !0 } : { status: "archived" })), x = async () => {
839
+ }), [p, m] = v(null), [h, g] = v(!1), _ = L(({ kind: t, product: n }) => e.updateProduct(n.id, t === "sold" ? { sold: !0 } : { status: "archived" })), y = async () => {
835
840
  if (!p) return;
836
- let e = await v.run(p);
841
+ let e = await _.run(p);
837
842
  m(null), e && (g(!0), f.reload());
838
843
  }, S = [
839
844
  {
840
845
  key: "image",
841
846
  header: i.columns.image,
842
- render: (e) => e.images[0] ? /* @__PURE__ */ y("img", {
847
+ render: (e) => e.images[0] ? /* @__PURE__ */ b("img", {
843
848
  className: "sfa-thumb",
844
849
  src: e.images[0].url,
845
850
  alt: e.images[0].alt,
846
851
  width: 48,
847
852
  height: 48
848
- }) : /* @__PURE__ */ y("span", {
853
+ }) : /* @__PURE__ */ b("span", {
849
854
  className: "sfa-thumb sfa-thumb--empty",
850
855
  children: i.noImage
851
856
  })
@@ -862,7 +867,7 @@ function de() {
862
867
  {
863
868
  key: "price",
864
869
  header: i.columns.price,
865
- render: (e) => /* @__PURE__ */ y(B, {
870
+ render: (e) => /* @__PURE__ */ b(B, {
866
871
  cents: e.priceCents,
867
872
  currency: e.currency
868
873
  })
@@ -870,7 +875,7 @@ function de() {
870
875
  {
871
876
  key: "status",
872
877
  header: i.columns.status,
873
- render: (e) => /* @__PURE__ */ y(z, { status: oe(e) })
878
+ render: (e) => /* @__PURE__ */ b(z, { status: se(e) })
874
879
  },
875
880
  {
876
881
  key: "quantity",
@@ -880,7 +885,7 @@ function de() {
880
885
  {
881
886
  key: "actions",
882
887
  header: i.columns.actions,
883
- render: (e) => /* @__PURE__ */ b("div", {
888
+ render: (e) => /* @__PURE__ */ x("div", {
884
889
  className: "sfa-row-actions",
885
890
  children: [
886
891
  e.status === "active" && n.storefrontProduct ? r({
@@ -888,7 +893,7 @@ function de() {
888
893
  children: i.viewInShop,
889
894
  className: "sfa-btn"
890
895
  }) : null,
891
- e.status !== "archived" && e.quantity > 0 ? /* @__PURE__ */ y("button", {
896
+ e.status !== "archived" && e.quantity > 0 ? /* @__PURE__ */ b("button", {
892
897
  type: "button",
893
898
  className: "sfa-btn",
894
899
  onClick: () => m({
@@ -897,7 +902,7 @@ function de() {
897
902
  }),
898
903
  children: i.markSold
899
904
  }) : null,
900
- e.status === "archived" ? null : /* @__PURE__ */ y("button", {
905
+ e.status === "archived" ? null : /* @__PURE__ */ b("button", {
901
906
  type: "button",
902
907
  className: "sfa-btn",
903
908
  onClick: () => m({
@@ -910,31 +915,31 @@ function de() {
910
915
  })
911
916
  }
912
917
  ], C = f.items, w = l ? i.noMatches : i.empty[a];
913
- return /* @__PURE__ */ b("section", {
918
+ return /* @__PURE__ */ x("section", {
914
919
  className: "sfa-products",
915
920
  children: [
916
- /* @__PURE__ */ b("header", {
921
+ /* @__PURE__ */ x("header", {
917
922
  className: "sfa-products__header",
918
- children: [/* @__PURE__ */ y("h1", { children: i.title }), r({
923
+ children: [/* @__PURE__ */ b("h1", { children: i.title }), r({
919
924
  href: n.newProduct,
920
925
  children: i.newProduct,
921
926
  className: "sfa-btn sfa-btn--primary"
922
927
  })]
923
928
  }),
924
- /* @__PURE__ */ b("div", {
929
+ /* @__PURE__ */ x("div", {
925
930
  className: "sfa-products__toolbar",
926
- children: [/* @__PURE__ */ y("div", {
931
+ children: [/* @__PURE__ */ b("div", {
927
932
  role: "group",
928
933
  "aria-label": i.columns.status,
929
934
  className: "sfa-filter-group",
930
- children: ue.map((e) => /* @__PURE__ */ y("button", {
935
+ children: de.map((e) => /* @__PURE__ */ b("button", {
931
936
  type: "button",
932
937
  className: "sfa-btn sfa-filter",
933
938
  "aria-pressed": a === e,
934
939
  onClick: () => o(e),
935
940
  children: i.filters[e]
936
941
  }, e))
937
- }), /* @__PURE__ */ y("input", {
942
+ }), /* @__PURE__ */ b("input", {
938
943
  type: "search",
939
944
  "aria-label": i.searchLabel,
940
945
  placeholder: i.searchPlaceholder,
@@ -942,36 +947,36 @@ function de() {
942
947
  onChange: (e) => c(e.target.value)
943
948
  })]
944
949
  }),
945
- /* @__PURE__ */ y(U, { error: f.error ?? v.error }),
946
- f.loading && !f.loaded ? /* @__PURE__ */ y("p", { children: t.loading }) : C.length === 0 ? /* @__PURE__ */ y("p", {
950
+ /* @__PURE__ */ b(U, { error: f.error ?? _.error }),
951
+ f.loading && !f.loaded ? /* @__PURE__ */ b("p", { children: t.loading }) : C.length === 0 ? /* @__PURE__ */ b("p", {
947
952
  className: "sfa-empty",
948
953
  children: w
949
- }) : /* @__PURE__ */ y(R, {
954
+ }) : /* @__PURE__ */ b(R, {
950
955
  columns: S,
951
956
  rows: C,
952
957
  rowKey: (e) => e.id
953
958
  }),
954
- f.hasMore ? /* @__PURE__ */ y("button", {
959
+ f.hasMore ? /* @__PURE__ */ b("button", {
955
960
  type: "button",
956
961
  className: "sfa-btn sfa-products__more",
957
962
  disabled: f.loadingMore,
958
963
  onClick: f.loadMore,
959
964
  children: i.loadMore
960
965
  }) : null,
961
- /* @__PURE__ */ y(V, {
966
+ /* @__PURE__ */ b(V, {
962
967
  open: p !== null,
963
968
  title: p?.kind === "archive" ? i.archiveTitle : i.markSoldTitle,
964
969
  confirmLabel: p?.kind === "archive" ? i.archive : i.markSold,
965
- pending: v.pending,
966
- onConfirm: x,
970
+ pending: _.pending,
971
+ onConfirm: y,
967
972
  onCancel: () => m(null),
968
- children: /* @__PURE__ */ b("p", { children: [
973
+ children: /* @__PURE__ */ x("p", { children: [
969
974
  p?.product.name,
970
975
  " — ",
971
976
  p?.kind === "archive" ? i.archiveBody : i.markSoldBody
972
977
  ] })
973
978
  }),
974
- h ? /* @__PURE__ */ y(H, {
979
+ h ? /* @__PURE__ */ b(H, {
975
980
  variant: "success",
976
981
  toast: !0,
977
982
  onDismiss: () => g(!1),
@@ -981,18 +986,18 @@ function de() {
981
986
  });
982
987
  }
983
988
  // src/lib/money-input.ts
984
- var fe = /^\$?\s*(\d+|\d{1,3}(?:,\d{3})+)?(?:\.(\d{1,2}))?$/;
985
- function G(e) {
986
- let t = e.trim(), n = fe.exec(t);
989
+ var pe = /^\$?\s*(\d+|\d{1,3}(?:,\d{3})+)?(?:\.(\d{1,2}))?$/;
990
+ function K(e) {
991
+ let t = e.trim(), n = pe.exec(t);
987
992
  if (!n || !n[1] && !n[2]) return null;
988
993
  let r = Number((n[1] ?? "0").replace(/,/g, "")), i = Number((n[2] ?? "").padEnd(2, "0")), a = r * 100 + i;
989
994
  return Number.isSafeInteger(a) ? a : null;
990
995
  }
991
- function K(e) {
996
+ function q(e) {
992
997
  return `${Math.floor(e / 100)}.${String(e % 100).padStart(2, "0")}`;
993
998
  }
994
999
  // src/lib/product-form.ts
995
- var pe = [
1000
+ var me = [
996
1001
  "name",
997
1002
  "category",
998
1003
  "description",
@@ -1002,7 +1007,7 @@ var pe = [
1002
1007
  "quantity",
1003
1008
  "status",
1004
1009
  "featured"
1005
- ], me = {
1010
+ ], he = {
1006
1011
  name: "",
1007
1012
  category: "",
1008
1013
  description: "",
@@ -1013,48 +1018,48 @@ var pe = [
1013
1018
  status: "draft",
1014
1019
  featured: !1
1015
1020
  };
1016
- function he(e) {
1021
+ function ge(e) {
1017
1022
  return {
1018
1023
  name: e.name,
1019
1024
  category: e.category,
1020
1025
  description: e.description,
1021
1026
  materials: e.materials ?? "",
1022
1027
  dimensions: e.dimensions ?? "",
1023
- price: K(e.priceCents),
1028
+ price: q(e.priceCents),
1024
1029
  quantity: String(e.quantity),
1025
1030
  status: e.status,
1026
1031
  featured: e.featured
1027
1032
  };
1028
1033
  }
1029
- function ge(e) {
1034
+ function _e(e) {
1030
1035
  let t = String(Array.isArray(e) ? e[0] ?? "" : e ?? ""), n = t === "priceCents" ? "price" : t;
1031
- return pe.includes(n) ? n : void 0;
1036
+ return me.includes(n) ? n : void 0;
1032
1037
  }
1033
- function _e(e) {
1038
+ function ve(e) {
1034
1039
  let t = {};
1035
1040
  for (let n of e) {
1036
- let { path: e, message: r } = n ?? {}, i = ge(e);
1041
+ let { path: e, message: r } = n ?? {}, i = _e(e);
1037
1042
  i && !t[i] && (t[i] = typeof r == "string" ? r : "Invalid value.");
1038
1043
  }
1039
1044
  return t;
1040
1045
  }
1041
- function ve(e) {
1042
- return pe.find((t) => e[t]);
1043
- }
1044
1046
  function ye(e) {
1047
+ return me.find((t) => e[t]);
1048
+ }
1049
+ function be(e) {
1045
1050
  let t = e.trim();
1046
1051
  return t === "" ? null : t;
1047
1052
  }
1048
- function be(e, t, n) {
1049
- let r = {}, i = G(e.price);
1053
+ function xe(e, t, n) {
1054
+ let r = {}, i = K(e.price);
1050
1055
  i === null && (r.price = t.validation.price);
1051
1056
  let a = /^\d+$/.test(e.quantity.trim()) ? Number(e.quantity.trim()) : null;
1052
1057
  a === null && (r.quantity = t.validation.quantity);
1053
- let o = x.safeParse({
1058
+ let o = S.safeParse({
1054
1059
  name: e.name,
1055
1060
  description: e.description,
1056
- materials: ye(e.materials),
1057
- dimensions: ye(e.dimensions),
1061
+ materials: be(e.materials),
1062
+ dimensions: be(e.dimensions),
1058
1063
  priceCents: i ?? 0,
1059
1064
  ...n ? { currency: n } : {},
1060
1065
  category: e.category,
@@ -1063,7 +1068,7 @@ function be(e, t, n) {
1063
1068
  featured: e.featured
1064
1069
  });
1065
1070
  if (!o.success) for (let e of o.error.issues) {
1066
- let n = ge(e.path);
1071
+ let n = _e(e.path);
1067
1072
  n && !r[n] && (r[n] = t.validation.required);
1068
1073
  }
1069
1074
  return !o.success || Object.keys(r).length > 0 ? {
@@ -1074,7 +1079,7 @@ function be(e, t, n) {
1074
1079
  input: o.data
1075
1080
  };
1076
1081
  }
1077
- var xe = [
1082
+ var Se = [
1078
1083
  "name",
1079
1084
  "description",
1080
1085
  "materials",
@@ -1085,27 +1090,27 @@ var xe = [
1085
1090
  "status",
1086
1091
  "featured"
1087
1092
  ];
1088
- function Se(e, t) {
1093
+ function Ce(e, t) {
1089
1094
  let n = {};
1090
- for (let r of xe) (t[r] ?? null) !== e[r] && (n[r] = t[r]);
1095
+ for (let r of Se) (t[r] ?? null) !== e[r] && (n[r] = t[r]);
1091
1096
  return n;
1092
1097
  }
1093
- var Ce = [
1098
+ var we = [
1094
1099
  "image/jpeg",
1095
1100
  "image/png",
1096
1101
  "image/webp",
1097
1102
  "image/heic"
1098
1103
  ];
1099
- function q(e, t) {
1104
+ function J(e, t) {
1100
1105
  return e.replace(/\{(\w+)\}/g, (e, n) => t[n] ?? "");
1101
1106
  }
1102
- function we(e, t) {
1103
- return Ce.includes(e.type) ? e.size > 8388608 ? q(t.tooLarge, { name: e.name }) : null : q(t.wrongType, { name: e.name });
1107
+ function Te(e, t) {
1108
+ return we.includes(e.type) ? e.size > 8388608 ? J(t.tooLarge, { name: e.name }) : null : J(t.wrongType, { name: e.name });
1104
1109
  }
1105
1110
  // src/lib/use-image-upload.ts
1106
- function Te({ productId: e, onUploaded: t }) {
1107
- let n = F(), { labels: r } = P(), [i, a] = _([]), o = g(0), s = g(Promise.resolve()), c = g(t);
1108
- h(() => {
1111
+ function Ee({ productId: e, onUploaded: t }) {
1112
+ let n = F(), { labels: r } = P(), [i, a] = v([]), o = _(0), s = _(Promise.resolve()), c = _(t);
1113
+ g(() => {
1109
1114
  c.current = t;
1110
1115
  });
1111
1116
  let l = (e, t) => a((n) => n.map((n) => n.id === e ? {
@@ -1125,11 +1130,11 @@ function Te({ productId: e, onUploaded: t }) {
1125
1130
  };
1126
1131
  return {
1127
1132
  entries: i,
1128
- upload: p((e, t) => {
1133
+ upload: m((e, t) => {
1129
1134
  let n = e.map((e) => ({
1130
1135
  id: o.current++,
1131
1136
  file: e,
1132
- reason: we(e, r.products.images)
1137
+ reason: Te(e, r.products.images)
1133
1138
  }));
1134
1139
  a((e) => [...e, ...n.map(({ id: e, file: t, reason: n }) => ({
1135
1140
  id: e,
@@ -1147,17 +1152,17 @@ function Te({ productId: e, onUploaded: t }) {
1147
1152
  };
1148
1153
  }
1149
1154
  // src/views/products/image-alt-editor.tsx
1150
- function Ee({ imageId: e, alt: t, name: n, labels: r, onSave: i }) {
1151
- let [a, o] = _(null), [s, c] = _(!1), [l, u] = _(void 0), d = () => {
1155
+ function De({ imageId: e, alt: t, name: n, labels: r, onSave: i }) {
1156
+ let [a, o] = v(null), [s, c] = v(!1), [l, u] = v(void 0), d = () => {
1152
1157
  o(null), u(void 0);
1153
1158
  };
1154
- return a === null ? /* @__PURE__ */ y("button", {
1159
+ return a === null ? /* @__PURE__ */ b("button", {
1155
1160
  type: "button",
1156
1161
  className: "sfa-btn",
1157
1162
  "aria-label": `${r.editAlt}: ${n}`,
1158
1163
  onClick: () => o(t),
1159
1164
  children: r.editAlt
1160
- }) : /* @__PURE__ */ b("form", {
1165
+ }) : /* @__PURE__ */ x("form", {
1161
1166
  className: "sfa-image-tile__alt",
1162
1167
  onSubmit: async (e) => {
1163
1168
  if (e.preventDefault(), a !== null) {
@@ -1172,7 +1177,7 @@ function Ee({ imageId: e, alt: t, name: n, labels: r, onSave: i }) {
1172
1177
  }
1173
1178
  },
1174
1179
  children: [
1175
- /* @__PURE__ */ y("input", {
1180
+ /* @__PURE__ */ b("input", {
1176
1181
  "aria-label": `${r.altLabel}: ${n}`,
1177
1182
  value: a,
1178
1183
  disabled: s,
@@ -1182,15 +1187,15 @@ function Ee({ imageId: e, alt: t, name: n, labels: r, onSave: i }) {
1182
1187
  e.key === "Escape" && d();
1183
1188
  }
1184
1189
  }),
1185
- /* @__PURE__ */ y(U, { error: l }),
1186
- /* @__PURE__ */ y("button", {
1190
+ /* @__PURE__ */ b(U, { error: l }),
1191
+ /* @__PURE__ */ b("button", {
1187
1192
  type: "submit",
1188
1193
  className: "sfa-btn",
1189
1194
  "data-image-id": e,
1190
1195
  disabled: s,
1191
1196
  children: r.saveAlt
1192
1197
  }),
1193
- /* @__PURE__ */ y("button", {
1198
+ /* @__PURE__ */ b("button", {
1194
1199
  type: "button",
1195
1200
  className: "sfa-btn",
1196
1201
  disabled: s,
@@ -1201,8 +1206,8 @@ function Ee({ imageId: e, alt: t, name: n, labels: r, onSave: i }) {
1201
1206
  });
1202
1207
  }
1203
1208
  // src/views/products/image-tile.tsx
1204
- function De({ image: e, index: t, total: n, busy: r, labels: i, onMove: a, onRemove: o, onSaveAlt: s }) {
1205
- let { renderImage: c } = P(), l = e.alt || q(i.photoName, { n: String(t + 1) }), u = (t, n, r) => /* @__PURE__ */ y("button", {
1209
+ function Oe({ image: e, index: t, total: n, busy: r, labels: i, onMove: a, onRemove: o, onSaveAlt: s }) {
1210
+ let { renderImage: c } = P(), l = e.alt || J(i.photoName, { n: String(t + 1) }), u = (t, n, r) => /* @__PURE__ */ b("button", {
1206
1211
  type: "button",
1207
1212
  className: "sfa-btn",
1208
1213
  "data-image-id": e.id,
@@ -1212,7 +1217,7 @@ function De({ image: e, index: t, total: n, busy: r, labels: i, onMove: a, onRem
1212
1217
  onClick: () => a(t),
1213
1218
  children: n
1214
1219
  });
1215
- return /* @__PURE__ */ b("li", {
1220
+ return /* @__PURE__ */ x("li", {
1216
1221
  className: "sfa-image-tile",
1217
1222
  "aria-busy": r,
1218
1223
  "data-image-id": e.id,
@@ -1223,28 +1228,28 @@ function De({ image: e, index: t, total: n, busy: r, labels: i, onMove: a, onRem
1223
1228
  sizes: "160px",
1224
1229
  className: "sfa-image-tile__img"
1225
1230
  }),
1226
- t === 0 ? /* @__PURE__ */ y("span", {
1231
+ t === 0 ? /* @__PURE__ */ b("span", {
1227
1232
  className: "sfa-image-tile__cover",
1228
1233
  children: i.cover
1229
1234
  }) : null,
1230
- r ? /* @__PURE__ */ y("span", {
1235
+ r ? /* @__PURE__ */ b("span", {
1231
1236
  className: "sfa-spinner",
1232
1237
  role: "status",
1233
1238
  children: i.working
1234
1239
  }) : null,
1235
- /* @__PURE__ */ b("div", {
1240
+ /* @__PURE__ */ x("div", {
1236
1241
  className: "sfa-image-tile__actions",
1237
1242
  children: [
1238
1243
  u("earlier", i.moveEarlier, t === 0),
1239
1244
  u("later", i.moveLater, t === n - 1),
1240
- /* @__PURE__ */ y(Ee, {
1245
+ /* @__PURE__ */ b(De, {
1241
1246
  imageId: e.id,
1242
1247
  alt: e.alt,
1243
1248
  name: l,
1244
1249
  labels: i,
1245
1250
  onSave: s
1246
1251
  }),
1247
- /* @__PURE__ */ y("button", {
1252
+ /* @__PURE__ */ b("button", {
1248
1253
  type: "button",
1249
1254
  className: "sfa-btn sfa-btn--danger",
1250
1255
  "aria-label": `${i.remove}: ${l}`,
@@ -1257,24 +1262,24 @@ function De({ image: e, index: t, total: n, busy: r, labels: i, onMove: a, onRem
1257
1262
  });
1258
1263
  }
1259
1264
  // src/views/products/upload-picker.tsx
1260
- function Oe({ labels: e, onFiles: t }) {
1265
+ function ke({ labels: e, onFiles: t }) {
1261
1266
  let n = (e) => {
1262
1267
  t(Array.from(e.target.files ?? [])), e.target.value = "";
1263
1268
  };
1264
- return /* @__PURE__ */ b("div", {
1269
+ return /* @__PURE__ */ x("div", {
1265
1270
  className: "sfa-image-picker",
1266
- children: [/* @__PURE__ */ b("label", {
1271
+ children: [/* @__PURE__ */ x("label", {
1267
1272
  className: "sfa-btn sfa-image-picker__btn",
1268
- children: [e.add, /* @__PURE__ */ y("input", {
1273
+ children: [e.add, /* @__PURE__ */ b("input", {
1269
1274
  type: "file",
1270
1275
  accept: "image/*",
1271
1276
  multiple: !0,
1272
1277
  className: "sfa-sr-only",
1273
1278
  onChange: n
1274
1279
  })]
1275
- }), /* @__PURE__ */ b("label", {
1280
+ }), /* @__PURE__ */ x("label", {
1276
1281
  className: "sfa-btn sfa-image-picker__btn",
1277
- children: [e.takePhoto, /* @__PURE__ */ y("input", {
1282
+ children: [e.takePhoto, /* @__PURE__ */ b("input", {
1278
1283
  type: "file",
1279
1284
  accept: "image/*",
1280
1285
  capture: "environment",
@@ -1285,13 +1290,13 @@ function Oe({ labels: e, onFiles: t }) {
1285
1290
  });
1286
1291
  }
1287
1292
  // src/views/products/admin-product-images.tsx
1288
- var J = (e) => [...e].sort((e, t) => e.position - t.position);
1289
- function ke({ productId: e, images: t }) {
1290
- let n = F(), { labels: r } = P(), i = r.products.images, [a, o] = _(() => J(t)), [s, c] = _(null), [l, u] = _(!1), [d, f] = _(""), [p, m] = _(void 0), [x, S] = _(!1), [C, w] = _(null), T = g(null), E = g(null), { entries: D, upload: O, dismiss: k } = Te({
1293
+ var Y = (e) => [...e].sort((e, t) => e.position - t.position);
1294
+ function Ae({ productId: e, images: t }) {
1295
+ let n = F(), { labels: r } = P(), i = r.products.images, [a, o] = v(() => Y(t)), [s, c] = v(null), [l, u] = v(!1), [d, f] = v(""), [p, m] = v(void 0), [h, S] = v(!1), [C, w] = v(null), T = _(null), E = _(null), { entries: D, upload: O, dismiss: k } = Ee({
1291
1296
  productId: e,
1292
- onUploaded: (e) => o(J(e.images))
1297
+ onUploaded: (e) => o(Y(e.images))
1293
1298
  });
1294
- h(() => {
1299
+ g(() => {
1295
1300
  let e = T.current;
1296
1301
  if (!e) return;
1297
1302
  T.current = null;
@@ -1308,7 +1313,7 @@ function ke({ productId: e, images: t }) {
1308
1313
  }, o(d), u(!0), c(a[t].id), m(void 0), S(!1);
1309
1314
  try {
1310
1315
  let t = await n.reorderProductImages(e, d.map((e) => e.id));
1311
- o(J(t.images));
1316
+ o(Y(t.images));
1312
1317
  } catch (e) {
1313
1318
  T.current = {
1314
1319
  id: a[t].id,
@@ -1323,38 +1328,38 @@ function ke({ productId: e, images: t }) {
1323
1328
  w(null), c(t.id), m(void 0), S(!1);
1324
1329
  try {
1325
1330
  let r = await n.deleteProductImage(e, t.id);
1326
- o(J(r.images));
1331
+ o(Y(r.images));
1327
1332
  } catch (e) {
1328
1333
  m(e);
1329
1334
  } finally {
1330
1335
  c(null);
1331
1336
  }
1332
- }, M = async (t, r) => {
1337
+ }, ee = async (t, r) => {
1333
1338
  let i = await n.updateProductImage(e, t, { alt: r });
1334
- o(J(i.images));
1339
+ o(Y(i.images));
1335
1340
  };
1336
- return /* @__PURE__ */ b("div", {
1341
+ return /* @__PURE__ */ x("div", {
1337
1342
  className: "sfa-images",
1338
1343
  onDragOver: (e) => e.preventDefault(),
1339
1344
  onDrop: (e) => {
1340
1345
  e.preventDefault(), O(Array.from(e.dataTransfer.files), d);
1341
1346
  },
1342
1347
  children: [
1343
- /* @__PURE__ */ y("h2", { children: i.title }),
1344
- x ? /* @__PURE__ */ y(H, {
1348
+ /* @__PURE__ */ b("h2", { children: i.title }),
1349
+ h ? /* @__PURE__ */ b(H, {
1345
1350
  variant: "error",
1346
1351
  onDismiss: () => S(!1),
1347
1352
  children: i.reorderFailed
1348
- }) : /* @__PURE__ */ y(U, { error: p }),
1349
- /* @__PURE__ */ b("div", {
1353
+ }) : /* @__PURE__ */ b(U, { error: p }),
1354
+ /* @__PURE__ */ x("div", {
1350
1355
  className: "sfa-field",
1351
1356
  children: [
1352
- /* @__PURE__ */ y("label", {
1357
+ /* @__PURE__ */ b("label", {
1353
1358
  className: "sfa-field__label",
1354
1359
  htmlFor: `${e}-image-alt`,
1355
1360
  children: i.altLabel
1356
1361
  }),
1357
- /* @__PURE__ */ y("input", {
1362
+ /* @__PURE__ */ b("input", {
1358
1363
  id: `${e}-image-alt`,
1359
1364
  value: d,
1360
1365
  onChange: (e) => f(e.target.value),
@@ -1362,29 +1367,29 @@ function ke({ productId: e, images: t }) {
1362
1367
  e.key === "Enter" && e.preventDefault();
1363
1368
  }
1364
1369
  }),
1365
- /* @__PURE__ */ y("p", {
1370
+ /* @__PURE__ */ b("p", {
1366
1371
  className: "sfa-field__help",
1367
1372
  children: i.altHelp
1368
1373
  }),
1369
- d.trim() === "" ? /* @__PURE__ */ y("p", {
1374
+ d.trim() === "" ? /* @__PURE__ */ b("p", {
1370
1375
  className: "sfa-field__error",
1371
1376
  children: i.altWarning
1372
1377
  }) : null
1373
1378
  ]
1374
1379
  }),
1375
- /* @__PURE__ */ y(Oe, {
1380
+ /* @__PURE__ */ b(ke, {
1376
1381
  labels: i,
1377
1382
  onFiles: (e) => O(e, d)
1378
1383
  }),
1379
- /* @__PURE__ */ y("p", {
1384
+ /* @__PURE__ */ b("p", {
1380
1385
  className: "sfa-field__help",
1381
1386
  children: i.dropHint
1382
1387
  }),
1383
- a.length === 0 && D.length === 0 ? /* @__PURE__ */ y("p", { children: i.empty }) : null,
1384
- /* @__PURE__ */ b("ul", {
1388
+ a.length === 0 && D.length === 0 ? /* @__PURE__ */ b("p", { children: i.empty }) : null,
1389
+ /* @__PURE__ */ x("ul", {
1385
1390
  ref: E,
1386
1391
  className: "sfa-image-grid",
1387
- children: [a.map((e, t) => /* @__PURE__ */ y(De, {
1392
+ children: [a.map((e, t) => /* @__PURE__ */ b(Oe, {
1388
1393
  image: e,
1389
1394
  index: t,
1390
1395
  total: a.length,
@@ -1392,44 +1397,44 @@ function ke({ productId: e, images: t }) {
1392
1397
  labels: i,
1393
1398
  onMove: (e) => A(t, e),
1394
1399
  onRemove: () => w(e),
1395
- onSaveAlt: (t) => M(e.id, t)
1396
- }, e.id)), D.map((e) => /* @__PURE__ */ b("li", {
1400
+ onSaveAlt: (t) => ee(e.id, t)
1401
+ }, e.id)), D.map((e) => /* @__PURE__ */ x("li", {
1397
1402
  className: "sfa-image-tile",
1398
1403
  "aria-busy": e.status !== "error",
1399
- children: [/* @__PURE__ */ y("span", { children: e.name }), e.status === "error" ? /* @__PURE__ */ b(v, { children: [e.reason ? /* @__PURE__ */ y(H, {
1404
+ children: [/* @__PURE__ */ b("span", { children: e.name }), e.status === "error" ? /* @__PURE__ */ x(y, { children: [e.reason ? /* @__PURE__ */ b(H, {
1400
1405
  variant: "error",
1401
1406
  children: e.reason
1402
- }) : /* @__PURE__ */ y(U, { error: e.error }), /* @__PURE__ */ y("button", {
1407
+ }) : /* @__PURE__ */ b(U, { error: e.error }), /* @__PURE__ */ b("button", {
1403
1408
  type: "button",
1404
1409
  className: "sfa-btn",
1405
1410
  onClick: () => k(e.id),
1406
1411
  children: i.dismiss
1407
- })] }) : /* @__PURE__ */ y("span", {
1412
+ })] }) : /* @__PURE__ */ b("span", {
1408
1413
  className: "sfa-spinner",
1409
1414
  role: "status",
1410
1415
  children: e.status === "uploading" ? i.uploading : i.working
1411
1416
  })]
1412
1417
  }, e.id))]
1413
1418
  }),
1414
- /* @__PURE__ */ y(V, {
1419
+ /* @__PURE__ */ b(V, {
1415
1420
  open: C !== null,
1416
1421
  title: i.removeTitle,
1417
1422
  destructive: !0,
1418
1423
  confirmLabel: i.remove,
1419
1424
  onConfirm: j,
1420
1425
  onCancel: () => w(null),
1421
- children: /* @__PURE__ */ y("p", { children: i.removeBody })
1426
+ children: /* @__PURE__ */ b("p", { children: i.removeBody })
1422
1427
  })
1423
1428
  ]
1424
1429
  });
1425
1430
  }
1426
1431
  // src/views/products/product-fields.tsx
1427
- function Y({ name: e, label: t, error: n, help: r, children: i }) {
1432
+ function X({ name: e, label: t, error: n, help: r, children: i }) {
1428
1433
  let a = `sfa-field-${e}`, o = [r ? `${a}-help` : "", n ? `${a}-error` : ""].filter(Boolean).join(" ");
1429
- return /* @__PURE__ */ b("div", {
1434
+ return /* @__PURE__ */ x("div", {
1430
1435
  className: "sfa-field",
1431
1436
  children: [
1432
- /* @__PURE__ */ y("label", {
1437
+ /* @__PURE__ */ b("label", {
1433
1438
  htmlFor: a,
1434
1439
  className: "sfa-field__label",
1435
1440
  children: t
@@ -1440,12 +1445,12 @@ function Y({ name: e, label: t, error: n, help: r, children: i }) {
1440
1445
  "aria-invalid": !!n,
1441
1446
  "aria-describedby": o || void 0
1442
1447
  }),
1443
- r ? /* @__PURE__ */ y("p", {
1448
+ r ? /* @__PURE__ */ b("p", {
1444
1449
  id: `${a}-help`,
1445
1450
  className: "sfa-field__help",
1446
1451
  children: r
1447
1452
  }) : null,
1448
- n ? /* @__PURE__ */ y("p", {
1453
+ n ? /* @__PURE__ */ b("p", {
1449
1454
  id: `${a}-error`,
1450
1455
  className: "sfa-field__error",
1451
1456
  children: n
@@ -1453,32 +1458,32 @@ function Y({ name: e, label: t, error: n, help: r, children: i }) {
1453
1458
  ]
1454
1459
  });
1455
1460
  }
1456
- var Ae = "sfa-field-category-options";
1457
- function je({ form: e, errors: t, labels: n, categories: r, onChange: i }) {
1458
- let a = !!r?.length, o = (r) => /* @__PURE__ */ y(Y, {
1461
+ var je = "sfa-field-category-options";
1462
+ function Me({ form: e, errors: t, labels: n, categories: r, onChange: i }) {
1463
+ let a = !!r?.length, o = (r) => /* @__PURE__ */ b(X, {
1459
1464
  name: r,
1460
1465
  label: n.fields[r],
1461
1466
  error: t[r],
1462
- children: (t) => /* @__PURE__ */ y("input", {
1467
+ children: (t) => /* @__PURE__ */ b("input", {
1463
1468
  ...t,
1464
1469
  type: "text",
1465
- list: r === "category" && a ? Ae : void 0,
1470
+ list: r === "category" && a ? je : void 0,
1466
1471
  value: e[r],
1467
1472
  onChange: (e) => i(r, e.target.value)
1468
1473
  })
1469
1474
  });
1470
- return /* @__PURE__ */ b(v, { children: [
1475
+ return /* @__PURE__ */ x(y, { children: [
1471
1476
  o("name"),
1472
1477
  o("category"),
1473
- a ? /* @__PURE__ */ y("datalist", {
1474
- id: Ae,
1475
- children: r?.map((e) => /* @__PURE__ */ y("option", { value: e }, e))
1478
+ a ? /* @__PURE__ */ b("datalist", {
1479
+ id: je,
1480
+ children: r?.map((e) => /* @__PURE__ */ b("option", { value: e }, e))
1476
1481
  }) : null,
1477
- /* @__PURE__ */ y(Y, {
1482
+ /* @__PURE__ */ b(X, {
1478
1483
  name: "description",
1479
1484
  label: n.fields.description,
1480
1485
  error: t.description,
1481
- children: (t) => /* @__PURE__ */ y("textarea", {
1486
+ children: (t) => /* @__PURE__ */ b("textarea", {
1482
1487
  ...t,
1483
1488
  rows: 5,
1484
1489
  value: e.description,
@@ -1489,19 +1494,19 @@ function je({ form: e, errors: t, labels: n, categories: r, onChange: i }) {
1489
1494
  o("dimensions")
1490
1495
  ] });
1491
1496
  }
1492
- var Me = [
1497
+ var Ne = [
1493
1498
  "draft",
1494
1499
  "active",
1495
1500
  "archived"
1496
1501
  ];
1497
- function Ne({ form: e, errors: t, labels: n, statusLabels: r, onChange: i }) {
1498
- return /* @__PURE__ */ b(v, { children: [
1499
- /* @__PURE__ */ y(Y, {
1502
+ function Pe({ form: e, errors: t, labels: n, statusLabels: r, onChange: i }) {
1503
+ return /* @__PURE__ */ x(y, { children: [
1504
+ /* @__PURE__ */ b(X, {
1500
1505
  name: "price",
1501
1506
  label: n.fields.price,
1502
1507
  error: t.price,
1503
1508
  help: n.priceHelp,
1504
- children: (t) => /* @__PURE__ */ y("input", {
1509
+ children: (t) => /* @__PURE__ */ b("input", {
1505
1510
  ...t,
1506
1511
  type: "text",
1507
1512
  inputMode: "decimal",
@@ -1509,11 +1514,11 @@ function Ne({ form: e, errors: t, labels: n, statusLabels: r, onChange: i }) {
1509
1514
  onChange: (e) => i("price", e.target.value)
1510
1515
  })
1511
1516
  }),
1512
- /* @__PURE__ */ y(Y, {
1517
+ /* @__PURE__ */ b(X, {
1513
1518
  name: "quantity",
1514
1519
  label: n.fields.quantity,
1515
1520
  error: t.quantity,
1516
- children: (t) => /* @__PURE__ */ y("input", {
1521
+ children: (t) => /* @__PURE__ */ b("input", {
1517
1522
  ...t,
1518
1523
  type: "text",
1519
1524
  inputMode: "numeric",
@@ -1521,78 +1526,78 @@ function Ne({ form: e, errors: t, labels: n, statusLabels: r, onChange: i }) {
1521
1526
  onChange: (e) => i("quantity", e.target.value)
1522
1527
  })
1523
1528
  }),
1524
- /* @__PURE__ */ y(Y, {
1529
+ /* @__PURE__ */ b(X, {
1525
1530
  name: "status",
1526
1531
  label: n.fields.status,
1527
1532
  error: t.status,
1528
1533
  help: n.statusHelp,
1529
- children: (t) => /* @__PURE__ */ y("select", {
1534
+ children: (t) => /* @__PURE__ */ b("select", {
1530
1535
  ...t,
1531
1536
  value: e.status,
1532
1537
  onChange: (e) => i("status", e.target.value),
1533
- children: Me.map((e) => /* @__PURE__ */ y("option", {
1538
+ children: Ne.map((e) => /* @__PURE__ */ b("option", {
1534
1539
  value: e,
1535
1540
  children: r[e] ?? e
1536
1541
  }, e))
1537
1542
  })
1538
1543
  }),
1539
- /* @__PURE__ */ y("div", {
1544
+ /* @__PURE__ */ b("div", {
1540
1545
  className: "sfa-field",
1541
- children: /* @__PURE__ */ b("label", {
1546
+ children: /* @__PURE__ */ x("label", {
1542
1547
  className: "sfa-check",
1543
1548
  htmlFor: "sfa-field-featured",
1544
- children: [/* @__PURE__ */ y("input", {
1549
+ children: [/* @__PURE__ */ b("input", {
1545
1550
  id: "sfa-field-featured",
1546
1551
  name: "featured",
1547
1552
  type: "checkbox",
1548
1553
  checked: e.featured,
1549
1554
  onChange: (e) => i("featured", e.target.checked)
1550
- }), /* @__PURE__ */ y("span", { children: n.fields.featured })]
1555
+ }), /* @__PURE__ */ b("span", { children: n.fields.featured })]
1551
1556
  })
1552
1557
  })
1553
1558
  ] });
1554
1559
  }
1555
1560
  // src/views/products/admin-product-editor.tsx
1556
- function Pe({ productId: e, onSaved: t, imagesSlot: n, categories: r }) {
1557
- return e ? /* @__PURE__ */ y(Fe, {
1561
+ function Fe({ productId: e, onSaved: t, imagesSlot: n, categories: r }) {
1562
+ return e ? /* @__PURE__ */ b(Ie, {
1558
1563
  productId: e,
1559
1564
  onSaved: t,
1560
1565
  imagesSlot: n,
1561
1566
  categories: r
1562
- }) : /* @__PURE__ */ y(Ie, {
1567
+ }) : /* @__PURE__ */ b(Le, {
1563
1568
  product: void 0,
1564
1569
  onSaved: t,
1565
1570
  imagesSlot: null,
1566
1571
  categories: r
1567
1572
  });
1568
1573
  }
1569
- function Fe({ productId: e, onSaved: t, imagesSlot: n, categories: r }) {
1574
+ function Ie({ productId: e, onSaved: t, imagesSlot: n, categories: r }) {
1570
1575
  let i = F(), { labels: a } = P(), o = I(["admin-product", e], () => i.getProduct(e));
1571
- return o.error ? /* @__PURE__ */ y(U, { error: o.error }) : o.data ? /* @__PURE__ */ y(Ie, {
1576
+ return o.error ? /* @__PURE__ */ b(U, { error: o.error }) : o.data ? /* @__PURE__ */ b(Le, {
1572
1577
  product: o.data,
1573
1578
  onSaved: t,
1574
1579
  imagesSlot: n,
1575
1580
  categories: r
1576
- }, o.data.id) : /* @__PURE__ */ y("p", { children: a.loading });
1581
+ }, o.data.id) : /* @__PURE__ */ b("p", { children: a.loading });
1577
1582
  }
1578
- function Ie({ product: e, onSaved: t, imagesSlot: n, categories: r }) {
1579
- let i = F(), { labels: a } = P(), o = a.products, [s, c] = _(e), [u, d] = _(e ? he(e) : me), [f, p] = _({}), [m, h] = _(!1), g = (e, t) => {
1583
+ function Le({ product: e, onSaved: t, imagesSlot: n, categories: r }) {
1584
+ let i = F(), { labels: a } = P(), o = a.products, [s, c] = v(e), [l, d] = v(e ? ge(e) : he), [f, p] = v({}), [m, h] = v(!1), g = (e, t) => {
1580
1585
  p(t);
1581
- let n = ve(t);
1586
+ let n = ye(t);
1582
1587
  n && e.elements.namedItem(n)?.focus();
1583
- }, v = L(async (e) => {
1584
- let t = be(u, o, s?.currency);
1588
+ }, _ = L(async (e) => {
1589
+ let t = xe(l, o, s?.currency);
1585
1590
  if (!t.ok) g(e, t.errors);
1586
1591
  else try {
1587
1592
  if (!s) return await i.createProduct(t.input);
1588
- let e = Se(s, t.input);
1593
+ let e = Ce(s, t.input);
1589
1594
  return Object.keys(e).length === 0 ? s : await i.updateProduct(s.id, e);
1590
1595
  } catch (t) {
1591
- if (!(t instanceof l)) throw t;
1592
- g(e, _e(t.issues));
1596
+ if (!(t instanceof u)) throw t;
1597
+ g(e, ve(t.issues));
1593
1598
  return;
1594
1599
  }
1595
- }), x = (e, t) => {
1600
+ }), y = (e, t) => {
1596
1601
  d((n) => ({
1597
1602
  ...n,
1598
1603
  [e]: t
@@ -1601,41 +1606,41 @@ function Ie({ product: e, onSaved: t, imagesSlot: n, categories: r }) {
1601
1606
  [e]: void 0
1602
1607
  }));
1603
1608
  }, S = async (e) => {
1604
- e.preventDefault(), h(!1), p({}), v.reset();
1605
- let n = await v.run(e.currentTarget);
1606
- n && (c(n), d(he(n)), h(!0), t?.(n));
1607
- }, C = e ? n ?? /* @__PURE__ */ y(ke, {
1609
+ e.preventDefault(), h(!1), p({}), _.reset();
1610
+ let n = await _.run(e.currentTarget);
1611
+ n && (c(n), d(ge(n)), h(!0), t?.(n));
1612
+ }, C = e ? n ?? /* @__PURE__ */ b(Ae, {
1608
1613
  productId: e.id,
1609
1614
  images: e.images
1610
1615
  }) : null, w = {
1611
- form: u,
1616
+ form: l,
1612
1617
  errors: f,
1613
1618
  labels: o,
1614
1619
  statusLabels: a.statuses,
1615
1620
  categories: r,
1616
- onChange: x
1621
+ onChange: y
1617
1622
  };
1618
- return /* @__PURE__ */ b("form", {
1623
+ return /* @__PURE__ */ x("form", {
1619
1624
  noValidate: !0,
1620
1625
  className: "sfa-form",
1621
1626
  onSubmit: S,
1622
1627
  children: [
1623
- /* @__PURE__ */ y("h1", { children: e ? o.editTitle : o.createTitle }),
1624
- /* @__PURE__ */ y(U, { error: v.error }),
1625
- /* @__PURE__ */ y(je, { ...w }),
1626
- /* @__PURE__ */ y(Ne, { ...w }),
1627
- C ? /* @__PURE__ */ y("section", {
1628
+ /* @__PURE__ */ b("h1", { children: e ? o.editTitle : o.createTitle }),
1629
+ /* @__PURE__ */ b(U, { error: _.error }),
1630
+ /* @__PURE__ */ b(Me, { ...w }),
1631
+ /* @__PURE__ */ b(Pe, { ...w }),
1632
+ C ? /* @__PURE__ */ b("section", {
1628
1633
  "data-slot": "images",
1629
1634
  className: "sfa-form__images",
1630
1635
  children: C
1631
1636
  }) : null,
1632
- /* @__PURE__ */ y("button", {
1637
+ /* @__PURE__ */ b("button", {
1633
1638
  type: "submit",
1634
1639
  className: "sfa-btn sfa-btn--primary",
1635
- disabled: v.pending,
1640
+ disabled: _.pending,
1636
1641
  children: a.save
1637
1642
  }),
1638
- m ? /* @__PURE__ */ y(H, {
1643
+ m ? /* @__PURE__ */ b(H, {
1639
1644
  variant: "success",
1640
1645
  toast: !0,
1641
1646
  onDismiss: () => h(!1),
@@ -1645,43 +1650,27 @@ function Ie({ product: e, onSaved: t, imagesSlot: n, categories: r }) {
1645
1650
  });
1646
1651
  }
1647
1652
  // src/lib/use-order-pages.ts
1648
- function Le(e) {
1649
- let t = F(), n = I(["admin-orders", e], () => t.listOrders(e)), [r, i] = _(null), a = L(async (n, r) => {
1650
- let a = await t.listOrders({
1651
- ...e,
1652
- cursor: n
1653
- });
1654
- i((e) => ({
1655
- base: r,
1656
- items: [...e?.base === r ? e.items : [], ...a.items],
1657
- nextCursor: a.nextCursor
1658
- }));
1659
- }), o = n.data, s = r && r.base === o ? r : null, c = s ? s.nextCursor : o?.nextCursor ?? null;
1660
- return {
1661
- items: [...o?.items ?? [], ...s?.items ?? []],
1662
- loading: n.loading,
1663
- error: n.error ?? a.error,
1664
- hasMore: !n.loading && c !== null,
1665
- loadingMore: a.pending,
1666
- loadMore: () => {
1667
- o && c && a.run(c, o);
1668
- }
1669
- };
1653
+ function Re(e) {
1654
+ let t = F();
1655
+ return G(["admin-orders", e], (n) => t.listOrders(n ? {
1656
+ ...e,
1657
+ cursor: n
1658
+ } : e));
1670
1659
  }
1671
1660
  // src/views/orders/admin-order-list.tsx
1672
- var Re = [
1661
+ var ze = [
1673
1662
  "paid",
1674
1663
  "shipped",
1675
1664
  "needs_attention",
1676
1665
  "pending_refund",
1677
1666
  "all"
1678
1667
  ];
1679
- function ze(e) {
1668
+ function Be(e) {
1680
1669
  return e === "pending_refund" ? { hasPendingRefund: !0 } : e === "all" ? {} : { status: e };
1681
1670
  }
1682
- function Be() {
1683
- let { labels: e, locale: t, hrefs: n, renderLink: r } = P(), i = e.orders, [a, o] = _("paid"), [s, c] = _(""), l = W(s.trim(), 300), u = Le({
1684
- ...ze(a),
1671
+ function Ve() {
1672
+ let { labels: e, locale: t, hrefs: n, renderLink: r } = P(), i = e.orders, [a, o] = v("paid"), [s, c] = v(""), l = W(s.trim(), 300), u = Re({
1673
+ ...Be(a),
1685
1674
  ...l ? { q: l } : {}
1686
1675
  }), d = new Intl.DateTimeFormat(t), f = [
1687
1676
  {
@@ -1696,7 +1685,7 @@ function Be() {
1696
1685
  {
1697
1686
  key: "status",
1698
1687
  header: i.columns.status,
1699
- render: (e) => /* @__PURE__ */ y(z, { status: e.status })
1688
+ render: (e) => /* @__PURE__ */ b(z, { status: e.status })
1700
1689
  },
1701
1690
  {
1702
1691
  key: "email",
@@ -1711,7 +1700,7 @@ function Be() {
1711
1700
  {
1712
1701
  key: "total",
1713
1702
  header: i.columns.total,
1714
- render: (e) => /* @__PURE__ */ y(B, {
1703
+ render: (e) => /* @__PURE__ */ b(B, {
1715
1704
  cents: e.totalCents,
1716
1705
  currency: e.currency
1717
1706
  })
@@ -1722,24 +1711,24 @@ function Be() {
1722
1711
  render: (e) => d.format(new Date(e.createdAt))
1723
1712
  }
1724
1713
  ];
1725
- return /* @__PURE__ */ b("section", {
1714
+ return /* @__PURE__ */ x("section", {
1726
1715
  className: "sfa-orders",
1727
1716
  children: [
1728
- /* @__PURE__ */ y("h1", { children: i.title }),
1729
- /* @__PURE__ */ b("div", {
1717
+ /* @__PURE__ */ b("h1", { children: i.title }),
1718
+ /* @__PURE__ */ x("div", {
1730
1719
  className: "sfa-orders__toolbar",
1731
- children: [/* @__PURE__ */ y("div", {
1720
+ children: [/* @__PURE__ */ b("div", {
1732
1721
  role: "group",
1733
1722
  "aria-label": i.columns.status,
1734
1723
  className: "sfa-filter-group",
1735
- children: Re.map((e) => /* @__PURE__ */ y("button", {
1724
+ children: ze.map((e) => /* @__PURE__ */ b("button", {
1736
1725
  type: "button",
1737
1726
  className: "sfa-btn sfa-filter",
1738
1727
  "aria-pressed": a === e,
1739
1728
  onClick: () => o(e),
1740
1729
  children: i.tabs[e]
1741
1730
  }, e))
1742
- }), /* @__PURE__ */ y("input", {
1731
+ }), /* @__PURE__ */ b("input", {
1743
1732
  type: "search",
1744
1733
  "aria-label": i.searchLabel,
1745
1734
  placeholder: i.searchPlaceholder,
@@ -1747,16 +1736,16 @@ function Be() {
1747
1736
  onChange: (e) => c(e.target.value)
1748
1737
  })]
1749
1738
  }),
1750
- /* @__PURE__ */ y(U, { error: u.error }),
1751
- u.loading ? /* @__PURE__ */ y("p", { children: e.loading }) : u.items.length === 0 ? /* @__PURE__ */ y("p", {
1739
+ /* @__PURE__ */ b(U, { error: u.error }),
1740
+ u.loading ? /* @__PURE__ */ b("p", { children: e.loading }) : u.items.length === 0 ? /* @__PURE__ */ b("p", {
1752
1741
  className: "sfa-empty",
1753
1742
  children: l ? i.noMatches : i.empty[a]
1754
- }) : /* @__PURE__ */ y(R, {
1743
+ }) : /* @__PURE__ */ b(R, {
1755
1744
  columns: f,
1756
1745
  rows: u.items,
1757
1746
  rowKey: (e) => e.id
1758
1747
  }),
1759
- u.hasMore ? /* @__PURE__ */ y("button", {
1748
+ u.hasMore ? /* @__PURE__ */ b("button", {
1760
1749
  type: "button",
1761
1750
  className: "sfa-btn sfa-orders__more",
1762
1751
  disabled: u.loadingMore,
@@ -1767,55 +1756,55 @@ function Be() {
1767
1756
  });
1768
1757
  }
1769
1758
  // src/lib/refund-rules.ts
1770
- function Ve(e) {
1759
+ function He(e) {
1771
1760
  return e.refunds.filter((e) => e.status === "pending").reduce((e, t) => e + t.amountCents, 0);
1772
1761
  }
1773
- function X(e) {
1774
- return e.totalCents - e.refundedCents - Ve(e);
1762
+ function Z(e) {
1763
+ return e.totalCents - e.refundedCents - He(e);
1775
1764
  }
1776
- function He(e) {
1765
+ function Ue(e) {
1777
1766
  return e.refunds.some((e) => e.status === "pending");
1778
1767
  }
1779
- function Ue(e, t) {
1780
- return e.status !== "needs_attention" && t !== null && t === X(e);
1768
+ function We(e, t) {
1769
+ return e.status !== "needs_attention" && t !== null && t === Z(e);
1781
1770
  }
1782
- function We(e) {
1771
+ function Ge(e) {
1783
1772
  return e.status === "paid" || e.status === "shipped";
1784
1773
  }
1785
- function Ge(e) {
1786
- return (We(e) || e.status === "needs_attention") && X(e) > 0;
1774
+ function Ke(e) {
1775
+ return (Ge(e) || e.status === "needs_attention") && Z(e) > 0;
1787
1776
  }
1788
1777
  // src/views/orders/refund-dialog.tsx
1789
- function Ke({ order: e, onClose: t, onDone: n }) {
1790
- let r = F(), i = P().labels.orders.actions, a = g(crypto.randomUUID()), s = X(e), [l, u] = _(K(s)), [d, f] = _(""), [p, m] = _(!1), [h, v] = _(!1), x = L(r.refundOrder), S = G(l), C = S !== null && S > 0 && S <= s, w = Ue(e, S), T = x.error instanceof c || x.error instanceof o;
1791
- return /* @__PURE__ */ b(V, {
1778
+ function qe({ order: e, onClose: t, onDone: n }) {
1779
+ let r = F(), a = P().labels.orders.actions, o = _(crypto.randomUUID()), c = Z(e), [l, u] = v(q(c)), [d, f] = v(""), [p, m] = v(!1), [h, g] = v(!1), y = L(r.refundOrder), S = K(l), C = S !== null && S > 0 && S <= c, w = We(e, S), T = y.error instanceof s || y.error instanceof i;
1780
+ return /* @__PURE__ */ x(V, {
1792
1781
  open: !0,
1793
- title: i.refundTitle,
1794
- confirmLabel: T ? i.refundRetry : i.refundSubmit,
1782
+ title: a.refundTitle,
1783
+ confirmLabel: T ? a.refundRetry : a.refundSubmit,
1795
1784
  destructive: !0,
1796
- pending: x.pending,
1785
+ pending: y.pending,
1797
1786
  onConfirm: async () => {
1798
- C ? (v(!1), await x.run(e.id, {
1787
+ C ? (g(!1), await y.run(e.id, {
1799
1788
  amountCents: S,
1800
1789
  reason: d.trim() || void 0,
1801
1790
  restock: p && w
1802
- }, { idempotencyKey: a.current }) && n(i.refundDone)) : v(!0);
1791
+ }, { idempotencyKey: o.current }) && n(a.refundDone)) : g(!0);
1803
1792
  },
1804
1793
  onCancel: t,
1805
1794
  children: [
1806
- He(e) ? /* @__PURE__ */ y(H, {
1795
+ Ue(e) ? /* @__PURE__ */ b(H, {
1807
1796
  variant: "warning",
1808
- children: i.refundPending
1797
+ children: a.refundPending
1809
1798
  }) : null,
1810
- /* @__PURE__ */ b("div", {
1799
+ /* @__PURE__ */ x("div", {
1811
1800
  className: "sfa-field",
1812
1801
  children: [
1813
- /* @__PURE__ */ y("label", {
1802
+ /* @__PURE__ */ b("label", {
1814
1803
  htmlFor: "sfa-refund-amount",
1815
1804
  className: "sfa-field__label",
1816
- children: i.refundAmount
1805
+ children: a.refundAmount
1817
1806
  }),
1818
- /* @__PURE__ */ y("input", {
1807
+ /* @__PURE__ */ b("input", {
1819
1808
  id: "sfa-refund-amount",
1820
1809
  inputMode: "decimal",
1821
1810
  value: l,
@@ -1823,19 +1812,19 @@ function Ke({ order: e, onClose: t, onDone: n }) {
1823
1812
  "aria-invalid": h && !C,
1824
1813
  onChange: (e) => u(e.target.value)
1825
1814
  }),
1826
- h && !C ? /* @__PURE__ */ y("p", {
1815
+ h && !C ? /* @__PURE__ */ b("p", {
1827
1816
  className: "sfa-field__error",
1828
- children: i.refundAmountInvalid
1817
+ children: a.refundAmountInvalid
1829
1818
  }) : null
1830
1819
  ]
1831
1820
  }),
1832
- /* @__PURE__ */ b("div", {
1821
+ /* @__PURE__ */ x("div", {
1833
1822
  className: "sfa-field",
1834
- children: [/* @__PURE__ */ y("label", {
1823
+ children: [/* @__PURE__ */ b("label", {
1835
1824
  htmlFor: "sfa-refund-reason",
1836
1825
  className: "sfa-field__label",
1837
- children: i.refundReason
1838
- }), /* @__PURE__ */ y("textarea", {
1826
+ children: a.refundReason
1827
+ }), /* @__PURE__ */ b("textarea", {
1839
1828
  id: "sfa-refund-reason",
1840
1829
  maxLength: 500,
1841
1830
  value: d,
@@ -1843,50 +1832,50 @@ function Ke({ order: e, onClose: t, onDone: n }) {
1843
1832
  onChange: (e) => f(e.target.value)
1844
1833
  })]
1845
1834
  }),
1846
- w ? /* @__PURE__ */ b("div", {
1835
+ w ? /* @__PURE__ */ x("div", {
1847
1836
  className: "sfa-field",
1848
- children: [/* @__PURE__ */ b("label", { children: [
1849
- /* @__PURE__ */ y("input", {
1837
+ children: [/* @__PURE__ */ x("label", { children: [
1838
+ /* @__PURE__ */ b("input", {
1850
1839
  type: "checkbox",
1851
1840
  checked: p,
1852
1841
  disabled: T,
1853
1842
  onChange: (e) => m(e.target.checked)
1854
1843
  }),
1855
1844
  " ",
1856
- i.restock
1857
- ] }), /* @__PURE__ */ y("p", {
1845
+ a.restock
1846
+ ] }), /* @__PURE__ */ b("p", {
1858
1847
  className: "sfa-field__help",
1859
- children: i.restockWarning
1848
+ children: a.restockWarning
1860
1849
  })]
1861
1850
  }) : null,
1862
- x.error instanceof o ? /* @__PURE__ */ y(H, {
1851
+ y.error instanceof i ? /* @__PURE__ */ b(H, {
1863
1852
  variant: "warning",
1864
- children: i.refundUnknown
1865
- }) : x.error instanceof c ? /* @__PURE__ */ y(H, {
1853
+ children: a.refundUnknown
1854
+ }) : y.error instanceof s ? /* @__PURE__ */ b(H, {
1866
1855
  variant: "warning",
1867
- children: i.refundGateway
1868
- }) : /* @__PURE__ */ y(U, { error: x.error })
1856
+ children: a.refundGateway
1857
+ }) : /* @__PURE__ */ b(U, { error: y.error })
1869
1858
  ]
1870
1859
  });
1871
1860
  }
1872
1861
  // src/views/orders/resolve-button.tsx
1873
- function qe({ order: e, onDone: t }) {
1874
- let n = F(), { labels: r, hrefs: i, renderLink: o } = P(), s = r.orders.actions, c = L(n.resolveOrder), l = async () => {
1862
+ function Je({ order: e, onDone: t }) {
1863
+ let n = F(), { labels: r, hrefs: i, renderLink: a } = P(), s = r.orders.actions, c = L(n.resolveOrder), l = async () => {
1875
1864
  await c.run(e.id) && t(s.resolved);
1876
- }, u = c.error instanceof a ? c.error : null, d = new Map(e.items.map((e) => [e.productId, e.name]));
1877
- return /* @__PURE__ */ b("div", {
1865
+ }, u = c.error instanceof o ? c.error : null, d = new Map(e.items.map((e) => [e.productId, e.name]));
1866
+ return /* @__PURE__ */ x("div", {
1878
1867
  className: "sfa-order__action",
1879
1868
  children: [
1880
- /* @__PURE__ */ y("p", { children: s.resolveHelp }),
1881
- u ? /* @__PURE__ */ b(H, {
1869
+ /* @__PURE__ */ b("p", { children: s.resolveHelp }),
1870
+ u ? /* @__PURE__ */ x(H, {
1882
1871
  variant: "error",
1883
- children: [r.errors.insufficientStock, /* @__PURE__ */ y("ul", { children: u.productIds.map((e) => /* @__PURE__ */ y("li", { children: o({
1872
+ children: [r.errors.insufficientStock, /* @__PURE__ */ b("ul", { children: u.productIds.map((e) => /* @__PURE__ */ b("li", { children: a({
1884
1873
  href: i.product(e),
1885
1874
  children: `${s.restockThenResolve}: ${d.get(e) ?? e}`,
1886
1875
  className: "sfa-link--tap"
1887
1876
  }) }, e)) })]
1888
- }) : /* @__PURE__ */ y(U, { error: c.error }),
1889
- /* @__PURE__ */ y("button", {
1877
+ }) : /* @__PURE__ */ b(U, { error: c.error }),
1878
+ /* @__PURE__ */ b("button", {
1890
1879
  type: "button",
1891
1880
  className: "sfa-btn sfa-btn--primary",
1892
1881
  disabled: c.pending,
@@ -1897,7 +1886,7 @@ function qe({ order: e, onDone: t }) {
1897
1886
  });
1898
1887
  }
1899
1888
  // src/views/orders/ship-form.tsx
1900
- function Je(e) {
1889
+ function Ye(e) {
1901
1890
  try {
1902
1891
  let { protocol: t } = new URL(e);
1903
1892
  return t === "http:" || t === "https:";
@@ -1905,69 +1894,69 @@ function Je(e) {
1905
1894
  return !1;
1906
1895
  }
1907
1896
  }
1908
- function Ye({ order: e, onDone: t }) {
1909
- let n = F(), r = P().labels.orders.actions, i = e.fulfillment, [a, o] = _(i?.carrier ?? ""), [s, c] = _(i?.trackingNumber ?? ""), [l, u] = _(i?.trackingUrl ?? ""), [d, f] = _(!1), p = L(n.shipOrder), m = e.status === "shipped";
1910
- return /* @__PURE__ */ b("form", {
1897
+ function Xe({ order: e, onDone: t }) {
1898
+ let n = F(), r = P().labels.orders.actions, i = e.fulfillment, [a, o] = v(i?.carrier ?? ""), [s, c] = v(i?.trackingNumber ?? ""), [l, u] = v(i?.trackingUrl ?? ""), [d, f] = v(!1), p = L(n.shipOrder), m = e.status === "shipped";
1899
+ return /* @__PURE__ */ x("form", {
1911
1900
  className: "sfa-order__action",
1912
1901
  onSubmit: async (n) => {
1913
1902
  n.preventDefault();
1914
1903
  let i = l.trim();
1915
- i && !Je(i) ? f(!0) : (f(!1), await p.run(e.id, {
1904
+ i && !Ye(i) ? f(!0) : (f(!1), await p.run(e.id, {
1916
1905
  carrier: a.trim() || void 0,
1917
1906
  trackingNumber: s.trim() || void 0,
1918
1907
  trackingUrl: i || void 0
1919
1908
  }) && t(r.shipped));
1920
1909
  },
1921
1910
  children: [
1922
- /* @__PURE__ */ y("h3", { children: r.shipHeading }),
1923
- /* @__PURE__ */ b("div", {
1911
+ /* @__PURE__ */ b("h3", { children: r.shipHeading }),
1912
+ /* @__PURE__ */ x("div", {
1924
1913
  className: "sfa-field",
1925
- children: [/* @__PURE__ */ y("label", {
1914
+ children: [/* @__PURE__ */ b("label", {
1926
1915
  htmlFor: "sfa-ship-carrier",
1927
1916
  className: "sfa-field__label",
1928
1917
  children: r.carrier
1929
- }), /* @__PURE__ */ y("input", {
1918
+ }), /* @__PURE__ */ b("input", {
1930
1919
  id: "sfa-ship-carrier",
1931
1920
  value: a,
1932
1921
  onChange: (e) => o(e.target.value)
1933
1922
  })]
1934
1923
  }),
1935
- /* @__PURE__ */ b("div", {
1924
+ /* @__PURE__ */ x("div", {
1936
1925
  className: "sfa-field",
1937
- children: [/* @__PURE__ */ y("label", {
1926
+ children: [/* @__PURE__ */ b("label", {
1938
1927
  htmlFor: "sfa-ship-number",
1939
1928
  className: "sfa-field__label",
1940
1929
  children: r.trackingNumber
1941
- }), /* @__PURE__ */ y("input", {
1930
+ }), /* @__PURE__ */ b("input", {
1942
1931
  id: "sfa-ship-number",
1943
1932
  value: s,
1944
1933
  onChange: (e) => c(e.target.value)
1945
1934
  })]
1946
1935
  }),
1947
- /* @__PURE__ */ b("div", {
1936
+ /* @__PURE__ */ x("div", {
1948
1937
  className: "sfa-field",
1949
1938
  children: [
1950
- /* @__PURE__ */ y("label", {
1939
+ /* @__PURE__ */ b("label", {
1951
1940
  htmlFor: "sfa-ship-url",
1952
1941
  className: "sfa-field__label",
1953
1942
  children: r.trackingUrl
1954
1943
  }),
1955
- /* @__PURE__ */ y("input", {
1944
+ /* @__PURE__ */ b("input", {
1956
1945
  id: "sfa-ship-url",
1957
1946
  value: l,
1958
1947
  "aria-invalid": d,
1959
1948
  "aria-describedby": d ? "sfa-ship-url-error" : void 0,
1960
1949
  onChange: (e) => u(e.target.value)
1961
1950
  }),
1962
- d ? /* @__PURE__ */ y("p", {
1951
+ d ? /* @__PURE__ */ b("p", {
1963
1952
  id: "sfa-ship-url-error",
1964
1953
  className: "sfa-field__error",
1965
1954
  children: r.trackingUrlInvalid
1966
1955
  }) : null
1967
1956
  ]
1968
1957
  }),
1969
- /* @__PURE__ */ y(U, { error: p.error }),
1970
- /* @__PURE__ */ y("button", {
1958
+ /* @__PURE__ */ b(U, { error: p.error }),
1959
+ /* @__PURE__ */ b("button", {
1971
1960
  type: "submit",
1972
1961
  className: "sfa-btn sfa-btn--primary",
1973
1962
  disabled: p.pending,
@@ -1977,33 +1966,33 @@ function Ye({ order: e, onDone: t }) {
1977
1966
  });
1978
1967
  }
1979
1968
  // src/views/orders/order-actions.tsx
1980
- function Xe({ order: e, reload: t }) {
1981
- let n = P().labels.orders.actions, [r, i] = _(!1), [a, o] = _(null), s = (e) => {
1969
+ function Ze({ order: e, reload: t }) {
1970
+ let n = P().labels.orders.actions, [r, i] = v(!1), [a, o] = v(null), s = (e) => {
1982
1971
  i(!1), o(e), t();
1983
1972
  };
1984
- return /* @__PURE__ */ b("div", {
1973
+ return /* @__PURE__ */ x("div", {
1985
1974
  className: "sfa-order__actions",
1986
1975
  children: [
1987
- a ? /* @__PURE__ */ y(H, {
1976
+ a ? /* @__PURE__ */ b(H, {
1988
1977
  variant: "success",
1989
1978
  onDismiss: () => o(null),
1990
1979
  children: a
1991
1980
  }) : null,
1992
- We(e) ? /* @__PURE__ */ y(Ye, {
1981
+ Ge(e) ? /* @__PURE__ */ b(Xe, {
1993
1982
  order: e,
1994
1983
  onDone: s
1995
1984
  }) : null,
1996
- e.status === "needs_attention" ? /* @__PURE__ */ y(qe, {
1985
+ e.status === "needs_attention" ? /* @__PURE__ */ b(Je, {
1997
1986
  order: e,
1998
1987
  onDone: s
1999
1988
  }) : null,
2000
- Ge(e) ? /* @__PURE__ */ y("button", {
1989
+ Ke(e) ? /* @__PURE__ */ b("button", {
2001
1990
  type: "button",
2002
1991
  className: "sfa-btn sfa-btn--danger",
2003
1992
  onClick: () => i(!0),
2004
1993
  children: n.refund
2005
1994
  }) : null,
2006
- r ? /* @__PURE__ */ y(Ke, {
1995
+ r ? /* @__PURE__ */ b(qe, {
2007
1996
  order: e,
2008
1997
  onClose: () => {
2009
1998
  i(!1), t();
@@ -2014,25 +2003,25 @@ function Xe({ order: e, reload: t }) {
2014
2003
  });
2015
2004
  }
2016
2005
  // src/views/orders/order-fulfillment.tsx
2017
- function Ze({ order: e }) {
2006
+ function Qe({ order: e }) {
2018
2007
  let { labels: t, locale: n, renderLink: r } = P(), i = t.orders, a = e.fulfillment;
2019
- return /* @__PURE__ */ b("section", {
2008
+ return /* @__PURE__ */ x("section", {
2020
2009
  className: "sfa-order__section",
2021
- children: [/* @__PURE__ */ y("h2", { children: i.fulfillment }), a ? /* @__PURE__ */ b("dl", { children: [
2022
- /* @__PURE__ */ y("dt", { children: i.shippedOn }),
2023
- /* @__PURE__ */ y("dd", { children: new Intl.DateTimeFormat(n).format(new Date(a.shippedAt)) }),
2024
- a.carrier ? /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("dt", { children: i.carrier }), /* @__PURE__ */ y("dd", { children: a.carrier })] }) : null,
2025
- a.trackingNumber ? /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("dt", { children: i.tracking }), /* @__PURE__ */ y("dd", { children: a.trackingNumber })] }) : null,
2026
- a.trackingUrl ? /* @__PURE__ */ y("dd", { children: r({
2010
+ children: [/* @__PURE__ */ b("h2", { children: i.fulfillment }), a ? /* @__PURE__ */ x("dl", { children: [
2011
+ /* @__PURE__ */ b("dt", { children: i.shippedOn }),
2012
+ /* @__PURE__ */ b("dd", { children: new Intl.DateTimeFormat(n).format(new Date(a.shippedAt)) }),
2013
+ a.carrier ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("dt", { children: i.carrier }), /* @__PURE__ */ b("dd", { children: a.carrier })] }) : null,
2014
+ a.trackingNumber ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("dt", { children: i.tracking }), /* @__PURE__ */ b("dd", { children: a.trackingNumber })] }) : null,
2015
+ a.trackingUrl ? /* @__PURE__ */ b("dd", { children: r({
2027
2016
  href: a.trackingUrl,
2028
2017
  children: i.trackShipment,
2029
2018
  className: "sfa-link--tap"
2030
2019
  }) }) : null
2031
- ] }) : /* @__PURE__ */ y("p", { children: i.notShipped })]
2020
+ ] }) : /* @__PURE__ */ b("p", { children: i.notShipped })]
2032
2021
  });
2033
2022
  }
2034
2023
  // src/views/orders/order-items.tsx
2035
- function Qe({ order: e }) {
2024
+ function $e({ order: e }) {
2036
2025
  let { labels: t } = P(), n = t.orders, { currency: r } = e, i = [
2037
2026
  {
2038
2027
  key: "name",
@@ -2042,7 +2031,7 @@ function Qe({ order: e }) {
2042
2031
  {
2043
2032
  key: "price",
2044
2033
  header: n.itemColumns.price,
2045
- render: (e) => /* @__PURE__ */ y(B, {
2034
+ render: (e) => /* @__PURE__ */ b(B, {
2046
2035
  cents: e.priceCents,
2047
2036
  currency: r
2048
2037
  })
@@ -2055,40 +2044,40 @@ function Qe({ order: e }) {
2055
2044
  {
2056
2045
  key: "line",
2057
2046
  header: n.itemColumns.line,
2058
- render: (e) => /* @__PURE__ */ y(B, {
2047
+ render: (e) => /* @__PURE__ */ b(B, {
2059
2048
  cents: e.priceCents * e.quantity,
2060
2049
  currency: r
2061
2050
  })
2062
2051
  }
2063
2052
  ];
2064
- return /* @__PURE__ */ b("section", {
2053
+ return /* @__PURE__ */ x("section", {
2065
2054
  className: "sfa-order__section",
2066
2055
  children: [
2067
- /* @__PURE__ */ y("h2", { children: n.itemsHeading }),
2068
- /* @__PURE__ */ y(R, {
2056
+ /* @__PURE__ */ b("h2", { children: n.itemsHeading }),
2057
+ /* @__PURE__ */ b(R, {
2069
2058
  columns: i,
2070
2059
  rows: e.items,
2071
2060
  rowKey: (e) => e.productId
2072
2061
  }),
2073
- /* @__PURE__ */ b("dl", {
2062
+ /* @__PURE__ */ x("dl", {
2074
2063
  className: "sfa-order__totals",
2075
2064
  children: [
2076
- /* @__PURE__ */ y("dt", { children: n.subtotal }),
2077
- /* @__PURE__ */ y("dd", { children: /* @__PURE__ */ y(B, {
2065
+ /* @__PURE__ */ b("dt", { children: n.subtotal }),
2066
+ /* @__PURE__ */ b("dd", { children: /* @__PURE__ */ b(B, {
2078
2067
  cents: e.subtotalCents,
2079
2068
  currency: r
2080
2069
  }) }),
2081
- e.discountCents > 0 ? /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ b("dt", { children: [t.discounts.orderRow, e.discountCode ? ` (${e.discountCode})` : ""] }), /* @__PURE__ */ b("dd", { children: ["−", /* @__PURE__ */ y(B, {
2070
+ e.discountCents > 0 ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ x("dt", { children: [t.discounts.orderRow, e.discountCode ? ` (${e.discountCode})` : ""] }), /* @__PURE__ */ x("dd", { children: ["−", /* @__PURE__ */ b(B, {
2082
2071
  cents: e.discountCents,
2083
2072
  currency: r
2084
2073
  })] })] }) : null,
2085
- /* @__PURE__ */ y("dt", { children: e.shippingLabel ?? n.shipping }),
2086
- /* @__PURE__ */ y("dd", { children: /* @__PURE__ */ y(B, {
2074
+ /* @__PURE__ */ b("dt", { children: e.shippingLabel ?? n.shipping }),
2075
+ /* @__PURE__ */ b("dd", { children: /* @__PURE__ */ b(B, {
2087
2076
  cents: e.shippingCents,
2088
2077
  currency: r
2089
2078
  }) }),
2090
- /* @__PURE__ */ y("dt", { children: n.total }),
2091
- /* @__PURE__ */ y("dd", { children: /* @__PURE__ */ y(B, {
2079
+ /* @__PURE__ */ b("dt", { children: n.total }),
2080
+ /* @__PURE__ */ b("dd", { children: /* @__PURE__ */ b(B, {
2092
2081
  cents: e.totalCents,
2093
2082
  currency: r
2094
2083
  }) })
@@ -2098,12 +2087,12 @@ function Qe({ order: e }) {
2098
2087
  });
2099
2088
  }
2100
2089
  // src/views/orders/order-refunds.tsx
2101
- function $e({ order: e }) {
2090
+ function et({ order: e }) {
2102
2091
  let { labels: t, locale: n } = P(), r = t.orders, { currency: i } = e, a = new Intl.DateTimeFormat(n), o = [
2103
2092
  {
2104
2093
  key: "amount",
2105
2094
  header: r.refundColumns.amount,
2106
- render: (e) => /* @__PURE__ */ y(B, {
2095
+ render: (e) => /* @__PURE__ */ b(B, {
2107
2096
  cents: e.amountCents,
2108
2097
  currency: i
2109
2098
  })
@@ -2121,7 +2110,7 @@ function $e({ order: e }) {
2121
2110
  {
2122
2111
  key: "status",
2123
2112
  header: r.refundColumns.status,
2124
- render: (e) => /* @__PURE__ */ y("span", {
2113
+ render: (e) => /* @__PURE__ */ b("span", {
2125
2114
  className: `sfa-badge sfa-badge--refund-${e.status}`,
2126
2115
  "data-refund-status": e.status,
2127
2116
  children: r.refundStatuses[e.status]
@@ -2138,22 +2127,22 @@ function $e({ order: e }) {
2138
2127
  render: (e) => a.format(new Date(e.createdAt))
2139
2128
  }
2140
2129
  ], s = e.totalCents - e.refundedCents;
2141
- return /* @__PURE__ */ b("section", {
2130
+ return /* @__PURE__ */ x("section", {
2142
2131
  className: "sfa-order__section",
2143
- children: [/* @__PURE__ */ y("h2", { children: r.refunds }), e.refunds.length === 0 ? /* @__PURE__ */ y("p", { children: r.noRefunds }) : /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y(R, {
2132
+ children: [/* @__PURE__ */ b("h2", { children: r.refunds }), e.refunds.length === 0 ? /* @__PURE__ */ b("p", { children: r.noRefunds }) : /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(R, {
2144
2133
  columns: o,
2145
2134
  rows: e.refunds,
2146
2135
  rowKey: (e) => e.id
2147
- }), /* @__PURE__ */ b("dl", {
2136
+ }), /* @__PURE__ */ x("dl", {
2148
2137
  className: "sfa-order__totals",
2149
2138
  children: [
2150
- /* @__PURE__ */ y("dt", { children: r.refunded }),
2151
- /* @__PURE__ */ y("dd", { children: /* @__PURE__ */ y(B, {
2139
+ /* @__PURE__ */ b("dt", { children: r.refunded }),
2140
+ /* @__PURE__ */ b("dd", { children: /* @__PURE__ */ b(B, {
2152
2141
  cents: e.refundedCents,
2153
2142
  currency: i
2154
2143
  }) }),
2155
- /* @__PURE__ */ y("dt", { children: r.remaining }),
2156
- /* @__PURE__ */ y("dd", { children: /* @__PURE__ */ y(B, {
2144
+ /* @__PURE__ */ b("dt", { children: r.remaining }),
2145
+ /* @__PURE__ */ b("dd", { children: /* @__PURE__ */ b(B, {
2157
2146
  cents: s,
2158
2147
  currency: i
2159
2148
  }) })
@@ -2162,7 +2151,7 @@ function $e({ order: e }) {
2162
2151
  });
2163
2152
  }
2164
2153
  // src/views/orders/admin-order-detail.tsx
2165
- function et(e) {
2154
+ function tt(e) {
2166
2155
  let t = e.shippingAddress;
2167
2156
  if (!t) return [];
2168
2157
  let n = [
@@ -2178,13 +2167,13 @@ function et(e) {
2178
2167
  t.country
2179
2168
  ].filter((e) => !!e);
2180
2169
  }
2181
- function tt({ orderId: e, actions: t }) {
2170
+ function nt({ orderId: e, actions: t }) {
2182
2171
  let n = F(), { labels: r, locale: i, hrefs: a, renderLink: o } = P(), s = r.orders, c = I(["admin-order", e], () => n.getOrder(e));
2183
- if (c.error) return /* @__PURE__ */ y(U, { error: c.error });
2172
+ if (c.error) return /* @__PURE__ */ b(U, { error: c.error });
2184
2173
  let l = c.data;
2185
- if (!l) return /* @__PURE__ */ y("p", { children: r.loading });
2186
- let u = et(l);
2187
- return /* @__PURE__ */ b("article", {
2174
+ if (!l) return /* @__PURE__ */ b("p", { children: r.loading });
2175
+ let u = tt(l);
2176
+ return /* @__PURE__ */ x("article", {
2188
2177
  className: "sfa-order",
2189
2178
  children: [
2190
2179
  o({
@@ -2192,46 +2181,46 @@ function tt({ orderId: e, actions: t }) {
2192
2181
  children: s.back,
2193
2182
  className: "sfa-link--tap"
2194
2183
  }),
2195
- /* @__PURE__ */ b("header", {
2184
+ /* @__PURE__ */ x("header", {
2196
2185
  className: "sfa-order__header",
2197
2186
  children: [
2198
- /* @__PURE__ */ b("h1", { children: [
2187
+ /* @__PURE__ */ x("h1", { children: [
2199
2188
  s.detailTitle,
2200
2189
  " ",
2201
2190
  l.id
2202
2191
  ] }),
2203
- /* @__PURE__ */ y(z, { status: l.status }),
2204
- /* @__PURE__ */ b("span", { children: [
2192
+ /* @__PURE__ */ b(z, { status: l.status }),
2193
+ /* @__PURE__ */ x("span", { children: [
2205
2194
  s.placed,
2206
2195
  " ",
2207
2196
  new Intl.DateTimeFormat(i).format(new Date(l.createdAt))
2208
2197
  ] }),
2209
- /* @__PURE__ */ y(B, {
2198
+ /* @__PURE__ */ b(B, {
2210
2199
  cents: l.totalCents,
2211
2200
  currency: l.currency
2212
2201
  })
2213
2202
  ]
2214
2203
  }),
2215
- /* @__PURE__ */ b("section", {
2204
+ /* @__PURE__ */ x("section", {
2216
2205
  className: "sfa-order__section",
2217
- children: [/* @__PURE__ */ y("h2", { children: s.buyer }), /* @__PURE__ */ y("p", { children: l.email ?? r.orders.noEmail })]
2206
+ children: [/* @__PURE__ */ b("h2", { children: s.buyer }), /* @__PURE__ */ b("p", { children: l.email ?? r.orders.noEmail })]
2218
2207
  }),
2219
- /* @__PURE__ */ y(Qe, { order: l }),
2220
- /* @__PURE__ */ b("section", {
2208
+ /* @__PURE__ */ b($e, { order: l }),
2209
+ /* @__PURE__ */ x("section", {
2221
2210
  className: "sfa-order__section",
2222
- children: [/* @__PURE__ */ y("h2", { children: s.shippingAddress }), u.length === 0 ? /* @__PURE__ */ y("p", { children: s.noAddress }) : /* @__PURE__ */ y("address", {
2211
+ children: [/* @__PURE__ */ b("h2", { children: s.shippingAddress }), u.length === 0 ? /* @__PURE__ */ b("p", { children: s.noAddress }) : /* @__PURE__ */ b("address", {
2223
2212
  className: "sfa-order__address",
2224
- children: u.map((e) => /* @__PURE__ */ y("div", { children: e }, e))
2213
+ children: u.map((e) => /* @__PURE__ */ b("div", { children: e }, e))
2225
2214
  })]
2226
2215
  }),
2227
- /* @__PURE__ */ y(Ze, { order: l }),
2228
- /* @__PURE__ */ y($e, { order: l }),
2229
- /* @__PURE__ */ y("section", {
2216
+ /* @__PURE__ */ b(Qe, { order: l }),
2217
+ /* @__PURE__ */ b(et, { order: l }),
2218
+ /* @__PURE__ */ b("section", {
2230
2219
  className: "sfa-order__section",
2231
2220
  children: t ? t({
2232
2221
  order: l,
2233
2222
  reload: c.reload
2234
- }) : /* @__PURE__ */ y(Xe, {
2223
+ }) : /* @__PURE__ */ b(Ze, {
2235
2224
  order: l,
2236
2225
  reload: c.reload
2237
2226
  })
@@ -2240,21 +2229,21 @@ function tt({ orderId: e, actions: t }) {
2240
2229
  });
2241
2230
  }
2242
2231
  // src/lib/shipping-rates.ts
2243
- var nt = 0, rt = () => `rate-${++nt}`;
2244
- function it(e) {
2232
+ var rt = 0, it = () => `rate-${++rt}`;
2233
+ function at(e) {
2245
2234
  return [...e].sort((e, t) => e.sort - t.sort).map((e) => ({
2246
- key: rt(),
2235
+ key: it(),
2247
2236
  label: e.label,
2248
- amount: K(e.amountCents),
2237
+ amount: q(e.amountCents),
2249
2238
  currency: e.currency,
2250
2239
  minDays: e.minDays == null ? "" : String(e.minDays),
2251
2240
  maxDays: e.maxDays == null ? "" : String(e.maxDays),
2252
2241
  active: e.active
2253
2242
  }));
2254
2243
  }
2255
- function at(e, t) {
2244
+ function ot(e, t) {
2256
2245
  return {
2257
- key: rt(),
2246
+ key: it(),
2258
2247
  label: t,
2259
2248
  amount: "",
2260
2249
  currency: e,
@@ -2263,18 +2252,18 @@ function at(e, t) {
2263
2252
  active: !0
2264
2253
  };
2265
2254
  }
2266
- var Z = (e) => JSON.stringify(e.map(({ key: e, ...t }) => t));
2267
- function ot(e) {
2255
+ var Q = (e) => JSON.stringify(e.map(({ key: e, ...t }) => t));
2256
+ function st(e) {
2268
2257
  let t = e.trim();
2269
2258
  return t === "" ? null : /^\d+$/.test(t) ? Number(t) : void 0;
2270
2259
  }
2271
- function st(e, t) {
2260
+ function ct(e, t) {
2272
2261
  let n = {}, r = [], i = /* @__PURE__ */ new Map();
2273
2262
  if (e.forEach((e) => {
2274
2263
  let t = e.label.trim();
2275
2264
  i.set(t, (i.get(t) ?? 0) + 1);
2276
2265
  }), e.forEach((e, a) => {
2277
- let o = {}, s = e.label.trim(), c = G(e.amount), l = ot(e.minDays), u = ot(e.maxDays);
2266
+ let o = {}, s = e.label.trim(), c = K(e.amount), l = st(e.minDays), u = st(e.maxDays);
2278
2267
  s === "" ? o.label = t.labelRequired : (i.get(s) ?? 0) > 1 && (o.label = t.labelDuplicate), /^[A-Z]{3}$/.test(e.currency) || (o.currency = t.currencyInvalid), c === null && (o.amount = t.amountInvalid), l === void 0 && (o.minDays = t.daysInvalid), u === void 0 && (o.maxDays = t.daysInvalid), typeof l == "number" && typeof u == "number" && l > u && (o.minDays = t.daysOrder), Object.keys(o).length > 0 && (n[e.key] = o), r.push({
2279
2268
  label: s,
2280
2269
  amountCents: c ?? 0,
@@ -2285,7 +2274,7 @@ function st(e, t) {
2285
2274
  sort: a
2286
2275
  });
2287
2276
  }), Object.keys(n).length === 0) {
2288
- let i = S.safeParse(r);
2277
+ let i = C.safeParse(r);
2289
2278
  if (!i.success) for (let r of i.error.issues) {
2290
2279
  let i = typeof r.path[0] == "number" ? e[r.path[0]]?.key : void 0;
2291
2280
  i && (n[i] = { row: t.rowInvalid });
@@ -2299,19 +2288,19 @@ function st(e, t) {
2299
2288
  valid: Object.keys(n).length === 0 && !a
2300
2289
  };
2301
2290
  }
2302
- var ct = {
2291
+ var lt = {
2303
2292
  label: "label",
2304
2293
  amountCents: "amount",
2305
2294
  currency: "currency",
2306
2295
  minDays: "minDays",
2307
2296
  maxDays: "maxDays"
2308
2297
  };
2309
- function lt(e, t, n) {
2298
+ function ut(e, t, n) {
2310
2299
  let r = {};
2311
2300
  for (let i of e) {
2312
2301
  let e = i?.path ?? [], a = e.findIndex((e) => typeof e == "number"), o = a >= 0 ? t[e[a]]?.key : void 0;
2313
2302
  if (!o) continue;
2314
- let s = e[e.length - 1], c = e.length - 1 > a && typeof s == "string" ? ct[s] : void 0;
2303
+ let s = e[e.length - 1], c = e.length - 1 > a && typeof s == "string" ? lt[s] : void 0;
2315
2304
  r[o] = {
2316
2305
  ...r[o],
2317
2306
  [c ?? "row"]: n.rowInvalid
@@ -2320,18 +2309,18 @@ function lt(e, t, n) {
2320
2309
  return r;
2321
2310
  }
2322
2311
  // src/views/shipping/shipping-rate-row.tsx
2323
- function ut({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, onChange: o, onMove: s, onRemove: c }) {
2324
- let l = e.label.trim() || q(a.rowName, { n: String(t + 1) }), u = (t, n, a, s, c) => {
2312
+ function dt({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, onChange: o, onMove: s, onRemove: c }) {
2313
+ let l = e.label.trim() || J(a.rowName, { n: String(t + 1) }), u = (t, n, a, s, c) => {
2325
2314
  let l = r[s], u = `${e.key}-${t}`;
2326
- return /* @__PURE__ */ b("div", {
2315
+ return /* @__PURE__ */ x("div", {
2327
2316
  className: "sfa-field",
2328
2317
  children: [
2329
- /* @__PURE__ */ y("label", {
2318
+ /* @__PURE__ */ b("label", {
2330
2319
  className: "sfa-field__label",
2331
2320
  htmlFor: u,
2332
2321
  children: n
2333
2322
  }),
2334
- /* @__PURE__ */ y("input", {
2323
+ /* @__PURE__ */ b("input", {
2335
2324
  id: u,
2336
2325
  value: a,
2337
2326
  inputMode: c,
@@ -2340,7 +2329,7 @@ function ut({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, o
2340
2329
  "aria-describedby": l ? `${u}-error` : void 0,
2341
2330
  onChange: (e) => o({ [s]: e.target.value })
2342
2331
  }),
2343
- l ? /* @__PURE__ */ y("p", {
2332
+ l ? /* @__PURE__ */ b("p", {
2344
2333
  id: `${u}-error`,
2345
2334
  className: "sfa-field__error",
2346
2335
  children: l
@@ -2348,25 +2337,25 @@ function ut({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, o
2348
2337
  ]
2349
2338
  });
2350
2339
  };
2351
- return /* @__PURE__ */ b("li", {
2340
+ return /* @__PURE__ */ x("li", {
2352
2341
  className: "sfa-rate",
2353
2342
  "data-rate-key": e.key,
2354
2343
  children: [
2355
2344
  u("label", a.label, e.label, "label"),
2356
2345
  u("amount", a.amount, e.amount, "amount", "decimal"),
2357
- /* @__PURE__ */ b("div", {
2346
+ /* @__PURE__ */ x("div", {
2358
2347
  className: "sfa-field",
2359
2348
  children: [
2360
- /* @__PURE__ */ y("span", {
2349
+ /* @__PURE__ */ b("span", {
2361
2350
  className: "sfa-field__label",
2362
2351
  children: a.currency
2363
2352
  }),
2364
- /* @__PURE__ */ y("span", {
2353
+ /* @__PURE__ */ b("span", {
2365
2354
  className: "sfa-rate__currency",
2366
2355
  "aria-invalid": !!r.currency,
2367
2356
  children: e.currency
2368
2357
  }),
2369
- r.currency ? /* @__PURE__ */ y("p", {
2358
+ r.currency ? /* @__PURE__ */ b("p", {
2370
2359
  className: "sfa-field__error",
2371
2360
  children: r.currency
2372
2361
  }) : null
@@ -2374,23 +2363,23 @@ function ut({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, o
2374
2363
  }),
2375
2364
  u("min", a.minDays, e.minDays, "minDays", "numeric"),
2376
2365
  u("max", a.maxDays, e.maxDays, "maxDays", "numeric"),
2377
- /* @__PURE__ */ b("label", {
2366
+ /* @__PURE__ */ x("label", {
2378
2367
  className: "sfa-rate__active",
2379
- children: [/* @__PURE__ */ y("input", {
2368
+ children: [/* @__PURE__ */ b("input", {
2380
2369
  type: "checkbox",
2381
2370
  checked: e.active,
2382
2371
  disabled: i,
2383
2372
  onChange: (e) => o({ active: e.target.checked })
2384
2373
  }), a.active]
2385
2374
  }),
2386
- r.row ? /* @__PURE__ */ y("p", {
2375
+ r.row ? /* @__PURE__ */ b("p", {
2387
2376
  className: "sfa-field__error",
2388
2377
  children: r.row
2389
2378
  }) : null,
2390
- /* @__PURE__ */ b("div", {
2379
+ /* @__PURE__ */ x("div", {
2391
2380
  className: "sfa-rate__actions",
2392
2381
  children: [
2393
- /* @__PURE__ */ y("button", {
2382
+ /* @__PURE__ */ b("button", {
2394
2383
  type: "button",
2395
2384
  className: "sfa-btn",
2396
2385
  "aria-label": `${a.moveEarlier}: ${l}`,
@@ -2398,7 +2387,7 @@ function ut({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, o
2398
2387
  onClick: () => s("earlier"),
2399
2388
  children: a.moveEarlier
2400
2389
  }),
2401
- /* @__PURE__ */ y("button", {
2390
+ /* @__PURE__ */ b("button", {
2402
2391
  type: "button",
2403
2392
  className: "sfa-btn",
2404
2393
  "aria-label": `${a.moveLater}: ${l}`,
@@ -2406,7 +2395,7 @@ function ut({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, o
2406
2395
  onClick: () => s("later"),
2407
2396
  children: a.moveLater
2408
2397
  }),
2409
- /* @__PURE__ */ y("button", {
2398
+ /* @__PURE__ */ b("button", {
2410
2399
  type: "button",
2411
2400
  className: "sfa-btn sfa-btn--danger",
2412
2401
  "aria-label": `${a.remove}: ${l}`,
@@ -2420,160 +2409,142 @@ function ut({ draft: e, index: t, total: n, errors: r, disabled: i, labels: a, o
2420
2409
  });
2421
2410
  }
2422
2411
  // src/views/shipping/admin-shipping-rates.tsx
2423
- function dt({ onDirtyChange: e }) {
2424
- let t = F(), { labels: n, currency: r } = P(), i = n.shipping, a = I(["shipping-rates"], () => t.listShippingRates()), [o, s] = _([]), [c, u] = _("[]"), [d, f] = _(void 0), [p, m] = _(null), [v, x] = _({}), [S, C] = _(!1), [w, T] = _(!1), [E, D] = _(!1), O = L((e) => t.replaceShippingRates(e)), k = g(void 0);
2412
+ function ft({ onDirtyChange: e }) {
2413
+ let t = F(), { labels: n, currency: r } = P(), i = n.shipping, a = I(["shipping-rates"], () => t.listShippingRates()), [o, s] = v([]), [c, l] = v("[]"), [d, f] = v(void 0), [p, m] = v(null), [h, y] = v({}), [S, C] = v(!1), [w, T] = v(!1), [E, D] = v(!1), O = L((e) => t.replaceShippingRates(e)), k = _(void 0);
2425
2414
  if (a.data && a.data !== d) {
2426
- let e = it(a.data);
2427
- f(a.data), s(e), u(Z(e));
2415
+ let e = at(a.data);
2416
+ f(a.data), s(e), l(Q(e));
2428
2417
  }
2429
- let A = d !== void 0 && Z(o) !== c;
2430
- h(() => {
2418
+ let A = d !== void 0 && Q(o) !== c;
2419
+ g(() => {
2431
2420
  k.current !== A && (k.current = A, e?.(A));
2432
2421
  }, [A, e]);
2433
2422
  let j = (e) => {
2434
2423
  s(e), T(!1), C(!1);
2435
- }, M = (e, t) => {
2424
+ }, ee = (e, t) => {
2436
2425
  j(o.map((n) => n.key === e ? {
2437
2426
  ...n,
2438
2427
  ...t
2439
- } : n)), x(({ [e]: t, ...n }) => n);
2440
- }, N = (e, t) => {
2428
+ } : n)), y(({ [e]: t, ...n }) => n);
2429
+ }, M = (e, t) => {
2441
2430
  let n = t === "earlier" ? e - 1 : e + 1;
2442
2431
  if (n < 0 || n >= o.length) return;
2443
2432
  let r = [...o];
2444
2433
  [r[e], r[n]] = [r[n], r[e]], j(r);
2445
- }, ee = () => j([...o, at(r, i.newRateLabel)]), te = () => {
2434
+ }, N = () => j([...o, ot(r, i.newRateLabel)]), te = () => {
2446
2435
  p && (j(o.filter((e) => e.key !== p.key)), D(!0), m(null));
2447
- }, R = async () => {
2448
- let e = st(o, i);
2449
- if (x(e.rowErrors), C(e.noActive), !e.valid) return;
2436
+ }, ne = async () => {
2437
+ let e = ct(o, i);
2438
+ if (y(e.rowErrors), C(e.noActive), !e.valid) return;
2450
2439
  let t = await O.run(e.rates);
2451
2440
  if (!t) return;
2452
- let n = it(t);
2453
- s(n), u(Z(n)), x({}), D(!1), T(!0);
2454
- }, z = o.some((e) => e.currency !== r), B = O.error instanceof l ? lt(O.error.issues, o, i) : {};
2455
- return a.loading && !a.data ? /* @__PURE__ */ y("p", {
2441
+ let n = at(t);
2442
+ s(n), l(Q(n)), y({}), D(!1), T(!0);
2443
+ }, R = o.some((e) => e.currency !== r), z = O.error instanceof u ? ut(O.error.issues, o, i) : {};
2444
+ return a.loading && !a.data ? /* @__PURE__ */ b("p", {
2456
2445
  role: "status",
2457
2446
  children: i.loading
2458
- }) : a.data ? /* @__PURE__ */ b("div", {
2447
+ }) : a.data ? /* @__PURE__ */ x("div", {
2459
2448
  className: "sfa-shipping",
2460
2449
  children: [
2461
- /* @__PURE__ */ y("h2", { children: i.title }),
2462
- E ? /* @__PURE__ */ y(H, {
2450
+ /* @__PURE__ */ b("h2", { children: i.title }),
2451
+ E ? /* @__PURE__ */ b(H, {
2463
2452
  variant: "warning",
2464
2453
  children: i.removalWarning
2465
2454
  }) : null,
2466
- z ? /* @__PURE__ */ y(H, {
2455
+ R ? /* @__PURE__ */ b(H, {
2467
2456
  variant: "warning",
2468
- children: q(i.mixedCurrency, { currency: r })
2457
+ children: J(i.mixedCurrency, { currency: r })
2469
2458
  }) : null,
2470
- S ? /* @__PURE__ */ y(H, {
2459
+ S ? /* @__PURE__ */ b(H, {
2471
2460
  variant: "error",
2472
2461
  children: i.noActive
2473
2462
  }) : null,
2474
- /* @__PURE__ */ y(U, { error: O.error }),
2475
- w ? /* @__PURE__ */ y(H, {
2463
+ /* @__PURE__ */ b(U, { error: O.error }),
2464
+ w ? /* @__PURE__ */ b(H, {
2476
2465
  variant: "success",
2477
2466
  children: i.saved
2478
2467
  }) : null,
2479
- A ? /* @__PURE__ */ y("p", {
2468
+ A ? /* @__PURE__ */ b("p", {
2480
2469
  className: "sfa-field__help",
2481
2470
  children: i.unsaved
2482
2471
  }) : null,
2483
- o.length === 0 ? /* @__PURE__ */ y("p", { children: i.empty }) : null,
2484
- /* @__PURE__ */ y("ul", {
2472
+ o.length === 0 ? /* @__PURE__ */ b("p", { children: i.empty }) : null,
2473
+ /* @__PURE__ */ b("ul", {
2485
2474
  className: "sfa-rates",
2486
- children: o.map((e, t) => /* @__PURE__ */ y(ut, {
2475
+ children: o.map((e, t) => /* @__PURE__ */ b(dt, {
2487
2476
  draft: e,
2488
2477
  index: t,
2489
2478
  total: o.length,
2490
2479
  errors: {
2491
- ...B[e.key],
2492
- ...v[e.key]
2480
+ ...z[e.key],
2481
+ ...h[e.key]
2493
2482
  },
2494
2483
  disabled: O.pending,
2495
2484
  labels: i,
2496
- onChange: (t) => M(e.key, t),
2497
- onMove: (e) => N(t, e),
2485
+ onChange: (t) => ee(e.key, t),
2486
+ onMove: (e) => M(t, e),
2498
2487
  onRemove: () => m(e)
2499
2488
  }, e.key))
2500
2489
  }),
2501
- /* @__PURE__ */ b("div", {
2490
+ /* @__PURE__ */ x("div", {
2502
2491
  className: "sfa-shipping__actions",
2503
- children: [/* @__PURE__ */ y("button", {
2492
+ children: [/* @__PURE__ */ b("button", {
2504
2493
  type: "button",
2505
2494
  className: "sfa-btn",
2506
- onClick: ee,
2495
+ onClick: N,
2507
2496
  children: i.add
2508
- }), /* @__PURE__ */ y("button", {
2497
+ }), /* @__PURE__ */ b("button", {
2509
2498
  type: "button",
2510
2499
  className: "sfa-btn sfa-btn--primary",
2511
2500
  disabled: O.pending,
2512
- onClick: R,
2501
+ onClick: ne,
2513
2502
  children: i.save
2514
2503
  })]
2515
2504
  }),
2516
- /* @__PURE__ */ y(V, {
2505
+ /* @__PURE__ */ b(V, {
2517
2506
  open: p !== null,
2518
2507
  title: i.removeTitle,
2519
2508
  destructive: !0,
2520
2509
  confirmLabel: i.remove,
2521
2510
  onConfirm: te,
2522
2511
  onCancel: () => m(null),
2523
- children: /* @__PURE__ */ y("p", { children: i.removeBody })
2512
+ children: /* @__PURE__ */ b("p", { children: i.removeBody })
2524
2513
  })
2525
2514
  ]
2526
- }) : /* @__PURE__ */ y(U, { error: a.error });
2515
+ }) : /* @__PURE__ */ b(U, { error: a.error });
2527
2516
  }
2528
2517
  // src/lib/discount-status.ts
2529
- function ft(e, t = /* @__PURE__ */ new Date()) {
2518
+ function pt(e, t = /* @__PURE__ */ new Date()) {
2530
2519
  return e.active ? e.startsAt && new Date(e.startsAt) > t ? "scheduled" : e.endsAt && new Date(e.endsAt) <= t ? "expired" : "active" : "inactive";
2531
2520
  }
2532
- function Q(e, t) {
2521
+ function mt(e, t) {
2533
2522
  return e.replace(/\{(\w+)\}/g, (e, n) => n in t ? String(t[n]) : e);
2534
2523
  }
2535
2524
  // src/lib/use-discount-pages.ts
2536
- function pt(e) {
2537
- let t = F(), n = I(["admin-discounts", e], () => t.listDiscounts(e)), [r, i] = _(null), a = L(async (n, r) => {
2538
- let a = await t.listDiscounts({
2539
- ...e,
2540
- cursor: n
2541
- });
2542
- i((e) => ({
2543
- base: r,
2544
- items: [...e?.base === r ? e.items : [], ...a.items],
2545
- nextCursor: a.nextCursor
2546
- }));
2547
- }), o = n.data, s = r && r.base === o ? r : null, c = s ? s.nextCursor : o?.nextCursor ?? null;
2548
- return {
2549
- items: [...o?.items ?? [], ...s?.items ?? []],
2550
- loaded: o !== void 0,
2551
- loading: n.loading,
2552
- error: n.error ?? a.error,
2553
- hasMore: !n.loading && c !== null,
2554
- loadingMore: a.pending,
2555
- reload: n.reload,
2556
- loadMore: () => {
2557
- o && c && a.run(c, o);
2558
- }
2559
- };
2525
+ function ht(e) {
2526
+ let t = F();
2527
+ return G(["admin-discounts", e], (n) => t.listDiscounts(n ? {
2528
+ ...e,
2529
+ cursor: n
2530
+ } : e));
2560
2531
  }
2561
2532
  // src/views/discounts/discount-value.tsx
2562
- function mt({ discount: e }) {
2563
- return e.type === "percent" ? /* @__PURE__ */ b("span", { children: [e.percentOff, "%"] }) : /* @__PURE__ */ y(B, {
2533
+ function gt({ discount: e }) {
2534
+ return e.type === "percent" ? /* @__PURE__ */ x("span", { children: [e.percentOff, "%"] }) : /* @__PURE__ */ b(B, {
2564
2535
  cents: e.amountOffCents ?? 0,
2565
2536
  currency: e.currency ?? "USD"
2566
2537
  });
2567
2538
  }
2568
2539
  // src/views/discounts/admin-discount-list.tsx
2569
- var ht = [
2540
+ var _t = [
2570
2541
  "active",
2571
2542
  "scheduled",
2572
2543
  "expired",
2573
2544
  "inactive"
2574
2545
  ];
2575
- function gt() {
2576
- let { labels: e, hrefs: t, renderLink: n } = P(), r = e.discounts, [i, a] = _("active"), [o, s] = _(""), c = W(o.trim(), 300), l = pt({
2546
+ function vt() {
2547
+ let { labels: e, hrefs: t, renderLink: n } = P(), r = e.discounts, [i, a] = v("active"), [o, s] = v(""), c = W(o.trim(), 300), l = ht({
2577
2548
  status: i,
2578
2549
  ...c ? { q: c } : {}
2579
2550
  }), u = [
@@ -2589,50 +2560,50 @@ function gt() {
2589
2560
  {
2590
2561
  key: "value",
2591
2562
  header: r.columns.value,
2592
- render: (e) => /* @__PURE__ */ y(mt, { discount: e })
2563
+ render: (e) => /* @__PURE__ */ b(gt, { discount: e })
2593
2564
  },
2594
2565
  {
2595
2566
  key: "status",
2596
2567
  header: r.columns.status,
2597
- render: (e) => /* @__PURE__ */ y(z, { status: ft(e) })
2568
+ render: (e) => /* @__PURE__ */ b(z, { status: pt(e) })
2598
2569
  },
2599
2570
  {
2600
2571
  key: "usage",
2601
2572
  header: r.columns.usage,
2602
2573
  render: (e) => {
2603
2574
  let t = e.redeemedCount + e.reservedCount;
2604
- return e.maxRedemptions ? Q(r.usage, {
2575
+ return e.maxRedemptions ? mt(r.usage, {
2605
2576
  used: t,
2606
2577
  max: e.maxRedemptions
2607
- }) : Q(r.usageUnlimited, { used: t });
2578
+ }) : mt(r.usageUnlimited, { used: t });
2608
2579
  }
2609
2580
  }
2610
2581
  ];
2611
- return /* @__PURE__ */ b("section", {
2582
+ return /* @__PURE__ */ x("section", {
2612
2583
  className: "sfa-products",
2613
2584
  children: [
2614
- /* @__PURE__ */ b("header", {
2585
+ /* @__PURE__ */ x("header", {
2615
2586
  className: "sfa-products__header",
2616
- children: [/* @__PURE__ */ y("h1", { children: r.title }), n({
2587
+ children: [/* @__PURE__ */ b("h1", { children: r.title }), n({
2617
2588
  href: t.newDiscount,
2618
2589
  children: r.newDiscount,
2619
2590
  className: "sfa-btn sfa-btn--primary"
2620
2591
  })]
2621
2592
  }),
2622
- /* @__PURE__ */ b("div", {
2593
+ /* @__PURE__ */ x("div", {
2623
2594
  className: "sfa-products__toolbar",
2624
- children: [/* @__PURE__ */ y("div", {
2595
+ children: [/* @__PURE__ */ b("div", {
2625
2596
  role: "group",
2626
2597
  "aria-label": r.columns.status,
2627
2598
  className: "sfa-filter-group",
2628
- children: ht.map((e) => /* @__PURE__ */ y("button", {
2599
+ children: _t.map((e) => /* @__PURE__ */ b("button", {
2629
2600
  type: "button",
2630
2601
  className: "sfa-btn sfa-filter",
2631
2602
  "aria-pressed": i === e,
2632
2603
  onClick: () => a(e),
2633
2604
  children: r.tabs[e]
2634
2605
  }, e))
2635
- }), /* @__PURE__ */ y("input", {
2606
+ }), /* @__PURE__ */ b("input", {
2636
2607
  type: "search",
2637
2608
  "aria-label": r.searchLabel,
2638
2609
  placeholder: r.searchPlaceholder,
@@ -2640,16 +2611,16 @@ function gt() {
2640
2611
  onChange: (e) => s(e.target.value)
2641
2612
  })]
2642
2613
  }),
2643
- /* @__PURE__ */ y(U, { error: l.error }),
2644
- l.loading && !l.loaded ? /* @__PURE__ */ y("p", { children: e.loading }) : l.items.length === 0 ? /* @__PURE__ */ y("p", {
2614
+ /* @__PURE__ */ b(U, { error: l.error }),
2615
+ l.loading && !l.loaded ? /* @__PURE__ */ b("p", { children: e.loading }) : l.items.length === 0 ? /* @__PURE__ */ b("p", {
2645
2616
  className: "sfa-empty",
2646
2617
  children: c ? r.noMatches : r.empty[i]
2647
- }) : /* @__PURE__ */ y(R, {
2618
+ }) : /* @__PURE__ */ b(R, {
2648
2619
  columns: u,
2649
2620
  rows: l.items,
2650
2621
  rowKey: (e) => e.id
2651
2622
  }),
2652
- l.hasMore ? /* @__PURE__ */ y("button", {
2623
+ l.hasMore ? /* @__PURE__ */ b("button", {
2653
2624
  type: "button",
2654
2625
  className: "sfa-btn sfa-products__more",
2655
2626
  disabled: l.loadingMore,
@@ -2660,7 +2631,7 @@ function gt() {
2660
2631
  });
2661
2632
  }
2662
2633
  // src/lib/discount-form.ts
2663
- var _t = {
2634
+ var yt = {
2664
2635
  code: "",
2665
2636
  type: "percent",
2666
2637
  percentOff: "",
@@ -2670,42 +2641,42 @@ var _t = {
2670
2641
  endsAt: "",
2671
2642
  maxRedemptions: ""
2672
2643
  }, $ = (e) => String(e).padStart(2, "0");
2673
- function vt(e) {
2644
+ function bt(e) {
2674
2645
  if (!e) return "";
2675
2646
  let t = new Date(e);
2676
2647
  return Number.isNaN(t.getTime()) ? "" : `${t.getFullYear()}-${$(t.getMonth() + 1)}-${$(t.getDate())}T${$(t.getHours())}:${$(t.getMinutes())}`;
2677
2648
  }
2678
- function yt(e) {
2649
+ function xt(e) {
2679
2650
  if (e.trim() === "") return null;
2680
2651
  let t = new Date(e);
2681
2652
  return Number.isNaN(t.getTime()) ? null : t.toISOString();
2682
2653
  }
2683
- function bt(e) {
2654
+ function St(e) {
2684
2655
  return {
2685
2656
  code: e.code,
2686
2657
  type: e.type,
2687
2658
  percentOff: e.percentOff ? String(e.percentOff) : "",
2688
- amountOff: e.amountOffCents ? K(e.amountOffCents) : "",
2689
- minSubtotal: e.minSubtotalCents ? K(e.minSubtotalCents) : "",
2690
- startsAt: vt(e.startsAt),
2691
- endsAt: vt(e.endsAt),
2659
+ amountOff: e.amountOffCents ? q(e.amountOffCents) : "",
2660
+ minSubtotal: e.minSubtotalCents ? q(e.minSubtotalCents) : "",
2661
+ startsAt: bt(e.startsAt),
2662
+ endsAt: bt(e.endsAt),
2692
2663
  maxRedemptions: e.maxRedemptions ? String(e.maxRedemptions) : ""
2693
2664
  };
2694
2665
  }
2695
- function xt(e) {
2666
+ function Ct(e) {
2696
2667
  return !!(e && e.redeemedCount + e.reservedCount > 0);
2697
2668
  }
2698
- var St = (e) => /^\d+$/.test(e.trim()) && Number(e) > 0 ? Number(e) : null;
2699
- function Ct(e, t, n, r = 0) {
2669
+ var wt = (e) => /^\d+$/.test(e.trim()) && Number(e) > 0 ? Number(e) : null;
2670
+ function Tt(e, t, n, r = 0) {
2700
2671
  let i = t.validation, a = {}, o = e.code.trim().toUpperCase();
2701
2672
  /^[A-Z0-9_-]{1,40}$/.test(o) || (a.code = i.code);
2702
- let s = St(e.percentOff), c = G(e.amountOff);
2673
+ let s = wt(e.percentOff), c = K(e.amountOff);
2703
2674
  e.type === "percent" && (s === null || s > 100) && (a.percentOff = i.percentOff), e.type === "fixed" && !c && (a.amountOff = i.amountOff);
2704
- let l = e.minSubtotal.trim(), u = l === "" ? null : G(l);
2675
+ let l = e.minSubtotal.trim(), u = l === "" ? null : K(l);
2705
2676
  l !== "" && !u && (a.minSubtotal = i.minSubtotal);
2706
- let d = e.maxRedemptions.trim(), f = d === "" ? null : St(d);
2677
+ let d = e.maxRedemptions.trim(), f = d === "" ? null : wt(d);
2707
2678
  d !== "" && f === null ? a.maxRedemptions = i.maxRedemptions : f !== null && f < r && (a.maxRedemptions = i.maxRedemptionsBelowUsage);
2708
- let p = yt(e.startsAt), m = yt(e.endsAt);
2679
+ let p = xt(e.startsAt), m = xt(e.endsAt);
2709
2680
  return e.startsAt.trim() !== "" && !p && (a.startsAt = i.date), e.endsAt.trim() !== "" && !m && (a.endsAt = i.date), p && m && new Date(m) <= new Date(p) && (a.endsAt = i.endsBeforeStart), Object.keys(a).length > 0 ? {
2710
2681
  ok: !1,
2711
2682
  errors: a
@@ -2725,25 +2696,25 @@ function Ct(e, t, n, r = 0) {
2725
2696
  }
2726
2697
  };
2727
2698
  }
2728
- var wt = [
2699
+ var Et = [
2729
2700
  "type",
2730
2701
  "percentOff",
2731
2702
  "amountOffCents",
2732
2703
  "currency"
2733
- ], Tt = [
2704
+ ], Dt = [
2734
2705
  "minSubtotalCents",
2735
2706
  "startsAt",
2736
2707
  "endsAt",
2737
2708
  "maxRedemptions"
2738
2709
  ];
2739
- function Et(e, t, n) {
2710
+ function Ot(e, t, n) {
2740
2711
  let r = {}, i = t, a = e, o = (e) => (i[e] ?? null) !== (a[e] ?? null);
2741
- for (let e of Tt) o(e) && (r[e] = i[e]);
2712
+ for (let e of Dt) o(e) && (r[e] = i[e]);
2742
2713
  if (n) return r;
2743
- if (o("code") && (r.code = t.code), wt.some(o)) for (let e of wt) r[e] = i[e];
2714
+ if (o("code") && (r.code = t.code), Et.some(o)) for (let e of Et) r[e] = i[e];
2744
2715
  return r;
2745
2716
  }
2746
- function Dt(e, t) {
2717
+ function kt(e, t) {
2747
2718
  let n = {
2748
2719
  code: "code",
2749
2720
  percentOff: "percentOff",
@@ -2760,12 +2731,12 @@ function Dt(e, t) {
2760
2731
  return r;
2761
2732
  }
2762
2733
  // src/views/discounts/discount-fields.tsx
2763
- function Ot({ name: e, label: t, error: n, help: r, disabled: i, children: a }) {
2734
+ function At({ name: e, label: t, error: n, help: r, disabled: i, children: a }) {
2764
2735
  let o = `sfa-field-${e}`, s = [r ? `${o}-help` : "", n ? `${o}-error` : ""].filter(Boolean).join(" ");
2765
- return /* @__PURE__ */ b("div", {
2736
+ return /* @__PURE__ */ x("div", {
2766
2737
  className: "sfa-field",
2767
2738
  children: [
2768
- /* @__PURE__ */ y("label", {
2739
+ /* @__PURE__ */ b("label", {
2769
2740
  htmlFor: o,
2770
2741
  className: "sfa-field__label",
2771
2742
  children: t
@@ -2777,12 +2748,12 @@ function Ot({ name: e, label: t, error: n, help: r, disabled: i, children: a })
2777
2748
  "aria-invalid": !!n,
2778
2749
  "aria-describedby": s || void 0
2779
2750
  }),
2780
- r ? /* @__PURE__ */ y("p", {
2751
+ r ? /* @__PURE__ */ b("p", {
2781
2752
  id: `${o}-help`,
2782
2753
  className: "sfa-field__help",
2783
2754
  children: r
2784
2755
  }) : null,
2785
- n ? /* @__PURE__ */ y("p", {
2756
+ n ? /* @__PURE__ */ b("p", {
2786
2757
  id: `${o}-error`,
2787
2758
  className: "sfa-field__error",
2788
2759
  children: n
@@ -2790,47 +2761,47 @@ function Ot({ name: e, label: t, error: n, help: r, disabled: i, children: a })
2790
2761
  ]
2791
2762
  });
2792
2763
  }
2793
- var kt = ["percent", "fixed"];
2794
- function At({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
2795
- let a = r > 0, o = a ? Q(n.lockedHelp, { count: r }) : void 0, s = (n, r, a = {}) => /* @__PURE__ */ y(Ot, {
2764
+ var jt = ["percent", "fixed"];
2765
+ function Mt({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
2766
+ let a = r > 0, o = a ? mt(n.lockedHelp, { count: r }) : void 0, s = (n, r, a = {}) => /* @__PURE__ */ b(At, {
2796
2767
  name: n,
2797
2768
  label: r,
2798
2769
  error: t[n],
2799
2770
  help: a.help,
2800
2771
  disabled: a.locked,
2801
- children: (t) => /* @__PURE__ */ y("input", {
2772
+ children: (t) => /* @__PURE__ */ b("input", {
2802
2773
  ...t,
2803
2774
  type: "text",
2804
2775
  inputMode: a.inputMode,
2805
2776
  value: e[n],
2806
2777
  onChange: (e) => i(n, e.target.value)
2807
2778
  })
2808
- }), c = (r) => /* @__PURE__ */ y(Ot, {
2779
+ }), c = (r) => /* @__PURE__ */ b(At, {
2809
2780
  name: r,
2810
2781
  label: n.fields[r],
2811
2782
  error: t[r],
2812
2783
  help: n.optionalHelp,
2813
- children: (t) => /* @__PURE__ */ y("input", {
2784
+ children: (t) => /* @__PURE__ */ b("input", {
2814
2785
  ...t,
2815
2786
  type: "datetime-local",
2816
2787
  value: e[r],
2817
2788
  onChange: (e) => i(r, e.target.value)
2818
2789
  })
2819
2790
  });
2820
- return /* @__PURE__ */ b(v, { children: [
2791
+ return /* @__PURE__ */ x(y, { children: [
2821
2792
  s("code", n.fields.code, {
2822
2793
  help: o,
2823
2794
  locked: a
2824
2795
  }),
2825
- /* @__PURE__ */ y(Ot, {
2796
+ /* @__PURE__ */ b(At, {
2826
2797
  name: "type",
2827
2798
  label: n.fields.type,
2828
2799
  disabled: a,
2829
- children: (t) => /* @__PURE__ */ y("select", {
2800
+ children: (t) => /* @__PURE__ */ b("select", {
2830
2801
  ...t,
2831
2802
  value: e.type,
2832
2803
  onChange: (e) => i("type", e.target.value),
2833
- children: kt.map((e) => /* @__PURE__ */ y("option", {
2804
+ children: jt.map((e) => /* @__PURE__ */ b("option", {
2834
2805
  value: e,
2835
2806
  children: n.types[e]
2836
2807
  }, e))
@@ -2856,122 +2827,126 @@ function At({ form: e, errors: t, labels: n, usedCount: r, onChange: i }) {
2856
2827
  ] });
2857
2828
  }
2858
2829
  // src/views/discounts/admin-discount-editor.tsx
2859
- function jt({ discountId: e, onSaved: t }) {
2860
- return e ? /* @__PURE__ */ y(Mt, {
2830
+ function Nt({ discountId: e, onSaved: t }) {
2831
+ return e ? /* @__PURE__ */ b(Pt, {
2861
2832
  discountId: e,
2862
2833
  onSaved: t
2863
- }) : /* @__PURE__ */ y(Nt, {
2834
+ }) : /* @__PURE__ */ b(Ft, {
2864
2835
  discount: void 0,
2865
2836
  onSaved: t
2866
2837
  });
2867
2838
  }
2868
- function Mt({ discountId: e, onSaved: t }) {
2839
+ function Pt({ discountId: e, onSaved: t }) {
2869
2840
  let n = F(), { labels: r } = P(), i = I(["admin-discount", e], () => n.getDiscount(e));
2870
- return i.error ? /* @__PURE__ */ y(U, { error: i.error }) : i.data ? /* @__PURE__ */ y(Nt, {
2841
+ return i.error ? /* @__PURE__ */ b(U, { error: i.error }) : i.data ? /* @__PURE__ */ b(Ft, {
2871
2842
  discount: i.data,
2872
2843
  onSaved: t
2873
- }, i.data.id) : /* @__PURE__ */ y("p", { children: r.loading });
2844
+ }, i.data.id) : /* @__PURE__ */ b("p", { children: r.loading });
2874
2845
  }
2875
- function Nt({ discount: e, onSaved: t }) {
2876
- let n = F(), { labels: r, currency: i } = P(), a = r.discounts, [o, c] = _(e), [u, d] = _(e ? bt(e) : _t), [f, p] = _({}), [m, h] = _(!1), [g, v] = _(!1), x = o ? o.redeemedCount + o.reservedCount : 0, S = xt(o), C = (e, t) => {
2877
- p(t);
2846
+ function Ft({ discount: e, onSaved: t }) {
2847
+ let n = F(), { labels: i, currency: a } = P(), o = i.discounts, [s, l] = v(e), [d, f] = v(e ? St(e) : yt), [p, m] = v({}), [h, g] = v(!1), [_, y] = v(!1), S = s ? s.redeemedCount + s.reservedCount : 0, C = Ct(s), w = (e, t) => {
2848
+ m(t);
2878
2849
  let n = Object.keys(t)[0];
2879
2850
  n && e.elements.namedItem(n)?.focus();
2880
- }, w = L(async (e) => {
2881
- let t = Ct(u, a, o?.currency ?? i, x);
2882
- if (!t.ok) C(e, t.errors);
2851
+ }, T = L(async (e) => {
2852
+ let t = Tt(d, o, s?.currency ?? a, S);
2853
+ if (!t.ok) w(e, t.errors);
2883
2854
  else try {
2884
- if (!o) return await n.createDiscount(t.input);
2885
- let e = Et(o, t.input, S);
2886
- return Object.keys(e).length === 0 ? o : await n.updateDiscount(o.id, e);
2855
+ if (!s) return await n.createDiscount(t.input);
2856
+ let e = Ot(s, t.input, C);
2857
+ return Object.keys(e).length === 0 ? s : await n.updateDiscount(s.id, e);
2887
2858
  } catch (t) {
2888
- if (t instanceof s) {
2889
- C(e, { code: a.validation.codeTaken });
2859
+ if (t instanceof c) {
2860
+ w(e, { code: o.validation.codeTaken });
2890
2861
  return;
2891
2862
  }
2892
- if (!(t instanceof l)) throw t;
2893
- C(e, Dt(t.issues, a.validation.invalid));
2863
+ if (t instanceof r) {
2864
+ w(e, { maxRedemptions: o.validation.maxRedemptionsBelowUsage });
2865
+ return;
2866
+ }
2867
+ if (!(t instanceof u)) throw t;
2868
+ w(e, kt(t.issues, o.validation.invalid));
2894
2869
  return;
2895
2870
  }
2896
- }), T = L((e) => {
2897
- if (!o) throw Error("Discount has not been created yet.");
2898
- return n.updateDiscount(o.id, { active: e });
2899
- }), E = (e) => {
2900
- c(e), d(bt(e)), h(!0), t?.(e);
2901
- }, D = (e, t) => {
2902
- d((n) => ({
2871
+ }), E = L((e) => {
2872
+ if (!s) throw Error("Discount has not been created yet.");
2873
+ return n.updateDiscount(s.id, { active: e });
2874
+ }), D = (e) => {
2875
+ l(e), f(St(e)), g(!0), t?.(e);
2876
+ }, O = (e, t) => {
2877
+ f((n) => ({
2903
2878
  ...n,
2904
2879
  [e]: t
2905
- })), p((t) => ({
2880
+ })), m((t) => ({
2906
2881
  ...t,
2907
2882
  [e]: void 0
2908
2883
  }));
2909
- }, O = async (e) => {
2910
- e.preventDefault(), h(!1), p({}), w.reset();
2911
- let t = await w.run(e.currentTarget);
2912
- t && E(t);
2913
2884
  }, k = async (e) => {
2914
- v(!1), h(!1);
2915
- let t = await T.run(e);
2916
- t && E(t);
2885
+ e.preventDefault(), g(!1), m({}), T.reset();
2886
+ let t = await T.run(e.currentTarget);
2887
+ t && D(t);
2888
+ }, A = async (e) => {
2889
+ y(!1), g(!1);
2890
+ let t = await E.run(e);
2891
+ t && D(t);
2917
2892
  };
2918
- return /* @__PURE__ */ b("form", {
2893
+ return /* @__PURE__ */ x("form", {
2919
2894
  noValidate: !0,
2920
2895
  className: "sfa-form",
2921
- onSubmit: O,
2896
+ onSubmit: k,
2922
2897
  children: [
2923
- /* @__PURE__ */ y("h1", { children: o ? a.editTitle : a.createTitle }),
2924
- /* @__PURE__ */ y(U, { error: w.error ?? T.error }),
2925
- /* @__PURE__ */ y(At, {
2926
- form: u,
2927
- errors: f,
2928
- labels: a,
2929
- usedCount: x,
2930
- onChange: D
2898
+ /* @__PURE__ */ b("h1", { children: s ? o.editTitle : o.createTitle }),
2899
+ /* @__PURE__ */ b(U, { error: T.error ?? E.error }),
2900
+ /* @__PURE__ */ b(Mt, {
2901
+ form: d,
2902
+ errors: p,
2903
+ labels: o,
2904
+ usedCount: S,
2905
+ onChange: O
2931
2906
  }),
2932
- /* @__PURE__ */ b("div", {
2907
+ /* @__PURE__ */ x("div", {
2933
2908
  className: "sfa-row-actions",
2934
2909
  children: [
2935
- /* @__PURE__ */ y("button", {
2910
+ /* @__PURE__ */ b("button", {
2936
2911
  type: "submit",
2937
2912
  className: "sfa-btn sfa-btn--primary",
2938
- disabled: w.pending,
2939
- children: r.save
2913
+ disabled: T.pending,
2914
+ children: i.save
2940
2915
  }),
2941
- o?.active ? /* @__PURE__ */ y("button", {
2916
+ s?.active ? /* @__PURE__ */ b("button", {
2942
2917
  type: "button",
2943
2918
  className: "sfa-btn",
2944
- onClick: () => v(!0),
2945
- children: a.deactivate
2919
+ onClick: () => y(!0),
2920
+ children: o.deactivate
2946
2921
  }) : null,
2947
- o && !o.active ? /* @__PURE__ */ y("button", {
2922
+ s && !s.active ? /* @__PURE__ */ b("button", {
2948
2923
  type: "button",
2949
2924
  className: "sfa-btn",
2950
- disabled: T.pending,
2951
- onClick: () => k(!0),
2952
- children: a.reactivate
2925
+ disabled: E.pending,
2926
+ onClick: () => A(!0),
2927
+ children: o.reactivate
2953
2928
  }) : null
2954
2929
  ]
2955
2930
  }),
2956
- /* @__PURE__ */ y(V, {
2957
- open: g,
2958
- title: a.deactivateTitle,
2959
- confirmLabel: a.deactivate,
2931
+ /* @__PURE__ */ b(V, {
2932
+ open: _,
2933
+ title: o.deactivateTitle,
2934
+ confirmLabel: o.deactivate,
2960
2935
  destructive: !0,
2961
- pending: T.pending,
2962
- onConfirm: () => k(!1),
2963
- onCancel: () => v(!1),
2964
- children: /* @__PURE__ */ y("p", { children: a.deactivateBody })
2936
+ pending: E.pending,
2937
+ onConfirm: () => A(!1),
2938
+ onCancel: () => y(!1),
2939
+ children: /* @__PURE__ */ b("p", { children: o.deactivateBody })
2965
2940
  }),
2966
- m ? /* @__PURE__ */ y(H, {
2941
+ h ? /* @__PURE__ */ b(H, {
2967
2942
  variant: "success",
2968
2943
  toast: !0,
2969
- onDismiss: () => h(!1),
2970
- children: a.saved
2944
+ onDismiss: () => g(!1),
2945
+ children: o.saved
2971
2946
  }) : null
2972
2947
  ]
2973
2948
  });
2974
2949
  }
2975
- export { jt as AdminDiscountEditor, gt as AdminDiscountList, te as AdminLayout, tt as AdminOrderDetail, Be as AdminOrderList, Pe as AdminProductEditor, ke as AdminProductImages, de as AdminProductList, ee as AdminProvider, dt as AdminShippingRates, R as AdminTable, V as ConfirmDialog, U as ErrorMessage, B as Money, H as Notice, Xe as OrderActions, z as StatusBadge, ie as errorKey, K as formatMoneyInput, G as parseMoneyInput, P as useAdmin, F as useAdminClient, L as useAdminMutation, I as useAdminQuery };
2950
+ export { Nt as AdminDiscountEditor, vt as AdminDiscountList, ne as AdminLayout, nt as AdminOrderDetail, Ve as AdminOrderList, Fe as AdminProductEditor, Ae as AdminProductImages, fe as AdminProductList, te as AdminProvider, ft as AdminShippingRates, R as AdminTable, V as ConfirmDialog, U as ErrorMessage, B as Money, H as Notice, Ze as OrderActions, z as StatusBadge, ae as errorKey, q as formatMoneyInput, K as parseMoneyInput, P as useAdmin, F as useAdminClient, L as useAdminMutation, I as useAdminQuery };
2976
2951
 
2977
2952
  //# sourceMappingURL=index.js.map