bitsnap-react 1.16.0 → 1.18.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 (125) hide show
  1. package/AGENTS.md +5 -0
  2. package/README.md +87 -0
  3. package/dist/CartProvider-ECQQH3PS.css +2 -0
  4. package/dist/CartProvider-ECQQH3PS.css.map +1 -0
  5. package/dist/CartProvider-OEI526IN.js +2 -0
  6. package/dist/{CartProvider-VGZMDVFJ.js.map → CartProvider-OEI526IN.js.map} +1 -1
  7. package/dist/CartProvider-RYAA3JDA.mjs +2 -0
  8. package/dist/{PanelModelFiles-NYCOFPLY.js → PanelModelFiles-7HPXWONN.js} +2 -2
  9. package/dist/{PanelModelFiles-NYCOFPLY.js.map → PanelModelFiles-7HPXWONN.js.map} +1 -1
  10. package/dist/PanelModelFiles-JZFSF7BF.mjs +2 -0
  11. package/dist/PanelModelFiles-JZFSF7BF.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.mjs +1 -1
  16. package/dist/catalog.css +1 -1
  17. package/dist/catalog.css.map +1 -1
  18. package/dist/catalog.d.mts +3 -1
  19. package/dist/catalog.d.ts +3 -1
  20. package/dist/catalog.js +1 -1
  21. package/dist/catalog.mjs +1 -1
  22. package/dist/{chunk-GXUNRJ5S.js → chunk-4HGZZJEL.js} +2 -2
  23. package/dist/{chunk-GXUNRJ5S.js.map → chunk-4HGZZJEL.js.map} +1 -1
  24. package/dist/chunk-4OVOKGGS.mjs +2 -0
  25. package/dist/chunk-4OVOKGGS.mjs.map +1 -0
  26. package/dist/chunk-5X7TP3TQ.mjs +2 -0
  27. package/dist/{chunk-SULHGFYN.mjs.map → chunk-5X7TP3TQ.mjs.map} +1 -1
  28. package/dist/{chunk-QQQ2JSPQ.mjs → chunk-CF45RDMD.mjs} +2 -2
  29. package/dist/{chunk-QQQ2JSPQ.mjs.map → chunk-CF45RDMD.mjs.map} +1 -1
  30. package/dist/{chunk-GQJDFLSL.js → chunk-DP2NOHCI.js} +2 -2
  31. package/dist/{chunk-GQJDFLSL.js.map → chunk-DP2NOHCI.js.map} +1 -1
  32. package/dist/chunk-EVIDNS22.mjs +2 -0
  33. package/dist/chunk-EVIDNS22.mjs.map +1 -0
  34. package/dist/chunk-G4V2KWTV.js +2 -0
  35. package/dist/chunk-G4V2KWTV.js.map +1 -0
  36. package/dist/{chunk-SXKJ26OA.mjs → chunk-GEBRXFT3.mjs} +2 -2
  37. package/dist/chunk-GWF3MRUP.js +2 -0
  38. package/dist/chunk-GWF3MRUP.js.map +1 -0
  39. package/dist/chunk-JA62KNAQ.js +2 -0
  40. package/dist/chunk-JA62KNAQ.js.map +1 -0
  41. package/dist/chunk-JHJ3ZZF4.mjs +2 -0
  42. package/dist/chunk-JHJ3ZZF4.mjs.map +1 -0
  43. package/dist/{chunk-WKE6ECID.mjs → chunk-UPAOIY4R.mjs} +2 -2
  44. package/dist/chunk-V5ECGBFW.js +5 -0
  45. package/dist/chunk-V5ECGBFW.js.map +1 -0
  46. package/dist/{chunk-SRQOFCMO.js → chunk-VNV5BD4X.js} +2 -2
  47. package/dist/{chunk-SRQOFCMO.js.map → chunk-VNV5BD4X.js.map} +1 -1
  48. package/dist/chunk-WJO5GSY3.mjs +5 -0
  49. package/dist/chunk-WJO5GSY3.mjs.map +1 -0
  50. package/dist/chunk-ZATPBYOA.js +2 -0
  51. package/dist/chunk-ZATPBYOA.js.map +1 -0
  52. package/dist/chunk-ZHTMK5TA.mjs +2 -0
  53. package/dist/chunk-ZHTMK5TA.mjs.map +1 -0
  54. package/dist/course.d.mts +13 -3
  55. package/dist/course.d.ts +13 -3
  56. package/dist/course.js +1 -1
  57. package/dist/course.js.map +1 -1
  58. package/dist/course.mjs +1 -1
  59. package/dist/course.mjs.map +1 -1
  60. package/dist/embed/analytics.js +1 -1
  61. package/dist/index.css +1 -1
  62. package/dist/index.css.map +1 -1
  63. package/dist/index.d.mts +41 -12
  64. package/dist/index.d.ts +41 -12
  65. package/dist/index.js +1 -1
  66. package/dist/index.js.map +1 -1
  67. package/dist/index.mjs +1 -1
  68. package/dist/index.mjs.map +1 -1
  69. package/dist/{instrument-BE8ktMUv.d.mts → instrument-eXaC8hc2.d.mts} +1 -1
  70. package/dist/{instrument-BE8ktMUv.d.ts → instrument-eXaC8hc2.d.ts} +1 -1
  71. package/dist/methods-AULQDKVS.mjs +2 -0
  72. package/dist/methods-OJEZREBK.css +2 -0
  73. package/dist/methods-OJEZREBK.css.map +1 -0
  74. package/dist/methods-PMH5VQ25.js +2 -0
  75. package/dist/{methods-WRONKK3D.js.map → methods-PMH5VQ25.js.map} +1 -1
  76. package/dist/returns.d.mts +19 -10
  77. package/dist/returns.d.ts +19 -10
  78. package/dist/returns.js +1 -1
  79. package/dist/returns.js.map +1 -1
  80. package/dist/returns.mjs +1 -1
  81. package/dist/{texts-tQtAGJCT.d.mts → texts-LGhuQfA9.d.mts} +28 -3
  82. package/dist/{texts-CIEFbJTN.d.ts → texts-m6XQGZ6w.d.ts} +28 -3
  83. package/dist/types-ClFCVzk_.d.ts +121 -0
  84. package/dist/types-D6LsoycW.d.mts +121 -0
  85. package/dist/viewer3d.css +1 -1
  86. package/dist/viewer3d.css.map +1 -1
  87. package/dist/viewer3d.mjs +1 -1
  88. package/package.json +2 -2
  89. package/dist/CartProvider-PDEV6GCV.css +0 -2
  90. package/dist/CartProvider-PDEV6GCV.css.map +0 -1
  91. package/dist/CartProvider-VGZMDVFJ.js +0 -2
  92. package/dist/CartProvider-ZY5OLTAF.mjs +0 -2
  93. package/dist/PanelModelFiles-RV7OHUUZ.mjs +0 -2
  94. package/dist/PanelModelFiles-RV7OHUUZ.mjs.map +0 -1
  95. package/dist/chunk-5AYH23UJ.mjs +0 -4
  96. package/dist/chunk-5AYH23UJ.mjs.map +0 -1
  97. package/dist/chunk-AGYS7Z6G.mjs +0 -2
  98. package/dist/chunk-AGYS7Z6G.mjs.map +0 -1
  99. package/dist/chunk-DPKWYLN7.mjs +0 -2
  100. package/dist/chunk-DPKWYLN7.mjs.map +0 -1
  101. package/dist/chunk-I3QXJJ7U.mjs +0 -2
  102. package/dist/chunk-I3QXJJ7U.mjs.map +0 -1
  103. package/dist/chunk-LL7ASBGY.js +0 -2
  104. package/dist/chunk-LL7ASBGY.js.map +0 -1
  105. package/dist/chunk-OZHXRKMX.js +0 -2
  106. package/dist/chunk-OZHXRKMX.js.map +0 -1
  107. package/dist/chunk-QERYM7RC.js +0 -2
  108. package/dist/chunk-QERYM7RC.js.map +0 -1
  109. package/dist/chunk-QXGK337V.mjs +0 -2
  110. package/dist/chunk-QXGK337V.mjs.map +0 -1
  111. package/dist/chunk-SULHGFYN.mjs +0 -2
  112. package/dist/chunk-WPOXLITY.js +0 -2
  113. package/dist/chunk-WPOXLITY.js.map +0 -1
  114. package/dist/chunk-Y5KWVTXT.js +0 -4
  115. package/dist/chunk-Y5KWVTXT.js.map +0 -1
  116. package/dist/methods-NJEP64AG.mjs +0 -2
  117. package/dist/methods-QAZED7TJ.css +0 -2
  118. package/dist/methods-QAZED7TJ.css.map +0 -1
  119. package/dist/methods-WRONKK3D.js +0 -2
  120. package/dist/types-DP1vxo5E.d.mts +0 -53
  121. package/dist/types-u8VwmC3j.d.ts +0 -53
  122. /package/dist/{CartProvider-ZY5OLTAF.mjs.map → CartProvider-RYAA3JDA.mjs.map} +0 -0
  123. /package/dist/{chunk-SXKJ26OA.mjs.map → chunk-GEBRXFT3.mjs.map} +0 -0
  124. /package/dist/{chunk-WKE6ECID.mjs.map → chunk-UPAOIY4R.mjs.map} +0 -0
  125. /package/dist/{methods-NJEP64AG.mjs.map → methods-AULQDKVS.mjs.map} +0 -0
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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 _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunkG4V2KWTVjs = require('./chunk-G4V2KWTV.js');var _chunk4HGZZJELjs = require('./chunk-4HGZZJEL.js');var _chunkDP2NOHCIjs = require('./chunk-DP2NOHCI.js');var _chunk7RXW6XFYjs = require('./chunk-7RXW6XFY.js');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=_chunkKOYBZORLjs.a.call(void 0, 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 _chunkKOYBZORLjs.b.call(void 0, e.elements,t)}var _react = require('react'); var an = _interopRequireWildcard(_react);var _jsxruntime = require('react/jsx-runtime');var At=_react.createContext.call(void 0, Ze());function Ot({appearance:e,children:t}){let n=_react.useMemo.call(void 0, ()=>Ze(e),[e]);return _jsxruntime.jsx.call(void 0, At.Provider,{value:n,children:t})}function $e(){return _react.useContext.call(void 0, At)}function d(e){let t=$e();return _nullishCoalesce(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=_optionalChain([t, 'optionalAccess', _2 => _2.brandColor, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);return n==null||n===""?e:{...e,tokens:{..._chunkG4V2KWTVjs.t.call(void 0, n),..._optionalChain([e, 'optionalAccess', _5 => _5.tokens])}}}function Ge(e,t){return typeof e=="object"&&e!=null?{pageSize:_nullishCoalesce(e.pageSize, () => (20)),explicitPageToken:void 0}:typeof e=="number"||t!==void 0?{pageSize:_nullishCoalesce(e, () => (20)),explicitPageToken:_nullishCoalesce(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 _chunk7RXW6XFYjs.b.call(void 0, 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 _nullishCoalesce(On[e], () => ("statusFallback"))}function _t(e){return _nullishCoalesce(zn[e], () => ("refundStatusFallback"))}var Je=_react.createContext.call(void 0, {locale:"pl-PL",texts:Xe("pl-PL")});function qt({texts:e,locale:t,children:n}){let r=_nullishCoalesce(t, () => (_chunk7RXW6XFYjs.f.call(void 0, ))),a=_react.useMemo.call(void 0, ()=>({locale:r,texts:Xe(r,e)}),[r,e]);return _jsxruntime.jsx.call(void 0, Je.Provider,{value:a,children:n})}function z(){let{texts:e}=_react.useContext.call(void 0, Je);return _react.useCallback.call(void 0, (t,n)=>n==null?e[t]:Ft(e[t],n),[e])}function Z(){return _react.useContext.call(void 0, Je).locale}var _connect = require('@connectrpc/connect');var _connectquery = require('@connectrpc/connect-query');var _reactquery = require('@tanstack/react-query');function et(){try{return typeof window<"u"?window.sessionStorage:void 0}catch (e2){return}}function Ut(e,t,n){return`bitsnap-login-pending:${e}:${encodeURIComponent(_nullishCoalesce(n, () => ("")))}:${encodeURIComponent(_nullishCoalesce(t, () => ("")))}`}function Le(e,t){try{_optionalChain([et, 'call', _6 => _6(), 'optionalAccess', _7 => _7.setItem, 'call', _8 => _8(e,JSON.stringify(t))])}catch (e3){}}function me(e){try{_optionalChain([et, 'call', _9 => _9(), 'optionalAccess', _10 => _10.removeItem, 'call', _11 => _11(e)])}catch (e4){}}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 (e5){try{n.removeItem(e)}catch (e6){}}}var _wkt = require('@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 (e7){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 (e8){try{e.removeItem(r)}catch (e9){}}}function Vt(e,t,n){try{_optionalChain([e, 'optionalAccess', _12 => _12.setItem, 'call', _13 => _13(tt(t),JSON.stringify(n))])}catch (e10){}}function nt(e,t){try{_optionalChain([e, 'optionalAccess', _14 => _14.removeItem, 'call', _15 => _15(tt(t))])}catch (e11){}}function Oe(e){return e==null?void 0:_wkt.timestampMs.call(void 0, e)}var Yt=_react.createContext.call(void 0, void 0);function D(e){let t=_react.useContext.call(void 0, Yt);if(t==null)throw new Error(`${e} must be rendered inside <ReturnsProvider>`);return t}function rt(){return _connectquery.createConnectQueryKey.call(void 0, {schema:_chunkG4V2KWTVjs.j,cardinality:void 0})}var $n=2**31-1;function Gn({projectID:e,environment:t,transport:n,panelAccessToken:r,className:a,children:i}){let s=_reactquery.useQueryClient.call(void 0, ),{boundaryClassName:o,boundaryStyle:g}=$e(),m=d("root"),[l,y]=_react.useState.call(void 0, {status:"hydrating"}),[c,f]=_react.useState.call(void 0, ),[b,x]=_react.useState.call(void 0, ),[v,k]=_react.useState.call(void 0, ),S=Ut("returns",e),w=_react.useRef.call(void 0, void 0),h=_react.useCallback.call(void 0, 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=_react.useCallback.call(void 0, ()=>{s.removeQueries({queryKey:rt()})},[s]),U=_react.useCallback.call(void 0, ()=>{nt(Ae(),e),h(void 0),y({status:"anonymous"}),C()},[e,C,h]),_=_react.useCallback.call(void 0, N=>{Vt(Ae(),e,N),f(void 0),h(void 0),y({status:"authenticated",token:N.token,expiresAt:N.expiresAt})},[e,h]);_react.useEffect.call(void 0, ()=>{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;_optionalChain([Q, 'optionalAccess', _16 => _16.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"}),_connect.createClient.call(void 0, _chunkG4V2KWTVjs.j,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]),_react.useEffect.call(void 0, ()=>{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=_react.useMemo.call(void 0, ()=>({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 _jsxruntime.jsx.call(void 0, Yt.Provider,{value:J,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-returns":"root","data-bitsnap-returns-slot":"root",className:_chunk4HGZZJELjs.g.call(void 0, "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=_chunkDP2NOHCIjs.n.call(void 0, e,m,"returns"),c=_react.useContext.call(void 0, _reactquery.QueryClientContext),[f]=_react.useState.call(void 0, ()=>c==null?new (0, _reactquery.QueryClient)({defaultOptions:{queries:{staleTime:5e3}}}):void 0),b=_nullishCoalesce(t, () => (_chunkG4V2KWTVjs.n.call(void 0, ))),x=_react.useMemo.call(void 0, ()=>_chunkG4V2KWTVjs.o.call(void 0, b),[b]),v=_optionalChain([i, 'optionalAccess', _17 => _17.brandColor]),k=_react.useMemo.call(void 0, ()=>Dt(r,{brandColor:v}),[r,v]),S=_react.useMemo.call(void 0, ()=>Mt(a),[a]),w=_jsxruntime.jsx.call(void 0, _chunkDP2NOHCIjs.l,{value:y,children:_jsxruntime.jsx.call(void 0, _connectquery.TransportProvider,{transport:x,children:_jsxruntime.jsx.call(void 0, Ot,{appearance:k,children:_jsxruntime.jsx.call(void 0, qt,{texts:S,locale:s,children:_jsxruntime.jsx.call(void 0, Gn,{projectID:e,environment:Bt(n),transport:x,panelAccessToken:o,className:g,children:l})})})})});return c==null&&f!=null?_jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:f,children:w}):w}var ls=Xn;function Zt(e){let t=_connect.ConnectError.from(e);switch(t.code){case _connect.Code.ResourceExhausted:return"rateLimited";case _connect.Code.Unavailable:case _connect.Code.DeadlineExceeded:case _connect.Code.Canceled:return"network";case _connect.Code.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(_connect.ConnectError.from(e).code===_connect.Code.ResourceExhausted)return"errorRateLimited";if(Zt(e)==="network")return"errorNetwork"}return"errorGeneric"}function ot(){let e=typeof globalThis<"u"?globalThis.crypto:void 0;if(typeof _optionalChain([e, 'optionalAccess', _18 => _18.randomUUID])=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof _optionalChain([e, 'optionalAccess', _19 => _19.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){_react.useEffect.call(void 0, ()=>{st(e)&&t()},[e,t])}function en(e){let[t,n]=_react.useState.call(void 0, [""]);return _react.useEffect.call(void 0, ()=>{n([""])},[e]),{pageToken:_nullishCoalesce(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=_connectquery.useMutation.call(void 0, _chunkG4V2KWTVjs.k.returns.startReturnSession),n=_connectquery.useMutation.call(void 0, _chunkG4V2KWTVjs.k.returns.verifyReturnSession),{setChallenge:r,authenticate:a,clearSession:i}=e,s=Z().toLowerCase().startsWith("en")?"en":"pl",o=_react.useCallback.call(void 0, 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=_react.useCallback.call(void 0, 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=_react.useCallback.call(void 0, async f=>{try{return await o(f),!0}catch (e12){return!1}},[o]),l=_react.useCallback.call(void 0, async f=>{if(e.challenge==null)return!1;try{return await g({challengeId:e.challenge.challengeId,code:f.trim()}),!0}catch (e13){return!1}},[e.challenge,g]),y=_react.useCallback.call(void 0, ()=>e.challenge!=null?m(e.challenge.email):Promise.resolve(!1),[e.challenge,m]),c=fe(_nullishCoalesce(_nullishCoalesce(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=_connectquery.useQuery.call(void 0, _chunkG4V2KWTVjs.k.returns.listReturnOrders,{projectId:n.projectID,sessionToken:_nullishCoalesce(n.token, () => ("")),pageSize:r,pageToken:_nullishCoalesce(a, () => (i.pageToken))},{enabled:n.token!=null});De(s.error,n.clearSession);let o=_nullishCoalesce(_optionalChain([s, 'access', _20 => _20.data, 'optionalAccess', _21 => _21.nextPageToken]), () => (""));return{orders:_nullishCoalesce(_optionalChain([s, 'access', _22 => _22.data, 'optionalAccess', _23 => _23.orders]), () => ([])),total:_nullishCoalesce(_optionalChain([s, 'access', _24 => _24.data, 'optionalAccess', _25 => _25.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=_connectquery.useQuery.call(void 0, _chunkG4V2KWTVjs.k.returns.getReturnableOrder,{projectId:t.projectID,sessionToken:_nullishCoalesce(t.token, () => ("")),canonicalOrderId:_nullishCoalesce(e, () => (""))},{enabled:t.token!=null&&e!=null&&e!==""});return De(n.error,t.clearSession),{order:_optionalChain([n, 'access', _26 => _26.data, 'optionalAccess', _27 => _27.order]),returnHistory:_nullishCoalesce(_optionalChain([n, 'access', _28 => _28.data, 'optionalAccess', _29 => _29.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=_reactquery.useQueryClient.call(void 0, ),n=_connectquery.useMutation.call(void 0, _chunkG4V2KWTVjs.k.returns.createReturnRequest),r=_chunkDP2NOHCIjs.m.call(void 0, ),a=_react.useRef.call(void 0, void 0),{clearSession:i}=e,s=_react.useCallback.call(void 0, async(l,y)=>{try{let c=await n.mutateAsync({projectId:e.projectID,sessionToken:_nullishCoalesce(e.token, () => ("")),canonicalOrderId:l.orderId,items:l.items,note:_nullishCoalesce(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=_react.useCallback.call(void 0, async l=>{a.current??=ot();try{let y=await s(l,a.current);return a.current=void 0,y.request}catch (e14){return}},[s]),g=_react.useCallback.call(void 0, 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},_nullishCoalesce(l.idempotencyKey, () => (ot())))},[e.token,s]),m=_react.useCallback.call(void 0, (l,y)=>{g(l).then(c=>_optionalChain([y, 'optionalAccess', _30 => _30.onSuccess, 'optionalCall', _31 => _31(c)]),c=>_optionalChain([y, 'optionalAccess', _32 => _32.onError, 'optionalCall', _33 => _33(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=_connectquery.useQuery.call(void 0, _chunkG4V2KWTVjs.k.returns.listMyReturns,{projectId:n.projectID,sessionToken:_nullishCoalesce(n.token, () => ("")),pageSize:r,pageToken:_nullishCoalesce(a, () => (i.pageToken))},{enabled:n.token!=null});De(s.error,n.clearSession);let o=_nullishCoalesce(_optionalChain([s, 'access', _34 => _34.data, 'optionalAccess', _35 => _35.nextPageToken]), () => (""));return{returns:_nullishCoalesce(_optionalChain([s, 'access', _36 => _36.data, 'optionalAccess', _37 => _37.returns]), () => ([])),total:_nullishCoalesce(_optionalChain([s, 'access', _38 => _38.data, 'optionalAccess', _39 => _39.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=_connectquery.useQuery.call(void 0, _chunkG4V2KWTVjs.k.returns.getMyReturn,{projectId:t.projectID,sessionToken:_nullishCoalesce(t.token, () => ("")),returnId:e},{enabled:t.token!=null});return De(n.error,t.clearSession),{request:_optionalChain([n, 'access', _40 => _40.data, 'optionalAccess', _41 => _41.request]),isLoading:Ke(t)||n.isLoading,error:n.error,errorKey:ge(n.error),refetch:()=>n.refetch()}}var _reactlabel = require('@radix-ui/react-label'); var sn = _interopRequireWildcard(_reactlabel);function Te({className:e,...t}){return _jsxruntime.jsx.call(void 0, sn.Root,{"data-slot":"label",className:_chunk4HGZZJELjs.g.call(void 0, "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})}var _lucidereact = require('lucide-react');function ye({className:e,...t}){return _jsxruntime.jsx.call(void 0, _lucidereact.Loader2Icon,{role:"status","aria-label":"Loading",className:_chunk4HGZZJELjs.g.call(void 0, "size-4 animate-spin",e),...t})}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 _jsxruntime.jsxs.call(void 0, "span",{role:"img","aria-label":"Bitsnap",className:"inline-flex items-center gap-1.5",children:[_jsxruntime.jsx.call(void 0, "svg",{"aria-hidden":"true",width:"29",height:"27",viewBox:"0 0 33 30",fill:"none",stroke:"currentColor",strokeWidth:"3.04",strokeLinecap:"round",children:_jsxruntime.jsx.call(void 0, "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"})}),_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",className:"text-xl tracking-wider",children:"bitsnap."})]})}function pr(e,t){return _chunkG4V2KWTVjs.l.call(void 0, _chunkG4V2KWTVjs.h,{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]=_react.useState.call(void 0, []),m=a||i,l=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _42 => _42.trim, 'call', _43 => _43()]), () => ("")),{data:y,isPending:c}=pr(l,r&&!m&&l!=="");if(!r)return null;if(!m&&l!==""&&c)return _jsxruntime.jsx.call(void 0, "div",{className:_chunk4HGZZJELjs.g.call(void 0, ut,s),"aria-hidden":"true"});let f=(m?a||i:_optionalChain([y, 'optionalAccess', _44 => _44.logoUrl])||_optionalChain([y, 'optionalAccess', _45 => _45.logoDarkUrl]))||"",b=(m?i||a:_optionalChain([y, 'optionalAccess', _46 => _46.logoDarkUrl])||_optionalChain([y, 'optionalAccess', _47 => _47.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 _jsxruntime.jsx.call(void 0, "div",{className:_chunk4HGZZJELjs.g.call(void 0, ut,s),children:_jsxruntime.jsx.call(void 0, cr,{})});let S=t||_optionalChain([y, 'optionalAccess', _48 => _48.name])||_chunk7RXW6XFYjs.a.call(void 0, dr,_nullishCoalesce(n, () => (_chunk7RXW6XFYjs.f.call(void 0, )))).alt,w=h=>()=>g(C=>C.includes(h)?C:[...C,h]);return _jsxruntime.jsx.call(void 0, "div",{className:_chunk4HGZZJELjs.g.call(void 0, ut,s),children:v===k?_jsxruntime.jsx.call(void 0, "img",{src:v,alt:S,className:lt,draggable:!1,onError:w(v)}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:v,alt:S,className:_chunk4HGZZJELjs.g.call(void 0, lt,"dark:hidden"),draggable:!1,onError:w(v)}),_jsxruntime.jsx.call(void 0, "img",{src:k,alt:S,className:_chunk4HGZZJELjs.g.call(void 0, lt,"hidden dark:block"),draggable:!1,onError:w(k)})]})})}var _inputotp = require('input-otp');function un({className:e,containerClassName:t,...n}){return _jsxruntime.jsx.call(void 0, _inputotp.OTPInput,{"data-slot":"input-otp",containerClassName:_chunk4HGZZJELjs.g.call(void 0, "flex items-center gap-2 has-disabled:opacity-50",t),className:_chunk4HGZZJELjs.g.call(void 0, "disabled:cursor-not-allowed",e),...n})}function ln({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"input-otp-group",className:_chunk4HGZZJELjs.g.call(void 0, "flex items-center",e),...t})}function dn({index:e,className:t,...n}){let r=an.useContext(_inputotp.OTPInputContext),{char:a,hasFakeCaret:i,isActive:s}=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _49 => _49.slots, 'access', _50 => _50[e]]), () => ({}));return _jsxruntime.jsxs.call(void 0, "div",{"data-slot":"input-otp-slot","data-active":s,className:_chunk4HGZZJELjs.g.call(void 0, "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&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:_jsxruntime.jsx.call(void 0, "div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function qe(e){let[,t]=_react.useState.call(void 0, 0);return _react.useEffect.call(void 0, ()=>{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={..._chunk7RXW6XFYjs.a.call(void 0, 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(_nullishCoalesce(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=_react.useRef.call(void 0, e);n.current=e;let[r,a]=_react.useState.call(void 0, "email"),[i,s]=_react.useState.call(void 0, _nullishCoalesce(e.initialEmail, () => (""))),[o,g]=_react.useState.call(void 0, ""),[m,l]=_react.useState.call(void 0, ),[y,c]=_react.useState.call(void 0, ),[f,b]=_react.useState.call(void 0, !1),[x,v]=_react.useState.call(void 0, ),[k,S]=_react.useState.call(void 0, ),[w,h]=_react.useState.call(void 0, ),[C,U]=_react.useState.call(void 0, !1),[_,J]=_react.useState.call(void 0, ""),[N,Y]=_react.useState.call(void 0, 0),O=_react.useRef.call(void 0, !1),j=_react.useRef.call(void 0, "email"),Q=_react.useRef.call(void 0, null),F=_react.useRef.call(void 0, null),re=_react.useRef.call(void 0, "email"),Se=qe(y),B=_react.useCallback.call(void 0, T=>{j.current=T,Y(A=>A+1)},[]);_react.useEffect.call(void 0, ()=>{N!==0&&_optionalChain([(j.current==="email"?Q:F), 'access', _51 => _51.current, 'optionalAccess', _52 => _52.focus, 'call', _53 => _53()])},[N]),_react.useEffect.call(void 0, ()=>{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]),_react.useEffect.call(void 0, ()=>{re.current!==r&&(re.current=r,J(r==="code"?n.current.texts.stepCode:n.current.texts.stepEmail))},[r]),_react.useEffect.call(void 0, ()=>{r==="code"&&N===0&&B(f?"email":"code")},[r]);let R=_react.useCallback.call(void 0, (T,A,L,M)=>{T!=="wrongCode"&&T!=="invalidEmail"&&T!=="alreadySent"&&_optionalChain([n, 'access', _54 => _54.current, 'access', _55 => _55.onFailure, 'optionalCall', _56 => _56(T,L)]);let se=pt(n.current.texts,T,A);return M!=null?{...se,text:M}:se},[]),X=_react.useCallback.call(void 0, (T,A,L,M)=>{let se=Date.now(),bt=se+(_nullishCoalesce(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=_react.useCallback.call(void 0, 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=_react.useCallback.call(void 0, async T=>{let A=_nullishCoalesce(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),_optionalChain([n, 'access', _57 => _57.current, 'access', _58 => _58.onVerified, 'optionalCall', _59 => _59(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=_react.useCallback.call(void 0, T=>{s(T),S(A=>_optionalChain([A, 'optionalAccess', _60 => _60.kind])==="error"?void 0:A)},[]),hn=_react.useCallback.call(void 0, T=>{g(T.replace(/\D/g,"").slice(0,de)),S(A=>_optionalChain([A, 'optionalAccess', _61 => _61.kind])==="error"?void 0:A)},[]),kn=_react.useCallback.call(void 0, ()=>{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=_react.useCallback.call(void 0, ()=>{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}}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=_react.useCallback.call(void 0, x=>{Tr(x),typeof o=="function"?o(x):o!=null&&(o.current=x)},[o]),b={className:_chunk4HGZZJELjs.g.call(void 0, "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 _jsxruntime.jsx.call(void 0, 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:_inputotp.REGEXP_ONLY_DIGITS,pasteTransformer:Nr,"aria-invalid":s?!0:void 0,"aria-label":c["aria-label"],"aria-describedby":c["aria-describedby"],containerClassName:_chunk4HGZZJELjs.g.call(void 0, "w-full",y),children:_jsxruntime.jsx.call(void 0, ln,{className:"w-full gap-1.5 sm:gap-2",children:Array.from({length:de},(x,v)=>_jsxruntime.jsx.call(void 0, dn,{index:v,...b},v))})})}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=_chunk4HGZZJELjs.g.call(void 0, 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 _jsxruntime.jsxs.call(void 0, "section",{className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-5",a),children:[r,_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"header",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-2",o.className),style:o.style,children:[n!=null&&_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"backButton",className:_chunk4HGZZJELjs.g.call(void 0, "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")}),_jsxruntime.jsx.call(void 0, "h2",{"data-bitsnap-returns-slot":"title",className:_chunk4HGZZJELjs.g.call(void 0, "text-2xl font-semibold",g.className),style:g.style,children:e}),t!=null&&_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"description",className:_chunk4HGZZJELjs.g.call(void 0, "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 _jsxruntime.jsxs.call(void 0, "div",{role:"alert","data-bitsnap-returns-slot":"error",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col items-start gap-2 text-sm",r.className),style:r.style,children:[_jsxruntime.jsx.call(void 0, "p",{children:n(e)}),t!=null&&_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunk4HGZZJELjs.g.call(void 0, W,a.className),style:a.style,onClick:t,children:n("errorRetry")})]})}function Ve({children:e}){let t=d("emptyState");return _jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"emptyState",className:_chunk4HGZZJELjs.g.call(void 0, "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 _jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true","aria-label":t("loading"),className:"flex flex-col gap-3",children:Array.from({length:e},(r,a)=>_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.u,{"data-bitsnap-returns-slot":"skeleton",className:_chunk4HGZZJELjs.g.call(void 0, "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 _jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"statusBadge","data-status":e,className:_chunk4HGZZJELjs.g.call(void 0, "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:_jsxruntime.jsxs.call(void 0, "nav",{"data-bitsnap-returns-slot":"pagination",className:_chunk4HGZZJELjs.g.call(void 0, "flex items-center justify-between gap-3 text-sm",g.className),style:g.style,children:[_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunk4HGZZJELjs.g.call(void 0, W,m.className),style:m.style,disabled:!r||a,onClick:s,children:o("paginationPrevious")}),_jsxruntime.jsx.call(void 0, "span",{"aria-live":"polite",children:o("paginationInfo",{page:e,total:t})}),_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunk4HGZZJELjs.g.call(void 0, W,m.className),style:m.style,disabled:!n||a,onClick:i,children:o("paginationNext")})]})}function Ko({onSubmitted:e,className:t,...n}){let r=D("ReturnsEmailStep"),a=z(),i=Z(),s=Fe(),[o,g]=_react.useState.call(void 0, _nullishCoalesce(r.lastEmail, () => (""))),m=d("emailForm"),l=d("emailInput"),y=d("submitButton");async function c(f){f.preventDefault(),!s.isStarting&&await s.start(o)&&_optionalChain([e, 'optionalCall', _62 => _62(o.trim())])}return _jsxruntime.jsx.call(void 0, te,{className:t,lead:_jsxruntime.jsx.call(void 0, dt,{projectId:r.projectID,locale:i,...n}),title:a("emailStepTitle"),description:a("emailStepDescription"),children:_jsxruntime.jsxs.call(void 0, "form",{"data-bitsnap-returns-slot":"emailForm",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-4",m.className),style:m.style,onSubmit:c,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, Te,{htmlFor:"bitsnap-returns-email",children:a("emailLabel")}),_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.r,{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:_chunk4HGZZJELjs.g.call(void 0, Re,l.className),style:l.style,onChange:f=>g(f.target.value)})]}),s.errorKey!=null&&_jsxruntime.jsx.call(void 0, H,{errorKey:s.errorKey}),_jsxruntime.jsxs.call(void 0, _chunkG4V2KWTVjs.q,{type:"submit",disabled:s.isStarting,"data-bitsnap-returns-slot":"submitButton",className:_chunk4HGZZJELjs.g.call(void 0, ce,y.className),style:y.style,children:[s.isStarting&&_jsxruntime.jsx.call(void 0, ye,{}),a("emailSubmit")]})]})})}function _o({onVerified:e,onBack:t,className:n,...r}){let a=D("ReturnsCodeStep"),i=z(),s=Z(),o=Fe(),[g,m]=_react.useState.call(void 0, ""),[l,y]=_react.useState.call(void 0, !1),[c,f]=_react.useState.call(void 0, !1),[b,x]=_react.useState.call(void 0, 1),v=_react.useRef.call(void 0, null),k=_react.useRef.call(void 0, !1),S=qe(_optionalChain([o, 'access', _63 => _63.challenge, 'optionalAccess', _64 => _64.resendAvailableAt])),w=d("codeForm"),h=d("codeInput"),C=d("submitButton"),U=d("resendButton"),_=o.isVerifying||o.isStarting,J="bitsnap-returns-code",N=`${J}-hint`;_react.useEffect.call(void 0, ()=>{_||_optionalChain([v, 'access', _65 => _65.current, 'optionalAccess', _66 => _66.focus, 'call', _67 => _67()])},[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)?_optionalChain([e, 'optionalCall', _68 => _68()]):(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),_optionalChain([t, 'optionalCall', _69 => _69()])}return _jsxruntime.jsx.call(void 0, te,{className:n,onBack:t!=null?Q:void 0,lead:_jsxruntime.jsx.call(void 0, dt,{projectId:a.projectID,locale:s,...r}),title:i("codeStepTitle"),description:i("codeStepDescription",{email:_nullishCoalesce(_optionalChain([o, 'access', _70 => _70.challenge, 'optionalAccess', _71 => _71.email]), () => (""))}),children:_jsxruntime.jsxs.call(void 0, "form",{"data-bitsnap-returns-slot":"codeForm",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-4",w.className),style:w.style,noValidate:!0,onSubmit:O,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, Te,{htmlFor:J,children:i("codeLabel")}),_jsxruntime.jsx.call(void 0, fn,{id:J,name:"code",inputRef:v,value:g,disabled:_,invalid:o.errorKey!=null||l,"aria-describedby":N,slotClassName:_chunk4HGZZJELjs.g.call(void 0, gn,h.className),slotStyle:h.style,onChange:F=>{m(F.replace(/\D/g,"")),y(!1)},onComplete:F=>void Y(F)}),_jsxruntime.jsxs.call(void 0, "p",{id:N,className:"text-xs",children:[i("codeValidity")," ",i("codeSpamHint")]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"min-h-10",children:[l&&_jsxruntime.jsx.call(void 0, "p",{role:"alert",className:"text-sm",children:i("codeIncomplete")}),!l&&o.errorKey!=null&&_jsxruntime.jsx.call(void 0, H,{errorKey:o.errorKey}),!l&&o.errorKey==null&&c&&_jsxruntime.jsx.call(void 0, "p",{role:"status",className:"text-sm",children:i("resendSent")})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center gap-3",children:[_jsxruntime.jsxs.call(void 0, _chunkG4V2KWTVjs.q,{type:"submit",disabled:_||o.challenge==null,"data-bitsnap-returns-slot":"submitButton",className:_chunk4HGZZJELjs.g.call(void 0, "h-11",ce,C.className),style:C.style,children:[o.isVerifying&&_jsxruntime.jsx.call(void 0, ye,{"aria-hidden":!0}),i("codeSubmit")]}),_jsxruntime.jsxs.call(void 0, _chunkG4V2KWTVjs.q,{type:"button",variant:"secondary",disabled:_||S>0||o.challenge==null,"data-bitsnap-returns-slot":"resendButton",className:_chunk4HGZZJELjs.g.call(void 0, "h-11",W,U.className),style:U.style,onClick:()=>void j(),children:[o.isStarting&&_jsxruntime.jsx.call(void 0, ye,{"aria-hidden":!0}),S>0?i("resendIn",{seconds:S}):i("resend")]})]})]})})}function bn(){let e=z(),t=Fe(),n=d("logoutButton");return _jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"logoutButton",className:_chunk4HGZZJELjs.g.call(void 0, "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")})}function pe(e,t){if(e==null)return"";let n=_wkt.timestampDate.call(void 0, e);try{return new Intl.DateTimeFormat(t,{dateStyle:"medium"}).format(n)}catch (e15){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=_nullishCoalesce(a.resolvedOptions().maximumFractionDigits, () => (2));return a.format(Rn(r,i))}catch (e16){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:_nullishCoalesce(t[n], () => (0))})).filter(n=>n.quantity>0)}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 _jsxruntime.jsxs.call(void 0, te,{className:a,title:i("ordersTitle"),description:i("ordersDescription"),children:[(n||t!=null)&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t!=null?_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunk4HGZZJELjs.g.call(void 0, W,f.className),style:f.style,onClick:t,children:i("myReturnsLink")}):_jsxruntime.jsx.call(void 0, "span",{}),n&&_jsxruntime.jsx.call(void 0, bn,{})]}),o.isLoading?_jsxruntime.jsx.call(void 0, le,{}):o.errorKey!=null?_jsxruntime.jsx.call(void 0, H,{errorKey:o.errorKey,onRetry:o.refetch}):o.orders.length===0?_jsxruntime.jsx.call(void 0, Ve,{children:i("ordersEmpty")}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"orderList",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-3",g.className),style:g.style,children:o.orders.map(b=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"orderCard",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderReference",className:_chunk4HGZZJELjs.g.call(void 0, "font-medium",l.className),style:l.style,children:i("orderTitle",{reference:b.displayReference})}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderDate",className:_chunk4HGZZJELjs.g.call(void 0, "text-sm",y.className),style:y.style,children:pe(b.purchasedAt,s)}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:i("orderReturnableLines",{count:b.returnableLineCount})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderTotal",className:_chunk4HGZZJELjs.g.call(void 0, "font-medium",c.className),style:c.style,children:ve(b.totalMinor,b.currency,s)}),_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"button",variant:"secondary",size:"sm","aria-label":`${i("orderSelect")}: ${i("orderTitle",{reference:b.displayReference})}`,"data-bitsnap-returns-slot":"secondaryButton",className:_chunk4HGZZJELjs.g.call(void 0, W,f.className),style:f.style,onClick:()=>_optionalChain([e, 'optionalCall', _72 => _72(b.canonicalOrderId)]),children:i("orderSelect")})]})]},b.canonicalOrderId))}),_jsxruntime.jsx.call(void 0, 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=_chunkDP2NOHCIjs.m.call(void 0, );_react.useEffect.call(void 0, ()=>{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]=_react.useState.call(void 0, ()=>Object.fromEntries((_nullishCoalesce(r, () => ([]))).map(R=>[R.lineId,R.quantity]))),[v,k]=_react.useState.call(void 0, _nullishCoalesce(a, () => (""))),[S,w]=_react.useState.call(void 0, !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}_optionalChain([t, 'optionalCall', _73 => _73({items:X,note:v.trim()})])}return _jsxruntime.jsx.call(void 0, te,{className:i,onBack:n,title:o("orderDetailTitle",{reference:_nullishCoalesce(_optionalChain([m, 'optionalAccess', _74 => _74.displayReference]), () => (""))}),description:o("orderDetailDescription"),children:y?_jsxruntime.jsx.call(void 0, le,{}):c!=null?_jsxruntime.jsx.call(void 0, H,{errorKey:c,onRetry:f}):m==null?null:_jsxruntime.jsxs.call(void 0, "form",{className:"flex flex-col gap-5",onSubmit:B,children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"lineList",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-3",h.className),style:h.style,children:m.lines.map(R=>{let X=gt(R),V=_nullishCoalesce(b[R.lineId], () => (0)),he=`bitsnap-returns-quantity-${R.lineId}`;return _jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line","data-selected":V>0?"":void 0,"data-ineligible":X?void 0:"",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-3 border p-4",C.className),style:C.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunk4HGZZJELjs.g.call(void 0, "font-medium",U.className),style:U.style,children:R.name}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"linePrice",className:_chunk4HGZZJELjs.g.call(void 0, "text-sm",_.className),style:_.style,children:ve(R.paidUnitMinor,R.currency,g)})]}),X?_jsxruntime.jsxs.call(void 0, "div",{role:"group","aria-label":o("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"lineQuantityControl",className:_chunk4HGZZJELjs.g.call(void 0, "flex items-center gap-2",J.className),style:J.style,children:[_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{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:_chunk4HGZZJELjs.g.call(void 0, W,N.className),style:N.style,onClick:()=>Se(R,V-1),children:_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"-"})}),_jsxruntime.jsx.call(void 0, "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:_chunk4HGZZJELjs.g.call(void 0, "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)}),_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{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:_chunk4HGZZJELjs.g.call(void 0, W,N.className),style:N.style,onClick:()=>Se(R,V+1),children:_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"+"})}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:o("quantityOfAvailable",{available:R.availableQuantity})})]}):_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"lineIneligibleReason",className:_chunk4HGZZJELjs.g.call(void 0, "text-sm",O.className),style:O.style,children:R.exclusionReason!==""?R.exclusionReason:o("lineIneligibleFallback")})]},R.lineId)})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, Te,{htmlFor:"bitsnap-returns-note",children:o("noteLabel")}),_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.v,{id:"bitsnap-returns-note",name:"note",rows:3,maxLength:1e3,value:v,placeholder:o("notePlaceholder"),"data-bitsnap-returns-slot":"noteInput",className:_chunk4HGZZJELjs.g.call(void 0, 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&&_jsxruntime.jsx.call(void 0, H,{errorKey:"selectionEmpty"}),_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"submit","data-bitsnap-returns-slot":"submitButton",className:_chunk4HGZZJELjs.g.call(void 0, ce,Q.className),style:Q.style,children:o("selectionContinue")}),l.length>0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:o("previousReturnsTitle")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"history",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-2",F.className),style:F.style,children:l.map(R=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"historyEntry",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-wrap items-center justify-between gap-2 text-sm",re.className),style:re.style,children:[_jsxruntime.jsx.call(void 0, "span",{children:R.reference}),_jsxruntime.jsx.call(void 0, "span",{children:pe(R.createdAt,g)}),_jsxruntime.jsx.call(void 0, 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&&_optionalChain([r, 'optionalCall', _75 => _75(h.id,h)])}return _jsxruntime.jsx.call(void 0, te,{className:i,onBack:a,title:s("confirmationTitle"),description:s("confirmationDescription"),children:m?_jsxruntime.jsx.call(void 0, le,{rows:2}):l!=null?_jsxruntime.jsx.call(void 0, H,{errorKey:l,onRetry:y}):_jsxruntime.jsxs.call(void 0, "form",{className:"flex flex-col gap-5",onSubmit:S,children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"summary",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-3 border p-4",f.className),style:f.style,children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:s("confirmationSummary")}),_jsxruntime.jsx.call(void 0, "ul",{className:"flex flex-col gap-3",children:t.map(w=>{let h=_optionalChain([g, 'optionalAccess', _76 => _76.lines, 'access', _77 => _77.find, 'call', _78 => _78(C=>C.lineId===w.lineId)]);return _jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-wrap items-baseline justify-between gap-2",b.className),style:b.style,children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunk4HGZZJELjs.g.call(void 0, "font-medium",x.className),style:x.style,children:_nullishCoalesce(_optionalChain([h, 'optionalAccess', _79 => _79.name]), () => (w.lineId))}),_jsxruntime.jsxs.call(void 0, "span",{"data-bitsnap-returns-slot":"linePrice",className:_chunk4HGZZJELjs.g.call(void 0, "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!==""&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:s("confirmationNote")}),_jsxruntime.jsx.call(void 0, "span",{className:"whitespace-pre-wrap",children:n})]})]}),c.errorKey!=null&&_jsxruntime.jsx.call(void 0, H,{errorKey:c.errorKey}),_jsxruntime.jsxs.call(void 0, _chunkG4V2KWTVjs.q,{type:"submit",disabled:c.isPending||t.length===0,"data-bitsnap-returns-slot":"submitButton",className:_chunk4HGZZJELjs.g.call(void 0, ce,k.className),style:k.style,children:[c.isPending&&_jsxruntime.jsx.call(void 0, 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 _jsxruntime.jsxs.call(void 0, "section",{className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-5",r),children:[_jsxruntime.jsxs.call(void 0, "div",{role:"status","data-bitsnap-returns-slot":"successState",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-4 border p-5",m.className),style:m.style,children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-2xl font-semibold",children:a("successTitle")}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:a("successDescription")}),s?_jsxruntime.jsx.call(void 0, le,{rows:2}):o!=null?_jsxruntime.jsx.call(void 0, H,{errorKey:o,onRetry:g}):i!=null&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:a("successReference")}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"returnReference",className:_chunk4HGZZJELjs.g.call(void 0, "text-lg font-semibold",l.className),style:l.style,children:i.reference})]}),i.returnInstructions!==""&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium",children:a("successInstructions")}),_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"returnInstructions",className:_chunk4HGZZJELjs.g.call(void 0, "whitespace-pre-wrap border p-3 text-sm",y.className),style:y.style,children:i.returnInstructions})]})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap gap-3",children:[_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"button","data-bitsnap-returns-slot":"submitButton",className:_chunk4HGZZJELjs.g.call(void 0, ce,c.className),style:c.style,onClick:t,children:a("successDone")}),n!=null&&_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"button",variant:"secondary","data-bitsnap-returns-slot":"secondaryButton",className:_chunk4HGZZJELjs.g.call(void 0, W,f.className),style:f.style,onClick:n,children:a("myReturnsLink")})]})]})}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 _jsxruntime.jsx.call(void 0, te,{className:r,onBack:t,title:a("myReturnsTitle"),description:a("myReturnsDescription"),children:o.isLoading?_jsxruntime.jsx.call(void 0, le,{}):o.errorKey!=null?_jsxruntime.jsx.call(void 0, H,{errorKey:o.errorKey,onRetry:o.refetch}):o.returns.length===0?_jsxruntime.jsx.call(void 0, Ve,{children:a("myReturnsEmpty")}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"returnList",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-3",g.className),style:g.style,children:o.returns.map(c=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"returnCard",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"returnReference",className:_chunk4HGZZJELjs.g.call(void 0, "font-medium",l.className),style:l.style,children:c.reference}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:pe(c.createdAt,i)}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm",children:[a("myReturnRefund"),": ",s(c.refundStatus)]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-3",children:[_jsxruntime.jsx.call(void 0, xe,{status:c.status}),_jsxruntime.jsx.call(void 0, _chunkG4V2KWTVjs.q,{type:"button",variant:"secondary",size:"sm","aria-label":`${a("myReturnOpen")}: ${c.reference}`,"data-bitsnap-returns-slot":"secondaryButton",className:_chunk4HGZZJELjs.g.call(void 0, W,y.className),style:y.style,onClick:()=>_optionalChain([e, 'optionalCall', _80 => _80(c.id)]),children:a("myReturnOpen")})]})]},c.id))}),_jsxruntime.jsx.call(void 0, 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 _jsxruntime.jsx.call(void 0, te,{className:n,onBack:t,title:s!=null?r("myReturnTitle",{reference:s.reference}):r("myReturnDetailTitle"),children:o?_jsxruntime.jsx.call(void 0, le,{}):g!=null?_jsxruntime.jsx.call(void 0, H,{errorKey:g,onRetry:m}):s!=null&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-5",children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"summary",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-2 border p-4 text-sm",l.className),style:l.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-2",children:[_jsxruntime.jsx.call(void 0, xe,{status:s.status}),_jsxruntime.jsxs.call(void 0, "span",{children:[r("myReturnCreatedAt"),":"," ",pe(s.createdAt,a)]})]}),_jsxruntime.jsxs.call(void 0, "span",{children:[r("myReturnRefund"),": ",i(s.refundStatus),s.refundAmountMinor>BigInt(0)&&` \xB7 ${ve(s.refundAmountMinor,s.currency,a)}`]}),s.customerNote!==""&&_jsxruntime.jsxs.call(void 0, "span",{className:"whitespace-pre-wrap",children:[r("myReturnNote"),": ",s.customerNote]})]}),s.returnInstructions!==""&&_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"returnInstructions",className:_chunk4HGZZJELjs.g.call(void 0, "whitespace-pre-wrap border p-3 text-sm",b.className),style:b.style,children:s.returnInstructions}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:r("myReturnLines")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"lineList",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-3",y.className),style:y.style,children:s.lines.map(k=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-wrap items-baseline justify-between gap-2 border p-4",c.className),style:c.style,children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunk4HGZZJELjs.g.call(void 0, "font-medium",f.className),style:f.style,children:k.name}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:r("myReturnLineQuantities",{requested:k.requestedQuantity,approved:k.approvedQuantity,received:k.receivedQuantity})})]},k.lineId))})]}),s.history.length>0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:r("myReturnHistory")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"history",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-col gap-2",x.className),style:x.style,children:s.history.map(k=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"historyEntry",className:_chunk4HGZZJELjs.g.call(void 0, "flex flex-wrap items-center justify-between gap-2 text-sm",v.className),style:v.style,children:[_jsxruntime.jsx.call(void 0, xe,{status:k.status}),_jsxruntime.jsx.call(void 0, "span",{children:pe(k.createdAt,a)})]},k.id))})]})]})})}exports.a = Zt; exports.b = pr; exports.c = dt; exports.d = Te; exports.e = ye; exports.f = Ut; exports.g = xr; exports.h = eo; exports.i = ct; exports.j = ao; exports.k = fn; exports.l = Pr; exports.m = Ot; exports.n = $e; exports.o = d; exports.p = st; exports.q = Xt; exports.r = z; exports.s = Z; exports.t = D; exports.u = Xn; exports.v = ls; exports.w = Fe; exports.x = tn; exports.y = it; exports.z = nn; exports.A = rn; exports.B = _e; exports.C = le; exports.D = Ko; exports.E = _o; exports.F = la; exports.G = da; exports.H = ca; exports.I = pa; exports.J = Na; exports.K = Ta;
2
+ //# sourceMappingURL=chunk-ZATPBYOA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-ZATPBYOA.js","../src/components/returns/appearance.ts","../src/components/returns/appearance.context.tsx","../src/components/returns/legacy.ts","../src/components/returns/texts.ts","../src/components/returns/texts.context.tsx","../src/components/returns/ReturnsProvider.tsx","../src/ui/email-code-login/pending.ts"],"names":["RETURNS_SLOT_NAMES","RETURNS_TOKEN_VARIABLES","RETURNS_THEME_PRESETS","RETURNS_SHADCN_VARIABLES","resolveReturnsAppearance","appearance","resolved","resolveAppearanceCore","getReturnsSlotAppearance","slot","getSlotAppearance","ReturnsAppearanceContext","createContext","ReturnsAppearanceProvider","children","useMemo","jsx","useReturnsAppearance","useContext","useReturnsSlot","resolveReturnsEnvironment","environment","LEGACY_TEXT_KEYS","mapLegacyTexts","texts","result","legacyKey","targets","value","target","key","resolveBrandAppearance","theme","color","brandColorTokens","resolvePagedArguments","first","pageToken","RETURNS_TEXT_TABLES","resolveReturnsTexts","locale","overrides","resolveTexts","fillText","template","values","match","name","STATUS_TEXT_KEYS","REFUND_STATUS_TEXT_KEYS","statusTextKey","status","refundStatusTextKey","ReturnsTextsContext","ReturnsTextsProvider","activeLocale","getLocale","useReturnsText","useCallback","useReturnsLocale","browserStorage","pendingLoginKey","surface","projectID","host"],"mappings":"AAAA,y/BAAgD,sDAAwH,sDAAwC,sDAAyD,sDAAyD,ICiErTA,EAAAA,CAAqB,CAEhC,MAAA,CACA,QAAA,CACA,OAAA,CACA,aAAA,CACA,YAAA,CACA,eAAA,CACA,OAAA,CACA,YAAA,CACA,UAAA,CAEA,WAAA,CACA,YAAA,CACA,UAAA,CACA,WAAA,CACA,cAAA,CACA,cAAA,CAEA,WAAA,CACA,WAAA,CACA,gBAAA,CACA,WAAA,CACA,YAAA,CACA,YAAA,CAEA,UAAA,CACA,MAAA,CACA,UAAA,CACA,WAAA,CACA,qBAAA,CACA,gBAAA,CACA,eAAA,CACA,sBAAA,CACA,WAAA,CAEA,SAAA,CACA,cAAA,CACA,iBAAA,CACA,cAAA,CACA,iBAAA,CACA,oBAAA,CAEA,YAAA,CACA,YAAA,CACA,aAAA,CACA,SAAA,CACA,cACF,CAAA,CA6BaC,EAAAA,CAA0B,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AAU,IAAA,CAAOrB,CAAAA,CAAMM,CAAG,CAAA,CAAIa,EAAAA,CAASnB,CAAAA,CAAMM,CAAG,CAAA,CAAGe,CAAM,CAAA,CAC3D,CAACrB,CAAK,CACR,CACF,CAGO,SAASmC,CAAAA,CAAAA,CAA2B,CACzC,OAAOzC,+BAAAA,EAA8B,CAAA,CAAE,MACzC,CCvEA,8CAA6B,yDAItB,mDAMA,SCUE0C,EAAAA,CAAAA,CAA0C,CACjD,GAAI,CACF,OAAO,OAAO,MAAA,CAAW,GAAA,CAAc,MAAA,CAAO,cAAA,CAAiB,KAAA,CACjE,CAAA,UAAQ,CACN,MACF,CACF,CAGO,SAASC,EAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACQ,CACR,MAAO,CAAA,sBAAA,EAAyBF,CAAO,CAAA,CAAA,EAAI,kBAAA,kBAAmBE,CAAAA,SAAQ,IAAE,CAAC,CAAA,CAAA,EAAI,kBAAA,kBAAmBD,CAAAA,SAAa,IAAE,CAAC,CAAA,CAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-ZATPBYOA.js","sourcesContent":[null,"import type { CSSProperties } from \"react\";\nimport {\n getSlotAppearance,\n resolveAppearanceCore,\n type AppearanceElements,\n type ShadcnVariableMapping,\n type SlotAppearance,\n} from \"@/src/lib/appearance-core\";\n\n/**\n * Returns appearance API.\n *\n * It mirrors `CheckoutAppearance` (theme, tokens, elements) so a shop can reuse\n * one brand object for both. The resolver is pure: it turns the caller input\n * into a theme name, the tokens in effect, the slot overrides and the inline\n * style for the theme boundary.\n */\n\nexport type ReturnsTheme = \"light\" | \"dark\";\n\nexport type ReturnsAppearanceTokens = {\n /** Font family of the returns views. The library never loads fonts. */\n fontFamily?: string;\n /** Base font size. */\n fontSize?: string;\n /** Page background. */\n background?: string;\n /** Raised surfaces: cards, skeletons, summaries. */\n surface?: string;\n /** Main text color. */\n foreground?: string;\n /** Secondary text: descriptions, dates, hints. */\n mutedForeground?: string;\n /** Borders of cards, inputs and separators. */\n border?: string;\n /** Primary button background. */\n buttonBackground?: string;\n /** Primary button text. */\n buttonForeground?: string;\n /** Primary button background on hover. */\n buttonHoverBackground?: string;\n /** Hover surface of secondary buttons and selectable cards. */\n hoverSurface?: string;\n /** Focus ring color. Also applied to shared UI primitives through `--ring`. */\n focusRing?: string;\n /** Error color. */\n error?: string;\n /** Success color: result screen, completed and refunded statuses. */\n success?: string;\n /** Warning color: statuses that need attention. */\n warning?: string;\n /** Status badge background. */\n badgeBackground?: string;\n /** Status badge text. */\n badgeForeground?: string;\n /** Background of text inputs and the note field. */\n inputBackground?: string;\n /** Corner radius, applied through `--radius`. */\n radius?: string;\n};\n\n/**\n * Stable slot names. They are exposed as `data-bitsnap-returns-slot`\n * attributes so they can also be targeted from plain CSS.\n */\nexport const RETURNS_SLOT_NAMES = [\n // Frame\n \"root\",\n \"header\",\n \"title\",\n \"description\",\n \"backButton\",\n \"stepIndicator\",\n \"error\",\n \"emptyState\",\n \"skeleton\",\n // Auth\n \"emailForm\",\n \"emailInput\",\n \"codeForm\",\n \"codeInput\",\n \"resendButton\",\n \"logoutButton\",\n // Orders\n \"orderList\",\n \"orderCard\",\n \"orderReference\",\n \"orderDate\",\n \"orderTotal\",\n \"pagination\",\n // Selection\n \"lineList\",\n \"line\",\n \"lineName\",\n \"linePrice\",\n \"lineQuantityControl\",\n \"quantityButton\",\n \"quantityInput\",\n \"lineIneligibleReason\",\n \"noteInput\",\n // Confirmation and result\n \"summary\",\n \"submitButton\",\n \"secondaryButton\",\n \"successState\",\n \"returnReference\",\n \"returnInstructions\",\n // My returns\n \"returnList\",\n \"returnCard\",\n \"statusBadge\",\n \"history\",\n \"historyEntry\",\n] as const;\n\nexport type ReturnsSlotName = (typeof RETURNS_SLOT_NAMES)[number];\n\nexport type ReturnsSlotAppearance = SlotAppearance;\n\nexport type ReturnsAppearanceElements = AppearanceElements<ReturnsSlotName>;\n\nexport type ReturnsAppearance = {\n /** `\"light\"` or `\"dark\"`. Omitted means `\"light\"`. */\n theme?: ReturnsTheme;\n /** Partial overrides applied over the theme preset. */\n tokens?: ReturnsAppearanceTokens;\n /** Per element `className`/`style` overrides. */\n elements?: ReturnsAppearanceElements;\n};\n\nexport type ResolvedReturnsAppearance = {\n theme: ReturnsTheme;\n /** Tokens that are in effect (the theme preset plus caller overrides). */\n tokens: ReturnsAppearanceTokens;\n elements: ReturnsAppearanceElements;\n /** Theme marker class for the theme boundary. */\n boundaryClassName: string;\n /** Inline custom properties applied to the returns root. */\n boundaryStyle: CSSProperties;\n};\n\n/** CSS custom property used for each token. */\nexport const RETURNS_TOKEN_VARIABLES = {\n fontFamily: \"--bitsnap-returns-font-family\",\n fontSize: \"--bitsnap-returns-font-size\",\n background: \"--bitsnap-returns-background\",\n surface: \"--bitsnap-returns-surface\",\n foreground: \"--bitsnap-returns-foreground\",\n mutedForeground: \"--bitsnap-returns-muted-foreground\",\n border: \"--bitsnap-returns-border\",\n buttonBackground: \"--bitsnap-returns-button-background\",\n buttonForeground: \"--bitsnap-returns-button-foreground\",\n buttonHoverBackground: \"--bitsnap-returns-button-hover-background\",\n hoverSurface: \"--bitsnap-returns-hover-surface\",\n focusRing: \"--bitsnap-returns-focus-ring\",\n error: \"--bitsnap-returns-error\",\n success: \"--bitsnap-returns-success\",\n warning: \"--bitsnap-returns-warning\",\n badgeBackground: \"--bitsnap-returns-badge-background\",\n badgeForeground: \"--bitsnap-returns-badge-foreground\",\n inputBackground: \"--bitsnap-returns-input-background\",\n radius: \"--bitsnap-returns-radius\",\n} as const;\n\nexport type ReturnsTokenName = keyof typeof RETURNS_TOKEN_VARIABLES;\n\n/**\n * Complete palettes. They carry colors and radius only, so typography is never\n * reset implicitly. `returns.css` falls back to the light values, which keeps\n * the views usable even when the boundary style is missing.\n */\nexport const RETURNS_THEME_PRESETS: Record<\n ReturnsTheme,\n ReturnsAppearanceTokens\n> = {\n light: {\n background: \"#ffffff\",\n surface: \"#f9fafb\",\n foreground: \"#18181b\",\n mutedForeground: \"#71717a\",\n border: \"#e4e4e7\",\n buttonBackground: \"#18181b\",\n buttonForeground: \"#fafafa\",\n buttonHoverBackground: \"#000000\",\n hoverSurface: \"#f4f4f5\",\n focusRing: \"#71717a\",\n error: \"#dc2626\",\n success: \"#16a34a\",\n warning: \"#d97706\",\n badgeBackground: \"#f4f4f5\",\n badgeForeground: \"#3f3f46\",\n inputBackground: \"#ffffff\",\n radius: \"8px\",\n },\n dark: {\n background: \"#18181b\",\n surface: \"#27272a\",\n foreground: \"#fafafa\",\n mutedForeground: \"#a1a1aa\",\n border: \"#3f3f46\",\n buttonBackground: \"#fafafa\",\n buttonForeground: \"#18181b\",\n buttonHoverBackground: \"#e4e4e7\",\n hoverSurface: \"#3f3f46\",\n focusRing: \"#a1a1aa\",\n error: \"#f87171\",\n success: \"#4ade80\",\n warning: \"#fbbf24\",\n badgeBackground: \"#3f3f46\",\n badgeForeground: \"#e4e4e7\",\n inputBackground: \"#27272a\",\n radius: \"8px\",\n },\n};\n\n/**\n * Shared UI primitives (`Button`, `Input`, `Label`, ...) read the shadcn theme\n * variables, so those follow the returns tokens inside the boundary.\n */\nconst RETURNS_SHADCN_VARIABLES: ShadcnVariableMapping<ReturnsTokenName> = [\n { token: \"background\", variable: \"--background\" },\n { token: \"foreground\", variable: \"--foreground\" },\n { token: \"surface\", variable: \"--card\" },\n { token: \"foreground\", variable: \"--card-foreground\" },\n { token: \"surface\", variable: \"--popover\" },\n { token: \"foreground\", variable: \"--popover-foreground\" },\n { token: \"buttonBackground\", variable: \"--primary\" },\n { token: \"buttonForeground\", variable: \"--primary-foreground\" },\n { token: \"surface\", variable: \"--secondary\" },\n { token: \"foreground\", variable: \"--secondary-foreground\" },\n { token: \"hoverSurface\", variable: \"--accent\" },\n { token: \"foreground\", variable: \"--accent-foreground\" },\n { token: \"mutedForeground\", variable: \"--muted-foreground\" },\n { token: \"border\", variable: \"--border\" },\n { token: \"border\", variable: \"--input\" },\n { token: \"focusRing\", variable: \"--ring\" },\n { token: \"error\", variable: \"--destructive\" },\n { token: \"radius\", variable: \"--radius\" },\n];\n\nexport function resolveReturnsAppearance(\n appearance?: ReturnsAppearance,\n): ResolvedReturnsAppearance {\n const resolved = resolveAppearanceCore<\n ReturnsTokenName,\n ReturnsTheme,\n ReturnsSlotName\n >(appearance, {\n defaultTheme: \"light\",\n presets: RETURNS_THEME_PRESETS,\n variables: RETURNS_TOKEN_VARIABLES,\n shadcnVariables: RETURNS_SHADCN_VARIABLES,\n });\n\n return {\n theme: resolved.theme,\n tokens: resolved.tokens,\n elements: resolved.elements,\n boundaryClassName: resolved.theme,\n boundaryStyle: resolved.boundaryStyle,\n };\n}\n\n/** Caller overrides for a single slot, if any were provided. */\nexport function getReturnsSlotAppearance(\n resolved: ResolvedReturnsAppearance,\n slot: ReturnsSlotName,\n): ReturnsSlotAppearance | undefined {\n return getSlotAppearance(resolved.elements, slot);\n}\n","import { createContext, useContext, useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport {\n getReturnsSlotAppearance,\n resolveReturnsAppearance,\n type ResolvedReturnsAppearance,\n type ReturnsAppearance,\n type ReturnsSlotAppearance,\n type ReturnsSlotName,\n} from \"./appearance\";\n\nconst ReturnsAppearanceContext = createContext<ResolvedReturnsAppearance>(\n resolveReturnsAppearance(),\n);\n\n/**\n * Returns scoped appearance provider. It only wraps the returns views, so the\n * configuration never leaks into checkout, the panel or the host page.\n */\nexport function ReturnsAppearanceProvider({\n appearance,\n children,\n}: {\n appearance?: ReturnsAppearance;\n children: ReactNode;\n}) {\n const resolved = useMemo(\n () => resolveReturnsAppearance(appearance),\n [appearance],\n );\n\n return (\n <ReturnsAppearanceContext.Provider value={resolved}>\n {children}\n </ReturnsAppearanceContext.Provider>\n );\n}\n\nexport function useReturnsAppearance(): ResolvedReturnsAppearance {\n return useContext(ReturnsAppearanceContext);\n}\n\n/**\n * Returns the caller overrides for a slot, meant to be merged with the\n * built-in presentation:\n *\n * ```tsx\n * const slot = useReturnsSlot(\"title\");\n *\n * return <h2 className={cn(\"text-xl font-semibold\", slot.className)} style={slot.style} />;\n * ```\n */\nexport function useReturnsSlot(slot: ReturnsSlotName): ReturnsSlotAppearance {\n const resolved = useReturnsAppearance();\n\n return getReturnsSlotAppearance(resolved, slot) ?? {};\n}\n","import { Environment } from \"@/src/gen/proto/common/v1/environment_pb\";\nimport type { ReturnsAppearance } from \"./appearance\";\nimport { brandColorTokens } from \"./color\";\nimport type { ReturnsTexts } from \"./texts\";\n\n/**\n * Compatibility layer for the `bitsnap-react` 1.6.0 returns widget. Everything\n * here is pure; the components and hooks apply it at their boundary.\n */\n\n/** Environment as a string or as the proto enum used by 1.6.0. */\nexport type ReturnsEnvironmentInput = \"production\" | \"test\" | Environment;\n\n/** Text keys of the 1.6.0 widget. */\nexport type LegacyReturnsTexts = Partial<{\n title: string;\n email: string;\n sendCode: string;\n code: string;\n verify: string;\n orders: string;\n submit: string;\n note: string;\n loading: string;\n history: string;\n}>;\n\n/** Our text keys plus the 1.6.0 ones. Our keys win when both are given. */\nexport type ReturnsTextsInput = Partial<ReturnsTexts> & LegacyReturnsTexts;\n\n/** 1.6.0 `theme` prop. */\nexport type LegacyReturnsTheme = { brandColor?: string };\n\n/** Backend environment for a string or enum value. Defaults to production. */\nexport function resolveReturnsEnvironment(\n environment?: ReturnsEnvironmentInput,\n): Environment {\n return environment === \"test\" || environment === Environment.TEST\n ? Environment.TEST\n : Environment.PRODUCTION;\n}\n\nconst LEGACY_TEXT_KEYS: Record<\n Exclude<keyof LegacyReturnsTexts, \"loading\">,\n readonly (keyof ReturnsTexts)[]\n> = {\n title: [\"emailStepTitle\"],\n email: [\"emailLabel\"],\n sendCode: [\"emailSubmit\"],\n code: [\"codeLabel\"],\n verify: [\"codeSubmit\"],\n orders: [\"ordersTitle\"],\n submit: [\"confirmationSubmit\"],\n note: [\"noteLabel\"],\n history: [\"myReturnsTitle\", \"myReturnsLink\"],\n};\n\n/**\n * Maps 1.6.0 text keys onto ours. A key of the new API always wins over the\n * legacy key that maps to it. `loading` has the same name in both.\n */\nexport function mapLegacyTexts(\n texts: ReturnsTextsInput | undefined,\n): Partial<ReturnsTexts> | undefined {\n if (texts == null) {\n return undefined;\n }\n\n const result: Partial<ReturnsTexts> = {};\n for (const [legacyKey, targets] of Object.entries(LEGACY_TEXT_KEYS) as [\n keyof typeof LEGACY_TEXT_KEYS,\n readonly (keyof ReturnsTexts)[],\n ][]) {\n const value = texts[legacyKey];\n if (typeof value === \"string\") {\n for (const target of targets) {\n result[target] = value;\n }\n }\n }\n\n for (const key of Object.keys(texts) as (keyof ReturnsTextsInput)[]) {\n if (key in LEGACY_TEXT_KEYS) {\n continue;\n }\n const value = texts[key];\n if (typeof value === \"string\") {\n result[key as keyof ReturnsTexts] = value;\n }\n }\n\n return result;\n}\n\n/**\n * Appearance with the 1.6.0 `brandColor` applied as button background, focus\n * ring and readable button foreground. Explicit `appearance.tokens` win.\n */\nexport function resolveBrandAppearance(\n appearance: ReturnsAppearance | undefined,\n theme: LegacyReturnsTheme | undefined,\n): ReturnsAppearance | undefined {\n const color = theme?.brandColor?.trim();\n if (color == null || color === \"\") {\n return appearance;\n }\n return {\n ...appearance,\n tokens: { ...brandColorTokens(color), ...appearance?.tokens },\n };\n}\n\n/** Arguments of the paged hooks in either call style. */\nexport type PagedArguments = {\n pageSize: number;\n /** Explicit page token of the positional (1.6.0) form. */\n explicitPageToken: string | undefined;\n};\n\n/**\n * Normalizes `(pageSize?, pageToken?)` (1.6.0) and `({ pageSize })` (ours).\n * Both forms default to 20 items, like 1.6.0.\n */\nexport function resolvePagedArguments(\n first: number | { pageSize?: number } | undefined,\n pageToken: string | undefined,\n): PagedArguments {\n if (typeof first === \"object\" && first != null) {\n return { pageSize: first.pageSize ?? 20, explicitPageToken: undefined };\n }\n if (typeof first === \"number\" || pageToken !== undefined) {\n return { pageSize: first ?? 20, explicitPageToken: pageToken ?? \"\" };\n }\n return { pageSize: 20, explicitPageToken: undefined };\n}\n","import { lookupText, resolveTexts, type LocaleTables } from \"@/src/lib/texts\";\n\n/**\n * Every string the returns views render. Pass a partial object through the\n * `texts` prop of `BitsnapReturns`/`ReturnsProvider` to override any of them,\n * whatever the locale. Strings with `{name}` placeholders keep them in\n * overrides; unknown placeholders are left untouched.\n */\nexport type ReturnsTexts = Omit<ResolvedReturnsTexts, OptionalReturnsTextKey> &\n Partial<Pick<ResolvedReturnsTexts, OptionalReturnsTextKey>>;\n\n/**\n * Keys added after 1.6: optional in {@link ReturnsTexts} so that code which\n * builds a complete texts object keeps compiling. The defaults fill them in.\n */\ntype OptionalReturnsTextKey =\n | \"resendSent\"\n | \"codeSpamHint\"\n | \"codeValidity\"\n | \"codeIncomplete\"\n | \"errorNetwork\";\n\n/** The texts after the defaults are applied: every key is present. */\nexport type ResolvedReturnsTexts = {\n // Frame\n /** Label of the back buttons. */\n back: string;\n /** Step indicator, placeholders `{current}` and `{total}`. */\n stepIndicator: string;\n /** Skeleton accessible label. */\n loading: string;\n /** Button that opens the list of previous returns. */\n myReturnsLink: string;\n\n // Email step\n emailStepTitle: string;\n emailStepDescription: string;\n emailLabel: string;\n emailPlaceholder: string;\n emailSubmit: string;\n\n // Code step\n codeStepTitle: string;\n /** Placeholder `{email}`. */\n codeStepDescription: string;\n codeLabel: string;\n codeSubmit: string;\n resend: string;\n /** Placeholder `{seconds}`. */\n resendIn: string;\n /** Confirmation after a new code was sent. */\n resendSent: string;\n /** Hint under the code field. */\n codeSpamHint: string;\n codeValidity: string;\n /** Shown when the form is submitted with fewer than 6 digits. */\n codeIncomplete: string;\n logout: string;\n\n // Orders\n ordersTitle: string;\n ordersDescription: string;\n ordersEmpty: string;\n /** Placeholder `{reference}`. */\n orderTitle: string;\n /** Placeholder `{count}`. */\n orderReturnableLines: string;\n orderSelect: string;\n paginationPrevious: string;\n paginationNext: string;\n /** Placeholders `{page}` and `{total}` (number of orders). */\n paginationInfo: string;\n\n // Order detail\n /** Placeholder `{reference}`. */\n orderDetailTitle: string;\n orderDetailDescription: string;\n /** Placeholder `{name}`. */\n quantityLabel: string;\n /** Placeholder `{name}`. */\n quantityDecrease: string;\n /** Placeholder `{name}`. */\n quantityIncrease: string;\n /** Placeholder `{available}`. */\n quantityOfAvailable: string;\n /** Shown for an ineligible line without a reason from the backend. */\n lineIneligibleFallback: string;\n noteLabel: string;\n notePlaceholder: string;\n selectionContinue: string;\n selectionEmpty: string;\n previousReturnsTitle: string;\n\n // Confirmation\n confirmationTitle: string;\n confirmationDescription: string;\n confirmationSummary: string;\n /** Placeholder `{quantity}`. */\n confirmationQuantity: string;\n confirmationNote: string;\n confirmationSubmit: string;\n\n // Result\n successTitle: string;\n successDescription: string;\n successReference: string;\n successInstructions: string;\n successDone: string;\n\n // My returns\n myReturnsTitle: string;\n myReturnsDescription: string;\n myReturnsEmpty: string;\n myReturnOpen: string;\n myReturnDetailTitle: string;\n /** Placeholder `{reference}`. */\n myReturnTitle: string;\n myReturnCreatedAt: string;\n myReturnRefund: string;\n myReturnLines: string;\n /** Placeholders `{requested}`, `{approved}`, `{received}`. */\n myReturnLineQuantities: string;\n myReturnNote: string;\n myReturnHistory: string;\n\n // Request status labels\n statusSubmitted: string;\n statusApproved: string;\n statusRejected: string;\n statusAwaitingReceipt: string;\n statusReceived: string;\n statusCompleted: string;\n statusCancelled: string;\n statusRefunded: string;\n /** Any status the backend adds later. */\n statusFallback: string;\n\n // Refund status labels\n refundStatusNotStarted: string;\n refundStatusPending: string;\n refundStatusSucceeded: string;\n refundStatusFailed: string;\n refundStatusFallback: string;\n\n // Error messages\n errorGeneric: string;\n errorNetwork: string;\n errorInvalidEmail: string;\n errorInvalidCode: string;\n errorSessionExpired: string;\n errorOrderNotFound: string;\n errorReturnNotFound: string;\n errorQuantityUnavailable: string;\n errorItemNotReturnable: string;\n errorReturnsDisabled: string;\n errorRateLimited: string;\n errorIdempotencyConflict: string;\n errorDeliveryFailed: string;\n errorRetry: string;\n};\n\nexport type ReturnsTextKey = keyof ResolvedReturnsTexts;\n\nexport const RETURNS_TEXT_TABLES: LocaleTables<ReturnsTextKey> = {\n en: {\n back: \"Back\",\n stepIndicator: \"Step {current} of {total}\",\n loading: \"Loading\",\n myReturnsLink: \"My returns\",\n\n emailStepTitle: \"Return a product\",\n emailStepDescription:\n \"Enter the email address you used for the order. We will send you a verification code.\",\n emailLabel: \"Email address\",\n emailPlaceholder: \"name@example.com\",\n emailSubmit: \"Send code\",\n\n codeStepTitle: \"Enter the code\",\n codeStepDescription: \"We sent a verification code to {email}.\",\n codeLabel: \"Verification code\",\n codeSubmit: \"Verify\",\n resend: \"Send the code again\",\n resendIn: \"Send again in {seconds} s\",\n resendSent: \"We sent a new code.\",\n codeSpamHint: \"Can't see the email? Check your spam folder.\",\n codeValidity: \"The code is valid for 10 minutes.\",\n codeIncomplete: \"Enter all 6 digits of the code.\",\n logout: \"Sign out\",\n\n ordersTitle: \"Your orders\",\n ordersDescription: \"Choose the order that contains the product to return.\",\n ordersEmpty: \"There are no orders eligible for return.\",\n orderTitle: \"Order {reference}\",\n orderReturnableLines: \"Products available to return: {count}\",\n orderSelect: \"Choose\",\n paginationPrevious: \"Previous\",\n paginationNext: \"Next\",\n paginationInfo: \"Page {page}, {total} orders\",\n\n orderDetailTitle: \"Order {reference}\",\n orderDetailDescription: \"Select the products and quantities to return.\",\n quantityLabel: \"Quantity to return: {name}\",\n quantityDecrease: \"Decrease quantity: {name}\",\n quantityIncrease: \"Increase quantity: {name}\",\n quantityOfAvailable: \"of {available}\",\n lineIneligibleFallback: \"This product cannot be returned.\",\n noteLabel: \"Note (optional)\",\n notePlaceholder: \"Tell us why you are returning the product\",\n selectionContinue: \"Continue\",\n selectionEmpty: \"Select at least one item to return.\",\n previousReturnsTitle: \"Earlier returns for this order\",\n\n confirmationTitle: \"Confirm the return\",\n confirmationDescription: \"Check the products before you submit the request.\",\n confirmationSummary: \"Products to return\",\n confirmationQuantity: \"Quantity: {quantity}\",\n confirmationNote: \"Your note\",\n confirmationSubmit: \"Submit return request\",\n\n successTitle: \"Return request submitted\",\n successDescription: \"We received your request and will keep you posted.\",\n successReference: \"Request number\",\n successInstructions: \"What to do next\",\n successDone: \"Back to orders\",\n\n myReturnsTitle: \"My returns\",\n myReturnsDescription: \"Track the status of your return requests.\",\n myReturnsEmpty: \"You have not submitted any return requests yet.\",\n myReturnOpen: \"Details\",\n myReturnDetailTitle: \"Return details\",\n myReturnTitle: \"Return {reference}\",\n myReturnCreatedAt: \"Submitted\",\n myReturnRefund: \"Refund\",\n myReturnLines: \"Products\",\n myReturnLineQuantities:\n \"Requested: {requested}, approved: {approved}, received: {received}\",\n myReturnNote: \"Your note\",\n myReturnHistory: \"History\",\n\n statusSubmitted: \"Submitted\",\n statusApproved: \"Approved\",\n statusRejected: \"Rejected\",\n statusAwaitingReceipt: \"Awaiting the package\",\n statusReceived: \"Package received\",\n statusCompleted: \"Completed\",\n statusCancelled: \"Cancelled\",\n statusRefunded: \"Refunded\",\n statusFallback: \"In progress\",\n\n refundStatusNotStarted: \"Not started\",\n refundStatusPending: \"Refund in progress\",\n refundStatusSucceeded: \"Refunded\",\n refundStatusFailed: \"Refund failed\",\n refundStatusFallback: \"Unknown\",\n\n errorGeneric: \"Something went wrong. Please try again.\",\n errorNetwork: \"Cannot reach the server. Check your connection and try again.\",\n errorInvalidEmail: \"Enter a valid email address.\",\n errorInvalidCode: \"The code is invalid or has expired.\",\n errorSessionExpired: \"Your session has expired. Verify your email again.\",\n errorOrderNotFound: \"We could not find this order.\",\n errorReturnNotFound: \"We could not find this return request.\",\n errorQuantityUnavailable:\n \"The selected quantity is no longer available for return.\",\n errorItemNotReturnable: \"One of the selected products cannot be returned.\",\n errorReturnsDisabled: \"Returns are not available in this shop.\",\n errorRateLimited: \"Too many attempts. Please try again later.\",\n errorIdempotencyConflict:\n \"This request was already submitted with different contents. Reload and try again.\",\n errorDeliveryFailed: \"We could not send the code. Please try again.\",\n errorRetry: \"Try again\",\n },\n pl: {\n back: \"Wstecz\",\n stepIndicator: \"Krok {current} z {total}\",\n loading: \"Ładowanie\",\n myReturnsLink: \"Moje zwroty\",\n\n emailStepTitle: \"Zwróć produkt\",\n emailStepDescription:\n \"Podaj adres e-mail użyty w zamówieniu. Wyślemy na niego kod weryfikacyjny.\",\n emailLabel: \"Adres e-mail\",\n emailPlaceholder: \"jan@example.com\",\n emailSubmit: \"Wyślij kod\",\n\n codeStepTitle: \"Wpisz kod\",\n codeStepDescription: \"Wysłaliśmy kod weryfikacyjny na adres {email}.\",\n codeLabel: \"Kod weryfikacyjny\",\n codeSubmit: \"Zweryfikuj\",\n resend: \"Wyślij kod ponownie\",\n resendIn: \"Wyślij ponownie za {seconds} s\",\n resendSent: \"Wysłaliśmy nowy kod.\",\n codeSpamHint: \"Nie widzisz e-maila? Sprawdź folder spam.\",\n codeValidity: \"Kod jest ważny 10 minut.\",\n codeIncomplete: \"Wpisz wszystkie 6 cyfr kodu.\",\n logout: \"Wyloguj się\",\n\n ordersTitle: \"Twoje zamówienia\",\n ordersDescription: \"Wybierz zamówienie z produktem do zwrotu.\",\n ordersEmpty: \"Brak zamówień, które można zwrócić.\",\n orderTitle: \"Zamówienie {reference}\",\n orderReturnableLines: \"Produkty do zwrotu: {count}\",\n orderSelect: \"Wybierz\",\n paginationPrevious: \"Poprzednia\",\n paginationNext: \"Następna\",\n paginationInfo: \"Strona {page}, zamówień: {total}\",\n\n orderDetailTitle: \"Zamówienie {reference}\",\n orderDetailDescription: \"Wybierz produkty i ilości do zwrotu.\",\n quantityLabel: \"Ilość do zwrotu: {name}\",\n quantityDecrease: \"Zmniejsz ilość: {name}\",\n quantityIncrease: \"Zwiększ ilość: {name}\",\n quantityOfAvailable: \"z {available}\",\n lineIneligibleFallback: \"Ten produkt nie podlega zwrotowi.\",\n noteLabel: \"Uwagi (opcjonalnie)\",\n notePlaceholder: \"Napisz, dlaczego zwracasz produkt\",\n selectionContinue: \"Dalej\",\n selectionEmpty: \"Wybierz co najmniej jedną sztukę do zwrotu.\",\n previousReturnsTitle: \"Wcześniejsze zwroty tego zamówienia\",\n\n confirmationTitle: \"Potwierdź zwrot\",\n confirmationDescription: \"Sprawdź produkty przed wysłaniem zgłoszenia.\",\n confirmationSummary: \"Produkty do zwrotu\",\n confirmationQuantity: \"Ilość: {quantity}\",\n confirmationNote: \"Twoje uwagi\",\n confirmationSubmit: \"Wyślij zgłoszenie zwrotu\",\n\n successTitle: \"Zgłoszenie zwrotu zostało wysłane\",\n successDescription: \"Otrzymaliśmy zgłoszenie i będziemy informować o jego statusie.\",\n successReference: \"Numer zgłoszenia\",\n successInstructions: \"Co dalej\",\n successDone: \"Wróć do zamówień\",\n\n myReturnsTitle: \"Moje zwroty\",\n myReturnsDescription: \"Sprawdź status swoich zgłoszeń zwrotu.\",\n myReturnsEmpty: \"Nie masz jeszcze żadnych zgłoszeń zwrotu.\",\n myReturnOpen: \"Szczegóły\",\n myReturnDetailTitle: \"Szczegóły zwrotu\",\n myReturnTitle: \"Zwrot {reference}\",\n myReturnCreatedAt: \"Zgłoszono\",\n myReturnRefund: \"Zwrot środków\",\n myReturnLines: \"Produkty\",\n myReturnLineQuantities:\n \"Zgłoszono: {requested}, zaakceptowano: {approved}, odebrano: {received}\",\n myReturnNote: \"Twoje uwagi\",\n myReturnHistory: \"Historia\",\n\n statusSubmitted: \"Zgłoszony\",\n statusApproved: \"Zaakceptowany\",\n statusRejected: \"Odrzucony\",\n statusAwaitingReceipt: \"Oczekiwanie na paczkę\",\n statusReceived: \"Paczka odebrana\",\n statusCompleted: \"Zakończony\",\n statusCancelled: \"Anulowany\",\n statusRefunded: \"Środki zwrócone\",\n statusFallback: \"W trakcie\",\n\n refundStatusNotStarted: \"Nie rozpoczęto\",\n refundStatusPending: \"Zwrot środków w toku\",\n refundStatusSucceeded: \"Środki zwrócone\",\n refundStatusFailed: \"Zwrot środków nie powiódł się\",\n refundStatusFallback: \"Nieznany\",\n\n errorGeneric: \"Coś poszło nie tak. Spróbuj ponownie.\",\n errorNetwork: \"Brak połączenia z serwerem. Sprawdź internet i spróbuj ponownie.\",\n errorInvalidEmail: \"Podaj poprawny adres e-mail.\",\n errorInvalidCode: \"Kod jest nieprawidłowy lub wygasł.\",\n errorSessionExpired: \"Sesja wygasła. Zweryfikuj adres e-mail ponownie.\",\n errorOrderNotFound: \"Nie znaleziono tego zamówienia.\",\n errorReturnNotFound: \"Nie znaleziono tego zgłoszenia zwrotu.\",\n errorQuantityUnavailable:\n \"Wybrana ilość nie jest już dostępna do zwrotu.\",\n errorItemNotReturnable: \"Jeden z wybranych produktów nie podlega zwrotowi.\",\n errorReturnsDisabled: \"Zwroty nie są dostępne w tym sklepie.\",\n errorRateLimited: \"Zbyt wiele prób. Spróbuj ponownie później.\",\n errorIdempotencyConflict:\n \"To zgłoszenie zostało już wysłane z inną zawartością. Odśwież stronę i spróbuj ponownie.\",\n errorDeliveryFailed: \"Nie udało się wysłać kodu. Spróbuj ponownie.\",\n errorRetry: \"Spróbuj ponownie\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveReturnsTexts(\n locale: string,\n overrides?: Partial<ReturnsTexts>,\n): ResolvedReturnsTexts {\n return resolveTexts(RETURNS_TEXT_TABLES, locale, overrides);\n}\n\nexport function getReturnsText(\n key: ReturnsTextKey,\n locale: string,\n overrides?: Partial<ReturnsTexts>,\n): string {\n return lookupText(resolveReturnsTexts(locale, overrides), key);\n}\n\n/** Replaces `{name}` placeholders. Unknown placeholders stay as they are. */\nexport function fillText(\n template: string,\n values: Record<string, string | number>,\n): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, name: string) =>\n Object.prototype.hasOwnProperty.call(values, name)\n ? String(values[name])\n : match,\n );\n}\n\nconst STATUS_TEXT_KEYS: Record<string, ReturnsTextKey> = {\n submitted: \"statusSubmitted\",\n approved: \"statusApproved\",\n rejected: \"statusRejected\",\n awaiting_receipt: \"statusAwaitingReceipt\",\n received: \"statusReceived\",\n completed: \"statusCompleted\",\n cancelled: \"statusCancelled\",\n refunded: \"statusRefunded\",\n};\n\nconst REFUND_STATUS_TEXT_KEYS: Record<string, ReturnsTextKey> = {\n not_started: \"refundStatusNotStarted\",\n pending: \"refundStatusPending\",\n succeeded: \"refundStatusSucceeded\",\n failed: \"refundStatusFailed\",\n};\n\n/** Text key for a backend request status, with a fallback for unknown ones. */\nexport function statusTextKey(status: string): ReturnsTextKey {\n return STATUS_TEXT_KEYS[status] ?? \"statusFallback\";\n}\n\n/** Text key for a backend refund status, with a fallback for unknown ones. */\nexport function refundStatusTextKey(status: string): ReturnsTextKey {\n return REFUND_STATUS_TEXT_KEYS[status] ?? \"refundStatusFallback\";\n}\n","import { createContext, useCallback, useContext, useMemo } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { getLocale } from \"@/src/components/checkout/locale\";\nimport {\n fillText,\n resolveReturnsTexts,\n type ReturnsTextKey,\n type ResolvedReturnsTexts,\n type ReturnsTexts,\n} from \"./texts\";\n\ntype ReturnsTextsContextValue = {\n /** Active locale (the `locale` prop or the library locale). */\n locale: string;\n texts: ResolvedReturnsTexts;\n};\n\nconst ReturnsTextsContext = createContext<ReturnsTextsContextValue>({\n locale: \"pl-PL\",\n texts: resolveReturnsTexts(\"pl-PL\"),\n});\n\n/**\n * Returns scoped texts provider. Carries the `texts` overrides and the\n * `locale` prop down to the returns tree.\n */\nexport function ReturnsTextsProvider({\n texts,\n locale,\n children,\n}: {\n texts?: Partial<ReturnsTexts>;\n locale?: string;\n children: ReactNode;\n}) {\n const activeLocale = locale ?? getLocale();\n const value = useMemo(\n () => ({\n locale: activeLocale,\n texts: resolveReturnsTexts(activeLocale, texts),\n }),\n [activeLocale, texts],\n );\n\n return (\n <ReturnsTextsContext.Provider value={value}>\n {children}\n </ReturnsTextsContext.Provider>\n );\n}\n\n/**\n * Returns a lookup for the returns strings: the caller override when provided,\n * otherwise the default for the locale. Optional `values` fill `{placeholders}`.\n */\nexport function useReturnsText(): (\n key: ReturnsTextKey,\n values?: Record<string, string | number>,\n) => string {\n const { texts } = useContext(ReturnsTextsContext);\n\n return useCallback(\n (key, values) =>\n values == null ? texts[key] : fillText(texts[key], values),\n [texts],\n );\n}\n\n/** Active locale of the returns views, for date and money formatting. */\nexport function useReturnsLocale(): string {\n return useContext(ReturnsTextsContext).locale;\n}\n","import { createClient } from \"@connectrpc/connect\";\nimport {\n createConnectQueryKey,\n TransportProvider,\n} from \"@connectrpc/connect-query\";\nimport {\n QueryClient,\n QueryClientContext,\n QueryClientProvider,\n useQueryClient,\n} from \"@tanstack/react-query\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { Environment } from \"@/src/gen/proto/common/v1/environment_pb\";\nimport { ReturnsService } from \"@/src/gen/proto/public/v1/returns_pb\";\nimport {\n InstrumentProvider,\n useInstrument,\n type AnalyticsOption,\n} from \"@/src/analytics/instrument\";\nimport { cn } from \"@/src/lib/utils\";\nimport {\n clearPendingLogin,\n pendingLoginKey,\n readPendingLogin,\n savePendingLogin,\n} from \"@/src/ui/email-code-login/pending\";\nimport { getRpcTransport, getTransportHost } from \"@/src/rpc-provider\";\nimport type { Transport } from \"@connectrpc/connect\";\nimport type { ReturnsAppearance } from \"./appearance\";\nimport {\n ReturnsAppearanceProvider,\n useReturnsAppearance,\n useReturnsSlot,\n} from \"./appearance.context\";\nimport {\n clearStoredSession,\n expiryToMillis,\n getBrowserSessionStorage,\n readStoredSession,\n writeStoredSession,\n type StoredReturnsSession,\n} from \"./session-storage\";\nimport {\n mapLegacyTexts,\n resolveBrandAppearance,\n resolveReturnsEnvironment,\n type LegacyReturnsTheme,\n type ReturnsEnvironmentInput,\n type ReturnsTextsInput,\n} from \"./legacy\";\nimport { ReturnsTextsProvider } from \"./texts.context\";\n\n/**\n * Backend environment the returns calls run against. The library has no other\n * environment switch for public API calls, so this defaults to `\"production\"`.\n */\nexport type ReturnsEnvironment = \"production\" | \"test\";\n\nexport type ReturnsSessionStatus =\n /** Server render and first client render: storage has not been read yet. */\n | \"hydrating\"\n /** A `panelAccessToken` is being exchanged for a returns session. */\n | \"exchanging\"\n | \"anonymous\"\n | \"authenticated\";\n\n/** A pending email verification. */\nexport type ReturnsChallenge = {\n challengeId: string;\n email: string;\n /** Unix milliseconds when the next code may be requested. */\n resendAvailableAt: number;\n};\n\nexport type ReturnsContextValue = {\n projectID: string;\n environment: Environment;\n status: ReturnsSessionStatus;\n /** Session token. Never log it. */\n token: string | undefined;\n /** Failure of the last panel token exchange, if any. */\n exchangeError: unknown;\n challenge: ReturnsChallenge | undefined;\n /**\n * Stores (or, with `undefined`, drops) the pending verification. It is kept\n * in `sessionStorage` too, so a reload returns to the code step.\n */\n setChallenge: (challenge: ReturnsChallenge | undefined) => void;\n /** Email of the last verification, kept after the challenge is dropped. */\n lastEmail: string | undefined;\n /** Stores a freshly issued session in state and `sessionStorage`. */\n authenticate: (session: StoredReturnsSession) => void;\n /** Drops the session, the pending challenge and cached customer data. */\n clearSession: () => void;\n};\n\nconst ReturnsContext = createContext<ReturnsContextValue | undefined>(\n undefined,\n);\n\n/**\n * Context of the nearest `ReturnsProvider`. Throws a clear error outside of\n * it, naming the component or hook that was misplaced.\n */\nexport function useReturnsContext(name: string): ReturnsContextValue {\n const value = useContext(ReturnsContext);\n\n if (value == null) {\n throw new Error(`${name} must be rendered inside <ReturnsProvider>`);\n }\n\n return value;\n}\n\nexport type ReturnsProviderProps = {\n /** Bitsnap project ID. */\n projectID: string;\n /**\n * API host. Defaults to the host set with `setCustomHost`/`setHost`, then to\n * `https://bitsnap.pl`. Each provider keeps its own transport.\n */\n host?: string;\n /**\n * Backend environment, `\"production\"` unless set to `\"test\"`. The proto\n * `Environment` enum is accepted too.\n */\n environment?: ReturnsEnvironmentInput;\n /** Theme, tokens and per-element overrides. */\n appearance?: ReturnsAppearance;\n /**\n * Text overrides, applied whatever the locale. The keys of `bitsnap-react`\n * 1.6.0 (`title`, `email`, `sendCode`, ...) are accepted too; our own keys\n * win when both are given.\n */\n texts?: ReturnsTextsInput;\n /** `bitsnap-react` 1.6.0 brand color. Explicit `appearance.tokens` win. */\n theme?: LegacyReturnsTheme;\n /** Locale of texts, dates and money. Defaults to the library locale. */\n locale?: string;\n /**\n * Customer panel access token. When set, it is exchanged for a returns\n * session on mount, so the customer needs no second verification code.\n * Changing or removing it drops the session.\n */\n panelAccessToken?: string;\n /** Class of the themed root element. */\n className?: string;\n /**\n * Usage statistics for your Bitsnap dashboard (return started, return\n * submitted). On by default; `false` turns it off. An object lets you\n * forward every event: `{ onEvent }`. Inside `<Panel>` the panel's setting\n * applies unless this is given. Nothing is stored on the visitor's device.\n */\n analytics?: AnalyticsOption;\n children?: ReactNode;\n};\n\n/** Key prefix that matches every returns query, for invalidation and removal. */\nexport function returnsQueryKey(): readonly unknown[] {\n return createConnectQueryKey({\n schema: ReturnsService,\n cardinality: undefined,\n });\n}\n\n/** Longest delay `setTimeout` accepts. */\nconst MAX_TIMEOUT_MS = 2 ** 31 - 1;\n\nfunction SessionProvider({\n projectID,\n environment,\n transport,\n panelAccessToken,\n className,\n children,\n}: {\n projectID: string;\n environment: Environment;\n transport: Transport;\n panelAccessToken?: string;\n className?: string;\n children?: ReactNode;\n}) {\n const queryClient = useQueryClient();\n const { boundaryClassName, boundaryStyle } = useReturnsAppearance();\n const root = useReturnsSlot(\"root\");\n\n const [session, setSession] = useState<{\n status: ReturnsSessionStatus;\n token?: string;\n expiresAt?: number;\n }>({ status: \"hydrating\" });\n const [exchangeError, setExchangeError] = useState<unknown>();\n const [challenge, setChallengeState] = useState<ReturnsChallenge>();\n const [lastEmail, setLastEmail] = useState<string>();\n const pendingKey = pendingLoginKey(\"returns\", projectID);\n const previousPanelToken = useRef<string | undefined>(undefined);\n\n const setChallenge = useCallback(\n (next: ReturnsChallenge | undefined) => {\n setChallengeState(next);\n if (next == null) {\n clearPendingLogin(pendingKey);\n return;\n }\n setLastEmail(next.email);\n savePendingLogin(pendingKey, {\n email: next.email,\n challengeId: next.challengeId,\n resendAt: next.resendAvailableAt,\n sentAt: Date.now(),\n });\n },\n [pendingKey],\n );\n\n const dropCachedData = useCallback(() => {\n // Query inputs carry the session token, so cached customer data must not\n // outlive the session. Only returns queries are touched.\n queryClient.removeQueries({ queryKey: returnsQueryKey() });\n }, [queryClient]);\n\n const clearSession = useCallback(() => {\n clearStoredSession(getBrowserSessionStorage(), projectID);\n setChallenge(undefined);\n setSession({ status: \"anonymous\" });\n dropCachedData();\n }, [projectID, dropCachedData, setChallenge]);\n\n const authenticate = useCallback(\n (next: StoredReturnsSession) => {\n writeStoredSession(getBrowserSessionStorage(), projectID, next);\n setExchangeError(undefined);\n setChallenge(undefined);\n setSession({\n status: \"authenticated\",\n token: next.token,\n expiresAt: next.expiresAt,\n });\n },\n [projectID, setChallenge],\n );\n\n // Hydrates from `sessionStorage`, or exchanges the panel token. Runs after\n // mount, so render never touches `window`.\n useEffect(() => {\n let cancelled = false;\n const storage = getBrowserSessionStorage();\n\n if (panelAccessToken == null || panelAccessToken === \"\") {\n const hadPanelToken = previousPanelToken.current != null;\n previousPanelToken.current = undefined;\n\n if (hadPanelToken) {\n clearSession();\n return;\n }\n\n const stored = readStoredSession(storage, projectID);\n // A verification that was pending before a reload or an app switch.\n const pending = stored == null ? readPendingLogin(pendingKey) : undefined;\n if (pending?.challengeId != null) {\n setChallengeState({\n challengeId: pending.challengeId,\n email: pending.email,\n resendAvailableAt: pending.resendAt,\n });\n setLastEmail(pending.email);\n }\n setSession(\n stored != null\n ? {\n status: \"authenticated\",\n token: stored.token,\n expiresAt: stored.expiresAt,\n }\n : { status: \"anonymous\" },\n );\n return;\n }\n\n previousPanelToken.current = panelAccessToken;\n clearStoredSession(storage, projectID);\n dropCachedData();\n setExchangeError(undefined);\n setSession({ status: \"exchanging\" });\n\n createClient(ReturnsService, transport)\n .exchangePanelSession({\n projectId: projectID,\n accessToken: panelAccessToken,\n environment,\n })\n .then((response) => {\n if (cancelled) {\n return;\n }\n const expiresAt = expiryToMillis(response.expiresAt);\n if (response.sessionToken === \"\" || expiresAt == null) {\n throw new Error(\"EMPTY_SESSION\");\n }\n authenticate({ token: response.sessionToken, expiresAt });\n })\n .catch((error: unknown) => {\n if (cancelled) {\n return;\n }\n setExchangeError(error);\n setSession({ status: \"anonymous\" });\n });\n\n return () => {\n cancelled = true;\n };\n // `clearSession`, `authenticate` and `dropCachedData` only change with the\n // project or the query client, which are already covered.\n }, [panelAccessToken, projectID, environment, transport]);\n\n // Expired sessions are dropped even when the page stays open.\n useEffect(() => {\n if (session.status !== \"authenticated\" || session.expiresAt == null) {\n return;\n }\n const remaining = session.expiresAt - Date.now();\n if (remaining <= 0) {\n clearSession();\n return;\n }\n const timer = setTimeout(\n clearSession,\n Math.min(remaining, MAX_TIMEOUT_MS),\n );\n return () => clearTimeout(timer);\n }, [session.status, session.expiresAt, clearSession]);\n\n const value = useMemo<ReturnsContextValue>(\n () => ({\n projectID,\n environment,\n status: session.status,\n token: session.token,\n exchangeError,\n challenge,\n setChallenge,\n lastEmail,\n authenticate,\n clearSession,\n }),\n [\n projectID,\n environment,\n session.status,\n session.token,\n exchangeError,\n challenge,\n setChallenge,\n lastEmail,\n authenticate,\n clearSession,\n ],\n );\n\n return (\n <ReturnsContext.Provider value={value}>\n <div\n data-bitsnap-returns=\"root\"\n data-bitsnap-returns-slot=\"root\"\n className={cn(\"bitsnap-react\", boundaryClassName, className, root.className)}\n style={{ ...boundaryStyle, ...root.style } as CSSProperties}\n >\n {children}\n </div>\n </ReturnsContext.Provider>\n );\n}\n\n/**\n * Holds everything the returns views share: the per-instance transport, the\n * query client (when the app has none), appearance, texts and the returns\n * session. It renders the themed root element, so step components composed\n * under it are themed without extra markup.\n *\n * ```tsx\n * <ReturnsProvider projectID=\"…\" appearance={brand}>\n * <ReturnsOrderList onSelectOrder={setOrderId} />\n * </ReturnsProvider>\n * ```\n */\nexport function ReturnsProvider({\n projectID,\n host,\n environment,\n appearance,\n texts,\n theme,\n locale,\n panelAccessToken,\n className,\n analytics,\n children,\n}: ReturnsProviderProps) {\n const instrument = useInstrument(projectID, analytics, \"returns\");\n const existingQueryClient = useContext(QueryClientContext);\n const [ownQueryClient] = useState(() =>\n existingQueryClient == null\n ? new QueryClient({ defaultOptions: { queries: { staleTime: 5000 } } })\n : undefined,\n );\n\n const resolvedHost = host ?? getTransportHost();\n const transport = useMemo(\n () => getRpcTransport(resolvedHost),\n [resolvedHost],\n );\n\n const brandColor = theme?.brandColor;\n const resolvedAppearance = useMemo(\n () => resolveBrandAppearance(appearance, { brandColor }),\n [appearance, brandColor],\n );\n const resolvedTexts = useMemo(() => mapLegacyTexts(texts), [texts]);\n\n const content = (\n <InstrumentProvider value={instrument}>\n <TransportProvider transport={transport}>\n <ReturnsAppearanceProvider appearance={resolvedAppearance}>\n <ReturnsTextsProvider texts={resolvedTexts} locale={locale}>\n <SessionProvider\n projectID={projectID}\n environment={resolveReturnsEnvironment(environment)}\n transport={transport}\n panelAccessToken={panelAccessToken}\n className={className}\n >\n {children}\n </SessionProvider>\n </ReturnsTextsProvider>\n </ReturnsAppearanceProvider>\n </TransportProvider>\n </InstrumentProvider>\n );\n\n return existingQueryClient == null && ownQueryClient != null ? (\n <QueryClientProvider client={ownQueryClient}>{content}</QueryClientProvider>\n ) : (\n content\n );\n}\n\n/** Name of {@link ReturnsProvider} in `bitsnap-react` 1.6.0. */\nexport const BitsnapReturnsProvider = ReturnsProvider;\n\nexport type BitsnapReturnsProviderProps = ReturnsProviderProps;\n","/**\n * The pending step of an e-mail-code login, kept in `sessionStorage` so a\n * reload or an app switch (the code arrives in the mail app) returns to the\n * code step. One key per surface and project; never holds the code itself.\n */\n\n/** How long a sent code stays usable, in milliseconds (the copy says 10 min). */\nexport const CODE_VALID_MS = 10 * 60 * 1000;\n\nexport type PendingLogin = {\n email: string;\n challengeId?: string;\n /** Unix milliseconds when a new code may be requested. */\n resendAt: number;\n /** Unix milliseconds when the code was sent. */\n sentAt: number;\n};\n\ntype StorageLike = Pick<Storage, \"getItem\" | \"setItem\" | \"removeItem\">;\n\nfunction browserStorage(): StorageLike | undefined {\n try {\n return typeof window !== \"undefined\" ? window.sessionStorage : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** `bitsnap-login-pending:<surface>:<host>:<project>`. */\nexport function pendingLoginKey(\n surface: string,\n projectID?: string,\n host?: string,\n): string {\n return `bitsnap-login-pending:${surface}:${encodeURIComponent(host ?? \"\")}:${encodeURIComponent(projectID ?? \"\")}`;\n}\n\nexport function savePendingLogin(key: string, pending: PendingLogin): void {\n try {\n browserStorage()?.setItem(key, JSON.stringify(pending));\n } catch {\n // Storage full or blocked: the login still works, it just is not restored.\n }\n}\n\nexport function clearPendingLogin(key: string): void {\n try {\n browserStorage()?.removeItem(key);\n } catch {\n // ignore\n }\n}\n\n/**\n * The stored step. Malformed and expired entries are removed and reported as\n * none.\n */\nexport function readPendingLogin(\n key: string,\n now: number = Date.now(),\n): PendingLogin | undefined {\n const storage = browserStorage();\n if (storage == null) return undefined;\n try {\n const raw = storage.getItem(key);\n if (raw == null) return undefined;\n const parsed = JSON.parse(raw) as Partial<PendingLogin> | null;\n if (\n parsed != null &&\n typeof parsed.email === \"string\" &&\n parsed.email !== \"\" &&\n typeof parsed.sentAt === \"number\" &&\n typeof parsed.resendAt === \"number\" &&\n (parsed.challengeId == null || typeof parsed.challengeId === \"string\") &&\n now - parsed.sentAt < CODE_VALID_MS\n ) {\n return {\n email: parsed.email,\n challengeId: parsed.challengeId,\n resendAt: parsed.resendAt,\n sentAt: parsed.sentAt,\n };\n }\n storage.removeItem(key);\n } catch {\n try {\n storage.removeItem(key);\n } catch {\n // ignore\n }\n }\n return undefined;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import{a as O,b as at,c as it,d as st,e as dt,f as U}from"./chunk-UPAOIY4R.mjs";import{a as ot,b as nt}from"./chunk-KOVKUJAW.mjs";import{a as M}from"./chunk-5R6AGO3Z.mjs";import{e as rt}from"./chunk-GEBRXFT3.mjs";import{f as X,l as Z,m as J,n as Y,p as Q}from"./chunk-CF45RDMD.mjs";import{b as tt,d as et}from"./chunk-VNYHJT6V.mjs";var ht=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","model3dBadge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],xt={fontFamily:"--bitsnap-products-font-family",gridMinWidth:"--bitsnap-products-grid-min-width",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},Tt={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px",gridMinWidth:"9rem"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px",gridMinWidth:"9rem"}},Ct=[];function ct(t){let e=ot(t,{defaultTheme:"light",presets:Tt,variables:xt,shadcnVariables:Ct});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function j(t,e){return nt(t.elements,e)}import{useCallback as ut,useEffect as St,useMemo as kt,useState as F}from"react";function q(t){let{projectID:e,locale:n,search:o,initialData:i}=t,[a]=F(()=>rt),d=t.host??a,c=O(t.pageSize),s=JSON.stringify([e,d,n??null,o?.trim()??null,c]),[g,l]=F({queryKey:s,page:1});g.queryKey!==s&&l({queryKey:s,page:1});let[P,C]=F(0),[m,p]=F(()=>({requestKey:i!=null?`${s}|1|0`:"",data:i,error:void 0})),f=m.data?.totalCount??0,b=at(f,c),h=g.queryKey===s?g.page:1,k=f>0?Math.min(h,b):h,S=`${s}|${k}|${P}`,T=m.requestKey===S;St(()=>{if(T)return;let y=new AbortController;return it({projectID:e,host:d,locale:n,search:o,limit:c,offset:(k-1)*c},y.signal).then(L=>{y.signal.aborted||p({requestKey:S,data:L,error:void 0})},L=>{y.signal.aborted||p(E=>({requestKey:S,data:E.data,error:L instanceof Error?L:new Error(String(L))}))}),()=>y.abort()},[S,T]);let I=ut(y=>{let L=Math.max(1,Math.floor(y));l({queryKey:s,page:f>0?Math.min(L,b):L})},[s,f,b]),A=ut(()=>C(y=>y+1),[]);return kt(()=>({products:m.data?.items??[],totalCount:f,page:k,pageCount:b,setPage:I,isLoading:!T,error:T?m.error:void 0,refetch:A}),[m,f,k,b,I,T,A])}import{createContext as gt,useCallback as K,useContext as mt,useEffect as B,useMemo as R,useRef as H,useState as It}from"react";var z=50,At=1e3;function lt(t,e=At){let n=new Set,o=new Map,i=[],a=[],d,c,s=!1;function g(){for(c!==void 0&&clearTimeout(c),c=void 0;i.length>0;){let p=i.slice(0,z),f=a.slice(0,z);i=i.slice(z),a=a.slice(z);try{t({productIds:p,positions:f})}catch{}}}function l(){g();try{X()?.flush()}catch{}}let P=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&l()};function C(){s||typeof window>"u"||(s=!0,window.addEventListener("pagehide",l,!0),document.addEventListener("visibilitychange",P,!0))}function m(){if(d)return d;if(!(typeof IntersectionObserver>"u"))return d=new IntersectionObserver(p=>{for(let f of p){let b=o.get(f.target);!b||!f.isIntersecting||f.intersectionRatio<.5||(o.delete(f.target),d?.unobserve(f.target),!n.has(b.id)&&(n.add(b.id),i.push(b.id),a.push(b.position)))}i.length>0&&c===void 0&&(c=setTimeout(g,e),c.unref?.())},{threshold:[.5]}),C(),d}return{observe(p,f,b){try{if(n.has(f))return()=>{};let h=m();return h?(o.set(p,{id:f,position:b}),h.observe(p),()=>{o.delete(p),h.unobserve(p)}):()=>{}}catch{return()=>{}}},flush:g,destroy(){try{g(),d?.disconnect(),s&&(window.removeEventListener("pagehide",l,!0),document.removeEventListener("visibilitychange",P,!0),s=!1)}catch{}d=void 0,o.clear()}}}var wt={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",model3d:"3D",model3dLabel:"3D model",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",model3d:"3D",model3dLabel:"Model 3D",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function pt(t,e){return tt(wt,t,e)}function V(t,e){return t.replace(/\{(\w+)\}/g,(n,o)=>o in e?String(e[o]):n)}import{Fragment as Lt,jsx as r,jsxs as x}from"react/jsx-runtime";var ft=gt(void 0),Et={observe:()=>()=>{},clicked:()=>{}},bt=gt(Et);function D(){let t=mt(ft);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function u(t,e){let{appearance:n}=D(),o=j(n,t);return{"data-bitsnap-products-slot":t,className:M(e,o?.className),style:o?.style}}var $="inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",Pt=`${$} w-full`,_t=`${Pt} no-underline`;function Nt({product:t,onAdd:e}){let{texts:n}=D(),[o,i]=It("idle"),a=u("addToCartButton",Pt),d=u("message","mt-2 text-xs");B(()=>{if(o!=="added")return;let g=setTimeout(()=>i("idle"),2e3);return()=>clearTimeout(g)},[o]);let c=K(async()=>{i("adding");try{await e(),i("added")}catch(g){console.error("bitsnap-react: could not add to the cart",g),i("error")}},[e]),s=o==="adding"?n.addingToCart:o==="added"?n.addedToCart:n.addToCart;return x(Lt,{children:[r("button",{type:"button",...a,disabled:o==="adding","aria-label":`${s}: ${t.name}`,onClick:c,children:s}),o==="error"?r("p",{...d,role:"alert",children:n.addToCartError}):null]})}function Ot({product:t,position:e,href:n,onAdd:o,renderItem:i}){let{texts:a,locale:d}=D(),c=mt(bt),s=H(null);B(()=>{if(s.current!=null)return c.observe(s.current,t.id,e)},[c,t.id,e]);let g=K(()=>c.clicked(t,e),[c,t,e]),l=u("card","relative flex flex-col overflow-hidden border transition-colors"),P=u("cardLink","flex flex-1 flex-col no-underline"),C=u("image","aspect-square w-full overflow-hidden"),m=u("imagePlaceholder","aspect-square w-full"),p=u("body","flex flex-1 flex-col gap-1 p-4"),f=u("name","text-base font-medium leading-snug"),b=u("description","line-clamp-2 text-sm"),h=u("price","mt-auto pt-2 text-base font-semibold"),k=u("comparePrice","ml-2 text-sm font-normal"),S=u("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=u("model3dBadge","absolute right-3 top-3 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-semibold"),I=u("actions","p-4 pt-0"),A=u("selectButton",_t),y=U(t.price,t.currency,d),L=t.compareAtPrice!=null&&t.compareAtPrice>t.price?U(t.compareAtPrice,t.currency,d):null;if(i!=null)return r("li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:i(t,{href:n,price:y,compareAtPrice:L,texts:a,locale:d,addToCart:o,trackClick:g})});let E=t.image?.thumbnailUrl??t.image?.url,_=t.available?t.isRecurring?a.subscription:null:a.unavailable;return x("li",{ref:s,...l,"data-unavailable":t.available?void 0:"",children:[x("a",{...P,href:n,onClick:g,children:[E!=null?r("div",{...C,children:r("img",{src:E,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):r("div",{...m,"aria-hidden":"true"}),x("div",{...p,children:[r("h3",{...f,children:t.name}),t.shortDescription?r("p",{...b,children:t.shortDescription}):null,x("p",{...h,children:[t.priceFrom?V(a.priceFrom,{price:y}):y,L!=null?x(Lt,{children:[x("span",{className:"sr-only",children:[a.originalPrice,": "]}),r("del",{...k,children:L})]}):null]})]})]}),_!=null?r("span",{...S,"data-kind":t.available?"subscription":"unavailable",children:_}):null,t.has3d===!0?x("span",{...T,title:a.model3dLabel,children:[r(Bt,{}),r("span",{"aria-hidden":"true",children:a.model3d}),r("span",{className:"sr-only",children:a.model3dLabel})]}):null,r("div",{...I,children:t.available?t.addToCart?r(Nt,{product:t,onAdd:o}):r("a",{...A,href:n,onClick:g,children:t.variantCount>1?a.chooseOptions:a.viewProduct}):r("button",{type:"button",...A,disabled:!0,children:a.unavailable})})]})}function Bt(){return x("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),r("path",{d:"m3.3 7 8.7 5 8.7-5"}),r("path",{d:"M12 22V12"})]})}var yt="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,var(--bitsnap-products-grid-min-width,9rem)),1fr))] gap-5 p-0";function Rt({count:t,label:e}){let n=u("grid",yt),o=u("skeleton","aspect-[3/4] animate-pulse");return r("div",{...n,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(i,a)=>r("div",{...o,"aria-hidden":"true"},a))})}function Dt({page:t,pageCount:e,isLoading:n,onPage:o}){let{texts:i}=D(),a=u("pagination","mt-8 flex items-center justify-center gap-4"),d=u("paginationButton",$),c=u("pageIndicator","text-sm");return x("nav",{...a,"aria-label":i.pagination,children:[r("button",{type:"button",...d,"aria-disabled":n||t<=1,onClick:()=>{!n&&t>1&&o(t-1)},children:i.previousPage}),r("span",{...c,"aria-live":"polite",children:V(i.pageOf,{page:t,pageCount:e})}),r("button",{type:"button",...d,"aria-disabled":n||t>=e,onClick:()=>{!n&&t<e&&o(t+1)},children:i.nextPage})]})}function Mt({options:t,productHref:e,renderItem:n,onAddToCart:o,showCartOnAdd:i}){let{texts:a}=D(),{products:d,page:c,pageCount:s,setPage:g,isLoading:l,error:P,refetch:C}=q(t),m=J(),p=t.search?.trim()?"search":"catalog",f=O(t.pageSize),b=H(!1);B(()=>{b.current||l||P!=null||(b.current=!0,m.track("product_list_viewed",{list_id:p,item_count:d.length}))},[m,l,P,p,d.length]);let h=R(()=>lt(({productIds:v,positions:w})=>m.track("product_impression",{list_id:p,product_ids:v,positions:w})),[m,p]);B(()=>()=>h.destroy(),[h]);let k=R(()=>({observe:h.observe,clicked:(v,w)=>m.track("product_clicked",{list_id:p,position:w},{product_id:v.id})}),[h,m,p]),S=H(null),T=H(!1),I=K(v=>{T.current=!0,g(v)},[g]);B(()=>{l||!T.current||(T.current=!1,S.current?.focus({preventScroll:!0}),S.current?.scrollIntoView({block:"start"}))},[l]);let A=u("grid",yt),y=u("emptyState","py-12 text-center text-sm"),L=u("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),E=u("retryButton",$),{projectID:_,host:W}=t,vt=K((v,w)=>async()=>{if(o!=null){await Q(()=>o(v)),st(m,v);return}await dt(v,{projectID:_,host:W,showCart:i,analytics:m,url:w})},[o,_,W,i,m]),N;return l&&d.length===0?N=r(Rt,{count:Math.min(O(t.pageSize),8),label:a.loading}):P!=null?N=x("div",{...L,role:"alert",children:[r("p",{children:a.error}),r("button",{type:"button",...E,onClick:C,children:a.retry})]}):d.length===0?N=r("p",{...y,children:a.empty}):N=r("ul",{...A,"aria-busy":l||void 0,className:M(A.className,l&&"opacity-60"),children:d.map((v,w)=>{let G=e(v);return r(Ot,{product:v,position:(c-1)*f+w,href:G,onAdd:vt(v,G),renderItem:n},v.id)})}),r(bt.Provider,{value:k,children:x("div",{ref:S,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[N,s>1&&P==null?r(Dt,{page:c,pageCount:s,isLoading:l,onPage:I}):null]})})}var Ut=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Ft({productHref:t=Ut,appearance:e,texts:n,renderItem:o,onAddToCart:i,showCartOnAdd:a=!0,className:d,analytics:c,...s}){let g=Y(s.projectID,c,"catalog"),l=s.locale??et,P=R(()=>ct(e),[e]),C=R(()=>pt(l,n),[l,n]),m=R(()=>({appearance:P,texts:C,locale:l}),[P,C,l]),p=j(P,"root");return r(Z,{value:g,children:r(ft.Provider,{value:m,children:r("div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:M("bitsnap-react",P.boundaryClassName,d,p?.className),style:{...P.boundaryStyle,...p?.style},children:r(Mt,{options:s,productHref:t,renderItem:o,onAddToCart:i,showCartOnAdd:a})})})})}export{ht as a,q as b,Ft as c};
2
+ //# sourceMappingURL=chunk-ZHTMK5TA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/products/appearance.ts","../src/components/products/useProducts.ts","../src/components/products/ProductList.tsx","../src/components/products/impressions.ts","../src/components/products/texts.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport {\n getSlotAppearance,\n resolveAppearanceCore,\n type AppearanceElements,\n type ShadcnVariableMapping,\n type SlotAppearance,\n} from \"@/src/lib/appearance-core\";\n\n/**\n * Product list appearance API.\n *\n * It mirrors `CheckoutAppearance` and `ReturnsAppearance` (theme, tokens,\n * elements) so a shop can reuse one brand object for all of them. The resolver\n * is pure: it turns the caller input into a theme name, the tokens in effect,\n * the slot overrides and the inline style for the theme boundary.\n */\n\nexport type ProductListTheme = \"light\" | \"dark\";\n\nexport type ProductListAppearanceTokens = {\n /** Font family of the list. The library never loads fonts. */\n fontFamily?: string;\n /** Minimum grid track width. Use \"100%\" for one column. */\n gridMinWidth?: string;\n /** Base font size. */\n fontSize?: string;\n /** List background. */\n background?: string;\n /** Raised surfaces: cards, image placeholders, skeletons. */\n surface?: string;\n /** Main text color. */\n foreground?: string;\n /** Secondary text: descriptions, the struck-through price. */\n mutedForeground?: string;\n /** Borders of cards and buttons. */\n border?: string;\n /** \"Add to cart\" button background. */\n buttonBackground?: string;\n /** \"Add to cart\" button text. */\n buttonForeground?: string;\n /** \"Add to cart\" button background on hover. */\n buttonHoverBackground?: string;\n /** Hover surface of cards and secondary buttons. */\n hoverSurface?: string;\n /** Focus ring color. */\n focusRing?: string;\n /** Error and unavailable state color. */\n error?: string;\n /** Badge background (subscription, unavailable). */\n badgeBackground?: string;\n /** Badge text. */\n badgeForeground?: string;\n /** Corner radius of cards, images and buttons. */\n radius?: string;\n};\n\n/**\n * Stable slot names. They are exposed as `data-bitsnap-products-slot`\n * attributes so they can also be targeted from plain CSS.\n */\nexport const PRODUCT_LIST_SLOT_NAMES = [\n \"root\",\n \"grid\",\n \"card\",\n \"cardLink\",\n \"image\",\n \"imagePlaceholder\",\n \"body\",\n \"name\",\n \"description\",\n \"price\",\n \"comparePrice\",\n \"badge\",\n \"model3dBadge\",\n \"actions\",\n \"addToCartButton\",\n \"selectButton\",\n \"message\",\n \"pagination\",\n \"paginationButton\",\n \"pageIndicator\",\n \"emptyState\",\n \"error\",\n \"retryButton\",\n \"skeleton\",\n] as const;\n\nexport type ProductListSlotName = (typeof PRODUCT_LIST_SLOT_NAMES)[number];\n\nexport type ProductListSlotAppearance = SlotAppearance;\n\nexport type ProductListAppearanceElements =\n AppearanceElements<ProductListSlotName>;\n\nexport type ProductListAppearance = {\n /** `\"light\"` or `\"dark\"`. Omitted means `\"light\"`. */\n theme?: ProductListTheme;\n /** Partial overrides applied over the theme preset. */\n tokens?: ProductListAppearanceTokens;\n /** Per element `className`/`style` overrides. */\n elements?: ProductListAppearanceElements;\n};\n\nexport type ResolvedProductListAppearance = {\n theme: ProductListTheme;\n /** Tokens that are in effect (the theme preset plus caller overrides). */\n tokens: ProductListAppearanceTokens;\n elements: ProductListAppearanceElements;\n /** Theme marker class for the theme boundary. */\n boundaryClassName: string;\n /** Inline custom properties applied to the list root. */\n boundaryStyle: CSSProperties;\n};\n\n/** CSS custom property used for each token. */\nexport const PRODUCT_LIST_TOKEN_VARIABLES = {\n fontFamily: \"--bitsnap-products-font-family\",\n gridMinWidth: \"--bitsnap-products-grid-min-width\",\n fontSize: \"--bitsnap-products-font-size\",\n background: \"--bitsnap-products-background\",\n surface: \"--bitsnap-products-surface\",\n foreground: \"--bitsnap-products-foreground\",\n mutedForeground: \"--bitsnap-products-muted-foreground\",\n border: \"--bitsnap-products-border\",\n buttonBackground: \"--bitsnap-products-button-background\",\n buttonForeground: \"--bitsnap-products-button-foreground\",\n buttonHoverBackground: \"--bitsnap-products-button-hover-background\",\n hoverSurface: \"--bitsnap-products-hover-surface\",\n focusRing: \"--bitsnap-products-focus-ring\",\n error: \"--bitsnap-products-error\",\n badgeBackground: \"--bitsnap-products-badge-background\",\n badgeForeground: \"--bitsnap-products-badge-foreground\",\n radius: \"--bitsnap-products-radius\",\n} as const;\n\nexport type ProductListTokenName = keyof typeof PRODUCT_LIST_TOKEN_VARIABLES;\n\n/**\n * Complete palettes. They carry colors and radius only, so typography is never\n * reset implicitly. `products.css` falls back to the light values, which keeps\n * the list usable even when the boundary style is missing.\n */\nexport const PRODUCT_LIST_THEME_PRESETS: Record<\n ProductListTheme,\n ProductListAppearanceTokens\n> = {\n light: {\n background: \"#ffffff\",\n surface: \"#f9fafb\",\n foreground: \"#18181b\",\n mutedForeground: \"#71717a\",\n border: \"#e4e4e7\",\n buttonBackground: \"#18181b\",\n buttonForeground: \"#fafafa\",\n buttonHoverBackground: \"#000000\",\n hoverSurface: \"#f4f4f5\",\n focusRing: \"#71717a\",\n error: \"#dc2626\",\n badgeBackground: \"#f4f4f5\",\n badgeForeground: \"#3f3f46\",\n radius: \"8px\",\n gridMinWidth: \"9rem\",\n },\n dark: {\n background: \"#18181b\",\n surface: \"#27272a\",\n foreground: \"#fafafa\",\n mutedForeground: \"#a1a1aa\",\n border: \"#3f3f46\",\n buttonBackground: \"#fafafa\",\n buttonForeground: \"#18181b\",\n buttonHoverBackground: \"#e4e4e7\",\n hoverSurface: \"#3f3f46\",\n focusRing: \"#a1a1aa\",\n error: \"#f87171\",\n badgeBackground: \"#3f3f46\",\n badgeForeground: \"#e4e4e7\",\n radius: \"8px\",\n gridMinWidth: \"9rem\",\n },\n};\n\n/** The list renders its own elements, so no shared primitive needs remapping. */\nconst PRODUCT_LIST_SHADCN_VARIABLES: ShadcnVariableMapping<ProductListTokenName> =\n [];\n\nexport function resolveProductListAppearance(\n appearance?: ProductListAppearance,\n): ResolvedProductListAppearance {\n const resolved = resolveAppearanceCore<\n ProductListTokenName,\n ProductListTheme,\n ProductListSlotName\n >(appearance, {\n defaultTheme: \"light\",\n presets: PRODUCT_LIST_THEME_PRESETS,\n variables: PRODUCT_LIST_TOKEN_VARIABLES,\n shadcnVariables: PRODUCT_LIST_SHADCN_VARIABLES,\n });\n\n return {\n theme: resolved.theme,\n tokens: resolved.tokens,\n elements: resolved.elements,\n boundaryClassName: resolved.theme,\n boundaryStyle: resolved.boundaryStyle,\n };\n}\n\n/** Caller overrides for a single slot, if any were provided. */\nexport function getProductListSlotAppearance(\n resolved: ResolvedProductListAppearance,\n slot: ProductListSlotName,\n): ProductListSlotAppearance | undefined {\n return getSlotAppearance(resolved.elements, slot);\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { HOST } from \"../checkout/constants\";\nimport {\n clampPageSize,\n fetchProductList,\n pageCountFor,\n type ProductListData,\n type PublicListProduct,\n} from \"./fetch\";\n\nexport type UseProductsOptions = {\n /** Project (shop) ID. */\n projectID: string;\n /**\n * Origin of the Bitsnap backend. Defaults to the library host\n * (`https://bitsnap.pl`, or what `setCustomHost` had set when the component\n * first rendered; later `setCustomHost` calls do not move an existing list).\n * On a custom domain pass the domain itself, or an empty string for\n * same-origin requests.\n */\n host?: string;\n locale?: string;\n /** Products per page, 1 to 48. Defaults to 24. */\n pageSize?: number;\n search?: string;\n /**\n * First page, loaded on the server. It is always used for the first request\n * of the mounted list (the first fetch is skipped and the products are\n * available on the first render), so it has to be the page the props ask\n * for: page 1 with the same `pageSize`, `locale` and `search`. Later changes\n * of the props fetch again.\n */\n initialData?: ProductListData;\n};\n\nexport type UseProductsResult = {\n /** Products of the current page. Keeps the previous page while loading. */\n products: PublicListProduct[];\n totalCount: number;\n /** Current page, starting at 1. */\n page: number;\n pageCount: number;\n setPage: (page: number) => void;\n /** `true` until the current page is available, also during server rendering. */\n isLoading: boolean;\n error: Error | undefined;\n /** Loads the current page again. */\n refetch: () => void;\n};\n\ntype Snapshot = {\n /** Request the data belongs to; empty when it is not tied to one. */\n requestKey: string;\n data: ProductListData | undefined;\n error: Error | undefined;\n};\n\n/**\n * Loads the product catalog page by page. It uses a plain `fetch` without\n * credentials, never reads global state (`setProjectID`, `setCustomHost`) other\n * than the default host, and does nothing during server rendering - pass\n * `initialData` to render products in the server HTML.\n */\nexport function useProducts(options: UseProductsOptions): UseProductsResult {\n const { projectID, locale, search, initialData } = options;\n // The library host is a mutable global; read it once so a later\n // `setCustomHost` does not change the query of a mounted list.\n const [defaultHost] = useState(() => HOST);\n const host = options.host ?? defaultHost;\n const pageSize = clampPageSize(options.pageSize);\n\n // Everything that identifies a list; a change resets the page.\n const queryKey = JSON.stringify([\n projectID,\n host,\n locale ?? null,\n search?.trim() ?? null,\n pageSize,\n ]);\n\n const [pageState, setPageState] = useState({ queryKey, page: 1 });\n if (pageState.queryKey !== queryKey) {\n // Another list: start from page 1 (adjusting state while rendering).\n setPageState({ queryKey, page: 1 });\n }\n const [reloads, setReloads] = useState(0);\n const [snapshot, setSnapshot] = useState<Snapshot>(() => ({\n requestKey: initialData != null ? `${queryKey}|1|0` : \"\",\n data: initialData,\n error: undefined,\n }));\n\n // A page past the end (the catalog shrank) falls back to the last page once\n // the total is known.\n const totalCount = snapshot.data?.totalCount ?? 0;\n const pageCount = pageCountFor(totalCount, pageSize);\n const requestedPage = pageState.queryKey === queryKey ? pageState.page : 1;\n const page = totalCount > 0 ? Math.min(requestedPage, pageCount) : requestedPage;\n\n const requestKey = `${queryKey}|${page}|${reloads}`;\n\n const isCurrent = snapshot.requestKey === requestKey;\n\n useEffect(() => {\n if (isCurrent) {\n return;\n }\n\n const controller = new AbortController();\n fetchProductList(\n {\n projectID,\n host,\n locale,\n search,\n limit: pageSize,\n offset: (page - 1) * pageSize,\n },\n controller.signal,\n ).then(\n (data) => {\n if (controller.signal.aborted) {\n return;\n }\n setSnapshot({ requestKey, data, error: undefined });\n },\n (error: unknown) => {\n if (controller.signal.aborted) {\n return;\n }\n setSnapshot((previous) => ({\n requestKey,\n data: previous.data,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n },\n );\n\n return () => controller.abort();\n // `requestKey` carries projectID, host, locale, search, pageSize, page and\n // the reload counter.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [requestKey, isCurrent]);\n\n const setPage = useCallback(\n (next: number) => {\n const target = Math.max(1, Math.floor(next));\n setPageState({\n queryKey,\n page: totalCount > 0 ? Math.min(target, pageCount) : target,\n });\n },\n [queryKey, totalCount, pageCount],\n );\n\n const refetch = useCallback(() => setReloads((value) => value + 1), []);\n\n return useMemo(\n () => ({\n products: snapshot.data?.items ?? [],\n totalCount,\n page,\n pageCount,\n setPage,\n isLoading: !isCurrent,\n error: isCurrent ? snapshot.error : undefined,\n refetch,\n }),\n [snapshot, totalCount, page, pageCount, setPage, isCurrent, refetch],\n );\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport {\n InstrumentProvider,\n useInstrument,\n useInstrumentContext,\n withCartAnalyticsMuted,\n type AnalyticsOption,\n type Instrument,\n} from \"@/src/analytics/instrument\";\nimport { DEFAULT_LOCALE } from \"../checkout/locale\";\nimport { addProductToCart, trackProductAdded } from \"./add-to-cart\";\nimport {\n getProductListSlotAppearance,\n resolveProductListAppearance,\n type ProductListAppearance,\n type ProductListSlotName,\n type ResolvedProductListAppearance,\n} from \"./appearance\";\nimport { clampPageSize, type PublicListProduct } from \"./fetch\";\nimport { formatProductPrice } from \"./format\";\nimport { createImpressionTracker } from \"./impressions\";\nimport {\n fillProductListText,\n resolveProductListTexts,\n type ProductListTexts,\n} from \"./texts\";\nimport { useProducts, type UseProductsOptions } from \"./useProducts\";\n\n/** What `renderItem` gets next to the product. */\nexport type ProductListItemContext = {\n /** Product page URL from `productHref`. */\n href: string;\n /** Price formatted for the locale and currency, without the \"from\" prefix. */\n price: string;\n /** Formatted regular price when the product is discounted. */\n compareAtPrice: string | null;\n texts: ProductListTexts;\n locale: string;\n /** Adds the product to the cart the way the built-in button does. */\n addToCart: () => Promise<void>;\n /**\n * Reports a click on the product (`product_clicked`). Call it from the link\n * a custom card renders; the built-in card does it itself.\n */\n trackClick: () => void;\n};\n\nexport type ProductListProps = UseProductsOptions & {\n /**\n * Product page URL. Defaults to the relative `/p/{uniqueSlug}`, which works\n * on a Bitsnap custom domain. Embedded on another site, return the full\n * URL of the product page.\n */\n productHref?: (product: PublicListProduct) => string;\n appearance?: ProductListAppearance;\n /** Text overrides, applied whatever the locale. */\n texts?: Partial<ProductListTexts>;\n /** Replaces the content of a card. The card frame stays. */\n renderItem?: (\n product: PublicListProduct,\n context: ProductListItemContext,\n ) => ReactNode;\n /**\n * Called by the \"Add to cart\" button instead of the default action\n * (`Bitsnap.addProductToCart`). A rejected promise shows the error message.\n */\n onAddToCart?: (product: PublicListProduct) => void | Promise<void>;\n /** Open the cart drawer after the default add to cart. Defaults to `true`. */\n showCartOnAdd?: boolean;\n className?: string;\n /**\n * Usage statistics for your Bitsnap dashboard (list views, impressions,\n * clicks, add to cart). On by default; `false` turns it off. An object\n * lets you forward every event: `{ onEvent }`. Nothing is stored on the\n * visitor's device.\n */\n analytics?: AnalyticsOption;\n};\n\ntype ListContext = {\n appearance: ResolvedProductListAppearance;\n texts: ProductListTexts;\n locale: string;\n};\n\nconst ProductListContext = createContext<ListContext | undefined>(undefined);\n\ntype CardAnalytics = {\n observe: (element: Element, id: string, position: number) => () => void;\n clicked: (product: PublicListProduct, position: number) => void;\n};\n\nconst noCardAnalytics: CardAnalytics = {\n observe: () => () => {},\n clicked: () => {},\n};\n\nconst CardAnalyticsContext = createContext<CardAnalytics>(noCardAnalytics);\n\nfunction useListContext(): ListContext {\n const value = useContext(ProductListContext);\n if (value == null) {\n throw new Error(\"ProductList parts must be rendered inside ProductList\");\n }\n return value;\n}\n\n/** Stable slot attribute, built-in classes and the caller overrides for a slot. */\nfunction useSlot(slot: ProductListSlotName, className?: string) {\n const { appearance } = useListContext();\n const override = getProductListSlotAppearance(appearance, slot);\n\n return {\n \"data-bitsnap-products-slot\": slot,\n className: cn(className, override?.className),\n style: override?.style,\n };\n}\n\nconst BUTTON_CLASS =\n \"inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50\";\nconst BLOCK_BUTTON_CLASS = `${BUTTON_CLASS} w-full`;\nconst LINK_BUTTON_CLASS = `${BLOCK_BUTTON_CLASS} no-underline`;\n\ntype AddStatus = \"idle\" | \"adding\" | \"added\" | \"error\";\n\nfunction AddToCartButton({\n product,\n onAdd,\n}: {\n product: PublicListProduct;\n onAdd: () => Promise<void>;\n}) {\n const { texts } = useListContext();\n const [status, setStatus] = useState<AddStatus>(\"idle\");\n const button = useSlot(\"addToCartButton\", BLOCK_BUTTON_CLASS);\n const message = useSlot(\"message\", \"mt-2 text-xs\");\n\n useEffect(() => {\n if (status !== \"added\") {\n return;\n }\n const timer = setTimeout(() => setStatus(\"idle\"), 2000);\n return () => clearTimeout(timer);\n }, [status]);\n\n const click = useCallback(async () => {\n setStatus(\"adding\");\n try {\n await onAdd();\n setStatus(\"added\");\n } catch (error) {\n console.error(\"bitsnap-react: could not add to the cart\", error);\n setStatus(\"error\");\n }\n }, [onAdd]);\n\n const label =\n status === \"adding\"\n ? texts.addingToCart\n : status === \"added\"\n ? texts.addedToCart\n : texts.addToCart;\n\n return (\n <>\n <button\n type=\"button\"\n {...button}\n disabled={status === \"adding\"}\n aria-label={`${label}: ${product.name}`}\n onClick={click}\n >\n {label}\n </button>\n {status === \"error\" ? (\n <p {...message} role=\"alert\">\n {texts.addToCartError}\n </p>\n ) : null}\n </>\n );\n}\n\nfunction ProductCard({\n product,\n position,\n href,\n onAdd,\n renderItem,\n}: {\n product: PublicListProduct;\n /** Index in the whole catalog (not in the current page). */\n position: number;\n href: string;\n onAdd: () => Promise<void>;\n renderItem?: ProductListProps[\"renderItem\"];\n}) {\n const { texts, locale } = useListContext();\n const analytics = useContext(CardAnalyticsContext);\n const element = useRef<HTMLLIElement>(null);\n useEffect(() => {\n if (element.current == null) {\n return;\n }\n return analytics.observe(element.current, product.id, position);\n }, [analytics, product.id, position]);\n const trackClick = useCallback(\n () => analytics.clicked(product, position),\n [analytics, product, position],\n );\n const card = useSlot(\n \"card\",\n \"relative flex flex-col overflow-hidden border transition-colors\",\n );\n const cardLink = useSlot(\"cardLink\", \"flex flex-1 flex-col no-underline\");\n const imageFrame = useSlot(\"image\", \"aspect-square w-full overflow-hidden\");\n const placeholder = useSlot(\"imagePlaceholder\", \"aspect-square w-full\");\n const body = useSlot(\"body\", \"flex flex-1 flex-col gap-1 p-4\");\n const name = useSlot(\"name\", \"text-base font-medium leading-snug\");\n const description = useSlot(\"description\", \"line-clamp-2 text-sm\");\n const price = useSlot(\"price\", \"mt-auto pt-2 text-base font-semibold\");\n const comparePrice = useSlot(\"comparePrice\", \"ml-2 text-sm font-normal\");\n const badge = useSlot(\n \"badge\",\n \"absolute left-3 top-3 px-2 py-0.5 text-xs font-medium\",\n );\n const model3dBadge = useSlot(\n \"model3dBadge\",\n \"absolute right-3 top-3 inline-flex items-center gap-1 px-2 py-0.5 text-xs font-semibold\",\n );\n const actions = useSlot(\"actions\", \"p-4 pt-0\");\n const selectButton = useSlot(\"selectButton\", LINK_BUTTON_CLASS);\n\n const formattedPrice = formatProductPrice(\n product.price,\n product.currency,\n locale,\n );\n const formattedCompare =\n product.compareAtPrice != null && product.compareAtPrice > product.price\n ? formatProductPrice(product.compareAtPrice, product.currency, locale)\n : null;\n\n if (renderItem != null) {\n return (\n <li\n ref={element}\n {...card}\n data-unavailable={product.available ? undefined : \"\"}\n >\n {renderItem(product, {\n href,\n price: formattedPrice,\n compareAtPrice: formattedCompare,\n texts,\n locale,\n addToCart: onAdd,\n trackClick,\n })}\n </li>\n );\n }\n\n const imageSource = product.image?.thumbnailUrl ?? product.image?.url;\n const badgeText = !product.available\n ? texts.unavailable\n : product.isRecurring\n ? texts.subscription\n : null;\n\n return (\n <li ref={element} {...card} data-unavailable={product.available ? undefined : \"\"}>\n <a {...cardLink} href={href} onClick={trackClick}>\n {imageSource != null ? (\n <div {...imageFrame}>\n <img\n src={imageSource}\n alt=\"\"\n loading=\"lazy\"\n decoding=\"async\"\n className=\"h-full w-full object-cover\"\n />\n </div>\n ) : (\n <div {...placeholder} aria-hidden=\"true\" />\n )}\n <div {...body}>\n <h3 {...name}>{product.name}</h3>\n {product.shortDescription ? (\n <p {...description}>{product.shortDescription}</p>\n ) : null}\n <p {...price}>\n {product.priceFrom\n ? fillProductListText(texts.priceFrom, { price: formattedPrice })\n : formattedPrice}\n {formattedCompare != null ? (\n <>\n <span className=\"sr-only\">{texts.originalPrice}: </span>\n <del {...comparePrice}>{formattedCompare}</del>\n </>\n ) : null}\n </p>\n </div>\n </a>\n {badgeText != null ? (\n <span\n {...badge}\n data-kind={product.available ? \"subscription\" : \"unavailable\"}\n >\n {badgeText}\n </span>\n ) : null}\n {product.has3d === true ? (\n <span {...model3dBadge} title={texts.model3dLabel}>\n <CubeIcon />\n <span aria-hidden=\"true\">{texts.model3d}</span>\n <span className=\"sr-only\">{texts.model3dLabel}</span>\n </span>\n ) : null}\n <div {...actions}>\n {!product.available ? (\n <button type=\"button\" {...selectButton} disabled>\n {texts.unavailable}\n </button>\n ) : product.addToCart ? (\n <AddToCartButton product={product} onAdd={onAdd} />\n ) : (\n <a {...selectButton} href={href} onClick={trackClick}>\n {product.variantCount > 1 ? texts.chooseOptions : texts.viewProduct}\n </a>\n )}\n </div>\n </li>\n );\n}\n\nfunction CubeIcon() {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n width=\"12\"\n height=\"12\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z\" />\n <path d=\"m3.3 7 8.7 5 8.7-5\" />\n <path d=\"M12 22V12\" />\n </svg>\n );\n}\n\nconst GRID_CLASS =\n \"m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,var(--bitsnap-products-grid-min-width,9rem)),1fr))] gap-5 p-0\";\n\nfunction SkeletonGrid({ count, label }: { count: number; label: string }) {\n const grid = useSlot(\"grid\", GRID_CLASS);\n const skeleton = useSlot(\"skeleton\", \"aspect-[3/4] animate-pulse\");\n\n return (\n <div {...grid} role=\"status\" aria-busy=\"true\" aria-label={label}>\n {Array.from({ length: count }, (_, index) => (\n <div key={index} {...skeleton} aria-hidden=\"true\" />\n ))}\n </div>\n );\n}\n\nfunction Pagination({\n page,\n pageCount,\n isLoading,\n onPage,\n}: {\n page: number;\n pageCount: number;\n isLoading: boolean;\n onPage: (page: number) => void;\n}) {\n const { texts } = useListContext();\n const nav = useSlot(\n \"pagination\",\n \"mt-8 flex items-center justify-center gap-4\",\n );\n const button = useSlot(\"paginationButton\", BUTTON_CLASS);\n const indicator = useSlot(\"pageIndicator\", \"text-sm\");\n\n return (\n <nav {...nav} aria-label={texts.pagination}>\n <button\n type=\"button\"\n {...button}\n aria-disabled={isLoading || page <= 1}\n onClick={() => {\n if (!isLoading && page > 1) {\n onPage(page - 1);\n }\n }}\n >\n {texts.previousPage}\n </button>\n <span {...indicator} aria-live=\"polite\">\n {fillProductListText(texts.pageOf, { page, pageCount })}\n </span>\n <button\n type=\"button\"\n {...button}\n aria-disabled={isLoading || page >= pageCount}\n onClick={() => {\n if (!isLoading && page < pageCount) {\n onPage(page + 1);\n }\n }}\n >\n {texts.nextPage}\n </button>\n </nav>\n );\n}\n\nfunction ProductListContent({\n options,\n productHref,\n renderItem,\n onAddToCart,\n showCartOnAdd,\n}: {\n options: UseProductsOptions;\n productHref: (product: PublicListProduct) => string;\n renderItem?: ProductListProps[\"renderItem\"];\n onAddToCart?: ProductListProps[\"onAddToCart\"];\n showCartOnAdd: boolean;\n}) {\n const { texts } = useListContext();\n const { products, page, pageCount, setPage, isLoading, error, refetch } =\n useProducts(options);\n const instrument = useInstrumentContext();\n // The search text is never reported, only that the list was searched.\n const listId = options.search?.trim() ? \"search\" : \"catalog\";\n const pageSize = clampPageSize(options.pageSize);\n\n const viewed = useRef(false);\n useEffect(() => {\n if (viewed.current || isLoading || error != null) {\n return;\n }\n viewed.current = true;\n instrument.track(\"product_list_viewed\", {\n list_id: listId,\n item_count: products.length,\n });\n }, [instrument, isLoading, error, listId, products.length]);\n\n const impressions = useMemo(\n () =>\n createImpressionTracker(({ productIds, positions }) =>\n instrument.track(\"product_impression\", {\n list_id: listId,\n product_ids: productIds,\n positions,\n }),\n ),\n [instrument, listId],\n );\n useEffect(() => () => impressions.destroy(), [impressions]);\n const cardAnalytics = useMemo<CardAnalytics>(\n () => ({\n observe: impressions.observe,\n clicked: (product, position) =>\n instrument.track(\n \"product_clicked\",\n { list_id: listId, position },\n { product_id: product.id },\n ),\n }),\n [impressions, instrument, listId],\n );\n\n // After a page change by the user, move focus to the products (the button\n // that was pressed stays where it is, but the content above it changes) and\n // bring them into view once the page has loaded.\n const content = useRef<HTMLDivElement>(null);\n const movedPage = useRef(false);\n const changePage = useCallback(\n (next: number) => {\n movedPage.current = true;\n setPage(next);\n },\n [setPage],\n );\n useEffect(() => {\n if (isLoading || !movedPage.current) {\n return;\n }\n movedPage.current = false;\n content.current?.focus({ preventScroll: true });\n content.current?.scrollIntoView({ block: \"start\" });\n }, [isLoading]);\n\n const grid = useSlot(\"grid\", GRID_CLASS);\n const empty = useSlot(\"emptyState\", \"py-12 text-center text-sm\");\n const errorSlot = useSlot(\"error\", \"flex flex-col items-center gap-3 py-12 text-center text-sm\");\n const retry = useSlot(\"retryButton\", BUTTON_CLASS);\n\n const { projectID, host } = options;\n const addFor = useCallback(\n (product: PublicListProduct, href: string) => async () => {\n if (onAddToCart != null) {\n // The list reports the add itself; a cart helper called inside must not report it again.\n await withCartAnalyticsMuted(() => onAddToCart(product));\n trackProductAdded(instrument, product);\n return;\n }\n await addProductToCart(product, {\n projectID,\n host,\n showCart: showCartOnAdd,\n analytics: instrument,\n url: href,\n });\n },\n [onAddToCart, projectID, host, showCartOnAdd, instrument],\n );\n\n let body: ReactNode;\n if (isLoading && products.length === 0) {\n body = (\n <SkeletonGrid\n count={Math.min(clampPageSize(options.pageSize), 8)}\n label={texts.loading}\n />\n );\n } else if (error != null) {\n body = (\n <div {...errorSlot} role=\"alert\">\n <p>{texts.error}</p>\n <button type=\"button\" {...retry} onClick={refetch}>\n {texts.retry}\n </button>\n </div>\n );\n } else if (products.length === 0) {\n body = <p {...empty}>{texts.empty}</p>;\n } else {\n body = (\n <ul\n {...grid}\n aria-busy={isLoading || undefined}\n className={cn(grid.className, isLoading && \"opacity-60\")}\n >\n {products.map((product, index) => {\n const href = productHref(product);\n return (\n <ProductCard\n key={product.id}\n product={product}\n position={(page - 1) * pageSize + index}\n href={href}\n onAdd={addFor(product, href)}\n renderItem={renderItem}\n />\n );\n })}\n </ul>\n );\n }\n\n return (\n <CardAnalyticsContext.Provider value={cardAnalytics}>\n <div\n ref={content}\n tabIndex={-1}\n className=\"p-1 outline-none scroll-mt-4\"\n >\n {body}\n {pageCount > 1 && error == null ? (\n <Pagination\n page={page}\n pageCount={pageCount}\n isLoading={isLoading}\n onPage={changePage}\n />\n ) : null}\n </div>\n </CardAnalyticsContext.Provider>\n );\n}\n\nconst defaultProductHref = (product: PublicListProduct) =>\n `/p/${encodeURIComponent(product.uniqueSlug)}`;\n\n/**\n * Responsive grid of the shop's products with pagination, loading, empty and\n * error states. Cards link to the product page and can add to the cart.\n *\n * ```tsx\n * <ProductList projectID=\"…\" locale=\"pl-PL\" initialData={firstPage} />\n * ```\n *\n * It renders on the server: pass `initialData` (the first page, fetched on the\n * server) to have the products in the HTML; without it the server renders the\n * loading skeleton and the browser fetches the first page.\n */\nexport function ProductList({\n productHref = defaultProductHref,\n appearance,\n texts,\n renderItem,\n onAddToCart,\n showCartOnAdd = true,\n className,\n analytics,\n ...options\n}: ProductListProps) {\n const instrument: Instrument = useInstrument(\n options.projectID,\n analytics,\n \"catalog\",\n );\n const locale = options.locale ?? DEFAULT_LOCALE;\n const resolvedAppearance = useMemo(\n () => resolveProductListAppearance(appearance),\n [appearance],\n );\n const resolvedTexts = useMemo(\n () => resolveProductListTexts(locale, texts),\n [locale, texts],\n );\n const context = useMemo(\n () => ({ appearance: resolvedAppearance, texts: resolvedTexts, locale }),\n [resolvedAppearance, resolvedTexts, locale],\n );\n const root = getProductListSlotAppearance(resolvedAppearance, \"root\");\n\n return (\n <InstrumentProvider value={instrument}>\n <ProductListContext.Provider value={context}>\n <div\n data-bitsnap-products=\"root\"\n data-bitsnap-products-slot=\"root\"\n className={cn(\n \"bitsnap-react\",\n resolvedAppearance.boundaryClassName,\n className,\n root?.className,\n )}\n style={\n { ...resolvedAppearance.boundaryStyle, ...root?.style } as CSSProperties\n }\n >\n <ProductListContent\n options={options}\n productHref={productHref}\n renderItem={renderItem}\n onAddToCart={onAddToCart}\n showCartOnAdd={showCartOnAdd}\n />\n </div>\n </ProductListContext.Provider>\n </InstrumentProvider>\n );\n}\n","import { getTracker } from \"@/src/analytics/core\";\n\n/** Matches the contract's `positions` / `product_ids` array limit. */\nconst MAX_PER_EVENT = 50;\nconst FLUSH_DELAY_MS = 1000;\n\nexport type ImpressionBatch = { productIds: string[]; positions: number[] };\n\n/**\n * Collects the products that were at least half visible, each one once, and\n * hands them over in batches. Without `IntersectionObserver` nothing is\n * reported. Never throws.\n */\nexport function createImpressionTracker(\n onBatch: (batch: ImpressionBatch) => void,\n delayMs = FLUSH_DELAY_MS,\n) {\n const seen = new Set<string>();\n const targets = new Map<Element, { id: string; position: number }>();\n let pendingIds: string[] = [];\n let pendingPositions: number[] = [];\n let observer: IntersectionObserver | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let listening = false;\n\n function flush() {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n while (pendingIds.length > 0) {\n const productIds = pendingIds.slice(0, MAX_PER_EVENT);\n const positions = pendingPositions.slice(0, MAX_PER_EVENT);\n pendingIds = pendingIds.slice(MAX_PER_EVENT);\n pendingPositions = pendingPositions.slice(MAX_PER_EVENT);\n try {\n onBatch({ productIds, positions });\n } catch {}\n }\n }\n\n // The tracker flushes its own queue on `pagehide`; ours must be in it by then.\n function flushAll() {\n flush();\n try {\n getTracker()?.flush();\n } catch {}\n }\n const onVisibility = () => {\n if (typeof document !== \"undefined\" && document.visibilityState === \"hidden\") flushAll();\n };\n\n function listen() {\n if (listening || typeof window === \"undefined\") return;\n listening = true;\n window.addEventListener(\"pagehide\", flushAll, true);\n document.addEventListener(\"visibilitychange\", onVisibility, true);\n }\n\n function getObserver(): IntersectionObserver | undefined {\n if (observer) return observer;\n if (typeof IntersectionObserver === \"undefined\") return undefined;\n observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n const target = targets.get(entry.target);\n if (!target || !entry.isIntersecting || entry.intersectionRatio < 0.5) continue;\n targets.delete(entry.target);\n observer?.unobserve(entry.target);\n if (seen.has(target.id)) continue;\n seen.add(target.id);\n pendingIds.push(target.id);\n pendingPositions.push(target.position);\n }\n if (pendingIds.length > 0 && timer === undefined) {\n timer = setTimeout(flush, delayMs);\n (timer as { unref?: () => void }).unref?.();\n }\n },\n { threshold: [0.5] },\n );\n listen();\n return observer;\n }\n\n return {\n /** Starts watching a card. Returns a function that stops. */\n observe(element: Element, id: string, position: number): () => void {\n try {\n if (seen.has(id)) return () => {};\n const watcher = getObserver();\n if (!watcher) return () => {};\n targets.set(element, { id, position });\n watcher.observe(element);\n return () => {\n targets.delete(element);\n watcher.unobserve(element);\n };\n } catch {\n return () => {};\n }\n },\n flush,\n destroy() {\n try {\n flush();\n observer?.disconnect();\n if (listening) {\n window.removeEventListener(\"pagehide\", flushAll, true);\n document.removeEventListener(\"visibilitychange\", onVisibility, true);\n listening = false;\n }\n } catch {}\n observer = undefined;\n targets.clear();\n },\n };\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string `ProductList` renders. Pass a partial object through the\n * `texts` prop to override any of them, whatever the locale. Placeholders\n * (`{price}`, `{page}`, `{pageCount}`) are filled by the component.\n */\nexport type ProductListTexts = {\n /** \"Add to cart\" button of products that can be bought straight from the list. */\n addToCart: string;\n /** Button label while the product is being added. */\n addingToCart: string;\n /** Button label after the product was added. */\n addedToCart: string;\n /** Message shown when adding to the cart failed. */\n addToCartError: string;\n /** Link of products with variants, to pick one on the product page. */\n chooseOptions: string;\n /** Link of products that cannot be added from the list (subscriptions). */\n viewProduct: string;\n /** Label of products that are out of stock. */\n unavailable: string;\n /** Badge of subscription products. */\n subscription: string;\n /** Badge of products with a 3D model. */\n model3d: string;\n /** Screen reader label of the 3D badge. */\n model3dLabel: string;\n /** Price of products whose variants differ in price. `{price}` is the lowest one. */\n priceFrom: string;\n /** Screen reader label of the struck-through regular price. */\n originalPrice: string;\n /** Accessible label of the loading skeleton. */\n loading: string;\n /** Shown when the shop has no products (or none matches the search). */\n empty: string;\n /** Shown when the products could not be loaded. */\n error: string;\n /** Retry button of the error state. */\n retry: string;\n /** Accessible label of the pagination. */\n pagination: string;\n previousPage: string;\n nextPage: string;\n /** Page indicator. `{page}` and `{pageCount}` are filled in. */\n pageOf: string;\n};\n\nexport type ProductListTextKey = keyof ProductListTexts;\n\nexport const PRODUCT_LIST_TEXT_TABLES: LocaleTables<ProductListTextKey> = {\n en: {\n addToCart: \"Add to cart\",\n addingToCart: \"Adding…\",\n addedToCart: \"Added to cart\",\n addToCartError: \"Could not add to the cart. Try again.\",\n chooseOptions: \"Choose\",\n viewProduct: \"View\",\n unavailable: \"Unavailable\",\n subscription: \"Subscription\",\n model3d: \"3D\",\n model3dLabel: \"3D model\",\n priceFrom: \"from {price}\",\n originalPrice: \"Original price\",\n loading: \"Loading products\",\n empty: \"There are no products to show.\",\n error: \"Could not load the products.\",\n retry: \"Try again\",\n pagination: \"Pagination\",\n previousPage: \"Previous\",\n nextPage: \"Next\",\n pageOf: \"Page {page} of {pageCount}\",\n },\n pl: {\n addToCart: \"Dodaj do koszyka\",\n addingToCart: \"Dodawanie…\",\n addedToCart: \"Dodano do koszyka\",\n addToCartError: \"Nie udało się dodać do koszyka. Spróbuj ponownie.\",\n chooseOptions: \"Wybierz\",\n viewProduct: \"Zobacz\",\n unavailable: \"Niedostępny\",\n subscription: \"Subskrypcja\",\n model3d: \"3D\",\n model3dLabel: \"Model 3D\",\n priceFrom: \"od {price}\",\n originalPrice: \"Cena przed obniżką\",\n loading: \"Ładowanie produktów\",\n empty: \"Brak produktów do wyświetlenia.\",\n error: \"Nie udało się załadować produktów.\",\n retry: \"Spróbuj ponownie\",\n pagination: \"Paginacja\",\n previousPage: \"Poprzednia\",\n nextPage: \"Następna\",\n pageOf: \"Strona {page} z {pageCount}\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveProductListTexts(\n locale: string,\n overrides?: Partial<ProductListTexts>,\n): ProductListTexts {\n return resolveTexts(PRODUCT_LIST_TEXT_TABLES, locale, overrides);\n}\n\nexport function getProductListText(\n key: ProductListTextKey,\n locale: string,\n overrides?: Partial<ProductListTexts>,\n): string {\n return lookupText(resolveProductListTexts(locale, overrides), key);\n}\n\n/** Replaces `{name}` placeholders. Unknown placeholders stay untouched. */\nexport function fillProductListText(\n text: string,\n values: Record<string, string | number>,\n): string {\n return text.replace(/\\{(\\w+)\\}/g, (match, name: string) =>\n name in values ? String(values[name]) : match,\n );\n}\n"],"mappings":"4UA6DO,IAAMA,GAA0B,CACrC,OACA,OACA,OACA,WACA,QACA,mBACA,OACA,OACA,cACA,QACA,eACA,QACA,eACA,UACA,kBACA,eACA,UACA,aACA,mBACA,gBACA,aACA,QACA,cACA,UACF,EA8BaC,GAA+B,CAC1C,WAAY,iCACZ,aAAc,oCACd,SAAU,+BACV,WAAY,gCACZ,QAAS,6BACT,WAAY,gCACZ,gBAAiB,sCACjB,OAAQ,4BACR,iBAAkB,uCAClB,iBAAkB,uCAClB,sBAAuB,6CACvB,aAAc,mCACd,UAAW,gCACX,MAAO,2BACP,gBAAiB,sC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BA,EAAQ,UAAU,CAAC,GAcvC,SAAS4F,GAAY,CAC1B,YAAAjC,EAAcgC,GACd,WAAAnG,EACA,MAAAU,EACA,WAAAe,EACA,YAAA2C,EACA,cAAAC,EAAgB,GAChB,UAAAtE,EACA,UAAA4B,EACA,GAAGuC,CACL,EAAqB,CACnB,IAAMQ,EAAyB2B,EAC7BnC,EAAQ,UACRvC,EACA,SACF,EACMD,EAASwC,EAAQ,QAAUoC,GAC3BC,EAAqBtB,EACzB,IAAMuB,GAA6BxG,CAAU,EAC7C,CAACA,CAAU,CACb,EACMyG,EAAgBxB,EACpB,IAAMyB,GAAwBhF,EAAQhB,CAAK,EAC3C,CAACgB,EAAQhB,CAAK,CAChB,EACMiG,EAAU1B,EACd,KAAO,CAAE,WAAYsB,EAAoB,MAAOE,EAAe,OAAA/E,CAAO,GACtE,CAAC6E,EAAoBE,EAAe/E,CAAM,CAC5C,EACMkF,EAAO1G,EAA6BqG,EAAoB,MAAM,EAEpE,OACEnH,EAACyH,EAAA,CAAmB,MAAOnC,EAC3B,SAAAtF,EAACE,GAAmB,SAAnB,CAA4B,MAAOqH,EAClC,SAAAvH,EAAC,OACC,wBAAsB,OACtB,6BAA2B,OAC3B,UAAWe,EACT,gBACAoG,EAAmB,kBACnBxG,EACA6G,GAAM,SACR,EACA,MACE,CAAE,GAAGL,EAAmB,cAAe,GAAGK,GAAM,KAAM,EAGxD,SAAAxH,EAAC6E,GAAA,CACC,QAASC,EACT,YAAaC,EACb,WAAY1C,EACZ,YAAa2C,EACb,cAAeC,EACjB,EACF,EACF,EACA,CAEJ","names":["PRODUCT_LIST_SLOT_NAMES","PRODUCT_LIST_TOKEN_VARIABLES","PRODUCT_LIST_THEME_PRESETS","PRODUCT_LIST_SHADCN_VARIABLES","resolveProductListAppearance","appearance","resolved","resolveAppearanceCore","getProductListSlotAppearance","slot","getSlotAppearance","useCallback","useEffect","useMemo","useState","useProducts","options","projectID","locale","search","initialData","defaultHost","useState","HOST","host","pageSize","clampPageSize","queryKey","pageState","setPageState","reloads","setReloads","snapshot","setSnapshot","totalCount","pageCount","pageCountFor","requestedPage","page","requestKey","isCurrent","useEffect","controller","fetchProductList","data","error","previous","setPage","useCallback","next","target","refetch","value","useMemo","createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","MAX_PER_EVENT","FLUSH_DELAY_MS","createImpressionTracker","onBatch","delayMs","seen","targets","pendingIds","pendingPositions","observer","timer","listening","flush","productIds","positions","flushAll","getTracker","onVisibility","listen","getObserver","entries","entry","target","element","id","position","watcher","PRODUCT_LIST_TEXT_TABLES","resolveProductListTexts","locale","overrides","resolveTexts","fillProductListText","text","values","match","name","Fragment","jsx","jsxs","ProductListContext","createContext","noCardAnalytics","CardAnalyticsContext","useListContext","value","useContext","useSlot","slot","className","appearance","override","getProductListSlotAppearance","cn","BUTTON_CLASS","BLOCK_BUTTON_CLASS","LINK_BUTTON_CLASS","AddToCartButton","product","onAdd","texts","status","setStatus","useState","button","message","useEffect","timer","click","useCallback","error","label","ProductCard","position","href","renderItem","locale","analytics","element","useRef","trackClick","card","cardLink","imageFrame","placeholder","body","name","description","price","comparePrice","badge","model3dBadge","actions","selectButton","formattedPrice","formatProductPrice","formattedCompare","imageSource","badgeText","fillProductListText","CubeIcon","GRID_CLASS","SkeletonGrid","count","grid","skeleton","_","index","Pagination","page","pageCount","isLoading","onPage","nav","indicator","ProductListContent","options","productHref","onAddToCart","showCartOnAdd","products","setPage","refetch","useProducts","instrument","useInstrumentContext","listId","pageSize","clampPageSize","viewed","impressions","useMemo","createImpressionTracker","productIds","positions","cardAnalytics","content","movedPage","changePage","next","empty","errorSlot","retry","projectID","host","addFor","withCartAnalyticsMuted","trackProductAdded","addProductToCart","defaultProductHref","ProductList","useInstrument","DEFAULT_LOCALE","resolvedAppearance","resolveProductListAppearance","resolvedTexts","resolveProductListTexts","context","root","InstrumentProvider"]}