bitsnap-react 1.15.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/AGENTS.md +8 -0
  2. package/README.md +132 -2
  3. package/dist/CartProvider-DGRZDTYC.mjs +2 -0
  4. package/dist/CartProvider-YVOHSMPE.js +2 -0
  5. package/dist/CartProvider-YVOHSMPE.js.map +1 -0
  6. package/dist/PanelModelFiles-NYCOFPLY.js +2 -0
  7. package/dist/PanelModelFiles-NYCOFPLY.js.map +1 -0
  8. package/dist/PanelModelFiles-RV7OHUUZ.mjs +2 -0
  9. package/dist/PanelModelFiles-RV7OHUUZ.mjs.map +1 -0
  10. package/dist/Viewer3D-2IDEH6W3.mjs +2 -0
  11. package/dist/Viewer3D-2IDEH6W3.mjs.map +1 -0
  12. package/dist/analytics.d.mts +2 -2
  13. package/dist/analytics.d.ts +2 -2
  14. package/dist/analytics.js +1 -1
  15. package/dist/analytics.js.map +1 -1
  16. package/dist/analytics.mjs +1 -1
  17. package/dist/catalog.d.mts +6 -2
  18. package/dist/catalog.d.ts +6 -2
  19. package/dist/catalog.js +1 -1
  20. package/dist/catalog.js.map +1 -1
  21. package/dist/catalog.mjs +1 -1
  22. package/dist/chunk-2NL5FCXC.mjs +4 -0
  23. package/dist/chunk-2NL5FCXC.mjs.map +1 -0
  24. package/dist/{chunk-PEVB3VL4.mjs → chunk-2UDAB2C5.mjs} +2 -2
  25. package/dist/{chunk-PEVB3VL4.mjs.map → chunk-2UDAB2C5.mjs.map} +1 -1
  26. package/dist/{chunk-7DG4UPWE.js → chunk-4BL7TLK3.js} +2 -2
  27. package/dist/chunk-4BL7TLK3.js.map +1 -0
  28. package/dist/chunk-4ETIDGYZ.mjs +2 -0
  29. package/dist/chunk-4ETIDGYZ.mjs.map +1 -0
  30. package/dist/chunk-555KFWGY.js +4 -0
  31. package/dist/chunk-555KFWGY.js.map +1 -0
  32. package/dist/chunk-5ED7FWNY.mjs +2 -0
  33. package/dist/chunk-5ED7FWNY.mjs.map +1 -0
  34. package/dist/chunk-5FZAROP6.js +2 -0
  35. package/dist/chunk-5FZAROP6.js.map +1 -0
  36. package/dist/chunk-5R6AGO3Z.mjs +2 -0
  37. package/dist/chunk-5R6AGO3Z.mjs.map +1 -0
  38. package/dist/chunk-6GCCNBEU.js +2 -0
  39. package/dist/chunk-6GCCNBEU.js.map +1 -0
  40. package/dist/chunk-6Q3VGPSF.js +2 -0
  41. package/dist/chunk-6Q3VGPSF.js.map +1 -0
  42. package/dist/chunk-6YIRRDCL.mjs +2 -0
  43. package/dist/chunk-6YIRRDCL.mjs.map +1 -0
  44. package/dist/chunk-7RXW6XFY.js +2 -0
  45. package/dist/chunk-7RXW6XFY.js.map +1 -0
  46. package/dist/chunk-A6VCP3A4.mjs +2 -0
  47. package/dist/chunk-A6VCP3A4.mjs.map +1 -0
  48. package/dist/chunk-BZXV77PT.mjs +2 -0
  49. package/dist/chunk-BZXV77PT.mjs.map +1 -0
  50. package/dist/{chunk-MG6VV5J2.js → chunk-C3BBJOVV.js} +2 -2
  51. package/dist/chunk-C3BBJOVV.js.map +1 -0
  52. package/dist/chunk-CUPG4B5W.mjs +2 -0
  53. package/dist/chunk-CUPG4B5W.mjs.map +1 -0
  54. package/dist/chunk-ESF5ZVVF.js +2 -0
  55. package/dist/chunk-ESF5ZVVF.js.map +1 -0
  56. package/dist/chunk-HKNWW37T.mjs +2 -0
  57. package/dist/chunk-HKNWW37T.mjs.map +1 -0
  58. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  59. package/dist/chunk-KOYBZORL.js.map +1 -1
  60. package/dist/chunk-L7Q7OKM5.mjs +2 -0
  61. package/dist/chunk-L7Q7OKM5.mjs.map +1 -0
  62. package/dist/chunk-M2G74N43.mjs +2 -0
  63. package/dist/chunk-M2G74N43.mjs.map +1 -0
  64. package/dist/chunk-MIMQTH2G.js +2 -0
  65. package/dist/chunk-MIMQTH2G.js.map +1 -0
  66. package/dist/chunk-SYN5KU3O.js +2 -0
  67. package/dist/chunk-SYN5KU3O.js.map +1 -0
  68. package/dist/chunk-VNYHJT6V.mjs +2 -0
  69. package/dist/chunk-VNYHJT6V.mjs.map +1 -0
  70. package/dist/chunk-W3RGQYPD.js.map +1 -1
  71. package/dist/chunk-X3LVYIJR.mjs +2 -0
  72. package/dist/chunk-X3LVYIJR.mjs.map +1 -0
  73. package/dist/consent.js.map +1 -1
  74. package/dist/course.d.mts +3 -3
  75. package/dist/course.d.ts +3 -3
  76. package/dist/course.js +1 -1
  77. package/dist/course.js.map +1 -1
  78. package/dist/course.mjs +1 -1
  79. package/dist/course.mjs.map +1 -1
  80. package/dist/embed/analytics.js +1 -1
  81. package/dist/errors.js.map +1 -1
  82. package/dist/index.css +1 -1
  83. package/dist/index.css.map +1 -1
  84. package/dist/index.d.mts +41 -12
  85. package/dist/index.d.ts +41 -12
  86. package/dist/index.js +1 -1
  87. package/dist/index.js.map +1 -1
  88. package/dist/index.mjs +1 -1
  89. package/dist/index.mjs.map +1 -1
  90. package/dist/{instrument-BE8ktMUv.d.mts → instrument-eXaC8hc2.d.mts} +1 -1
  91. package/dist/{instrument-BE8ktMUv.d.ts → instrument-eXaC8hc2.d.ts} +1 -1
  92. package/dist/internal.js.map +1 -1
  93. package/dist/methods-3W34GRYL.js +2 -0
  94. package/dist/methods-3W34GRYL.js.map +1 -0
  95. package/dist/methods-LUJSKSQ4.mjs +2 -0
  96. package/dist/model-files-client-HHDXJDTS.mjs +2 -0
  97. package/dist/model-files-client-HHDXJDTS.mjs.map +1 -0
  98. package/dist/model-files-client-P4PORZJ6.js +2 -0
  99. package/dist/model-files-client-P4PORZJ6.js.map +1 -0
  100. package/dist/models.d.mts +2 -0
  101. package/dist/models.d.ts +2 -0
  102. package/dist/models.js +1 -1
  103. package/dist/models.js.map +1 -1
  104. package/dist/models.mjs +1 -1
  105. package/dist/models.mjs.map +1 -1
  106. package/dist/returns.d.mts +19 -10
  107. package/dist/returns.d.ts +19 -10
  108. package/dist/returns.js +1 -1
  109. package/dist/returns.js.map +1 -1
  110. package/dist/returns.mjs +1 -1
  111. package/dist/{texts-tQtAGJCT.d.mts → texts-LGhuQfA9.d.mts} +28 -3
  112. package/dist/{texts-CIEFbJTN.d.ts → texts-m6XQGZ6w.d.ts} +28 -3
  113. package/dist/types-ClFCVzk_.d.ts +121 -0
  114. package/dist/types-D6LsoycW.d.mts +121 -0
  115. package/dist/viewer3d.css +2 -0
  116. package/dist/viewer3d.css.map +1 -0
  117. package/dist/viewer3d.d.mts +318 -0
  118. package/dist/viewer3d.d.ts +318 -0
  119. package/dist/viewer3d.js +2 -0
  120. package/dist/viewer3d.js.map +1 -0
  121. package/dist/viewer3d.mjs +63 -0
  122. package/dist/viewer3d.mjs.map +1 -0
  123. package/package.json +43 -16
  124. package/dist/CartProvider-64QEJ7A7.js +0 -2
  125. package/dist/CartProvider-64QEJ7A7.js.map +0 -1
  126. package/dist/CartProvider-XKK7A3C2.mjs +0 -2
  127. package/dist/chunk-2TLWMYXW.mjs +0 -2
  128. package/dist/chunk-2TLWMYXW.mjs.map +0 -1
  129. package/dist/chunk-7DG4UPWE.js.map +0 -1
  130. package/dist/chunk-7TLJKYZD.mjs +0 -2
  131. package/dist/chunk-7TLJKYZD.mjs.map +0 -1
  132. package/dist/chunk-AZQOW73L.mjs +0 -4
  133. package/dist/chunk-AZQOW73L.mjs.map +0 -1
  134. package/dist/chunk-DY2S42Q6.js +0 -2
  135. package/dist/chunk-DY2S42Q6.js.map +0 -1
  136. package/dist/chunk-FGB5FJCI.js +0 -2
  137. package/dist/chunk-FGB5FJCI.js.map +0 -1
  138. package/dist/chunk-GLAJPUMA.js +0 -2
  139. package/dist/chunk-GLAJPUMA.js.map +0 -1
  140. package/dist/chunk-H4WAQQVO.js +0 -2
  141. package/dist/chunk-H4WAQQVO.js.map +0 -1
  142. package/dist/chunk-MG6VV5J2.js.map +0 -1
  143. package/dist/chunk-Q3DSK66F.mjs +0 -2
  144. package/dist/chunk-Q3DSK66F.mjs.map +0 -1
  145. package/dist/chunk-RWEP6IUC.mjs +0 -2
  146. package/dist/chunk-RWEP6IUC.mjs.map +0 -1
  147. package/dist/chunk-S4Z4O46O.mjs +0 -2
  148. package/dist/chunk-S4Z4O46O.mjs.map +0 -1
  149. package/dist/chunk-VY6CZVVA.js +0 -4
  150. package/dist/chunk-VY6CZVVA.js.map +0 -1
  151. package/dist/chunk-XZYCQ655.js +0 -2
  152. package/dist/chunk-XZYCQ655.js.map +0 -1
  153. package/dist/chunk-ZIWQ57GY.mjs +0 -2
  154. package/dist/chunk-ZIWQ57GY.mjs.map +0 -1
  155. package/dist/methods-NUMVR53L.js +0 -2
  156. package/dist/methods-NUMVR53L.js.map +0 -1
  157. package/dist/methods-YKZZ6OVT.mjs +0 -2
  158. package/dist/types-DP1vxo5E.d.mts +0 -53
  159. package/dist/types-u8VwmC3j.d.ts +0 -53
  160. /package/dist/{CartProvider-XKK7A3C2.mjs.map → CartProvider-DGRZDTYC.mjs.map} +0 -0
  161. /package/dist/{methods-YKZZ6OVT.mjs.map → methods-LUJSKSQ4.mjs.map} +0 -0
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }function l(t,e){return e.toLowerCase().startsWith("en")?t.en:t.pl}function u(t,e){let n={...t};if(e!=null)for(let[c,i]of Object.entries(e))i!=null&&(n[c]=i);return n}function s(t,e,n){return u(l(t,e),n)}function p(t,e){return _nullishCoalesce(t[e], () => (e))}var y={en:{cart:"Cart",emptyCart:"Your cart is empty.",total:"Total:",delivery:"+ delivery",chooseCountry:"Choose a country",nextStep:"Next step",unavailableProducts:"Not all products are available.",checkoutFailed:"Something went wrong. Please try again later.",noPaymentGateway:"This shop doesn't accept online payments yet. Try again later or contact the seller.",gatewayNotConfigured:"Payments in this shop are not set up correctly. Try again later or contact the seller.",shippingNotConfigured:"Delivery in this shop is not configured yet. Try again later or contact the seller.",mixedRecurring:"Subscriptions and one-time products cannot be paid for together. Pay for them in separate orders.",currencyUnsupported:"The shop doesn't accept payments in this currency. Contact the seller.",priceChanged:"The product price has changed. Refresh the page to see the current price.",close:"Close cart",remove:"Remove",quantity:"Quantity",increaseQuantity:"Increase quantity",decreaseQuantity:"Decrease quantity",openCart:"Open cart",cartItemsCount:"Items in cart",lowestPrice30Days:"Lowest price in the last 30 days:",noPriceHistory:"No price data for the last 30 days",redirectFailed:"Could not redirect to the payment. Please try again later.",subscriptionUnsupported:"Subscriptions cannot be added to the cart yet.",searchCountry:"Find a country",noCountriesFound:"No countries found",countryRequired:"Choose a country to continue.",paymentForCart:"Cart payment",coupon:"Coupon",extrasCalculatedNext:"Discounts, shipping and taxes are calculated at the next step",loadFailed:"Could not load your cart.",retry:"Try again",paymentMethodLegend:"How would you like to pay?",paymentMethodOnline:"Pay online",paymentMethodOnlineDescription:"Card, BLIK code or instant bank payment. You pay right away.",paymentMethodManualTransfer:"Bank transfer",paymentMethodManualBlik:"BLIK \u2013 transfer to a phone number",paymentMethodManualBoth:"Bank transfer or BLIK to a phone number",paymentMethodManualDescription:"You pay in your bank's app. We show the payment details after you place the order, and the order waits for your payment.",paymentMethodManualBlikNote:"This is not a BLIK code payment \u2013 you do not enter a 6\u2011digit code.",paymentMethodCod:"Cash on delivery",paymentMethodCodDescription:"You pay the courier in cash or by card when you receive the parcel.",paymentMethodCodUnavailable:"Cash on delivery is not available for this order. Choose another way to pay."},pl:{cart:"Koszyk",emptyCart:"Brak produkt\xF3w w koszyku.",total:"Suma:",delivery:"+ dostawa",chooseCountry:"Wybierz kraj",nextStep:"Nast\u0119pny krok",unavailableProducts:"Nie wszystkie produkty s\u0105 dost\u0119pne w magazynie.",checkoutFailed:"Co\u015B posz\u0142o nie tak. Spr\xF3buj ponownie p\xF3\u017Aniej.",noPaymentGateway:"Ten sklep nie przyjmuje jeszcze p\u0142atno\u015Bci online. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",gatewayNotConfigured:"P\u0142atno\u015Bci w tym sklepie nie s\u0105 poprawnie skonfigurowane. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",shippingNotConfigured:"Dostawa w tym sklepie nie jest jeszcze skonfigurowana. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",mixedRecurring:"Subskrypcji i produkt\xF3w jednorazowych nie mo\u017Cna op\u0142aci\u0107 razem. Op\u0142a\u0107 je w osobnych zam\xF3wieniach.",currencyUnsupported:"Sklep nie przyjmuje p\u0142atno\u015Bci w tej walucie. Skontaktuj si\u0119 ze sprzedawc\u0105.",priceChanged:"Cena produktu si\u0119 zmieni\u0142a. Od\u015Bwie\u017C stron\u0119, aby zobaczy\u0107 aktualn\u0105 cen\u0119.",close:"Zamknij koszyk",remove:"Usu\u0144",quantity:"Ilo\u015B\u0107",increaseQuantity:"Zwi\u0119ksz ilo\u015B\u0107",decreaseQuantity:"Zmniejsz ilo\u015B\u0107",openCart:"Otw\xF3rz koszyk",cartItemsCount:"Produkt\xF3w w koszyku",lowestPrice30Days:"Najni\u017Csza cena z 30 dni:",noPriceHistory:"Brak danych o cenie z ostatnich 30 dni",redirectFailed:"Nie uda\u0142o si\u0119 przekierowa\u0107 do p\u0142atno\u015Bci. Spr\xF3buj ponownie p\xF3\u017Aniej.",subscriptionUnsupported:"Subskrypcji nie mo\u017Cna jeszcze doda\u0107 do koszyka.",searchCountry:"Znajd\u017A kraj",noCountriesFound:"Nie znaleziono kraj\xF3w",countryRequired:"Wybierz kraj, aby przej\u015B\u0107 dalej.",paymentForCart:"P\u0142atno\u015B\u0107 za koszyk",coupon:"Kupon",extrasCalculatedNext:"Rabaty, dostawa i podatki w nast\u0119pnym kroku",loadFailed:"Nie uda\u0142o si\u0119 wczyta\u0107 koszyka.",retry:"Spr\xF3buj ponownie",paymentMethodLegend:"Jak chcesz zap\u0142aci\u0107?",paymentMethodOnline:"Zap\u0142a\u0107 online",paymentMethodOnlineDescription:"Karta, kod BLIK lub szybki przelew. P\u0142acisz od razu.",paymentMethodManualTransfer:"Przelew bankowy",paymentMethodManualBlik:"BLIK \u2013 przelew na telefon",paymentMethodManualBoth:"Przelew lub BLIK na telefon",paymentMethodManualDescription:"Zap\u0142acisz w aplikacji swojego banku. Dane do p\u0142atno\u015Bci poka\u017Cemy po z\u0142o\u017Ceniu zam\xF3wienia, a zam\xF3wienie poczeka na Twoj\u0105 wp\u0142at\u0119.",paymentMethodManualBlikNote:"To nie jest p\u0142atno\u015B\u0107 kodem BLIK \u2013 nie wpisujesz 6\u2011cyfrowego kodu.",paymentMethodCod:"P\u0142atno\u015B\u0107 przy odbiorze",paymentMethodCodDescription:"Zap\u0142acisz kurierowi got\xF3wk\u0105 lub kart\u0105, gdy odbierzesz przesy\u0142k\u0119.",paymentMethodCodUnavailable:"P\u0142atno\u015B\u0107 przy odbiorze nie jest dost\u0119pna dla tego zam\xF3wienia. Wybierz inn\u0105 form\u0119 p\u0142atno\u015Bci."}};function d(t,e){return s(y,t,e)}function m(t,e,n){return p(d(e,n),t)}var o="pl-PL",r="bitsnap-locale",a;function w(t){let e=_optionalChain([t, 'optionalAccess', _ => _.trim, 'call', _2 => _2()]);a=e?e.toLowerCase()==="en"?"en-US":e.toLowerCase()==="pl"?o:e:void 0,typeof localStorage<"u"&&(a==null?localStorage.removeItem(r):localStorage.setItem(r,a))}function C(){return _nullishCoalesce(a, () => ((typeof localStorage<"u"?_nullishCoalesce(localStorage.getItem(r), () => (o)):o)))}exports.a = l; exports.b = s; exports.c = m; exports.d = o; exports.e = w; exports.f = C;
2
+ //# sourceMappingURL=chunk-7RXW6XFY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/texts.ts","../src/components/checkout/texts.ts","../src/components/checkout/locale.ts"],"names":["pickLocaleTable","tables","locale","mergeTexts","table","overrides","result","key","value","resolveTexts","lookupText","texts","CHECKOUT_TEXT_TABLES","resolveCheckoutTexts","getCheckoutText","DEFAULT_LOCALE","localeStorageKey","activeLocale","setLocale","getLocale"],"mappings":"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","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-7RXW6XFY.js","sourcesContent":["/**\n * Shared text machinery: typed string tables per locale, the locale fallback\n * and a merge with caller overrides. Each module (checkout, later returns)\n * supplies its own key type and default tables.\n */\n\n/** Strings of one locale, keyed by text key. */\nexport type TextTable<Key extends string> = Record<Key, string>;\n\n/** Default tables for the supported locales. */\nexport type LocaleTables<Key extends string> = {\n en: TextTable<Key>;\n pl: TextTable<Key>;\n};\n\n/**\n * Picks the table for a locale. Any locale starting with `en` (case\n * insensitive, so `en`, `en-US`, `EN-gb`) gets English; everything else,\n * including unknown locales, gets the Polish default.\n */\nexport function pickLocaleTable<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n): TextTable<Key> {\n return locale.toLowerCase().startsWith(\"en\") ? tables.en : tables.pl;\n}\n\n/**\n * Merges caller overrides over a table. Overrides apply regardless of the\n * locale; `undefined`/`null` entries are ignored so the default stays.\n */\nexport function mergeTexts<Key extends string>(\n table: TextTable<Key>,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n const result: Record<string, string> = { ...table };\n\n if (overrides != null) {\n for (const [key, value] of Object.entries<string | undefined>(overrides)) {\n if (value != null) {\n result[key] = value;\n }\n }\n }\n\n return result as TextTable<Key>;\n}\n\n/** Locale table merged with the caller overrides. */\nexport function resolveTexts<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n return mergeTexts(pickLocaleTable(tables, locale), overrides);\n}\n\n/** Looks up a single text. Unknown keys return the key itself. */\nexport function lookupText<Key extends string>(\n texts: TextTable<Key>,\n key: Key,\n): string {\n return (texts as Record<string, string | undefined>)[key] ?? key;\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string the checkout renders. Pass a partial object through the\n * `texts` prop of `BitsnapCheckout` to override any of them, whatever the\n * locale.\n */\nexport type CheckoutTexts = {\n /** Drawer title. */\n cart: string;\n /** Shown when the cart has no products. */\n emptyCart: string;\n /** Label next to the total price. */\n total: string;\n /** Delivery note next to the total price. */\n delivery: string;\n /** Country selector placeholder. */\n chooseCountry: string;\n /** Checkout button label. */\n nextStep: string;\n /** Error shown when some products are out of stock. */\n unavailableProducts: string;\n /** Error shown when the checkout fails and the server gave no reason. */\n checkoutFailed: string;\n /** Error shown when the shop has no payment gateway connected. */\n noPaymentGateway: string;\n /** Error shown when the payment gateway of the shop is not set up. */\n gatewayNotConfigured: string;\n /** Error shown when delivery of the shop is not set up. */\n shippingNotConfigured: string;\n /** Error shown when the cart mixes subscriptions with one-time products. */\n mixedRecurring: string;\n /** Error shown when the cart currency cannot be paid in. */\n currencyUnsupported: string;\n /** Error shown when a price changed after the product was added. */\n priceChanged: string;\n /** Accessible name of the close button of the drawer. */\n close: string;\n /** Remove button of a cart line (also read together with the product name). */\n remove: string;\n /** Accessible name of the quantity control and its input. */\n quantity: string;\n /** Accessible name of the \"+\" quantity button. */\n increaseQuantity: string;\n /** Accessible name of the \"-\" quantity button. */\n decreaseQuantity: string;\n /** Accessible name of the cart button when it only shows an icon. */\n openCart: string;\n /** Hidden label of the number of products badge; the number is appended after a colon. */\n cartItemsCount: string;\n /** Label before the lowest price of the last 30 days; the price is appended. */\n lowestPrice30Days: string;\n /** Shown instead of the lowest price when the price has no history. */\n noPriceHistory: string;\n /** Error shown when redirecting to the payment failed. */\n redirectFailed: string;\n /** Error shown when a subscription is added to the cart. */\n subscriptionUnsupported: string;\n /** Country search placeholder. */\n searchCountry: string;\n /** Shown when the country search has no match. */\n noCountriesFound: string;\n /** Hint under the checkout button when no country is chosen. */\n countryRequired: string;\n /** Title of the Apple Pay and Google Pay sheet total. */\n paymentForCart: string;\n /** Coupon label in the Google Pay sheet; the code is appended. */\n coupon: string;\n /** Note under the cart total. */\n extrasCalculatedNext: string;\n /** Error shown when the products of the cart could not be loaded. */\n loadFailed: string;\n /** Button that loads the cart again. */\n retry: string;\n /** Heading of the payment method choice (shown only when the shop offers paying by hand). */\n paymentMethodLegend: string;\n /** Option that pays through the shop's online gateway. */\n paymentMethodOnline: string;\n /** Hint under the online option. */\n paymentMethodOnlineDescription: string;\n /** Manual option when the seller takes bank transfers only. */\n paymentMethodManualTransfer: string;\n /** Manual option when the seller takes BLIK transfers to a phone number only. */\n paymentMethodManualBlik: string;\n /** Manual option when the seller takes both. */\n paymentMethodManualBoth: string;\n /** What paying by hand means: the details come after the order is placed. */\n paymentMethodManualDescription: string;\n /** Shown with a selected manual option that includes BLIK to a phone number. */\n paymentMethodManualBlikNote: string;\n /** Cash on delivery option. */\n paymentMethodCod: string;\n /** Hint under the cash on delivery option. */\n paymentMethodCodDescription: string;\n /** Error shown when the shop refused cash on delivery for the order. */\n paymentMethodCodUnavailable: string;\n};\n\nexport type CheckoutTextKey = keyof CheckoutTexts;\n\nexport const CHECKOUT_TEXT_TABLES: LocaleTables<CheckoutTextKey> = {\n en: {\n cart: \"Cart\",\n emptyCart: \"Your cart is empty.\",\n total: \"Total:\",\n delivery: \"+ delivery\",\n chooseCountry: \"Choose a country\",\n nextStep: \"Next step\",\n unavailableProducts: \"Not all products are available.\",\n checkoutFailed: \"Something went wrong. Please try again later.\",\n noPaymentGateway:\n \"This shop doesn't accept online payments yet. Try again later or contact the seller.\",\n gatewayNotConfigured:\n \"Payments in this shop are not set up correctly. Try again later or contact the seller.\",\n shippingNotConfigured:\n \"Delivery in this shop is not configured yet. Try again later or contact the seller.\",\n mixedRecurring:\n \"Subscriptions and one-time products cannot be paid for together. Pay for them in separate orders.\",\n currencyUnsupported:\n \"The shop doesn't accept payments in this currency. Contact the seller.\",\n priceChanged: \"The product price has changed. Refresh the page to see the current price.\",\n close: \"Close cart\",\n remove: \"Remove\",\n quantity: \"Quantity\",\n increaseQuantity: \"Increase quantity\",\n decreaseQuantity: \"Decrease quantity\",\n openCart: \"Open cart\",\n cartItemsCount: \"Items in cart\",\n lowestPrice30Days: \"Lowest price in the last 30 days:\",\n noPriceHistory: \"No price data for the last 30 days\",\n redirectFailed: \"Could not redirect to the payment. Please try again later.\",\n subscriptionUnsupported: \"Subscriptions cannot be added to the cart yet.\",\n searchCountry: \"Find a country\",\n noCountriesFound: \"No countries found\",\n countryRequired: \"Choose a country to continue.\",\n paymentForCart: \"Cart payment\",\n coupon: \"Coupon\",\n extrasCalculatedNext:\n \"Discounts, shipping and taxes are calculated at the next step\",\n loadFailed: \"Could not load your cart.\",\n retry: \"Try again\",\n paymentMethodLegend: \"How would you like to pay?\",\n paymentMethodOnline: \"Pay online\",\n paymentMethodOnlineDescription:\n \"Card, BLIK code or instant bank payment. You pay right away.\",\n paymentMethodManualTransfer: \"Bank transfer\",\n paymentMethodManualBlik: \"BLIK – transfer to a phone number\",\n paymentMethodManualBoth: \"Bank transfer or BLIK to a phone number\",\n paymentMethodManualDescription:\n \"You pay in your bank's app. We show the payment details after you place the order, and the order waits for your payment.\",\n paymentMethodManualBlikNote:\n \"This is not a BLIK code payment – you do not enter a 6‑digit code.\",\n paymentMethodCod: \"Cash on delivery\",\n paymentMethodCodDescription:\n \"You pay the courier in cash or by card when you receive the parcel.\",\n paymentMethodCodUnavailable:\n \"Cash on delivery is not available for this order. Choose another way to pay.\",\n },\n pl: {\n cart: \"Koszyk\",\n emptyCart: \"Brak produktów w koszyku.\",\n total: \"Suma:\",\n delivery: \"+ dostawa\",\n chooseCountry: \"Wybierz kraj\",\n nextStep: \"Następny krok\",\n unavailableProducts: \"Nie wszystkie produkty są dostępne w magazynie.\",\n checkoutFailed: \"Coś poszło nie tak. Spróbuj ponownie później.\",\n noPaymentGateway:\n \"Ten sklep nie przyjmuje jeszcze płatności online. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n gatewayNotConfigured:\n \"Płatności w tym sklepie nie są poprawnie skonfigurowane. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n shippingNotConfigured:\n \"Dostawa w tym sklepie nie jest jeszcze skonfigurowana. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n mixedRecurring:\n \"Subskrypcji i produktów jednorazowych nie można opłacić razem. Opłać je w osobnych zamówieniach.\",\n currencyUnsupported:\n \"Sklep nie przyjmuje płatności w tej walucie. Skontaktuj się ze sprzedawcą.\",\n priceChanged: \"Cena produktu się zmieniła. Odśwież stronę, aby zobaczyć aktualną cenę.\",\n close: \"Zamknij koszyk\",\n remove: \"Usuń\",\n quantity: \"Ilość\",\n increaseQuantity: \"Zwiększ ilość\",\n decreaseQuantity: \"Zmniejsz ilość\",\n openCart: \"Otwórz koszyk\",\n cartItemsCount: \"Produktów w koszyku\",\n lowestPrice30Days: \"Najniższa cena z 30 dni:\",\n noPriceHistory: \"Brak danych o cenie z ostatnich 30 dni\",\n redirectFailed:\n \"Nie udało się przekierować do płatności. Spróbuj ponownie później.\",\n subscriptionUnsupported: \"Subskrypcji nie można jeszcze dodać do koszyka.\",\n searchCountry: \"Znajdź kraj\",\n noCountriesFound: \"Nie znaleziono krajów\",\n countryRequired: \"Wybierz kraj, aby przejść dalej.\",\n paymentForCart: \"Płatność za koszyk\",\n coupon: \"Kupon\",\n extrasCalculatedNext: \"Rabaty, dostawa i podatki w następnym kroku\",\n loadFailed: \"Nie udało się wczytać koszyka.\",\n retry: \"Spróbuj ponownie\",\n paymentMethodLegend: \"Jak chcesz zapłacić?\",\n paymentMethodOnline: \"Zapłać online\",\n paymentMethodOnlineDescription:\n \"Karta, kod BLIK lub szybki przelew. Płacisz od razu.\",\n paymentMethodManualTransfer: \"Przelew bankowy\",\n paymentMethodManualBlik: \"BLIK – przelew na telefon\",\n paymentMethodManualBoth: \"Przelew lub BLIK na telefon\",\n paymentMethodManualDescription:\n \"Zapłacisz w aplikacji swojego banku. Dane do płatności pokażemy po złożeniu zamówienia, a zamówienie poczeka na Twoją wpłatę.\",\n paymentMethodManualBlikNote:\n \"To nie jest płatność kodem BLIK – nie wpisujesz 6‑cyfrowego kodu.\",\n paymentMethodCod: \"Płatność przy odbiorze\",\n paymentMethodCodDescription:\n \"Zapłacisz kurierowi gotówką lub kartą, gdy odbierzesz przesyłkę.\",\n paymentMethodCodUnavailable:\n \"Płatność przy odbiorze nie jest dostępna dla tego zamówienia. Wybierz inną formę płatności.\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveCheckoutTexts(\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): CheckoutTexts {\n return resolveTexts(CHECKOUT_TEXT_TABLES, locale, overrides);\n}\n\nexport function getCheckoutText(\n key: CheckoutTextKey,\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): string {\n return lookupText(resolveCheckoutTexts(locale, overrides), key);\n}\n","import { pickLocaleTable } from \"@/src/lib/texts\";\nimport { CHECKOUT_TEXT_TABLES } from \"./texts\";\n\nexport const DEFAULT_LOCALE = \"pl-PL\" as const;\nconst localeStorageKey = \"bitsnap-locale\";\n\nlet activeLocale: string | undefined;\n\nexport function setLocale(locale?: string): void {\n const value = locale?.trim();\n activeLocale = value\n ? value.toLowerCase() === \"en\"\n ? \"en-US\"\n : value.toLowerCase() === \"pl\"\n ? DEFAULT_LOCALE\n : value\n : undefined;\n if (typeof localStorage !== \"undefined\") {\n if (activeLocale == null) {\n localStorage.removeItem(localeStorageKey);\n } else {\n localStorage.setItem(localeStorageKey, activeLocale);\n }\n }\n}\n\nexport function getLocale(): string {\n if (activeLocale != null) {\n return activeLocale;\n }\n if (typeof localStorage !== \"undefined\") {\n return localStorage.getItem(localeStorageKey) ?? DEFAULT_LOCALE;\n }\n return DEFAULT_LOCALE;\n}\n\nexport function translate(key: string, locale: string = getLocale()): string {\n return (\n (pickLocaleTable(CHECKOUT_TEXT_TABLES, locale) as Record<string, string>)[\n key\n ] ?? key\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import{b as r}from"./chunk-CUPG4B5W.mjs";import{p}from"./chunk-L7Q7OKM5.mjs";import{l,n as d}from"./chunk-2UDAB2C5.mjs";import{createContext as g,useContext as f}from"react";import{jsx as i}from"react/jsx-runtime";var c=g(r()),v=({children:n,analytics:e})=>{let t=r(),o=d(t.projectID,e,"panel");return i(p,{children:i(c.Provider,{value:{...t},children:i(l,{value:o,children:i("div",{className:"bitsnap-react",children:n})})})})},C=()=>f(c);var s=(n,e)=>`bitsnap-panel-session:${encodeURIComponent(e??"https://bitsnap.pl")}:${encodeURIComponent(n)}`,a=(n,e)=>`bitsnap-panel-email:${encodeURIComponent(e??"https://bitsnap.pl")}:${encodeURIComponent(n)}`;function x(n,e){return typeof window>"u"||!n?void 0:window.localStorage.getItem(s(n,e))??void 0}function R(n,e,t,o){typeof window>"u"||!n||(window.localStorage.setItem(s(n,o),e),window.localStorage.setItem(a(n,o),t))}function I(n,e){return typeof window>"u"||!n?null:window.localStorage.getItem(a(n,e))}function b(n,e){typeof window>"u"||!n||(window.localStorage.removeItem(s(n,e)),window.localStorage.removeItem(a(n,e)))}export{v as a,C as b,x as c,R as d,I as e,b as f};
2
+ //# sourceMappingURL=chunk-A6VCP3A4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/panel/PanelProvider.tsx","../src/panel/session-storage.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport {\n InstrumentProvider,\n useInstrument,\n type AnalyticsOption,\n} from \"../analytics/instrument\";\nimport { RpcProvider } from \"../rpc-provider\";\nimport { getPanelConfig, type PanelConfig } from \"./config\";\n\nconst PanelContext = createContext<PanelConfig>(getPanelConfig());\n\nexport const PanelProvider: React.FC<{\n children: React.ReactNode;\n /**\n * Usage statistics for your Bitsnap dashboard (panel logins, orders viewed,\n * downloads, course progress). On by default; `false` turns it off. An\n * object lets you forward every event: `{ onEvent }`. Nothing is stored on\n * the visitor's device.\n */\n analytics?: AnalyticsOption;\n}> = ({ children, analytics }) => {\n const config = getPanelConfig();\n const instrument = useInstrument(config.projectID, analytics, \"panel\");\n return (\n <RpcProvider>\n <PanelContext.Provider value={{ ...config }}>\n <InstrumentProvider value={instrument}>\n <div className=\"bitsnap-react\">{children}</div>\n </InstrumentProvider>\n </PanelContext.Provider>\n </RpcProvider>\n );\n};\n\nexport const usePanelConfig = () => useContext(PanelContext);\n","const panelSessionKey = (projectID: string, host?: string) =>\n `bitsnap-panel-session:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nconst panelEmailKey = (projectID: string, host?: string) =>\n `bitsnap-panel-email:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nexport function getPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return undefined;\n const token = window.localStorage.getItem(panelSessionKey(projectID, host));\n return token ?? undefined;\n}\n\nexport function savePanelSession(projectID: string | undefined, token: string, email: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.setItem(panelSessionKey(projectID, host), token);\n window.localStorage.setItem(panelEmailKey(projectID, host), email);\n}\n\nexport function getPanelEmail(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return null;\n return window.localStorage.getItem(panelEmailKey(projectID, host));\n}\n\nexport function clearPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.removeItem(panelSessionKey(projectID, host));\n window.localStorage.removeItem(panelEmailKey(projectID, host));\n}\n"],"mappings":"wHAAA,OAAS,iBAAAA,EAAe,cAAAC,MAAkB,QA2BhC,cAAAC,MAAA,oBAlBV,IAAMC,EAAeC,EAA2BC,EAAe,CAAC,EAEnDC,EASR,CAAC,CAAE,SAAAC,EAAU,UAAAC,CAAU,IAAM,CAChC,IAAMC,EAASJ,EAAe,EACxBK,EAAaC,EAAcF,EAAO,UAAWD,EAAW,OAAO,EACrE,OACEN,EAACU,EAAA,CACC,SAAAV,EAACC,EAAa,SAAb,CAAsB,MAAO,CAAE,GAAGM,CAAO,EACxC,SAAAP,EAACW,EAAA,CAAmB,MAAOH,EACzB,SAAAR,EAAC,OAAI,UAAU,gBAAiB,SAAAK,EAAS,EAC3C,EACF,EACF,CAEJ,EAEaO,EAAiB,IAAMC,EAAWZ,CAAY,EClC3D,IAAMa,EAAkB,CAACC,EAAmBC,IAC1C,yBAAyB,mBAAmBA,GAAQ,oBAAoB,CAAC,IAAI,mBAAmBD,CAAS,CAAC,GAEtGE,EAAgB,CAACF,EAAmBC,IACxC,uBAAuB,mBAAmBA,GAAQ,oBAAoB,CAAC,IAAI,mBAAmBD,CAAS,CAAC,GAEnG,SAASG,EAAgBH,EAAoBC,EAAe,CACjE,OAAI,OAAO,OAAW,KAAe,CAACD,EAAW,OACnC,OAAO,aAAa,QAAQD,EAAgBC,EAAWC,CAAI,CAAC,GAC1D,MAClB,CAEO,SAASG,EAAiBJ,EAA+BK,EAAeC,EAAeL,EAAe,CACvG,OAAO,OAAW,KAAe,CAACD,IACtC,OAAO,aAAa,QAAQD,EAAgBC,EAAWC,CAAI,EAAGI,CAAK,EACnE,OAAO,aAAa,QAAQH,EAAcF,EAAWC,CAAI,EAAGK,CAAK,EACnE,CAEO,SAASC,EAAcP,EAAoBC,EAAe,CAC/D,OAAI,OAAO,OAAW,KAAe,CAACD,EAAkB,KACjD,OAAO,aAAa,QAAQE,EAAcF,EAAWC,CAAI,CAAC,CACnE,CAEO,SAASO,EAAkBR,EAAoBC,EAAe,CAC/D,OAAO,OAAW,KAAe,CAACD,IACtC,OAAO,aAAa,WAAWD,EAAgBC,EAAWC,CAAI,CAAC,EAC/D,OAAO,aAAa,WAAWC,EAAcF,EAAWC,CAAI,CAAC,EAC/D","names":["createContext","useContext","jsx","PanelContext","createContext","getPanelConfig","PanelProvider","children","analytics","config","instrument","useInstrument","RpcProvider","InstrumentProvider","usePanelConfig","useContext","panelSessionKey","projectID","host","panelEmailKey","getPanelSession","savePanelSession","token","email","getPanelEmail","clearPanelSession"]}
@@ -0,0 +1,2 @@
1
+ import{C as y,D as I,E as T,F as N,G as f,H as g,I as C,J as O,K as _,c as R,o as c,r as p,s as l,t as E,u as S}from"./chunk-HKNWW37T.mjs";import{a as d}from"./chunk-5R6AGO3Z.mjs";var M=["orders","order","confirmation","result","myReturns","myReturn"];function k(e){return M.includes(e)}function L(e){return e?{name:"orders"}:{name:"email"}}function U(e,s){switch(s.type){case"SESSION_EXPIRED":return k(e.name)?{name:"email"}:e;case"CODE_SENT":return e.name==="email"?{name:"code"}:e;case"AUTHENTICATED":return e.name==="email"||e.name==="code"?{name:"orders"}:e;case"SELECT_ORDER":return e.name==="orders"?{name:"order",orderId:s.orderId}:e;case"REVIEW":return e.name==="order"?{name:"confirmation",orderId:e.orderId,items:s.items,note:s.note}:e;case"SUBMITTED":return e.name==="confirmation"?{name:"result",returnId:s.returnId}:e;case"OPEN_MY_RETURNS":return e.name==="orders"||e.name==="result"?{name:"myReturns"}:e;case"SELECT_RETURN":return e.name==="myReturns"?{name:"myReturn",returnId:s.returnId}:e;case"CONTINUE":return e.name==="result"?{name:"orders"}:e;case"BACK":switch(e.name){case"code":return{name:"email"};case"order":case"myReturns":return{name:"orders"};case"confirmation":return{name:"order",orderId:e.orderId,items:e.items,note:e.note};case"myReturn":return{name:"myReturns"};default:return e}}}var K={email:1,code:2,orders:3,order:4,confirmation:5,result:6},B=6;function D(e){return K[e]}import{useEffect as P,useReducer as w,useRef as H}from"react";import{jsx as n,jsxs as Y}from"react/jsx-runtime";function V({current:e}){let s=p(),o=c("stepIndicator");return n("p",{"data-bitsnap-returns-slot":"stepIndicator",className:d("text-xs",o.className),style:o.style,children:s("stepIndicator",{current:e,total:B})})}function W({panelToken:e,logo:s}){let{status:o,challenge:a,projectID:x}=E("BitsnapReturns"),A=l(),[r,t]=w(U,L(!1));P(()=>{o==="authenticated"?t({type:"AUTHENTICATED"}):o==="anonymous"&&t({type:"SESSION_EXPIRED"})},[o]);let i=H(!1);if(P(()=>{i.current||o==="hydrating"||(i.current=!0,o==="anonymous"&&a!=null&&t({type:"CODE_SENT"}))},[o,a]),o==="exchanging"||o==="hydrating"&&e)return n(y,{});let m=D(r.name),b=r.name==="email"||r.name==="code";return Y("div",{className:"flex flex-col gap-4",children:[b&&n(R,{projectId:x,locale:A,...s}),m!=null&&n(V,{current:m}),r.name==="email"&&n(I,{showLogo:!1,onSubmitted:()=>t({type:"CODE_SENT"})}),r.name==="code"&&n(T,{showLogo:!1,onVerified:()=>t({type:"AUTHENTICATED"}),onBack:()=>t({type:"BACK"})}),r.name==="orders"&&n(N,{showLogout:!e,onSelectOrder:u=>t({type:"SELECT_ORDER",orderId:u}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="order"&&n(f,{orderId:r.orderId,initialItems:r.items,initialNote:r.note,onBack:()=>t({type:"BACK"}),onContinue:({items:u,note:h})=>t({type:"REVIEW",items:u,note:h})}),r.name==="confirmation"&&n(g,{orderId:r.orderId,items:r.items,note:r.note,onBack:()=>t({type:"BACK"}),onSubmitted:u=>t({type:"SUBMITTED",returnId:u})}),r.name==="result"&&n(C,{returnId:r.returnId,onContinue:()=>t({type:"CONTINUE"}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="myReturns"&&n(O,{onSelectReturn:u=>t({type:"SELECT_RETURN",returnId:u}),onBack:()=>t({type:"BACK"})}),r.name==="myReturn"&&n(_,{returnId:r.returnId,onBack:()=>t({type:"BACK"})})]})}function re({showLogo:e,logoUrl:s,logoDarkUrl:o,...a}){return n(S,{...a,children:n(W,{panelToken:a.panelAccessToken!=null&&a.panelAccessToken!=="",logo:{showLogo:e,logoUrl:s,logoDarkUrl:o}})})}export{re as a};
2
+ //# sourceMappingURL=chunk-BZXV77PT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/returns/state-machine.ts","../src/components/returns/BitsnapReturns.tsx"],"sourcesContent":["/** One line chosen for return. */\nexport type SelectedReturnLine = {\n lineId: string;\n quantity: number;\n};\n\n/** Where the default flow of `BitsnapReturns` currently is. */\nexport type ReturnsStep =\n | { name: \"email\" }\n | { name: \"code\" }\n | { name: \"orders\" }\n | {\n name: \"order\";\n orderId: string;\n /** Selection to restore when coming back from the confirmation. */\n items?: SelectedReturnLine[];\n note?: string;\n }\n | {\n name: \"confirmation\";\n orderId: string;\n items: SelectedReturnLine[];\n note: string;\n }\n | { name: \"result\"; returnId: string }\n | { name: \"myReturns\" }\n | { name: \"myReturn\"; returnId: string };\n\nexport type ReturnsStepName = ReturnsStep[\"name\"];\n\nexport type ReturnsStepEvent =\n /** A verification code was requested. */\n | { type: \"CODE_SENT\" }\n /** The session became valid: code verified, stored session or panel token. */\n | { type: \"AUTHENTICATED\" }\n /** The session was dropped by the backend, expiry or logout. */\n | { type: \"SESSION_EXPIRED\" }\n | { type: \"SELECT_ORDER\"; orderId: string }\n | { type: \"REVIEW\"; items: SelectedReturnLine[]; note: string }\n | { type: \"SUBMITTED\"; returnId: string }\n | { type: \"OPEN_MY_RETURNS\" }\n | { type: \"SELECT_RETURN\"; returnId: string }\n | { type: \"BACK\" }\n /** Leave the result screen for the order list. */\n | { type: \"CONTINUE\" };\n\nconst STEPS_WITH_SESSION: readonly ReturnsStepName[] = [\n \"orders\",\n \"order\",\n \"confirmation\",\n \"result\",\n \"myReturns\",\n \"myReturn\",\n];\n\n/** Steps that cannot be shown without a returns session. */\nexport function stepRequiresSession(step: ReturnsStepName): boolean {\n return STEPS_WITH_SESSION.includes(step);\n}\n\n/** Starts at the orders when a session exists, otherwise at the email. */\nexport function initialReturnsStep(hasSession: boolean): ReturnsStep {\n return hasSession ? { name: \"orders\" } : { name: \"email\" };\n}\n\n/**\n * Pure transition function of the default flow. Events that do not apply to\n * the current step leave it unchanged.\n */\nexport function reduceReturnsStep(\n step: ReturnsStep,\n event: ReturnsStepEvent,\n): ReturnsStep {\n switch (event.type) {\n case \"SESSION_EXPIRED\":\n // Email and code do not need a session; keep a pending verification.\n return stepRequiresSession(step.name) ? { name: \"email\" } : step;\n case \"CODE_SENT\":\n return step.name === \"email\" ? { name: \"code\" } : step;\n case \"AUTHENTICATED\":\n return step.name === \"email\" || step.name === \"code\"\n ? { name: \"orders\" }\n : step;\n case \"SELECT_ORDER\":\n return step.name === \"orders\"\n ? { name: \"order\", orderId: event.orderId }\n : step;\n case \"REVIEW\":\n return step.name === \"order\"\n ? {\n name: \"confirmation\",\n orderId: step.orderId,\n items: event.items,\n note: event.note,\n }\n : step;\n case \"SUBMITTED\":\n return step.name === \"confirmation\"\n ? { name: \"result\", returnId: event.returnId }\n : step;\n case \"OPEN_MY_RETURNS\":\n return step.name === \"orders\" || step.name === \"result\"\n ? { name: \"myReturns\" }\n : step;\n case \"SELECT_RETURN\":\n return step.name === \"myReturns\"\n ? { name: \"myReturn\", returnId: event.returnId }\n : step;\n case \"CONTINUE\":\n return step.name === \"result\" ? { name: \"orders\" } : step;\n case \"BACK\":\n switch (step.name) {\n case \"code\":\n return { name: \"email\" };\n case \"order\":\n case \"myReturns\":\n return { name: \"orders\" };\n case \"confirmation\":\n return {\n name: \"order\",\n orderId: step.orderId,\n items: step.items,\n note: step.note,\n };\n case \"myReturn\":\n return { name: \"myReturns\" };\n default:\n return step;\n }\n }\n}\n\nconst STEP_NUMBERS: Partial<Record<ReturnsStepName, number>> = {\n email: 1,\n code: 2,\n orders: 3,\n order: 4,\n confirmation: 5,\n result: 6,\n};\n\nexport const RETURNS_STEP_COUNT = 6;\n\n/** Position of a step in the return flow, `undefined` for the \"my returns\" views. */\nexport function returnsStepNumber(step: ReturnsStepName): number | undefined {\n return STEP_NUMBERS[step];\n}\n","import { useEffect, useReducer, useRef } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport {\n LoginBrandLogo,\n type LoginLogoOptions,\n} from \"@/src/ui/email-code-login/LoginBrandLogo\";\nimport { useReturnsSlot } from \"./appearance.context\";\nimport { ReturnsCodeStep, ReturnsEmailStep } from \"./AuthSteps\";\nimport { SkeletonRows } from \"./internal\";\nimport { ReturnsMyReturnDetail, ReturnsMyReturnsList } from \"./MyReturns\";\nimport {\n ReturnsConfirmation,\n ReturnsOrderDetail,\n ReturnsOrderList,\n ReturnsResult,\n} from \"./OrderSteps\";\nimport {\n ReturnsProvider,\n useReturnsContext,\n type ReturnsProviderProps,\n} from \"./ReturnsProvider\";\nimport {\n initialReturnsStep,\n reduceReturnsStep,\n RETURNS_STEP_COUNT,\n returnsStepNumber,\n} from \"./state-machine\";\nimport { useReturnsLocale, useReturnsText } from \"./texts.context\";\n\n/**\n * Props of {@link BitsnapReturns}. `showLogo`, `logoUrl` and `logoDarkUrl` set\n * the shop logo above the e-mail and code steps: by default the logo from the\n * shop settings, or Bitsnap's when the shop has none.\n */\nexport type BitsnapReturnsProps = Omit<ReturnsProviderProps, \"children\"> &\n LoginLogoOptions;\n\nfunction StepIndicator({ current }: { current: number }) {\n const text = useReturnsText();\n const slot = useReturnsSlot(\"stepIndicator\");\n\n return (\n <p\n data-bitsnap-returns-slot=\"stepIndicator\"\n className={cn(\"text-xs\", slot.className)}\n style={slot.style}\n >\n {text(\"stepIndicator\", { current, total: RETURNS_STEP_COUNT })}\n </p>\n );\n}\n\n/** Default step router. All transitions come from the pure state machine. */\nfunction ReturnsRouter({\n panelToken,\n logo,\n}: {\n panelToken: boolean;\n logo: LoginLogoOptions;\n}) {\n const { status, challenge, projectID } = useReturnsContext(\"BitsnapReturns\");\n const locale = useReturnsLocale();\n const [step, dispatch] = useReducer(\n reduceReturnsStep,\n initialReturnsStep(false),\n );\n\n // A valid session (verified code, stored session, exchanged panel token)\n // moves on to the orders; a dropped one returns to the start.\n useEffect(() => {\n if (status === \"authenticated\") {\n dispatch({ type: \"AUTHENTICATED\" });\n } else if (status === \"anonymous\") {\n dispatch({ type: \"SESSION_EXPIRED\" });\n }\n }, [status]);\n\n // A verification that was pending before a reload or an app switch returns\n // to the code step once, when the stored state has been read.\n const restored = useRef(false);\n useEffect(() => {\n if (restored.current || status === \"hydrating\") {\n return;\n }\n restored.current = true;\n if (status === \"anonymous\" && challenge != null) {\n dispatch({ type: \"CODE_SENT\" });\n }\n }, [status, challenge]);\n\n // Without a panel token the server render and the first client render show\n // the email step; a stored session switches to the orders after hydration.\n if (status === \"exchanging\" || (status === \"hydrating\" && panelToken)) {\n return <SkeletonRows />;\n }\n\n const stepNumber = returnsStepNumber(step.name);\n\n // The logo sits above the step indicator, and stays mounted between the\n // e-mail and the code step; the steps themselves then show none.\n const loginStep = step.name === \"email\" || step.name === \"code\";\n\n return (\n <div className=\"flex flex-col gap-4\">\n {loginStep && (\n <LoginBrandLogo projectId={projectID} locale={locale} {...logo} />\n )}\n {stepNumber != null && <StepIndicator current={stepNumber} />}\n {step.name === \"email\" && (\n <ReturnsEmailStep\n showLogo={false}\n onSubmitted={() => dispatch({ type: \"CODE_SENT\" })}\n />\n )}\n {step.name === \"code\" && (\n <ReturnsCodeStep\n showLogo={false}\n onVerified={() => dispatch({ type: \"AUTHENTICATED\" })}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"orders\" && (\n <ReturnsOrderList\n showLogout={!panelToken}\n onSelectOrder={(orderId) =>\n dispatch({ type: \"SELECT_ORDER\", orderId })\n }\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"order\" && (\n <ReturnsOrderDetail\n orderId={step.orderId}\n initialItems={step.items}\n initialNote={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onContinue={({ items, note }) =>\n dispatch({ type: \"REVIEW\", items, note })\n }\n />\n )}\n {step.name === \"confirmation\" && (\n <ReturnsConfirmation\n orderId={step.orderId}\n items={step.items}\n note={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onSubmitted={(returnId) =>\n dispatch({ type: \"SUBMITTED\", returnId })\n }\n />\n )}\n {step.name === \"result\" && (\n <ReturnsResult\n returnId={step.returnId}\n onContinue={() => dispatch({ type: \"CONTINUE\" })}\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"myReturns\" && (\n <ReturnsMyReturnsList\n onSelectReturn={(returnId) =>\n dispatch({ type: \"SELECT_RETURN\", returnId })\n }\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"myReturn\" && (\n <ReturnsMyReturnDetail\n returnId={step.returnId}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n </div>\n );\n}\n\n/**\n * Customer return flow: email, code, orders, line selection, confirmation and\n * result, plus the list of earlier returns. It is `ReturnsProvider` with the\n * default step router; compose your own page from the step components to\n * change the layout.\n *\n * ```tsx\n * <BitsnapReturns projectID=\"…\" appearance={brand} texts={{ emailStepTitle: \"Return a product\" }} />\n * ```\n */\nexport function BitsnapReturns({\n showLogo,\n logoUrl,\n logoDarkUrl,\n ...props\n}: BitsnapReturnsProps) {\n return (\n <ReturnsProvider {...props}>\n <ReturnsRouter\n panelToken={props.panelAccessToken != null && props.panelAccessToken !== \"\"}\n logo={{ showLogo, logoUrl, logoDarkUrl }}\n />\n </ReturnsProvider>\n );\n}\n"],"mappings":"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","names":["STEPS_WITH_SESSION","stepRequiresSession","step","initialReturnsStep","hasSession","reduceReturnsStep","event","STEP_NUMBERS","RETURNS_STEP_COUNT","returnsStepNumber","useEffect","useReducer","useRef","jsx","jsxs","StepIndicator","current","text","useReturnsText","slot","useReturnsSlot","cn","RETURNS_STEP_COUNT","ReturnsRouter","panelToken","logo","status","challenge","projectID","useReturnsContext","locale","useReturnsLocale","step","dispatch","useReducer","reduceReturnsStep","initialReturnsStep","useEffect","restored","useRef","SkeletonRows","stepNumber","returnsStepNumber","loginStep","LoginBrandLogo","ReturnsEmailStep","ReturnsCodeStep","ReturnsOrderList","orderId","ReturnsOrderDetail","items","note","ReturnsConfirmation","returnId","ReturnsResult","ReturnsMyReturnsList","ReturnsMyReturnDetail","BitsnapReturns","showLogo","logoUrl","logoDarkUrl","props","ReturnsProvider"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkW3RGQYPDjs = require('./chunk-W3RGQYPD.js');var Oe=Symbol.for("bitsnap.pageViews");function ye(e){let t=e;return t[Oe]??={path:null,starters:new Set,watching:!1}}function De(e,t){let n=()=>{try{t()}catch (e2){}};for(let o of["pushState","replaceState"]){let a=e.history[o];e.history[o]=function(...i){let c=a.apply(this,i);return n(),c}}e.addEventListener("popstate",n)}function A(e,t=window){try{let n=ye(t),o=()=>e();n.watching||(n.watching=!0,De(t,()=>{let i=t.location.pathname;i===n.path||n.starters.size===0||(n.path=i,_optionalChain([n, 'access', _2 => _2.starters, 'access', _3 => _3.values, 'call', _4 => _4(), 'access', _5 => _5.next, 'call', _6 => _6(), 'access', _7 => _7.value, 'optionalCall', _8 => _8()]))})),n.starters.add(o);let a=t.location.pathname;return a!==n.path&&(n.path=a,o()),()=>void n.starters.delete(o)}catch (e3){return()=>{}}}function ge(e=window){let t=ye(e);t.path=null,t.starters.clear()}var ve="1.15.0";function I(e){let t=new Uint8Array(e),n=typeof crypto<"u"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")n.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);return t}var me="X-Bitsnap-Visitor",$e=390*24*60*60,Me=/^[A-Za-z0-9_-]{22}$/;function R(e){return e.BitsnapConsent}function je(e,t){for(let n of e.cookie.split(";")){let o=n.indexOf("=");if(o!==-1&&n.slice(0,o).trim()===t)return n.slice(o+1).trim()}return null}function He(e){let t=e.toLowerCase();return t==="bitsnap.pl"||t.endsWith(".bitsnap.pl")}function F(e,t){try{let n=R(e);if(!n)return!1;if(n.scope==="project")return n.projectKey===t;let o=He(e.location.hostname);return n.scope==="global"?!o:!1}catch (e4){return!1}}function J(e,t){try{return _optionalChain([R, 'call', _9 => _9(e), 'optionalAccess', _10 => _10.get, 'call', _11 => _11(), 'optionalAccess', _12 => _12.c, 'access', _13 => _13.analytics])===!0&&F(e,t)}catch (e5){return!1}}function he(){let e="";return I(16).forEach(t=>e+=String.fromCharCode(t)),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ee(e,t){try{return je(e,_chunkW3RGQYPDjs.g.call(void 0, t))}catch (e6){return null}}function B(e,t){let n=Ee(e,t);return n!==null&&Me.test(n)?n:null}function ke(e,t,n){try{let o=e.document,a=`${_chunkW3RGQYPDjs.g.call(void 0, t)}=${n}; Max-Age=${$e}; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");for(let i of _chunkW3RGQYPDjs.o.call(void 0, e.location.hostname).reverse())if(o.cookie=`${a}; Domain=${i}`,B(o,t)===n)return;o.cookie=a}catch (e7){}}function be(e,t){try{let n=e.document;if(Ee(n,t)===null)return;let o=`${_chunkW3RGQYPDjs.g.call(void 0, t)}=; Max-Age=0; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");n.cookie=o;for(let a of _chunkW3RGQYPDjs.o.call(void 0, e.location.hostname))n.cookie=`${o}; Domain=${a}`}catch (e8){}}function N(e,t){try{let n=e.navigator;return _optionalChain([n, 'optionalAccess', _14 => _14.globalPrivacyControl])===!0||_optionalChain([n, 'optionalAccess', _15 => _15.webdriver])===!0?null:J(e,t)?B(e.document,t):null}catch (e9){return null}}var Ue="https://collect.bitsnap.pl",Ke=5e3,Ge=20,Te=32*1024,ze=60*1024,xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _e(e){return typeof TextEncoder=="function"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}var y={track(){},page(){},clientId:()=>null,flush(){},setEnabled(){},onEvent:()=>()=>{},configure(){},destroy(){}};function Ye(e=Date.now()){let t=I(16),n=e;for(let a=5;a>=0;a--)t[a]=n%256,n=Math.floor(n/256);t[6]=t[6]&15|112,t[8]=t[8]&63|128;let o=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Fe(){return Array.from(I(16),e=>Ce[e%Ce.length]).join("")}function Je(e,t,n=!1){let o=_e(JSON.stringify({k:e,events:[]})),a=[],i=[],c=o,s=()=>{i.length>0&&a.push({body:JSON.stringify({k:e,events:i}),bytes:c,count:i.length}),i=[],c=o};for(let u of t){let l=_e(JSON.stringify(u));o+l>Te||((i.length>=_chunkW3RGQYPDjs.a.maxBatchEvents||c+l+(i.length>0?1:0)>Te)&&s(),c+=l+(i.length>0?1:0),i.push(u))}if(s(),n){let u=0,l=a.length;for(;l>0&&u+a[l-1].bytes<=ze;)u+=a[l-1].bytes,l--;a=a.slice(l)}return a}function Xe(e){try{return typeof window>"u"||typeof document>"u"?y:qe(e,window)}catch (e10){return y}}function qe(e,t){let n=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => (""))),o=!!e.debug,a=(...r)=>{o&&console.warn("[bitsnap analytics]",...r)};if(!n)return a("invalid projectKey, tracking is off"),y;let i=n,c=r=>`${(r||Ue).replace(/\/+$/,"")}/e`,s=c(e.endpoint),u=_nullishCoalesce(e.source, () => ("sdk_react")),l=_nullishCoalesce(e.channel, () => ("embed")),b=`bitsnap-react@${ve}`,M=Fe(),T=_chunkW3RGQYPDjs.e.call(void 0, t.location.href),j=_nullishCoalesce(e.env, () => ("live"));if(!e.env)try{new URLSearchParams(t.location.search).has("test")&&(j="test")}catch (e11){}let Le=_chunkW3RGQYPDjs.f.call(void 0, document.referrer),H=e.enabled!==!1,ee=null,Re=0,p=[],h=null,C=new Set;e.onEvent&&C.add(e.onEvent);let E=[],g,m=!0;function W(){let r=R(t);!r||r===g||(g=r,m=!r.ready,_optionalChain([r, 'access', _16 => _16.ready, 'optionalAccess', _17 => _17.then, 'call', _18 => _18(()=>{g===r&&(m=!0,re())},()=>{g===r&&(m=!0)})]))}function te(){W();try{if(!g)return!1;let r=g.get();return!!g.denied&&g.denied("analytics")||!!r&&r.c.analytics===!1}catch (e12){return!1}}function ne(r){C.forEach(f=>{try{f(r)}catch (e13){}})}function U(r){try{if(W(),!g||!F(t,i))return;J(t,i)?P()&&B(t.document,i)===null&&ke(t,i,he()):r&&be(t,i)}catch (e14){}}function re(){if(U(!0),te())p=[],E=[],w();else{if(m&&E.length>0){let r=E;E=[],r.forEach(ne)}p.length>0&&x()}}function P(){if(!H)return!1;let r=t.navigator;return r&&(r.globalPrivacyControl===!0||r.webdriver===!0)?!1:!te()}function w(){h!==null&&clearTimeout(h),h=null}function Be(){h===null&&(h=setTimeout(()=>{h=null,x()},Ke),_optionalChain([h, 'access', _19 => _19.unref, 'optionalCall', _20 => _20()]))}function Ne(r){try{if(typeof fetch=="function"){fetch(s,{method:"POST",body:r,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{});return}}catch (e15){}try{let f=t.navigator;f&&typeof f.sendBeacon=="function"&&f.sendBeacon(s,new Blob([r],{type:"text/plain"}))}catch (e16){}}function x(r=!1){try{if(w(),p.length===0)return;if(!P()){p=[];return}if(!m)return;U(m);let f=N(t,i),d=f?p.map(k=>({...k,client_id:f})):p;p=[],Je(i,d,r).forEach(k=>Ne(k.body))}catch (e17){}}function oe(r,f,d){if(!P())return;let k=_chunkW3RGQYPDjs.h.call(void 0, r,f);if(!k.ok){a("dropped",r,k.reason);return}let se=_chunkW3RGQYPDjs.e.call(void 0, t.location.href),K={event_id:_optionalChain([d, 'optionalAccess', _21 => _21.event_id])&&xe.test(d.event_id)?d.event_id:Ye(),event:r,ts:Date.now(),schema_version:1,env:j,source:u,channel:l,sdk:b,page_id:M,page_type:_optionalChain([d, 'optionalAccess', _22 => _22.page_type])!==void 0?d.page_type:ee,host:_nullishCoalesce(_optionalChain([se, 'optionalAccess', _23 => _23.host]), () => (null)),path:_optionalChain([d, 'optionalAccess', _24 => _24.path])?_chunkW3RGQYPDjs.d.call(void 0, d.path.split(/[?#]/)[0]):_nullishCoalesce(_optionalChain([se, 'optionalAccess', _25 => _25.path]), () => (null)),referrer_host:Le,utm_source:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _26 => _26.utm_source]), () => (null)),utm_medium:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _27 => _27.utm_medium]), () => (null)),utm_campaign:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _28 => _28.utm_campaign]), () => (null)),utm_content:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _29 => _29.utm_content]), () => (null)),utm_term:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _30 => _30.utm_term]), () => (null)),ref_code:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _31 => _31.ref_code]), () => (null)),product_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _32 => _32.product_id]), () => (null)),variant_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _33 => _33.variant_id]), () => (null)),order_ref:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _34 => _34.order_ref]), () => (null)),props:k.props};_optionalChain([d, 'optionalAccess', _35 => _35.event_id])&&!xe.test(d.event_id)&&a("ignored invalid event_id",r),u==="dashboard"&&e.visitorId&&(K.visitor_id=e.visitorId);let ce=_chunkW3RGQYPDjs.i.call(void 0, K);if(!ce.ok){a("dropped",r,ce.reason);return}let G=K;m?ne(G):E.push(G),p.push(G),p.length>=Ge?x():Be()}let ie=()=>x(!0),ae=()=>{document.visibilityState==="hidden"&&x(!0)},S=()=>re();return t.addEventListener("pagehide",ie),document.addEventListener("visibilitychange",ae),t.addEventListener("bitsnap:consent",S),t.addEventListener("bitsnap:consent:ready",S),W(),U(m),{track(r,f,d){try{oe(r,f,d)}catch (e18){}},page(r,f){try{r!==void 0&&(ee=r),oe("page_view",{landing:Re++===0},f)}catch (e19){}},clientId(r){try{return r!==void 0&&_chunkW3RGQYPDjs.c.call(void 0, r)!==i?null:P()?N(t,i):null}catch (e20){return null}},flush:()=>x(),setEnabled(r){H=!!r,H||(p=[],E=[],w())},configure(r){try{(r.env==="live"||r.env==="test")&&(j=r.env),typeof r.endpoint=="string"&&r.endpoint&&(s=c(r.endpoint))}catch (e21){}},onEvent(r){return C.add(r),()=>void C.delete(r)},destroy(){p=[],E=[],w(),C.clear(),t.removeEventListener("pagehide",ie),document.removeEventListener("visibilitychange",ae),t.removeEventListener("bitsnap:consent",S),t.removeEventListener("bitsnap:consent:ready",S)}}}var v,O=null;function D(e){if(!v){let t=Xe(e);return t===y||(v=t,O=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => ("")))),t}try{let t=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => ("")));t!==O&&e.debug&&console.warn("[bitsnap analytics]","tracker already started for another projectKey, ignoring",e.projectKey),t===O&&((e.env||e.endpoint)&&v.configure({env:e.env,endpoint:e.endpoint}),e.enabled!=null&&v.setEnabled(e.enabled))}catch (e22){}return v}function Ae(){return v}function xt(){typeof window<"u"&&ge(window),_optionalChain([v, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]),v=void 0,O=null}function _t(e){try{if(typeof window>"u")return{};let t=v,n=null;if(t)n=t.clientId(e);else{let o=e?_chunkW3RGQYPDjs.c.call(void 0, e):null;n=o?N(window,o):null}return n?{[me]:n}:{}}catch (e23){return{}}}var _react = require('react');var nt={track:y.track,page:y.page},Pe=_react.createContext.call(void 0, nt);function St({projectKey:e,env:t,enabled:n,endpoint:o,onEvent:a,autoPageViews:i,children:c}){let s=_react.useMemo.call(void 0, ()=>D({projectKey:e,env:t,endpoint:o,enabled:n}),[e,t,o]),u=_react.useRef.call(void 0, a);u.current=a,_chunkW3RGQYPDjs.q.call(void 0, ()=>{s.setEnabled(n!==!1)},[s,n]),_chunkW3RGQYPDjs.q.call(void 0, ()=>{if(!(i===!1||n===!1||s===y))return A(()=>s.page(null))},[s,i,n]),_chunkW3RGQYPDjs.q.call(void 0, ()=>s.onEvent(b=>_optionalChain([u, 'access', _38 => _38.current, 'optionalCall', _39 => _39(b)])),[s]);let l=_react.useMemo.call(void 0, ()=>({track:s.track.bind(s),page:s.page.bind(s)}),[s]);return _react.createElement.call(void 0, Pe.Provider,{value:l},c)}function we(){return _react.useContext.call(void 0, Pe)}var $={track(){}},X=null;function lt(e){let t=Symbol("bitsnap-instrument");function n(){if(typeof window>"u")return null;let{projectKey:i,analytics:c,provided:s}=e();return c===!1?null:s||(i?D({projectKey:i,source:"sdk_react",channel:"embed",env:typeof c=="object"?c.env:void 0}):null)}let o={track(i,c,s){try{let u=n();if(!u)return;let{analytics:l,pageType:b}=e(),M=b&&_optionalChain([s, 'optionalAccess', _40 => _40.page_type])===void 0?{...s,page_type:b}:s;X=typeof l=="object"&&l.onEvent?t:null,u.track(i,c,M)}catch (e24){}finally{X=null}}};function a(){try{if(!n())return()=>{};let i=Ae();if(!i)return()=>{};let c=e().provided?()=>{}:A(()=>i.page(_nullishCoalesce(e().pageType, () => (null)))),s=i.onEvent(u=>{if(X===t)try{let{analytics:l}=e();typeof l=="object"&&_optionalChain([l, 'access', _41 => _41.onEvent, 'optionalCall', _42 => _42(u)])}catch (e25){}});return()=>{c(),s()}}catch (e26){return()=>{}}}return{instrument:o,attach:a}}var Z=_react.createContext.call(void 0, null);function Nt({value:e,children:t}){return _react.createElement.call(void 0, Z.Provider,{value:e},t)}function Ot(){return _nullishCoalesce(_react.useContext.call(void 0, Z), () => ($))}function Dt(e,t,n){let o=_react.useContext.call(void 0, Z),a=we(),i=a.track===y.track?null:a,c=_react.useRef.call(void 0, {projectKey:e,analytics:t,pageType:n,provided:i});c.current={projectKey:e,analytics:t,pageType:n,provided:i};let s=_react.useMemo.call(void 0, ()=>lt(()=>c.current),[]),u=t===void 0&&o!==null,l=typeof t=="object"&&!!t.onEvent;return _react.useLayoutEffect.call(void 0, ()=>{if(!u)return s.attach()},[s,u,l,e]),u?o:s.instrument}var Q=$;function Se(e){Q=_nullishCoalesce(e, () => ($))}var q=0;function $t(){return q>0?$:Q}async function Mt(e){q++;try{return await e()}finally{q--}}function jt(e){_react.useEffect.call(void 0, ()=>(Se(e),()=>{Q===e&&Se(null)}),[e])}function Ht(e){let t=Number.isFinite(e)?Math.max(0,Math.min(100,e)):0;return t>=100?"100":t>=75?"75-99":t>=50?"50-74":t>=25?"25-49":"0-24"}function Wt(e,t){let n=[];for(let o of[25,50,75,100])e>=o&&!t.has(o)&&(t.add(o),n.push(o));return n}exports.a = ve; exports.b = A; exports.c = Ue; exports.d = Xe; exports.e = D; exports.f = Ae; exports.g = xt; exports.h = _t; exports.i = St; exports.j = we; exports.k = $; exports.l = Nt; exports.m = Ot; exports.n = Dt; exports.o = $t; exports.p = Mt; exports.q = jt; exports.r = Ht; exports.s = Wt;
2
- //# sourceMappingURL=chunk-MG6VV5J2.js.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkW3RGQYPDjs = require('./chunk-W3RGQYPD.js');var Oe=Symbol.for("bitsnap.pageViews");function ye(e){let t=e;return t[Oe]??={path:null,starters:new Set,watching:!1}}function De(e,t){let n=()=>{try{t()}catch (e2){}};for(let o of["pushState","replaceState"]){let a=e.history[o];e.history[o]=function(...i){let c=a.apply(this,i);return n(),c}}e.addEventListener("popstate",n)}function A(e,t=window){try{let n=ye(t),o=()=>e();n.watching||(n.watching=!0,De(t,()=>{let i=t.location.pathname;i===n.path||n.starters.size===0||(n.path=i,_optionalChain([n, 'access', _2 => _2.starters, 'access', _3 => _3.values, 'call', _4 => _4(), 'access', _5 => _5.next, 'call', _6 => _6(), 'access', _7 => _7.value, 'optionalCall', _8 => _8()]))})),n.starters.add(o);let a=t.location.pathname;return a!==n.path&&(n.path=a,o()),()=>void n.starters.delete(o)}catch (e3){return()=>{}}}function ge(e=window){let t=ye(e);t.path=null,t.starters.clear()}var ve="1.17.0";function I(e){let t=new Uint8Array(e),n=typeof crypto<"u"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")n.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);return t}var me="X-Bitsnap-Visitor",$e=390*24*60*60,Me=/^[A-Za-z0-9_-]{22}$/;function R(e){return e.BitsnapConsent}function je(e,t){for(let n of e.cookie.split(";")){let o=n.indexOf("=");if(o!==-1&&n.slice(0,o).trim()===t)return n.slice(o+1).trim()}return null}function He(e){let t=e.toLowerCase();return t==="bitsnap.pl"||t.endsWith(".bitsnap.pl")}function F(e,t){try{let n=R(e);if(!n)return!1;if(n.scope==="project")return n.projectKey===t;let o=He(e.location.hostname);return n.scope==="global"?!o:!1}catch (e4){return!1}}function J(e,t){try{return _optionalChain([R, 'call', _9 => _9(e), 'optionalAccess', _10 => _10.get, 'call', _11 => _11(), 'optionalAccess', _12 => _12.c, 'access', _13 => _13.analytics])===!0&&F(e,t)}catch (e5){return!1}}function he(){let e="";return I(16).forEach(t=>e+=String.fromCharCode(t)),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ee(e,t){try{return je(e,_chunkW3RGQYPDjs.g.call(void 0, t))}catch (e6){return null}}function B(e,t){let n=Ee(e,t);return n!==null&&Me.test(n)?n:null}function ke(e,t,n){try{let o=e.document,a=`${_chunkW3RGQYPDjs.g.call(void 0, t)}=${n}; Max-Age=${$e}; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");for(let i of _chunkW3RGQYPDjs.o.call(void 0, e.location.hostname).reverse())if(o.cookie=`${a}; Domain=${i}`,B(o,t)===n)return;o.cookie=a}catch (e7){}}function be(e,t){try{let n=e.document;if(Ee(n,t)===null)return;let o=`${_chunkW3RGQYPDjs.g.call(void 0, t)}=; Max-Age=0; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");n.cookie=o;for(let a of _chunkW3RGQYPDjs.o.call(void 0, e.location.hostname))n.cookie=`${o}; Domain=${a}`}catch (e8){}}function N(e,t){try{let n=e.navigator;return _optionalChain([n, 'optionalAccess', _14 => _14.globalPrivacyControl])===!0||_optionalChain([n, 'optionalAccess', _15 => _15.webdriver])===!0?null:J(e,t)?B(e.document,t):null}catch (e9){return null}}var Ue="https://collect.bitsnap.pl",Ke=5e3,Ge=20,Te=32*1024,ze=60*1024,xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _e(e){return typeof TextEncoder=="function"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}var y={track(){},page(){},clientId:()=>null,flush(){},setEnabled(){},onEvent:()=>()=>{},configure(){},destroy(){}};function Ye(e=Date.now()){let t=I(16),n=e;for(let a=5;a>=0;a--)t[a]=n%256,n=Math.floor(n/256);t[6]=t[6]&15|112,t[8]=t[8]&63|128;let o=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Fe(){return Array.from(I(16),e=>Ce[e%Ce.length]).join("")}function Je(e,t,n=!1){let o=_e(JSON.stringify({k:e,events:[]})),a=[],i=[],c=o,s=()=>{i.length>0&&a.push({body:JSON.stringify({k:e,events:i}),bytes:c,count:i.length}),i=[],c=o};for(let u of t){let l=_e(JSON.stringify(u));o+l>Te||((i.length>=_chunkW3RGQYPDjs.a.maxBatchEvents||c+l+(i.length>0?1:0)>Te)&&s(),c+=l+(i.length>0?1:0),i.push(u))}if(s(),n){let u=0,l=a.length;for(;l>0&&u+a[l-1].bytes<=ze;)u+=a[l-1].bytes,l--;a=a.slice(l)}return a}function Xe(e){try{return typeof window>"u"||typeof document>"u"?y:qe(e,window)}catch (e10){return y}}function qe(e,t){let n=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => (""))),o=!!e.debug,a=(...r)=>{o&&console.warn("[bitsnap analytics]",...r)};if(!n)return a("invalid projectKey, tracking is off"),y;let i=n,c=r=>`${(r||Ue).replace(/\/+$/,"")}/e`,s=c(e.endpoint),u=_nullishCoalesce(e.source, () => ("sdk_react")),l=_nullishCoalesce(e.channel, () => ("embed")),b=`bitsnap-react@${ve}`,M=Fe(),T=_chunkW3RGQYPDjs.e.call(void 0, t.location.href),j=_nullishCoalesce(e.env, () => ("live"));if(!e.env)try{new URLSearchParams(t.location.search).has("test")&&(j="test")}catch (e11){}let Le=_chunkW3RGQYPDjs.f.call(void 0, document.referrer),H=e.enabled!==!1,ee=null,Re=0,p=[],h=null,C=new Set;e.onEvent&&C.add(e.onEvent);let E=[],g,m=!0;function W(){let r=R(t);!r||r===g||(g=r,m=!r.ready,_optionalChain([r, 'access', _16 => _16.ready, 'optionalAccess', _17 => _17.then, 'call', _18 => _18(()=>{g===r&&(m=!0,re())},()=>{g===r&&(m=!0)})]))}function te(){W();try{if(!g)return!1;let r=g.get();return!!g.denied&&g.denied("analytics")||!!r&&r.c.analytics===!1}catch (e12){return!1}}function ne(r){C.forEach(f=>{try{f(r)}catch (e13){}})}function U(r){try{if(W(),!g||!F(t,i))return;J(t,i)?P()&&B(t.document,i)===null&&ke(t,i,he()):r&&be(t,i)}catch (e14){}}function re(){if(U(!0),te())p=[],E=[],w();else{if(m&&E.length>0){let r=E;E=[],r.forEach(ne)}p.length>0&&x()}}function P(){if(!H)return!1;let r=t.navigator;return r&&(r.globalPrivacyControl===!0||r.webdriver===!0)?!1:!te()}function w(){h!==null&&clearTimeout(h),h=null}function Be(){h===null&&(h=setTimeout(()=>{h=null,x()},Ke),_optionalChain([h, 'access', _19 => _19.unref, 'optionalCall', _20 => _20()]))}function Ne(r){try{if(typeof fetch=="function"){fetch(s,{method:"POST",body:r,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{});return}}catch (e15){}try{let f=t.navigator;f&&typeof f.sendBeacon=="function"&&f.sendBeacon(s,new Blob([r],{type:"text/plain"}))}catch (e16){}}function x(r=!1){try{if(w(),p.length===0)return;if(!P()){p=[];return}if(!m)return;U(m);let f=N(t,i),d=f?p.map(k=>({...k,client_id:f})):p;p=[],Je(i,d,r).forEach(k=>Ne(k.body))}catch (e17){}}function oe(r,f,d){if(!P())return;let k=_chunkW3RGQYPDjs.h.call(void 0, r,f);if(!k.ok){a("dropped",r,k.reason);return}let se=_chunkW3RGQYPDjs.e.call(void 0, t.location.href),K={event_id:_optionalChain([d, 'optionalAccess', _21 => _21.event_id])&&xe.test(d.event_id)?d.event_id:Ye(),event:r,ts:Date.now(),schema_version:1,env:j,source:u,channel:l,sdk:b,page_id:M,page_type:_optionalChain([d, 'optionalAccess', _22 => _22.page_type])!==void 0?d.page_type:ee,host:_nullishCoalesce(_optionalChain([se, 'optionalAccess', _23 => _23.host]), () => (null)),path:_optionalChain([d, 'optionalAccess', _24 => _24.path])?_chunkW3RGQYPDjs.d.call(void 0, d.path.split(/[?#]/)[0]):_nullishCoalesce(_optionalChain([se, 'optionalAccess', _25 => _25.path]), () => (null)),referrer_host:Le,utm_source:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _26 => _26.utm_source]), () => (null)),utm_medium:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _27 => _27.utm_medium]), () => (null)),utm_campaign:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _28 => _28.utm_campaign]), () => (null)),utm_content:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _29 => _29.utm_content]), () => (null)),utm_term:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _30 => _30.utm_term]), () => (null)),ref_code:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _31 => _31.ref_code]), () => (null)),product_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _32 => _32.product_id]), () => (null)),variant_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _33 => _33.variant_id]), () => (null)),order_ref:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _34 => _34.order_ref]), () => (null)),props:k.props};_optionalChain([d, 'optionalAccess', _35 => _35.event_id])&&!xe.test(d.event_id)&&a("ignored invalid event_id",r),u==="dashboard"&&e.visitorId&&(K.visitor_id=e.visitorId);let ce=_chunkW3RGQYPDjs.i.call(void 0, K);if(!ce.ok){a("dropped",r,ce.reason);return}let G=K;m?ne(G):E.push(G),p.push(G),p.length>=Ge?x():Be()}let ie=()=>x(!0),ae=()=>{document.visibilityState==="hidden"&&x(!0)},S=()=>re();return t.addEventListener("pagehide",ie),document.addEventListener("visibilitychange",ae),t.addEventListener("bitsnap:consent",S),t.addEventListener("bitsnap:consent:ready",S),W(),U(m),{track(r,f,d){try{oe(r,f,d)}catch (e18){}},page(r,f){try{r!==void 0&&(ee=r),oe("page_view",{landing:Re++===0},f)}catch (e19){}},clientId(r){try{return r!==void 0&&_chunkW3RGQYPDjs.c.call(void 0, r)!==i?null:P()?N(t,i):null}catch (e20){return null}},flush:()=>x(),setEnabled(r){H=!!r,H||(p=[],E=[],w())},configure(r){try{(r.env==="live"||r.env==="test")&&(j=r.env),typeof r.endpoint=="string"&&r.endpoint&&(s=c(r.endpoint))}catch (e21){}},onEvent(r){return C.add(r),()=>void C.delete(r)},destroy(){p=[],E=[],w(),C.clear(),t.removeEventListener("pagehide",ie),document.removeEventListener("visibilitychange",ae),t.removeEventListener("bitsnap:consent",S),t.removeEventListener("bitsnap:consent:ready",S)}}}var v,O=null;function D(e){if(!v){let t=Xe(e);return t===y||(v=t,O=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => ("")))),t}try{let t=_chunkW3RGQYPDjs.c.call(void 0, _nullishCoalesce(e.projectKey, () => ("")));t!==O&&e.debug&&console.warn("[bitsnap analytics]","tracker already started for another projectKey, ignoring",e.projectKey),t===O&&((e.env||e.endpoint)&&v.configure({env:e.env,endpoint:e.endpoint}),e.enabled!=null&&v.setEnabled(e.enabled))}catch (e22){}return v}function Ae(){return v}function xt(){typeof window<"u"&&ge(window),_optionalChain([v, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]),v=void 0,O=null}function _t(e){try{if(typeof window>"u")return{};let t=v,n=null;if(t)n=t.clientId(e);else{let o=e?_chunkW3RGQYPDjs.c.call(void 0, e):null;n=o?N(window,o):null}return n?{[me]:n}:{}}catch (e23){return{}}}var _react = require('react');var nt={track:y.track,page:y.page},Pe=_react.createContext.call(void 0, nt);function St({projectKey:e,env:t,enabled:n,endpoint:o,onEvent:a,autoPageViews:i,children:c}){let s=_react.useMemo.call(void 0, ()=>D({projectKey:e,env:t,endpoint:o,enabled:n}),[e,t,o]),u=_react.useRef.call(void 0, a);u.current=a,_chunkW3RGQYPDjs.q.call(void 0, ()=>{s.setEnabled(n!==!1)},[s,n]),_chunkW3RGQYPDjs.q.call(void 0, ()=>{if(!(i===!1||n===!1||s===y))return A(()=>s.page(null))},[s,i,n]),_chunkW3RGQYPDjs.q.call(void 0, ()=>s.onEvent(b=>_optionalChain([u, 'access', _38 => _38.current, 'optionalCall', _39 => _39(b)])),[s]);let l=_react.useMemo.call(void 0, ()=>({track:s.track.bind(s),page:s.page.bind(s)}),[s]);return _react.createElement.call(void 0, Pe.Provider,{value:l},c)}function we(){return _react.useContext.call(void 0, Pe)}var $={track(){}},X=null;function lt(e){let t=Symbol("bitsnap-instrument");function n(){if(typeof window>"u")return null;let{projectKey:i,analytics:c,provided:s}=e();return c===!1?null:s||(i?D({projectKey:i,source:"sdk_react",channel:"embed",env:typeof c=="object"?c.env:void 0}):null)}let o={track(i,c,s){try{let u=n();if(!u)return;let{analytics:l,pageType:b}=e(),M=b&&_optionalChain([s, 'optionalAccess', _40 => _40.page_type])===void 0?{...s,page_type:b}:s;X=typeof l=="object"&&l.onEvent?t:null,u.track(i,c,M)}catch (e24){}finally{X=null}}};function a(){try{if(!n())return()=>{};let i=Ae();if(!i)return()=>{};let c=e().provided?()=>{}:A(()=>i.page(_nullishCoalesce(e().pageType, () => (null)))),s=i.onEvent(u=>{if(X===t)try{let{analytics:l}=e();typeof l=="object"&&_optionalChain([l, 'access', _41 => _41.onEvent, 'optionalCall', _42 => _42(u)])}catch (e25){}});return()=>{c(),s()}}catch (e26){return()=>{}}}return{instrument:o,attach:a}}var Z=_react.createContext.call(void 0, null);function Nt({value:e,children:t}){return _react.createElement.call(void 0, Z.Provider,{value:e},t)}function Ot(){return _nullishCoalesce(_react.useContext.call(void 0, Z), () => ($))}function Dt(e,t,n){let o=_react.useContext.call(void 0, Z),a=we(),i=a.track===y.track?null:a,c=_react.useRef.call(void 0, {projectKey:e,analytics:t,pageType:n,provided:i});c.current={projectKey:e,analytics:t,pageType:n,provided:i};let s=_react.useMemo.call(void 0, ()=>lt(()=>c.current),[]),u=t===void 0&&o!==null,l=typeof t=="object"&&!!t.onEvent;return _react.useLayoutEffect.call(void 0, ()=>{if(!u)return s.attach()},[s,u,l,e]),u?o:s.instrument}var Q=$;function Se(e){Q=_nullishCoalesce(e, () => ($))}var q=0;function $t(){return q>0?$:Q}async function Mt(e){q++;try{return await e()}finally{q--}}function jt(e){_react.useEffect.call(void 0, ()=>(Se(e),()=>{Q===e&&Se(null)}),[e])}function Ht(e){let t=Number.isFinite(e)?Math.max(0,Math.min(100,e)):0;return t>=100?"100":t>=75?"75-99":t>=50?"50-74":t>=25?"25-49":"0-24"}function Wt(e,t){let n=[];for(let o of[25,50,75,100])e>=o&&!t.has(o)&&(t.add(o),n.push(o));return n}exports.a = ve; exports.b = A; exports.c = Ue; exports.d = Xe; exports.e = D; exports.f = Ae; exports.g = xt; exports.h = _t; exports.i = St; exports.j = we; exports.k = $; exports.l = Nt; exports.m = Ot; exports.n = Dt; exports.o = $t; exports.p = Mt; exports.q = jt; exports.r = Ht; exports.s = Wt;
2
+ //# sourceMappingURL=chunk-C3BBJOVV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-C3BBJOVV.js","../src/analytics/pageviews.ts","../src/version.ts","../src/analytics/random.ts","../src/analytics/visitor.ts"],"names":["REGISTRY","registry","win","holder","watchNavigation","onChange","check","name","original","args","result","startAutoPageViews","send","reg","starter","path","resetAutoPageViews","SDK_VERSION","randomBytes","n","bytes","c","i","VISITOR_HEADER","MAX_AGE_SECONDS","VISITOR_ID_RE","consentApi","readCookie","doc","part","index","isBitsnapHost","hostname","host","consentBelongsTo","projectKey","api","onBitsnap","analyticsGranted","newVisitorId","binary","byte","rawVisitorCookie","clientIdCookieName","readVisitorCookie","value","writeVisitorCookie","id","base"],"mappings":"AAAA,uuBAA2G,ICYrGA,EAAAA,CAAW,MAAA,CAAO,GAAA,CAAI,mBAAmB,CAAA,CAE/C,SAASC,EAAAA,CAASC,CAAAA,CAAuB,CACvC,IAAMC,CAAAA,CAASD,CAAAA,CACf,OAAQC,CAAAA,CAAOH,EAAQ,CAAA,GAAM,CAAE,IAAA,CAAM,IAAA,CAAM,QAAA,CAAU,IAAI,GAAA,CAAO,QAAA,CAAU,CAAA,CAAM,CAClF,CAGA,SAASI,EAAAA,CAAgBF,CAAAA,CAAaG,CAAAA,CAAsB,CAC1D,IAAMC,CAAAA,CAAQ,CAAA,CAAA,EAAM,CAClB,GAAI,CACFD,CAAAA,CAAS,CACX,CAAA,UAAQ,CAAC,CACX,CAAA,CACA,GAAA,CAAA,IAAWE,EAAAA,EAAQ,CAAC,WAAA,CAAa,cAAc,CAAA,CAAY,CACzD,IAAMC,CAAAA,CAAWN,CAAAA,CAAI,OAAA,CAAQK,CAAI,CAAA,CACjCL,CAAAA,CAAI,OAAA,CAAQK,CAAI,CAAA,CAAI,QAAA,CAAA,GAA4BE,CAAAA,CAAwC,CACtF,IAAMC,CAAAA,CAASF,CAAAA,CAAS,KAAA,CAAM,IAAA,CAAMC,CAAI,CAAA,CACxC,OAAAH,CAAAA,CAAM,CAAA,CACCI,CACT,CACF,CACAR,CAAAA,CAAI,gBAAA,CAAiB,UAAA,CAAYI,CAAK,CACxC,CAQO,SAASK,CAAAA,CAAmBC,CAAAA,CAAkBV,CAAAA,CAAc,MAAA,CAAoB,CACrF,GAAI,CACF,IAAMW,CAAAA,CAAMZ,EAAAA,CAASC,CAAG,CAAA,CAClBY,CAAAA,CAAU,CAAA,CAAA,EAAMF,CAAAA,CAAK,CAAA,CACtBC,CAAAA,CAAI,QAAA,EAAA,CACPA,CAAAA,CAAI,QAAA,CAAW,CAAA,CAAA,CACfT,EAAAA,CAAgBF,CAAAA,CAAK,CAAA,CAAA,EAAM,CACzB,IAAMa,CAAAA,CAAOb,CAAAA,CAAI,QAAA,CAAS,QAAA,CAEtBa,CAAAA,GAASF,CAAAA,CAAI,IAAA,EAAQA,CAAAA,CAAI,QAAA,CAAS,IAAA,GAAS,CAAA,EAAA,CAC/CA,CAAAA,CAAI,IAAA,CAAOE,CAAAA,iBACXF,CAAAA,qBAAI,QAAA,qBAAS,MAAA,mBAAO,CAAA,qBAAE,IAAA,mBAAK,CAAA,qBAAE,KAAA,0BAAA,CAAQ,GAAA,CACvC,CAAC,CAAA,CAAA,CAEHA,CAAAA,CAAI,QAAA,CAAS,GAAA,CAAIC,CAAO,CAAA,CACxB,IAAMC,CAAAA,CAAOb,CAAAA,CAAI,QAAA,CAAS,QAAA,CAC1B,OAAIa,CAAAA,GAASF,CAAAA,CAAI,IAAA,EAAA,CACfA,CAAAA,CAAI,IAAA,CAAOE,CAAAA,CACXD,CAAAA,CAAQ,CAAA,CAAA,CAEH,CAAA,CAAA,EAAM,KAAKD,CAAAA,CAAI,QAAA,CAAS,MAAA,CAAOC,CAAO,CAC/C,CAAA,UAAQ,CACN,MAAO,CAAA,CAAA,EAAM,CAAC,CAChB,CACF,CAGO,SAASE,EAAAA,CAAmBd,CAAAA,CAAc,MAAA,CAAQ,CACvD,IAAMW,CAAAA,CAAMZ,EAAAA,CAASC,CAAG,CAAA,CACxBW,CAAAA,CAAI,IAAA,CAAO,IAAA,CACXA,CAAAA,CAAI,QAAA,CAAS,KAAA,CAAM,CACrB,CCzEO,IAAMI,EAAAA,CAAc,QAAA,CCDpB,SAASC,CAAAA,CAAYC,CAAAA,CAAuB,CACjD,IAAMC,CAAAA,CAAQ,IAAI,UAAA,CAAWD,CAAC,CAAA,CACxBE,CAAAA,CAAI,OAAO,MAAA,CAAW,GAAA,CAAc,MAAA,CAAS,KAAA,CAAA,CACnD,EAAA,CAAIA,CAAAA,EAAK,OAAOA,CAAAA,CAAE,eAAA,EAAoB,UAAA,CAAYA,CAAAA,CAAE,eAAA,CAAgBD,CAAK,CAAA,CAAA,KACpE,GAAA,CAAA,IAASE,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAIH,CAAAA,CAAGG,CAAAA,EAAAA,CAAKF,CAAAA,CAAME,CAAC,CAAA,CAAI,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,CAAO,CAAA,CAAI,GAAG,CAAA,CAC1E,OAAOF,CACT,CCUO,IAAMG,EAAAA,CAAiB,mBAAA,CAExBC,EAAAA,CAAkB,GAAA,CAAM,EAAA,CAAK,EAAA,CAAK,EAAA,CAClCC,EAAAA,CAAgB,qBAAA,CAEf,SAASC,CAAAA,CAAWxB,CAAAA,CAAsC,CAC/D,OAAQA,CAAAA,CAAoD,cAC9D,CAEA,SAASyB,EAAAA,CAAWC,CAAAA,CAAerB,CAAAA,CAA6B,CAC9D,GAAA,CAAA,IAAWsB,EAAAA,GAAQD,CAAAA,CAAI,MAAA,CAAO,KAAA,CAAM,GAAG,CAAA,CAAG,CACxC,IAAME,CAAAA,CAAQD,CAAAA,CAAK,OAAA,CAAQ,GAAG,CAAA,CAC9B,EAAA,CAAIC,CAAAA,GAAU,CAAA,CAAA,EAAMD,CAAAA,CAAK,KAAA,CAAM,CAAA,CAAGC,CAAK,CAAA,CAAE,IAAA,CAAK,CAAA,GAAMvB,CAAAA,CAAM,OAAOsB,CAAAA,CAAK,KAAA,CAAMC,CAAAA,CAAQ,CAAC,CAAA,CAAE,IAAA,CAAK,CAC9F,CACA,OAAO,IACT,CAGA,SAASC,EAAAA,CAAcC,CAAAA,CAA2B,CAChD,IAAMC,CAAAA,CAAOD,CAAAA,CAAS,WAAA,CAAY,CAAA,CAClC,OAAOC,CAAAA,GAAS,YAAA,EAAgBA,CAAAA,CAAK,QAAA,CAAS,aAAa,CAC7D,CAOO,SAASC,CAAAA,CAAiBhC,CAAAA,CAAaiC,CAAAA,CAA6B,CACzE,GAAI,CACF,IAAMC,CAAAA,CAAMV,CAAAA,CAAWxB,CAAG,CAAA,CAC1B,EAAA,CAAI,CAACkC,CAAAA,CAAK,MAAO,CAAA,CAAA,CACjB,EAAA,CAAIA,CAAAA,CAAI,KAAA,GAAU,SAAA,CAAW,OAAOA,CAAAA,CAAI,UAAA,GAAeD,CAAAA,CACvD,IAAME,CAAAA,CAAYN,EAAAA,CAAc7B,CAAAA,CAAI,QAAA,CAAS,QAAQ,CAAA,CACrD,OAAIkC,CAAAA,CAAI,KAAA,GAAU,QAAA,CAAiB,CAACC,CAAAA,CAE7B,CAAA,CACT,CAAA,UAAQ,CACN,MAAO,CAAA,CACT,CACF,CAGO,SAASC,CAAAA,CAAiBpC,CAAAA,CAAaiC,CAAAA,CAA6B,CACzE,GAAI,CACF,uBAAOT,CAAAA,mBAAWxB,CAAG,CAAA,+BAAG,GAAA,qBAAI,CAAA,+BAAG,CAAA,uBAAE,WAAA,GAAc,CAAA,CAAA,EAAQgC,CAAAA,CAAiBhC,CAAAA,CAAKiC,CAAU,CACzF,CAAA,UAAQ,CACN,MAAO,CAAA,CACT,CACF,CAGO,SAASI,EAAAA,CAAAA,CAAuB,CACrC,IAAIC,CAAAA,CAAS,EAAA,CACb,OAAAtB,CAAAA,CAAY,EAAE,CAAA,CAAE,OAAA,CAASuB,CAAAA,EAAUD,CAAAA,EAAU,MAAA,CAAO,YAAA,CAAaC,CAAI,CAAE,CAAA,CAChE,IAAA,CAAKD,CAAM,CAAA,CAAE,OAAA,CAAQ,KAAA,CAAO,GAAG,CAAA,CAAE,OAAA,CAAQ,KAAA,CAAO,GAAG,CAAA,CAAE,OAAA,CAAQ,KAAA,CAAO,EAAE,CAC/E,CAGA,SAASE,EAAAA,CAAiBd,CAAAA,CAAeO,CAAAA,CAAmC,CAC1E,GAAI,CACF,OAAOR,EAAAA,CAAWC,CAAAA,CAAKe,gCAAAA,CAA6B,CAAC,CACvD,CAAA,UAAQ,CACN,OAAO,IACT,CACF,CAGO,SAASC,CAAAA,CAAkBhB,CAAAA,CAAeO,CAAAA,CAAmC,CAClF,IAAMU,CAAAA,CAAQH,EAAAA,CAAiBd,CAAAA,CAAKO,CAAU,CAAA,CAC9C,OAAOU,CAAAA,GAAU,IAAA,EAAQpB,EAAAA,CAAc,IAAA,CAAKoB,CAAK,CAAA,CAAIA,CAAAA,CAAQ,IAC/D,CAOO,SAASC,EAAAA,CAAmB5C,CAAAA,CAAaiC,CAAAA,CAAoBY,CAAAA,CAAkB,CACpF,GAAI,CACF,IAAMnB,CAAAA,CAAM1B,CAAAA,CAAI,QAAA,CACV8C,CAAAA,CACJ,CAAA,EAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-C3BBJOVV.js","sourcesContent":[null,"/**\n * Page-wide state of the automatic page views. It lives on `window`, so the\n * npm package, a second copy of it and the `analytics.js` script agree on who\n * reports a path and the history is patched once.\n */\ntype Registry = {\n /** Last path some starter reported. */\n path: string | null;\n starters: Set<() => void>;\n watching: boolean;\n};\n\nconst REGISTRY = Symbol.for(\"bitsnap.pageViews\");\n\nfunction registry(win: Window): Registry {\n const holder = win as unknown as Record<symbol, Registry | undefined>;\n return (holder[REGISTRY] ??= { path: null, starters: new Set(), watching: false });\n}\n\n/** Calls `onChange` when the path changes through `history.pushState`/`replaceState` or Back/Forward. */\nfunction watchNavigation(win: Window, onChange: () => void) {\n const check = () => {\n try {\n onChange();\n } catch {}\n };\n for (const name of [\"pushState\", \"replaceState\"] as const) {\n const original = win.history[name];\n win.history[name] = function (this: History, ...args: Parameters<History[typeof name]>) {\n const result = original.apply(this, args);\n check();\n return result;\n };\n }\n win.addEventListener(\"popstate\", check);\n}\n\n/**\n * Calls `send` for the current path and again on every path change, unless\n * another starter on the page already reported that path: the page gets one\n * `page_view` per path change however many providers, components and embeds\n * start it. Returns the function that stops this starter.\n */\nexport function startAutoPageViews(send: () => void, win: Window = window): () => void {\n try {\n const reg = registry(win);\n const starter = () => send();\n if (!reg.watching) {\n reg.watching = true;\n watchNavigation(win, () => {\n const path = win.location.pathname;\n // Nobody listening: leave the path unreported so the next starter sends it.\n if (path === reg.path || reg.starters.size === 0) return;\n reg.path = path;\n reg.starters.values().next().value?.();\n });\n }\n reg.starters.add(starter);\n const path = win.location.pathname;\n if (path !== reg.path) {\n reg.path = path;\n starter();\n }\n return () => void reg.starters.delete(starter);\n } catch {\n return () => {};\n }\n}\n\n/** Forgets the reported path and the starters (tests, hot reload). The history patch stays. */\nexport function resetAutoPageViews(win: Window = window) {\n const reg = registry(win);\n reg.path = null;\n reg.starters.clear();\n}\n","// Generated by scripts/write-version.mjs from package.json. Do not edit.\nexport const SDK_VERSION = \"1.17.0\";\n","export function randomBytes(n: number): Uint8Array {\n const bytes = new Uint8Array(n);\n const c = typeof crypto !== \"undefined\" ? crypto : undefined;\n if (c && typeof c.getRandomValues === \"function\") c.getRandomValues(bytes);\n else for (let i = 0; i < n; i++) bytes[i] = Math.floor(Math.random() * 256);\n return bytes;\n}\n","import { domainCandidates } from \"../consent/core/cookie\";\nimport { clientIdCookieName } from \"./contract\";\nimport { randomBytes } from \"./random\";\n\n/** The part of `window.BitsnapConsent` (`bitsnap-react/consent`) the tracker reads. */\nexport type ConsentLike = {\n /** Absent on a consent script older than 1.9.0, which never counts as the project's banner. */\n scope?: \"global\" | \"project\";\n projectKey?: string | null;\n get(): { c: { analytics?: boolean } } | null;\n /** Also true for a refusal made on an older banner version, which `get()` no longer returns. */\n denied?(category: \"analytics\"): boolean;\n ready?: Promise<unknown>;\n};\n\n/** Sent to the Bitsnap server on the requests that create a checkout or payment link. */\nexport const VISITOR_HEADER = \"X-Bitsnap-Visitor\";\n// 390 days, under the 13 months CNIL allows. Set once, never extended.\nconst MAX_AGE_SECONDS = 390 * 24 * 60 * 60;\nconst VISITOR_ID_RE = /^[A-Za-z0-9_-]{22}$/;\n\nexport function consentApi(win: Window): ConsentLike | undefined {\n return (win as unknown as { BitsnapConsent?: ConsentLike }).BitsnapConsent;\n}\n\nfunction readCookie(doc: Document, name: string): string | null {\n for (const part of doc.cookie.split(\";\")) {\n const index = part.indexOf(\"=\");\n if (index !== -1 && part.slice(0, index).trim() === name) return part.slice(index + 1).trim();\n }\n return null;\n}\n\n/** bitsnap.pl and its subdomains: many merchants share them, and the site-wide choice is bitsnap's own. */\nfunction isBitsnapHost(hostname: string): boolean {\n const host = hostname.toLowerCase();\n return host === \"bitsnap.pl\" || host.endsWith(\".bitsnap.pl\");\n}\n\n/**\n * Whether the page's consent banner speaks for `projectKey`: a project-scope banner of that\n * key, or a site-scope banner on a merchant's own site. On bitsnap.pl a site-scope choice is\n * bitsnap's own, so only a project-scope one counts.\n */\nexport function consentBelongsTo(win: Window, projectKey: string): boolean {\n try {\n const api = consentApi(win);\n if (!api) return false;\n if (api.scope === \"project\") return api.projectKey === projectKey;\n const onBitsnap = isBitsnapHost(win.location.hostname);\n if (api.scope === \"global\") return !onBitsnap;\n // A consent script from before the scope info: it cannot be told apart from another project's banner.\n return false;\n } catch {\n return false;\n }\n}\n\n/** `true` only while a banner that speaks for `projectKey` holds a valid choice that grants `analytics`. */\nexport function analyticsGranted(win: Window, projectKey: string): boolean {\n try {\n return consentApi(win)?.get()?.c.analytics === true && consentBelongsTo(win, projectKey);\n } catch {\n return false;\n }\n}\n\n/** 16 random bytes as 22 base64url characters. */\nexport function newVisitorId(): string {\n let binary = \"\";\n randomBytes(16).forEach((byte) => (binary += String.fromCharCode(byte)));\n return btoa(binary).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n}\n\n/** Value of the `bs_vid_<projectKey>` cookie, whatever it holds; `null` when it is absent. */\nfunction rawVisitorCookie(doc: Document, projectKey: string): string | null {\n try {\n return readCookie(doc, clientIdCookieName(projectKey));\n } catch {\n return null;\n }\n}\n\n/** The project's client id from its first-party cookie (`bs_vid_<projectKey>`), or `null` if absent or malformed. */\nexport function readVisitorCookie(doc: Document, projectKey: string): string | null {\n const value = rawVisitorCookie(doc, projectKey);\n return value !== null && VISITOR_ID_RE.test(value) ? value : null;\n}\n\n/**\n * Sets the cookie on the widest registrable domain the browser accepts\n * (shortest suffix with two labels first, so `shop.example.co.uk` skips the\n * refused `co.uk`), host-only where no domain sticks (localhost, IP hosts).\n */\nexport function writeVisitorCookie(win: Window, projectKey: string, id: string): void {\n try {\n const doc = win.document;\n const base =\n `${clientIdCookieName(projectKey)}=${id}; Max-Age=${MAX_AGE_SECONDS}; Path=/; SameSite=Lax` +\n (win.location.protocol === \"https:\" ? \"; Secure\" : \"\");\n for (const domain of domainCandidates(win.location.hostname).reverse()) {\n doc.cookie = `${base}; Domain=${domain}`;\n if (readVisitorCookie(doc, projectKey) === id) return;\n }\n doc.cookie = base;\n } catch {\n // cookies blocked (sandboxed frame)\n }\n}\n\n/** Expires the cookie on the host and on every parent domain it may have been set on. */\nexport function deleteVisitorCookie(win: Window, projectKey: string): void {\n try {\n const doc = win.document;\n // Present under any value: a malformed one must go too.\n if (rawVisitorCookie(doc, projectKey) === null) return;\n const base =\n `${clientIdCookieName(projectKey)}=; Max-Age=0; Path=/; SameSite=Lax` +\n (win.location.protocol === \"https:\" ? \"; Secure\" : \"\");\n doc.cookie = base;\n for (const domain of domainCandidates(win.location.hostname)) doc.cookie = `${base}; Domain=${domain}`;\n } catch {\n // best effort\n }\n}\n\n/**\n * The project's client id to send, or `null`: analytics consent is granted,\n * Global Privacy Control is off, the browser is not automated and the cookie exists.\n */\nexport function readVisitorId(win: Window, projectKey: string): string | null {\n try {\n const nav = win.navigator as { globalPrivacyControl?: boolean; webdriver?: boolean } | undefined;\n if (nav?.globalPrivacyControl === true || nav?.webdriver === true) return null;\n return analyticsGranted(win, projectKey) ? readVisitorCookie(win.document, projectKey) : null;\n } catch {\n return null;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ var t={projectID:void 0,loginURL:"/panel/login",theme:void 0,host:void 0,allowedReturnOrigins:[]},n=[];function i(e){t={...t,...e}}function o(){return t}function r(e){t.projectID=e}function g(e){t.theme=e}function l(e){t.loginURL=e}function s(e){t.host=e}function u(e){n=e,t={...t,allowedReturnOrigins:e}}function f(){return n}export{i as a,o as b,r as c,g as d,l as e,s as f,u as g,f as h};
2
+ //# sourceMappingURL=chunk-CUPG4B5W.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/panel/config.ts"],"sourcesContent":["import type { GetThemeOutput } from \"./types\";\n\nlet config: PanelConfig = {\n projectID: undefined,\n loginURL: \"/panel/login\",\n theme: undefined,\n host: undefined,\n allowedReturnOrigins: [],\n};\n\nlet allowedReturnOrigins: string[] = [];\n\nexport interface PanelConfig {\n projectID?: string;\n loginURL?: string;\n theme?: GetThemeOutput;\n host?: string;\n allowedReturnOrigins: string[];\n}\n\nexport function setPanelConfig(newConfig: Partial<PanelConfig>): void {\n config = { ...config, ...newConfig };\n}\n\nexport function getPanelConfig(): PanelConfig {\n return config;\n}\n\nexport function setProjectID(projectID: string): void {\n config.projectID = projectID;\n}\n\nexport function setTheme(theme: GetThemeOutput): void {\n config.theme = theme;\n}\n\nexport function setLoginURL(loginURL: string): void {\n config.loginURL = loginURL;\n}\n\nexport function setHost(host: string): void {\n config.host = host;\n}\n\nexport function setAllowedReturnOrigins(origins: string[]): void {\n allowedReturnOrigins = origins;\n config = { ...config, allowedReturnOrigins: origins };\n}\n\nexport function getAllowedReturnOrigins(): string[] {\n return allowedReturnOrigins;\n}\n"],"mappings":"AAEA,IAAIA,EAAsB,CACxB,UAAW,OACX,SAAU,eACV,MAAO,OACP,KAAM,OACN,qBAAsB,CAAC,CACzB,EAEIC,EAAiC,CAAC,EAU/B,SAASC,EAAeC,EAAuC,CACpEH,EAAS,CAAE,GAAGA,EAAQ,GAAGG,CAAU,CACrC,CAEO,SAASC,GAA8B,CAC5C,OAAOJ,CACT,CAEO,SAASK,EAAaC,EAAyB,CACpDN,EAAO,UAAYM,CACrB,CAEO,SAASC,EAASC,EAA6B,CACpDR,EAAO,MAAQQ,CACjB,CAEO,SAASC,EAAYC,EAAwB,CAClDV,EAAO,SAAWU,CACpB,CAEO,SAASC,EAAQC,EAAoB,CAC1CZ,EAAO,KAAOY,CAChB,CAEO,SAASC,EAAwBC,EAAyB,CAC/Db,EAAuBa,EACvBd,EAAS,CAAE,GAAGA,EAAQ,qBAAsBc,CAAQ,CACtD,CAEO,SAASC,GAAoC,CAClD,OAAOd,CACT","names":["config","allowedReturnOrigins","setPanelConfig","newConfig","getPanelConfig","setProjectID","projectID","setTheme","theme","setLoginURL","loginURL","setHost","host","setAllowedReturnOrigins","origins","getAllowedReturnOrigins"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkC3BBJOVVjs = require('./chunk-C3BBJOVV.js');var s="X-Bitsnap-Client",n=`bitsnap-react@${_chunkC3BBJOVVjs.a}`,i="bs_client",E= exports.a ={[s]:n},T= exports.b =t=>e=>(e.header.set(s,n),t(e));function C(t){let e=t.indexOf("#"),o=e===-1?t:t.slice(0,e),c=e===-1?"":t.slice(e),p=o.includes("?")?/[?&]$/.test(o)?"":"&":"?";return`${o}${p}${i}=${encodeURIComponent(n)}${c}`}var a="https://bitsnap.pl",l= exports.e =a;function _(t){console.log("setCustomHost",t),l= exports.e =t}var _clsx = require('clsx');var _tailwindmerge = require('tailwind-merge');function H(...t){return _tailwindmerge.twMerge.call(void 0, _clsx.clsx.call(void 0, t))}exports.a = E; exports.b = T; exports.c = C; exports.d = a; exports.e = l; exports.f = _; exports.g = H;
2
+ //# sourceMappingURL=chunk-ESF5ZVVF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-ESF5ZVVF.js","../src/lib/client-header.ts"],"names":["CLIENT_HEADER_NAME","CLIENT_HEADER_VALUE","SDK_VERSION"],"mappings":"AAAA,+HAAuC,ICG1BA,CAAAA,CAAqB,kBAAA,CACrBC,CAAAA,CAAsB,CAAA,cAAA,EAAiBC,kBAAW,CAAA,CAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-ESF5ZVVF.js","sourcesContent":[null,"import type { Interceptor } from \"@connectrpc/connect\";\nimport { SDK_VERSION } from \"../version\";\n\nexport const CLIENT_HEADER_NAME = \"X-Bitsnap-Client\";\nexport const CLIENT_HEADER_VALUE = `bitsnap-react@${SDK_VERSION}`;\n\nexport const CLIENT_QUERY_PARAM = \"bs_client\";\n\n/**\n * Spread into the `headers` of a fetch that already triggers a CORS preflight\n * (JSON POST, Connect RPC). Never use it on a simple cross-origin GET: the\n * custom header would force a preflight that older servers and merchant\n * proxies do not allow. Use `withClientParam` there.\n */\nexport const clientHeaders: Record<string, string> = {\n [CLIENT_HEADER_NAME]: CLIENT_HEADER_VALUE,\n};\n\n/** Connect interceptor adding the client header to every RPC. */\nexport const clientHeaderInterceptor: Interceptor = (next) => (req) => {\n req.header.set(CLIENT_HEADER_NAME, CLIENT_HEADER_VALUE);\n return next(req);\n};\n\n/** Adds `bs_client=<pkg>@<ver>` to a URL, for simple GETs that must stay preflight-free. */\nexport function withClientParam(url: string): string {\n const hash = url.indexOf(\"#\");\n const base = hash === -1 ? url : url.slice(0, hash);\n const fragment = hash === -1 ? \"\" : url.slice(hash);\n const separator = base.includes(\"?\") ? (/[?&]$/.test(base) ? \"\" : \"&\") : \"?\";\n return `${base}${separator}${CLIENT_QUERY_PARAM}=${encodeURIComponent(CLIENT_HEADER_VALUE)}${fragment}`;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import{a as It,b as Lt}from"./chunk-KOVKUJAW.mjs";import{h as St,j as Ye,k as ie,l as ht,n as kt,o as Nt,r as P,s as Tt,u as wt,v as Et,w as Ct}from"./chunk-L7Q7OKM5.mjs";import{a as u}from"./chunk-5R6AGO3Z.mjs";import{l as Rt,m as Ee,n as xt}from"./chunk-2UDAB2C5.mjs";import{a as Ce,b as vt,f as Ie}from"./chunk-VNYHJT6V.mjs";var Pr=["root","header","title","description","backButton","stepIndicator","error","emptyState","skeleton","emailForm","emailInput","codeForm","codeInput","resendButton","logoutButton","orderList","orderCard","orderReference","orderDate","orderTotal","pagination","lineList","line","lineName","linePrice","lineQuantityControl","quantityButton","quantityInput","lineIneligibleReason","noteInput","summary","submitButton","secondaryButton","successState","returnReference","returnInstructions","returnList","returnCard","statusBadge","history","historyEntry"],Tn={fontFamily:"--bitsnap-returns-font-family",fontSize:"--bitsnap-returns-font-size",background:"--bitsnap-returns-background",surface:"--bitsnap-returns-surface",foreground:"--bitsnap-returns-foreground",mutedForeground:"--bitsnap-returns-muted-foreground",border:"--bitsnap-returns-border",buttonBackground:"--bitsnap-returns-button-background",buttonForeground:"--bitsnap-returns-button-foreground",buttonHoverBackground:"--bitsnap-returns-button-hover-background",hoverSurface:"--bitsnap-returns-hover-surface",focusRing:"--bitsnap-returns-focus-ring",error:"--bitsnap-returns-error",success:"--bitsnap-returns-success",warning:"--bitsnap-returns-warning",badgeBackground:"--bitsnap-returns-badge-background",badgeForeground:"--bitsnap-returns-badge-foreground",inputBackground:"--bitsnap-returns-input-background",radius:"--bitsnap-returns-radius"},wn={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",success:"#16a34a",warning:"#d97706",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",inputBackground:"#ffffff",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",success:"#4ade80",warning:"#fbbf24",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",inputBackground:"#27272a",radius:"8px"}},En=[{token:"background",variable:"--background"},{token:"foreground",variable:"--foreground"},{token:"surface",variable:"--card"},{token:"foreground",variable:"--card-foreground"},{token:"surface",variable:"--popover"},{token:"foreground",variable:"--popover-foreground"},{token:"buttonBackground",variable:"--primary"},{token:"buttonForeground",variable:"--primary-foreground"},{token:"surface",variable:"--secondary"},{token:"foreground",variable:"--secondary-foreground"},{token:"hoverSurface",variable:"--accent"},{token:"foreground",variable:"--accent-foreground"},{token:"mutedForeground",variable:"--muted-foreground"},{token:"border",variable:"--border"},{token:"border",variable:"--input"},{token:"focusRing",variable:"--ring"},{token:"error",variable:"--destructive"},{token:"radius",variable:"--radius"}];function Ze(e){let t=It(e,{defaultTheme:"light",presets:wn,variables:Tn,shadcnVariables:En});return{theme:t.theme,tokens:t.tokens,elements:t.elements,boundaryClassName:t.theme,boundaryStyle:t.boundaryStyle}}function Pt(e,t){return Lt(e.elements,t)}import{createContext as Cn,useContext as In,useMemo as Ln}from"react";import{jsx as Pn}from"react/jsx-runtime";var At=Cn(Ze());function Ot({appearance:e,children:t}){let n=Ln(()=>Ze(e),[e]);return Pn(At.Provider,{value:n,children:t})}function $e(){return In(At)}function d(e){let t=$e();return Pt(t,e)??{}}function Bt(e){return e==="test"||e===1?1:0}var zt={title:["emailStepTitle"],email:["emailLabel"],sendCode:["emailSubmit"],code:["codeLabel"],verify:["codeSubmit"],orders:["ordersTitle"],submit:["confirmationSubmit"],note:["noteLabel"],history:["myReturnsTitle","myReturnsLink"]};function Mt(e){if(e==null)return;let t={};for(let[n,r]of Object.entries(zt)){let a=e[n];if(typeof a=="string")for(let i of r)t[i]=a}for(let n of Object.keys(e)){if(n in zt)continue;let r=e[n];typeof r=="string"&&(t[n]=r)}return t}function Dt(e,t){let n=t?.brandColor?.trim();return n==null||n===""?e:{...e,tokens:{...wt(n),...e?.tokens}}}function Ge(e,t){return typeof e=="object"&&e!=null?{pageSize:e.pageSize??20,explicitPageToken:void 0}:typeof e=="number"||t!==void 0?{pageSize:e??20,explicitPageToken:t??""}:{pageSize:20,explicitPageToken:void 0}}var An={en:{back:"Back",stepIndicator:"Step {current} of {total}",loading:"Loading",myReturnsLink:"My returns",emailStepTitle:"Return a product",emailStepDescription:"Enter the email address you used for the order. We will send you a verification code.",emailLabel:"Email address",emailPlaceholder:"name@example.com",emailSubmit:"Send code",codeStepTitle:"Enter the code",codeStepDescription:"We sent a verification code to {email}.",codeLabel:"Verification code",codeSubmit:"Verify",resend:"Send the code again",resendIn:"Send again in {seconds} s",resendSent:"We sent a new code.",codeSpamHint:"Can't see the email? Check your spam folder.",codeValidity:"The code is valid for 10 minutes.",codeIncomplete:"Enter all 6 digits of the code.",logout:"Sign out",ordersTitle:"Your orders",ordersDescription:"Choose the order that contains the product to return.",ordersEmpty:"There are no orders eligible for return.",orderTitle:"Order {reference}",orderReturnableLines:"Products available to return: {count}",orderSelect:"Choose",paginationPrevious:"Previous",paginationNext:"Next",paginationInfo:"Page {page}, {total} orders",orderDetailTitle:"Order {reference}",orderDetailDescription:"Select the products and quantities to return.",quantityLabel:"Quantity to return: {name}",quantityDecrease:"Decrease quantity: {name}",quantityIncrease:"Increase quantity: {name}",quantityOfAvailable:"of {available}",lineIneligibleFallback:"This product cannot be returned.",noteLabel:"Note (optional)",notePlaceholder:"Tell us why you are returning the product",selectionContinue:"Continue",selectionEmpty:"Select at least one item to return.",previousReturnsTitle:"Earlier returns for this order",confirmationTitle:"Confirm the return",confirmationDescription:"Check the products before you submit the request.",confirmationSummary:"Products to return",confirmationQuantity:"Quantity: {quantity}",confirmationNote:"Your note",confirmationSubmit:"Submit return request",successTitle:"Return request submitted",successDescription:"We received your request and will keep you posted.",successReference:"Request number",successInstructions:"What to do next",successDone:"Back to orders",myReturnsTitle:"My returns",myReturnsDescription:"Track the status of your return requests.",myReturnsEmpty:"You have not submitted any return requests yet.",myReturnOpen:"Details",myReturnDetailTitle:"Return details",myReturnTitle:"Return {reference}",myReturnCreatedAt:"Submitted",myReturnRefund:"Refund",myReturnLines:"Products",myReturnLineQuantities:"Requested: {requested}, approved: {approved}, received: {received}",myReturnNote:"Your note",myReturnHistory:"History",statusSubmitted:"Submitted",statusApproved:"Approved",statusRejected:"Rejected",statusAwaitingReceipt:"Awaiting the package",statusReceived:"Package received",statusCompleted:"Completed",statusCancelled:"Cancelled",statusRefunded:"Refunded",statusFallback:"In progress",refundStatusNotStarted:"Not started",refundStatusPending:"Refund in progress",refundStatusSucceeded:"Refunded",refundStatusFailed:"Refund failed",refundStatusFallback:"Unknown",errorGeneric:"Something went wrong. Please try again.",errorNetwork:"Cannot reach the server. Check your connection and try again.",errorInvalidEmail:"Enter a valid email address.",errorInvalidCode:"The code is invalid or has expired.",errorSessionExpired:"Your session has expired. Verify your email again.",errorOrderNotFound:"We could not find this order.",errorReturnNotFound:"We could not find this return request.",errorQuantityUnavailable:"The selected quantity is no longer available for return.",errorItemNotReturnable:"One of the selected products cannot be returned.",errorReturnsDisabled:"Returns are not available in this shop.",errorRateLimited:"Too many attempts. Please try again later.",errorIdempotencyConflict:"This request was already submitted with different contents. Reload and try again.",errorDeliveryFailed:"We could not send the code. Please try again.",errorRetry:"Try again"},pl:{back:"Wstecz",stepIndicator:"Krok {current} z {total}",loading:"\u0141adowanie",myReturnsLink:"Moje zwroty",emailStepTitle:"Zwr\xF3\u0107 produkt",emailStepDescription:"Podaj adres e-mail u\u017Cyty w zam\xF3wieniu. Wy\u015Blemy na niego kod weryfikacyjny.",emailLabel:"Adres e-mail",emailPlaceholder:"jan@example.com",emailSubmit:"Wy\u015Blij kod",codeStepTitle:"Wpisz kod",codeStepDescription:"Wys\u0142ali\u015Bmy kod weryfikacyjny na adres {email}.",codeLabel:"Kod weryfikacyjny",codeSubmit:"Zweryfikuj",resend:"Wy\u015Blij kod ponownie",resendIn:"Wy\u015Blij ponownie za {seconds} s",resendSent:"Wys\u0142ali\u015Bmy nowy kod.",codeSpamHint:"Nie widzisz e-maila? Sprawd\u017A folder spam.",codeValidity:"Kod jest wa\u017Cny 10 minut.",codeIncomplete:"Wpisz wszystkie 6 cyfr kodu.",logout:"Wyloguj si\u0119",ordersTitle:"Twoje zam\xF3wienia",ordersDescription:"Wybierz zam\xF3wienie z produktem do zwrotu.",ordersEmpty:"Brak zam\xF3wie\u0144, kt\xF3re mo\u017Cna zwr\xF3ci\u0107.",orderTitle:"Zam\xF3wienie {reference}",orderReturnableLines:"Produkty do zwrotu: {count}",orderSelect:"Wybierz",paginationPrevious:"Poprzednia",paginationNext:"Nast\u0119pna",paginationInfo:"Strona {page}, zam\xF3wie\u0144: {total}",orderDetailTitle:"Zam\xF3wienie {reference}",orderDetailDescription:"Wybierz produkty i ilo\u015Bci do zwrotu.",quantityLabel:"Ilo\u015B\u0107 do zwrotu: {name}",quantityDecrease:"Zmniejsz ilo\u015B\u0107: {name}",quantityIncrease:"Zwi\u0119ksz ilo\u015B\u0107: {name}",quantityOfAvailable:"z {available}",lineIneligibleFallback:"Ten produkt nie podlega zwrotowi.",noteLabel:"Uwagi (opcjonalnie)",notePlaceholder:"Napisz, dlaczego zwracasz produkt",selectionContinue:"Dalej",selectionEmpty:"Wybierz co najmniej jedn\u0105 sztuk\u0119 do zwrotu.",previousReturnsTitle:"Wcze\u015Bniejsze zwroty tego zam\xF3wienia",confirmationTitle:"Potwierd\u017A zwrot",confirmationDescription:"Sprawd\u017A produkty przed wys\u0142aniem zg\u0142oszenia.",confirmationSummary:"Produkty do zwrotu",confirmationQuantity:"Ilo\u015B\u0107: {quantity}",confirmationNote:"Twoje uwagi",confirmationSubmit:"Wy\u015Blij zg\u0142oszenie zwrotu",successTitle:"Zg\u0142oszenie zwrotu zosta\u0142o wys\u0142ane",successDescription:"Otrzymali\u015Bmy zg\u0142oszenie i b\u0119dziemy informowa\u0107 o jego statusie.",successReference:"Numer zg\u0142oszenia",successInstructions:"Co dalej",successDone:"Wr\xF3\u0107 do zam\xF3wie\u0144",myReturnsTitle:"Moje zwroty",myReturnsDescription:"Sprawd\u017A status swoich zg\u0142osze\u0144 zwrotu.",myReturnsEmpty:"Nie masz jeszcze \u017Cadnych zg\u0142osze\u0144 zwrotu.",myReturnOpen:"Szczeg\xF3\u0142y",myReturnDetailTitle:"Szczeg\xF3\u0142y zwrotu",myReturnTitle:"Zwrot {reference}",myReturnCreatedAt:"Zg\u0142oszono",myReturnRefund:"Zwrot \u015Brodk\xF3w",myReturnLines:"Produkty",myReturnLineQuantities:"Zg\u0142oszono: {requested}, zaakceptowano: {approved}, odebrano: {received}",myReturnNote:"Twoje uwagi",myReturnHistory:"Historia",statusSubmitted:"Zg\u0142oszony",statusApproved:"Zaakceptowany",statusRejected:"Odrzucony",statusAwaitingReceipt:"Oczekiwanie na paczk\u0119",statusReceived:"Paczka odebrana",statusCompleted:"Zako\u0144czony",statusCancelled:"Anulowany",statusRefunded:"\u015Arodki zwr\xF3cone",statusFallback:"W trakcie",refundStatusNotStarted:"Nie rozpocz\u0119to",refundStatusPending:"Zwrot \u015Brodk\xF3w w toku",refundStatusSucceeded:"\u015Arodki zwr\xF3cone",refundStatusFailed:"Zwrot \u015Brodk\xF3w nie powi\xF3d\u0142 si\u0119",refundStatusFallback:"Nieznany",errorGeneric:"Co\u015B posz\u0142o nie tak. Spr\xF3buj ponownie.",errorNetwork:"Brak po\u0142\u0105czenia z serwerem. Sprawd\u017A internet i spr\xF3buj ponownie.",errorInvalidEmail:"Podaj poprawny adres e-mail.",errorInvalidCode:"Kod jest nieprawid\u0142owy lub wygas\u0142.",errorSessionExpired:"Sesja wygas\u0142a. Zweryfikuj adres e-mail ponownie.",errorOrderNotFound:"Nie znaleziono tego zam\xF3wienia.",errorReturnNotFound:"Nie znaleziono tego zg\u0142oszenia zwrotu.",errorQuantityUnavailable:"Wybrana ilo\u015B\u0107 nie jest ju\u017C dost\u0119pna do zwrotu.",errorItemNotReturnable:"Jeden z wybranych produkt\xF3w nie podlega zwrotowi.",errorReturnsDisabled:"Zwroty nie s\u0105 dost\u0119pne w tym sklepie.",errorRateLimited:"Zbyt wiele pr\xF3b. Spr\xF3buj ponownie p\xF3\u017Aniej.",errorIdempotencyConflict:"To zg\u0142oszenie zosta\u0142o ju\u017C wys\u0142ane z inn\u0105 zawarto\u015Bci\u0105. Od\u015Bwie\u017C stron\u0119 i spr\xF3buj ponownie.",errorDeliveryFailed:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu. Spr\xF3buj ponownie.",errorRetry:"Spr\xF3buj ponownie"}};function Xe(e,t){return vt(An,e,t)}function Ft(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>Object.prototype.hasOwnProperty.call(t,r)?String(t[r]):n)}var On={submitted:"statusSubmitted",approved:"statusApproved",rejected:"statusRejected",awaiting_receipt:"statusAwaitingReceipt",received:"statusReceived",completed:"statusCompleted",cancelled:"statusCancelled",refunded:"statusRefunded"},zn={not_started:"refundStatusNotStarted",pending:"refundStatusPending",succeeded:"refundStatusSucceeded",failed:"refundStatusFailed"};function Kt(e){return On[e]??"statusFallback"}function _t(e){return zn[e]??"refundStatusFallback"}import{createContext as Bn,useCallback as Mn,useContext as jt,useMemo as Dn}from"react";import{jsx as Fn}from"react/jsx-runtime";var Je=Bn({locale:"pl-PL",texts:Xe("pl-PL")});function qt({texts:e,locale:t,children:n}){let r=t??Ie(),a=Dn(()=>({locale:r,texts:Xe(r,e)}),[r,e]);return Fn(Je.Provider,{value:a,children:n})}function z(){let{texts:e}=jt(Je);return Mn((t,n)=>n==null?e[t]:Ft(e[t],n),[e])}function Z(){return jt(Je).locale}import{createClient as jn}from"@connectrpc/connect";import{createConnectQueryKey as qn,TransportProvider as Un}from"@connectrpc/connect-query";import{QueryClient as Qn,QueryClientContext as Vn,QueryClientProvider as Wn,useQueryClient as Hn}from"@tanstack/react-query";import{createContext as Yn,useCallback as ze,useContext as Ht,useEffect as Wt,useMemo as Be,useRef as Zn,useState as ke}from"react";function et(){try{return typeof window<"u"?window.sessionStorage:void 0}catch{return}}function Ut(e,t,n){return`bitsnap-login-pending:${e}:${encodeURIComponent(n??"")}:${encodeURIComponent(t??"")}`}function Le(e,t){try{et()?.setItem(e,JSON.stringify(t))}catch{}}function me(e){try{et()?.removeItem(e)}catch{}}function Pe(e,t=Date.now()){let n=et();if(n!=null)try{let r=n.getItem(e);if(r==null)return;let a=JSON.parse(r);if(a!=null&&typeof a.email=="string"&&a.email!==""&&typeof a.sentAt=="number"&&typeof a.resendAt=="number"&&(a.challengeId==null||typeof a.challengeId=="string")&&t-a.sentAt<6e5)return{email:a.email,challengeId:a.challengeId,resendAt:a.resendAt,sentAt:a.sentAt};n.removeItem(e)}catch{try{n.removeItem(e)}catch{}}}import{timestampMs as Kn}from"@bufbuild/protobuf/wkt";var _n="bitsnap-returns-session:";function tt(e){return`${_n}${e}`}function Ae(){try{return typeof window<"u"?window.sessionStorage:void 0}catch{return}}function Qt(e,t,n=Date.now()){if(e==null)return;let r=tt(t);try{let a=e.getItem(r);if(a==null)return;let i=JSON.parse(a);if(i!=null&&typeof i=="object"&&typeof i.token=="string"&&i.token.length>0&&typeof i.expiresAt=="number"&&i.expiresAt>n){let{token:s,expiresAt:o}=i;return{token:s,expiresAt:o}}e.removeItem(r)}catch{try{e.removeItem(r)}catch{}}}function Vt(e,t,n){try{e?.setItem(tt(t),JSON.stringify(n))}catch{}}function nt(e,t){try{e?.removeItem(tt(t))}catch{}}function Oe(e){return e==null?void 0:Kn(e)}import{jsx as ue}from"react/jsx-runtime";var Yt=Yn(void 0);function D(e){let t=Ht(Yt);if(t==null)throw new Error(`${e} must be rendered inside <ReturnsProvider>`);return t}function rt(){return qn({schema:Ye,cardinality:void 0})}var $n=2**31-1;function Gn({projectID:e,environment:t,transport:n,panelAccessToken:r,className:a,children:i}){let s=Hn(),{boundaryClassName:o,boundaryStyle:g}=$e(),m=d("root"),[l,y]=ke({status:"hydrating"}),[c,f]=ke(),[b,x]=ke(),[v,k]=ke(),S=Ut("returns",e),w=Zn(void 0),h=ze(N=>{if(x(N),N==null){me(S);return}k(N.email),Le(S,{email:N.email,challengeId:N.challengeId,resendAt:N.resendAvailableAt,sentAt:Date.now()})},[S]),C=ze(()=>{s.removeQueries({queryKey:rt()})},[s]),U=ze(()=>{nt(Ae(),e),h(void 0),y({status:"anonymous"}),C()},[e,C,h]),_=ze(N=>{Vt(Ae(),e,N),f(void 0),h(void 0),y({status:"authenticated",token:N.token,expiresAt:N.expiresAt})},[e,h]);Wt(()=>{let N=!1,Y=Ae();if(r==null||r===""){let O=w.current!=null;if(w.current=void 0,O){U();return}let j=Qt(Y,e),Q=j==null?Pe(S):void 0;Q?.challengeId!=null&&(x({challengeId:Q.challengeId,email:Q.email,resendAvailableAt:Q.resendAt}),k(Q.email)),y(j!=null?{status:"authenticated",token:j.token,expiresAt:j.expiresAt}:{status:"anonymous"});return}return w.current=r,nt(Y,e),C(),f(void 0),y({status:"exchanging"}),jn(Ye,n).exchangePanelSession({projectId:e,accessToken:r,environment:t}).then(O=>{if(N)return;let j=Oe(O.expiresAt);if(O.sessionToken===""||j==null)throw new Error("EMPTY_SESSION");_({token:O.sessionToken,expiresAt:j})}).catch(O=>{N||(f(O),y({status:"anonymous"}))}),()=>{N=!0}},[r,e,t,n]),Wt(()=>{if(l.status!=="authenticated"||l.expiresAt==null)return;let N=l.expiresAt-Date.now();if(N<=0){U();return}let Y=setTimeout(U,Math.min(N,$n));return()=>clearTimeout(Y)},[l.status,l.expiresAt,U]);let J=Be(()=>({projectID:e,environment:t,status:l.status,token:l.token,exchangeError:c,challenge:b,setChallenge:h,lastEmail:v,authenticate:_,clearSession:U}),[e,t,l.status,l.token,c,b,h,v,_,U]);return ue(Yt.Provider,{value:J,children:ue("div",{"data-bitsnap-returns":"root","data-bitsnap-returns-slot":"root",className:u("bitsnap-react",o,a,m.className),style:{...g,...m.style},children:i})})}function Xn({projectID:e,host:t,environment:n,appearance:r,texts:a,theme:i,locale:s,panelAccessToken:o,className:g,analytics:m,children:l}){let y=xt(e,m,"returns"),c=Ht(Vn),[f]=ke(()=>c==null?new Qn({defaultOptions:{queries:{staleTime:5e3}}}):void 0),b=t??kt(),x=Be(()=>Nt(b),[b]),v=i?.brandColor,k=Be(()=>Dt(r,{brandColor:v}),[r,v]),S=Be(()=>Mt(a),[a]),w=ue(Rt,{value:y,children:ue(Un,{transport:x,children:ue(Ot,{appearance:k,children:ue(qt,{texts:S,locale:s,children:ue(Gn,{projectID:e,environment:Bt(n),transport:x,panelAccessToken:o,className:g,children:l})})})})});return c==null&&f!=null?ue(Wn,{client:f,children:w}):w}var ls=Xn;import{useMutation as at,useQuery as Me}from"@connectrpc/connect-query";import{useQueryClient as rr}from"@tanstack/react-query";import{useCallback as oe,useEffect as Jt,useRef as sr,useState as or}from"react";import{Code as er,ConnectError as tr}from"@connectrpc/connect";import{Code as Ne,ConnectError as Jn}from"@connectrpc/connect";function Zt(e){let t=Jn.from(e);switch(t.code){case Ne.ResourceExhausted:return"rateLimited";case Ne.Unavailable:case Ne.DeadlineExceeded:case Ne.Canceled:return"network";case Ne.Unknown:return e instanceof TypeError||t.cause instanceof TypeError?"network":"unknown";default:return"unknown"}}var nr="SESSION_EXPIRED",$t={INVALID_EMAIL:"errorInvalidEmail",INVALID_OR_EXPIRED_CODE:"errorInvalidCode",SESSION_EXPIRED:"errorSessionExpired",ORDER_NOT_FOUND:"errorOrderNotFound",RETURN_NOT_FOUND:"errorReturnNotFound",QUANTITY_UNAVAILABLE:"errorQuantityUnavailable",ITEM_NOT_RETURNABLE:"errorItemNotReturnable",INVALID_RETURN_ITEMS:"errorItemNotReturnable",RETURNS_DISABLED:"errorReturnsDisabled",SUBMISSION_RATE_LIMITED:"errorRateLimited",IDEMPOTENCY_CONFLICT:"errorIdempotencyConflict",VERIFICATION_DELIVERY_FAILED:"errorDeliveryFailed"};function Gt(e){if(e==null||typeof e!="object")return;let{rawMessage:t,message:n}=e;if(typeof t=="string"&&t.length>0)return t;if(typeof n=="string")return Object.keys($t).find(r=>n.includes(r))}function st(e){return Gt(e)===nr}function Xt(e){let t=Gt(e),n=t!=null?$t[t]:void 0;if(n!=null)return n;if(e!=null&&typeof e=="object"){if(tr.from(e).code===er.ResourceExhausted)return"errorRateLimited";if(Zt(e)==="network")return"errorNetwork"}return"errorGeneric"}function ot(){let e=typeof globalThis<"u"?globalThis.crypto:void 0;if(typeof e?.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let n=0;n<t.length;n++)t[n]=Math.floor(Math.random()*256);return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function fe(e){return e==null?null:e instanceof Error?e:new Error(String(e))}function ge(e){return e==null?void 0:Xt(e)}function De(e,t){Jt(()=>{st(e)&&t()},[e,t])}function en(e){let[t,n]=or([""]);return Jt(()=>{n([""])},[e]),{pageToken:t[t.length-1]??"",page:t.length,push:r=>n(a=>[...a,r]),pop:()=>n(r=>r.length>1?r.slice(0,-1):r)}}function Fe(){let e=D("useReturnSession"),t=at(ie.returns.startReturnSession),n=at(ie.returns.verifyReturnSession),{setChallenge:r,authenticate:a,clearSession:i}=e,s=Z().toLowerCase().startsWith("en")?"en":"pl",o=oe(async f=>{n.reset();let b=f.trim(),x=await t.mutateAsync({projectId:e.projectID,email:b,environment:e.environment,locale:s});return r({challengeId:x.challengeId,email:b,resendAvailableAt:Date.now()+Math.max(0,x.resendAfterSeconds)*1e3}),x},[e.projectID,e.environment,s,r,t,n]),g=oe(async f=>{let b=await n.mutateAsync({projectId:e.projectID,challengeId:f.challengeId,code:f.code,environment:e.environment}),x=Oe(b.expiresAt);if(b.sessionToken===""||x==null)throw new Error("EMPTY_SESSION");return a({token:b.sessionToken,expiresAt:x}),b},[e.projectID,e.environment,a,n]),m=oe(async f=>{try{return await o(f),!0}catch{return!1}},[o]),l=oe(async f=>{if(e.challenge==null)return!1;try{return await g({challengeId:e.challenge.challengeId,code:f.trim()}),!0}catch{return!1}},[e.challenge,g]),y=oe(()=>e.challenge!=null?m(e.challenge.email):Promise.resolve(!1),[e.challenge,m]),c=fe(t.error??n.error??e.exchangeError);return{status:e.status,isAuthenticated:e.status==="authenticated",challenge:e.challenge,isStarting:t.isPending,isVerifying:n.isPending,starting:t.isPending,verifying:n.isPending,error:c,errorKey:ge(c),start:m,startSession:o,verifySession:g,verify:l,resend:y,logout:i}}function Ke(e){return e.status==="hydrating"||e.status==="exchanging"}function tn(e,t){let n=D("useReturnOrders"),{pageSize:r,explicitPageToken:a}=Ge(e,t),i=en(n.token),s=Me(ie.returns.listReturnOrders,{projectId:n.projectID,sessionToken:n.token??"",pageSize:r,pageToken:a??i.pageToken},{enabled:n.token!=null});De(s.error,n.clearSession);let o=s.data?.nextPageToken??"";return{orders:s.data?.orders??[],total:s.data?.total??0,data:s.data,isLoading:Ke(n)||s.isLoading,isFetching:s.isFetching,error:fe(s.error),errorKey:ge(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:i.page,hasNext:o!=="",hasPrevious:i.page>1,next:()=>{o!==""&&i.push(o)},previous:i.pop,refetch:()=>s.refetch()}}function it(e){let t=D("useReturnableOrder"),n=Me(ie.returns.getReturnableOrder,{projectId:t.projectID,sessionToken:t.token??"",canonicalOrderId:e??""},{enabled:t.token!=null&&e!=null&&e!==""});return De(n.error,t.clearSession),{order:n.data?.order,returnHistory:n.data?.returnHistory??[],data:n.data,isLoading:e!=null&&e!==""&&(Ke(t)||n.isLoading),error:fe(n.error),errorKey:ge(n.error),status:n.status,isError:n.isError,isSuccess:n.isSuccess,refetch:()=>n.refetch()}}function nn(){let e=D("useCreateReturn"),t=rr(),n=at(ie.returns.createReturnRequest),r=Ee(),a=sr(void 0),{clearSession:i}=e,s=oe(async(l,y)=>{try{let c=await n.mutateAsync({projectId:e.projectID,sessionToken:e.token??"",canonicalOrderId:l.orderId,items:l.items,note:l.note??"",idempotencyKey:y});return t.invalidateQueries({queryKey:rt()}),r.track("return_submitted",{reason_code:"unspecified",item_count:l.items.length},{order_ref:null}),c}catch(c){throw st(c)&&i(),c}},[e.projectID,e.token,n,t,i,r]),o=oe(async l=>{a.current??=ot();try{let y=await s(l,a.current);return a.current=void 0,y.request}catch{return}},[s]),g=oe(async l=>{if(e.token==null)throw new Error("Verify your email to continue.");return s({orderId:l.canonicalOrderID,items:l.items,note:l.note},l.idempotencyKey??ot())},[e.token,s]),m=oe((l,y)=>{g(l).then(c=>y?.onSuccess?.(c),c=>y?.onError?.(fe(c)))},[g]);return{submit:o,isPending:n.isPending,error:fe(n.error),errorKey:ge(n.error),mutateAsync:g,mutate:m,data:n.data,reset:n.reset,status:n.status,isError:n.isError,isSuccess:n.isSuccess}}function rn(e,t){let n=D("useMyReturns"),{pageSize:r,explicitPageToken:a}=Ge(e,t),i=en(n.token),s=Me(ie.returns.listMyReturns,{projectId:n.projectID,sessionToken:n.token??"",pageSize:r,pageToken:a??i.pageToken},{enabled:n.token!=null});De(s.error,n.clearSession);let o=s.data?.nextPageToken??"";return{returns:s.data?.returns??[],total:s.data?.total??0,data:s.data,isLoading:Ke(n)||s.isLoading,isFetching:s.isFetching,error:fe(s.error),errorKey:ge(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:i.page,hasNext:o!=="",hasPrevious:i.page>1,next:()=>{o!==""&&i.push(o)},previous:i.pop,refetch:()=>s.refetch()}}function _e(e){let t=D("useMyReturn"),n=Me(ie.returns.getMyReturn,{projectId:t.projectID,sessionToken:t.token??"",returnId:e},{enabled:t.token!=null});return De(n.error,t.clearSession),{request:n.data?.request,isLoading:Ke(t)||n.isLoading,error:n.error,errorKey:ge(n.error),refetch:()=>n.refetch()}}import{useEffect as wr,useRef as yn,useState as we}from"react";import*as sn from"@radix-ui/react-label";import{jsx as ar}from"react/jsx-runtime";function Te({className:e,...t}){return ar(sn.Root,{"data-slot":"label",className:u("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}import{Loader2Icon as ir}from"lucide-react";import{jsx as ur}from"react/jsx-runtime";function ye({className:e,...t}){return ur(ir,{role:"status","aria-label":"Loading",className:u("size-4 animate-spin",e),...t})}import{useState as lr}from"react";import{Fragment as mr,jsx as ee,jsxs as on}from"react/jsx-runtime";var dr={pl:{alt:"Logo sklepu"},en:{alt:"Shop logo"}},ut="flex h-10 items-center",lt="block max-h-10 max-w-48 w-auto object-contain";function cr(){return on("span",{role:"img","aria-label":"Bitsnap",className:"inline-flex items-center gap-1.5",children:[ee("svg",{"aria-hidden":"true",width:"29",height:"27",viewBox:"0 0 33 30",fill:"none",stroke:"currentColor",strokeWidth:"3.04",strokeLinecap:"round",children:ee("path",{d:"M20.2 1.8h0M22.8 6.2h0M22.8 10.6h0M22.8 15h0M22.8 19.4h0M22.8 23.8h0M20.2 28.2h0M27.1 10.6h0M27.1 15h0M27.1 19.4h0M31.5 15h0M1.5 1.8h0M5.4 1.8h0M9.3 1.8h0M13.2 1.8h0M5.4 15h0M9.3 15h0M13.2 15h0M5.4 28.2h0M9.3 28.2h0M13.2 28.2h0M1.5 6.2h0M1.5 10.6h0M1.5 15h0M1.5 19.4h0M1.5 23.8h0M1.5 28.2h0M16.7 19.4h0M16.7 23.8h0M16.7 6.2h0M16.7 10.6h0"})}),ee("span",{"aria-hidden":"true",className:"text-xl tracking-wider",children:"bitsnap."})]})}function pr(e,t){return ht(St,{projectId:e},{enabled:t,staleTime:1/0,retry:!1,refetchOnWindowFocus:!1})}function dt({projectId:e,name:t,locale:n,showLogo:r=!0,logoUrl:a,logoDarkUrl:i,className:s}){let[o,g]=lr([]),m=a||i,l=e?.trim()??"",{data:y,isPending:c}=pr(l,r&&!m&&l!=="");if(!r)return null;if(!m&&l!==""&&c)return ee("div",{className:u(ut,s),"aria-hidden":"true"});let f=(m?a||i:y?.logoUrl||y?.logoDarkUrl)||"",b=(m?i||a:y?.logoDarkUrl||y?.logoUrl)||"",x=h=>h!==""&&!o.includes(h),v=x(f)?f:x(b)?b:"",k=x(b)?b:x(f)?f:"";if(v===""&&k==="")return ee("div",{className:u(ut,s),children:ee(cr,{})});let S=t||y?.name||Ce(dr,n??Ie()).alt,w=h=>()=>g(C=>C.includes(h)?C:[...C,h]);return ee("div",{className:u(ut,s),children:v===k?ee("img",{src:v,alt:S,className:lt,draggable:!1,onError:w(v)}):on(mr,{children:[ee("img",{src:v,alt:S,className:u(lt,"dark:hidden"),draggable:!1,onError:w(v)}),ee("img",{src:k,alt:S,className:u(lt,"hidden dark:block"),draggable:!1,onError:w(k)})]})})}import{REGEXP_ONLY_DIGITS as hr}from"input-otp";import{useCallback as kr}from"react";import*as an from"react";import{OTPInput as fr,OTPInputContext as gr}from"input-otp";import{MinusIcon as Hs}from"lucide-react";import{jsx as je,jsxs as yr}from"react/jsx-runtime";function un({className:e,containerClassName:t,...n}){return je(fr,{"data-slot":"input-otp",containerClassName:u("flex items-center gap-2 has-disabled:opacity-50",t),className:u("disabled:cursor-not-allowed",e),...n})}function ln({className:e,...t}){return je("div",{"data-slot":"input-otp-group",className:u("flex items-center",e),...t})}function dn({index:e,className:t,...n}){let r=an.useContext(gr),{char:a,hasFakeCaret:i,isActive:s}=r?.slots[e]??{};return yr("div",{"data-slot":"input-otp-slot","data-active":s,className:u("data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",t),...n,children:[a,i&&je("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:je("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}import{useCallback as ae,useEffect as Ue,useRef as be,useState as $}from"react";import{useEffect as br,useState as Rr}from"react";function qe(e){let[,t]=Rr(0);return br(()=>{if(e==null||Date.now()>=e)return;let n=setInterval(()=>{t(r=>r+1),Date.now()>=e&&clearInterval(n)},1e3);return()=>clearInterval(n)},[e]),e!=null?Math.max(0,Math.ceil((e-Date.now())/1e3)):0}var xr={pl:{emailLabel:"E-mail",emailPlaceholder:"m@example.com",sendCode:"Wy\u015Blij kod",sending:"Wysy\u0142anie\u2026",invalidEmail:"Podaj poprawny adres e-mail.",codeSentTo:"Wys\u0142ali\u015Bmy kod na {email}.",changeEmail:"Zmie\u0144",codeLabel:"Kod z e-maila",verify:"Zaloguj si\u0119",verifying:"Sprawdzanie\u2026",codeIncomplete:"Wpisz wszystkie 6 cyfr kodu.",spamHint:"Nie widzisz e-maila? Sprawd\u017A folder spam.",validity:"Kod jest wa\u017Cny 10 minut.",resend:"Wy\u015Blij ponownie",resendIn:"Wy\u015Blij ponownie za {seconds}\xA0s",resendNew:"Wy\u015Blij nowy kod",resent:"Wys\u0142ali\u015Bmy nowy kod.",haveCodePrompt:"Masz ju\u017C kod?",haveCode:"Mam ju\u017C kod",noCode:"Nie masz kodu? Wy\u015Blij go",stepEmail:"Krok 1 z 2: podaj adres e-mail.",stepCode:"Krok 2 z 2: wpisz kod z e-maila.",wrongCode:"Nieprawid\u0142owy kod. Spr\xF3buj jeszcze raz.",expired:"Kod wygas\u0142. Wy\u015Blij nowy kod.",tooManyAttempts:"Zbyt wiele b\u0142\u0119dnych pr\xF3b. Wy\u015Blij nowy kod albo zmie\u0144 adres e-mail.",rateLimited:"Zbyt wiele pr\xF3b. Spr\xF3buj ponownie za {time}.",alreadySent:"Kod zosta\u0142 ju\u017C wys\u0142any. Nowy mo\u017Cesz poprosi\u0107 za {time}.",emailNotFound:"Nie znale\u017Ali\u015Bmy konta z tym adresem e-mail.",deliveryFailed:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu. Spr\xF3buj ponownie.",deliveryUnavailable:"Nie mo\u017Cemy teraz wys\u0142a\u0107 kodu na ten adres. Spr\xF3buj p\xF3\u017Aniej.",network:"Brak po\u0142\u0105czenia z serwerem. Sprawd\u017A internet i spr\xF3buj ponownie.",generic:"Co\u015B posz\u0142o nie tak. Spr\xF3buj ponownie."},en:{emailLabel:"Email",emailPlaceholder:"m@example.com",sendCode:"Send code",sending:"Sending\u2026",invalidEmail:"Enter a valid email address.",codeSentTo:"We sent a code to {email}.",changeEmail:"Change",codeLabel:"Code from the email",verify:"Sign in",verifying:"Checking\u2026",codeIncomplete:"Enter all 6 digits of the code.",spamHint:"Can't see the email? Check your spam folder.",validity:"The code is valid for 10 minutes.",resend:"Resend",resendIn:"Resend in {seconds}s",resendNew:"Send a new code",resent:"We sent a new code.",haveCodePrompt:"Already have a code?",haveCode:"I have a code",noCode:"No code yet? Send one",stepEmail:"Step 1 of 2: enter your email address.",stepCode:"Step 2 of 2: enter the code from the email.",wrongCode:"Incorrect code. Please try again.",expired:"The code has expired. Send a new one.",tooManyAttempts:"Too many wrong attempts. Send a new code or change the email address.",rateLimited:"Too many attempts. Try again in {time}.",alreadySent:"A code was already sent. You can ask for a new one in {time}.",emailNotFound:"We could not find an account with this email address.",deliveryFailed:"We could not send the code. Please try again.",deliveryUnavailable:"We cannot send a code to this address right now. Try again later.",network:"Cannot reach the server. Check your connection and try again.",generic:"Something went wrong. Please try again."}};function eo(e,...t){let n={...Ce(xr,e)};for(let r of t)if(r!=null)for(let[a,i]of Object.entries(r))i!=null&&(n[a]=i);return n}function cn(e){let t=Math.max(1,Math.ceil(e));return t<=60?`${t}\xA0s`:`${Math.ceil(t/60)}\xA0min`}function ct(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>Object.prototype.hasOwnProperty.call(t,r)?String(t[r]):n)}var de=6,mn=60,vr=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;function pn(e){return vr.test(e.trim())}function pt(e,t,n){return{...Sr(e,t,n),failure:t}}function Sr(e,t,n){let r=cn(n??mn);switch(t){case"invalidEmail":return{kind:"error",text:e.invalidEmail};case"emailNotFound":return{kind:"error",text:e.emailNotFound};case"wrongCode":return{kind:"error",text:e.wrongCode};case"expired":return{kind:"error",text:e.expired};case"tooManyAttempts":return{kind:"error",text:e.tooManyAttempts};case"rateLimited":return{kind:"error",text:ct(e.rateLimited,{time:r})};case"alreadySent":return{kind:"info",text:ct(e.alreadySent,{time:r})};case"deliveryFailed":return{kind:"error",text:e.deliveryFailed};case"deliveryUnavailable":return{kind:"error",text:e.deliveryUnavailable};case"network":return{kind:"error",text:e.network};default:return{kind:"error",text:e.generic}}}function ao(e){let{storageKey:t}=e,n=be(e);n.current=e;let[r,a]=$("email"),[i,s]=$(e.initialEmail??""),[o,g]=$(""),[m,l]=$(),[y,c]=$(),[f,b]=$(!1),[x,v]=$(),[k,S]=$(),[w,h]=$(),[C,U]=$(!1),[_,J]=$(""),[N,Y]=$(0),O=be(!1),j=be("email"),Q=be(null),F=be(null),re=be("email"),Se=qe(y),B=ae(T=>{j.current=T,Y(A=>A+1)},[]);Ue(()=>{N!==0&&(j.current==="email"?Q:F).current?.focus()},[N]),Ue(()=>{if(a("email"),g(""),l(void 0),c(void 0),b(!1),v(void 0),S(void 0),t==null)return;let T=Pe(t);T!=null&&(s(T.email),l(T.challengeId),c(T.resendAt>Date.now()?T.resendAt:void 0),a("code"))},[t]),Ue(()=>{re.current!==r&&(re.current=r,J(r==="code"?n.current.texts.stepCode:n.current.texts.stepEmail))},[r]),Ue(()=>{r==="code"&&N===0&&B(f?"email":"code")},[r]);let R=ae((T,A,L,M)=>{T!=="wrongCode"&&T!=="invalidEmail"&&T!=="alreadySent"&&n.current.onFailure?.(T,L);let se=pt(n.current.texts,T,A);return M!=null?{...se,text:M}:se},[]),X=ae((T,A,L,M)=>{let se=Date.now(),bt=se+(L??mn)*1e3;s(T),a("code"),b(!1),l(A),c(bt),g(""),v(void 0),S(M),t!=null&&Le(t,{email:T,challengeId:A,resendAt:bt,sentAt:se}),B("code")},[t,B]),V=ae(async T=>{if(O.current)return;let A=i.trim();if(!pn(A)){S(pt(n.current.texts,"invalidEmail")),B("email");return}O.current=!0,h(T),S(void 0);let L;try{L=await n.current.adapter.send(A,{resend:T==="resend"})}catch(se){L={ok:!1,kind:"network",cause:se}}if(O.current=!1,h(void 0),L.ok){X(A,L.challengeId,L.retryIn,T==="resend"?{kind:"success",text:n.current.texts.resent}:void 0);return}let M=R(L.kind,L.retryIn,L.cause,L.message);if(L.kind==="alreadySent"&&T==="send"){X(A,void 0,L.retryIn,M);return}L.retryIn!=null&&T==="resend"&&c(Date.now()+L.retryIn*1e3),S(M),T==="send"&&B("email")},[i,X,R,B]),he=ae(async T=>{let A=T??o;if(O.current||C||x!=null)return;let L=i.trim();if(f&&!pn(L)){S(pt(n.current.texts,"invalidEmail")),B("email");return}if(A.length!==de){S({kind:"error",text:n.current.texts.codeIncomplete}),B("code");return}O.current=!0,h("verify"),S(void 0);let M;try{M=await n.current.adapter.verify({email:L,code:A,challengeId:m})}catch(se){M={ok:!1,kind:"network",cause:se}}if(O.current=!1,h(void 0),M.ok){t!=null&&me(t),U(!0),n.current.onVerified?.(M.value,L);return}switch(S(R(M.kind,M.retryIn,M.cause,M.message)),M.kind){case"expired":case"tooManyAttempts":v(M.kind),g(""),t!=null&&me(t);break;case"invalidEmail":case"emailNotFound":B(f?"email":"code");break;case"network":case"unknown":case"deliveryFailed":case"deliveryUnavailable":B("code");break;default:g(""),B("code")}},[o,m,x,C,i,R,f,B,t]),He=ae(T=>{s(T),S(A=>A?.kind==="error"?void 0:A)},[]),hn=ae(T=>{g(T.replace(/\D/g,"").slice(0,de)),S(A=>A?.kind==="error"?void 0:A)},[]),kn=ae(()=>{a("email"),b(!1),g(""),l(void 0),c(void 0),v(void 0),S(void 0),t!=null&&me(t),B("email")},[t,B]),Nn=ae(()=>{a("code"),b(!0),g(""),l(void 0),c(void 0),v(void 0),S(void 0),B("email")},[B]);return{step:r,email:i,setEmail:He,code:o,setCode:hn,needsEmail:f,busy:w,isBusy:w!=null||C,done:C,notice:k,dead:x,secondsLeft:Se,announcement:_,emailRef:Q,codeRef:F,sendCode:()=>V("send"),resend:()=>V("resend"),submitCode:he,changeEmail:kn,haveCode:Nn}}import{jsx as mt}from"react/jsx-runtime";function Nr(e){return e.replace(/[\s-]/g,"")}function Tr(e){e!=null&&(e.style.boxSizing="border-box",e.style.padding="0")}function fn({id:e,name:t,value:n,onChange:r,onComplete:a,disabled:i,invalid:s,inputRef:o,autoFocus:g,slotClassName:m,slotStyle:l,className:y,...c}){let f=kr(x=>{Tr(x),typeof o=="function"?o(x):o!=null&&(o.current=x)},[o]),b={className:u("h-11 w-auto min-w-0 flex-1 rounded-md border first:rounded-md last:rounded-md text-base","dark:border-foreground/30 dark:data-[active=true]:border-foreground/70 dark:data-[active=true]:ring-foreground/25","dark:aria-invalid:border-destructive-foreground dark:data-[active=true]:aria-invalid:border-destructive-foreground dark:aria-invalid:ring-destructive-foreground/30 dark:data-[active=true]:aria-invalid:ring-destructive-foreground/30",m),style:l,"aria-invalid":s?!0:void 0};return mt(un,{ref:f,id:e,name:t,maxLength:de,value:n,onChange:r,onComplete:a,disabled:i,autoFocus:g,inputMode:"numeric",autoComplete:"one-time-code",pattern:hr,pasteTransformer:Nr,"aria-invalid":s?!0:void 0,"aria-label":c["aria-label"],"aria-describedby":c["aria-describedby"],containerClassName:u("w-full",y),children:mt(ln,{className:"w-full gap-1.5 sm:gap-2",children:Array.from({length:de},(x,v)=>mt(dn,{index:v,...b},v))})})}import{jsx as G,jsxs as Qe}from"react/jsx-runtime";var ce="bg-[var(--bitsnap-returns-button-background,#18181b)] text-[color:var(--bitsnap-returns-button-foreground,#fafafa)] hover:bg-[var(--bitsnap-returns-button-hover-background,#000000)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",W="border border-[color:var(--bitsnap-returns-border,#e4e4e7)] bg-transparent text-[color:var(--bitsnap-returns-foreground,#18181b)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",Re="bg-[var(--bitsnap-returns-input-background,#ffffff)] dark:bg-[var(--bitsnap-returns-input-background,#ffffff)] border-[color:var(--bitsnap-returns-border,#e4e4e7)] text-[color:var(--bitsnap-returns-foreground,#18181b)] placeholder:text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] focus-visible:border-[color:var(--bitsnap-returns-focus-ring,#71717a)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",gn=u(Re,"data-[active=true]:border-[color:var(--bitsnap-returns-focus-ring,#71717a)] data-[active=true]:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50");function te({title:e,description:t,onBack:n,lead:r,className:a,children:i}){let s=z(),o=d("header"),g=d("title"),m=d("description"),l=d("backButton");return Qe("section",{className:u("flex flex-col gap-5",a),children:[r,Qe("div",{"data-bitsnap-returns-slot":"header",className:u("flex flex-col gap-2",o.className),style:o.style,children:[n!=null&&G(P,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"backButton",className:u("self-start -ml-3 text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",l.className),style:l.style,onClick:n,children:s("back")}),G("h2",{"data-bitsnap-returns-slot":"title",className:u("text-2xl font-semibold",g.className),style:g.style,children:e}),t!=null&&G("p",{"data-bitsnap-returns-slot":"description",className:u("text-sm",m.className),style:m.style,children:t})]}),i]})}function H({errorKey:e,onRetry:t}){let n=z(),r=d("error"),a=d("secondaryButton");return Qe("div",{role:"alert","data-bitsnap-returns-slot":"error",className:u("flex flex-col items-start gap-2 text-sm",r.className),style:r.style,children:[G("p",{children:n(e)}),t!=null&&G(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,a.className),style:a.style,onClick:t,children:n("errorRetry")})]})}function Ve({children:e}){let t=d("emptyState");return G("p",{"data-bitsnap-returns-slot":"emptyState",className:u("py-6 text-center text-sm",t.className),style:t.style,children:e})}function le({rows:e=3}){let t=z(),n=d("skeleton");return G("div",{role:"status","aria-busy":"true","aria-label":t("loading"),className:"flex flex-col gap-3",children:Array.from({length:e},(r,a)=>G(Et,{"data-bitsnap-returns-slot":"skeleton",className:u("h-16 w-full bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",n.className),style:n.style},a))})}function xe({status:e}){let t=z(),n=d("statusBadge");return G("span",{"data-bitsnap-returns-slot":"statusBadge","data-status":e,className:u("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",n.className),style:n.style,children:t(Kt(e))})}function ft(){let e=z();return t=>e(_t(t))}function We({page:e,total:t,hasNext:n,hasPrevious:r,isFetching:a,onNext:i,onPrevious:s}){let o=z(),g=d("pagination"),m=d("secondaryButton");return!n&&!r?null:Qe("nav",{"data-bitsnap-returns-slot":"pagination",className:u("flex items-center justify-between gap-3 text-sm",g.className),style:g.style,children:[G(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,m.className),style:m.style,disabled:!r||a,onClick:s,children:o("paginationPrevious")}),G("span",{"aria-live":"polite",children:o("paginationInfo",{page:e,total:t})}),G(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,m.className),style:m.style,disabled:!n||a,onClick:i,children:o("paginationNext")})]})}import{jsx as K,jsxs as ne}from"react/jsx-runtime";function Ko({onSubmitted:e,className:t,...n}){let r=D("ReturnsEmailStep"),a=z(),i=Z(),s=Fe(),[o,g]=we(r.lastEmail??""),m=d("emailForm"),l=d("emailInput"),y=d("submitButton");async function c(f){f.preventDefault(),!s.isStarting&&await s.start(o)&&e?.(o.trim())}return K(te,{className:t,lead:K(dt,{projectId:r.projectID,locale:i,...n}),title:a("emailStepTitle"),description:a("emailStepDescription"),children:ne("form",{"data-bitsnap-returns-slot":"emailForm",className:u("flex flex-col gap-4",m.className),style:m.style,onSubmit:c,children:[ne("div",{className:"flex flex-col gap-2",children:[K(Te,{htmlFor:"bitsnap-returns-email",children:a("emailLabel")}),K(Tt,{id:"bitsnap-returns-email",type:"email",name:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",spellCheck:!1,autoFocus:!0,required:!0,value:o,placeholder:a("emailPlaceholder"),disabled:s.isStarting,"data-bitsnap-returns-slot":"emailInput",className:u(Re,l.className),style:l.style,onChange:f=>g(f.target.value)})]}),s.errorKey!=null&&K(H,{errorKey:s.errorKey}),ne(P,{type:"submit",disabled:s.isStarting,"data-bitsnap-returns-slot":"submitButton",className:u(ce,y.className),style:y.style,children:[s.isStarting&&K(ye,{}),a("emailSubmit")]})]})})}function _o({onVerified:e,onBack:t,className:n,...r}){let a=D("ReturnsCodeStep"),i=z(),s=Z(),o=Fe(),[g,m]=we(""),[l,y]=we(!1),[c,f]=we(!1),[b,x]=we(1),v=yn(null),k=yn(!1),S=qe(o.challenge?.resendAvailableAt),w=d("codeForm"),h=d("codeInput"),C=d("submitButton"),U=d("resendButton"),_=o.isVerifying||o.isStarting,J="bitsnap-returns-code",N=`${J}-hint`;wr(()=>{_||v.current?.focus()},[b,_]);async function Y(F){if(!(_||k.current)){if(F.length!==de){y(!0),x(re=>re+1);return}k.current=!0,y(!1),f(!1);try{await o.verify(F)?e?.():(m(""),x(re=>re+1))}finally{k.current=!1}}}async function O(F){F.preventDefault(),await Y(g)}async function j(){y(!1),f(!1),await o.resend()&&(m(""),f(!0)),x(F=>F+1)}function Q(){a.setChallenge(void 0),t?.()}return K(te,{className:n,onBack:t!=null?Q:void 0,lead:K(dt,{projectId:a.projectID,locale:s,...r}),title:i("codeStepTitle"),description:i("codeStepDescription",{email:o.challenge?.email??""}),children:ne("form",{"data-bitsnap-returns-slot":"codeForm",className:u("flex flex-col gap-4",w.className),style:w.style,noValidate:!0,onSubmit:O,children:[ne("div",{className:"flex flex-col gap-2",children:[K(Te,{htmlFor:J,children:i("codeLabel")}),K(fn,{id:J,name:"code",inputRef:v,value:g,disabled:_,invalid:o.errorKey!=null||l,"aria-describedby":N,slotClassName:u(gn,h.className),slotStyle:h.style,onChange:F=>{m(F.replace(/\D/g,"")),y(!1)},onComplete:F=>void Y(F)}),ne("p",{id:N,className:"text-xs",children:[i("codeValidity")," ",i("codeSpamHint")]})]}),ne("div",{className:"min-h-10",children:[l&&K("p",{role:"alert",className:"text-sm",children:i("codeIncomplete")}),!l&&o.errorKey!=null&&K(H,{errorKey:o.errorKey}),!l&&o.errorKey==null&&c&&K("p",{role:"status",className:"text-sm",children:i("resendSent")})]}),ne("div",{className:"flex flex-wrap items-center gap-3",children:[ne(P,{type:"submit",disabled:_||o.challenge==null,"data-bitsnap-returns-slot":"submitButton",className:u("h-11",ce,C.className),style:C.style,children:[o.isVerifying&&K(ye,{"aria-hidden":!0}),i("codeSubmit")]}),ne(P,{type:"button",variant:"secondary",disabled:_||S>0||o.challenge==null,"data-bitsnap-returns-slot":"resendButton",className:u("h-11",W,U.className),style:U.style,onClick:()=>void j(),children:[o.isStarting&&K(ye,{"aria-hidden":!0}),S>0?i("resendIn",{seconds:S}):i("resend")]})]})]})})}function bn(){let e=z(),t=Fe(),n=d("logoutButton");return K(P,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"logoutButton",className:u("text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",n.className),style:n.style,onClick:t.logout,children:e("logout")})}import{useEffect as Cr,useState as yt}from"react";import{timestampDate as Er}from"@bufbuild/protobuf/wkt";function pe(e,t){if(e==null)return"";let n=Er(e);try{return new Intl.DateTimeFormat(t,{dateStyle:"medium"}).format(n)}catch{return n.toISOString().slice(0,10)}}function ve(e,t,n){let r=typeof e=="bigint"?e:BigInt(Math.trunc(e));try{let a=new Intl.NumberFormat(n,{style:"currency",currency:t}),i=a.resolvedOptions().maximumFractionDigits??2;return a.format(Rn(r,i))}catch{return`${Rn(r,2)} ${t}`}}function Rn(e,t){let n=e<BigInt(0),r=n?-e:e;if(t<=0)return`${n?"-":""}${r}`;let a=BigInt(10)**BigInt(t),i=r/a,s=(r%a).toString().padStart(t,"0");return`${n?"-":""}${i}.${s}`}function xn(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.trunc(e)),Math.max(0,t)):0}function gt(e){return e.eligible&&e.availableQuantity>0}function vn(e,t){return e.map(n=>({lineId:n,quantity:t[n]??0})).filter(n=>n.quantity>0)}import{Fragment as Sn,jsx as p,jsxs as E}from"react/jsx-runtime";function la({onSelectOrder:e,onOpenMyReturns:t,showLogout:n=!0,pageSize:r,className:a}){D("ReturnsOrderList");let i=z(),s=Z(),o=tn({pageSize:r}),g=d("orderList"),m=d("orderCard"),l=d("orderReference"),y=d("orderDate"),c=d("orderTotal"),f=d("secondaryButton");return E(te,{className:a,title:i("ordersTitle"),description:i("ordersDescription"),children:[(n||t!=null)&&E("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t!=null?p(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,f.className),style:f.style,onClick:t,children:i("myReturnsLink")}):p("span",{}),n&&p(bn,{})]}),o.isLoading?p(le,{}):o.errorKey!=null?p(H,{errorKey:o.errorKey,onRetry:o.refetch}):o.orders.length===0?p(Ve,{children:i("ordersEmpty")}):E(Sn,{children:[p("ul",{"data-bitsnap-returns-slot":"orderList",className:u("flex flex-col gap-3",g.className),style:g.style,children:o.orders.map(b=>E("li",{"data-bitsnap-returns-slot":"orderCard",className:u("flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[E("div",{className:"flex flex-col gap-1",children:[p("span",{"data-bitsnap-returns-slot":"orderReference",className:u("font-medium",l.className),style:l.style,children:i("orderTitle",{reference:b.displayReference})}),p("span",{"data-bitsnap-returns-slot":"orderDate",className:u("text-sm",y.className),style:y.style,children:pe(b.purchasedAt,s)}),p("span",{className:"text-sm",children:i("orderReturnableLines",{count:b.returnableLineCount})})]}),E("div",{className:"flex items-center gap-4",children:[p("span",{"data-bitsnap-returns-slot":"orderTotal",className:u("font-medium",c.className),style:c.style,children:ve(b.totalMinor,b.currency,s)}),p(P,{type:"button",variant:"secondary",size:"sm","aria-label":`${i("orderSelect")}: ${i("orderTitle",{reference:b.displayReference})}`,"data-bitsnap-returns-slot":"secondaryButton",className:u(W,f.className),style:f.style,onClick:()=>e?.(b.canonicalOrderId),children:i("orderSelect")})]})]},b.canonicalOrderId))}),p(We,{page:o.page,total:o.total,hasNext:o.hasNext,hasPrevious:o.hasPrevious,isFetching:o.isFetching,onNext:o.next,onPrevious:o.previous})]})]})}function da({orderId:e,onContinue:t,onBack:n,initialItems:r,initialNote:a,className:i}){D("ReturnsOrderDetail");let s=Ee();Cr(()=>{s.track("return_started",{},{order_ref:null})},[s]);let o=z(),g=Z(),{order:m,returnHistory:l,isLoading:y,errorKey:c,refetch:f}=it(e),[b,x]=yt(()=>Object.fromEntries((r??[]).map(R=>[R.lineId,R.quantity]))),[v,k]=yt(a??""),[S,w]=yt(!1),h=d("lineList"),C=d("line"),U=d("lineName"),_=d("linePrice"),J=d("lineQuantityControl"),N=d("quantityButton"),Y=d("quantityInput"),O=d("lineIneligibleReason"),j=d("noteInput"),Q=d("submitButton"),F=d("history"),re=d("historyEntry");function Se(R,X){w(!1),x(V=>({...V,[R.lineId]:xn(X,R.availableQuantity)}))}function B(R){if(R.preventDefault(),m==null)return;let X=vn(m.lines.filter(gt).map(V=>V.lineId),b);if(X.length===0){w(!0);return}t?.({items:X,note:v.trim()})}return p(te,{className:i,onBack:n,title:o("orderDetailTitle",{reference:m?.displayReference??""}),description:o("orderDetailDescription"),children:y?p(le,{}):c!=null?p(H,{errorKey:c,onRetry:f}):m==null?null:E("form",{className:"flex flex-col gap-5",onSubmit:B,children:[p("ul",{"data-bitsnap-returns-slot":"lineList",className:u("flex flex-col gap-3",h.className),style:h.style,children:m.lines.map(R=>{let X=gt(R),V=b[R.lineId]??0,he=`bitsnap-returns-quantity-${R.lineId}`;return E("li",{"data-bitsnap-returns-slot":"line","data-selected":V>0?"":void 0,"data-ineligible":X?void 0:"",className:u("flex flex-col gap-3 border p-4",C.className),style:C.style,children:[E("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[p("span",{"data-bitsnap-returns-slot":"lineName",className:u("font-medium",U.className),style:U.style,children:R.name}),p("span",{"data-bitsnap-returns-slot":"linePrice",className:u("text-sm",_.className),style:_.style,children:ve(R.paidUnitMinor,R.currency,g)})]}),X?E("div",{role:"group","aria-label":o("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"lineQuantityControl",className:u("flex items-center gap-2",J.className),style:J.style,children:[p(P,{type:"button",variant:"secondary",size:"icon-sm","aria-label":o("quantityDecrease",{name:R.name}),"aria-controls":he,disabled:V<=0,"data-bitsnap-returns-slot":"quantityButton",className:u(W,N.className),style:N.style,onClick:()=>Se(R,V-1),children:p("span",{"aria-hidden":"true",children:"-"})}),p("input",{id:he,type:"number",inputMode:"numeric",min:0,max:R.availableQuantity,step:1,value:V,"aria-label":o("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"quantityInput",className:u("h-8 w-16 rounded-md border px-2 text-center text-sm outline-none focus-visible:ring-[3px]",Re,Y.className),style:Y.style,onChange:He=>Se(R,He.target.valueAsNumber)}),p(P,{type:"button",variant:"secondary",size:"icon-sm","aria-label":o("quantityIncrease",{name:R.name}),"aria-controls":he,disabled:V>=R.availableQuantity,"data-bitsnap-returns-slot":"quantityButton",className:u(W,N.className),style:N.style,onClick:()=>Se(R,V+1),children:p("span",{"aria-hidden":"true",children:"+"})}),p("span",{className:"text-sm",children:o("quantityOfAvailable",{available:R.availableQuantity})})]}):p("p",{"data-bitsnap-returns-slot":"lineIneligibleReason",className:u("text-sm",O.className),style:O.style,children:R.exclusionReason!==""?R.exclusionReason:o("lineIneligibleFallback")})]},R.lineId)})}),E("div",{className:"flex flex-col gap-2",children:[p(Te,{htmlFor:"bitsnap-returns-note",children:o("noteLabel")}),p(Ct,{id:"bitsnap-returns-note",name:"note",rows:3,maxLength:1e3,value:v,placeholder:o("notePlaceholder"),"data-bitsnap-returns-slot":"noteInput",className:u(Re,"dark:border-[color:var(--bitsnap-returns-border,#e4e4e7)] dark:placeholder:text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] dark:focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]",j.className),style:j.style,onChange:R=>k(R.target.value)})]}),S&&p(H,{errorKey:"selectionEmpty"}),p(P,{type:"submit","data-bitsnap-returns-slot":"submitButton",className:u(ce,Q.className),style:Q.style,children:o("selectionContinue")}),l.length>0&&E("div",{className:"flex flex-col gap-2",children:[p("h3",{className:"text-sm font-medium",children:o("previousReturnsTitle")}),p("ul",{"data-bitsnap-returns-slot":"history",className:u("flex flex-col gap-2",F.className),style:F.style,children:l.map(R=>E("li",{"data-bitsnap-returns-slot":"historyEntry",className:u("flex flex-wrap items-center justify-between gap-2 text-sm",re.className),style:re.style,children:[p("span",{children:R.reference}),p("span",{children:pe(R.createdAt,g)}),p(xe,{status:R.status})]},R.id))})]})]})})}function ca({orderId:e,items:t,note:n,onSubmitted:r,onBack:a,className:i}){D("ReturnsConfirmation");let s=z(),o=Z(),{order:g,isLoading:m,errorKey:l,refetch:y}=it(e),c=nn(),f=d("summary"),b=d("line"),x=d("lineName"),v=d("linePrice"),k=d("submitButton");async function S(w){if(w.preventDefault(),c.isPending)return;let h=await c.submit({orderId:e,items:t.map(C=>({lineId:C.lineId,quantity:C.quantity})),note:n});h!=null&&r?.(h.id,h)}return p(te,{className:i,onBack:a,title:s("confirmationTitle"),description:s("confirmationDescription"),children:m?p(le,{rows:2}):l!=null?p(H,{errorKey:l,onRetry:y}):E("form",{className:"flex flex-col gap-5",onSubmit:S,children:[E("div",{"data-bitsnap-returns-slot":"summary",className:u("flex flex-col gap-3 border p-4",f.className),style:f.style,children:[p("h3",{className:"text-sm font-medium",children:s("confirmationSummary")}),p("ul",{className:"flex flex-col gap-3",children:t.map(w=>{let h=g?.lines.find(C=>C.lineId===w.lineId);return E("li",{"data-bitsnap-returns-slot":"line",className:u("flex flex-wrap items-baseline justify-between gap-2",b.className),style:b.style,children:[p("span",{"data-bitsnap-returns-slot":"lineName",className:u("font-medium",x.className),style:x.style,children:h?.name??w.lineId}),E("span",{"data-bitsnap-returns-slot":"linePrice",className:u("text-sm",v.className),style:v.style,children:[s("confirmationQuantity",{quantity:w.quantity}),h!=null&&` \xB7 ${ve(h.paidUnitMinor*BigInt(w.quantity),h.currency,o)}`]})]},w.lineId)})}),n!=null&&n!==""&&E("div",{className:"flex flex-col gap-1 text-sm",children:[p("span",{className:"font-medium",children:s("confirmationNote")}),p("span",{className:"whitespace-pre-wrap",children:n})]})]}),c.errorKey!=null&&p(H,{errorKey:c.errorKey}),E(P,{type:"submit",disabled:c.isPending||t.length===0,"data-bitsnap-returns-slot":"submitButton",className:u(ce,k.className),style:k.style,children:[c.isPending&&p(ye,{}),s("confirmationSubmit")]})]})})}function pa({returnId:e,onContinue:t,onOpenMyReturns:n,className:r}){D("ReturnsResult");let a=z(),{request:i,isLoading:s,errorKey:o,refetch:g}=_e(e),m=d("successState"),l=d("returnReference"),y=d("returnInstructions"),c=d("submitButton"),f=d("secondaryButton");return E("section",{className:u("flex flex-col gap-5",r),children:[E("div",{role:"status","data-bitsnap-returns-slot":"successState",className:u("flex flex-col gap-4 border p-5",m.className),style:m.style,children:[p("h2",{className:"text-2xl font-semibold",children:a("successTitle")}),p("p",{className:"text-sm",children:a("successDescription")}),s?p(le,{rows:2}):o!=null?p(H,{errorKey:o,onRetry:g}):i!=null&&E(Sn,{children:[E("div",{className:"flex flex-col gap-1",children:[p("span",{className:"text-sm",children:a("successReference")}),p("span",{"data-bitsnap-returns-slot":"returnReference",className:u("text-lg font-semibold",l.className),style:l.style,children:i.reference})]}),i.returnInstructions!==""&&E("div",{className:"flex flex-col gap-1",children:[p("span",{className:"text-sm font-medium",children:a("successInstructions")}),p("p",{"data-bitsnap-returns-slot":"returnInstructions",className:u("whitespace-pre-wrap border p-3 text-sm",y.className),style:y.style,children:i.returnInstructions})]})]})]}),E("div",{className:"flex flex-wrap gap-3",children:[p(P,{type:"button","data-bitsnap-returns-slot":"submitButton",className:u(ce,c.className),style:c.style,onClick:t,children:a("successDone")}),n!=null&&p(P,{type:"button",variant:"secondary","data-bitsnap-returns-slot":"secondaryButton",className:u(W,f.className),style:f.style,onClick:n,children:a("myReturnsLink")})]})]})}import{Fragment as Ir,jsx as I,jsxs as q}from"react/jsx-runtime";function Na({onSelectReturn:e,onBack:t,pageSize:n,className:r}){D("ReturnsMyReturnsList");let a=z(),i=Z(),s=ft(),o=rn({pageSize:n}),g=d("returnList"),m=d("returnCard"),l=d("returnReference"),y=d("secondaryButton");return I(te,{className:r,onBack:t,title:a("myReturnsTitle"),description:a("myReturnsDescription"),children:o.isLoading?I(le,{}):o.errorKey!=null?I(H,{errorKey:o.errorKey,onRetry:o.refetch}):o.returns.length===0?I(Ve,{children:a("myReturnsEmpty")}):q(Ir,{children:[I("ul",{"data-bitsnap-returns-slot":"returnList",className:u("flex flex-col gap-3",g.className),style:g.style,children:o.returns.map(c=>q("li",{"data-bitsnap-returns-slot":"returnCard",className:u("flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[q("div",{className:"flex flex-col gap-1",children:[I("span",{"data-bitsnap-returns-slot":"returnReference",className:u("font-medium",l.className),style:l.style,children:c.reference}),I("span",{className:"text-sm",children:pe(c.createdAt,i)}),q("span",{className:"text-sm",children:[a("myReturnRefund"),": ",s(c.refundStatus)]})]}),q("div",{className:"flex items-center gap-3",children:[I(xe,{status:c.status}),I(P,{type:"button",variant:"secondary",size:"sm","aria-label":`${a("myReturnOpen")}: ${c.reference}`,"data-bitsnap-returns-slot":"secondaryButton",className:u(W,y.className),style:y.style,onClick:()=>e?.(c.id),children:a("myReturnOpen")})]})]},c.id))}),I(We,{page:o.page,total:o.total,hasNext:o.hasNext,hasPrevious:o.hasPrevious,isFetching:o.isFetching,onNext:o.next,onPrevious:o.previous})]})})}function Ta({returnId:e,onBack:t,className:n}){D("ReturnsMyReturnDetail");let r=z(),a=Z(),i=ft(),{request:s,isLoading:o,errorKey:g,refetch:m}=_e(e),l=d("summary"),y=d("lineList"),c=d("line"),f=d("lineName"),b=d("returnInstructions"),x=d("history"),v=d("historyEntry");return I(te,{className:n,onBack:t,title:s!=null?r("myReturnTitle",{reference:s.reference}):r("myReturnDetailTitle"),children:o?I(le,{}):g!=null?I(H,{errorKey:g,onRetry:m}):s!=null&&q("div",{className:"flex flex-col gap-5",children:[q("div",{"data-bitsnap-returns-slot":"summary",className:u("flex flex-col gap-2 border p-4 text-sm",l.className),style:l.style,children:[q("div",{className:"flex items-center justify-between gap-2",children:[I(xe,{status:s.status}),q("span",{children:[r("myReturnCreatedAt"),":"," ",pe(s.createdAt,a)]})]}),q("span",{children:[r("myReturnRefund"),": ",i(s.refundStatus),s.refundAmountMinor>BigInt(0)&&` \xB7 ${ve(s.refundAmountMinor,s.currency,a)}`]}),s.customerNote!==""&&q("span",{className:"whitespace-pre-wrap",children:[r("myReturnNote"),": ",s.customerNote]})]}),s.returnInstructions!==""&&I("p",{"data-bitsnap-returns-slot":"returnInstructions",className:u("whitespace-pre-wrap border p-3 text-sm",b.className),style:b.style,children:s.returnInstructions}),q("div",{className:"flex flex-col gap-2",children:[I("h3",{className:"text-sm font-medium",children:r("myReturnLines")}),I("ul",{"data-bitsnap-returns-slot":"lineList",className:u("flex flex-col gap-3",y.className),style:y.style,children:s.lines.map(k=>q("li",{"data-bitsnap-returns-slot":"line",className:u("flex flex-wrap items-baseline justify-between gap-2 border p-4",c.className),style:c.style,children:[I("span",{"data-bitsnap-returns-slot":"lineName",className:u("font-medium",f.className),style:f.style,children:k.name}),I("span",{className:"text-sm",children:r("myReturnLineQuantities",{requested:k.requestedQuantity,approved:k.approvedQuantity,received:k.receivedQuantity})})]},k.lineId))})]}),s.history.length>0&&q("div",{className:"flex flex-col gap-2",children:[I("h3",{className:"text-sm font-medium",children:r("myReturnHistory")}),I("ul",{"data-bitsnap-returns-slot":"history",className:u("flex flex-col gap-2",x.className),style:x.style,children:s.history.map(k=>q("li",{"data-bitsnap-returns-slot":"historyEntry",className:u("flex flex-wrap items-center justify-between gap-2 text-sm",v.className),style:v.style,children:[I(xe,{status:k.status}),I("span",{children:pe(k.createdAt,a)})]},k.id))})]})]})})}export{Zt as a,pr as b,dt as c,Te as d,ye as e,Ut as f,xr as g,eo as h,ct as i,ao as j,fn as k,Pr as l,Ot as m,$e as n,d as o,st as p,Xt as q,z as r,Z as s,D as t,Xn as u,ls as v,Fe as w,tn as x,it as y,nn as z,rn as A,_e as B,le as C,Ko as D,_o as E,la as F,da as G,ca as H,pa as I,Na as J,Ta as K};
2
+ //# sourceMappingURL=chunk-HKNWW37T.mjs.map