@betterstore/react 0.6.8 → 0.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3328,7 +3328,8 @@ const CheckoutEmbed$2 = {
3328
3328
  },
3329
3329
  shipment: {
3330
3330
  title: "Zásilka č."
3331
- }
3331
+ },
3332
+ errorNoShippingRates: "Dopravu se nepodařilo načíst. Zkuste stránku obnovit. Pokud problém přetrvává, kontaktujte prodejce."
3332
3333
  }
3333
3334
  };
3334
3335
  const Errors$1 = {
@@ -3389,6 +3390,7 @@ const CheckoutEmbed$1 = {
3389
3390
  },
3390
3391
  loading: "Loading...",
3391
3392
  Shipping: {
3393
+ errorNoShippingRates: "Failed to load shipping rates. Try to refresh the page. Contact the seller if the problem persists.",
3392
3394
  title: "Shipping",
3393
3395
  change: "Change",
3394
3396
  address: "Address:",
@@ -3454,6 +3456,13 @@ const createI18nInstance = (locale) => __awaiter(void 0, void 0, void 0, functio
3454
3456
  return instance;
3455
3457
  });
3456
3458
 
3459
+ /**
3460
+ * Create a bound version of a function with a specified `this` context
3461
+ *
3462
+ * @param {Function} fn - The function to bind
3463
+ * @param {*} thisArg - The value to be passed as the `this` parameter
3464
+ * @returns {Function} A new function that will call the original function with the specified `this` context
3465
+ */
3457
3466
  function bind(fn, thisArg) {
3458
3467
  return function wrap() {
3459
3468
  return fn.apply(thisArg, arguments);
@@ -4706,7 +4715,7 @@ class InterceptorManager {
4706
4715
  *
4707
4716
  * @param {Number} id The ID that was returned by `use`
4708
4717
  *
4709
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
4718
+ * @returns {void}
4710
4719
  */
4711
4720
  eject(id) {
4712
4721
  if (this.handlers[id]) {
@@ -5666,27 +5675,38 @@ var cookies = platform$1.hasStandardBrowserEnv ?
5666
5675
 
5667
5676
  // Standard browser envs support document.cookie
5668
5677
  {
5669
- write(name, value, expires, path, domain, secure) {
5670
- const cookie = [name + '=' + encodeURIComponent(value)];
5671
-
5672
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
5673
-
5674
- utils$1.isString(path) && cookie.push('path=' + path);
5678
+ write(name, value, expires, path, domain, secure, sameSite) {
5679
+ if (typeof document === 'undefined') return;
5675
5680
 
5676
- utils$1.isString(domain) && cookie.push('domain=' + domain);
5681
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
5677
5682
 
5678
- secure === true && cookie.push('secure');
5683
+ if (utils$1.isNumber(expires)) {
5684
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
5685
+ }
5686
+ if (utils$1.isString(path)) {
5687
+ cookie.push(`path=${path}`);
5688
+ }
5689
+ if (utils$1.isString(domain)) {
5690
+ cookie.push(`domain=${domain}`);
5691
+ }
5692
+ if (secure === true) {
5693
+ cookie.push('secure');
5694
+ }
5695
+ if (utils$1.isString(sameSite)) {
5696
+ cookie.push(`SameSite=${sameSite}`);
5697
+ }
5679
5698
 
5680
5699
  document.cookie = cookie.join('; ');
5681
5700
  },
5682
5701
 
5683
5702
  read(name) {
5684
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
5685
- return (match ? decodeURIComponent(match[3]) : null);
5703
+ if (typeof document === 'undefined') return null;
5704
+ const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
5705
+ return match ? decodeURIComponent(match[1]) : null;
5686
5706
  },
5687
5707
 
5688
5708
  remove(name) {
5689
- this.write(name, '', Date.now() - 86400000);
5709
+ this.write(name, '', Date.now() - 86400000, '/');
5690
5710
  }
5691
5711
  }
5692
5712
 
@@ -5775,11 +5795,11 @@ function mergeConfig$1(config1, config2) {
5775
5795
  }
5776
5796
 
5777
5797
  // eslint-disable-next-line consistent-return
5778
- function mergeDeepProperties(a, b, prop , caseless) {
5798
+ function mergeDeepProperties(a, b, prop, caseless) {
5779
5799
  if (!utils$1.isUndefined(b)) {
5780
- return getMergedValue(a, b, prop , caseless);
5800
+ return getMergedValue(a, b, prop, caseless);
5781
5801
  } else if (!utils$1.isUndefined(a)) {
5782
- return getMergedValue(undefined, a, prop , caseless);
5802
+ return getMergedValue(undefined, a, prop, caseless);
5783
5803
  }
5784
5804
  }
5785
5805
 
@@ -5837,7 +5857,7 @@ function mergeConfig$1(config1, config2) {
5837
5857
  socketPath: defaultToConfig2,
5838
5858
  responseEncoding: defaultToConfig2,
5839
5859
  validateStatus: mergeDirectKeys,
5840
- headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
5860
+ headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
5841
5861
  };
5842
5862
 
5843
5863
  utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
@@ -6475,7 +6495,7 @@ const factory = (env) => {
6475
6495
  const seedCache = new Map();
6476
6496
 
6477
6497
  const getFetch = (config) => {
6478
- let env = config ? config.env : {};
6498
+ let env = (config && config.env) || {};
6479
6499
  const {fetch, Request, Response} = env;
6480
6500
  const seeds = [
6481
6501
  Request, Response, fetch
@@ -6498,6 +6518,15 @@ const getFetch = (config) => {
6498
6518
 
6499
6519
  getFetch();
6500
6520
 
6521
+ /**
6522
+ * Known adapters mapping.
6523
+ * Provides environment-specific adapters for Axios:
6524
+ * - `http` for Node.js
6525
+ * - `xhr` for browsers
6526
+ * - `fetch` for fetch API-based requests
6527
+ *
6528
+ * @type {Object<string, Function|Object>}
6529
+ */
6501
6530
  const knownAdapters = {
6502
6531
  http: httpAdapter,
6503
6532
  xhr: xhrAdapter,
@@ -6506,71 +6535,107 @@ const knownAdapters = {
6506
6535
  }
6507
6536
  };
6508
6537
 
6538
+ // Assign adapter names for easier debugging and identification
6509
6539
  utils$1.forEach(knownAdapters, (fn, value) => {
6510
6540
  if (fn) {
6511
6541
  try {
6512
- Object.defineProperty(fn, 'name', {value});
6542
+ Object.defineProperty(fn, 'name', { value });
6513
6543
  } catch (e) {
6514
6544
  // eslint-disable-next-line no-empty
6515
6545
  }
6516
- Object.defineProperty(fn, 'adapterName', {value});
6546
+ Object.defineProperty(fn, 'adapterName', { value });
6517
6547
  }
6518
6548
  });
6519
6549
 
6550
+ /**
6551
+ * Render a rejection reason string for unknown or unsupported adapters
6552
+ *
6553
+ * @param {string} reason
6554
+ * @returns {string}
6555
+ */
6520
6556
  const renderReason = (reason) => `- ${reason}`;
6521
6557
 
6558
+ /**
6559
+ * Check if the adapter is resolved (function, null, or false)
6560
+ *
6561
+ * @param {Function|null|false} adapter
6562
+ * @returns {boolean}
6563
+ */
6522
6564
  const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
6523
6565
 
6524
- var adapters = {
6525
- getAdapter: (adapters, config) => {
6526
- adapters = utils$1.isArray(adapters) ? adapters : [adapters];
6566
+ /**
6567
+ * Get the first suitable adapter from the provided list.
6568
+ * Tries each adapter in order until a supported one is found.
6569
+ * Throws an AxiosError if no adapter is suitable.
6570
+ *
6571
+ * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
6572
+ * @param {Object} config - Axios request configuration
6573
+ * @throws {AxiosError} If no suitable adapter is available
6574
+ * @returns {Function} The resolved adapter function
6575
+ */
6576
+ function getAdapter$1(adapters, config) {
6577
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
6527
6578
 
6528
- const {length} = adapters;
6529
- let nameOrAdapter;
6530
- let adapter;
6579
+ const { length } = adapters;
6580
+ let nameOrAdapter;
6581
+ let adapter;
6531
6582
 
6532
- const rejectedReasons = {};
6583
+ const rejectedReasons = {};
6533
6584
 
6534
- for (let i = 0; i < length; i++) {
6535
- nameOrAdapter = adapters[i];
6536
- let id;
6585
+ for (let i = 0; i < length; i++) {
6586
+ nameOrAdapter = adapters[i];
6587
+ let id;
6537
6588
 
6538
- adapter = nameOrAdapter;
6589
+ adapter = nameOrAdapter;
6539
6590
 
6540
- if (!isResolvedHandle(nameOrAdapter)) {
6541
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
6591
+ if (!isResolvedHandle(nameOrAdapter)) {
6592
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
6542
6593
 
6543
- if (adapter === undefined) {
6544
- throw new AxiosError$1(`Unknown adapter '${id}'`);
6545
- }
6546
- }
6547
-
6548
- if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
6549
- break;
6594
+ if (adapter === undefined) {
6595
+ throw new AxiosError$1(`Unknown adapter '${id}'`);
6550
6596
  }
6597
+ }
6551
6598
 
6552
- rejectedReasons[id || '#' + i] = adapter;
6599
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
6600
+ break;
6553
6601
  }
6554
6602
 
6555
- if (!adapter) {
6603
+ rejectedReasons[id || '#' + i] = adapter;
6604
+ }
6556
6605
 
6557
- const reasons = Object.entries(rejectedReasons)
6558
- .map(([id, state]) => `adapter ${id} ` +
6559
- (state === false ? 'is not supported by the environment' : 'is not available in the build')
6560
- );
6606
+ if (!adapter) {
6607
+ const reasons = Object.entries(rejectedReasons)
6608
+ .map(([id, state]) => `adapter ${id} ` +
6609
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
6610
+ );
6561
6611
 
6562
- let s = length ?
6563
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
6564
- 'as no adapter specified';
6612
+ let s = length ?
6613
+ (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
6614
+ 'as no adapter specified';
6565
6615
 
6566
- throw new AxiosError$1(
6567
- `There is no suitable adapter to dispatch the request ` + s,
6568
- 'ERR_NOT_SUPPORT'
6569
- );
6570
- }
6616
+ throw new AxiosError$1(
6617
+ `There is no suitable adapter to dispatch the request ` + s,
6618
+ 'ERR_NOT_SUPPORT'
6619
+ );
6620
+ }
6571
6621
 
6572
- return adapter;
6573
- },
6622
+ return adapter;
6623
+ }
6624
+
6625
+ /**
6626
+ * Exports Axios adapters and utility to resolve an adapter
6627
+ */
6628
+ var adapters = {
6629
+ /**
6630
+ * Resolve an adapter from a list of adapter names or functions.
6631
+ * @type {Function}
6632
+ */
6633
+ getAdapter: getAdapter$1,
6634
+
6635
+ /**
6636
+ * Exposes all known adapters
6637
+ * @type {Object<string, Function|Object>}
6638
+ */
6574
6639
  adapters: knownAdapters
6575
6640
  };
6576
6641
 
@@ -6647,7 +6712,7 @@ function dispatchRequest(config) {
6647
6712
  });
6648
6713
  }
6649
6714
 
6650
- const VERSION$1 = "1.12.2";
6715
+ const VERSION$1 = "1.13.2";
6651
6716
 
6652
6717
  const validators$1 = {};
6653
6718
 
@@ -7202,6 +7267,12 @@ const HttpStatusCode$1 = {
7202
7267
  LoopDetected: 508,
7203
7268
  NotExtended: 510,
7204
7269
  NetworkAuthenticationRequired: 511,
7270
+ WebServerIsDown: 521,
7271
+ ConnectionTimedOut: 522,
7272
+ OriginIsUnreachable: 523,
7273
+ TimeoutOccurred: 524,
7274
+ SslHandshakeFailed: 525,
7275
+ InvalidSslCertificate: 526,
7205
7276
  };
7206
7277
 
7207
7278
  Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
@@ -12222,7 +12293,7 @@ var createApiClient = (apiKey, proxy) => {
12222
12293
  apiError.code = "REQUEST_SETUP_ERROR";
12223
12294
  apiError.details = error;
12224
12295
  }
12225
- console.error(apiError);
12296
+ console.error("API ERROR: ", apiError);
12226
12297
  if (apiError.code === "REQUEST_SETUP_ERROR" || apiError.code === "SERVICE_UNAVAILABLE") {
12227
12298
  throw apiError;
12228
12299
  }
@@ -12287,7 +12358,7 @@ var Client = class {
12287
12358
  async removeDiscount(clientSecret, checkoutId, discountId) {
12288
12359
  const apiClient = createApiClient(clientSecret, this.proxy);
12289
12360
  const data = await apiClient.delete(
12290
- `/checkout/${checkoutId}/discounts/${discountId}`
12361
+ `/checkout/${checkoutId}/discounts/remove/${discountId}`
12291
12362
  );
12292
12363
  if ("isError" in data && data.isError || !data || !("id" in data)) {
12293
12364
  throw new Error("Failed to remove discount code");
@@ -12316,7 +12387,9 @@ var Client = class {
12316
12387
  const data = await apiClient.get(
12317
12388
  `/checkout/${checkoutId}/shipping/rates`
12318
12389
  );
12319
- if ("isError" in data && data.isError || !data || !("rates" in data)) {
12390
+ console.log("SHIPPING RATES DATA: ", data);
12391
+ if ("isError" in data && data.isError || !data) {
12392
+ console.error("Failed to get shipping rates: ", data);
12320
12393
  return {};
12321
12394
  }
12322
12395
  return data;
@@ -12326,7 +12399,7 @@ var Client = class {
12326
12399
  */
12327
12400
  async generateCheckoutPaymentSecret(clientSecret, checkoutId) {
12328
12401
  const apiClient = createApiClient(clientSecret, this.proxy);
12329
- const data = await apiClient.post(`/checkout/payment/${checkoutId}`);
12402
+ const data = await apiClient.post(`/checkout/${checkoutId}/payment`);
12330
12403
  if ("isError" in data && data.isError || !data || !("paymentSecret" in data)) {
12331
12404
  throw new Error("Failed to generate payment secret");
12332
12405
  }
@@ -13568,14 +13641,14 @@ const customerSchema = objectType({
13568
13641
  lastName: stringType().min(1, "required_error"),
13569
13642
  address: objectType({
13570
13643
  line1: stringType().min(1, "required_error"),
13571
- line2: stringType().nullable(),
13644
+ line2: stringType().nullable().optional(),
13572
13645
  city: stringType().min(1, "required_error"),
13573
- province: stringType().nullable(),
13574
- provinceCode: stringType().nullable(),
13646
+ province: stringType().nullable().optional(),
13647
+ provinceCode: stringType().nullable().optional(),
13575
13648
  zipCode: stringType().min(5, "invalid_zipCode"),
13576
13649
  country: stringType().min(1, "required_error"),
13577
13650
  countryCode: stringType().min(1, "required_error"),
13578
- company: stringType().nullable(),
13651
+ company: stringType().nullable().optional(),
13579
13652
  }),
13580
13653
  phone: stringType().regex(phoneRegex, "invalid_phone"),
13581
13654
  isEmailSubscribed: booleanType().optional(),
@@ -13652,13 +13725,24 @@ function useComposedRefs(...refs) {
13652
13725
  }
13653
13726
 
13654
13727
  // src/slot.tsx
13728
+ var REACT_LAZY_TYPE = Symbol.for("react.lazy");
13729
+ var use = React[" use ".trim().toString()];
13730
+ function isPromiseLike(value) {
13731
+ return typeof value === "object" && value !== null && "then" in value;
13732
+ }
13733
+ function isLazyComponent(element) {
13734
+ return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
13735
+ }
13655
13736
  // @__NO_SIDE_EFFECTS__
13656
- function createSlot(ownerName) {
13657
- const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
13737
+ function createSlot$1(ownerName) {
13738
+ const SlotClone = /* @__PURE__ */ createSlotClone$1(ownerName);
13658
13739
  const Slot2 = React.forwardRef((props, forwardedRef) => {
13659
- const { children, ...slotProps } = props;
13740
+ let { children, ...slotProps } = props;
13741
+ if (isLazyComponent(children) && typeof use === "function") {
13742
+ children = use(children._payload);
13743
+ }
13660
13744
  const childrenArray = React.Children.toArray(children);
13661
- const slottable = childrenArray.find(isSlottable);
13745
+ const slottable = childrenArray.find(isSlottable$1);
13662
13746
  if (slottable) {
13663
13747
  const newElement = slottable.props.children;
13664
13748
  const newChildren = childrenArray.map((child) => {
@@ -13676,14 +13760,17 @@ function createSlot(ownerName) {
13676
13760
  Slot2.displayName = `${ownerName}.Slot`;
13677
13761
  return Slot2;
13678
13762
  }
13679
- var Slot$2 = /* @__PURE__ */ createSlot("Slot");
13763
+ var Slot$2 = /* @__PURE__ */ createSlot$1("Slot");
13680
13764
  // @__NO_SIDE_EFFECTS__
13681
- function createSlotClone(ownerName) {
13765
+ function createSlotClone$1(ownerName) {
13682
13766
  const SlotClone = React.forwardRef((props, forwardedRef) => {
13683
- const { children, ...slotProps } = props;
13767
+ let { children, ...slotProps } = props;
13768
+ if (isLazyComponent(children) && typeof use === "function") {
13769
+ children = use(children._payload);
13770
+ }
13684
13771
  if (React.isValidElement(children)) {
13685
- const childrenRef = getElementRef$1(children);
13686
- const props2 = mergeProps(slotProps, children.props);
13772
+ const childrenRef = getElementRef$2(children);
13773
+ const props2 = mergeProps$1(slotProps, children.props);
13687
13774
  if (children.type !== React.Fragment) {
13688
13775
  props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
13689
13776
  }
@@ -13694,11 +13781,11 @@ function createSlotClone(ownerName) {
13694
13781
  SlotClone.displayName = `${ownerName}.SlotClone`;
13695
13782
  return SlotClone;
13696
13783
  }
13697
- var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
13698
- function isSlottable(child) {
13699
- return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
13784
+ var SLOTTABLE_IDENTIFIER$1 = Symbol("radix.slottable");
13785
+ function isSlottable$1(child) {
13786
+ return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$1;
13700
13787
  }
13701
- function mergeProps(slotProps, childProps) {
13788
+ function mergeProps$1(slotProps, childProps) {
13702
13789
  const overrideProps = { ...childProps };
13703
13790
  for (const propName in childProps) {
13704
13791
  const slotPropValue = slotProps[propName];
@@ -13722,7 +13809,7 @@ function mergeProps(slotProps, childProps) {
13722
13809
  }
13723
13810
  return { ...slotProps, ...overrideProps };
13724
13811
  }
13725
- function getElementRef$1(element) {
13812
+ function getElementRef$2(element) {
13726
13813
  let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
13727
13814
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
13728
13815
  if (mayWarn) {
@@ -13897,7 +13984,7 @@ HookFormContext.displayName = 'HookFormContext';
13897
13984
  */
13898
13985
  const useFormContext = () => React__default.useContext(HookFormContext);
13899
13986
  /**
13900
- * A provider component that propagates the `useForm` methods to all children components via [React Context](https://reactjs.org/docs/context.html) API. To be used with {@link useFormContext}.
13987
+ * A provider component that propagates the `useForm` methods to all children components via [React Context](https://react.dev/reference/react/useContext) API. To be used with {@link useFormContext}.
13901
13988
  *
13902
13989
  * @remarks
13903
13990
  * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
@@ -14033,7 +14120,7 @@ var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
14033
14120
 
14034
14121
  function deepEqual$1(object1, object2, _internal_visited = new WeakSet()) {
14035
14122
  if (isPrimitive(object1) || isPrimitive(object2)) {
14036
- return object1 === object2;
14123
+ return Object.is(object1, object2);
14037
14124
  }
14038
14125
  if (isDateObject(object1) && isDateObject(object2)) {
14039
14126
  return object1.getTime() === object2.getTime();
@@ -14059,7 +14146,7 @@ function deepEqual$1(object1, object2, _internal_visited = new WeakSet()) {
14059
14146
  (isObject(val1) && isObject(val2)) ||
14060
14147
  (Array.isArray(val1) && Array.isArray(val2))
14061
14148
  ? !deepEqual$1(val1, val2, _internal_visited)
14062
- : val1 !== val2) {
14149
+ : !Object.is(val1, val2)) {
14063
14150
  return false;
14064
14151
  }
14065
14152
  }
@@ -14089,33 +14176,68 @@ function useWatch(props) {
14089
14176
  const _defaultValue = React__default.useRef(defaultValue);
14090
14177
  const _compute = React__default.useRef(compute);
14091
14178
  const _computeFormValues = React__default.useRef(undefined);
14179
+ const _prevControl = React__default.useRef(control);
14180
+ const _prevName = React__default.useRef(name);
14092
14181
  _compute.current = compute;
14093
- const defaultValueMemo = React__default.useMemo(() => control._getWatch(name, _defaultValue.current), [control, name]);
14094
- const [value, updateValue] = React__default.useState(_compute.current ? _compute.current(defaultValueMemo) : defaultValueMemo);
14095
- useIsomorphicLayoutEffect$1(() => control._subscribe({
14096
- name,
14097
- formState: {
14098
- values: true,
14099
- },
14100
- exact,
14101
- callback: (formState) => {
14102
- if (!disabled) {
14103
- const formValues = generateWatchOutput(name, control._names, formState.values || control._formValues, false, _defaultValue.current);
14104
- if (_compute.current) {
14105
- const computedFormValues = _compute.current(formValues);
14106
- if (!deepEqual$1(computedFormValues, _computeFormValues.current)) {
14107
- updateValue(computedFormValues);
14108
- _computeFormValues.current = computedFormValues;
14109
- }
14110
- }
14111
- else {
14112
- updateValue(formValues);
14182
+ const [value, updateValue] = React__default.useState(() => {
14183
+ const defaultValue = control._getWatch(name, _defaultValue.current);
14184
+ return _compute.current ? _compute.current(defaultValue) : defaultValue;
14185
+ });
14186
+ const getCurrentOutput = React__default.useCallback((values) => {
14187
+ const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
14188
+ return _compute.current ? _compute.current(formValues) : formValues;
14189
+ }, [control._formValues, control._names, name]);
14190
+ const refreshValue = React__default.useCallback((values) => {
14191
+ if (!disabled) {
14192
+ const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);
14193
+ if (_compute.current) {
14194
+ const computedFormValues = _compute.current(formValues);
14195
+ if (!deepEqual$1(computedFormValues, _computeFormValues.current)) {
14196
+ updateValue(computedFormValues);
14197
+ _computeFormValues.current = computedFormValues;
14113
14198
  }
14114
14199
  }
14115
- },
14116
- }), [control, disabled, name, exact]);
14200
+ else {
14201
+ updateValue(formValues);
14202
+ }
14203
+ }
14204
+ }, [control._formValues, control._names, disabled, name]);
14205
+ useIsomorphicLayoutEffect$1(() => {
14206
+ if (_prevControl.current !== control ||
14207
+ !deepEqual$1(_prevName.current, name)) {
14208
+ _prevControl.current = control;
14209
+ _prevName.current = name;
14210
+ refreshValue();
14211
+ }
14212
+ return control._subscribe({
14213
+ name,
14214
+ formState: {
14215
+ values: true,
14216
+ },
14217
+ exact,
14218
+ callback: (formState) => {
14219
+ refreshValue(formState.values);
14220
+ },
14221
+ });
14222
+ }, [control, exact, name, refreshValue]);
14117
14223
  React__default.useEffect(() => control._removeUnmounted());
14118
- return value;
14224
+ // If name or control changed for this render, synchronously reflect the
14225
+ // latest value so callers (like useController) see the correct value
14226
+ // immediately on the same render.
14227
+ // Optimize: Check control reference first before expensive deepEqual
14228
+ const controlChanged = _prevControl.current !== control;
14229
+ const prevName = _prevName.current;
14230
+ // Cache the computed output to avoid duplicate calls within the same render
14231
+ // We include shouldReturnImmediate in deps to ensure proper recomputation
14232
+ const computedOutput = React__default.useMemo(() => {
14233
+ if (disabled) {
14234
+ return null;
14235
+ }
14236
+ const nameChanged = !controlChanged && !deepEqual$1(prevName, name);
14237
+ const shouldReturnImmediate = controlChanged || nameChanged;
14238
+ return shouldReturnImmediate ? getCurrentOutput() : null;
14239
+ }, [disabled, controlChanged, name, prevName, getCurrentOutput]);
14240
+ return computedOutput !== null ? computedOutput : value;
14119
14241
  }
14120
14242
 
14121
14243
  /**
@@ -14449,11 +14571,12 @@ function isTraversable(value) {
14449
14571
  }
14450
14572
  function markFieldsDirty(data, fields = {}) {
14451
14573
  for (const key in data) {
14452
- if (isTraversable(data[key])) {
14453
- fields[key] = Array.isArray(data[key]) ? [] : {};
14454
- markFieldsDirty(data[key], fields[key]);
14574
+ const value = data[key];
14575
+ if (isTraversable(value)) {
14576
+ fields[key] = Array.isArray(value) ? [] : {};
14577
+ markFieldsDirty(value, fields[key]);
14455
14578
  }
14456
- else if (!isNullOrUndefined(data[key])) {
14579
+ else if (!isUndefined(value)) {
14457
14580
  fields[key] = true;
14458
14581
  }
14459
14582
  }
@@ -14464,16 +14587,18 @@ function getDirtyFields(data, formValues, dirtyFieldsFromValues) {
14464
14587
  dirtyFieldsFromValues = markFieldsDirty(formValues);
14465
14588
  }
14466
14589
  for (const key in data) {
14467
- if (isTraversable(data[key])) {
14590
+ const value = data[key];
14591
+ if (isTraversable(value)) {
14468
14592
  if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) {
14469
- dirtyFieldsFromValues[key] = markFieldsDirty(data[key], Array.isArray(data[key]) ? [] : {});
14593
+ dirtyFieldsFromValues[key] = markFieldsDirty(value, Array.isArray(value) ? [] : {});
14470
14594
  }
14471
14595
  else {
14472
- getDirtyFields(data[key], isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
14596
+ getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);
14473
14597
  }
14474
14598
  }
14475
14599
  else {
14476
- dirtyFieldsFromValues[key] = !deepEqual$1(data[key], formValues[key]);
14600
+ const formValue = formValues[key];
14601
+ dirtyFieldsFromValues[key] = !deepEqual$1(value, formValue);
14477
14602
  }
14478
14603
  }
14479
14604
  return dirtyFieldsFromValues;
@@ -15068,7 +15193,7 @@ function createFormControl(props = {}) {
15068
15193
  shouldSkipSetValueAs
15069
15194
  ? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f))
15070
15195
  : setFieldValue(name, defaultValue);
15071
- _state.mount && _setValid();
15196
+ _state.mount && !_state.action && _setValid();
15072
15197
  }
15073
15198
  };
15074
15199
  const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {
@@ -15822,7 +15947,8 @@ function createFormControl(props = {}) {
15822
15947
  _state.mount =
15823
15948
  !_proxyFormState.isValid ||
15824
15949
  !!keepStateOptions.keepIsValid ||
15825
- !!keepStateOptions.keepDirtyValues;
15950
+ !!keepStateOptions.keepDirtyValues ||
15951
+ (!_options.shouldUnregister && !isEmptyObject(values));
15826
15952
  _state.watch = !!_options.shouldUnregister;
15827
15953
  _subjects.state.next({
15828
15954
  submitCount: keepStateOptions.keepSubmitCount
@@ -16084,11 +16210,15 @@ function useForm(props = {}) {
16084
16210
  }
16085
16211
  }, [control, formState.isDirty]);
16086
16212
  React__default.useEffect(() => {
16213
+ var _a;
16087
16214
  if (props.values && !deepEqual$1(props.values, _values.current)) {
16088
16215
  control._reset(props.values, {
16089
16216
  keepFieldsRef: true,
16090
16217
  ...control._options.resetOptions,
16091
16218
  });
16219
+ if (!((_a = control._options.resetOptions) === null || _a === void 0 ? void 0 : _a.keepIsValid)) {
16220
+ control._setValid();
16221
+ }
16092
16222
  _values.current = props.values;
16093
16223
  updateFormState((state) => ({ ...state }));
16094
16224
  }
@@ -16112,7 +16242,7 @@ function useForm(props = {}) {
16112
16242
  }
16113
16243
 
16114
16244
  // src/primitive.tsx
16115
- var NODES = [
16245
+ var NODES$1 = [
16116
16246
  "a",
16117
16247
  "button",
16118
16248
  "div",
@@ -16131,8 +16261,8 @@ var NODES = [
16131
16261
  "svg",
16132
16262
  "ul"
16133
16263
  ];
16134
- var Primitive = NODES.reduce((primitive, node) => {
16135
- const Slot = createSlot(`Primitive.${node}`);
16264
+ var Primitive$1 = NODES$1.reduce((primitive, node) => {
16265
+ const Slot = createSlot$1(`Primitive.${node}`);
16136
16266
  const Node = React.forwardRef((props, forwardedRef) => {
16137
16267
  const { asChild, ...primitiveProps } = props;
16138
16268
  const Comp = asChild ? Slot : node;
@@ -16144,14 +16274,11 @@ var Primitive = NODES.reduce((primitive, node) => {
16144
16274
  Node.displayName = `Primitive.${node}`;
16145
16275
  return { ...primitive, [node]: Node };
16146
16276
  }, {});
16147
- function dispatchDiscreteCustomEvent(target, event) {
16148
- if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
16149
- }
16150
16277
 
16151
16278
  var NAME$1 = "Label";
16152
16279
  var Label$1 = React.forwardRef((props, forwardedRef) => {
16153
16280
  return /* @__PURE__ */ jsx(
16154
- Primitive.label,
16281
+ Primitive$1.label,
16155
16282
  {
16156
16283
  ...props,
16157
16284
  ref: forwardedRef,
@@ -16169,7 +16296,36 @@ var Root$2 = Label$1;
16169
16296
 
16170
16297
  function r$2(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r$2(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r$2(e))&&(n&&(n+=" "),n+=t);return n}
16171
16298
 
16299
+ /**
16300
+ * Concatenates two arrays faster than the array spread operator.
16301
+ */
16302
+ const concatArrays = (array1, array2) => {
16303
+ // Pre-allocate for better V8 optimization
16304
+ const combinedArray = new Array(array1.length + array2.length);
16305
+ for (let i = 0; i < array1.length; i++) {
16306
+ combinedArray[i] = array1[i];
16307
+ }
16308
+ for (let i = 0; i < array2.length; i++) {
16309
+ combinedArray[array1.length + i] = array2[i];
16310
+ }
16311
+ return combinedArray;
16312
+ };
16313
+
16314
+ // Factory function ensures consistent object shapes
16315
+ const createClassValidatorObject = (classGroupId, validator) => ({
16316
+ classGroupId,
16317
+ validator
16318
+ });
16319
+ // Factory ensures consistent ClassPartObject shape
16320
+ const createClassPartObject = (nextPart = new Map(), validators = null, classGroupId) => ({
16321
+ nextPart,
16322
+ validators,
16323
+ classGroupId
16324
+ });
16172
16325
  const CLASS_PART_SEPARATOR = '-';
16326
+ const EMPTY_CONFLICTS = [];
16327
+ // I use two dots here because one dot is used as prefix for class groups in plugins
16328
+ const ARBITRARY_PROPERTY_PREFIX = 'arbitrary..';
16173
16329
  const createClassGroupUtils = config => {
16174
16330
  const classMap = createClassMap(config);
16175
16331
  const {
@@ -16177,54 +16333,73 @@ const createClassGroupUtils = config => {
16177
16333
  conflictingClassGroupModifiers
16178
16334
  } = config;
16179
16335
  const getClassGroupId = className => {
16180
- const classParts = className.split(CLASS_PART_SEPARATOR);
16181
- // Classes like `-inset-1` produce an empty string as first classPart. We assume that classes for negative values are used correctly and remove it from classParts.
16182
- if (classParts[0] === '' && classParts.length !== 1) {
16183
- classParts.shift();
16336
+ if (className.startsWith('[') && className.endsWith(']')) {
16337
+ return getGroupIdForArbitraryProperty(className);
16184
16338
  }
16185
- return getGroupRecursive(classParts, classMap) || getGroupIdForArbitraryProperty(className);
16339
+ const classParts = className.split(CLASS_PART_SEPARATOR);
16340
+ // Classes like `-inset-1` produce an empty string as first classPart. We assume that classes for negative values are used correctly and skip it.
16341
+ const startIndex = classParts[0] === '' && classParts.length > 1 ? 1 : 0;
16342
+ return getGroupRecursive(classParts, startIndex, classMap);
16186
16343
  };
16187
16344
  const getConflictingClassGroupIds = (classGroupId, hasPostfixModifier) => {
16188
- const conflicts = conflictingClassGroups[classGroupId] || [];
16189
- if (hasPostfixModifier && conflictingClassGroupModifiers[classGroupId]) {
16190
- return [...conflicts, ...conflictingClassGroupModifiers[classGroupId]];
16345
+ if (hasPostfixModifier) {
16346
+ const modifierConflicts = conflictingClassGroupModifiers[classGroupId];
16347
+ const baseConflicts = conflictingClassGroups[classGroupId];
16348
+ if (modifierConflicts) {
16349
+ if (baseConflicts) {
16350
+ // Merge base conflicts with modifier conflicts
16351
+ return concatArrays(baseConflicts, modifierConflicts);
16352
+ }
16353
+ // Only modifier conflicts
16354
+ return modifierConflicts;
16355
+ }
16356
+ // Fall back to without postfix if no modifier conflicts
16357
+ return baseConflicts || EMPTY_CONFLICTS;
16191
16358
  }
16192
- return conflicts;
16359
+ return conflictingClassGroups[classGroupId] || EMPTY_CONFLICTS;
16193
16360
  };
16194
16361
  return {
16195
16362
  getClassGroupId,
16196
16363
  getConflictingClassGroupIds
16197
16364
  };
16198
16365
  };
16199
- const getGroupRecursive = (classParts, classPartObject) => {
16200
- if (classParts.length === 0) {
16366
+ const getGroupRecursive = (classParts, startIndex, classPartObject) => {
16367
+ const classPathsLength = classParts.length - startIndex;
16368
+ if (classPathsLength === 0) {
16201
16369
  return classPartObject.classGroupId;
16202
16370
  }
16203
- const currentClassPart = classParts[0];
16371
+ const currentClassPart = classParts[startIndex];
16204
16372
  const nextClassPartObject = classPartObject.nextPart.get(currentClassPart);
16205
- const classGroupFromNextClassPart = nextClassPartObject ? getGroupRecursive(classParts.slice(1), nextClassPartObject) : undefined;
16206
- if (classGroupFromNextClassPart) {
16207
- return classGroupFromNextClassPart;
16373
+ if (nextClassPartObject) {
16374
+ const result = getGroupRecursive(classParts, startIndex + 1, nextClassPartObject);
16375
+ if (result) return result;
16208
16376
  }
16209
- if (classPartObject.validators.length === 0) {
16377
+ const validators = classPartObject.validators;
16378
+ if (validators === null) {
16210
16379
  return undefined;
16211
16380
  }
16212
- const classRest = classParts.join(CLASS_PART_SEPARATOR);
16213
- return classPartObject.validators.find(({
16214
- validator
16215
- }) => validator(classRest))?.classGroupId;
16216
- };
16217
- const arbitraryPropertyRegex = /^\[(.+)\]$/;
16218
- const getGroupIdForArbitraryProperty = className => {
16219
- if (arbitraryPropertyRegex.test(className)) {
16220
- const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];
16221
- const property = arbitraryPropertyClassName?.substring(0, arbitraryPropertyClassName.indexOf(':'));
16222
- if (property) {
16223
- // I use two dots here because one dot is used as prefix for class groups in plugins
16224
- return 'arbitrary..' + property;
16381
+ // Build classRest string efficiently by joining from startIndex onwards
16382
+ const classRest = startIndex === 0 ? classParts.join(CLASS_PART_SEPARATOR) : classParts.slice(startIndex).join(CLASS_PART_SEPARATOR);
16383
+ const validatorsLength = validators.length;
16384
+ for (let i = 0; i < validatorsLength; i++) {
16385
+ const validatorObj = validators[i];
16386
+ if (validatorObj.validator(classRest)) {
16387
+ return validatorObj.classGroupId;
16225
16388
  }
16226
16389
  }
16390
+ return undefined;
16227
16391
  };
16392
+ /**
16393
+ * Get the class group ID for an arbitrary property.
16394
+ *
16395
+ * @param className - The class name to get the group ID for. Is expected to be string starting with `[` and ending with `]`.
16396
+ */
16397
+ const getGroupIdForArbitraryProperty = className => className.slice(1, -1).indexOf(':') === -1 ? undefined : (() => {
16398
+ const content = className.slice(1, -1);
16399
+ const colonIndex = content.indexOf(':');
16400
+ const property = content.slice(0, colonIndex);
16401
+ return property ? ARBITRARY_PROPERTY_PREFIX + property : undefined;
16402
+ })();
16228
16403
  /**
16229
16404
  * Exported for testing only
16230
16405
  */
@@ -16233,54 +16408,77 @@ const createClassMap = config => {
16233
16408
  theme,
16234
16409
  classGroups
16235
16410
  } = config;
16236
- const classMap = {
16237
- nextPart: new Map(),
16238
- validators: []
16239
- };
16411
+ return processClassGroups(classGroups, theme);
16412
+ };
16413
+ // Split into separate functions to maintain monomorphic call sites
16414
+ const processClassGroups = (classGroups, theme) => {
16415
+ const classMap = createClassPartObject();
16240
16416
  for (const classGroupId in classGroups) {
16241
- processClassesRecursively(classGroups[classGroupId], classMap, classGroupId, theme);
16417
+ const group = classGroups[classGroupId];
16418
+ processClassesRecursively(group, classMap, classGroupId, theme);
16242
16419
  }
16243
16420
  return classMap;
16244
16421
  };
16245
16422
  const processClassesRecursively = (classGroup, classPartObject, classGroupId, theme) => {
16246
- classGroup.forEach(classDefinition => {
16247
- if (typeof classDefinition === 'string') {
16248
- const classPartObjectToEdit = classDefinition === '' ? classPartObject : getPart(classPartObject, classDefinition);
16249
- classPartObjectToEdit.classGroupId = classGroupId;
16250
- return;
16251
- }
16252
- if (typeof classDefinition === 'function') {
16253
- if (isThemeGetter(classDefinition)) {
16254
- processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
16255
- return;
16256
- }
16257
- classPartObject.validators.push({
16258
- validator: classDefinition,
16259
- classGroupId
16260
- });
16261
- return;
16262
- }
16263
- Object.entries(classDefinition).forEach(([key, classGroup]) => {
16264
- processClassesRecursively(classGroup, getPart(classPartObject, key), classGroupId, theme);
16265
- });
16266
- });
16423
+ const len = classGroup.length;
16424
+ for (let i = 0; i < len; i++) {
16425
+ const classDefinition = classGroup[i];
16426
+ processClassDefinition(classDefinition, classPartObject, classGroupId, theme);
16427
+ }
16428
+ };
16429
+ // Split into separate functions for each type to maintain monomorphic call sites
16430
+ const processClassDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
16431
+ if (typeof classDefinition === 'string') {
16432
+ processStringDefinition(classDefinition, classPartObject, classGroupId);
16433
+ return;
16434
+ }
16435
+ if (typeof classDefinition === 'function') {
16436
+ processFunctionDefinition(classDefinition, classPartObject, classGroupId, theme);
16437
+ return;
16438
+ }
16439
+ processObjectDefinition(classDefinition, classPartObject, classGroupId, theme);
16440
+ };
16441
+ const processStringDefinition = (classDefinition, classPartObject, classGroupId) => {
16442
+ const classPartObjectToEdit = classDefinition === '' ? classPartObject : getPart(classPartObject, classDefinition);
16443
+ classPartObjectToEdit.classGroupId = classGroupId;
16444
+ };
16445
+ const processFunctionDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
16446
+ if (isThemeGetter(classDefinition)) {
16447
+ processClassesRecursively(classDefinition(theme), classPartObject, classGroupId, theme);
16448
+ return;
16449
+ }
16450
+ if (classPartObject.validators === null) {
16451
+ classPartObject.validators = [];
16452
+ }
16453
+ classPartObject.validators.push(createClassValidatorObject(classGroupId, classDefinition));
16454
+ };
16455
+ const processObjectDefinition = (classDefinition, classPartObject, classGroupId, theme) => {
16456
+ const entries = Object.entries(classDefinition);
16457
+ const len = entries.length;
16458
+ for (let i = 0; i < len; i++) {
16459
+ const [key, value] = entries[i];
16460
+ processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
16461
+ }
16267
16462
  };
16268
16463
  const getPart = (classPartObject, path) => {
16269
- let currentClassPartObject = classPartObject;
16270
- path.split(CLASS_PART_SEPARATOR).forEach(pathPart => {
16271
- if (!currentClassPartObject.nextPart.has(pathPart)) {
16272
- currentClassPartObject.nextPart.set(pathPart, {
16273
- nextPart: new Map(),
16274
- validators: []
16275
- });
16464
+ let current = classPartObject;
16465
+ const parts = path.split(CLASS_PART_SEPARATOR);
16466
+ const len = parts.length;
16467
+ for (let i = 0; i < len; i++) {
16468
+ const part = parts[i];
16469
+ let next = current.nextPart.get(part);
16470
+ if (!next) {
16471
+ next = createClassPartObject();
16472
+ current.nextPart.set(part, next);
16276
16473
  }
16277
- currentClassPartObject = currentClassPartObject.nextPart.get(pathPart);
16278
- });
16279
- return currentClassPartObject;
16474
+ current = next;
16475
+ }
16476
+ return current;
16280
16477
  };
16281
- const isThemeGetter = func => func.isThemeGetter;
16478
+ // Type guard maintains monomorphic check
16479
+ const isThemeGetter = func => 'isThemeGetter' in func && func.isThemeGetter === true;
16282
16480
 
16283
- // LRU cache inspired from hashlru (https://github.com/dominictarr/hashlru/blob/v1.0.4/index.js) but object replaced with Map to improve performance
16481
+ // LRU cache implementation using plain objects for simplicity
16284
16482
  const createLruCache = maxCacheSize => {
16285
16483
  if (maxCacheSize < 1) {
16286
16484
  return {
@@ -16289,31 +16487,31 @@ const createLruCache = maxCacheSize => {
16289
16487
  };
16290
16488
  }
16291
16489
  let cacheSize = 0;
16292
- let cache = new Map();
16293
- let previousCache = new Map();
16490
+ let cache = Object.create(null);
16491
+ let previousCache = Object.create(null);
16294
16492
  const update = (key, value) => {
16295
- cache.set(key, value);
16493
+ cache[key] = value;
16296
16494
  cacheSize++;
16297
16495
  if (cacheSize > maxCacheSize) {
16298
16496
  cacheSize = 0;
16299
16497
  previousCache = cache;
16300
- cache = new Map();
16498
+ cache = Object.create(null);
16301
16499
  }
16302
16500
  };
16303
16501
  return {
16304
16502
  get(key) {
16305
- let value = cache.get(key);
16503
+ let value = cache[key];
16306
16504
  if (value !== undefined) {
16307
16505
  return value;
16308
16506
  }
16309
- if ((value = previousCache.get(key)) !== undefined) {
16507
+ if ((value = previousCache[key]) !== undefined) {
16310
16508
  update(key, value);
16311
16509
  return value;
16312
16510
  }
16313
16511
  },
16314
16512
  set(key, value) {
16315
- if (cache.has(key)) {
16316
- cache.set(key, value);
16513
+ if (key in cache) {
16514
+ cache[key] = value;
16317
16515
  } else {
16318
16516
  update(key, value);
16319
16517
  }
@@ -16322,7 +16520,15 @@ const createLruCache = maxCacheSize => {
16322
16520
  };
16323
16521
  const IMPORTANT_MODIFIER = '!';
16324
16522
  const MODIFIER_SEPARATOR = ':';
16325
- const MODIFIER_SEPARATOR_LENGTH = MODIFIER_SEPARATOR.length;
16523
+ const EMPTY_MODIFIERS = [];
16524
+ // Pre-allocated result object shape for consistency
16525
+ const createResultObject = (modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition, isExternal) => ({
16526
+ modifiers,
16527
+ hasImportantModifier,
16528
+ baseClassName,
16529
+ maybePostfixModifierPosition,
16530
+ isExternal
16531
+ });
16326
16532
  const createParseClassName = config => {
16327
16533
  const {
16328
16534
  prefix,
@@ -16335,17 +16541,19 @@ const createParseClassName = config => {
16335
16541
  * @see https://github.com/tailwindlabs/tailwindcss/blob/v3.2.2/src/util/splitAtTopLevelOnly.js
16336
16542
  */
16337
16543
  let parseClassName = className => {
16544
+ // Use simple array with push for better performance
16338
16545
  const modifiers = [];
16339
16546
  let bracketDepth = 0;
16340
16547
  let parenDepth = 0;
16341
16548
  let modifierStart = 0;
16342
16549
  let postfixModifierPosition;
16343
- for (let index = 0; index < className.length; index++) {
16344
- let currentCharacter = className[index];
16550
+ const len = className.length;
16551
+ for (let index = 0; index < len; index++) {
16552
+ const currentCharacter = className[index];
16345
16553
  if (bracketDepth === 0 && parenDepth === 0) {
16346
16554
  if (currentCharacter === MODIFIER_SEPARATOR) {
16347
16555
  modifiers.push(className.slice(modifierStart, index));
16348
- modifierStart = index + MODIFIER_SEPARATOR_LENGTH;
16556
+ modifierStart = index + 1;
16349
16557
  continue;
16350
16558
  }
16351
16559
  if (currentCharacter === '/') {
@@ -16353,37 +16561,31 @@ const createParseClassName = config => {
16353
16561
  continue;
16354
16562
  }
16355
16563
  }
16356
- if (currentCharacter === '[') {
16357
- bracketDepth++;
16358
- } else if (currentCharacter === ']') {
16359
- bracketDepth--;
16360
- } else if (currentCharacter === '(') {
16361
- parenDepth++;
16362
- } else if (currentCharacter === ')') {
16363
- parenDepth--;
16364
- }
16564
+ if (currentCharacter === '[') bracketDepth++;else if (currentCharacter === ']') bracketDepth--;else if (currentCharacter === '(') parenDepth++;else if (currentCharacter === ')') parenDepth--;
16565
+ }
16566
+ const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.slice(modifierStart);
16567
+ // Inline important modifier check
16568
+ let baseClassName = baseClassNameWithImportantModifier;
16569
+ let hasImportantModifier = false;
16570
+ if (baseClassNameWithImportantModifier.endsWith(IMPORTANT_MODIFIER)) {
16571
+ baseClassName = baseClassNameWithImportantModifier.slice(0, -1);
16572
+ hasImportantModifier = true;
16573
+ } else if (
16574
+ /**
16575
+ * In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
16576
+ * @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
16577
+ */
16578
+ baseClassNameWithImportantModifier.startsWith(IMPORTANT_MODIFIER)) {
16579
+ baseClassName = baseClassNameWithImportantModifier.slice(1);
16580
+ hasImportantModifier = true;
16365
16581
  }
16366
- const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.substring(modifierStart);
16367
- const baseClassName = stripImportantModifier(baseClassNameWithImportantModifier);
16368
- const hasImportantModifier = baseClassName !== baseClassNameWithImportantModifier;
16369
16582
  const maybePostfixModifierPosition = postfixModifierPosition && postfixModifierPosition > modifierStart ? postfixModifierPosition - modifierStart : undefined;
16370
- return {
16371
- modifiers,
16372
- hasImportantModifier,
16373
- baseClassName,
16374
- maybePostfixModifierPosition
16375
- };
16583
+ return createResultObject(modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition);
16376
16584
  };
16377
16585
  if (prefix) {
16378
16586
  const fullPrefix = prefix + MODIFIER_SEPARATOR;
16379
16587
  const parseClassNameOriginal = parseClassName;
16380
- parseClassName = className => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.substring(fullPrefix.length)) : {
16381
- isExternal: true,
16382
- modifiers: [],
16383
- hasImportantModifier: false,
16384
- baseClassName: className,
16385
- maybePostfixModifierPosition: undefined
16386
- };
16588
+ parseClassName = className => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.slice(fullPrefix.length)) : createResultObject(EMPTY_MODIFIERS, false, className, undefined, true);
16387
16589
  }
16388
16590
  if (experimentalParseClassName) {
16389
16591
  const parseClassNameOriginal = parseClassName;
@@ -16394,19 +16596,6 @@ const createParseClassName = config => {
16394
16596
  }
16395
16597
  return parseClassName;
16396
16598
  };
16397
- const stripImportantModifier = baseClassName => {
16398
- if (baseClassName.endsWith(IMPORTANT_MODIFIER)) {
16399
- return baseClassName.substring(0, baseClassName.length - 1);
16400
- }
16401
- /**
16402
- * In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
16403
- * @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
16404
- */
16405
- if (baseClassName.startsWith(IMPORTANT_MODIFIER)) {
16406
- return baseClassName.substring(1);
16407
- }
16408
- return baseClassName;
16409
- };
16410
16599
 
16411
16600
  /**
16412
16601
  * Sorts modifiers according to following schema:
@@ -16414,26 +16603,41 @@ const stripImportantModifier = baseClassName => {
16414
16603
  * - When an arbitrary variant appears, it must be preserved which modifiers are before and after it
16415
16604
  */
16416
16605
  const createSortModifiers = config => {
16417
- const orderSensitiveModifiers = Object.fromEntries(config.orderSensitiveModifiers.map(modifier => [modifier, true]));
16418
- const sortModifiers = modifiers => {
16419
- if (modifiers.length <= 1) {
16420
- return modifiers;
16421
- }
16422
- const sortedModifiers = [];
16423
- let unsortedModifiers = [];
16424
- modifiers.forEach(modifier => {
16425
- const isPositionSensitive = modifier[0] === '[' || orderSensitiveModifiers[modifier];
16426
- if (isPositionSensitive) {
16427
- sortedModifiers.push(...unsortedModifiers.sort(), modifier);
16428
- unsortedModifiers = [];
16606
+ // Pre-compute weights for all known modifiers for O(1) comparison
16607
+ const modifierWeights = new Map();
16608
+ // Assign weights to sensitive modifiers (highest priority, but preserve order)
16609
+ config.orderSensitiveModifiers.forEach((mod, index) => {
16610
+ modifierWeights.set(mod, 1000000 + index); // High weights for sensitive mods
16611
+ });
16612
+ return modifiers => {
16613
+ const result = [];
16614
+ let currentSegment = [];
16615
+ // Process modifiers in one pass
16616
+ for (let i = 0; i < modifiers.length; i++) {
16617
+ const modifier = modifiers[i];
16618
+ // Check if modifier is sensitive (starts with '[' or in orderSensitiveModifiers)
16619
+ const isArbitrary = modifier[0] === '[';
16620
+ const isOrderSensitive = modifierWeights.has(modifier);
16621
+ if (isArbitrary || isOrderSensitive) {
16622
+ // Sort and flush current segment alphabetically
16623
+ if (currentSegment.length > 0) {
16624
+ currentSegment.sort();
16625
+ result.push(...currentSegment);
16626
+ currentSegment = [];
16627
+ }
16628
+ result.push(modifier);
16429
16629
  } else {
16430
- unsortedModifiers.push(modifier);
16630
+ // Regular modifier - add to current segment for batch sorting
16631
+ currentSegment.push(modifier);
16431
16632
  }
16432
- });
16433
- sortedModifiers.push(...unsortedModifiers.sort());
16434
- return sortedModifiers;
16633
+ }
16634
+ // Sort and add any remaining segment items
16635
+ if (currentSegment.length > 0) {
16636
+ currentSegment.sort();
16637
+ result.push(...currentSegment);
16638
+ }
16639
+ return result;
16435
16640
  };
16436
- return sortModifiers;
16437
16641
  };
16438
16642
  const createConfigUtils = config => ({
16439
16643
  cache: createLruCache(config.cacheSize),
@@ -16488,10 +16692,11 @@ const mergeClassList = (classList, configUtils) => {
16488
16692
  }
16489
16693
  hasPostfixModifier = false;
16490
16694
  }
16491
- const variantModifier = sortModifiers(modifiers).join(':');
16695
+ // Fast path: skip sorting for empty or single modifier
16696
+ const variantModifier = modifiers.length === 0 ? '' : modifiers.length === 1 ? modifiers[0] : sortModifiers(modifiers).join(':');
16492
16697
  const modifierId = hasImportantModifier ? variantModifier + IMPORTANT_MODIFIER : variantModifier;
16493
16698
  const classId = modifierId + classGroupId;
16494
- if (classGroupsInConflict.includes(classId)) {
16699
+ if (classGroupsInConflict.indexOf(classId) > -1) {
16495
16700
  // Tailwind class omitted due to conflict
16496
16701
  continue;
16497
16702
  }
@@ -16516,13 +16721,13 @@ const mergeClassList = (classList, configUtils) => {
16516
16721
  *
16517
16722
  * Original code has MIT license: Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
16518
16723
  */
16519
- function twJoin() {
16724
+ const twJoin = (...classLists) => {
16520
16725
  let index = 0;
16521
16726
  let argument;
16522
16727
  let resolvedValue;
16523
16728
  let string = '';
16524
- while (index < arguments.length) {
16525
- if (argument = arguments[index++]) {
16729
+ while (index < classLists.length) {
16730
+ if (argument = classLists[index++]) {
16526
16731
  if (resolvedValue = toValue(argument)) {
16527
16732
  string && (string += ' ');
16528
16733
  string += resolvedValue;
@@ -16530,8 +16735,9 @@ function twJoin() {
16530
16735
  }
16531
16736
  }
16532
16737
  return string;
16533
- }
16738
+ };
16534
16739
  const toValue = mix => {
16740
+ // Fast path for strings
16535
16741
  if (typeof mix === 'string') {
16536
16742
  return mix;
16537
16743
  }
@@ -16547,20 +16753,20 @@ const toValue = mix => {
16547
16753
  }
16548
16754
  return string;
16549
16755
  };
16550
- function createTailwindMerge(createConfigFirst, ...createConfigRest) {
16756
+ const createTailwindMerge = (createConfigFirst, ...createConfigRest) => {
16551
16757
  let configUtils;
16552
16758
  let cacheGet;
16553
16759
  let cacheSet;
16554
- let functionToCall = initTailwindMerge;
16555
- function initTailwindMerge(classList) {
16760
+ let functionToCall;
16761
+ const initTailwindMerge = classList => {
16556
16762
  const config = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
16557
16763
  configUtils = createConfigUtils(config);
16558
16764
  cacheGet = configUtils.cache.get;
16559
16765
  cacheSet = configUtils.cache.set;
16560
16766
  functionToCall = tailwindMerge;
16561
16767
  return tailwindMerge(classList);
16562
- }
16563
- function tailwindMerge(classList) {
16768
+ };
16769
+ const tailwindMerge = classList => {
16564
16770
  const cachedResult = cacheGet(classList);
16565
16771
  if (cachedResult) {
16566
16772
  return cachedResult;
@@ -16568,13 +16774,13 @@ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
16568
16774
  const result = mergeClassList(classList, configUtils);
16569
16775
  cacheSet(classList, result);
16570
16776
  return result;
16571
- }
16572
- return function callTailwindMerge() {
16573
- return functionToCall(twJoin.apply(null, arguments));
16574
16777
  };
16575
- }
16778
+ functionToCall = initTailwindMerge;
16779
+ return (...args) => functionToCall(twJoin(...args));
16780
+ };
16781
+ const fallbackThemeArr = [];
16576
16782
  const fromTheme = key => {
16577
- const themeGetter = theme => theme[key] || [];
16783
+ const themeGetter = theme => theme[key] || fallbackThemeArr;
16578
16784
  themeGetter.isThemeGetter = true;
16579
16785
  return themeGetter;
16580
16786
  };
@@ -19197,7 +19403,7 @@ const FloatingLabel = React.forwardRef((_a, ref) => {
19197
19403
  const LabelComponent = isFormLabel ? FormLabel : Label;
19198
19404
  const isEmpty = !value || value.length === 0;
19199
19405
  const isFloating = isFocused || !isEmpty;
19200
- return (jsxs("div", { className: cn("pointer-events-none absolute translate-x-2", "z-10 block", "duration-200 ease-in-out", isFloating ? "top-0 -translate-y-1/2" : "top-1/2 -translate-y-1/2", className), children: [jsx("div", { className: "bg-background absolute left-0 right-0 top-1/2 z-0 h-[2px] -translate-x-0 -translate-y-1/2" }), jsxs(LabelComponent, Object.assign({ ref: ref, className: cn("relative z-10 block",
19406
+ return (jsxs("div", { className: cn("pointer-events-none absolute translate-x-2", "z-10 block", "duration-200 ease-in-out", isFloating ? "top-0 -translate-y-1/2" : "top-1/2 -translate-y-1/2", className), children: [jsx("div", { className: "bg-background absolute left-0 right-0 top-1/2 z-10 h-[5px] -translate-x-0 -translate-y-[calc(50%+2px)]" }), jsxs(LabelComponent, Object.assign({ ref: ref, className: cn("relative z-20 block",
19201
19407
  // "after:bg-background after:absolute after:left-0 after:right-0 after:top-1/2 after:z-0 after:h-px after:-translate-y-1/2 after:content-['']",
19202
19408
  "m-0 p-0 px-1 leading-none", "duration-200 ease-in-out", isFloating
19203
19409
  ? "text-xs font-medium"
@@ -19448,6 +19654,127 @@ function isFunction(value) {
19448
19654
  return typeof value === "function";
19449
19655
  }
19450
19656
 
19657
+ // src/slot.tsx
19658
+ // @__NO_SIDE_EFFECTS__
19659
+ function createSlot(ownerName) {
19660
+ const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
19661
+ const Slot2 = React.forwardRef((props, forwardedRef) => {
19662
+ const { children, ...slotProps } = props;
19663
+ const childrenArray = React.Children.toArray(children);
19664
+ const slottable = childrenArray.find(isSlottable);
19665
+ if (slottable) {
19666
+ const newElement = slottable.props.children;
19667
+ const newChildren = childrenArray.map((child) => {
19668
+ if (child === slottable) {
19669
+ if (React.Children.count(newElement) > 1) return React.Children.only(null);
19670
+ return React.isValidElement(newElement) ? newElement.props.children : null;
19671
+ } else {
19672
+ return child;
19673
+ }
19674
+ });
19675
+ return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
19676
+ }
19677
+ return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
19678
+ });
19679
+ Slot2.displayName = `${ownerName}.Slot`;
19680
+ return Slot2;
19681
+ }
19682
+ // @__NO_SIDE_EFFECTS__
19683
+ function createSlotClone(ownerName) {
19684
+ const SlotClone = React.forwardRef((props, forwardedRef) => {
19685
+ const { children, ...slotProps } = props;
19686
+ if (React.isValidElement(children)) {
19687
+ const childrenRef = getElementRef$1(children);
19688
+ const props2 = mergeProps(slotProps, children.props);
19689
+ if (children.type !== React.Fragment) {
19690
+ props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
19691
+ }
19692
+ return React.cloneElement(children, props2);
19693
+ }
19694
+ return React.Children.count(children) > 1 ? React.Children.only(null) : null;
19695
+ });
19696
+ SlotClone.displayName = `${ownerName}.SlotClone`;
19697
+ return SlotClone;
19698
+ }
19699
+ var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
19700
+ function isSlottable(child) {
19701
+ return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
19702
+ }
19703
+ function mergeProps(slotProps, childProps) {
19704
+ const overrideProps = { ...childProps };
19705
+ for (const propName in childProps) {
19706
+ const slotPropValue = slotProps[propName];
19707
+ const childPropValue = childProps[propName];
19708
+ const isHandler = /^on[A-Z]/.test(propName);
19709
+ if (isHandler) {
19710
+ if (slotPropValue && childPropValue) {
19711
+ overrideProps[propName] = (...args) => {
19712
+ const result = childPropValue(...args);
19713
+ slotPropValue(...args);
19714
+ return result;
19715
+ };
19716
+ } else if (slotPropValue) {
19717
+ overrideProps[propName] = slotPropValue;
19718
+ }
19719
+ } else if (propName === "style") {
19720
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
19721
+ } else if (propName === "className") {
19722
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
19723
+ }
19724
+ }
19725
+ return { ...slotProps, ...overrideProps };
19726
+ }
19727
+ function getElementRef$1(element) {
19728
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
19729
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
19730
+ if (mayWarn) {
19731
+ return element.ref;
19732
+ }
19733
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
19734
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
19735
+ if (mayWarn) {
19736
+ return element.props.ref;
19737
+ }
19738
+ return element.props.ref || element.ref;
19739
+ }
19740
+
19741
+ // src/primitive.tsx
19742
+ var NODES = [
19743
+ "a",
19744
+ "button",
19745
+ "div",
19746
+ "form",
19747
+ "h2",
19748
+ "h3",
19749
+ "img",
19750
+ "input",
19751
+ "label",
19752
+ "li",
19753
+ "nav",
19754
+ "ol",
19755
+ "p",
19756
+ "select",
19757
+ "span",
19758
+ "svg",
19759
+ "ul"
19760
+ ];
19761
+ var Primitive = NODES.reduce((primitive, node) => {
19762
+ const Slot = createSlot(`Primitive.${node}`);
19763
+ const Node = React.forwardRef((props, forwardedRef) => {
19764
+ const { asChild, ...primitiveProps } = props;
19765
+ const Comp = asChild ? Slot : node;
19766
+ if (typeof window !== "undefined") {
19767
+ window[Symbol.for("radix-ui")] = true;
19768
+ }
19769
+ return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
19770
+ });
19771
+ Node.displayName = `Primitive.${node}`;
19772
+ return { ...primitive, [node]: Node };
19773
+ }, {});
19774
+ function dispatchDiscreteCustomEvent(target, event) {
19775
+ if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
19776
+ }
19777
+
19451
19778
  // packages/react/use-callback-ref/src/use-callback-ref.tsx
19452
19779
  function useCallbackRef$1(callback) {
19453
19780
  const callbackRef = React.useRef(callback);
@@ -21165,7 +21492,7 @@ var Portal = DialogPortal;
21165
21492
  var Overlay = DialogOverlay;
21166
21493
  var Content$1 = DialogContent;
21167
21494
 
21168
- var N='[cmdk-group=""]',Y='[cmdk-group-items=""]',be='[cmdk-group-heading=""]',le='[cmdk-item=""]',ce=`${le}:not([aria-disabled="true"])`,Z="cmdk-item-select",T="data-value",Re=(r,o,n)=>W(r,o,n),ue=React.createContext(void 0),K=()=>React.useContext(ue),de=React.createContext(void 0),ee=()=>React.useContext(de),fe=React.createContext(void 0),me=React.forwardRef((r,o)=>{let n=L(()=>{var e,a;return {search:"",value:(a=(e=r.value)!=null?e:r.defaultValue)!=null?a:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),u=L(()=>new Set),c=L(()=>new Map),d=L(()=>new Map),f=L(()=>new Set),p=pe(r),{label:b,children:m,value:R,onValueChange:x,filter:C,shouldFilter:S,loop:A,disablePointerSelection:ge=false,vimBindings:j=true,...O}=r,$=useId(),q=useId(),_=useId(),I=React.useRef(null),v=ke();k$2(()=>{if(R!==void 0){let e=R.trim();n.current.value=e,E.emit();}},[R]),k$2(()=>{v(6,ne);},[]);let E=React.useMemo(()=>({subscribe:e=>(f.current.add(e),()=>f.current.delete(e)),snapshot:()=>n.current,setState:(e,a,s)=>{var i,l,g,y;if(!Object.is(n.current[e],a)){if(n.current[e]=a,e==="search")J(),z(),v(1,W);else if(e==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let h=document.getElementById(_);h?h.focus():(i=document.getElementById($))==null||i.focus();}if(v(7,()=>{var h;n.current.selectedItemId=(h=M())==null?void 0:h.id,E.emit();}),s||v(5,ne),((l=p.current)==null?void 0:l.value)!==void 0){let h=a!=null?a:"";(y=(g=p.current).onValueChange)==null||y.call(g,h);return}}E.emit();}},emit:()=>{f.current.forEach(e=>e());}}),[]),U=React.useMemo(()=>({value:(e,a,s)=>{var i;a!==((i=d.current.get(e))==null?void 0:i.value)&&(d.current.set(e,{value:a,keywords:s}),n.current.filtered.items.set(e,te(a,s)),v(2,()=>{z(),E.emit();}));},item:(e,a)=>(u.current.add(e),a&&(c.current.has(a)?c.current.get(a).add(e):c.current.set(a,new Set([e]))),v(3,()=>{J(),z(),n.current.value||W(),E.emit();}),()=>{d.current.delete(e),u.current.delete(e),n.current.filtered.items.delete(e);let s=M();v(4,()=>{J(),(s==null?void 0:s.getAttribute("id"))===e&&W(),E.emit();});}),group:e=>(c.current.has(e)||c.current.set(e,new Set),()=>{d.current.delete(e),c.current.delete(e);}),filter:()=>p.current.shouldFilter,label:b||r["aria-label"],getDisablePointerSelection:()=>p.current.disablePointerSelection,listId:$,inputId:_,labelId:q,listInnerRef:I}),[]);function te(e,a){var i,l;let s=(l=(i=p.current)==null?void 0:i.filter)!=null?l:Re;return e?s(e,n.current.search,a):0}function z(){if(!n.current.search||p.current.shouldFilter===false)return;let e=n.current.filtered.items,a=[];n.current.filtered.groups.forEach(i=>{let l=c.current.get(i),g=0;l.forEach(y=>{let h=e.get(y);g=Math.max(h,g);}),a.push([i,g]);});let s=I.current;V().sort((i,l)=>{var h,F;let g=i.getAttribute("id"),y=l.getAttribute("id");return ((h=e.get(y))!=null?h:0)-((F=e.get(g))!=null?F:0)}).forEach(i=>{let l=i.closest(Y);l?l.appendChild(i.parentElement===l?i:i.closest(`${Y} > *`)):s.appendChild(i.parentElement===s?i:i.closest(`${Y} > *`));}),a.sort((i,l)=>l[1]-i[1]).forEach(i=>{var g;let l=(g=I.current)==null?void 0:g.querySelector(`${N}[${T}="${encodeURIComponent(i[0])}"]`);l==null||l.parentElement.appendChild(l);});}function W(){let e=V().find(s=>s.getAttribute("aria-disabled")!=="true"),a=e==null?void 0:e.getAttribute(T);E.setState("value",a||void 0);}function J(){var a,s,i,l;if(!n.current.search||p.current.shouldFilter===false){n.current.filtered.count=u.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let g of u.current){let y=(s=(a=d.current.get(g))==null?void 0:a.value)!=null?s:"",h=(l=(i=d.current.get(g))==null?void 0:i.keywords)!=null?l:[],F=te(y,h);n.current.filtered.items.set(g,F),F>0&&e++;}for(let[g,y]of c.current)for(let h of y)if(n.current.filtered.items.get(h)>0){n.current.filtered.groups.add(g);break}n.current.filtered.count=e;}function ne(){var a,s,i;let e=M();e&&(((a=e.parentElement)==null?void 0:a.firstChild)===e&&((i=(s=e.closest(N))==null?void 0:s.querySelector(be))==null||i.scrollIntoView({block:"nearest"})),e.scrollIntoView({block:"nearest"}));}function M(){var e;return (e=I.current)==null?void 0:e.querySelector(`${le}[aria-selected="true"]`)}function V(){var e;return Array.from(((e=I.current)==null?void 0:e.querySelectorAll(ce))||[])}function X(e){let s=V()[e];s&&E.setState("value",s.getAttribute(T));}function Q(e){var g;let a=M(),s=V(),i=s.findIndex(y=>y===a),l=s[i+e];(g=p.current)!=null&&g.loop&&(l=i+e<0?s[s.length-1]:i+e===s.length?s[0]:s[i+e]),l&&E.setState("value",l.getAttribute(T));}function re(e){let a=M(),s=a==null?void 0:a.closest(N),i;for(;s&&!i;)s=e>0?we(s,N):De(s,N),i=s==null?void 0:s.querySelector(ce);i?E.setState("value",i.getAttribute(T)):Q(e);}let oe=()=>X(V().length-1),ie=e=>{e.preventDefault(),e.metaKey?oe():e.altKey?re(1):Q(1);},se=e=>{e.preventDefault(),e.metaKey?X(0):e.altKey?re(-1):Q(-1);};return React.createElement(Primitive.div,{ref:o,tabIndex:-1,...O,"cmdk-root":"",onKeyDown:e=>{var s;(s=O.onKeyDown)==null||s.call(O,e);let a=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||a))switch(e.key){case "n":case "j":{j&&e.ctrlKey&&ie(e);break}case "ArrowDown":{ie(e);break}case "p":case "k":{j&&e.ctrlKey&&se(e);break}case "ArrowUp":{se(e);break}case "Home":{e.preventDefault(),X(0);break}case "End":{e.preventDefault(),oe();break}case "Enter":{e.preventDefault();let i=M();if(i){let l=new Event(Z);i.dispatchEvent(l);}}}}},React.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:Te},b),B(r,e=>React.createElement(de.Provider,{value:E},React.createElement(ue.Provider,{value:U},e))))}),he=React.forwardRef((r,o)=>{var _,I;let n=useId(),u=React.useRef(null),c=React.useContext(fe),d=K(),f=pe(r),p=(I=(_=f.current)==null?void 0:_.forceMount)!=null?I:c==null?void 0:c.forceMount;k$2(()=>{if(!p)return d.item(n,c==null?void 0:c.id)},[p]);let b=ve(n,u,[r.value,r.children,u],r.keywords),m=ee(),R=P(v=>v.value&&v.value===b.current),x=P(v=>p||d.filter()===false?true:v.search?v.filtered.items.get(n)>0:true);React.useEffect(()=>{let v=u.current;if(!(!v||r.disabled))return v.addEventListener(Z,C),()=>v.removeEventListener(Z,C)},[x,r.onSelect,r.disabled]);function C(){var v,E;S(),(E=(v=f.current).onSelect)==null||E.call(v,b.current);}function S(){m.setState("value",b.current,true);}if(!x)return null;let{disabled:A,value:ge,onSelect:j,forceMount:O,keywords:$,...q}=r;return React.createElement(Primitive.div,{ref:composeRefs(u,o),...q,id:n,"cmdk-item":"",role:"option","aria-disabled":!!A,"aria-selected":!!R,"data-disabled":!!A,"data-selected":!!R,onPointerMove:A||d.getDisablePointerSelection()?void 0:S,onClick:A?void 0:C},r.children)}),Ee=React.forwardRef((r,o)=>{let{heading:n,children:u,forceMount:c,...d}=r,f=useId(),p=React.useRef(null),b=React.useRef(null),m=useId(),R=K(),x=P(S=>c||R.filter()===false?true:S.search?S.filtered.groups.has(f):true);k$2(()=>R.group(f),[]),ve(f,p,[r.value,r.heading,b]);let C=React.useMemo(()=>({id:f,forceMount:c}),[c]);return React.createElement(Primitive.div,{ref:composeRefs(p,o),...d,"cmdk-group":"",role:"presentation",hidden:x?void 0:true},n&&React.createElement("div",{ref:b,"cmdk-group-heading":"","aria-hidden":true,id:m},n),B(r,S=>React.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?m:void 0},React.createElement(fe.Provider,{value:C},S))))}),ye=React.forwardRef((r,o)=>{let{alwaysRender:n,...u}=r,c=React.useRef(null),d=P(f=>!f.search);return !n&&!d?null:React.createElement(Primitive.div,{ref:composeRefs(c,o),...u,"cmdk-separator":"",role:"separator"})}),Se=React.forwardRef((r,o)=>{let{onValueChange:n,...u}=r,c=r.value!=null,d=ee(),f=P(m=>m.search),p=P(m=>m.selectedItemId),b=K();return React.useEffect(()=>{r.value!=null&&d.setState("search",r.value);},[r.value]),React.createElement(Primitive.input,{ref:o,...u,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:false,"aria-autocomplete":"list",role:"combobox","aria-expanded":true,"aria-controls":b.listId,"aria-labelledby":b.labelId,"aria-activedescendant":p,id:b.inputId,type:"text",value:c?r.value:f,onChange:m=>{c||d.setState("search",m.target.value),n==null||n(m.target.value);}})}),Ce=React.forwardRef((r,o)=>{let{children:n,label:u="Suggestions",...c}=r,d=React.useRef(null),f=React.useRef(null),p=P(m=>m.selectedItemId),b=K();return React.useEffect(()=>{if(f.current&&d.current){let m=f.current,R=d.current,x,C=new ResizeObserver(()=>{x=requestAnimationFrame(()=>{let S=m.offsetHeight;R.style.setProperty("--cmdk-list-height",S.toFixed(1)+"px");});});return C.observe(m),()=>{cancelAnimationFrame(x),C.unobserve(m);}}},[]),React.createElement(Primitive.div,{ref:composeRefs(d,o),...c,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":p,"aria-label":u,id:b.listId},B(r,m=>React.createElement("div",{ref:composeRefs(f,b.listInnerRef),"cmdk-list-sizer":""},m)))}),xe=React.forwardRef((r,o)=>{let{open:n,onOpenChange:u,overlayClassName:c,contentClassName:d,container:f,...p}=r;return React.createElement(Root$1,{open:n,onOpenChange:u},React.createElement(Portal,{container:f},React.createElement(Overlay,{"cmdk-overlay":"",className:c}),React.createElement(Content$1,{"aria-label":r.label,"cmdk-dialog":"",className:d},React.createElement(me,{ref:o,...p}))))}),Ie=React.forwardRef((r,o)=>P(u=>u.filtered.count===0)?React.createElement(Primitive.div,{ref:o,...r,"cmdk-empty":"",role:"presentation"}):null),Pe=React.forwardRef((r,o)=>{let{progress:n,children:u,label:c="Loading...",...d}=r;return React.createElement(Primitive.div,{ref:o,...d,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":c},B(r,f=>React.createElement("div",{"aria-hidden":true},f)))}),_e=Object.assign(me,{List:Ce,Item:he,Input:Se,Group:Ee,Separator:ye,Dialog:xe,Empty:Ie,Loading:Pe});function we(r,o){let n=r.nextElementSibling;for(;n;){if(n.matches(o))return n;n=n.nextElementSibling;}}function De(r,o){let n=r.previousElementSibling;for(;n;){if(n.matches(o))return n;n=n.previousElementSibling;}}function pe(r){let o=React.useRef(r);return k$2(()=>{o.current=r;}),o}var k$2=typeof window=="undefined"?React.useEffect:React.useLayoutEffect;function L(r){let o=React.useRef();return o.current===void 0&&(o.current=r()),o}function P(r){let o=ee(),n=()=>r(o.snapshot());return React.useSyncExternalStore(o.subscribe,n,n)}function ve(r,o,n,u=[]){let c=React.useRef(),d=K();return k$2(()=>{var b;let f=(()=>{var m;for(let R of n){if(typeof R=="string")return R.trim();if(typeof R=="object"&&"current"in R)return R.current?(m=R.current.textContent)==null?void 0:m.trim():c.current}})(),p=u.map(m=>m.trim());d.value(r,f,p),(b=o.current)==null||b.setAttribute(T,f),c.current=f;}),c}var ke=()=>{let[r,o]=React.useState(),n=L(()=>new Map);return k$2(()=>{n.current.forEach(u=>u()),n.current=new Map;},[r]),(u,c)=>{n.current.set(u,c),o({});}};function Me(r){let o=r.type;return typeof o=="function"?o(r.props):"render"in o?o.render(r.props):r}function B({asChild:r,children:o},n){return r&&React.isValidElement(o)?React.cloneElement(Me(o),{ref:o.ref},n(o.props.children)):n(o)}var Te={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};
21495
+ var N='[cmdk-group=""]',Y='[cmdk-group-items=""]',be='[cmdk-group-heading=""]',le='[cmdk-item=""]',ce=`${le}:not([aria-disabled="true"])`,Z="cmdk-item-select",T="data-value",Re=(r,o,n)=>W(r,o,n),ue=React.createContext(void 0),K=()=>React.useContext(ue),de=React.createContext(void 0),ee=()=>React.useContext(de),fe=React.createContext(void 0),me=React.forwardRef((r,o)=>{let n=L(()=>{var e,a;return {search:"",value:(a=(e=r.value)!=null?e:r.defaultValue)!=null?a:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),u=L(()=>new Set),c=L(()=>new Map),d=L(()=>new Map),f=L(()=>new Set),p=pe(r),{label:b,children:m,value:R,onValueChange:x,filter:C,shouldFilter:S,loop:A,disablePointerSelection:ge=false,vimBindings:j=true,...O}=r,$=useId(),q=useId(),_=useId(),I=React.useRef(null),v=ke();k$2(()=>{if(R!==void 0){let e=R.trim();n.current.value=e,E.emit();}},[R]),k$2(()=>{v(6,ne);},[]);let E=React.useMemo(()=>({subscribe:e=>(f.current.add(e),()=>f.current.delete(e)),snapshot:()=>n.current,setState:(e,a,s)=>{var i,l,g,y;if(!Object.is(n.current[e],a)){if(n.current[e]=a,e==="search")J(),z(),v(1,W);else if(e==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let h=document.getElementById(_);h?h.focus():(i=document.getElementById($))==null||i.focus();}if(v(7,()=>{var h;n.current.selectedItemId=(h=M())==null?void 0:h.id,E.emit();}),s||v(5,ne),((l=p.current)==null?void 0:l.value)!==void 0){let h=a!=null?a:"";(y=(g=p.current).onValueChange)==null||y.call(g,h);return}}E.emit();}},emit:()=>{f.current.forEach(e=>e());}}),[]),U=React.useMemo(()=>({value:(e,a,s)=>{var i;a!==((i=d.current.get(e))==null?void 0:i.value)&&(d.current.set(e,{value:a,keywords:s}),n.current.filtered.items.set(e,te(a,s)),v(2,()=>{z(),E.emit();}));},item:(e,a)=>(u.current.add(e),a&&(c.current.has(a)?c.current.get(a).add(e):c.current.set(a,new Set([e]))),v(3,()=>{J(),z(),n.current.value||W(),E.emit();}),()=>{d.current.delete(e),u.current.delete(e),n.current.filtered.items.delete(e);let s=M();v(4,()=>{J(),(s==null?void 0:s.getAttribute("id"))===e&&W(),E.emit();});}),group:e=>(c.current.has(e)||c.current.set(e,new Set),()=>{d.current.delete(e),c.current.delete(e);}),filter:()=>p.current.shouldFilter,label:b||r["aria-label"],getDisablePointerSelection:()=>p.current.disablePointerSelection,listId:$,inputId:_,labelId:q,listInnerRef:I}),[]);function te(e,a){var i,l;let s=(l=(i=p.current)==null?void 0:i.filter)!=null?l:Re;return e?s(e,n.current.search,a):0}function z(){if(!n.current.search||p.current.shouldFilter===false)return;let e=n.current.filtered.items,a=[];n.current.filtered.groups.forEach(i=>{let l=c.current.get(i),g=0;l.forEach(y=>{let h=e.get(y);g=Math.max(h,g);}),a.push([i,g]);});let s=I.current;V().sort((i,l)=>{var h,F;let g=i.getAttribute("id"),y=l.getAttribute("id");return ((h=e.get(y))!=null?h:0)-((F=e.get(g))!=null?F:0)}).forEach(i=>{let l=i.closest(Y);l?l.appendChild(i.parentElement===l?i:i.closest(`${Y} > *`)):s.appendChild(i.parentElement===s?i:i.closest(`${Y} > *`));}),a.sort((i,l)=>l[1]-i[1]).forEach(i=>{var g;let l=(g=I.current)==null?void 0:g.querySelector(`${N}[${T}="${encodeURIComponent(i[0])}"]`);l==null||l.parentElement.appendChild(l);});}function W(){let e=V().find(s=>s.getAttribute("aria-disabled")!=="true"),a=e==null?void 0:e.getAttribute(T);E.setState("value",a||void 0);}function J(){var a,s,i,l;if(!n.current.search||p.current.shouldFilter===false){n.current.filtered.count=u.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let g of u.current){let y=(s=(a=d.current.get(g))==null?void 0:a.value)!=null?s:"",h=(l=(i=d.current.get(g))==null?void 0:i.keywords)!=null?l:[],F=te(y,h);n.current.filtered.items.set(g,F),F>0&&e++;}for(let[g,y]of c.current)for(let h of y)if(n.current.filtered.items.get(h)>0){n.current.filtered.groups.add(g);break}n.current.filtered.count=e;}function ne(){var a,s,i;let e=M();e&&(((a=e.parentElement)==null?void 0:a.firstChild)===e&&((i=(s=e.closest(N))==null?void 0:s.querySelector(be))==null||i.scrollIntoView({block:"nearest"})),e.scrollIntoView({block:"nearest"}));}function M(){var e;return (e=I.current)==null?void 0:e.querySelector(`${le}[aria-selected="true"]`)}function V(){var e;return Array.from(((e=I.current)==null?void 0:e.querySelectorAll(ce))||[])}function X(e){let s=V()[e];s&&E.setState("value",s.getAttribute(T));}function Q(e){var g;let a=M(),s=V(),i=s.findIndex(y=>y===a),l=s[i+e];(g=p.current)!=null&&g.loop&&(l=i+e<0?s[s.length-1]:i+e===s.length?s[0]:s[i+e]),l&&E.setState("value",l.getAttribute(T));}function re(e){let a=M(),s=a==null?void 0:a.closest(N),i;for(;s&&!i;)s=e>0?we(s,N):De(s,N),i=s==null?void 0:s.querySelector(ce);i?E.setState("value",i.getAttribute(T)):Q(e);}let oe=()=>X(V().length-1),ie=e=>{e.preventDefault(),e.metaKey?oe():e.altKey?re(1):Q(1);},se=e=>{e.preventDefault(),e.metaKey?X(0):e.altKey?re(-1):Q(-1);};return React.createElement(Primitive$1.div,{ref:o,tabIndex:-1,...O,"cmdk-root":"",onKeyDown:e=>{var s;(s=O.onKeyDown)==null||s.call(O,e);let a=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||a))switch(e.key){case "n":case "j":{j&&e.ctrlKey&&ie(e);break}case "ArrowDown":{ie(e);break}case "p":case "k":{j&&e.ctrlKey&&se(e);break}case "ArrowUp":{se(e);break}case "Home":{e.preventDefault(),X(0);break}case "End":{e.preventDefault(),oe();break}case "Enter":{e.preventDefault();let i=M();if(i){let l=new Event(Z);i.dispatchEvent(l);}}}}},React.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:Te},b),B(r,e=>React.createElement(de.Provider,{value:E},React.createElement(ue.Provider,{value:U},e))))}),he=React.forwardRef((r,o)=>{var _,I;let n=useId(),u=React.useRef(null),c=React.useContext(fe),d=K(),f=pe(r),p=(I=(_=f.current)==null?void 0:_.forceMount)!=null?I:c==null?void 0:c.forceMount;k$2(()=>{if(!p)return d.item(n,c==null?void 0:c.id)},[p]);let b=ve(n,u,[r.value,r.children,u],r.keywords),m=ee(),R=P(v=>v.value&&v.value===b.current),x=P(v=>p||d.filter()===false?true:v.search?v.filtered.items.get(n)>0:true);React.useEffect(()=>{let v=u.current;if(!(!v||r.disabled))return v.addEventListener(Z,C),()=>v.removeEventListener(Z,C)},[x,r.onSelect,r.disabled]);function C(){var v,E;S(),(E=(v=f.current).onSelect)==null||E.call(v,b.current);}function S(){m.setState("value",b.current,true);}if(!x)return null;let{disabled:A,value:ge,onSelect:j,forceMount:O,keywords:$,...q}=r;return React.createElement(Primitive$1.div,{ref:composeRefs(u,o),...q,id:n,"cmdk-item":"",role:"option","aria-disabled":!!A,"aria-selected":!!R,"data-disabled":!!A,"data-selected":!!R,onPointerMove:A||d.getDisablePointerSelection()?void 0:S,onClick:A?void 0:C},r.children)}),Ee=React.forwardRef((r,o)=>{let{heading:n,children:u,forceMount:c,...d}=r,f=useId(),p=React.useRef(null),b=React.useRef(null),m=useId(),R=K(),x=P(S=>c||R.filter()===false?true:S.search?S.filtered.groups.has(f):true);k$2(()=>R.group(f),[]),ve(f,p,[r.value,r.heading,b]);let C=React.useMemo(()=>({id:f,forceMount:c}),[c]);return React.createElement(Primitive$1.div,{ref:composeRefs(p,o),...d,"cmdk-group":"",role:"presentation",hidden:x?void 0:true},n&&React.createElement("div",{ref:b,"cmdk-group-heading":"","aria-hidden":true,id:m},n),B(r,S=>React.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?m:void 0},React.createElement(fe.Provider,{value:C},S))))}),ye=React.forwardRef((r,o)=>{let{alwaysRender:n,...u}=r,c=React.useRef(null),d=P(f=>!f.search);return !n&&!d?null:React.createElement(Primitive$1.div,{ref:composeRefs(c,o),...u,"cmdk-separator":"",role:"separator"})}),Se=React.forwardRef((r,o)=>{let{onValueChange:n,...u}=r,c=r.value!=null,d=ee(),f=P(m=>m.search),p=P(m=>m.selectedItemId),b=K();return React.useEffect(()=>{r.value!=null&&d.setState("search",r.value);},[r.value]),React.createElement(Primitive$1.input,{ref:o,...u,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:false,"aria-autocomplete":"list",role:"combobox","aria-expanded":true,"aria-controls":b.listId,"aria-labelledby":b.labelId,"aria-activedescendant":p,id:b.inputId,type:"text",value:c?r.value:f,onChange:m=>{c||d.setState("search",m.target.value),n==null||n(m.target.value);}})}),Ce=React.forwardRef((r,o)=>{let{children:n,label:u="Suggestions",...c}=r,d=React.useRef(null),f=React.useRef(null),p=P(m=>m.selectedItemId),b=K();return React.useEffect(()=>{if(f.current&&d.current){let m=f.current,R=d.current,x,C=new ResizeObserver(()=>{x=requestAnimationFrame(()=>{let S=m.offsetHeight;R.style.setProperty("--cmdk-list-height",S.toFixed(1)+"px");});});return C.observe(m),()=>{cancelAnimationFrame(x),C.unobserve(m);}}},[]),React.createElement(Primitive$1.div,{ref:composeRefs(d,o),...c,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":p,"aria-label":u,id:b.listId},B(r,m=>React.createElement("div",{ref:composeRefs(f,b.listInnerRef),"cmdk-list-sizer":""},m)))}),xe=React.forwardRef((r,o)=>{let{open:n,onOpenChange:u,overlayClassName:c,contentClassName:d,container:f,...p}=r;return React.createElement(Root$1,{open:n,onOpenChange:u},React.createElement(Portal,{container:f},React.createElement(Overlay,{"cmdk-overlay":"",className:c}),React.createElement(Content$1,{"aria-label":r.label,"cmdk-dialog":"",className:d},React.createElement(me,{ref:o,...p}))))}),Ie=React.forwardRef((r,o)=>P(u=>u.filtered.count===0)?React.createElement(Primitive$1.div,{ref:o,...r,"cmdk-empty":"",role:"presentation"}):null),Pe=React.forwardRef((r,o)=>{let{progress:n,children:u,label:c="Loading...",...d}=r;return React.createElement(Primitive$1.div,{ref:o,...d,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":c},B(r,f=>React.createElement("div",{"aria-hidden":true},f)))}),_e=Object.assign(me,{List:Ce,Item:he,Input:Se,Group:Ee,Separator:ye,Dialog:xe,Empty:Ie,Loading:Pe});function we(r,o){let n=r.nextElementSibling;for(;n;){if(n.matches(o))return n;n=n.nextElementSibling;}}function De(r,o){let n=r.previousElementSibling;for(;n;){if(n.matches(o))return n;n=n.previousElementSibling;}}function pe(r){let o=React.useRef(r);return k$2(()=>{o.current=r;}),o}var k$2=typeof window=="undefined"?React.useEffect:React.useLayoutEffect;function L(r){let o=React.useRef();return o.current===void 0&&(o.current=r()),o}function P(r){let o=ee(),n=()=>r(o.snapshot());return React.useSyncExternalStore(o.subscribe,n,n)}function ve(r,o,n,u=[]){let c=React.useRef(),d=K();return k$2(()=>{var b;let f=(()=>{var m;for(let R of n){if(typeof R=="string")return R.trim();if(typeof R=="object"&&"current"in R)return R.current?(m=R.current.textContent)==null?void 0:m.trim():c.current}})(),p=u.map(m=>m.trim());d.value(r,f,p),(b=o.current)==null||b.setAttribute(T,f),c.current=f;}),c}var ke=()=>{let[r,o]=React.useState(),n=L(()=>new Map);return k$2(()=>{n.current.forEach(u=>u()),n.current=new Map;},[r]),(u,c)=>{n.current.set(u,c),o({});}};function Me(r){let o=r.type;return typeof o=="function"?o(r.props):"render"in o?o.render(r.props):r}function B({asChild:r,children:o},n){return r&&React.isValidElement(o)?React.cloneElement(Me(o),{ref:o.ref},n(o.props.children)):n(o)}var Te={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};
21169
21496
 
21170
21497
  /**
21171
21498
  * @license lucide-react v0.479.0 - ISC
@@ -30016,7 +30343,7 @@ var frRawCountries = [
30016
30343
  id: 704,
30017
30344
  alpha2: "vn",
30018
30345
  alpha3: "vnm",
30019
- name: "Viêt Nam"
30346
+ name: "Vietnam"
30020
30347
  },
30021
30348
  {
30022
30349
  id: 887,
@@ -36108,7 +36435,7 @@ function CustomerForm({ initialData, onSubmit, clientProxy, clientSecret, latitu
36108
36435
  phone: "",
36109
36436
  },
36110
36437
  });
36111
- return (jsx(Form, Object.assign({}, form, { children: jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "grid gap-5 md:grid-cols-2", children: [jsx("div", { className: "md:col-span-2", children: jsx("h2", { children: t("CheckoutEmbed.CustomerForm.title") }) }), jsx(InputGroup, { className: "md:col-span-2", name: "email", label: t("CheckoutEmbed.CustomerForm.email"), type: "email", autoComplete: "email" }), jsx(InputGroup, { name: "firstName", label: t("CheckoutEmbed.CustomerForm.firstName"), autoComplete: "given-name" }), jsx(InputGroup, { name: "lastName", label: t("CheckoutEmbed.CustomerForm.lastName"), autoComplete: "family-name" }), jsx(AddressInput, { className: "md:col-span-2", proxy: clientProxy, clientSecret: clientSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }), jsx(InputGroup, { name: "phone", label: t("CheckoutEmbed.CustomerForm.phone"), type: "tel", autoComplete: "tel" }), jsx("div", { className: "flex justify-end pt-2 md:col-span-2", children: jsx(SubmitButton, { isValid: form.formState.isValid, isSubmitting: form.formState.isSubmitting, children: t("CheckoutEmbed.CustomerForm.button") }) })] }) })));
36438
+ return (jsx(Form, Object.assign({}, form, { children: jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "grid gap-5 md:grid-cols-2", children: [jsx("div", { className: "md:col-span-2", children: jsx("h2", { children: t("CheckoutEmbed.CustomerForm.title") }) }), jsx(InputGroup, { className: "md:col-span-2", name: "email", label: t("CheckoutEmbed.CustomerForm.email"), type: "email", autoComplete: "email" }), jsx(InputGroup, { name: "firstName", label: t("CheckoutEmbed.CustomerForm.firstName"), autoComplete: "given-name" }), jsx(InputGroup, { name: "lastName", label: t("CheckoutEmbed.CustomerForm.lastName"), autoComplete: "family-name" }), jsx(AddressInput, { className: "md:col-span-2", proxy: clientProxy, clientSecret: clientSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }), jsx(InputGroup, { name: "phone", label: t("CheckoutEmbed.CustomerForm.phone"), type: "tel", autoComplete: "tel" }), jsx("div", { className: "flex justify-end pt-2 md:col-span-2", children: jsx(SubmitButton, { isValid: form.formState.isDirty || form.formState.isValid, isSubmitting: form.formState.isSubmitting, children: t("CheckoutEmbed.CustomerForm.button") }) })] }) })));
36112
36439
  }
36113
36440
 
36114
36441
  var reactStripe_umd$1 = {exports: {}};
@@ -36120,10 +36447,10 @@ var hasRequiredReactStripe_umd;
36120
36447
  function requireReactStripe_umd () {
36121
36448
  if (hasRequiredReactStripe_umd) return reactStripe_umd$1.exports;
36122
36449
  hasRequiredReactStripe_umd = 1;
36123
- (function (module, exports) {
36450
+ (function (module, exports$1) {
36124
36451
  (function (global, factory) {
36125
- factory(exports, React__default) ;
36126
- })(reactStripe_umd, (function (exports, React) {
36452
+ factory(exports$1, React__default) ;
36453
+ })(reactStripe_umd, (function (exports$1, React) {
36127
36454
  function ownKeys(object, enumerableOnly) {
36128
36455
  var keys = Object.keys(object);
36129
36456
 
@@ -37392,35 +37719,35 @@ function requireReactStripe_umd () {
37392
37719
 
37393
37720
  var TaxIdElement = createElementComponent('taxId', isServer);
37394
37721
 
37395
- exports.AddressElement = AddressElement;
37396
- exports.AffirmMessageElement = AffirmMessageElement;
37397
- exports.AfterpayClearpayMessageElement = AfterpayClearpayMessageElement;
37398
- exports.AuBankAccountElement = AuBankAccountElement;
37399
- exports.CardCvcElement = CardCvcElement;
37400
- exports.CardElement = CardElement;
37401
- exports.CardExpiryElement = CardExpiryElement;
37402
- exports.CardNumberElement = CardNumberElement;
37403
- exports.CheckoutProvider = CheckoutProvider;
37404
- exports.CurrencySelectorElement = CurrencySelectorElement;
37405
- exports.Elements = Elements;
37406
- exports.ElementsConsumer = ElementsConsumer;
37407
- exports.EmbeddedCheckout = EmbeddedCheckout;
37408
- exports.EmbeddedCheckoutProvider = EmbeddedCheckoutProvider;
37409
- exports.EpsBankElement = EpsBankElement;
37410
- exports.ExpressCheckoutElement = ExpressCheckoutElement;
37411
- exports.FpxBankElement = FpxBankElement;
37412
- exports.IbanElement = IbanElement;
37413
- exports.IdealBankElement = IdealBankElement;
37414
- exports.LinkAuthenticationElement = LinkAuthenticationElement;
37415
- exports.P24BankElement = P24BankElement;
37416
- exports.PaymentElement = PaymentElement;
37417
- exports.PaymentMethodMessagingElement = PaymentMethodMessagingElement;
37418
- exports.PaymentRequestButtonElement = PaymentRequestButtonElement;
37419
- exports.ShippingAddressElement = ShippingAddressElement;
37420
- exports.TaxIdElement = TaxIdElement;
37421
- exports.useCheckout = useCheckout;
37422
- exports.useElements = useElements;
37423
- exports.useStripe = useStripe;
37722
+ exports$1.AddressElement = AddressElement;
37723
+ exports$1.AffirmMessageElement = AffirmMessageElement;
37724
+ exports$1.AfterpayClearpayMessageElement = AfterpayClearpayMessageElement;
37725
+ exports$1.AuBankAccountElement = AuBankAccountElement;
37726
+ exports$1.CardCvcElement = CardCvcElement;
37727
+ exports$1.CardElement = CardElement;
37728
+ exports$1.CardExpiryElement = CardExpiryElement;
37729
+ exports$1.CardNumberElement = CardNumberElement;
37730
+ exports$1.CheckoutProvider = CheckoutProvider;
37731
+ exports$1.CurrencySelectorElement = CurrencySelectorElement;
37732
+ exports$1.Elements = Elements;
37733
+ exports$1.ElementsConsumer = ElementsConsumer;
37734
+ exports$1.EmbeddedCheckout = EmbeddedCheckout;
37735
+ exports$1.EmbeddedCheckoutProvider = EmbeddedCheckoutProvider;
37736
+ exports$1.EpsBankElement = EpsBankElement;
37737
+ exports$1.ExpressCheckoutElement = ExpressCheckoutElement;
37738
+ exports$1.FpxBankElement = FpxBankElement;
37739
+ exports$1.IbanElement = IbanElement;
37740
+ exports$1.IdealBankElement = IdealBankElement;
37741
+ exports$1.LinkAuthenticationElement = LinkAuthenticationElement;
37742
+ exports$1.P24BankElement = P24BankElement;
37743
+ exports$1.PaymentElement = PaymentElement;
37744
+ exports$1.PaymentMethodMessagingElement = PaymentMethodMessagingElement;
37745
+ exports$1.PaymentRequestButtonElement = PaymentRequestButtonElement;
37746
+ exports$1.ShippingAddressElement = ShippingAddressElement;
37747
+ exports$1.TaxIdElement = TaxIdElement;
37748
+ exports$1.useCheckout = useCheckout;
37749
+ exports$1.useElements = useElements;
37750
+ exports$1.useStripe = useStripe;
37424
37751
 
37425
37752
  }));
37426
37753
  } (reactStripe_umd$1, reactStripe_umd$1.exports));
@@ -37623,7 +37950,7 @@ const useCheckout = create((set) => ({
37623
37950
  setIsSubmitting: (isSubmitting) => set({ isSubmitting }),
37624
37951
  }));
37625
37952
 
37626
- const CheckoutForm$1 = ({ onSuccess, onError, children, setSubmitting, }) => {
37953
+ const CheckoutForm$2 = ({ onSuccess, onError, children, setSubmitting, }) => {
37627
37954
  const stripe = reactStripe_umdExports.useStripe();
37628
37955
  const elements = reactStripe_umdExports.useElements();
37629
37956
  const { setIsSubmitting } = useCheckout();
@@ -37654,9 +37981,9 @@ const CheckoutForm$1 = ({ onSuccess, onError, children, setSubmitting, }) => {
37654
37981
  });
37655
37982
  return (jsxs("form", { className: "w-full pb-40 sm:pb-0", onSubmit: handleSubmit, children: [jsx(reactStripe_umdExports.PaymentElement, {}), errorMessage && (jsx("p", { className: "text-destructive -mb-2 mt-2 text-sm", children: errorMessage })), children] }));
37656
37983
  };
37657
- var CheckoutForm$2 = memo(CheckoutForm$1);
37984
+ var CheckoutForm$1 = memo(CheckoutForm$2);
37658
37985
 
37659
- function PaymentElement({ paymentSecret, publicKey, checkoutAppearance, locale, fonts, onSuccess, onError, children, setSubmitting, }) {
37986
+ function PaymentElement$1({ paymentSecret, publicKey, checkoutAppearance, locale, fonts, onSuccess, onError, children, setSubmitting, }) {
37660
37987
  const stripePromise = loadStripe(publicKey !== null && publicKey !== void 0 ? publicKey : "");
37661
37988
  const options = {
37662
37989
  locale: locale !== null && locale !== void 0 ? locale : "en",
@@ -37664,9 +37991,9 @@ function PaymentElement({ paymentSecret, publicKey, checkoutAppearance, locale,
37664
37991
  clientSecret: paymentSecret,
37665
37992
  fonts: fonts,
37666
37993
  };
37667
- return (jsx(reactStripe_umdExports.Elements, { stripe: stripePromise, options: options, children: jsx(CheckoutForm$2, { onSuccess: onSuccess, onError: onError, setSubmitting: setSubmitting, children: children }) }));
37994
+ return (jsx(reactStripe_umdExports.Elements, { stripe: stripePromise, options: options, children: jsx(CheckoutForm$1, { onSuccess: onSuccess, onError: onError, setSubmitting: setSubmitting, children: children }) }));
37668
37995
  }
37669
- var PaymentElement$1 = memo(PaymentElement);
37996
+ var PaymentElement = memo(PaymentElement$1);
37670
37997
 
37671
37998
  const parseNumber = (color, len) => {
37672
37999
  if (typeof color !== 'number') return;
@@ -42328,7 +42655,7 @@ const convertCheckoutAppearanceToStripeAppearance = (appearance, fonts) => {
42328
42655
  function PaymentForm({ paymentSecret, onSuccess, onError, onBack, onDoubleBack, contactEmail, shippingFormData, address, checkoutAppearance, fonts, locale, publicKey, paymentComponentKey, }) {
42329
42656
  const [isSubmitting, setIsSubmitting] = useState(false);
42330
42657
  const { t } = useTranslation();
42331
- return (jsxs("div", { className: "space-y-6", children: [jsxs("div", { children: [jsx("h2", { className: "mb-2", children: t("CheckoutEmbed.Payment.title") }), jsx("p", { className: "text-muted-foreground text-sm", children: t("CheckoutEmbed.Payment.description") })] }), jsxs("div", { className: "space-y-2", children: [jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("p", { children: [jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.contact") }), " ", jsx("span", { className: "text-muted-foreground", children: contactEmail })] }), jsx(Button, { variant: "link", size: "link", onClick: onDoubleBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("p", { children: [jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.address") }), " ", jsx("span", { className: "text-muted-foreground", children: address })] }), jsx(Button, { variant: "link", size: "link", onClick: onDoubleBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("div", { className: "flex gap-1", children: [jsx("p", { className: "font-medium", children: t("CheckoutEmbed.Shipping.shipping") }), " ", jsx("div", { className: "text-muted-foreground flex flex-col gap-1", children: Object.entries(shippingFormData).map(([id, shipmentFormData]) => (jsxs("p", { children: [shipmentFormData.displayName, " \u00B7", " ", shipmentFormData.priceInCents] }, id))) })] }), jsx(Button, { variant: "link", size: "link", onClick: onBack, children: t("CheckoutEmbed.Shipping.change") })] })] }), jsx("div", { className: "mt-8", children: paymentSecret && (jsx(PaymentElement$1, { fonts: fonts, checkoutAppearance: convertCheckoutAppearanceToStripeAppearance(checkoutAppearance, fonts), locale: locale, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, setSubmitting: setIsSubmitting, publicKey: publicKey, children: jsx("div", { className: "fixed bottom-0 left-0 right-0 z-50 mt-8 px-4 sm:static sm:px-0", children: jsxs("div", { className: "bg-background flex flex-col-reverse items-center justify-between gap-2 pb-4 sm:flex-row sm:bg-transparent sm:pb-0", children: [jsxs(Button, { className: "w-full sm:w-fit", type: "button", variant: "ghost", onClick: onBack, children: [jsx(ChevronLeft, {}), t("CheckoutEmbed.Payment.back")] }), jsx(SubmitButton, { className: "w-full max-sm:h-[52px] sm:w-fit", isValid: true, isSubmitting: isSubmitting, children: t("CheckoutEmbed.Payment.button") })] }) }) }, paymentComponentKey)) })] }));
42658
+ return (jsxs("div", { className: "space-y-6", children: [jsxs("div", { children: [jsx("h2", { className: "mb-2", children: t("CheckoutEmbed.Payment.title") }), jsx("p", { className: "text-muted-foreground text-sm", children: t("CheckoutEmbed.Payment.description") })] }), jsxs("div", { className: "space-y-2", children: [jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("p", { children: [jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.contact") }), " ", jsx("span", { className: "text-muted-foreground", children: contactEmail })] }), jsx(Button, { variant: "link", size: "link", onClick: onDoubleBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("p", { children: [jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.address") }), " ", jsx("span", { className: "text-muted-foreground", children: address })] }), jsx(Button, { variant: "link", size: "link", onClick: onDoubleBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("div", { className: "flex gap-1", children: [jsx("p", { className: "font-medium", children: t("CheckoutEmbed.Shipping.shipping") }), " ", jsx("div", { className: "text-muted-foreground flex flex-col gap-1", children: Object.entries(shippingFormData).map(([id, shipmentFormData]) => (jsxs("p", { children: [shipmentFormData.displayName, " \u00B7", " ", shipmentFormData.priceInCents] }, id))) })] }), jsx(Button, { variant: "link", size: "link", onClick: onBack, children: t("CheckoutEmbed.Shipping.change") })] })] }), jsx("div", { className: "mt-8", children: paymentSecret && (jsx(PaymentElement, { fonts: fonts, checkoutAppearance: convertCheckoutAppearanceToStripeAppearance(checkoutAppearance, fonts), locale: locale, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, setSubmitting: setIsSubmitting, publicKey: publicKey, children: jsx("div", { className: "fixed bottom-0 left-0 right-0 z-50 mt-8 px-4 sm:static sm:px-0", children: jsxs("div", { className: "bg-background flex flex-col-reverse items-center justify-between gap-2 pb-4 sm:flex-row sm:bg-transparent sm:pb-0", children: [jsxs(Button, { className: "w-full sm:w-fit", type: "button", variant: "ghost", onClick: onBack, children: [jsx(ChevronLeft, {}), t("CheckoutEmbed.Payment.back")] }), jsx(SubmitButton, { className: "w-full max-sm:h-[52px] sm:w-fit", isValid: true, isSubmitting: isSubmitting, children: t("CheckoutEmbed.Payment.button") })] }) }) }, paymentComponentKey)) })] }));
42332
42659
  }
42333
42660
 
42334
42661
  function Skeleton(_a) {
@@ -42383,7 +42710,7 @@ function ShippingOptionWrapper({ rate, children, onPickupPointSelected, locale,
42383
42710
  return jsx(Fragment, { children: children });
42384
42711
  }
42385
42712
 
42386
- function ShipmentsForm({ shippingRates, initialData, onSubmit, onBack, contactEmail, shippingAddress, currency, exchangeRate, locale, countryCode, setFormData, formData, shipments, }) {
42713
+ function ShipmentsShippingMethodForm({ shippingRates, initialData, onSubmit, onBack, contactEmail, shippingAddress, currency, exchangeRate, locale, countryCode, setFormData, formData, shipments, }) {
42387
42714
  var _a;
42388
42715
  const { t } = useTranslation();
42389
42716
  const form = useForm({
@@ -42401,53 +42728,55 @@ function ShipmentsForm({ shippingRates, initialData, onSubmit, onBack, contactEm
42401
42728
  ])),
42402
42729
  });
42403
42730
  const isButtonEnabled = Object.values(form.getValues()).every((value) => { var _a; return ((_a = value.rateId) === null || _a === void 0 ? void 0 : _a.length) > 0; });
42404
- return (jsxs("div", { className: "space-y-6", children: [jsx("h2", { children: t("CheckoutEmbed.Shipping.title") }), jsxs("div", { className: "space-y-2 pb-2", children: [jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("p", { children: [jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.contact") }), " ", jsx("span", { className: "text-muted-foreground", children: contactEmail })] }), jsx(Button, { variant: "link", size: "link", onClick: onBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("p", { children: [jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.address") }), " ", jsx("span", { className: "text-muted-foreground", children: shippingAddress })] }), jsx(Button, { variant: "link", size: "link", onClick: onBack, children: t("CheckoutEmbed.Shipping.change") })] })] }), jsx(Form, Object.assign({}, form, { children: jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "space-y-4", children: [shipments.map((shipment, index) => {
42405
- var _a;
42406
- return (jsx(SingleShipmentSection, { shipment: shipment, shippingRates: (_a = shippingRates[shipment.id]) !== null && _a !== void 0 ? _a : [], form: form, setFormData: setFormData, formData: formData, currency: currency, exchangeRate: exchangeRate, locale: locale, countryCode: countryCode, multipleShipments: shipments.length > 1, index: index }, shipment.id));
42407
- }), jsx(FormMessage, { children: (_a = form.formState.errors.root) === null || _a === void 0 ? void 0 : _a.message }), jsxs("div", { className: "flex items-center justify-between pt-4", children: [jsxs(Button, { type: "button", variant: "ghost", onClick: onBack, children: [jsx(ChevronLeft, {}), t("CheckoutEmbed.Shipping.back")] }), jsx(SubmitButton, { isSubmitting: form.formState.isSubmitting, isValid: isButtonEnabled, children: t("CheckoutEmbed.Shipping.button") })] })] }) }))] }));
42731
+ const shippingRatesAreLoadingOrDefined = shippingRates === undefined || Object.keys(shippingRates).length > 0;
42732
+ return (jsxs("div", { className: "space-y-6", children: [jsx("h2", { children: t("CheckoutEmbed.Shipping.title") }), jsxs("div", { className: "space-y-2 pb-2", children: [jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("p", { children: [jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.contact") }), " ", jsx("span", { className: "text-muted-foreground", children: contactEmail })] }), jsx(Button, { variant: "link", size: "link", onClick: onBack, children: t("CheckoutEmbed.Shipping.change") })] }), jsxs("div", { className: "flex items-center justify-between text-sm", children: [jsxs("p", { children: [jsx("span", { className: "font-medium", children: t("CheckoutEmbed.Shipping.address") }), " ", jsx("span", { className: "text-muted-foreground", children: shippingAddress })] }), jsx(Button, { variant: "link", size: "link", onClick: onBack, children: t("CheckoutEmbed.Shipping.change") })] })] }), jsx(Form, Object.assign({}, form, { children: jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "space-y-4", children: [!shippingRatesAreLoadingOrDefined && (jsx("p", { className: "text-destructive py-2 text-base font-medium", children: t("CheckoutEmbed.Shipping.errorNoShippingRates") })), shippingRatesAreLoadingOrDefined &&
42733
+ shipments.map((shipment, index) => {
42734
+ var _a;
42735
+ return (jsx(SingleShipmentSection, { shipment: shipment, shippingRates: (_a = shippingRates === null || shippingRates === void 0 ? void 0 : shippingRates[shipment.id]) !== null && _a !== void 0 ? _a : [], form: form, setFormData: setFormData, formData: formData, currency: currency, exchangeRate: exchangeRate, locale: locale, countryCode: countryCode, multipleShipments: shipments.length > 1, index: index }, shipment.id));
42736
+ }), jsx(FormMessage, { children: (_a = form.formState.errors.root) === null || _a === void 0 ? void 0 : _a.message }), jsxs("div", { className: "flex items-center justify-between pt-4", children: [jsxs(Button, { type: "button", variant: "ghost", onClick: onBack, children: [jsx(ChevronLeft, {}), t("CheckoutEmbed.Shipping.back")] }), jsx(SubmitButton, { isSubmitting: form.formState.isSubmitting, isValid: isButtonEnabled, children: t("CheckoutEmbed.Shipping.button") })] })] }) }))] }));
42408
42737
  }
42409
42738
  const SingleShipmentSection = ({ shippingRates, form, currency, exchangeRate, locale, countryCode, setFormData, formData, multipleShipments, shipment, index, }) => {
42410
42739
  const { t } = useTranslation();
42411
42740
  const shipmentId = shipment.id;
42412
42741
  const currentRateId = form.watch(`${shipmentId}.rateId`);
42413
42742
  // TODO: construct the headline
42414
- return (jsxs("div", { children: [multipleShipments && (jsxs("h3", { className: "text-lg font-medium", children: [t("CheckoutEmbed.Shipping.Shipment.title"), index + 1] })), shippingRates.length === 0 &&
42415
- Array.from({ length: 3 }).map((_, index) => (jsx(ShippingRateLoading, {}, index))), shippingRates.map((rate) => {
42416
- var _a, _b;
42417
- const pickupPointDisplayName = form.watch(`${shipmentId}.pickupPointDisplayName`);
42418
- const intPrice = Math.ceil(Number(rate.priceInCents));
42419
- const displayPrice = formatPrice(intPrice, currency, exchangeRate);
42420
- const isFixedRate = rate.type === "FIXED";
42421
- const isAutoRate = rate.type === "CUSTOM_SHIPPING_VENDOR" ||
42422
- rate.type === "PLATFORM_CARRIER";
42423
- const isZasilkovna = isAutoRate && rate.providerId === "zasilkovna";
42424
- const name = isFixedRate
42425
- ? rate.name
42426
- : ((_a = t(`CheckoutEmbed.Shipping.Shipment.perIdTitles.${rate.id}`)) !== null && _a !== void 0 ? _a : rate.id);
42427
- const fallbackDescription = t(`CheckoutEmbed.Shipping.Shipment.perIdDescriptions.fallback`);
42428
- const description = (_b = (isFixedRate
42429
- ? rate.description
42430
- : t(`CheckoutEmbed.Shipping.Shipment.perIdDescriptions.${rate.id}`))) !== null && _b !== void 0 ? _b : fallbackDescription;
42431
- return (jsx(ShippingOptionWrapper, { rate: rate, onPickupPointSelected: (pickupPointId, pickupPointName) => {
42432
- const newData = {
42433
- rateId: rate.id,
42434
- providerId: isAutoRate ? rate.providerId : undefined,
42435
- priceInCents: intPrice,
42436
- displayName: name,
42437
- pickupPointId: isZasilkovna ? pickupPointId : "",
42438
- pickupPointDisplayName: isZasilkovna ? pickupPointName : "",
42439
- };
42440
- form.setValue(`${shipmentId}.rateId`, newData.rateId);
42441
- form.setValue(`${shipmentId}.providerId`, newData.providerId);
42442
- form.setValue(`${shipmentId}.displayName`, newData.displayName);
42443
- form.setValue(`${shipmentId}.priceInCents`, newData.priceInCents);
42444
- form.setValue(`${shipmentId}.pickupPointId`, newData.pickupPointId);
42445
- form.setValue(`${shipmentId}.pickupPointDisplayName`, newData.pickupPointDisplayName);
42446
- setFormData(Object.assign(Object.assign({}, formData), { shipping: Object.assign(Object.assign({}, formData.shipping), { [shipmentId]: newData }) }));
42447
- }, locale: locale, countryCode: countryCode, children: jsxs("div", { className: clsx("bg-background cursor-pointer rounded-md border p-4", {
42448
- "bg-muted border-primary": currentRateId === rate.id,
42449
- }), children: [jsxs("div", { className: "flex w-full items-center justify-between", children: [jsx("p", { children: name }), jsx("p", { children: displayPrice })] }), jsx("p", { className: "text-muted-foreground text-sm", children: description }), pickupPointDisplayName && (jsxs(Fragment, { children: [jsx("hr", { className: "my-2" }), jsxs("p", { className: "text-muted-foreground text-sm", children: [t("CheckoutEmbed.Shipping.description.shippedTo"), " ", jsx("span", { className: "text-foreground", children: pickupPointDisplayName })] })] }))] }) }, rate.id));
42450
- })] }));
42743
+ return (jsxs("div", { children: [multipleShipments && (jsxs("h3", { className: "text-lg font-medium", children: [t("CheckoutEmbed.Shipping.Shipment.title"), index + 1] })), jsxs("div", { className: "space-y-2", children: [shippingRates.length === 0 &&
42744
+ Array.from({ length: 3 }).map((_, index) => (jsx(ShippingRateLoading, {}, index))), shippingRates.map((rate) => {
42745
+ var _a, _b;
42746
+ const pickupPointDisplayName = form.watch(`${shipmentId}.pickupPointDisplayName`);
42747
+ const intPrice = Math.ceil(Number(rate.priceInCents));
42748
+ const displayPrice = formatPrice(intPrice, currency, exchangeRate);
42749
+ const isFixedRate = rate.type === "FIXED";
42750
+ const isAutoRate = rate.type === "CUSTOM_SHIPPING_VENDOR" ||
42751
+ rate.type === "PLATFORM_CARRIER";
42752
+ const isZasilkovna = isAutoRate && rate.providerId === "zasilkovna";
42753
+ const name = isFixedRate
42754
+ ? rate.name
42755
+ : ((_a = t(`CheckoutEmbed.Shipping.Shipment.perIdTitles.${rate.id}`)) !== null && _a !== void 0 ? _a : rate.id);
42756
+ const fallbackDescription = t(`CheckoutEmbed.Shipping.Shipment.perIdDescriptions.fallback`);
42757
+ const description = (_b = (isFixedRate
42758
+ ? rate.description
42759
+ : t(`CheckoutEmbed.Shipping.Shipment.perIdDescriptions.${rate.id}`))) !== null && _b !== void 0 ? _b : fallbackDescription;
42760
+ return (jsx(ShippingOptionWrapper, { rate: rate, onPickupPointSelected: (pickupPointId, pickupPointName) => {
42761
+ const newData = {
42762
+ rateId: rate.id,
42763
+ providerId: isAutoRate ? rate.providerId : undefined,
42764
+ priceInCents: intPrice,
42765
+ displayName: name,
42766
+ pickupPointId: isZasilkovna ? pickupPointId : "",
42767
+ pickupPointDisplayName: isZasilkovna ? pickupPointName : "",
42768
+ };
42769
+ form.setValue(`${shipmentId}.rateId`, newData.rateId);
42770
+ form.setValue(`${shipmentId}.providerId`, newData.providerId);
42771
+ form.setValue(`${shipmentId}.displayName`, newData.displayName);
42772
+ form.setValue(`${shipmentId}.priceInCents`, newData.priceInCents);
42773
+ form.setValue(`${shipmentId}.pickupPointId`, newData.pickupPointId);
42774
+ form.setValue(`${shipmentId}.pickupPointDisplayName`, newData.pickupPointDisplayName);
42775
+ setFormData(Object.assign(Object.assign({}, formData), { shipping: Object.assign(Object.assign({}, formData.shipping), { [shipmentId]: newData }) }));
42776
+ }, locale: locale, countryCode: countryCode, children: jsxs("div", { className: clsx("bg-background cursor-pointer rounded-md border p-4", {
42777
+ "bg-muted border-primary": currentRateId === rate.id,
42778
+ }), children: [jsxs("div", { className: "flex w-full items-center justify-between", children: [jsx("p", { children: name }), jsx("p", { children: displayPrice })] }), jsx("p", { className: "text-muted-foreground text-sm", children: description }), pickupPointDisplayName && (jsxs(Fragment, { children: [jsx("hr", { className: "my-2" }), jsxs("p", { className: "text-muted-foreground text-sm", children: [t("CheckoutEmbed.Shipping.description.shippedTo"), " ", jsx("span", { className: "text-foreground", children: pickupPointDisplayName })] })] }))] }) }, rate.id));
42779
+ })] })] }));
42451
42780
  };
42452
42781
  function ShippingRateLoading() {
42453
42782
  return (jsxs("div", { className: clsx("bg-background grid cursor-pointer gap-[10px] rounded-md border p-4"), children: [jsxs("div", { className: "flex w-full items-center justify-between", children: [jsx(Skeleton, { className: "h-5 w-12" }), jsx(Skeleton, { className: "h-5 w-16" })] }), jsx(Skeleton, { className: "h-3.5 w-40" })] }));
@@ -42468,7 +42797,7 @@ const resetFormStore = (formData) => {
42468
42797
 
42469
42798
  function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl, clientSecret, customer, currency, checkoutAppearance, fonts, locale, setShippingCost, exchangeRate, paymentSecret, publicKey, paymentComponentKey, clientProxy, latitude, longitude, currentAlpha3CountryCode, shipments, }) {
42470
42799
  const { formData, setFormData, step, setStep, checkoutId: storedCheckoutId, setCheckoutId, } = useFormStore();
42471
- const [shippingRates, setShippingRates] = useState({});
42800
+ const [shippingRates, setShippingRates] = useState(undefined);
42472
42801
  const validateStep = useCallback(() => {
42473
42802
  if (step === "customer")
42474
42803
  return;
@@ -42559,11 +42888,12 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
42559
42888
  useEffect(() => {
42560
42889
  if (step !== "shipping")
42561
42890
  return;
42562
- if (Object.keys(shippingRates).length > 0)
42891
+ if (Object.keys(shippingRates !== null && shippingRates !== void 0 ? shippingRates : {}).length > 0)
42563
42892
  return;
42564
42893
  const getShippingRates = () => __awaiter(this, void 0, void 0, function* () {
42565
42894
  try {
42566
42895
  const shippingRates = yield storeClient.getCheckoutShippingRates(clientSecret, checkoutId);
42896
+ console.log("FETCHED SHIPPING RATES: ", shippingRates);
42567
42897
  setShippingRates(shippingRates);
42568
42898
  }
42569
42899
  catch (error) {
@@ -42576,6 +42906,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
42576
42906
  }, [step, clientSecret, checkoutId]);
42577
42907
  // Handle address form submission
42578
42908
  const handleCustomerSubmit = (data) => __awaiter(this, void 0, void 0, function* () {
42909
+ var _a, _b, _c, _d, _e, _f, _g, _h;
42579
42910
  setFormData(Object.assign(Object.assign({}, formData), { customer: data }));
42580
42911
  let newCustomerId = formData.customerId;
42581
42912
  if (!newCustomerId) {
@@ -42584,7 +42915,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
42584
42915
  phone: data.phone,
42585
42916
  firstName: data.firstName,
42586
42917
  lastName: data.lastName,
42587
- address: Object.assign(Object.assign({}, data.address), { phone: data.phone, name: data.firstName + " " + data.lastName }),
42918
+ address: Object.assign(Object.assign({}, data.address), { company: (_a = data.address.company) !== null && _a !== void 0 ? _a : null, line2: (_b = data.address.line2) !== null && _b !== void 0 ? _b : null, province: (_c = data.address.province) !== null && _c !== void 0 ? _c : null, provinceCode: (_d = data.address.provinceCode) !== null && _d !== void 0 ? _d : null, phone: data.phone, name: data.firstName + " " + data.lastName }),
42588
42919
  });
42589
42920
  yield storeClient.updateCheckout(clientSecret, checkoutId, {
42590
42921
  customerId: newCustomer.id,
@@ -42597,9 +42928,10 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
42597
42928
  phone: data.phone,
42598
42929
  firstName: data.firstName,
42599
42930
  lastName: data.lastName,
42600
- address: Object.assign(Object.assign({}, data.address), { phone: data.phone, name: data.firstName + " " + data.lastName }),
42931
+ address: Object.assign(Object.assign({}, data.address), { company: (_e = data.address.company) !== null && _e !== void 0 ? _e : null, line2: (_f = data.address.line2) !== null && _f !== void 0 ? _f : null, province: (_g = data.address.province) !== null && _g !== void 0 ? _g : null, provinceCode: (_h = data.address.provinceCode) !== null && _h !== void 0 ? _h : null, phone: data.phone, name: data.firstName + " " + data.lastName }),
42601
42932
  });
42602
42933
  }
42934
+ console.log("FETCHING SHIPPING RATES");
42603
42935
  const shippingRates = yield storeClient.getCheckoutShippingRates(clientSecret, checkoutId);
42604
42936
  setShippingRates(shippingRates);
42605
42937
  setFormData(Object.assign(Object.assign({}, formData), { customer: data, customerId: newCustomerId }));
@@ -42642,7 +42974,7 @@ function CheckoutForm({ storeClient, checkoutId, onSuccess, onError, cancelUrl,
42642
42974
  return (jsx(PaymentForm, { paymentComponentKey: paymentComponentKey, locale: locale, fonts: fonts, checkoutAppearance: checkoutAppearance, paymentSecret: paymentSecret, onSuccess: onSuccess, onError: onError, onBack: handleBack, onDoubleBack: handleDoubleBack, contactEmail: formData.customer.email, address: formatAddress(formData.customer.address), shippingFormData: formData.shipping, publicKey: publicKey }));
42643
42975
  }
42644
42976
  if (step === "shipping" && formData.customer) {
42645
- return (jsx(ShipmentsForm, { setFormData: setFormData, formData: formData, shippingRates: shippingRates, initialData: formData.shipping, onSubmit: handleShippingSubmit, onBack: handleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), currency: currency, exchangeRate: exchangeRate, locale: locale, countryCode: formData.customer.address.countryCode, shipments: shipments }));
42977
+ return (jsx(ShipmentsShippingMethodForm, { setFormData: setFormData, formData: formData, shippingRates: shippingRates, initialData: formData.shipping, onSubmit: handleShippingSubmit, onBack: handleBack, contactEmail: formData.customer.email, shippingAddress: formatAddress(formData.customer.address), currency: currency, exchangeRate: exchangeRate, locale: locale, countryCode: formData.customer.address.countryCode, shipments: shipments }));
42646
42978
  }
42647
42979
  return (jsx(CustomerForm, { initialData: formData.customer, onSubmit: handleCustomerSubmit, clientProxy: clientProxy, clientSecret: clientSecret, latitude: latitude, longitude: longitude, currentAlpha3CountryCode: currentAlpha3CountryCode, locale: locale }));
42648
42980
  };