@superlogic/spree-pay 0.1.1 → 0.1.2

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/build/index.cjs CHANGED
@@ -37,11 +37,11 @@ __export(index_exports, {
37
37
  module.exports = __toCommonJS(index_exports);
38
38
 
39
39
  // src/SpreePay.tsx
40
- var import_react7 = require("react");
40
+ var import_react9 = require("react");
41
41
  var import_swr3 = require("swr");
42
42
 
43
43
  // src/SpreePayContent.tsx
44
- var import_react6 = require("react");
44
+ var import_react8 = require("react");
45
45
 
46
46
  // ../../node_modules/clsx/dist/clsx.mjs
47
47
  function r(e) {
@@ -60,12 +60,12 @@ function clsx() {
60
60
 
61
61
  // ../../node_modules/tailwind-merge/dist/bundle-mjs.mjs
62
62
  var CLASS_PART_SEPARATOR = "-";
63
- var createClassGroupUtils = (config) => {
64
- const classMap = createClassMap(config);
63
+ var createClassGroupUtils = (config2) => {
64
+ const classMap = createClassMap(config2);
65
65
  const {
66
66
  conflictingClassGroups,
67
67
  conflictingClassGroupModifiers
68
- } = config;
68
+ } = config2;
69
69
  const getClassGroupId = (className) => {
70
70
  const classParts = className.split(CLASS_PART_SEPARATOR);
71
71
  if (classParts[0] === "" && classParts.length !== 1) {
@@ -113,11 +113,11 @@ var getGroupIdForArbitraryProperty = (className) => {
113
113
  }
114
114
  }
115
115
  };
116
- var createClassMap = (config) => {
116
+ var createClassMap = (config2) => {
117
117
  const {
118
118
  theme,
119
119
  classGroups
120
- } = config;
120
+ } = config2;
121
121
  const classMap = {
122
122
  nextPart: /* @__PURE__ */ new Map(),
123
123
  validators: []
@@ -207,11 +207,11 @@ var createLruCache = (maxCacheSize) => {
207
207
  var IMPORTANT_MODIFIER = "!";
208
208
  var MODIFIER_SEPARATOR = ":";
209
209
  var MODIFIER_SEPARATOR_LENGTH = MODIFIER_SEPARATOR.length;
210
- var createParseClassName = (config) => {
210
+ var createParseClassName = (config2) => {
211
211
  const {
212
212
  prefix,
213
213
  experimentalParseClassName
214
- } = config;
214
+ } = config2;
215
215
  let parseClassName = (className) => {
216
216
  const modifiers = [];
217
217
  let bracketDepth = 0;
@@ -281,8 +281,8 @@ var stripImportantModifier = (baseClassName) => {
281
281
  }
282
282
  return baseClassName;
283
283
  };
284
- var createSortModifiers = (config) => {
285
- const orderSensitiveModifiers = Object.fromEntries(config.orderSensitiveModifiers.map((modifier) => [modifier, true]));
284
+ var createSortModifiers = (config2) => {
285
+ const orderSensitiveModifiers = Object.fromEntries(config2.orderSensitiveModifiers.map((modifier) => [modifier, true]));
286
286
  const sortModifiers = (modifiers) => {
287
287
  if (modifiers.length <= 1) {
288
288
  return modifiers;
@@ -303,11 +303,11 @@ var createSortModifiers = (config) => {
303
303
  };
304
304
  return sortModifiers;
305
305
  };
306
- var createConfigUtils = (config) => ({
307
- cache: createLruCache(config.cacheSize),
308
- parseClassName: createParseClassName(config),
309
- sortModifiers: createSortModifiers(config),
310
- ...createClassGroupUtils(config)
306
+ var createConfigUtils = (config2) => ({
307
+ cache: createLruCache(config2.cacheSize),
308
+ parseClassName: createParseClassName(config2),
309
+ sortModifiers: createSortModifiers(config2),
310
+ ...createClassGroupUtils(config2)
311
311
  });
312
312
  var SPLIT_CLASSES_REGEX = /\s+/;
313
313
  var mergeClassList = (classList, configUtils) => {
@@ -400,8 +400,8 @@ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
400
400
  let cacheSet;
401
401
  let functionToCall = initTailwindMerge;
402
402
  function initTailwindMerge(classList) {
403
- const config = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
404
- configUtils = createConfigUtils(config);
403
+ const config2 = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
404
+ configUtils = createConfigUtils(config2);
405
405
  cacheGet = configUtils.cache.get;
406
406
  cacheSet = configUtils.cache.set;
407
407
  functionToCall = tailwindMerge;
@@ -3068,13 +3068,32 @@ var useSpreePayRegister = () => {
3068
3068
  return { register: ctx.register };
3069
3069
  };
3070
3070
 
3071
+ // src/utils/format.ts
3072
+ var formatUSD = (amount, currency = "USD") => {
3073
+ const formattedAmount = new Intl.NumberFormat("en-US", {
3074
+ style: "decimal",
3075
+ maximumFractionDigits: 5,
3076
+ minimumFractionDigits: 2
3077
+ }).format(amount);
3078
+ return `${formattedAmount} ${currency}`;
3079
+ };
3080
+ var formatCoin = (amount, currency = "USDC") => {
3081
+ const formattedAmount = new Intl.NumberFormat("en-US", {
3082
+ style: "decimal",
3083
+ maximumFractionDigits: 5,
3084
+ minimumFractionDigits: 2
3085
+ }).format(amount);
3086
+ return `${formattedAmount} ${currency}`;
3087
+ };
3088
+
3071
3089
  // src/components/CheckoutButton.tsx
3072
3090
  var import_jsx_runtime2 = require("react/jsx-runtime");
3073
3091
  var CheckoutButton = ({ amount, onCheckout }) => {
3074
3092
  const { selectedPaymentMethod } = useSpreePaymentMethod();
3075
- const isDisabled = !amount || !selectedPaymentMethod.method;
3093
+ const isDisabled = !amount || !selectedPaymentMethod.method || selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */;
3094
+ const isUSD = selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */;
3076
3095
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex w-full flex-col overflow-hidden rounded-[24px] border border-black/25 bg-white text-xs font-medium", children: [
3077
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "px-7 py-5", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-secondary", children: [
3096
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "px-7 py-5", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-[#798B95]", children: [
3078
3097
  "By clicking on the button below I acknowledge that I have read and accepted the",
3079
3098
  " ",
3080
3099
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { className: "underline", href: "/", children: "Property Policies" }),
@@ -3097,7 +3116,7 @@ var CheckoutButton = ({ amount, onCheckout }) => {
3097
3116
  className: cn("bg-primary pointer w-full py-4 text-xl font-semibold text-white", {
3098
3117
  "opacity-50": isDisabled
3099
3118
  }),
3100
- children: amount ? `Pay ${amount}` : "Checkout"
3119
+ children: amount ? `Pay ${isUSD ? formatUSD(amount) : formatCoin(amount)}` : "Checkout"
3101
3120
  }
3102
3121
  )
3103
3122
  ] });
@@ -3115,7 +3134,7 @@ var SpreeLegal = () => {
3115
3134
  d: "M57.79 25.48a4.82 4.82 0 0 1-1.55-.25l.55-1.86c.34.1.65.15.92.15s.51-.1.72-.26c.21-.16.39-.43.53-.81l.2-.55-3.65-10.3h2.52l2.32 7.62h.1l2.34-7.62h2.53l-4.04 11.31c-.19.54-.44 1-.75 1.38-.31.38-.7.68-1.14.88-.45.2-.98.3-1.6.3ZM48.95 21.9a4.2 4.2 0 0 1-1.73-.35c-.5-.23-.9-.57-1.2-1.02a3 3 0 0 1-.44-1.67 2.44 2.44 0 0 1 1.18-2.3c.35-.23.76-.4 1.22-.5.46-.13.93-.21 1.42-.27l1.44-.16c.37-.05.64-.13.8-.24.18-.1.26-.27.26-.5v-.04c0-.5-.15-.88-.44-1.15-.3-.27-.72-.4-1.27-.4-.58 0-1.04.12-1.38.37-.34.26-.57.56-.69.9l-2.22-.31a3.54 3.54 0 0 1 2.35-2.47 6.29 6.29 0 0 1 3.38-.14c.48.1.92.3 1.32.56.4.26.72.6.96 1.06.25.44.37 1 .37 1.67v6.75h-2.29v-1.38h-.08a2.9 2.9 0 0 1-1.59 1.37c-.39.14-.84.22-1.37.22Zm.62-1.75c.48 0 .89-.1 1.24-.28.35-.2.62-.45.8-.77.2-.31.3-.65.3-1.03V16.9c-.08.06-.2.11-.38.17a18.34 18.34 0 0 1-1.8.32c-.36.05-.68.12-.96.23-.28.11-.5.27-.66.46-.16.2-.24.45-.24.75 0 .44.16.77.48 1 .32.22.72.33 1.22.33ZM34.43 21.7V8.23h5.05c1.03 0 1.9.2 2.6.58.7.38 1.23.91 1.6 1.59.36.67.54 1.43.54 2.28 0 .87-.18 1.63-.55 2.3a3.9 3.9 0 0 1-1.6 1.59c-.72.38-1.59.57-2.63.57H36.1v-2h3.01c.6 0 1.1-.11 1.49-.32.38-.21.67-.5.85-.87.2-.37.29-.79.29-1.27 0-.47-.1-.9-.29-1.26a1.92 1.92 0 0 0-.86-.84c-.38-.2-.88-.31-1.49-.31h-2.23v11.41h-2.44ZM14.54.46a14.54 14.54 0 1 1 0 29.08 14.54 14.54 0 0 1 0-29.08ZM5.59 18.12l-.84 3.35h.83l.84-3.35h-.83Zm1.66 0-.83 3.35h1.66l.84-3.35H7.25Zm3.35-9.58c-1.03 0-2.08.84-2.34 1.87l-1.1 4.4c-.26 1.03.37 1.87 1.4 1.87h9.64l-.34 1.44h-8.1l-.85 3.35h9.6c1.04 0 2.1-.85 2.35-1.89l1.05-4.4c.25-1.03-.38-1.85-1.4-1.85h-9.63l.36-1.44h8.13l.84-3.35H10.6Zm10.44 0-.84 3.35h1.67l.83-3.35h-1.66Zm2.5 0-.84 3.35h.83l.84-3.35h-.83Z"
3116
3135
  }
3117
3136
  ) }),
3118
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "text-secondary text-xs", children: [
3137
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "text-xs text-[#798B95]", children: [
3119
3138
  "Spree enables seamless crypto payments for real-world goods, travel, and experiences. Enjoy secure, fast transactions and earn rewards.",
3120
3139
  " ",
3121
3140
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { className: "underline", href: "/", children: "Learn more" }),
@@ -3174,7 +3193,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
3174
3193
  "div",
3175
3194
  {
3176
3195
  className: cn(
3177
- "flex w-full items-center justify-between rounded-r-md border-1 !border-l-0 border-transparent px-4",
3196
+ "flex w-full items-center justify-between rounded-r-md border-1 !border-l-0 border-transparent px-3",
3178
3197
  {
3179
3198
  "border-primary": isSelected
3180
3199
  }
@@ -3182,7 +3201,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
3182
3201
  children: [
3183
3202
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-sm font-medium text-black", children: card.schema }) }),
3184
3203
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-2", children: [
3185
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "text-secondary text-sm font-medium", children: [
3204
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "text-sm font-medium text-[#798B95]", children: [
3186
3205
  "Ending in ",
3187
3206
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "text-black", children: card.lastFourNumbers })
3188
3207
  ] }),
@@ -3267,7 +3286,7 @@ var import_jsx_runtime5 = require("react/jsx-runtime");
3267
3286
  // @__NO_SIDE_EFFECTS__
3268
3287
  function createSlot(ownerName) {
3269
3288
  const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
3270
- const Slot2 = React2.forwardRef((props, forwardedRef) => {
3289
+ const Slot22 = React2.forwardRef((props, forwardedRef) => {
3271
3290
  const { children, ...slotProps } = props;
3272
3291
  const childrenArray = React2.Children.toArray(children);
3273
3292
  const slottable = childrenArray.find(isSlottable);
@@ -3285,8 +3304,8 @@ function createSlot(ownerName) {
3285
3304
  }
3286
3305
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SlotClone, { ...slotProps, ref: forwardedRef, children });
3287
3306
  });
3288
- Slot2.displayName = `${ownerName}.Slot`;
3289
- return Slot2;
3307
+ Slot22.displayName = `${ownerName}.Slot`;
3308
+ return Slot22;
3290
3309
  }
3291
3310
  var Slot = /* @__PURE__ */ createSlot("Slot");
3292
3311
  // @__NO_SIDE_EFFECTS__
@@ -3351,10 +3370,10 @@ function getElementRef(element) {
3351
3370
  // ../../node_modules/class-variance-authority/dist/index.mjs
3352
3371
  var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
3353
3372
  var cx = clsx;
3354
- var cva = (base, config) => (props) => {
3373
+ var cva = (base2, config2) => (props) => {
3355
3374
  var _config_compoundVariants;
3356
- if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
3357
- const { variants, defaultVariants } = config;
3375
+ if ((config2 === null || config2 === void 0 ? void 0 : config2.variants) == null) return cx(base2, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
3376
+ const { variants, defaultVariants } = config2;
3358
3377
  const getVariantClassNames = Object.keys(variants).map((variant) => {
3359
3378
  const variantProp = props === null || props === void 0 ? void 0 : props[variant];
3360
3379
  const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
@@ -3370,7 +3389,7 @@ var cva = (base, config) => (props) => {
3370
3389
  acc[key] = value;
3371
3390
  return acc;
3372
3391
  }, {});
3373
- const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
3392
+ const getCompoundVariantClassNames = config2 === null || config2 === void 0 ? void 0 : (_config_compoundVariants = config2.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
3374
3393
  let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
3375
3394
  return Object.entries(compoundVariantOptions).every((param2) => {
3376
3395
  let [key, value] = param2;
@@ -3387,7 +3406,7 @@ var cva = (base, config) => (props) => {
3387
3406
  cvClassName
3388
3407
  ] : acc;
3389
3408
  }, []);
3390
- return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
3409
+ return cx(base2, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
3391
3410
  };
3392
3411
 
3393
3412
  // ../ui/src/components/button.tsx
@@ -3435,9 +3454,25 @@ var React10 = __toESM(require("react"), 1);
3435
3454
  // ../../node_modules/@radix-ui/react-context/dist/index.mjs
3436
3455
  var React3 = __toESM(require("react"), 1);
3437
3456
  var import_jsx_runtime7 = require("react/jsx-runtime");
3457
+ function createContext22(rootComponentName, defaultContext) {
3458
+ const Context = React3.createContext(defaultContext);
3459
+ const Provider = (props) => {
3460
+ const { children, ...context } = props;
3461
+ const value = React3.useMemo(() => context, Object.values(context));
3462
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Context.Provider, { value, children });
3463
+ };
3464
+ Provider.displayName = rootComponentName + "Provider";
3465
+ function useContext22(consumerName) {
3466
+ const context = React3.useContext(Context);
3467
+ if (context) return context;
3468
+ if (defaultContext !== void 0) return defaultContext;
3469
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
3470
+ }
3471
+ return [Provider, useContext22];
3472
+ }
3438
3473
  function createContextScope(scopeName, createContextScopeDeps = []) {
3439
3474
  let defaultContexts = [];
3440
- function createContext3(rootComponentName, defaultContext) {
3475
+ function createContext32(rootComponentName, defaultContext) {
3441
3476
  const BaseContext = React3.createContext(defaultContext);
3442
3477
  const index = defaultContexts.length;
3443
3478
  defaultContexts = [...defaultContexts, defaultContext];
@@ -3470,7 +3505,7 @@ function createContextScope(scopeName, createContextScopeDeps = []) {
3470
3505
  };
3471
3506
  };
3472
3507
  createScope.scopeName = scopeName;
3473
- return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
3508
+ return [createContext32, composeContextScopes(createScope, ...createContextScopeDeps)];
3474
3509
  }
3475
3510
  function composeContextScopes(...scopes) {
3476
3511
  const baseScope = scopes[0];
@@ -3779,18 +3814,21 @@ var NODES = [
3779
3814
  "ul"
3780
3815
  ];
3781
3816
  var Primitive = NODES.reduce((primitive, node) => {
3782
- const Slot2 = createSlot(`Primitive.${node}`);
3783
- const Node = React9.forwardRef((props, forwardedRef) => {
3817
+ const Slot3 = createSlot(`Primitive.${node}`);
3818
+ const Node2 = React9.forwardRef((props, forwardedRef) => {
3784
3819
  const { asChild, ...primitiveProps } = props;
3785
- const Comp = asChild ? Slot2 : node;
3820
+ const Comp = asChild ? Slot3 : node;
3786
3821
  if (typeof window !== "undefined") {
3787
3822
  window[Symbol.for("radix-ui")] = true;
3788
3823
  }
3789
3824
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
3790
3825
  });
3791
- Node.displayName = `Primitive.${node}`;
3792
- return { ...primitive, [node]: Node };
3826
+ Node2.displayName = `Primitive.${node}`;
3827
+ return { ...primitive, [node]: Node2 };
3793
3828
  }, {});
3829
+ function dispatchDiscreteCustomEvent(target, event) {
3830
+ if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
3831
+ }
3794
3832
 
3795
3833
  // ../../node_modules/@radix-ui/react-checkbox/dist/index.mjs
3796
3834
  var import_jsx_runtime9 = require("react/jsx-runtime");
@@ -4145,6 +4183,13 @@ var createLucideIcon = (iconName, iconNode) => {
4145
4183
  var __iconNode = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
4146
4184
  var Check = createLucideIcon("check", __iconNode);
4147
4185
 
4186
+ // ../../node_modules/lucide-react/dist/esm/icons/x.js
4187
+ var __iconNode2 = [
4188
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
4189
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
4190
+ ];
4191
+ var X = createLucideIcon("x", __iconNode2);
4192
+
4148
4193
  // ../ui/src/components/checkbox.tsx
4149
4194
  var import_jsx_runtime10 = require("react/jsx-runtime");
4150
4195
  function Checkbox2({ className, ...props }) {
@@ -4320,7 +4365,7 @@ var CreditCard = () => {
4320
4365
  const [showForm, setShowForm] = (0, import_react5.useState)(false);
4321
4366
  const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
4322
4367
  const { mutateCards } = useCards();
4323
- const { config } = useConfig();
4368
+ const { config: config2 } = useConfig();
4324
4369
  const setCard = (card) => {
4325
4370
  setSelectedPaymentMethod({ type: "CREDIT_CARD" /* CREDIT_CARD */, method: card });
4326
4371
  };
@@ -4330,7 +4375,7 @@ var CreditCard = () => {
4330
4375
  setShowForm(false);
4331
4376
  };
4332
4377
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
4333
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h3", { className: "text-primary text-xl font-semibold", children: "Your Credit Cards" }),
4378
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h3", { className: "text-primary text-xl leading-[34px] font-semibold", children: "Your Credit Cards" }),
4334
4379
  !showForm && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
4335
4380
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
4336
4381
  CardsList,
@@ -4339,167 +4384,2576 @@ var CreditCard = () => {
4339
4384
  setCard
4340
4385
  }
4341
4386
  ),
4342
- config?.stripePublicKey && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { onClick: () => setShowForm(true), className: "text-sm font-medium text-black", children: "Add new card" })
4387
+ config2?.stripePublicKey && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { onClick: () => setShowForm(true), className: "text-sm font-medium text-black", children: "Add new card" })
4343
4388
  ] }),
4344
- config?.stripePublicKey && showForm && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SripeWrapper, { saveNewCard, publicKey: config.stripePublicKey })
4389
+ config2?.stripePublicKey && showForm && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SripeWrapper, { saveNewCard, publicKey: config2.stripePublicKey })
4345
4390
  ] });
4346
4391
  };
4347
4392
 
4348
- // src/components/TabButtons.tsx
4393
+ // src/components/Crypto/CryptoWrapper.tsx
4394
+ var import_react_query = require("@tanstack/react-query");
4395
+ var import_nice_modal_react3 = __toESM(require("@ebay/nice-modal-react"), 1);
4396
+ var import_rainbowkit2 = require("@rainbow-me/rainbowkit");
4397
+ var import_rainbowkit3 = require("@rainbow-me/rainbowkit");
4398
+ var import_styles = require("@rainbow-me/rainbowkit/styles.css");
4399
+ var import_wagmi4 = require("wagmi");
4400
+ var import_chains = require("wagmi/chains");
4401
+
4402
+ // src/components/Crypto/Crypto.tsx
4403
+ var import_nice_modal_react2 = __toESM(require("@ebay/nice-modal-react"), 1);
4404
+ var import_wagmi3 = require("wagmi");
4405
+
4406
+ // src/config/symbolLogos.tsx
4349
4407
  var import_jsx_runtime15 = require("react/jsx-runtime");
4350
- var TabButton = ({ isActive, children, onClick }) => {
4351
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4352
- "button",
4408
+ var MOCA_SVG = /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", fill: "none", children: [
4409
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("circle", { cx: "14", cy: "14", r: "13.5", fill: "#C15F97" }),
4410
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4411
+ "path",
4353
4412
  {
4354
- onClick,
4355
- className: cn(
4356
- "flex w-[132px] flex-col items-baseline rounded-sm border-1 border-black px-2.5 py-1.5 text-sm text-black",
4357
- { "opacity-50": !isActive },
4358
- { "bg-primary/7 border-primary text-primary": isActive }
4359
- ),
4360
- children
4413
+ fill: "#fff",
4414
+ d: "M16.06 6.65c.3 0 .59.16.74.43l6.06 10.5a.85.85 0 1 1-1.47.84L16.06 9.2l-1.51 2.62-.02.03-3.8 6.57a.85.85 0 0 1-1.47-.84l3.57-6.18-1.27-2.2-5.32 9.22a.85.85 0 0 1-1.48-.84l6.07-10.5.06-.1a.85.85 0 0 1 1.4.1l1.52 2.62 1.52-2.62.06-.1c.16-.2.4-.33.67-.33Z"
4361
4415
  }
4362
- );
4363
- };
4364
- var TabButtons = (props) => {
4365
- const { value, onChange } = props;
4366
- const handleChange = (type) => () => {
4367
- onChange({ type, method: null });
4368
- };
4369
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex gap-2", children: [
4370
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(TabButton, { onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */), isActive: value === "CREDIT_CARD" /* CREDIT_CARD */, children: [
4371
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4372
- "path",
4373
- {
4374
- fill: "currentColor",
4375
- d: "M22 6v12c0 .55-.2 1.02-.59 1.41-.39.4-.86.59-1.41.59H4c-.55 0-1.02-.2-1.41-.59-.4-.39-.59-.86-.59-1.41V6c0-.55.2-1.02.59-1.41C2.98 4.19 3.45 4 4 4h16c.55 0 1.02.2 1.41.59.4.39.59.86.59 1.41ZM4 8h16V6H4v2Zm0 4v6h16v-6H4Z"
4376
- }
4377
- ) }),
4378
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-sm font-medium", children: "Card" })
4379
- ] }),
4380
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(TabButton, { onClick: handleChange("CRYPTO" /* CRYPTO */), isActive: value === "CRYPTO" /* CRYPTO */, children: [
4381
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("svg", { className: "my-1", xmlns: "http://www.w3.org/2000/svg", width: "30", height: "16", fill: "none", children: [
4382
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4383
- "path",
4384
- {
4385
- fill: "currentColor",
4386
- d: "M14.5 0C19.2 0 23 3.58 23 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.11.09 3.7 0 6.5-2.8 6.5-6s-2.8-6-6.5-6c-.38 0-.75.03-1.11.09A8 8 0 0 0 11.15.65 8.93 8.93 0 0 1 14.5 0Z"
4387
- }
4388
- ),
4389
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4390
- "path",
4391
- {
4392
- fill: "currentColor",
4393
- d: "M21.15 0c4.7 0 8.5 3.58 8.5 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.1.09 3.71 0 6.5-2.8 6.5-6s-2.79-6-6.5-6c-.37 0-.74.03-1.1.09A8 8 0 0 0 17.8.65 8.93 8.93 0 0 1 21.15 0Z"
4394
- }
4395
- ),
4396
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "2" })
4397
- ] }),
4398
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-sm font-medium", children: "Crypto" })
4399
- ] })
4400
- ] });
4416
+ ),
4417
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("circle", { cx: "16", cy: "14", r: "1.5", fill: "#fff" })
4418
+ ] });
4419
+ var USDC_SVG = /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", fill: "none", children: [
4420
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { clipPath: "url(#clip0_528_9163)", children: [
4421
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { fill: "#2775CA", d: "M14 28c7.76 0 14-6.24 14-14S21.76 0 14 0 0 6.24 0 14s6.24 14 14 14Z" }),
4422
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4423
+ "path",
4424
+ {
4425
+ fill: "#fff",
4426
+ d: "M17.85 16.22c0-2.04-1.23-2.74-3.68-3.04-1.75-.23-2.1-.7-2.1-1.51 0-.82.59-1.34 1.75-1.34 1.05 0 1.64.35 1.93 1.22.06.18.23.3.4.3h.94a.4.4 0 0 0 .41-.42v-.05a2.91 2.91 0 0 0-2.63-2.4v-1.4c0-.23-.17-.4-.46-.46h-.88c-.23 0-.4.17-.46.46v1.35c-1.75.23-2.86 1.4-2.86 2.85 0 1.93 1.16 2.69 3.61 2.98 1.64.29 2.16.64 2.16 1.57 0 .94-.81 1.58-1.92 1.58-1.52 0-2.04-.64-2.22-1.52-.06-.23-.23-.35-.4-.35h-1a.4.4 0 0 0-.4.41v.06c.23 1.46 1.16 2.5 3.08 2.8v1.4c0 .23.18.4.47.47h.88c.23 0 .4-.18.46-.47v-1.4c1.75-.3 2.92-1.52 2.92-3.1Z"
4427
+ }
4428
+ ),
4429
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4430
+ "path",
4431
+ {
4432
+ fill: "#fff",
4433
+ d: "M11.03 22.34a8.69 8.69 0 0 1-5.2-11.2 8.63 8.63 0 0 1 5.2-5.19c.23-.12.35-.3.35-.58v-.82c0-.23-.12-.4-.35-.47-.06 0-.18 0-.24.06a10.48 10.48 0 0 0 0 20.01c.24.12.47 0 .53-.23.06-.06.06-.12.06-.24v-.81c0-.18-.18-.41-.35-.53Zm6.18-18.2c-.23-.12-.47 0-.53.23-.05.06-.05.12-.05.24v.81c0 .24.17.47.35.59a8.69 8.69 0 0 1 5.19 11.2 8.63 8.63 0 0 1-5.2 5.19c-.23.12-.34.3-.34.58v.82c0 .23.11.4.35.47.05 0 .17 0 .23-.06a10.48 10.48 0 0 0 6.82-13.19 10.58 10.58 0 0 0-6.82-6.88Z"
4434
+ }
4435
+ )
4436
+ ] }),
4437
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("clipPath", { id: "clip0_528_9163", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { fill: "#fff", d: "M0 0h28v28H0z" }) }) })
4438
+ ] });
4439
+ var USDT_SVG = /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", fill: "none", children: [
4440
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { fill: "#26A17B", d: "M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28Z" }),
4441
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4442
+ "path",
4443
+ {
4444
+ fill: "#fff",
4445
+ d: "M15.5 15.3v-.01c-.1 0-.6.04-1.72.04-.88 0-1.5-.03-1.73-.04-3.42-.15-5.97-.74-5.97-1.46 0-.7 2.55-1.3 5.97-1.46v2.33a26 26 0 0 0 3.44 0v-2.32c3.42.15 5.96.74 5.96 1.46 0 .7-2.55 1.3-5.96 1.45m0-3.15v-2.08h4.76V6.89H7.3v3.17h4.76v2.08c-3.87.17-6.77.94-6.77 1.86 0 .92 2.9 1.68 6.77 1.86v6.67h3.45v-6.67c3.86-.18 6.76-.94 6.76-1.86 0-.92-2.9-1.68-6.76-1.86"
4446
+ }
4447
+ )
4448
+ ] });
4449
+ var WETH_SVG = /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", width: "28", height: "28", viewBox: "0 0 24 24", children: [
4450
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("g", { clipPath: "url(#clip0_528_9173)", children: [
4451
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4452
+ "path",
4453
+ {
4454
+ fill: "#000",
4455
+ d: "M17.14 20.57c0 .95-1.31 2.01-3.39 2.4h-2.59c-4.65 0-8.42-1.07-8.42-2.4 0-1.32 3.77-2.4 8.42-2.4s5.98 1.08 5.98 2.4Z"
4456
+ }
4457
+ ),
4458
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4459
+ "path",
4460
+ {
4461
+ fill: "#F61F7D",
4462
+ d: "M23.31 11c0 5.86-5.18 11.63-11.07 11.63-5.9 0-11.9-6.17-11.9-12.03C.34 4.75 5.12 0 11.01 0s12.3 5.15 12.3 11Z"
4463
+ }
4464
+ ),
4465
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4466
+ "path",
4467
+ {
4468
+ fill: "#000",
4469
+ fillRule: "evenodd",
4470
+ d: "M19.19 18.27c1.87-2 3.03-4.65 3.03-7.26 0-2.52-1.39-5-3.56-6.87-2.18-1.88-5-3.05-7.65-3.05a9.54 9.54 0 0 0-9.57 9.51c0 2.57 1.33 5.31 3.42 7.44 2.1 2.13 4.8 3.5 7.38 3.5a9.7 9.7 0 0 0 6.95-3.27Zm-6.95 4.36c5.89 0 11.07-5.77 11.07-11.62C23.31 5.15 16.9 0 11.01 0A10.63 10.63 0 0 0 .34 10.6c0 5.86 6 12.03 11.9 12.03Z",
4471
+ clipRule: "evenodd"
4472
+ }
4473
+ ),
4474
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { fill: "#fff", d: "M24 12.17a10.8 10.8 0 1 1-21.6 0 10.8 10.8 0 0 1 21.6 0Z" }),
4475
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4476
+ "path",
4477
+ {
4478
+ fill: "#000",
4479
+ fillRule: "evenodd",
4480
+ d: "M13.2 21.87a9.7 9.7 0 1 0 0-19.4 9.7 9.7 0 0 0 0 19.4Zm0 1.1a10.8 10.8 0 1 0 0-21.6 10.8 10.8 0 0 0 0 21.6Z",
4481
+ clipRule: "evenodd"
4482
+ }
4483
+ ),
4484
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { fill: "#000", fillRule: "evenodd", d: "M3.02 10.63.7 8.75l.74-.86 2.34 1.87-.75.87Z", clipRule: "evenodd" }),
4485
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
4486
+ "path",
4487
+ {
4488
+ fill: "#000",
4489
+ d: "M5.83 9.94h.99l.31 3 .4-3h.78l.41 2.98.32-2.98h.98l-.63 5.15H8.37l-.45-3.1-.42 3.1H6.47l-.64-5.15ZM10.91 9.94h2.38v.78h-1.2v1.27H13v.8h-.92v1.53h1.22v.77h-2.39V9.94ZM14.64 10.79h-.81v-.85h2.78v.85h-.8v4.3h-1.17v-4.3ZM17.42 9.94h1.16v2.09h.82V9.94h1.17v5.15H19.4v-2.25h-.82v2.25h-1.16V9.94Z"
4490
+ }
4491
+ )
4492
+ ] }),
4493
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("clipPath", { id: "clip0_528_9173", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { fill: "#fff", d: "M0 0h24v24H0z" }) }) })
4494
+ ] });
4495
+ var symbolLogos = {
4496
+ MOCA: MOCA_SVG,
4497
+ USDC: USDC_SVG,
4498
+ USDT: USDT_SVG,
4499
+ WETH: WETH_SVG
4401
4500
  };
4501
+ function getSymbolLogo(symbol) {
4502
+ return symbolLogos[symbol] ?? null;
4503
+ }
4402
4504
 
4403
- // src/components/Tabs.tsx
4404
- var import_jsx_runtime16 = require("react/jsx-runtime");
4405
- var Tabs = () => {
4406
- const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
4407
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "mb-4 rounded-2xl border border-black/25 bg-white", children: [
4408
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex w-full flex-col gap-4 border-b-1 border-black/7 px-7 py-6", children: [
4409
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
4410
- /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
4411
- ] }),
4412
- /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "px-7 py-6", children: [
4413
- selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CreditCard, {}),
4414
- selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && null
4415
- ] })
4416
- ] });
4417
- };
4505
+ // src/modals/CryptoSelectModal.tsx
4506
+ var import_react7 = require("react");
4507
+ var import_nice_modal_react = __toESM(require("@ebay/nice-modal-react"), 1);
4418
4508
 
4419
- // src/fetcher/client.ts
4420
- var cfg = { baseUrl: void 0, accessToken: void 0, tenantId: void 0 };
4421
- var buildUrl = (key) => {
4422
- if (!cfg.baseUrl) throw new Error("Missing SLAPI baseUrl. Call registerApi(...) first.");
4423
- if (typeof key === "string") return cfg.baseUrl + key;
4424
- const { url, params = {} } = key;
4425
- const usp = new URLSearchParams();
4426
- Object.entries(params).forEach(([k, v]) => {
4427
- if (v === void 0 || v === null) return;
4428
- usp.append(k, String(v));
4509
+ // ../../node_modules/@radix-ui/react-dialog/dist/index.mjs
4510
+ var React28 = __toESM(require("react"), 1);
4511
+
4512
+ // ../../node_modules/@radix-ui/react-id/dist/index.mjs
4513
+ var React12 = __toESM(require("react"), 1);
4514
+ var useReactId = React12[" useId ".trim().toString()] || (() => void 0);
4515
+ var count = 0;
4516
+ function useId2(deterministicId) {
4517
+ const [id, setId] = React12.useState(useReactId());
4518
+ useLayoutEffect2(() => {
4519
+ if (!deterministicId) setId((reactId) => reactId ?? String(count++));
4520
+ }, [deterministicId]);
4521
+ return deterministicId || (id ? `radix-${id}` : "");
4522
+ }
4523
+
4524
+ // ../../node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs
4525
+ var React15 = __toESM(require("react"), 1);
4526
+
4527
+ // ../../node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs
4528
+ var React13 = __toESM(require("react"), 1);
4529
+ function useCallbackRef(callback) {
4530
+ const callbackRef = React13.useRef(callback);
4531
+ React13.useEffect(() => {
4532
+ callbackRef.current = callback;
4429
4533
  });
4430
- const qs = usp.toString();
4431
- return cfg.baseUrl + url + (qs ? `?${qs}` : "");
4432
- };
4433
- var request = async (method, url, body) => {
4434
- const headers = {
4435
- Accept: "application/json"
4534
+ return React13.useMemo(() => (...args) => callbackRef.current?.(...args), []);
4535
+ }
4536
+
4537
+ // ../../node_modules/@radix-ui/react-use-escape-keydown/dist/index.mjs
4538
+ var React14 = __toESM(require("react"), 1);
4539
+ function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
4540
+ const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
4541
+ React14.useEffect(() => {
4542
+ const handleKeyDown = (event) => {
4543
+ if (event.key === "Escape") {
4544
+ onEscapeKeyDown(event);
4545
+ }
4546
+ };
4547
+ ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
4548
+ return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
4549
+ }, [onEscapeKeyDown, ownerDocument]);
4550
+ }
4551
+
4552
+ // ../../node_modules/@radix-ui/react-dismissable-layer/dist/index.mjs
4553
+ var import_jsx_runtime16 = require("react/jsx-runtime");
4554
+ var DISMISSABLE_LAYER_NAME = "DismissableLayer";
4555
+ var CONTEXT_UPDATE = "dismissableLayer.update";
4556
+ var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
4557
+ var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
4558
+ var originalBodyPointerEvents;
4559
+ var DismissableLayerContext = React15.createContext({
4560
+ layers: /* @__PURE__ */ new Set(),
4561
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
4562
+ branches: /* @__PURE__ */ new Set()
4563
+ });
4564
+ var DismissableLayer = React15.forwardRef(
4565
+ (props, forwardedRef) => {
4566
+ const {
4567
+ disableOutsidePointerEvents = false,
4568
+ onEscapeKeyDown,
4569
+ onPointerDownOutside,
4570
+ onFocusOutside,
4571
+ onInteractOutside,
4572
+ onDismiss,
4573
+ ...layerProps
4574
+ } = props;
4575
+ const context = React15.useContext(DismissableLayerContext);
4576
+ const [node, setNode] = React15.useState(null);
4577
+ const ownerDocument = node?.ownerDocument ?? globalThis?.document;
4578
+ const [, force] = React15.useState({});
4579
+ const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
4580
+ const layers = Array.from(context.layers);
4581
+ const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
4582
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
4583
+ const index = node ? layers.indexOf(node) : -1;
4584
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
4585
+ const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
4586
+ const pointerDownOutside = usePointerDownOutside((event) => {
4587
+ const target = event.target;
4588
+ const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
4589
+ if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
4590
+ onPointerDownOutside?.(event);
4591
+ onInteractOutside?.(event);
4592
+ if (!event.defaultPrevented) onDismiss?.();
4593
+ }, ownerDocument);
4594
+ const focusOutside = useFocusOutside((event) => {
4595
+ const target = event.target;
4596
+ const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
4597
+ if (isFocusInBranch) return;
4598
+ onFocusOutside?.(event);
4599
+ onInteractOutside?.(event);
4600
+ if (!event.defaultPrevented) onDismiss?.();
4601
+ }, ownerDocument);
4602
+ useEscapeKeydown((event) => {
4603
+ const isHighestLayer = index === context.layers.size - 1;
4604
+ if (!isHighestLayer) return;
4605
+ onEscapeKeyDown?.(event);
4606
+ if (!event.defaultPrevented && onDismiss) {
4607
+ event.preventDefault();
4608
+ onDismiss();
4609
+ }
4610
+ }, ownerDocument);
4611
+ React15.useEffect(() => {
4612
+ if (!node) return;
4613
+ if (disableOutsidePointerEvents) {
4614
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
4615
+ originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
4616
+ ownerDocument.body.style.pointerEvents = "none";
4617
+ }
4618
+ context.layersWithOutsidePointerEventsDisabled.add(node);
4619
+ }
4620
+ context.layers.add(node);
4621
+ dispatchUpdate();
4622
+ return () => {
4623
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
4624
+ ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
4625
+ }
4626
+ };
4627
+ }, [node, ownerDocument, disableOutsidePointerEvents, context]);
4628
+ React15.useEffect(() => {
4629
+ return () => {
4630
+ if (!node) return;
4631
+ context.layers.delete(node);
4632
+ context.layersWithOutsidePointerEventsDisabled.delete(node);
4633
+ dispatchUpdate();
4634
+ };
4635
+ }, [node, context]);
4636
+ React15.useEffect(() => {
4637
+ const handleUpdate = () => force({});
4638
+ document.addEventListener(CONTEXT_UPDATE, handleUpdate);
4639
+ return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
4640
+ }, []);
4641
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
4642
+ Primitive.div,
4643
+ {
4644
+ ...layerProps,
4645
+ ref: composedRefs,
4646
+ style: {
4647
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
4648
+ ...props.style
4649
+ },
4650
+ onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
4651
+ onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
4652
+ onPointerDownCapture: composeEventHandlers(
4653
+ props.onPointerDownCapture,
4654
+ pointerDownOutside.onPointerDownCapture
4655
+ )
4656
+ }
4657
+ );
4658
+ }
4659
+ );
4660
+ DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
4661
+ var BRANCH_NAME = "DismissableLayerBranch";
4662
+ var DismissableLayerBranch = React15.forwardRef((props, forwardedRef) => {
4663
+ const context = React15.useContext(DismissableLayerContext);
4664
+ const ref = React15.useRef(null);
4665
+ const composedRefs = useComposedRefs(forwardedRef, ref);
4666
+ React15.useEffect(() => {
4667
+ const node = ref.current;
4668
+ if (node) {
4669
+ context.branches.add(node);
4670
+ return () => {
4671
+ context.branches.delete(node);
4672
+ };
4673
+ }
4674
+ }, [context.branches]);
4675
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Primitive.div, { ...props, ref: composedRefs });
4676
+ });
4677
+ DismissableLayerBranch.displayName = BRANCH_NAME;
4678
+ function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
4679
+ const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
4680
+ const isPointerInsideReactTreeRef = React15.useRef(false);
4681
+ const handleClickRef = React15.useRef(() => {
4682
+ });
4683
+ React15.useEffect(() => {
4684
+ const handlePointerDown = (event) => {
4685
+ if (event.target && !isPointerInsideReactTreeRef.current) {
4686
+ let handleAndDispatchPointerDownOutsideEvent2 = function() {
4687
+ handleAndDispatchCustomEvent(
4688
+ POINTER_DOWN_OUTSIDE,
4689
+ handlePointerDownOutside,
4690
+ eventDetail,
4691
+ { discrete: true }
4692
+ );
4693
+ };
4694
+ var handleAndDispatchPointerDownOutsideEvent = handleAndDispatchPointerDownOutsideEvent2;
4695
+ const eventDetail = { originalEvent: event };
4696
+ if (event.pointerType === "touch") {
4697
+ ownerDocument.removeEventListener("click", handleClickRef.current);
4698
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
4699
+ ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
4700
+ } else {
4701
+ handleAndDispatchPointerDownOutsideEvent2();
4702
+ }
4703
+ } else {
4704
+ ownerDocument.removeEventListener("click", handleClickRef.current);
4705
+ }
4706
+ isPointerInsideReactTreeRef.current = false;
4707
+ };
4708
+ const timerId = window.setTimeout(() => {
4709
+ ownerDocument.addEventListener("pointerdown", handlePointerDown);
4710
+ }, 0);
4711
+ return () => {
4712
+ window.clearTimeout(timerId);
4713
+ ownerDocument.removeEventListener("pointerdown", handlePointerDown);
4714
+ ownerDocument.removeEventListener("click", handleClickRef.current);
4715
+ };
4716
+ }, [ownerDocument, handlePointerDownOutside]);
4717
+ return {
4718
+ // ensures we check React component tree (not just DOM tree)
4719
+ onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
4436
4720
  };
4437
- if (!cfg.accessToken) throw new Error("Missing SLAPI accessToken. Call registerApi(...) first.");
4438
- if (!cfg.tenantId) throw new Error("Missing SLAPI tenantId. Call registerApi(...) first.");
4439
- headers.Authorization = `Bearer ${cfg.accessToken}`;
4440
- headers["X-Tenant-ID"] = cfg.tenantId;
4441
- let payload;
4442
- if (method !== "GET" && method !== "DELETE" && body !== void 0) {
4443
- if (typeof FormData !== "undefined" && body instanceof FormData) {
4444
- payload = body;
4445
- } else if (body instanceof Blob) {
4446
- payload = body;
4447
- } else {
4448
- headers["Content-Type"] = "application/json";
4449
- payload = JSON.stringify(body);
4721
+ }
4722
+ function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
4723
+ const handleFocusOutside = useCallbackRef(onFocusOutside);
4724
+ const isFocusInsideReactTreeRef = React15.useRef(false);
4725
+ React15.useEffect(() => {
4726
+ const handleFocus = (event) => {
4727
+ if (event.target && !isFocusInsideReactTreeRef.current) {
4728
+ const eventDetail = { originalEvent: event };
4729
+ handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
4730
+ discrete: false
4731
+ });
4732
+ }
4733
+ };
4734
+ ownerDocument.addEventListener("focusin", handleFocus);
4735
+ return () => ownerDocument.removeEventListener("focusin", handleFocus);
4736
+ }, [ownerDocument, handleFocusOutside]);
4737
+ return {
4738
+ onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
4739
+ onBlurCapture: () => isFocusInsideReactTreeRef.current = false
4740
+ };
4741
+ }
4742
+ function dispatchUpdate() {
4743
+ const event = new CustomEvent(CONTEXT_UPDATE);
4744
+ document.dispatchEvent(event);
4745
+ }
4746
+ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
4747
+ const target = detail.originalEvent.target;
4748
+ const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
4749
+ if (handler) target.addEventListener(name, handler, { once: true });
4750
+ if (discrete) {
4751
+ dispatchDiscreteCustomEvent(target, event);
4752
+ } else {
4753
+ target.dispatchEvent(event);
4754
+ }
4755
+ }
4756
+
4757
+ // ../../node_modules/@radix-ui/react-focus-scope/dist/index.mjs
4758
+ var React16 = __toESM(require("react"), 1);
4759
+ var import_jsx_runtime17 = require("react/jsx-runtime");
4760
+ var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
4761
+ var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
4762
+ var EVENT_OPTIONS = { bubbles: false, cancelable: true };
4763
+ var FOCUS_SCOPE_NAME = "FocusScope";
4764
+ var FocusScope = React16.forwardRef((props, forwardedRef) => {
4765
+ const {
4766
+ loop = false,
4767
+ trapped = false,
4768
+ onMountAutoFocus: onMountAutoFocusProp,
4769
+ onUnmountAutoFocus: onUnmountAutoFocusProp,
4770
+ ...scopeProps
4771
+ } = props;
4772
+ const [container, setContainer] = React16.useState(null);
4773
+ const onMountAutoFocus = useCallbackRef(onMountAutoFocusProp);
4774
+ const onUnmountAutoFocus = useCallbackRef(onUnmountAutoFocusProp);
4775
+ const lastFocusedElementRef = React16.useRef(null);
4776
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
4777
+ const focusScope = React16.useRef({
4778
+ paused: false,
4779
+ pause() {
4780
+ this.paused = true;
4781
+ },
4782
+ resume() {
4783
+ this.paused = false;
4784
+ }
4785
+ }).current;
4786
+ React16.useEffect(() => {
4787
+ if (trapped) {
4788
+ let handleFocusIn2 = function(event) {
4789
+ if (focusScope.paused || !container) return;
4790
+ const target = event.target;
4791
+ if (container.contains(target)) {
4792
+ lastFocusedElementRef.current = target;
4793
+ } else {
4794
+ focus(lastFocusedElementRef.current, { select: true });
4795
+ }
4796
+ }, handleFocusOut2 = function(event) {
4797
+ if (focusScope.paused || !container) return;
4798
+ const relatedTarget = event.relatedTarget;
4799
+ if (relatedTarget === null) return;
4800
+ if (!container.contains(relatedTarget)) {
4801
+ focus(lastFocusedElementRef.current, { select: true });
4802
+ }
4803
+ }, handleMutations2 = function(mutations) {
4804
+ const focusedElement = document.activeElement;
4805
+ if (focusedElement !== document.body) return;
4806
+ for (const mutation of mutations) {
4807
+ if (mutation.removedNodes.length > 0) focus(container);
4808
+ }
4809
+ };
4810
+ var handleFocusIn = handleFocusIn2, handleFocusOut = handleFocusOut2, handleMutations = handleMutations2;
4811
+ document.addEventListener("focusin", handleFocusIn2);
4812
+ document.addEventListener("focusout", handleFocusOut2);
4813
+ const mutationObserver = new MutationObserver(handleMutations2);
4814
+ if (container) mutationObserver.observe(container, { childList: true, subtree: true });
4815
+ return () => {
4816
+ document.removeEventListener("focusin", handleFocusIn2);
4817
+ document.removeEventListener("focusout", handleFocusOut2);
4818
+ mutationObserver.disconnect();
4819
+ };
4820
+ }
4821
+ }, [trapped, container, focusScope.paused]);
4822
+ React16.useEffect(() => {
4823
+ if (container) {
4824
+ focusScopesStack.add(focusScope);
4825
+ const previouslyFocusedElement = document.activeElement;
4826
+ const hasFocusedCandidate = container.contains(previouslyFocusedElement);
4827
+ if (!hasFocusedCandidate) {
4828
+ const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
4829
+ container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
4830
+ container.dispatchEvent(mountEvent);
4831
+ if (!mountEvent.defaultPrevented) {
4832
+ focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
4833
+ if (document.activeElement === previouslyFocusedElement) {
4834
+ focus(container);
4835
+ }
4836
+ }
4837
+ }
4838
+ return () => {
4839
+ container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
4840
+ setTimeout(() => {
4841
+ const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
4842
+ container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
4843
+ container.dispatchEvent(unmountEvent);
4844
+ if (!unmountEvent.defaultPrevented) {
4845
+ focus(previouslyFocusedElement ?? document.body, { select: true });
4846
+ }
4847
+ container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
4848
+ focusScopesStack.remove(focusScope);
4849
+ }, 0);
4850
+ };
4450
4851
  }
4852
+ }, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
4853
+ const handleKeyDown = React16.useCallback(
4854
+ (event) => {
4855
+ if (!loop && !trapped) return;
4856
+ if (focusScope.paused) return;
4857
+ const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
4858
+ const focusedElement = document.activeElement;
4859
+ if (isTabKey && focusedElement) {
4860
+ const container2 = event.currentTarget;
4861
+ const [first, last] = getTabbableEdges(container2);
4862
+ const hasTabbableElementsInside = first && last;
4863
+ if (!hasTabbableElementsInside) {
4864
+ if (focusedElement === container2) event.preventDefault();
4865
+ } else {
4866
+ if (!event.shiftKey && focusedElement === last) {
4867
+ event.preventDefault();
4868
+ if (loop) focus(first, { select: true });
4869
+ } else if (event.shiftKey && focusedElement === first) {
4870
+ event.preventDefault();
4871
+ if (loop) focus(last, { select: true });
4872
+ }
4873
+ }
4874
+ }
4875
+ },
4876
+ [loop, trapped, focusScope.paused]
4877
+ );
4878
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
4879
+ });
4880
+ FocusScope.displayName = FOCUS_SCOPE_NAME;
4881
+ function focusFirst(candidates, { select = false } = {}) {
4882
+ const previouslyFocusedElement = document.activeElement;
4883
+ for (const candidate of candidates) {
4884
+ focus(candidate, { select });
4885
+ if (document.activeElement !== previouslyFocusedElement) return;
4451
4886
  }
4452
- const res = await fetch(url, {
4453
- method,
4454
- headers,
4455
- body: payload,
4456
- cache: "no-store"
4887
+ }
4888
+ function getTabbableEdges(container) {
4889
+ const candidates = getTabbableCandidates(container);
4890
+ const first = findVisible(candidates, container);
4891
+ const last = findVisible(candidates.reverse(), container);
4892
+ return [first, last];
4893
+ }
4894
+ function getTabbableCandidates(container) {
4895
+ const nodes = [];
4896
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
4897
+ acceptNode: (node) => {
4898
+ const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
4899
+ if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
4900
+ return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
4901
+ }
4457
4902
  });
4458
- if (!res.ok) {
4459
- const text = await res.text().catch(() => "");
4460
- throw new Error(text || `Request failed: ${res.status}`);
4903
+ while (walker.nextNode()) nodes.push(walker.currentNode);
4904
+ return nodes;
4905
+ }
4906
+ function findVisible(elements, container) {
4907
+ for (const element of elements) {
4908
+ if (!isHidden(element, { upTo: container })) return element;
4461
4909
  }
4462
- const contentType = res.headers.get("content-type") || "";
4463
- if (!contentType.includes("application/json")) {
4464
- return await res.text();
4910
+ }
4911
+ function isHidden(node, { upTo }) {
4912
+ if (getComputedStyle(node).visibility === "hidden") return true;
4913
+ while (node) {
4914
+ if (upTo !== void 0 && node === upTo) return false;
4915
+ if (getComputedStyle(node).display === "none") return true;
4916
+ node = node.parentElement;
4465
4917
  }
4466
- return await res.json();
4467
- };
4468
- var slapiApi = {
4469
- get: async () => {
4470
- throw new Error("slapiApi is not configured. Call registerApi(...) first.");
4471
- },
4472
- post: async () => {
4473
- throw new Error("slapiApi is not configured. Call registerApi(...) first.");
4474
- },
4475
- put: async () => {
4476
- throw new Error("slapiApi is not configured. Call registerApi(...) first.");
4477
- },
4478
- patch: async () => {
4479
- throw new Error("slapiApi is not configured. Call registerApi(...) first.");
4480
- },
4481
- delete: async () => {
4482
- throw new Error("slapiApi is not configured. Call registerApi(...) first.");
4918
+ return false;
4919
+ }
4920
+ function isSelectableInput(element) {
4921
+ return element instanceof HTMLInputElement && "select" in element;
4922
+ }
4923
+ function focus(element, { select = false } = {}) {
4924
+ if (element && element.focus) {
4925
+ const previouslyFocusedElement = document.activeElement;
4926
+ element.focus({ preventScroll: true });
4927
+ if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
4928
+ element.select();
4483
4929
  }
4484
- };
4485
- var registerApi = (config) => {
4486
- cfg.baseUrl = config.baseUrl;
4487
- cfg.accessToken = config.accessToken;
4488
- cfg.tenantId = config.tenantId;
4489
- slapiApi = {
4490
- get: async (key) => {
4491
- const url = buildUrl(key);
4492
- return request("GET", url);
4493
- },
4494
- post: async (key, body) => {
4495
- const url = buildUrl(key);
4496
- return request("POST", url, body);
4497
- },
4498
- put: async (key, body) => {
4499
- const url = buildUrl(key);
4500
- return request("PUT", url, body);
4930
+ }
4931
+ var focusScopesStack = createFocusScopesStack();
4932
+ function createFocusScopesStack() {
4933
+ let stack = [];
4934
+ return {
4935
+ add(focusScope) {
4936
+ const activeFocusScope = stack[0];
4937
+ if (focusScope !== activeFocusScope) {
4938
+ activeFocusScope?.pause();
4939
+ }
4940
+ stack = arrayRemove(stack, focusScope);
4941
+ stack.unshift(focusScope);
4501
4942
  },
4502
- patch: async (key, body) => {
4943
+ remove(focusScope) {
4944
+ stack = arrayRemove(stack, focusScope);
4945
+ stack[0]?.resume();
4946
+ }
4947
+ };
4948
+ }
4949
+ function arrayRemove(array, item) {
4950
+ const updatedArray = [...array];
4951
+ const index = updatedArray.indexOf(item);
4952
+ if (index !== -1) {
4953
+ updatedArray.splice(index, 1);
4954
+ }
4955
+ return updatedArray;
4956
+ }
4957
+ function removeLinks(items) {
4958
+ return items.filter((item) => item.tagName !== "A");
4959
+ }
4960
+
4961
+ // ../../node_modules/@radix-ui/react-portal/dist/index.mjs
4962
+ var React17 = __toESM(require("react"), 1);
4963
+ var import_react_dom = __toESM(require("react-dom"), 1);
4964
+ var import_jsx_runtime18 = require("react/jsx-runtime");
4965
+ var PORTAL_NAME = "Portal";
4966
+ var Portal = React17.forwardRef((props, forwardedRef) => {
4967
+ const { container: containerProp, ...portalProps } = props;
4968
+ const [mounted, setMounted] = React17.useState(false);
4969
+ useLayoutEffect2(() => setMounted(true), []);
4970
+ const container = containerProp || mounted && globalThis?.document?.body;
4971
+ return container ? import_react_dom.default.createPortal(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
4972
+ });
4973
+ Portal.displayName = PORTAL_NAME;
4974
+
4975
+ // ../../node_modules/@radix-ui/react-focus-guards/dist/index.mjs
4976
+ var React18 = __toESM(require("react"), 1);
4977
+ var count2 = 0;
4978
+ function useFocusGuards() {
4979
+ React18.useEffect(() => {
4980
+ const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
4981
+ document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
4982
+ document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
4983
+ count2++;
4984
+ return () => {
4985
+ if (count2 === 1) {
4986
+ document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
4987
+ }
4988
+ count2--;
4989
+ };
4990
+ }, []);
4991
+ }
4992
+ function createFocusGuard() {
4993
+ const element = document.createElement("span");
4994
+ element.setAttribute("data-radix-focus-guard", "");
4995
+ element.tabIndex = 0;
4996
+ element.style.outline = "none";
4997
+ element.style.opacity = "0";
4998
+ element.style.position = "fixed";
4999
+ element.style.pointerEvents = "none";
5000
+ return element;
5001
+ }
5002
+
5003
+ // ../../node_modules/tslib/tslib.es6.mjs
5004
+ var __assign = function() {
5005
+ __assign = Object.assign || function __assign2(t) {
5006
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5007
+ s = arguments[i];
5008
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
5009
+ }
5010
+ return t;
5011
+ };
5012
+ return __assign.apply(this, arguments);
5013
+ };
5014
+ function __rest(s, e) {
5015
+ var t = {};
5016
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5017
+ t[p] = s[p];
5018
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
5019
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
5020
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
5021
+ t[p[i]] = s[p[i]];
5022
+ }
5023
+ return t;
5024
+ }
5025
+ function __spreadArray(to, from, pack) {
5026
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
5027
+ if (ar || !(i in from)) {
5028
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5029
+ ar[i] = from[i];
5030
+ }
5031
+ }
5032
+ return to.concat(ar || Array.prototype.slice.call(from));
5033
+ }
5034
+
5035
+ // ../../node_modules/react-remove-scroll/dist/es2015/Combination.js
5036
+ var React27 = __toESM(require("react"));
5037
+
5038
+ // ../../node_modules/react-remove-scroll/dist/es2015/UI.js
5039
+ var React21 = __toESM(require("react"));
5040
+
5041
+ // ../../node_modules/react-remove-scroll-bar/dist/es2015/constants.js
5042
+ var zeroRightClassName = "right-scroll-bar-position";
5043
+ var fullWidthClassName = "width-before-scroll-bar";
5044
+ var noScrollbarsClassName = "with-scroll-bars-hidden";
5045
+ var removedBarSizeVariable = "--removed-body-scroll-bar-size";
5046
+
5047
+ // ../../node_modules/use-callback-ref/dist/es2015/assignRef.js
5048
+ function assignRef(ref, value) {
5049
+ if (typeof ref === "function") {
5050
+ ref(value);
5051
+ } else if (ref) {
5052
+ ref.current = value;
5053
+ }
5054
+ return ref;
5055
+ }
5056
+
5057
+ // ../../node_modules/use-callback-ref/dist/es2015/useRef.js
5058
+ var import_react6 = require("react");
5059
+ function useCallbackRef2(initialValue, callback) {
5060
+ var ref = (0, import_react6.useState)(function() {
5061
+ return {
5062
+ // value
5063
+ value: initialValue,
5064
+ // last callback
5065
+ callback,
5066
+ // "memoized" public interface
5067
+ facade: {
5068
+ get current() {
5069
+ return ref.value;
5070
+ },
5071
+ set current(value) {
5072
+ var last = ref.value;
5073
+ if (last !== value) {
5074
+ ref.value = value;
5075
+ ref.callback(value, last);
5076
+ }
5077
+ }
5078
+ }
5079
+ };
5080
+ })[0];
5081
+ ref.callback = callback;
5082
+ return ref.facade;
5083
+ }
5084
+
5085
+ // ../../node_modules/use-callback-ref/dist/es2015/useMergeRef.js
5086
+ var React19 = __toESM(require("react"));
5087
+ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React19.useLayoutEffect : React19.useEffect;
5088
+ var currentValues = /* @__PURE__ */ new WeakMap();
5089
+ function useMergeRefs(refs, defaultValue) {
5090
+ var callbackRef = useCallbackRef2(defaultValue || null, function(newValue) {
5091
+ return refs.forEach(function(ref) {
5092
+ return assignRef(ref, newValue);
5093
+ });
5094
+ });
5095
+ useIsomorphicLayoutEffect(function() {
5096
+ var oldValue = currentValues.get(callbackRef);
5097
+ if (oldValue) {
5098
+ var prevRefs_1 = new Set(oldValue);
5099
+ var nextRefs_1 = new Set(refs);
5100
+ var current_1 = callbackRef.current;
5101
+ prevRefs_1.forEach(function(ref) {
5102
+ if (!nextRefs_1.has(ref)) {
5103
+ assignRef(ref, null);
5104
+ }
5105
+ });
5106
+ nextRefs_1.forEach(function(ref) {
5107
+ if (!prevRefs_1.has(ref)) {
5108
+ assignRef(ref, current_1);
5109
+ }
5110
+ });
5111
+ }
5112
+ currentValues.set(callbackRef, refs);
5113
+ }, [refs]);
5114
+ return callbackRef;
5115
+ }
5116
+
5117
+ // ../../node_modules/use-sidecar/dist/es2015/medium.js
5118
+ function ItoI(a) {
5119
+ return a;
5120
+ }
5121
+ function innerCreateMedium(defaults, middleware) {
5122
+ if (middleware === void 0) {
5123
+ middleware = ItoI;
5124
+ }
5125
+ var buffer = [];
5126
+ var assigned = false;
5127
+ var medium = {
5128
+ read: function() {
5129
+ if (assigned) {
5130
+ throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
5131
+ }
5132
+ if (buffer.length) {
5133
+ return buffer[buffer.length - 1];
5134
+ }
5135
+ return defaults;
5136
+ },
5137
+ useMedium: function(data) {
5138
+ var item = middleware(data, assigned);
5139
+ buffer.push(item);
5140
+ return function() {
5141
+ buffer = buffer.filter(function(x) {
5142
+ return x !== item;
5143
+ });
5144
+ };
5145
+ },
5146
+ assignSyncMedium: function(cb) {
5147
+ assigned = true;
5148
+ while (buffer.length) {
5149
+ var cbs = buffer;
5150
+ buffer = [];
5151
+ cbs.forEach(cb);
5152
+ }
5153
+ buffer = {
5154
+ push: function(x) {
5155
+ return cb(x);
5156
+ },
5157
+ filter: function() {
5158
+ return buffer;
5159
+ }
5160
+ };
5161
+ },
5162
+ assignMedium: function(cb) {
5163
+ assigned = true;
5164
+ var pendingQueue = [];
5165
+ if (buffer.length) {
5166
+ var cbs = buffer;
5167
+ buffer = [];
5168
+ cbs.forEach(cb);
5169
+ pendingQueue = buffer;
5170
+ }
5171
+ var executeQueue = function() {
5172
+ var cbs2 = pendingQueue;
5173
+ pendingQueue = [];
5174
+ cbs2.forEach(cb);
5175
+ };
5176
+ var cycle = function() {
5177
+ return Promise.resolve().then(executeQueue);
5178
+ };
5179
+ cycle();
5180
+ buffer = {
5181
+ push: function(x) {
5182
+ pendingQueue.push(x);
5183
+ cycle();
5184
+ },
5185
+ filter: function(filter) {
5186
+ pendingQueue = pendingQueue.filter(filter);
5187
+ return buffer;
5188
+ }
5189
+ };
5190
+ }
5191
+ };
5192
+ return medium;
5193
+ }
5194
+ function createSidecarMedium(options) {
5195
+ if (options === void 0) {
5196
+ options = {};
5197
+ }
5198
+ var medium = innerCreateMedium(null);
5199
+ medium.options = __assign({ async: true, ssr: false }, options);
5200
+ return medium;
5201
+ }
5202
+
5203
+ // ../../node_modules/use-sidecar/dist/es2015/exports.js
5204
+ var React20 = __toESM(require("react"));
5205
+ var SideCar = function(_a) {
5206
+ var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
5207
+ if (!sideCar) {
5208
+ throw new Error("Sidecar: please provide `sideCar` property to import the right car");
5209
+ }
5210
+ var Target = sideCar.read();
5211
+ if (!Target) {
5212
+ throw new Error("Sidecar medium not found");
5213
+ }
5214
+ return React20.createElement(Target, __assign({}, rest));
5215
+ };
5216
+ SideCar.isSideCarExport = true;
5217
+ function exportSidecar(medium, exported) {
5218
+ medium.useMedium(exported);
5219
+ return SideCar;
5220
+ }
5221
+
5222
+ // ../../node_modules/react-remove-scroll/dist/es2015/medium.js
5223
+ var effectCar = createSidecarMedium();
5224
+
5225
+ // ../../node_modules/react-remove-scroll/dist/es2015/UI.js
5226
+ var nothing = function() {
5227
+ return;
5228
+ };
5229
+ var RemoveScroll = React21.forwardRef(function(props, parentRef) {
5230
+ var ref = React21.useRef(null);
5231
+ var _a = React21.useState({
5232
+ onScrollCapture: nothing,
5233
+ onWheelCapture: nothing,
5234
+ onTouchMoveCapture: nothing
5235
+ }), callbacks = _a[0], setCallbacks = _a[1];
5236
+ var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noRelative = props.noRelative, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? "div" : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
5237
+ var SideCar2 = sideCar;
5238
+ var containerRef = useMergeRefs([ref, parentRef]);
5239
+ var containerProps = __assign(__assign({}, rest), callbacks);
5240
+ return React21.createElement(
5241
+ React21.Fragment,
5242
+ null,
5243
+ enabled && React21.createElement(SideCar2, { sideCar: effectCar, removeScrollBar, shards, noRelative, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }),
5244
+ forwardProps ? React21.cloneElement(React21.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React21.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)
5245
+ );
5246
+ });
5247
+ RemoveScroll.defaultProps = {
5248
+ enabled: true,
5249
+ removeScrollBar: true,
5250
+ inert: false
5251
+ };
5252
+ RemoveScroll.classNames = {
5253
+ fullWidth: fullWidthClassName,
5254
+ zeroRight: zeroRightClassName
5255
+ };
5256
+
5257
+ // ../../node_modules/react-remove-scroll/dist/es2015/SideEffect.js
5258
+ var React26 = __toESM(require("react"));
5259
+
5260
+ // ../../node_modules/react-remove-scroll-bar/dist/es2015/component.js
5261
+ var React25 = __toESM(require("react"));
5262
+
5263
+ // ../../node_modules/react-style-singleton/dist/es2015/hook.js
5264
+ var React24 = __toESM(require("react"));
5265
+
5266
+ // ../../node_modules/get-nonce/dist/es2015/index.js
5267
+ var currentNonce;
5268
+ var getNonce = function() {
5269
+ if (currentNonce) {
5270
+ return currentNonce;
5271
+ }
5272
+ if (typeof __webpack_nonce__ !== "undefined") {
5273
+ return __webpack_nonce__;
5274
+ }
5275
+ return void 0;
5276
+ };
5277
+
5278
+ // ../../node_modules/react-style-singleton/dist/es2015/singleton.js
5279
+ function makeStyleTag() {
5280
+ if (!document)
5281
+ return null;
5282
+ var tag = document.createElement("style");
5283
+ tag.type = "text/css";
5284
+ var nonce = getNonce();
5285
+ if (nonce) {
5286
+ tag.setAttribute("nonce", nonce);
5287
+ }
5288
+ return tag;
5289
+ }
5290
+ function injectStyles(tag, css) {
5291
+ if (tag.styleSheet) {
5292
+ tag.styleSheet.cssText = css;
5293
+ } else {
5294
+ tag.appendChild(document.createTextNode(css));
5295
+ }
5296
+ }
5297
+ function insertStyleTag(tag) {
5298
+ var head = document.head || document.getElementsByTagName("head")[0];
5299
+ head.appendChild(tag);
5300
+ }
5301
+ var stylesheetSingleton = function() {
5302
+ var counter = 0;
5303
+ var stylesheet = null;
5304
+ return {
5305
+ add: function(style2) {
5306
+ if (counter == 0) {
5307
+ if (stylesheet = makeStyleTag()) {
5308
+ injectStyles(stylesheet, style2);
5309
+ insertStyleTag(stylesheet);
5310
+ }
5311
+ }
5312
+ counter++;
5313
+ },
5314
+ remove: function() {
5315
+ counter--;
5316
+ if (!counter && stylesheet) {
5317
+ stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
5318
+ stylesheet = null;
5319
+ }
5320
+ }
5321
+ };
5322
+ };
5323
+
5324
+ // ../../node_modules/react-style-singleton/dist/es2015/hook.js
5325
+ var styleHookSingleton = function() {
5326
+ var sheet = stylesheetSingleton();
5327
+ return function(styles, isDynamic) {
5328
+ React24.useEffect(function() {
5329
+ sheet.add(styles);
5330
+ return function() {
5331
+ sheet.remove();
5332
+ };
5333
+ }, [styles && isDynamic]);
5334
+ };
5335
+ };
5336
+
5337
+ // ../../node_modules/react-style-singleton/dist/es2015/component.js
5338
+ var styleSingleton = function() {
5339
+ var useStyle = styleHookSingleton();
5340
+ var Sheet = function(_a) {
5341
+ var styles = _a.styles, dynamic = _a.dynamic;
5342
+ useStyle(styles, dynamic);
5343
+ return null;
5344
+ };
5345
+ return Sheet;
5346
+ };
5347
+
5348
+ // ../../node_modules/react-remove-scroll-bar/dist/es2015/utils.js
5349
+ var zeroGap = {
5350
+ left: 0,
5351
+ top: 0,
5352
+ right: 0,
5353
+ gap: 0
5354
+ };
5355
+ var parse = function(x) {
5356
+ return parseInt(x || "", 10) || 0;
5357
+ };
5358
+ var getOffset = function(gapMode) {
5359
+ var cs = window.getComputedStyle(document.body);
5360
+ var left = cs[gapMode === "padding" ? "paddingLeft" : "marginLeft"];
5361
+ var top = cs[gapMode === "padding" ? "paddingTop" : "marginTop"];
5362
+ var right = cs[gapMode === "padding" ? "paddingRight" : "marginRight"];
5363
+ return [parse(left), parse(top), parse(right)];
5364
+ };
5365
+ var getGapWidth = function(gapMode) {
5366
+ if (gapMode === void 0) {
5367
+ gapMode = "margin";
5368
+ }
5369
+ if (typeof window === "undefined") {
5370
+ return zeroGap;
5371
+ }
5372
+ var offsets = getOffset(gapMode);
5373
+ var documentWidth = document.documentElement.clientWidth;
5374
+ var windowWidth = window.innerWidth;
5375
+ return {
5376
+ left: offsets[0],
5377
+ top: offsets[1],
5378
+ right: offsets[2],
5379
+ gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0])
5380
+ };
5381
+ };
5382
+
5383
+ // ../../node_modules/react-remove-scroll-bar/dist/es2015/component.js
5384
+ var Style = styleSingleton();
5385
+ var lockAttribute = "data-scroll-locked";
5386
+ var getStyles = function(_a, allowRelative, gapMode, important) {
5387
+ var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
5388
+ if (gapMode === void 0) {
5389
+ gapMode = "margin";
5390
+ }
5391
+ return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
5392
+ allowRelative && "position: relative ".concat(important, ";"),
5393
+ gapMode === "margin" && "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
5394
+ gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";")
5395
+ ].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
5396
+ };
5397
+ var getCurrentUseCounter = function() {
5398
+ var counter = parseInt(document.body.getAttribute(lockAttribute) || "0", 10);
5399
+ return isFinite(counter) ? counter : 0;
5400
+ };
5401
+ var useLockAttribute = function() {
5402
+ React25.useEffect(function() {
5403
+ document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
5404
+ return function() {
5405
+ var newCounter = getCurrentUseCounter() - 1;
5406
+ if (newCounter <= 0) {
5407
+ document.body.removeAttribute(lockAttribute);
5408
+ } else {
5409
+ document.body.setAttribute(lockAttribute, newCounter.toString());
5410
+ }
5411
+ };
5412
+ }, []);
5413
+ };
5414
+ var RemoveScrollBar = function(_a) {
5415
+ var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
5416
+ useLockAttribute();
5417
+ var gap = React25.useMemo(function() {
5418
+ return getGapWidth(gapMode);
5419
+ }, [gapMode]);
5420
+ return React25.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") });
5421
+ };
5422
+
5423
+ // ../../node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js
5424
+ var passiveSupported = false;
5425
+ if (typeof window !== "undefined") {
5426
+ try {
5427
+ options = Object.defineProperty({}, "passive", {
5428
+ get: function() {
5429
+ passiveSupported = true;
5430
+ return true;
5431
+ }
5432
+ });
5433
+ window.addEventListener("test", options, options);
5434
+ window.removeEventListener("test", options, options);
5435
+ } catch (err) {
5436
+ passiveSupported = false;
5437
+ }
5438
+ }
5439
+ var options;
5440
+ var nonPassive = passiveSupported ? { passive: false } : false;
5441
+
5442
+ // ../../node_modules/react-remove-scroll/dist/es2015/handleScroll.js
5443
+ var alwaysContainsScroll = function(node) {
5444
+ return node.tagName === "TEXTAREA";
5445
+ };
5446
+ var elementCanBeScrolled = function(node, overflow) {
5447
+ if (!(node instanceof Element)) {
5448
+ return false;
5449
+ }
5450
+ var styles = window.getComputedStyle(node);
5451
+ return (
5452
+ // not-not-scrollable
5453
+ styles[overflow] !== "hidden" && // contains scroll inside self
5454
+ !(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === "visible")
5455
+ );
5456
+ };
5457
+ var elementCouldBeVScrolled = function(node) {
5458
+ return elementCanBeScrolled(node, "overflowY");
5459
+ };
5460
+ var elementCouldBeHScrolled = function(node) {
5461
+ return elementCanBeScrolled(node, "overflowX");
5462
+ };
5463
+ var locationCouldBeScrolled = function(axis, node) {
5464
+ var ownerDocument = node.ownerDocument;
5465
+ var current = node;
5466
+ do {
5467
+ if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
5468
+ current = current.host;
5469
+ }
5470
+ var isScrollable = elementCouldBeScrolled(axis, current);
5471
+ if (isScrollable) {
5472
+ var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
5473
+ if (scrollHeight > clientHeight) {
5474
+ return true;
5475
+ }
5476
+ }
5477
+ current = current.parentNode;
5478
+ } while (current && current !== ownerDocument.body);
5479
+ return false;
5480
+ };
5481
+ var getVScrollVariables = function(_a) {
5482
+ var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
5483
+ return [
5484
+ scrollTop,
5485
+ scrollHeight,
5486
+ clientHeight
5487
+ ];
5488
+ };
5489
+ var getHScrollVariables = function(_a) {
5490
+ var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
5491
+ return [
5492
+ scrollLeft,
5493
+ scrollWidth,
5494
+ clientWidth
5495
+ ];
5496
+ };
5497
+ var elementCouldBeScrolled = function(axis, node) {
5498
+ return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
5499
+ };
5500
+ var getScrollVariables = function(axis, node) {
5501
+ return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node);
5502
+ };
5503
+ var getDirectionFactor = function(axis, direction) {
5504
+ return axis === "h" && direction === "rtl" ? -1 : 1;
5505
+ };
5506
+ var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
5507
+ var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
5508
+ var delta = directionFactor * sourceDelta;
5509
+ var target = event.target;
5510
+ var targetInLock = endTarget.contains(target);
5511
+ var shouldCancelScroll = false;
5512
+ var isDeltaPositive = delta > 0;
5513
+ var availableScroll = 0;
5514
+ var availableScrollTop = 0;
5515
+ do {
5516
+ if (!target) {
5517
+ break;
5518
+ }
5519
+ var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
5520
+ var elementScroll = scroll_1 - capacity - directionFactor * position;
5521
+ if (position || elementScroll) {
5522
+ if (elementCouldBeScrolled(axis, target)) {
5523
+ availableScroll += elementScroll;
5524
+ availableScrollTop += position;
5525
+ }
5526
+ }
5527
+ var parent_1 = target.parentNode;
5528
+ target = parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1;
5529
+ } while (
5530
+ // portaled content
5531
+ !targetInLock && target !== document.body || // self content
5532
+ targetInLock && (endTarget.contains(target) || endTarget === target)
5533
+ );
5534
+ if (isDeltaPositive && (noOverscroll && Math.abs(availableScroll) < 1 || !noOverscroll && delta > availableScroll)) {
5535
+ shouldCancelScroll = true;
5536
+ } else if (!isDeltaPositive && (noOverscroll && Math.abs(availableScrollTop) < 1 || !noOverscroll && -delta > availableScrollTop)) {
5537
+ shouldCancelScroll = true;
5538
+ }
5539
+ return shouldCancelScroll;
5540
+ };
5541
+
5542
+ // ../../node_modules/react-remove-scroll/dist/es2015/SideEffect.js
5543
+ var getTouchXY = function(event) {
5544
+ return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
5545
+ };
5546
+ var getDeltaXY = function(event) {
5547
+ return [event.deltaX, event.deltaY];
5548
+ };
5549
+ var extractRef = function(ref) {
5550
+ return ref && "current" in ref ? ref.current : ref;
5551
+ };
5552
+ var deltaCompare = function(x, y) {
5553
+ return x[0] === y[0] && x[1] === y[1];
5554
+ };
5555
+ var generateStyle = function(id) {
5556
+ return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
5557
+ };
5558
+ var idCounter = 0;
5559
+ var lockStack = [];
5560
+ function RemoveScrollSideCar(props) {
5561
+ var shouldPreventQueue = React26.useRef([]);
5562
+ var touchStartRef = React26.useRef([0, 0]);
5563
+ var activeAxis = React26.useRef();
5564
+ var id = React26.useState(idCounter++)[0];
5565
+ var Style2 = React26.useState(styleSingleton)[0];
5566
+ var lastProps = React26.useRef(props);
5567
+ React26.useEffect(function() {
5568
+ lastProps.current = props;
5569
+ }, [props]);
5570
+ React26.useEffect(function() {
5571
+ if (props.inert) {
5572
+ document.body.classList.add("block-interactivity-".concat(id));
5573
+ var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
5574
+ allow_1.forEach(function(el) {
5575
+ return el.classList.add("allow-interactivity-".concat(id));
5576
+ });
5577
+ return function() {
5578
+ document.body.classList.remove("block-interactivity-".concat(id));
5579
+ allow_1.forEach(function(el) {
5580
+ return el.classList.remove("allow-interactivity-".concat(id));
5581
+ });
5582
+ };
5583
+ }
5584
+ return;
5585
+ }, [props.inert, props.lockRef.current, props.shards]);
5586
+ var shouldCancelEvent = React26.useCallback(function(event, parent) {
5587
+ if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) {
5588
+ return !lastProps.current.allowPinchZoom;
5589
+ }
5590
+ var touch = getTouchXY(event);
5591
+ var touchStart = touchStartRef.current;
5592
+ var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
5593
+ var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
5594
+ var currentAxis;
5595
+ var target = event.target;
5596
+ var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
5597
+ if ("touches" in event && moveDirection === "h" && target.type === "range") {
5598
+ return false;
5599
+ }
5600
+ var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
5601
+ if (!canBeScrolledInMainDirection) {
5602
+ return true;
5603
+ }
5604
+ if (canBeScrolledInMainDirection) {
5605
+ currentAxis = moveDirection;
5606
+ } else {
5607
+ currentAxis = moveDirection === "v" ? "h" : "v";
5608
+ canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
5609
+ }
5610
+ if (!canBeScrolledInMainDirection) {
5611
+ return false;
5612
+ }
5613
+ if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) {
5614
+ activeAxis.current = currentAxis;
5615
+ }
5616
+ if (!currentAxis) {
5617
+ return true;
5618
+ }
5619
+ var cancelingAxis = activeAxis.current || currentAxis;
5620
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY, true);
5621
+ }, []);
5622
+ var shouldPrevent = React26.useCallback(function(_event) {
5623
+ var event = _event;
5624
+ if (!lockStack.length || lockStack[lockStack.length - 1] !== Style2) {
5625
+ return;
5626
+ }
5627
+ var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
5628
+ var sourceEvent = shouldPreventQueue.current.filter(function(e) {
5629
+ return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
5630
+ })[0];
5631
+ if (sourceEvent && sourceEvent.should) {
5632
+ if (event.cancelable) {
5633
+ event.preventDefault();
5634
+ }
5635
+ return;
5636
+ }
5637
+ if (!sourceEvent) {
5638
+ var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
5639
+ return node.contains(event.target);
5640
+ });
5641
+ var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
5642
+ if (shouldStop) {
5643
+ if (event.cancelable) {
5644
+ event.preventDefault();
5645
+ }
5646
+ }
5647
+ }
5648
+ }, []);
5649
+ var shouldCancel = React26.useCallback(function(name, delta, target, should) {
5650
+ var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
5651
+ shouldPreventQueue.current.push(event);
5652
+ setTimeout(function() {
5653
+ shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
5654
+ return e !== event;
5655
+ });
5656
+ }, 1);
5657
+ }, []);
5658
+ var scrollTouchStart = React26.useCallback(function(event) {
5659
+ touchStartRef.current = getTouchXY(event);
5660
+ activeAxis.current = void 0;
5661
+ }, []);
5662
+ var scrollWheel = React26.useCallback(function(event) {
5663
+ shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
5664
+ }, []);
5665
+ var scrollTouchMove = React26.useCallback(function(event) {
5666
+ shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
5667
+ }, []);
5668
+ React26.useEffect(function() {
5669
+ lockStack.push(Style2);
5670
+ props.setCallbacks({
5671
+ onScrollCapture: scrollWheel,
5672
+ onWheelCapture: scrollWheel,
5673
+ onTouchMoveCapture: scrollTouchMove
5674
+ });
5675
+ document.addEventListener("wheel", shouldPrevent, nonPassive);
5676
+ document.addEventListener("touchmove", shouldPrevent, nonPassive);
5677
+ document.addEventListener("touchstart", scrollTouchStart, nonPassive);
5678
+ return function() {
5679
+ lockStack = lockStack.filter(function(inst) {
5680
+ return inst !== Style2;
5681
+ });
5682
+ document.removeEventListener("wheel", shouldPrevent, nonPassive);
5683
+ document.removeEventListener("touchmove", shouldPrevent, nonPassive);
5684
+ document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
5685
+ };
5686
+ }, []);
5687
+ var removeScrollBar = props.removeScrollBar, inert = props.inert;
5688
+ return React26.createElement(
5689
+ React26.Fragment,
5690
+ null,
5691
+ inert ? React26.createElement(Style2, { styles: generateStyle(id) }) : null,
5692
+ removeScrollBar ? React26.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null
5693
+ );
5694
+ }
5695
+ function getOutermostShadowParent(node) {
5696
+ var shadowParent = null;
5697
+ while (node !== null) {
5698
+ if (node instanceof ShadowRoot) {
5699
+ shadowParent = node.host;
5700
+ node = node.host;
5701
+ }
5702
+ node = node.parentNode;
5703
+ }
5704
+ return shadowParent;
5705
+ }
5706
+
5707
+ // ../../node_modules/react-remove-scroll/dist/es2015/sidecar.js
5708
+ var sidecar_default = exportSidecar(effectCar, RemoveScrollSideCar);
5709
+
5710
+ // ../../node_modules/react-remove-scroll/dist/es2015/Combination.js
5711
+ var ReactRemoveScroll = React27.forwardRef(function(props, ref) {
5712
+ return React27.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: sidecar_default }));
5713
+ });
5714
+ ReactRemoveScroll.classNames = RemoveScroll.classNames;
5715
+ var Combination_default = ReactRemoveScroll;
5716
+
5717
+ // ../../node_modules/aria-hidden/dist/es2015/index.js
5718
+ var getDefaultParent = function(originalTarget) {
5719
+ if (typeof document === "undefined") {
5720
+ return null;
5721
+ }
5722
+ var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
5723
+ return sampleTarget.ownerDocument.body;
5724
+ };
5725
+ var counterMap = /* @__PURE__ */ new WeakMap();
5726
+ var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
5727
+ var markerMap = {};
5728
+ var lockCount = 0;
5729
+ var unwrapHost = function(node) {
5730
+ return node && (node.host || unwrapHost(node.parentNode));
5731
+ };
5732
+ var correctTargets = function(parent, targets) {
5733
+ return targets.map(function(target) {
5734
+ if (parent.contains(target)) {
5735
+ return target;
5736
+ }
5737
+ var correctedTarget = unwrapHost(target);
5738
+ if (correctedTarget && parent.contains(correctedTarget)) {
5739
+ return correctedTarget;
5740
+ }
5741
+ console.error("aria-hidden", target, "in not contained inside", parent, ". Doing nothing");
5742
+ return null;
5743
+ }).filter(function(x) {
5744
+ return Boolean(x);
5745
+ });
5746
+ };
5747
+ var applyAttributeToOthers = function(originalTarget, parentNode, markerName, controlAttribute) {
5748
+ var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
5749
+ if (!markerMap[markerName]) {
5750
+ markerMap[markerName] = /* @__PURE__ */ new WeakMap();
5751
+ }
5752
+ var markerCounter = markerMap[markerName];
5753
+ var hiddenNodes = [];
5754
+ var elementsToKeep = /* @__PURE__ */ new Set();
5755
+ var elementsToStop = new Set(targets);
5756
+ var keep = function(el) {
5757
+ if (!el || elementsToKeep.has(el)) {
5758
+ return;
5759
+ }
5760
+ elementsToKeep.add(el);
5761
+ keep(el.parentNode);
5762
+ };
5763
+ targets.forEach(keep);
5764
+ var deep = function(parent) {
5765
+ if (!parent || elementsToStop.has(parent)) {
5766
+ return;
5767
+ }
5768
+ Array.prototype.forEach.call(parent.children, function(node) {
5769
+ if (elementsToKeep.has(node)) {
5770
+ deep(node);
5771
+ } else {
5772
+ try {
5773
+ var attr = node.getAttribute(controlAttribute);
5774
+ var alreadyHidden = attr !== null && attr !== "false";
5775
+ var counterValue = (counterMap.get(node) || 0) + 1;
5776
+ var markerValue = (markerCounter.get(node) || 0) + 1;
5777
+ counterMap.set(node, counterValue);
5778
+ markerCounter.set(node, markerValue);
5779
+ hiddenNodes.push(node);
5780
+ if (counterValue === 1 && alreadyHidden) {
5781
+ uncontrolledNodes.set(node, true);
5782
+ }
5783
+ if (markerValue === 1) {
5784
+ node.setAttribute(markerName, "true");
5785
+ }
5786
+ if (!alreadyHidden) {
5787
+ node.setAttribute(controlAttribute, "true");
5788
+ }
5789
+ } catch (e) {
5790
+ console.error("aria-hidden: cannot operate on ", node, e);
5791
+ }
5792
+ }
5793
+ });
5794
+ };
5795
+ deep(parentNode);
5796
+ elementsToKeep.clear();
5797
+ lockCount++;
5798
+ return function() {
5799
+ hiddenNodes.forEach(function(node) {
5800
+ var counterValue = counterMap.get(node) - 1;
5801
+ var markerValue = markerCounter.get(node) - 1;
5802
+ counterMap.set(node, counterValue);
5803
+ markerCounter.set(node, markerValue);
5804
+ if (!counterValue) {
5805
+ if (!uncontrolledNodes.has(node)) {
5806
+ node.removeAttribute(controlAttribute);
5807
+ }
5808
+ uncontrolledNodes.delete(node);
5809
+ }
5810
+ if (!markerValue) {
5811
+ node.removeAttribute(markerName);
5812
+ }
5813
+ });
5814
+ lockCount--;
5815
+ if (!lockCount) {
5816
+ counterMap = /* @__PURE__ */ new WeakMap();
5817
+ counterMap = /* @__PURE__ */ new WeakMap();
5818
+ uncontrolledNodes = /* @__PURE__ */ new WeakMap();
5819
+ markerMap = {};
5820
+ }
5821
+ };
5822
+ };
5823
+ var hideOthers = function(originalTarget, parentNode, markerName) {
5824
+ if (markerName === void 0) {
5825
+ markerName = "data-aria-hidden";
5826
+ }
5827
+ var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
5828
+ var activeParentNode = parentNode || getDefaultParent(originalTarget);
5829
+ if (!activeParentNode) {
5830
+ return function() {
5831
+ return null;
5832
+ };
5833
+ }
5834
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live], script")));
5835
+ return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
5836
+ };
5837
+
5838
+ // ../../node_modules/@radix-ui/react-dialog/dist/index.mjs
5839
+ var import_jsx_runtime19 = require("react/jsx-runtime");
5840
+ var DIALOG_NAME = "Dialog";
5841
+ var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
5842
+ var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
5843
+ var Dialog = (props) => {
5844
+ const {
5845
+ __scopeDialog,
5846
+ children,
5847
+ open: openProp,
5848
+ defaultOpen,
5849
+ onOpenChange,
5850
+ modal = true
5851
+ } = props;
5852
+ const triggerRef = React28.useRef(null);
5853
+ const contentRef = React28.useRef(null);
5854
+ const [open, setOpen] = useControllableState({
5855
+ prop: openProp,
5856
+ defaultProp: defaultOpen ?? false,
5857
+ onChange: onOpenChange,
5858
+ caller: DIALOG_NAME
5859
+ });
5860
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5861
+ DialogProvider,
5862
+ {
5863
+ scope: __scopeDialog,
5864
+ triggerRef,
5865
+ contentRef,
5866
+ contentId: useId2(),
5867
+ titleId: useId2(),
5868
+ descriptionId: useId2(),
5869
+ open,
5870
+ onOpenChange: setOpen,
5871
+ onOpenToggle: React28.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
5872
+ modal,
5873
+ children
5874
+ }
5875
+ );
5876
+ };
5877
+ Dialog.displayName = DIALOG_NAME;
5878
+ var TRIGGER_NAME2 = "DialogTrigger";
5879
+ var DialogTrigger = React28.forwardRef(
5880
+ (props, forwardedRef) => {
5881
+ const { __scopeDialog, ...triggerProps } = props;
5882
+ const context = useDialogContext(TRIGGER_NAME2, __scopeDialog);
5883
+ const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
5884
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5885
+ Primitive.button,
5886
+ {
5887
+ type: "button",
5888
+ "aria-haspopup": "dialog",
5889
+ "aria-expanded": context.open,
5890
+ "aria-controls": context.contentId,
5891
+ "data-state": getState2(context.open),
5892
+ ...triggerProps,
5893
+ ref: composedTriggerRef,
5894
+ onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
5895
+ }
5896
+ );
5897
+ }
5898
+ );
5899
+ DialogTrigger.displayName = TRIGGER_NAME2;
5900
+ var PORTAL_NAME2 = "DialogPortal";
5901
+ var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME2, {
5902
+ forceMount: void 0
5903
+ });
5904
+ var DialogPortal = (props) => {
5905
+ const { __scopeDialog, forceMount, children, container } = props;
5906
+ const context = useDialogContext(PORTAL_NAME2, __scopeDialog);
5907
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PortalProvider, { scope: __scopeDialog, forceMount, children: React28.Children.map(children, (child) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Portal, { asChild: true, container, children: child }) })) });
5908
+ };
5909
+ DialogPortal.displayName = PORTAL_NAME2;
5910
+ var OVERLAY_NAME = "DialogOverlay";
5911
+ var DialogOverlay = React28.forwardRef(
5912
+ (props, forwardedRef) => {
5913
+ const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
5914
+ const { forceMount = portalContext.forceMount, ...overlayProps } = props;
5915
+ const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
5916
+ return context.modal ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
5917
+ }
5918
+ );
5919
+ DialogOverlay.displayName = OVERLAY_NAME;
5920
+ var Slot2 = createSlot("DialogOverlay.RemoveScroll");
5921
+ var DialogOverlayImpl = React28.forwardRef(
5922
+ (props, forwardedRef) => {
5923
+ const { __scopeDialog, ...overlayProps } = props;
5924
+ const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
5925
+ return (
5926
+ // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
5927
+ // ie. when `Overlay` and `Content` are siblings
5928
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Combination_default, { as: Slot2, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5929
+ Primitive.div,
5930
+ {
5931
+ "data-state": getState2(context.open),
5932
+ ...overlayProps,
5933
+ ref: forwardedRef,
5934
+ style: { pointerEvents: "auto", ...overlayProps.style }
5935
+ }
5936
+ ) })
5937
+ );
5938
+ }
5939
+ );
5940
+ var CONTENT_NAME = "DialogContent";
5941
+ var DialogContent = React28.forwardRef(
5942
+ (props, forwardedRef) => {
5943
+ const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
5944
+ const { forceMount = portalContext.forceMount, ...contentProps } = props;
5945
+ const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
5946
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
5947
+ }
5948
+ );
5949
+ DialogContent.displayName = CONTENT_NAME;
5950
+ var DialogContentModal = React28.forwardRef(
5951
+ (props, forwardedRef) => {
5952
+ const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
5953
+ const contentRef = React28.useRef(null);
5954
+ const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
5955
+ React28.useEffect(() => {
5956
+ const content = contentRef.current;
5957
+ if (content) return hideOthers(content);
5958
+ }, []);
5959
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5960
+ DialogContentImpl,
5961
+ {
5962
+ ...props,
5963
+ ref: composedRefs,
5964
+ trapFocus: context.open,
5965
+ disableOutsidePointerEvents: true,
5966
+ onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
5967
+ event.preventDefault();
5968
+ context.triggerRef.current?.focus();
5969
+ }),
5970
+ onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
5971
+ const originalEvent = event.detail.originalEvent;
5972
+ const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
5973
+ const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
5974
+ if (isRightClick) event.preventDefault();
5975
+ }),
5976
+ onFocusOutside: composeEventHandlers(
5977
+ props.onFocusOutside,
5978
+ (event) => event.preventDefault()
5979
+ )
5980
+ }
5981
+ );
5982
+ }
5983
+ );
5984
+ var DialogContentNonModal = React28.forwardRef(
5985
+ (props, forwardedRef) => {
5986
+ const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
5987
+ const hasInteractedOutsideRef = React28.useRef(false);
5988
+ const hasPointerDownOutsideRef = React28.useRef(false);
5989
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
5990
+ DialogContentImpl,
5991
+ {
5992
+ ...props,
5993
+ ref: forwardedRef,
5994
+ trapFocus: false,
5995
+ disableOutsidePointerEvents: false,
5996
+ onCloseAutoFocus: (event) => {
5997
+ props.onCloseAutoFocus?.(event);
5998
+ if (!event.defaultPrevented) {
5999
+ if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
6000
+ event.preventDefault();
6001
+ }
6002
+ hasInteractedOutsideRef.current = false;
6003
+ hasPointerDownOutsideRef.current = false;
6004
+ },
6005
+ onInteractOutside: (event) => {
6006
+ props.onInteractOutside?.(event);
6007
+ if (!event.defaultPrevented) {
6008
+ hasInteractedOutsideRef.current = true;
6009
+ if (event.detail.originalEvent.type === "pointerdown") {
6010
+ hasPointerDownOutsideRef.current = true;
6011
+ }
6012
+ }
6013
+ const target = event.target;
6014
+ const targetIsTrigger = context.triggerRef.current?.contains(target);
6015
+ if (targetIsTrigger) event.preventDefault();
6016
+ if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
6017
+ event.preventDefault();
6018
+ }
6019
+ }
6020
+ }
6021
+ );
6022
+ }
6023
+ );
6024
+ var DialogContentImpl = React28.forwardRef(
6025
+ (props, forwardedRef) => {
6026
+ const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
6027
+ const context = useDialogContext(CONTENT_NAME, __scopeDialog);
6028
+ const contentRef = React28.useRef(null);
6029
+ const composedRefs = useComposedRefs(forwardedRef, contentRef);
6030
+ useFocusGuards();
6031
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
6032
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
6033
+ FocusScope,
6034
+ {
6035
+ asChild: true,
6036
+ loop: true,
6037
+ trapped: trapFocus,
6038
+ onMountAutoFocus: onOpenAutoFocus,
6039
+ onUnmountAutoFocus: onCloseAutoFocus,
6040
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
6041
+ DismissableLayer,
6042
+ {
6043
+ role: "dialog",
6044
+ id: context.contentId,
6045
+ "aria-describedby": context.descriptionId,
6046
+ "aria-labelledby": context.titleId,
6047
+ "data-state": getState2(context.open),
6048
+ ...contentProps,
6049
+ ref: composedRefs,
6050
+ onDismiss: () => context.onOpenChange(false)
6051
+ }
6052
+ )
6053
+ }
6054
+ ),
6055
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
6056
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TitleWarning, { titleId: context.titleId }),
6057
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
6058
+ ] })
6059
+ ] });
6060
+ }
6061
+ );
6062
+ var TITLE_NAME = "DialogTitle";
6063
+ var DialogTitle = React28.forwardRef(
6064
+ (props, forwardedRef) => {
6065
+ const { __scopeDialog, ...titleProps } = props;
6066
+ const context = useDialogContext(TITLE_NAME, __scopeDialog);
6067
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
6068
+ }
6069
+ );
6070
+ DialogTitle.displayName = TITLE_NAME;
6071
+ var DESCRIPTION_NAME = "DialogDescription";
6072
+ var DialogDescription = React28.forwardRef(
6073
+ (props, forwardedRef) => {
6074
+ const { __scopeDialog, ...descriptionProps } = props;
6075
+ const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
6076
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
6077
+ }
6078
+ );
6079
+ DialogDescription.displayName = DESCRIPTION_NAME;
6080
+ var CLOSE_NAME = "DialogClose";
6081
+ var DialogClose = React28.forwardRef(
6082
+ (props, forwardedRef) => {
6083
+ const { __scopeDialog, ...closeProps } = props;
6084
+ const context = useDialogContext(CLOSE_NAME, __scopeDialog);
6085
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
6086
+ Primitive.button,
6087
+ {
6088
+ type: "button",
6089
+ ...closeProps,
6090
+ ref: forwardedRef,
6091
+ onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
6092
+ }
6093
+ );
6094
+ }
6095
+ );
6096
+ DialogClose.displayName = CLOSE_NAME;
6097
+ function getState2(open) {
6098
+ return open ? "open" : "closed";
6099
+ }
6100
+ var TITLE_WARNING_NAME = "DialogTitleWarning";
6101
+ var [WarningProvider, useWarningContext] = createContext22(TITLE_WARNING_NAME, {
6102
+ contentName: CONTENT_NAME,
6103
+ titleName: TITLE_NAME,
6104
+ docsSlug: "dialog"
6105
+ });
6106
+ var TitleWarning = ({ titleId }) => {
6107
+ const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
6108
+ const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
6109
+
6110
+ If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
6111
+
6112
+ For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
6113
+ React28.useEffect(() => {
6114
+ if (titleId) {
6115
+ const hasTitle = document.getElementById(titleId);
6116
+ if (!hasTitle) console.error(MESSAGE);
6117
+ }
6118
+ }, [MESSAGE, titleId]);
6119
+ return null;
6120
+ };
6121
+ var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
6122
+ var DescriptionWarning = ({ contentRef, descriptionId }) => {
6123
+ const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
6124
+ const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
6125
+ React28.useEffect(() => {
6126
+ const describedById = contentRef.current?.getAttribute("aria-describedby");
6127
+ if (descriptionId && describedById) {
6128
+ const hasDescription = document.getElementById(descriptionId);
6129
+ if (!hasDescription) console.warn(MESSAGE);
6130
+ }
6131
+ }, [MESSAGE, contentRef, descriptionId]);
6132
+ return null;
6133
+ };
6134
+ var Root2 = Dialog;
6135
+ var Portal2 = DialogPortal;
6136
+ var Overlay = DialogOverlay;
6137
+ var Content = DialogContent;
6138
+ var Title = DialogTitle;
6139
+ var Close = DialogClose;
6140
+
6141
+ // ../ui/src/components/dialog.tsx
6142
+ var import_jsx_runtime20 = require("react/jsx-runtime");
6143
+ function Dialog2({ ...props }) {
6144
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Root2, { "data-slot": "dialog", ...props });
6145
+ }
6146
+ function DialogPortal2({ ...props }) {
6147
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Portal2, { "data-slot": "dialog-portal", ...props });
6148
+ }
6149
+ function DialogOverlay2({ className, ...props }) {
6150
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
6151
+ Overlay,
6152
+ {
6153
+ "data-slot": "dialog-overlay",
6154
+ className: cn(
6155
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
6156
+ className
6157
+ ),
6158
+ ...props
6159
+ }
6160
+ );
6161
+ }
6162
+ function DialogContent2({
6163
+ className,
6164
+ children,
6165
+ showCloseButton = true,
6166
+ ...props
6167
+ }) {
6168
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DialogPortal2, { "data-slot": "dialog-portal", children: [
6169
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DialogOverlay2, {}),
6170
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
6171
+ Content,
6172
+ {
6173
+ "data-slot": "dialog-content",
6174
+ className: cn(
6175
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
6176
+ className
6177
+ ),
6178
+ ...props,
6179
+ children: [
6180
+ children,
6181
+ showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
6182
+ Close,
6183
+ {
6184
+ "data-slot": "dialog-close",
6185
+ className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
6186
+ children: [
6187
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(X, {}),
6188
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "sr-only", children: "Close" })
6189
+ ]
6190
+ }
6191
+ )
6192
+ ]
6193
+ }
6194
+ )
6195
+ ] });
6196
+ }
6197
+ function DialogTitle2({ className, ...props }) {
6198
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
6199
+ Title,
6200
+ {
6201
+ "data-slot": "dialog-title",
6202
+ className: cn("text-lg leading-none font-semibold", className),
6203
+ ...props
6204
+ }
6205
+ );
6206
+ }
6207
+
6208
+ // ../ui/src/components/input.tsx
6209
+ var import_jsx_runtime21 = require("react/jsx-runtime");
6210
+ function Input({ className, type, ...props }) {
6211
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
6212
+ "input",
6213
+ {
6214
+ type,
6215
+ "data-slot": "input",
6216
+ className: cn(
6217
+ "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
6218
+ "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
6219
+ "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
6220
+ className
6221
+ ),
6222
+ ...props
6223
+ }
6224
+ );
6225
+ }
6226
+
6227
+ // ../../node_modules/@radix-ui/react-separator/dist/index.mjs
6228
+ var React29 = __toESM(require("react"), 1);
6229
+ var import_jsx_runtime22 = require("react/jsx-runtime");
6230
+ var NAME2 = "Separator";
6231
+ var DEFAULT_ORIENTATION = "horizontal";
6232
+ var ORIENTATIONS = ["horizontal", "vertical"];
6233
+ var Separator = React29.forwardRef((props, forwardedRef) => {
6234
+ const { decorative, orientation: orientationProp = DEFAULT_ORIENTATION, ...domProps } = props;
6235
+ const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
6236
+ const ariaOrientation = orientation === "vertical" ? orientation : void 0;
6237
+ const semanticProps = decorative ? { role: "none" } : { "aria-orientation": ariaOrientation, role: "separator" };
6238
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
6239
+ Primitive.div,
6240
+ {
6241
+ "data-orientation": orientation,
6242
+ ...semanticProps,
6243
+ ...domProps,
6244
+ ref: forwardedRef
6245
+ }
6246
+ );
6247
+ });
6248
+ Separator.displayName = NAME2;
6249
+ function isValidOrientation(orientation) {
6250
+ return ORIENTATIONS.includes(orientation);
6251
+ }
6252
+ var Root3 = Separator;
6253
+
6254
+ // ../ui/src/components/separator.tsx
6255
+ var import_jsx_runtime23 = require("react/jsx-runtime");
6256
+ function Separator2({
6257
+ className,
6258
+ orientation = "horizontal",
6259
+ decorative = true,
6260
+ ...props
6261
+ }) {
6262
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
6263
+ Root3,
6264
+ {
6265
+ "data-slot": "separator",
6266
+ decorative,
6267
+ orientation,
6268
+ className: cn(
6269
+ "bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
6270
+ className
6271
+ ),
6272
+ ...props
6273
+ }
6274
+ );
6275
+ }
6276
+
6277
+ // src/hooks/useBaseERC20Token.ts
6278
+ var React30 = __toESM(require("react"), 1);
6279
+ var import_viem = require("viem");
6280
+ var import_wagmi = require("wagmi");
6281
+
6282
+ // src/config/baseTokens.ts
6283
+ var BASE_TOKENS = [
6284
+ {
6285
+ address: "0x2b11834ed1feaed4b4b3a86a6f571315e25a884d",
6286
+ chainId: 8453,
6287
+ decimals: 18,
6288
+ symbol: "MOCA",
6289
+ name: "Moca",
6290
+ logoURI: "https://assets.coingecko.com/coins/images/30046/standard/moca.png"
6291
+ },
6292
+ {
6293
+ address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bDA02913",
6294
+ chainId: 8453,
6295
+ decimals: 6,
6296
+ symbol: "USDC",
6297
+ name: "USD Coin",
6298
+ logoURI: "https://cryptologos.cc/logos/usd-coin-usdc-logo.png"
6299
+ },
6300
+ {
6301
+ address: "0x4200000000000000000000000000000000000006",
6302
+ chainId: 8453,
6303
+ decimals: 18,
6304
+ symbol: "WETH",
6305
+ name: "Wrapped Ether",
6306
+ logoURI: "https://static.cdnlogo.com/logos/e/84/ethereum-eth_thumb.png"
6307
+ },
6308
+ {
6309
+ address: "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
6310
+ chainId: 8453,
6311
+ decimals: 6,
6312
+ symbol: "USDT",
6313
+ name: "Tether USD",
6314
+ logoURI: "https://cryptologos.cc/logos/tether-usdt-logo.png"
6315
+ }
6316
+ ];
6317
+
6318
+ // src/hooks/useBaseERC20Token.ts
6319
+ function useBaseERC20Token() {
6320
+ const { address } = (0, import_wagmi.useAccount)();
6321
+ const baseClient = (0, import_wagmi.usePublicClient)({ chainId: 8453 });
6322
+ const defaultClient = (0, import_wagmi.usePublicClient)();
6323
+ const [rows, setRows] = React30.useState([]);
6324
+ const [isLoading, setLoading] = React30.useState(false);
6325
+ const [error, setError] = React30.useState(null);
6326
+ React30.useEffect(() => {
6327
+ let cancelled = false;
6328
+ async function run() {
6329
+ const client = baseClient ?? defaultClient;
6330
+ if (!address || !client) {
6331
+ setRows([]);
6332
+ return;
6333
+ }
6334
+ setLoading(true);
6335
+ try {
6336
+ const normalizedTokens = [];
6337
+ for (const t of BASE_TOKENS) {
6338
+ try {
6339
+ const addr = (0, import_viem.getAddress)(t.address);
6340
+ normalizedTokens.push({ ...t, address: addr });
6341
+ } catch {
6342
+ }
6343
+ }
6344
+ const res = await client.multicall({
6345
+ allowFailure: true,
6346
+ contracts: normalizedTokens.map((t) => ({
6347
+ address: t.address,
6348
+ abi: import_viem.erc20Abi,
6349
+ functionName: "balanceOf",
6350
+ args: [address]
6351
+ }))
6352
+ });
6353
+ const acc = [];
6354
+ for (let idx = 0; idx < res.length; idx++) {
6355
+ const r2 = res[idx];
6356
+ const t = normalizedTokens[idx];
6357
+ if (r2.status === "success") {
6358
+ const raw = r2.result;
6359
+ if (raw > 0n) acc.push({ ...t, raw, formatted: (0, import_viem.formatUnits)(raw, t.decimals) });
6360
+ }
6361
+ }
6362
+ if (!cancelled) setRows(acc);
6363
+ } catch (e) {
6364
+ if (!cancelled) {
6365
+ const msg = e instanceof Error ? e.message : "Multicall failed";
6366
+ setError(baseClient ? msg : "Base client unavailable. Ensure Base (8453) is configured in Wagmi.");
6367
+ }
6368
+ } finally {
6369
+ if (!cancelled) setLoading(false);
6370
+ }
6371
+ }
6372
+ run();
6373
+ return () => {
6374
+ cancelled = true;
6375
+ };
6376
+ }, [address, baseClient, defaultClient]);
6377
+ return { isLoading, error: error ?? null, erc20Balances: rows };
6378
+ }
6379
+
6380
+ // src/hooks/useBaseNativeToken.ts
6381
+ var import_wagmi2 = require("wagmi");
6382
+ function useBaseNativeToken() {
6383
+ const { address } = (0, import_wagmi2.useAccount)();
6384
+ const { data, isLoading, error } = (0, import_wagmi2.useBalance)({
6385
+ address,
6386
+ chainId: 8453,
6387
+ // Base
6388
+ query: { enabled: !!address }
6389
+ });
6390
+ const nativeBalance = data ? { ...data, logoURI: "https://static.cdnlogo.com/logos/e/84/ethereum-eth_thumb.png" } : void 0;
6391
+ return {
6392
+ isLoadingNative: isLoading,
6393
+ nativeError: error?.message ?? null,
6394
+ nativeBalance
6395
+ };
6396
+ }
6397
+
6398
+ // src/modals/CryptoSelectModal.tsx
6399
+ var import_jsx_runtime24 = require("react/jsx-runtime");
6400
+ var CryptoSelectModal = import_nice_modal_react.default.create(() => {
6401
+ const modal = (0, import_nice_modal_react.useModal)();
6402
+ const { isLoading, error, erc20Balances } = useBaseERC20Token();
6403
+ const { isLoadingNative, nativeError, nativeBalance } = useBaseNativeToken();
6404
+ const { setSelectedPaymentMethod } = useSpreePaymentMethod();
6405
+ const [search, setSearch] = (0, import_react7.useState)("");
6406
+ const handleSelect = (coin) => {
6407
+ modal.remove();
6408
+ setSelectedPaymentMethod({ type: "CRYPTO" /* CRYPTO */, method: coin });
6409
+ };
6410
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Dialog2, { open: modal.visible, onOpenChange: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(DialogContent2, { showCloseButton: false, className: "gap-0 p-0", children: [
6411
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col gap-6 px-7 py-6", children: [
6412
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
6413
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { className: "rounded-md hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("path", { stroke: "#000", d: "m15 6.5-6 6 6 6" }) }) }),
6414
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DialogTitle2, { className: "text-primary text-2xl font-semibold", children: "Select a token" }),
6415
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { className: "rounded-md p-1 hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "17", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
6416
+ "path",
6417
+ {
6418
+ fill: "#000",
6419
+ d: "M12.6 3.9c.2.2.2.52 0 .71L8.7 8.5l3.9 3.89a.5.5 0 1 1-.71.7L8 9.22 4.11 13.1a.5.5 0 1 1-.7-.71L7.28 8.5 3.4 4.61a.5.5 0 1 1 .71-.7L8 7.78l3.89-3.89c.2-.2.51-.2.7 0Z"
6420
+ }
6421
+ ) }) })
6422
+ ] }),
6423
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Input, { onChange: (e) => setSearch(e.target.value), placeholder: "Search by token name", value: search })
6424
+ ] }),
6425
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Separator2, { className: "hidden md:block" }),
6426
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-col gap-4 px-7 py-6", children: [
6427
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h3", { className: "text-primary text-xl font-semibold", children: "Tokens with wallet balance" }),
6428
+ (error || nativeError) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-center text-sm text-red-500", children: "Something wrong" }),
6429
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
6430
+ isLoadingNative && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
6431
+ nativeBalance && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
6432
+ "button",
6433
+ {
6434
+ className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 hover:bg-gray-100",
6435
+ onClick: () => handleSelect(nativeBalance),
6436
+ children: [
6437
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center gap-2", children: [
6438
+ nativeBalance.logoURI && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
6439
+ "img",
6440
+ {
6441
+ className: "h-8 w-8 shrink-0",
6442
+ src: nativeBalance.logoURI,
6443
+ alt: `${nativeBalance.symbol} logo`
6444
+ }
6445
+ ),
6446
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
6447
+ ] }),
6448
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
6449
+ ]
6450
+ },
6451
+ nativeBalance.symbol
6452
+ ),
6453
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
6454
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
6455
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
6456
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
6457
+ ] }),
6458
+ erc20Balances.map((coin) => {
6459
+ const Icon2 = getSymbolLogo(coin.symbol);
6460
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
6461
+ "button",
6462
+ {
6463
+ className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 hover:bg-gray-100",
6464
+ onClick: () => handleSelect(coin),
6465
+ children: [
6466
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center gap-2", children: [
6467
+ Boolean(Icon2) && Icon2,
6468
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm font-medium", children: coin.symbol })
6469
+ ] }),
6470
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm font-medium", children: coin.formatted })
6471
+ ]
6472
+ },
6473
+ coin.symbol
6474
+ );
6475
+ })
6476
+ ] })
6477
+ ] })
6478
+ ] }) });
6479
+ });
6480
+ CryptoSelectModal.displayName = "CryptoSelectModal";
6481
+
6482
+ // src/components/Crypto/ConnectButton.tsx
6483
+ var import_rainbowkit = require("@rainbow-me/rainbowkit");
6484
+ var import_jsx_runtime25 = require("react/jsx-runtime");
6485
+ var ConnectButton = () => {
6486
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_rainbowkit.ConnectButton.Custom, { children: ({ mounted, chain, account, openAccountModal, openChainModal, openConnectModal }) => {
6487
+ if (!mounted) return null;
6488
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: (() => {
6489
+ if (!mounted || !account || !chain) {
6490
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6491
+ "button",
6492
+ {
6493
+ className: "h-[34px] rounded-md border-1 border-black px-3 text-sm font-medium",
6494
+ onClick: openConnectModal,
6495
+ children: "Connect a Wallet"
6496
+ }
6497
+ );
6498
+ }
6499
+ if (chain.unsupported) {
6500
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
6501
+ "button",
6502
+ {
6503
+ className: "h-[34px] rounded-md border-1 border-black px-3 text-sm font-medium text-red-500",
6504
+ onClick: openChainModal,
6505
+ children: "Wrong network"
6506
+ }
6507
+ );
6508
+ }
6509
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
6510
+ "button",
6511
+ {
6512
+ className: "flex h-[34px] items-center gap-2 rounded-md border-1 border-black px-1.5 text-sm font-medium",
6513
+ onClick: openAccountModal,
6514
+ children: [
6515
+ chain.hasIcon && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "h-6 w-6 overflow-hidden rounded-full", style: { background: chain.iconBackground }, children: chain.iconUrl && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("img", { alt: chain.name ?? "Chain icon", src: chain.iconUrl }) }),
6516
+ account.displayName
6517
+ ]
6518
+ }
6519
+ );
6520
+ })() });
6521
+ } });
6522
+ };
6523
+
6524
+ // src/components/Crypto/Logos.tsx
6525
+ var import_jsx_runtime26 = require("react/jsx-runtime");
6526
+ var Logos = () => {
6527
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex", children: [
6528
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "rounded-full border border-[#F5F7FA]", children: getSymbolLogo("MOCA") }),
6529
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "-ml-2.5 rounded-full border border-[#F5F7FA]", children: getSymbolLogo("USDC") }),
6530
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "-ml-2.5 rounded-full border border-[#F5F7FA]", children: getSymbolLogo("USDT") }),
6531
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "-ml-2.5 rounded-full border border-[#F5F7FA] bg-[#F5F7FA]", children: getSymbolLogo("WETH") })
6532
+ ] });
6533
+ };
6534
+
6535
+ // src/components/Crypto/Crypto.tsx
6536
+ var import_jsx_runtime27 = require("react/jsx-runtime");
6537
+ var SelectCoinButton = () => {
6538
+ const openModal = () => {
6539
+ import_nice_modal_react2.default.show(CryptoSelectModal);
6540
+ };
6541
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("button", { onClick: openModal, type: "button", className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
6542
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "bg-primary flex w-11 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white" }) }),
6543
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex w-full items-center justify-between px-3", children: [
6544
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "font-medium text-black/50", children: "Select a token" }) }),
6545
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { stroke: "#000", strokeLinecap: "round", d: "m6 12.43 4-4-4-4" }) })
6546
+ ] })
6547
+ ] });
6548
+ };
6549
+ var SelectedCoin = (props) => {
6550
+ const { coin, balance, logoURI } = props;
6551
+ const Icon2 = getSymbolLogo(coin);
6552
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
6553
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "bg-primary flex w-11 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "bg-primary h-2.5 w-2.5 rounded-full" }) }) }),
6554
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "border-primary flex w-full items-center justify-between rounded-r-md border-1 !border-l-0 px-3", children: [
6555
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-1", children: [
6556
+ Icon2,
6557
+ !Icon2 && logoURI && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { className: "mr-1 h-8 w-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
6558
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "font-semibold", children: coin }),
6559
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { d: "M6 12.4341L10 8.43408L6 4.43408", stroke: "black", strokeLinecap: "round" }) })
6560
+ ] }),
6561
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { className: "text-xs font-medium text-[#798B95]", children: [
6562
+ "Wallet balance ",
6563
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-black", children: balance })
6564
+ ] })
6565
+ ] })
6566
+ ] });
6567
+ };
6568
+ var Crypto = () => {
6569
+ const { address } = (0, import_wagmi3.useAccount)();
6570
+ const { selectedPaymentMethod } = useSpreePaymentMethod();
6571
+ const isWalletConnected = Boolean(address);
6572
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
6573
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [
6574
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h3", { className: "text-primary text-xl leading-[1.7] font-semibold", children: "Pay with Crypto" }),
6575
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ConnectButton, {})
6576
+ ] }),
6577
+ !isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Logos, {}),
6578
+ isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
6579
+ selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
6580
+ SelectedCoin,
6581
+ {
6582
+ coin: selectedPaymentMethod.method.symbol,
6583
+ balance: selectedPaymentMethod.method.formatted,
6584
+ logoURI: selectedPaymentMethod.method.logoURI
6585
+ }
6586
+ ),
6587
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SelectCoinButton, {})
6588
+ ] })
6589
+ ] });
6590
+ };
6591
+
6592
+ // src/components/Crypto/CryptoWrapper.tsx
6593
+ var import_jsx_runtime28 = require("react/jsx-runtime");
6594
+ var queryClient = new import_react_query.QueryClient();
6595
+ var config = (0, import_rainbowkit3.getDefaultConfig)({
6596
+ appName: "Spree Pay",
6597
+ projectId: "YOUR_PROJECT_ID",
6598
+ chains: [import_chains.base],
6599
+ ssr: true
6600
+ });
6601
+ var CryptoWrapper = () => {
6602
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_wagmi4.WagmiProvider, { config, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_rainbowkit2.RainbowKitProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_nice_modal_react3.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Crypto, {}) }) }) }) });
6603
+ };
6604
+
6605
+ // ../../node_modules/@radix-ui/react-switch/dist/index.mjs
6606
+ var React31 = __toESM(require("react"), 1);
6607
+
6608
+ // ../../node_modules/@radix-ui/react-switch/node_modules/@radix-ui/primitive/dist/index.mjs
6609
+ var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
6610
+ function composeEventHandlers2(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
6611
+ return function handleEvent(event) {
6612
+ originalEventHandler?.(event);
6613
+ if (checkForDefaultPrevented === false || !event.defaultPrevented) {
6614
+ return ourEventHandler?.(event);
6615
+ }
6616
+ };
6617
+ }
6618
+
6619
+ // ../../node_modules/@radix-ui/react-switch/dist/index.mjs
6620
+ var import_jsx_runtime29 = require("react/jsx-runtime");
6621
+ var SWITCH_NAME = "Switch";
6622
+ var [createSwitchContext, createSwitchScope] = createContextScope(SWITCH_NAME);
6623
+ var [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);
6624
+ var Switch = React31.forwardRef(
6625
+ (props, forwardedRef) => {
6626
+ const {
6627
+ __scopeSwitch,
6628
+ name,
6629
+ checked: checkedProp,
6630
+ defaultChecked,
6631
+ required,
6632
+ disabled,
6633
+ value = "on",
6634
+ onCheckedChange,
6635
+ form,
6636
+ ...switchProps
6637
+ } = props;
6638
+ const [button, setButton] = React31.useState(null);
6639
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));
6640
+ const hasConsumerStoppedPropagationRef = React31.useRef(false);
6641
+ const isFormControl = button ? form || !!button.closest("form") : true;
6642
+ const [checked, setChecked] = useControllableState({
6643
+ prop: checkedProp,
6644
+ defaultProp: defaultChecked ?? false,
6645
+ onChange: onCheckedChange,
6646
+ caller: SWITCH_NAME
6647
+ });
6648
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [
6649
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6650
+ Primitive.button,
6651
+ {
6652
+ type: "button",
6653
+ role: "switch",
6654
+ "aria-checked": checked,
6655
+ "aria-required": required,
6656
+ "data-state": getState3(checked),
6657
+ "data-disabled": disabled ? "" : void 0,
6658
+ disabled,
6659
+ value,
6660
+ ...switchProps,
6661
+ ref: composedRefs,
6662
+ onClick: composeEventHandlers2(props.onClick, (event) => {
6663
+ setChecked((prevChecked) => !prevChecked);
6664
+ if (isFormControl) {
6665
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
6666
+ if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
6667
+ }
6668
+ })
6669
+ }
6670
+ ),
6671
+ isFormControl && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6672
+ SwitchBubbleInput,
6673
+ {
6674
+ control: button,
6675
+ bubbles: !hasConsumerStoppedPropagationRef.current,
6676
+ name,
6677
+ value,
6678
+ checked,
6679
+ required,
6680
+ disabled,
6681
+ form,
6682
+ style: { transform: "translateX(-100%)" }
6683
+ }
6684
+ )
6685
+ ] });
6686
+ }
6687
+ );
6688
+ Switch.displayName = SWITCH_NAME;
6689
+ var THUMB_NAME = "SwitchThumb";
6690
+ var SwitchThumb = React31.forwardRef(
6691
+ (props, forwardedRef) => {
6692
+ const { __scopeSwitch, ...thumbProps } = props;
6693
+ const context = useSwitchContext(THUMB_NAME, __scopeSwitch);
6694
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6695
+ Primitive.span,
6696
+ {
6697
+ "data-state": getState3(context.checked),
6698
+ "data-disabled": context.disabled ? "" : void 0,
6699
+ ...thumbProps,
6700
+ ref: forwardedRef
6701
+ }
6702
+ );
6703
+ }
6704
+ );
6705
+ SwitchThumb.displayName = THUMB_NAME;
6706
+ var BUBBLE_INPUT_NAME2 = "SwitchBubbleInput";
6707
+ var SwitchBubbleInput = React31.forwardRef(
6708
+ ({
6709
+ __scopeSwitch,
6710
+ control,
6711
+ checked,
6712
+ bubbles = true,
6713
+ ...props
6714
+ }, forwardedRef) => {
6715
+ const ref = React31.useRef(null);
6716
+ const composedRefs = useComposedRefs(ref, forwardedRef);
6717
+ const prevChecked = usePrevious(checked);
6718
+ const controlSize = useSize(control);
6719
+ React31.useEffect(() => {
6720
+ const input = ref.current;
6721
+ if (!input) return;
6722
+ const inputProto = window.HTMLInputElement.prototype;
6723
+ const descriptor = Object.getOwnPropertyDescriptor(
6724
+ inputProto,
6725
+ "checked"
6726
+ );
6727
+ const setChecked = descriptor.set;
6728
+ if (prevChecked !== checked && setChecked) {
6729
+ const event = new Event("click", { bubbles });
6730
+ setChecked.call(input, checked);
6731
+ input.dispatchEvent(event);
6732
+ }
6733
+ }, [prevChecked, checked, bubbles]);
6734
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6735
+ "input",
6736
+ {
6737
+ type: "checkbox",
6738
+ "aria-hidden": true,
6739
+ defaultChecked: checked,
6740
+ ...props,
6741
+ tabIndex: -1,
6742
+ ref: composedRefs,
6743
+ style: {
6744
+ ...props.style,
6745
+ ...controlSize,
6746
+ position: "absolute",
6747
+ pointerEvents: "none",
6748
+ opacity: 0,
6749
+ margin: 0
6750
+ }
6751
+ }
6752
+ );
6753
+ }
6754
+ );
6755
+ SwitchBubbleInput.displayName = BUBBLE_INPUT_NAME2;
6756
+ function getState3(checked) {
6757
+ return checked ? "checked" : "unchecked";
6758
+ }
6759
+ var Root4 = Switch;
6760
+ var Thumb = SwitchThumb;
6761
+
6762
+ // ../ui/src/components/switch.tsx
6763
+ var import_jsx_runtime30 = require("react/jsx-runtime");
6764
+ function Switch2({ className, ...props }) {
6765
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6766
+ Root4,
6767
+ {
6768
+ "data-slot": "switch",
6769
+ className: cn(
6770
+ "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
6771
+ className
6772
+ ),
6773
+ ...props,
6774
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
6775
+ Thumb,
6776
+ {
6777
+ "data-slot": "switch-thumb",
6778
+ className: cn(
6779
+ "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
6780
+ )
6781
+ }
6782
+ )
6783
+ }
6784
+ );
6785
+ }
6786
+
6787
+ // src/components/PointsSwitch.tsx
6788
+ var import_jsx_runtime31 = require("react/jsx-runtime");
6789
+ var PointsSwitch = () => {
6790
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-3", children: [
6791
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Switch2, { disabled: true, id: "points" }),
6792
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Label2, { className: "items-baseline text-xl font-semibold text-black", htmlFor: "points", children: [
6793
+ "Use Points ",
6794
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "text-xs font-medium", children: "Optional" })
6795
+ ] })
6796
+ ] });
6797
+ };
6798
+
6799
+ // src/components/TabButtons.tsx
6800
+ var import_jsx_runtime32 = require("react/jsx-runtime");
6801
+ var TabButton = ({ isActive, children, onClick }) => {
6802
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6803
+ "button",
6804
+ {
6805
+ onClick,
6806
+ className: cn(
6807
+ "flex w-[132px] flex-col items-baseline rounded-sm border-1 border-black px-2.5 py-1.5 text-sm text-black",
6808
+ { "opacity-50": !isActive },
6809
+ { "bg-primary/7 border-primary text-primary": isActive }
6810
+ ),
6811
+ children
6812
+ }
6813
+ );
6814
+ };
6815
+ var TabButtons = (props) => {
6816
+ const { value, onChange } = props;
6817
+ const handleChange = (type) => () => {
6818
+ if (value !== type) {
6819
+ onChange({ type, method: null });
6820
+ }
6821
+ };
6822
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex gap-2", children: [
6823
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(TabButton, { onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */), isActive: value === "CREDIT_CARD" /* CREDIT_CARD */, children: [
6824
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6825
+ "path",
6826
+ {
6827
+ fill: "currentColor",
6828
+ d: "M22 6v12c0 .55-.2 1.02-.59 1.41-.39.4-.86.59-1.41.59H4c-.55 0-1.02-.2-1.41-.59-.4-.39-.59-.86-.59-1.41V6c0-.55.2-1.02.59-1.41C2.98 4.19 3.45 4 4 4h16c.55 0 1.02.2 1.41.59.4.39.59.86.59 1.41ZM4 8h16V6H4v2Zm0 4v6h16v-6H4Z"
6829
+ }
6830
+ ) }),
6831
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-sm font-medium", children: "Card" })
6832
+ ] }),
6833
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(TabButton, { onClick: handleChange("CRYPTO" /* CRYPTO */), isActive: value === "CRYPTO" /* CRYPTO */, children: [
6834
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { className: "my-1", xmlns: "http://www.w3.org/2000/svg", width: "30", height: "16", fill: "none", children: [
6835
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6836
+ "path",
6837
+ {
6838
+ fill: "currentColor",
6839
+ d: "M14.5 0C19.2 0 23 3.58 23 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.11.09 3.7 0 6.5-2.8 6.5-6s-2.8-6-6.5-6c-.38 0-.75.03-1.11.09A8 8 0 0 0 11.15.65 8.93 8.93 0 0 1 14.5 0Z"
6840
+ }
6841
+ ),
6842
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
6843
+ "path",
6844
+ {
6845
+ fill: "currentColor",
6846
+ d: "M21.15 0c4.7 0 8.5 3.58 8.5 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.1.09 3.71 0 6.5-2.8 6.5-6s-2.79-6-6.5-6c-.37 0-.74.03-1.1.09A8 8 0 0 0 17.8.65 8.93 8.93 0 0 1 21.15 0Z"
6847
+ }
6848
+ ),
6849
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "2" })
6850
+ ] }),
6851
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-sm font-medium", children: "Crypto" })
6852
+ ] })
6853
+ ] });
6854
+ };
6855
+
6856
+ // src/components/Tabs.tsx
6857
+ var import_jsx_runtime33 = require("react/jsx-runtime");
6858
+ var Tabs = () => {
6859
+ const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
6860
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "mb-4 rounded-2xl border border-black/25 bg-white", children: [
6861
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex w-full flex-col gap-4 border-b-1 border-black/7 px-7 py-6", children: [
6862
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
6863
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
6864
+ ] }),
6865
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "border-b-1 border-black/7 px-7 py-6", children: [
6866
+ selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CreditCard, {}),
6867
+ selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CryptoWrapper, {})
6868
+ ] }),
6869
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "px-7 py-6", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(PointsSwitch, {}) })
6870
+ ] });
6871
+ };
6872
+
6873
+ // src/fetcher/client.ts
6874
+ var cfg = { baseUrl: void 0, accessToken: void 0, tenantId: void 0 };
6875
+ var buildUrl = (key) => {
6876
+ if (!cfg.baseUrl) throw new Error("Missing SLAPI baseUrl. Call registerApi(...) first.");
6877
+ if (typeof key === "string") return cfg.baseUrl + key;
6878
+ const { url, params = {} } = key;
6879
+ const usp = new URLSearchParams();
6880
+ Object.entries(params).forEach(([k, v]) => {
6881
+ if (v === void 0 || v === null) return;
6882
+ usp.append(k, String(v));
6883
+ });
6884
+ const qs = usp.toString();
6885
+ return cfg.baseUrl + url + (qs ? `?${qs}` : "");
6886
+ };
6887
+ var request = async (method, url, body) => {
6888
+ const headers = {
6889
+ Accept: "application/json"
6890
+ };
6891
+ if (!cfg.accessToken) throw new Error("Missing SLAPI accessToken. Call registerApi(...) first.");
6892
+ if (!cfg.tenantId) throw new Error("Missing SLAPI tenantId. Call registerApi(...) first.");
6893
+ headers.Authorization = `Bearer ${cfg.accessToken}`;
6894
+ headers["X-Tenant-ID"] = cfg.tenantId;
6895
+ let payload;
6896
+ if (method !== "GET" && method !== "DELETE" && body !== void 0) {
6897
+ if (typeof FormData !== "undefined" && body instanceof FormData) {
6898
+ payload = body;
6899
+ } else if (body instanceof Blob) {
6900
+ payload = body;
6901
+ } else {
6902
+ headers["Content-Type"] = "application/json";
6903
+ payload = JSON.stringify(body);
6904
+ }
6905
+ }
6906
+ const res = await fetch(url, {
6907
+ method,
6908
+ headers,
6909
+ body: payload,
6910
+ cache: "no-store"
6911
+ });
6912
+ if (!res.ok) {
6913
+ const text = await res.text().catch(() => "");
6914
+ throw new Error(text || `Request failed: ${res.status}`);
6915
+ }
6916
+ const contentType = res.headers.get("content-type") || "";
6917
+ if (!contentType.includes("application/json")) {
6918
+ return await res.text();
6919
+ }
6920
+ return await res.json();
6921
+ };
6922
+ var slapiApi = {
6923
+ get: async () => {
6924
+ throw new Error("slapiApi is not configured. Call registerApi(...) first.");
6925
+ },
6926
+ post: async () => {
6927
+ throw new Error("slapiApi is not configured. Call registerApi(...) first.");
6928
+ },
6929
+ put: async () => {
6930
+ throw new Error("slapiApi is not configured. Call registerApi(...) first.");
6931
+ },
6932
+ patch: async () => {
6933
+ throw new Error("slapiApi is not configured. Call registerApi(...) first.");
6934
+ },
6935
+ delete: async () => {
6936
+ throw new Error("slapiApi is not configured. Call registerApi(...) first.");
6937
+ }
6938
+ };
6939
+ var registerApi = (config2) => {
6940
+ cfg.baseUrl = config2.baseUrl;
6941
+ cfg.accessToken = config2.accessToken;
6942
+ cfg.tenantId = config2.tenantId;
6943
+ slapiApi = {
6944
+ get: async (key) => {
6945
+ const url = buildUrl(key);
6946
+ return request("GET", url);
6947
+ },
6948
+ post: async (key, body) => {
6949
+ const url = buildUrl(key);
6950
+ return request("POST", url, body);
6951
+ },
6952
+ put: async (key, body) => {
6953
+ const url = buildUrl(key);
6954
+ return request("PUT", url, body);
6955
+ },
6956
+ patch: async (key, body) => {
4503
6957
  const url = buildUrl(key);
4504
6958
  return request("PATCH", url, body);
4505
6959
  },
@@ -4590,12 +7044,12 @@ var cardPayment = async ({ card, hash }) => {
4590
7044
  };
4591
7045
 
4592
7046
  // src/SpreePayContent.tsx
4593
- var import_jsx_runtime17 = require("react/jsx-runtime");
7047
+ var import_jsx_runtime34 = require("react/jsx-runtime");
4594
7048
  var SpreePayContent = (props) => {
4595
7049
  const { className, amount, onProcess } = props;
4596
7050
  const { selectedPaymentMethod } = useSpreePaymentMethod();
4597
7051
  const { register } = useSpreePayRegister();
4598
- const handlePay = (0, import_react6.useCallback)(
7052
+ const handlePay = (0, import_react8.useCallback)(
4599
7053
  (data) => {
4600
7054
  if (selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && selectedPaymentMethod.method) {
4601
7055
  return cardPayment({ card: selectedPaymentMethod.method, hash: data.hash });
@@ -4604,18 +7058,18 @@ var SpreePayContent = (props) => {
4604
7058
  },
4605
7059
  [selectedPaymentMethod]
4606
7060
  );
4607
- (0, import_react6.useEffect)(() => {
7061
+ (0, import_react8.useEffect)(() => {
4608
7062
  register(handlePay);
4609
7063
  }, [register, handlePay]);
4610
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: cn("sl-spreepay", className), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "w-full max-w-[540px]", children: [
4611
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Tabs, {}),
4612
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CheckoutButton, { onCheckout: onProcess, amount }),
4613
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SpreeLegal, {})
7064
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: cn("sl-spreepay", className), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "w-full", children: [
7065
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Tabs, {}),
7066
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CheckoutButton, { onCheckout: onProcess, amount }),
7067
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(SpreeLegal, {})
4614
7068
  ] }) });
4615
7069
  };
4616
7070
 
4617
7071
  // src/SpreePay.tsx
4618
- var import_jsx_runtime18 = require("react/jsx-runtime");
7072
+ var import_jsx_runtime35 = require("react/jsx-runtime");
4619
7073
  var envConfig = {
4620
7074
  dev: { slapiUrl: "https://slapi.dev.superlogic.com", tenantId: "bookit" },
4621
7075
  stg: { slapiUrl: "https://slapi.dev.superlogic.com", tenantId: "bookit" },
@@ -4623,7 +7077,7 @@ var envConfig = {
4623
7077
  };
4624
7078
  var SpreePay = (props) => {
4625
7079
  const { env } = useSpreePayEnv();
4626
- const slapiFetcher = (0, import_react7.useMemo)(
7080
+ const slapiFetcher = (0, import_react9.useMemo)(
4627
7081
  () => registerApi({
4628
7082
  accessToken: env.accessToken,
4629
7083
  baseUrl: envConfig[env.environment].slapiUrl,
@@ -4631,7 +7085,7 @@ var SpreePay = (props) => {
4631
7085
  }),
4632
7086
  [env]
4633
7087
  );
4634
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
7088
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4635
7089
  import_swr3.SWRConfig,
4636
7090
  {
4637
7091
  value: {
@@ -4640,7 +7094,7 @@ var SpreePay = (props) => {
4640
7094
  revalidateIfStale: false,
4641
7095
  revalidateOnReconnect: false
4642
7096
  },
4643
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SpreePayContent, { ...props })
7097
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SpreePayContent, { ...props })
4644
7098
  }
4645
7099
  );
4646
7100
  };
@@ -4657,6 +7111,7 @@ lucide-react/dist/esm/defaultAttributes.js:
4657
7111
  lucide-react/dist/esm/Icon.js:
4658
7112
  lucide-react/dist/esm/createLucideIcon.js:
4659
7113
  lucide-react/dist/esm/icons/check.js:
7114
+ lucide-react/dist/esm/icons/x.js:
4660
7115
  lucide-react/dist/esm/lucide-react.js:
4661
7116
  (**
4662
7117
  * @license lucide-react v0.525.0 - ISC