bitsnap-react 1.20.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BitsnapCart-73ESTTTH.mjs +2 -0
- package/dist/BitsnapCart-TWT7LVGJ.js +2 -0
- package/dist/BitsnapCart-TWT7LVGJ.js.map +1 -0
- package/dist/{CartProvider-G7FQUPXL.mjs → CartProvider-4WXJPQJB.mjs} +2 -2
- package/dist/CartProvider-CPF2E7JA.js +2 -0
- package/dist/CartProvider-CPF2E7JA.js.map +1 -0
- package/dist/PanelModelFiles-EKQRLF46.js.map +1 -1
- package/dist/analytics.js +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/chat.d.mts +2 -2
- package/dist/chat.d.ts +2 -2
- package/dist/chat.js +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/chat.mjs +1 -1
- package/dist/chat.mjs.map +1 -1
- package/dist/{chunk-IXQCN7MR.mjs → chunk-27JN2GIQ.mjs} +2 -2
- package/dist/{chunk-URQBHNJK.mjs → chunk-6ALA5M44.mjs} +2 -2
- package/dist/{chunk-4Y233NII.js → chunk-6DEKVABT.js} +2 -2
- package/dist/chunk-6DEKVABT.js.map +1 -0
- package/dist/chunk-6Q3VGPSF.js.map +1 -1
- package/dist/{chunk-AQYHQY2Y.js → chunk-E5MMKBC4.js} +2 -2
- package/dist/chunk-E5MMKBC4.js.map +1 -0
- package/dist/chunk-EFN4OW2C.js.map +1 -1
- package/dist/{chunk-IRZJIPUF.js → chunk-EK3D44XW.js} +2 -2
- package/dist/chunk-EK3D44XW.js.map +1 -0
- package/dist/{chunk-BTERIY6N.mjs → chunk-EXC5Z5VM.mjs} +2 -2
- package/dist/{chunk-RJPQMDIQ.js → chunk-EZGL6DPG.js} +2 -2
- package/dist/chunk-EZGL6DPG.js.map +1 -0
- package/dist/{chunk-HP3I6D2R.js → chunk-FORZ5AH4.js} +2 -2
- package/dist/chunk-FORZ5AH4.js.map +1 -0
- package/dist/{chunk-KO7ZERN5.mjs → chunk-HLULQA3B.mjs} +2 -2
- package/dist/{chunk-YPA6MMGJ.js → chunk-I2RHVELR.js} +2 -2
- package/dist/chunk-I2RHVELR.js.map +1 -0
- package/dist/{chunk-GHBRR665.js → chunk-IKKMSLKC.js} +2 -2
- package/dist/chunk-IKKMSLKC.js.map +1 -0
- package/dist/{chunk-TW25G7XX.mjs → chunk-J6WKSO33.mjs} +2 -2
- package/dist/{chunk-TW25G7XX.mjs.map → chunk-J6WKSO33.mjs.map} +1 -1
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/{chunk-IXX6SUMB.mjs → chunk-KO7Z3E23.mjs} +2 -2
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/chunk-KYSMT6ZK.js +2 -0
- package/dist/chunk-KYSMT6ZK.js.map +1 -0
- package/dist/{chunk-LHQEM3CU.mjs → chunk-LRUBBPTV.mjs} +2 -2
- package/dist/chunk-MDAFPGPA.js.map +1 -1
- package/dist/chunk-Q337IQNA.js.map +1 -1
- package/dist/{chunk-5M3OUOMU.mjs → chunk-T5JO4SP7.mjs} +2 -2
- package/dist/{chunk-C736F727.js → chunk-TM3E3L57.js} +2 -2
- package/dist/chunk-TM3E3L57.js.map +1 -0
- package/dist/{chunk-LHNTSQYO.mjs → chunk-TMEII7BM.mjs} +2 -2
- package/dist/chunk-W3RGQYPD.js.map +1 -1
- package/dist/{chunk-A2ZDFN3J.mjs → chunk-WOA6W5RM.mjs} +2 -2
- package/dist/{chunk-KZWCVKLU.js → chunk-XMRGA5AN.js} +3 -3
- package/dist/chunk-XMRGA5AN.js.map +1 -0
- package/dist/chunk-Z3YOJ6NZ.js.map +1 -1
- package/dist/consent.js.map +1 -1
- package/dist/course.js +1 -1
- package/dist/course.js.map +1 -1
- package/dist/course.mjs +1 -1
- package/dist/embed/analytics.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/methods-43RQLLWD.mjs +2 -0
- package/dist/methods-SZVF3HMF.js +2 -0
- package/dist/methods-SZVF3HMF.js.map +1 -0
- package/dist/model-files-client-P4PORZJ6.js.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/dist/viewer3d.js.map +1 -1
- package/dist/viewer3d.mjs +1 -1
- package/dist/{widgets-Bsojw94g.d.ts → widgets-BL6pCMdc.d.ts} +34 -2
- package/dist/{widgets-u7xMJbsY.d.mts → widgets-DmHlIbp8.d.mts} +34 -2
- package/package.json +1 -1
- package/dist/BitsnapCart-V4S4EXYV.js +0 -2
- package/dist/BitsnapCart-V4S4EXYV.js.map +0 -1
- package/dist/BitsnapCart-Z6JFYNH2.mjs +0 -2
- package/dist/CartProvider-5NP4WACK.js +0 -2
- package/dist/CartProvider-5NP4WACK.js.map +0 -1
- package/dist/chunk-4Y233NII.js.map +0 -1
- package/dist/chunk-AQYHQY2Y.js.map +0 -1
- package/dist/chunk-C736F727.js.map +0 -1
- package/dist/chunk-GHBRR665.js.map +0 -1
- package/dist/chunk-HP3I6D2R.js.map +0 -1
- package/dist/chunk-IRZJIPUF.js.map +0 -1
- package/dist/chunk-KDL35KEI.js +0 -2
- package/dist/chunk-KDL35KEI.js.map +0 -1
- package/dist/chunk-KZWCVKLU.js.map +0 -1
- package/dist/chunk-RJPQMDIQ.js.map +0 -1
- package/dist/chunk-YPA6MMGJ.js.map +0 -1
- package/dist/methods-33CWGKNA.mjs +0 -2
- package/dist/methods-4GB652MQ.js +0 -2
- package/dist/methods-4GB652MQ.js.map +0 -1
- /package/dist/{BitsnapCart-Z6JFYNH2.mjs.map → BitsnapCart-73ESTTTH.mjs.map} +0 -0
- /package/dist/{CartProvider-G7FQUPXL.mjs.map → CartProvider-4WXJPQJB.mjs.map} +0 -0
- /package/dist/{chunk-IXQCN7MR.mjs.map → chunk-27JN2GIQ.mjs.map} +0 -0
- /package/dist/{chunk-URQBHNJK.mjs.map → chunk-6ALA5M44.mjs.map} +0 -0
- /package/dist/{chunk-BTERIY6N.mjs.map → chunk-EXC5Z5VM.mjs.map} +0 -0
- /package/dist/{chunk-KO7ZERN5.mjs.map → chunk-HLULQA3B.mjs.map} +0 -0
- /package/dist/{chunk-IXX6SUMB.mjs.map → chunk-KO7Z3E23.mjs.map} +0 -0
- /package/dist/{chunk-LHQEM3CU.mjs.map → chunk-LRUBBPTV.mjs.map} +0 -0
- /package/dist/{chunk-5M3OUOMU.mjs.map → chunk-T5JO4SP7.mjs.map} +0 -0
- /package/dist/{chunk-LHNTSQYO.mjs.map → chunk-TMEII7BM.mjs.map} +0 -0
- /package/dist/{chunk-A2ZDFN3J.mjs.map → chunk-WOA6W5RM.mjs.map} +0 -0
- /package/dist/{methods-33CWGKNA.mjs.map → methods-43RQLLWD.mjs.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as It,b as Lt}from"./chunk-KOVKUJAW.mjs";import{b as St,d as Ze,e as ie,f as ht,h as kt,i as Nt,k as P,l as Tt,n as wt,o as Et,p as Ct}from"./chunk-LHNTSQYO.mjs";import{a as u}from"./chunk-5R6AGO3Z.mjs";import{l as Rt,m as Ee,n as xt}from"./chunk-TW25G7XX.mjs";import{a as Ce,b as vt,f as Ie}from"./chunk-OFPRIENJ.mjs";var Pr=["root","header","title","description","backButton","stepIndicator","error","emptyState","skeleton","emailForm","emailInput","codeForm","codeInput","resendButton","logoutButton","orderList","orderCard","orderReference","orderDate","orderTotal","pagination","lineList","line","lineName","linePrice","lineQuantityControl","quantityButton","quantityInput","lineIneligibleReason","noteInput","summary","submitButton","secondaryButton","successState","returnReference","returnInstructions","returnList","returnCard","statusBadge","history","historyEntry"],Tn={fontFamily:"--bitsnap-returns-font-family",fontSize:"--bitsnap-returns-font-size",background:"--bitsnap-returns-background",surface:"--bitsnap-returns-surface",foreground:"--bitsnap-returns-foreground",mutedForeground:"--bitsnap-returns-muted-foreground",border:"--bitsnap-returns-border",buttonBackground:"--bitsnap-returns-button-background",buttonForeground:"--bitsnap-returns-button-foreground",buttonHoverBackground:"--bitsnap-returns-button-hover-background",hoverSurface:"--bitsnap-returns-hover-surface",focusRing:"--bitsnap-returns-focus-ring",error:"--bitsnap-returns-error",success:"--bitsnap-returns-success",warning:"--bitsnap-returns-warning",badgeBackground:"--bitsnap-returns-badge-background",badgeForeground:"--bitsnap-returns-badge-foreground",inputBackground:"--bitsnap-returns-input-background",radius:"--bitsnap-returns-radius"},wn={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",success:"#16a34a",warning:"#d97706",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",inputBackground:"#ffffff",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",success:"#4ade80",warning:"#fbbf24",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",inputBackground:"#27272a",radius:"8px"}},En=[{token:"background",variable:"--background"},{token:"foreground",variable:"--foreground"},{token:"surface",variable:"--card"},{token:"foreground",variable:"--card-foreground"},{token:"surface",variable:"--popover"},{token:"foreground",variable:"--popover-foreground"},{token:"buttonBackground",variable:"--primary"},{token:"buttonForeground",variable:"--primary-foreground"},{token:"surface",variable:"--secondary"},{token:"foreground",variable:"--secondary-foreground"},{token:"hoverSurface",variable:"--accent"},{token:"foreground",variable:"--accent-foreground"},{token:"mutedForeground",variable:"--muted-foreground"},{token:"border",variable:"--border"},{token:"border",variable:"--input"},{token:"focusRing",variable:"--ring"},{token:"error",variable:"--destructive"},{token:"radius",variable:"--radius"}];function $e(e){let t=It(e,{defaultTheme:"light",presets:wn,variables:Tn,shadcnVariables:En});return{theme:t.theme,tokens:t.tokens,elements:t.elements,boundaryClassName:t.theme,boundaryStyle:t.boundaryStyle}}function Pt(e,t){return Lt(e.elements,t)}import{createContext as Cn,useContext as In,useMemo as Ln}from"react";import{jsx as Pn}from"react/jsx-runtime";var At=Cn($e());function Ot({appearance:e,children:t}){let n=Ln(()=>$e(e),[e]);return Pn(At.Provider,{value:n,children:t})}function Ge(){return In(At)}function d(e){let t=Ge();return Pt(t,e)??{}}function Bt(e){return e==="test"||e===1?1:0}var zt={title:["emailStepTitle"],email:["emailLabel"],sendCode:["emailSubmit"],code:["codeLabel"],verify:["codeSubmit"],orders:["ordersTitle"],submit:["confirmationSubmit"],note:["noteLabel"],history:["myReturnsTitle","myReturnsLink"]};function Mt(e){if(e==null)return;let t={};for(let[n,r]of Object.entries(zt)){let a=e[n];if(typeof a=="string")for(let i of r)t[i]=a}for(let n of Object.keys(e)){if(n in zt)continue;let r=e[n];typeof r=="string"&&(t[n]=r)}return t}function Dt(e,t){let n=t?.brandColor?.trim();return n==null||n===""?e:{...e,tokens:{...wt(n),...e?.tokens}}}function Xe(e,t){return typeof e=="object"&&e!=null?{pageSize:e.pageSize??20,explicitPageToken:void 0}:typeof e=="number"||t!==void 0?{pageSize:e??20,explicitPageToken:t??""}:{pageSize:20,explicitPageToken:void 0}}var An={en:{back:"Back",stepIndicator:"Step {current} of {total}",loading:"Loading",myReturnsLink:"My returns",emailStepTitle:"Return a product",emailStepDescription:"Enter the email address you used for the order. We will send you a verification code.",emailLabel:"Email address",emailPlaceholder:"name@example.com",emailSubmit:"Send code",codeStepTitle:"Enter the code",codeStepDescription:"We sent a verification code to {email}.",codeLabel:"Verification code",codeSubmit:"Verify",resend:"Send the code again",resendIn:"Send again in {seconds} s",resendSent:"We sent a new code.",codeSpamHint:"Can't see the email? Check your spam folder.",codeValidity:"The code is valid for 10 minutes.",codeIncomplete:"Enter all 6 digits of the code.",logout:"Sign out",ordersTitle:"Your orders",ordersDescription:"Choose the order that contains the product to return.",ordersEmpty:"There are no orders eligible for return.",orderTitle:"Order {reference}",orderReturnableLines:"Products available to return: {count}",orderSelect:"Choose",paginationPrevious:"Previous",paginationNext:"Next",paginationInfo:"Page {page}, {total} orders",orderDetailTitle:"Order {reference}",orderDetailDescription:"Select the products and quantities to return.",quantityLabel:"Quantity to return: {name}",quantityDecrease:"Decrease quantity: {name}",quantityIncrease:"Increase quantity: {name}",quantityOfAvailable:"of {available}",lineIneligibleFallback:"This product cannot be returned.",noteLabel:"Note (optional)",notePlaceholder:"Tell us why you are returning the product",selectionContinue:"Continue",selectionEmpty:"Select at least one item to return.",previousReturnsTitle:"Earlier returns for this order",confirmationTitle:"Confirm the return",confirmationDescription:"Check the products before you submit the request.",confirmationSummary:"Products to return",confirmationQuantity:"Quantity: {quantity}",confirmationNote:"Your note",confirmationSubmit:"Submit return request",successTitle:"Return request submitted",successDescription:"We received your request and will keep you posted.",successReference:"Request number",successInstructions:"What to do next",successDone:"Back to orders",myReturnsTitle:"My returns",myReturnsDescription:"Track the status of your return requests.",myReturnsEmpty:"You have not submitted any return requests yet.",myReturnOpen:"Details",myReturnDetailTitle:"Return details",myReturnTitle:"Return {reference}",myReturnCreatedAt:"Submitted",myReturnRefund:"Refund",myReturnLines:"Products",myReturnLineQuantities:"Requested: {requested}, approved: {approved}, received: {received}",myReturnNote:"Your note",myReturnHistory:"History",statusSubmitted:"Submitted",statusApproved:"Approved",statusRejected:"Rejected",statusAwaitingReceipt:"Awaiting the package",statusReceived:"Package received",statusCompleted:"Completed",statusCancelled:"Cancelled",statusRefunded:"Refunded",statusFallback:"In progress",refundStatusNotStarted:"Not started",refundStatusPending:"Refund in progress",refundStatusSucceeded:"Refunded",refundStatusFailed:"Refund failed",refundStatusFallback:"Unknown",errorGeneric:"Something went wrong. Please try again.",errorNetwork:"Cannot reach the server. Check your connection and try again.",errorInvalidEmail:"Enter a valid email address.",errorInvalidCode:"The code is invalid or has expired.",errorSessionExpired:"Your session has expired. Verify your email again.",errorOrderNotFound:"We could not find this order.",errorReturnNotFound:"We could not find this return request.",errorQuantityUnavailable:"The selected quantity is no longer available for return.",errorItemNotReturnable:"One of the selected products cannot be returned.",errorReturnsDisabled:"Returns are not available in this shop.",errorRateLimited:"Too many attempts. Please try again later.",errorIdempotencyConflict:"This request was already submitted with different contents. Reload and try again.",errorDeliveryFailed:"We could not send the code. Please try again.",errorRetry:"Try again"},pl:{back:"Wstecz",stepIndicator:"Krok {current} z {total}",loading:"\u0141adowanie",myReturnsLink:"Moje zwroty",emailStepTitle:"Zwr\xF3\u0107 produkt",emailStepDescription:"Podaj adres e-mail u\u017Cyty w zam\xF3wieniu. Wy\u015Blemy na niego kod weryfikacyjny.",emailLabel:"Adres e-mail",emailPlaceholder:"jan@example.com",emailSubmit:"Wy\u015Blij kod",codeStepTitle:"Wpisz kod",codeStepDescription:"Wys\u0142ali\u015Bmy kod weryfikacyjny na adres {email}.",codeLabel:"Kod weryfikacyjny",codeSubmit:"Zweryfikuj",resend:"Wy\u015Blij kod ponownie",resendIn:"Wy\u015Blij ponownie za {seconds} s",resendSent:"Wys\u0142ali\u015Bmy nowy kod.",codeSpamHint:"Nie widzisz e-maila? Sprawd\u017A folder spam.",codeValidity:"Kod jest wa\u017Cny 10 minut.",codeIncomplete:"Wpisz wszystkie 6 cyfr kodu.",logout:"Wyloguj si\u0119",ordersTitle:"Twoje zam\xF3wienia",ordersDescription:"Wybierz zam\xF3wienie z produktem do zwrotu.",ordersEmpty:"Brak zam\xF3wie\u0144, kt\xF3re mo\u017Cna zwr\xF3ci\u0107.",orderTitle:"Zam\xF3wienie {reference}",orderReturnableLines:"Produkty do zwrotu: {count}",orderSelect:"Wybierz",paginationPrevious:"Poprzednia",paginationNext:"Nast\u0119pna",paginationInfo:"Strona {page}, zam\xF3wie\u0144: {total}",orderDetailTitle:"Zam\xF3wienie {reference}",orderDetailDescription:"Wybierz produkty i ilo\u015Bci do zwrotu.",quantityLabel:"Ilo\u015B\u0107 do zwrotu: {name}",quantityDecrease:"Zmniejsz ilo\u015B\u0107: {name}",quantityIncrease:"Zwi\u0119ksz ilo\u015B\u0107: {name}",quantityOfAvailable:"z {available}",lineIneligibleFallback:"Ten produkt nie podlega zwrotowi.",noteLabel:"Uwagi (opcjonalnie)",notePlaceholder:"Napisz, dlaczego zwracasz produkt",selectionContinue:"Dalej",selectionEmpty:"Wybierz co najmniej jedn\u0105 sztuk\u0119 do zwrotu.",previousReturnsTitle:"Wcze\u015Bniejsze zwroty tego zam\xF3wienia",confirmationTitle:"Potwierd\u017A zwrot",confirmationDescription:"Sprawd\u017A produkty przed wys\u0142aniem zg\u0142oszenia.",confirmationSummary:"Produkty do zwrotu",confirmationQuantity:"Ilo\u015B\u0107: {quantity}",confirmationNote:"Twoje uwagi",confirmationSubmit:"Wy\u015Blij zg\u0142oszenie zwrotu",successTitle:"Zg\u0142oszenie zwrotu zosta\u0142o wys\u0142ane",successDescription:"Otrzymali\u015Bmy zg\u0142oszenie i b\u0119dziemy informowa\u0107 o jego statusie.",successReference:"Numer zg\u0142oszenia",successInstructions:"Co dalej",successDone:"Wr\xF3\u0107 do zam\xF3wie\u0144",myReturnsTitle:"Moje zwroty",myReturnsDescription:"Sprawd\u017A status swoich zg\u0142osze\u0144 zwrotu.",myReturnsEmpty:"Nie masz jeszcze \u017Cadnych zg\u0142osze\u0144 zwrotu.",myReturnOpen:"Szczeg\xF3\u0142y",myReturnDetailTitle:"Szczeg\xF3\u0142y zwrotu",myReturnTitle:"Zwrot {reference}",myReturnCreatedAt:"Zg\u0142oszono",myReturnRefund:"Zwrot \u015Brodk\xF3w",myReturnLines:"Produkty",myReturnLineQuantities:"Zg\u0142oszono: {requested}, zaakceptowano: {approved}, odebrano: {received}",myReturnNote:"Twoje uwagi",myReturnHistory:"Historia",statusSubmitted:"Zg\u0142oszony",statusApproved:"Zaakceptowany",statusRejected:"Odrzucony",statusAwaitingReceipt:"Oczekiwanie na paczk\u0119",statusReceived:"Paczka odebrana",statusCompleted:"Zako\u0144czony",statusCancelled:"Anulowany",statusRefunded:"\u015Arodki zwr\xF3cone",statusFallback:"W trakcie",refundStatusNotStarted:"Nie rozpocz\u0119to",refundStatusPending:"Zwrot \u015Brodk\xF3w w toku",refundStatusSucceeded:"\u015Arodki zwr\xF3cone",refundStatusFailed:"Zwrot \u015Brodk\xF3w nie powi\xF3d\u0142 si\u0119",refundStatusFallback:"Nieznany",errorGeneric:"Co\u015B posz\u0142o nie tak. Spr\xF3buj ponownie.",errorNetwork:"Brak po\u0142\u0105czenia z serwerem. Sprawd\u017A internet i spr\xF3buj ponownie.",errorInvalidEmail:"Podaj poprawny adres e-mail.",errorInvalidCode:"Kod jest nieprawid\u0142owy lub wygas\u0142.",errorSessionExpired:"Sesja wygas\u0142a. Zweryfikuj adres e-mail ponownie.",errorOrderNotFound:"Nie znaleziono tego zam\xF3wienia.",errorReturnNotFound:"Nie znaleziono tego zg\u0142oszenia zwrotu.",errorQuantityUnavailable:"Wybrana ilo\u015B\u0107 nie jest ju\u017C dost\u0119pna do zwrotu.",errorItemNotReturnable:"Jeden z wybranych produkt\xF3w nie podlega zwrotowi.",errorReturnsDisabled:"Zwroty nie s\u0105 dost\u0119pne w tym sklepie.",errorRateLimited:"Zbyt wiele pr\xF3b. Spr\xF3buj ponownie p\xF3\u017Aniej.",errorIdempotencyConflict:"To zg\u0142oszenie zosta\u0142o ju\u017C wys\u0142ane z inn\u0105 zawarto\u015Bci\u0105. Od\u015Bwie\u017C stron\u0119 i spr\xF3buj ponownie.",errorDeliveryFailed:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu. Spr\xF3buj ponownie.",errorRetry:"Spr\xF3buj ponownie"}};function Je(e,t){return vt(An,e,t)}function Ft(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>Object.prototype.hasOwnProperty.call(t,r)?String(t[r]):n)}var On={submitted:"statusSubmitted",approved:"statusApproved",rejected:"statusRejected",awaiting_receipt:"statusAwaitingReceipt",received:"statusReceived",completed:"statusCompleted",cancelled:"statusCancelled",refunded:"statusRefunded"},zn={not_started:"refundStatusNotStarted",pending:"refundStatusPending",succeeded:"refundStatusSucceeded",failed:"refundStatusFailed"};function Kt(e){return On[e]??"statusFallback"}function jt(e){return zn[e]??"refundStatusFallback"}import{createContext as Bn,useCallback as Mn,useContext as _t,useMemo as Dn}from"react";import{jsx as Fn}from"react/jsx-runtime";var et=Bn({locale:"pl-PL",texts:Je("pl-PL")});function qt({texts:e,locale:t,children:n}){let r=t??Ie(),a=Dn(()=>({locale:r,texts:Je(r,e)}),[r,e]);return Fn(et.Provider,{value:a,children:n})}function z(){let{texts:e}=_t(et);return Mn((t,n)=>n==null?e[t]:Ft(e[t],n),[e])}function Z(){return _t(et).locale}import{createClient as _n}from"@connectrpc/connect";import{createConnectQueryKey as qn,TransportProvider as Un}from"@connectrpc/connect-query";import{QueryClient as Vn,QueryClientContext as Qn,QueryClientProvider as Wn,useQueryClient as Hn}from"@tanstack/react-query";import{createContext as Yn,useCallback as ze,useContext as Ht,useEffect as Wt,useMemo as Be,useRef as Zn,useState as ke}from"react";function tt(){try{return typeof window<"u"?window.sessionStorage:void 0}catch{return}}function Ut(e,t,n){return`bitsnap-login-pending:${e}:${encodeURIComponent(n??"")}:${encodeURIComponent(t??"")}`}function Le(e,t){try{tt()?.setItem(e,JSON.stringify(t))}catch{}}function me(e){try{tt()?.removeItem(e)}catch{}}function Pe(e,t=Date.now()){let n=tt();if(n!=null)try{let r=n.getItem(e);if(r==null)return;let a=JSON.parse(r);if(a!=null&&typeof a.email=="string"&&a.email!==""&&typeof a.sentAt=="number"&&typeof a.resendAt=="number"&&(a.challengeId==null||typeof a.challengeId=="string")&&t-a.sentAt<6e5)return{email:a.email,challengeId:a.challengeId,resendAt:a.resendAt,sentAt:a.sentAt};n.removeItem(e)}catch{try{n.removeItem(e)}catch{}}}import{timestampMs as Kn}from"@bufbuild/protobuf/wkt";var jn="bitsnap-returns-session:";function nt(e){return`${jn}${e}`}function Ae(){try{return typeof window<"u"?window.sessionStorage:void 0}catch{return}}function Vt(e,t,n=Date.now()){if(e==null)return;let r=nt(t);try{let a=e.getItem(r);if(a==null)return;let i=JSON.parse(a);if(i!=null&&typeof i=="object"&&typeof i.token=="string"&&i.token.length>0&&typeof i.expiresAt=="number"&&i.expiresAt>n){let{token:s,expiresAt:o}=i;return{token:s,expiresAt:o}}e.removeItem(r)}catch{try{e.removeItem(r)}catch{}}}function Qt(e,t,n){try{e?.setItem(nt(t),JSON.stringify(n))}catch{}}function rt(e,t){try{e?.removeItem(nt(t))}catch{}}function Oe(e){return e==null?void 0:Kn(e)}import{jsx as ue}from"react/jsx-runtime";var Yt=Yn(void 0);function D(e){let t=Ht(Yt);if(t==null)throw new Error(`${e} must be rendered inside <ReturnsProvider>`);return t}function st(){return qn({schema:Ze,cardinality:void 0})}var $n=2**31-1;function Gn({projectID:e,environment:t,transport:n,panelAccessToken:r,className:a,children:i}){let s=Hn(),{boundaryClassName:o,boundaryStyle:g}=Ge(),m=d("root"),[l,y]=ke({status:"hydrating"}),[c,f]=ke(),[b,x]=ke(),[v,k]=ke(),S=Ut("returns",e),w=Zn(void 0),h=ze(N=>{if(x(N),N==null){me(S);return}k(N.email),Le(S,{email:N.email,challengeId:N.challengeId,resendAt:N.resendAvailableAt,sentAt:Date.now()})},[S]),C=ze(()=>{s.removeQueries({queryKey:st()})},[s]),U=ze(()=>{rt(Ae(),e),h(void 0),y({status:"anonymous"}),C()},[e,C,h]),j=ze(N=>{Qt(Ae(),e,N),f(void 0),h(void 0),y({status:"authenticated",token:N.token,expiresAt:N.expiresAt})},[e,h]);Wt(()=>{let N=!1,Y=Ae();if(r==null||r===""){let A=w.current!=null;if(w.current=void 0,A){U();return}let _=Vt(Y,e),V=_==null?Pe(S):void 0;V?.challengeId!=null&&(x({challengeId:V.challengeId,email:V.email,resendAvailableAt:V.resendAt}),k(V.email)),y(_!=null?{status:"authenticated",token:_.token,expiresAt:_.expiresAt}:{status:"anonymous"});return}return w.current=r,rt(Y,e),C(),f(void 0),y({status:"exchanging"}),_n(Ze,n).exchangePanelSession({projectId:e,accessToken:r,environment:t}).then(A=>{if(N)return;let _=Oe(A.expiresAt);if(A.sessionToken===""||_==null)throw new Error("EMPTY_SESSION");j({token:A.sessionToken,expiresAt:_})}).catch(A=>{N||(f(A),y({status:"anonymous"}))}),()=>{N=!0}},[r,e,t,n]),Wt(()=>{if(l.status!=="authenticated"||l.expiresAt==null)return;let N=l.expiresAt-Date.now();if(N<=0){U();return}let Y=setTimeout(U,Math.min(N,$n));return()=>clearTimeout(Y)},[l.status,l.expiresAt,U]);let J=Be(()=>({projectID:e,environment:t,status:l.status,token:l.token,exchangeError:c,challenge:b,setChallenge:h,lastEmail:v,authenticate:j,clearSession:U}),[e,t,l.status,l.token,c,b,h,v,j,U]);return ue(Yt.Provider,{value:J,children:ue("div",{"data-bitsnap-returns":"root","data-bitsnap-returns-slot":"root",className:u("bitsnap-react",o,a,m.className),style:{...g,...m.style},children:i})})}function Xn({projectID:e,host:t,environment:n,appearance:r,texts:a,theme:i,locale:s,panelAccessToken:o,className:g,analytics:m,children:l}){let y=xt(e,m,"returns"),c=Ht(Qn),[f]=ke(()=>c==null?new Vn({defaultOptions:{queries:{staleTime:5e3}}}):void 0),b=t??kt(),x=Be(()=>Nt(b),[b]),v=i?.brandColor,k=Be(()=>Dt(r,{brandColor:v}),[r,v]),S=Be(()=>Mt(a),[a]),w=ue(Rt,{value:y,children:ue(Un,{transport:x,children:ue(Ot,{appearance:k,children:ue(qt,{texts:S,locale:s,children:ue(Gn,{projectID:e,environment:Bt(n),transport:x,panelAccessToken:o,className:g,children:l})})})})});return c==null&&f!=null?ue(Wn,{client:f,children:w}):w}var ls=Xn;import{useMutation as it,useQuery as Me}from"@connectrpc/connect-query";import{useQueryClient as rr}from"@tanstack/react-query";import{useCallback as oe,useEffect as Jt,useRef as sr,useState as or}from"react";import{Code as er,ConnectError as tr}from"@connectrpc/connect";import{Code as Ne,ConnectError as Jn}from"@connectrpc/connect";function Zt(e){let t=Jn.from(e);switch(t.code){case Ne.ResourceExhausted:return"rateLimited";case Ne.Unavailable:case Ne.DeadlineExceeded:case Ne.Canceled:return"network";case Ne.Unknown:return e instanceof TypeError||t.cause instanceof TypeError?"network":"unknown";default:return"unknown"}}var nr="SESSION_EXPIRED",$t={INVALID_EMAIL:"errorInvalidEmail",INVALID_OR_EXPIRED_CODE:"errorInvalidCode",SESSION_EXPIRED:"errorSessionExpired",ORDER_NOT_FOUND:"errorOrderNotFound",RETURN_NOT_FOUND:"errorReturnNotFound",QUANTITY_UNAVAILABLE:"errorQuantityUnavailable",ITEM_NOT_RETURNABLE:"errorItemNotReturnable",INVALID_RETURN_ITEMS:"errorItemNotReturnable",RETURNS_DISABLED:"errorReturnsDisabled",SUBMISSION_RATE_LIMITED:"errorRateLimited",IDEMPOTENCY_CONFLICT:"errorIdempotencyConflict",VERIFICATION_DELIVERY_FAILED:"errorDeliveryFailed"};function Gt(e){if(e==null||typeof e!="object")return;let{rawMessage:t,message:n}=e;if(typeof t=="string"&&t.length>0)return t;if(typeof n=="string")return Object.keys($t).find(r=>n.includes(r))}function ot(e){return Gt(e)===nr}function Xt(e){let t=Gt(e),n=t!=null?$t[t]:void 0;if(n!=null)return n;if(e!=null&&typeof e=="object"){if(tr.from(e).code===er.ResourceExhausted)return"errorRateLimited";if(Zt(e)==="network")return"errorNetwork"}return"errorGeneric"}function at(){let e=typeof globalThis<"u"?globalThis.crypto:void 0;if(typeof e?.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let n=0;n<t.length;n++)t[n]=Math.floor(Math.random()*256);return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function fe(e){return e==null?null:e instanceof Error?e:new Error(String(e))}function ge(e){return e==null?void 0:Xt(e)}function De(e,t){Jt(()=>{ot(e)&&t()},[e,t])}function en(e){let[t,n]=or([""]);return Jt(()=>{n([""])},[e]),{pageToken:t[t.length-1]??"",page:t.length,push:r=>n(a=>[...a,r]),pop:()=>n(r=>r.length>1?r.slice(0,-1):r)}}function Fe(){let e=D("useReturnSession"),t=it(ie.returns.startReturnSession),n=it(ie.returns.verifyReturnSession),{setChallenge:r,authenticate:a,clearSession:i}=e,s=Z().toLowerCase().startsWith("en")?"en":"pl",o=oe(async f=>{n.reset();let b=f.trim(),x=await t.mutateAsync({projectId:e.projectID,email:b,environment:e.environment,locale:s});return r({challengeId:x.challengeId,email:b,resendAvailableAt:Date.now()+Math.max(0,x.resendAfterSeconds)*1e3}),x},[e.projectID,e.environment,s,r,t,n]),g=oe(async f=>{let b=await n.mutateAsync({projectId:e.projectID,challengeId:f.challengeId,code:f.code,environment:e.environment}),x=Oe(b.expiresAt);if(b.sessionToken===""||x==null)throw new Error("EMPTY_SESSION");return a({token:b.sessionToken,expiresAt:x}),b},[e.projectID,e.environment,a,n]),m=oe(async f=>{try{return await o(f),!0}catch{return!1}},[o]),l=oe(async f=>{if(e.challenge==null)return!1;try{return await g({challengeId:e.challenge.challengeId,code:f.trim()}),!0}catch{return!1}},[e.challenge,g]),y=oe(()=>e.challenge!=null?m(e.challenge.email):Promise.resolve(!1),[e.challenge,m]),c=fe(t.error??n.error??e.exchangeError);return{status:e.status,isAuthenticated:e.status==="authenticated",challenge:e.challenge,isStarting:t.isPending,isVerifying:n.isPending,starting:t.isPending,verifying:n.isPending,error:c,errorKey:ge(c),start:m,startSession:o,verifySession:g,verify:l,resend:y,logout:i}}function Ke(e){return e.status==="hydrating"||e.status==="exchanging"}function tn(e,t){let n=D("useReturnOrders"),{pageSize:r,explicitPageToken:a}=Xe(e,t),i=en(n.token),s=Me(ie.returns.listReturnOrders,{projectId:n.projectID,sessionToken:n.token??"",pageSize:r,pageToken:a??i.pageToken},{enabled:n.token!=null});De(s.error,n.clearSession);let o=s.data?.nextPageToken??"";return{orders:s.data?.orders??[],total:s.data?.total??0,data:s.data,isLoading:Ke(n)||s.isLoading,isFetching:s.isFetching,error:fe(s.error),errorKey:ge(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:i.page,hasNext:o!=="",hasPrevious:i.page>1,next:()=>{o!==""&&i.push(o)},previous:i.pop,refetch:()=>s.refetch()}}function ut(e){let t=D("useReturnableOrder"),n=Me(ie.returns.getReturnableOrder,{projectId:t.projectID,sessionToken:t.token??"",canonicalOrderId:e??""},{enabled:t.token!=null&&e!=null&&e!==""});return De(n.error,t.clearSession),{order:n.data?.order,returnHistory:n.data?.returnHistory??[],data:n.data,isLoading:e!=null&&e!==""&&(Ke(t)||n.isLoading),error:fe(n.error),errorKey:ge(n.error),status:n.status,isError:n.isError,isSuccess:n.isSuccess,refetch:()=>n.refetch()}}function nn(){let e=D("useCreateReturn"),t=rr(),n=it(ie.returns.createReturnRequest),r=Ee(),a=sr(void 0),{clearSession:i}=e,s=oe(async(l,y)=>{try{let c=await n.mutateAsync({projectId:e.projectID,sessionToken:e.token??"",canonicalOrderId:l.orderId,items:l.items,note:l.note??"",idempotencyKey:y});return t.invalidateQueries({queryKey:st()}),r.track("return_submitted",{reason_code:"unspecified",item_count:l.items.length},{order_ref:null}),c}catch(c){throw ot(c)&&i(),c}},[e.projectID,e.token,n,t,i,r]),o=oe(async l=>{a.current??=at();try{let y=await s(l,a.current);return a.current=void 0,y.request}catch{return}},[s]),g=oe(async l=>{if(e.token==null)throw new Error("Verify your email to continue.");return s({orderId:l.canonicalOrderID,items:l.items,note:l.note},l.idempotencyKey??at())},[e.token,s]),m=oe((l,y)=>{g(l).then(c=>y?.onSuccess?.(c),c=>y?.onError?.(fe(c)))},[g]);return{submit:o,isPending:n.isPending,error:fe(n.error),errorKey:ge(n.error),mutateAsync:g,mutate:m,data:n.data,reset:n.reset,status:n.status,isError:n.isError,isSuccess:n.isSuccess}}function rn(e,t){let n=D("useMyReturns"),{pageSize:r,explicitPageToken:a}=Xe(e,t),i=en(n.token),s=Me(ie.returns.listMyReturns,{projectId:n.projectID,sessionToken:n.token??"",pageSize:r,pageToken:a??i.pageToken},{enabled:n.token!=null});De(s.error,n.clearSession);let o=s.data?.nextPageToken??"";return{returns:s.data?.returns??[],total:s.data?.total??0,data:s.data,isLoading:Ke(n)||s.isLoading,isFetching:s.isFetching,error:fe(s.error),errorKey:ge(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:i.page,hasNext:o!=="",hasPrevious:i.page>1,next:()=>{o!==""&&i.push(o)},previous:i.pop,refetch:()=>s.refetch()}}function je(e){let t=D("useMyReturn"),n=Me(ie.returns.getMyReturn,{projectId:t.projectID,sessionToken:t.token??"",returnId:e},{enabled:t.token!=null});return De(n.error,t.clearSession),{request:n.data?.request,isLoading:Ke(t)||n.isLoading,error:n.error,errorKey:ge(n.error),refetch:()=>n.refetch()}}import{useEffect as wr,useRef as yn,useState as we}from"react";import*as sn from"@radix-ui/react-label";import{jsx as ar}from"react/jsx-runtime";function Te({className:e,...t}){return ar(sn.Root,{"data-slot":"label",className:u("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}import{Loader2Icon as ir}from"lucide-react";import{jsx as ur}from"react/jsx-runtime";function ye({className:e,...t}){return ur(ir,{role:"status","aria-label":"Loading",className:u("size-4 animate-spin",e),...t})}import{useState as lr}from"react";import{Fragment as mr,jsx as ee,jsxs as on}from"react/jsx-runtime";var dr={pl:{alt:"Logo sklepu"},en:{alt:"Shop logo"}},lt="flex h-10 items-center",dt="block max-h-10 max-w-48 w-auto object-contain";function cr(){return on("span",{role:"img","aria-label":"Bitsnap",className:"inline-flex items-center gap-1.5",children:[ee("svg",{"aria-hidden":"true",width:"29",height:"27",viewBox:"0 0 33 30",fill:"none",stroke:"currentColor",strokeWidth:"3.04",strokeLinecap:"round",children:ee("path",{d:"M20.2 1.8h0M22.8 6.2h0M22.8 10.6h0M22.8 15h0M22.8 19.4h0M22.8 23.8h0M20.2 28.2h0M27.1 10.6h0M27.1 15h0M27.1 19.4h0M31.5 15h0M1.5 1.8h0M5.4 1.8h0M9.3 1.8h0M13.2 1.8h0M5.4 15h0M9.3 15h0M13.2 15h0M5.4 28.2h0M9.3 28.2h0M13.2 28.2h0M1.5 6.2h0M1.5 10.6h0M1.5 15h0M1.5 19.4h0M1.5 23.8h0M1.5 28.2h0M16.7 19.4h0M16.7 23.8h0M16.7 6.2h0M16.7 10.6h0"})}),ee("span",{"aria-hidden":"true",className:"text-xl tracking-wider",children:"bitsnap."})]})}function pr(e,t){return ht(St,{projectId:e},{enabled:t,staleTime:1/0,retry:!1,refetchOnWindowFocus:!1})}function ct({projectId:e,name:t,locale:n,showLogo:r=!0,logoUrl:a,logoDarkUrl:i,className:s}){let[o,g]=lr([]),m=a||i,l=e?.trim()??"",{data:y,isPending:c}=pr(l,r&&!m&&l!=="");if(!r)return null;if(!m&&l!==""&&c)return ee("div",{className:u(lt,s),"aria-hidden":"true"});let f=(m?a||i:y?.logoUrl||y?.logoDarkUrl)||"",b=(m?i||a:y?.logoDarkUrl||y?.logoUrl)||"",x=h=>h!==""&&!o.includes(h),v=x(f)?f:x(b)?b:"",k=x(b)?b:x(f)?f:"";if(v===""&&k==="")return ee("div",{className:u(lt,s),children:ee(cr,{})});let S=t||y?.name||Ce(dr,n??Ie()).alt,w=h=>()=>g(C=>C.includes(h)?C:[...C,h]);return ee("div",{className:u(lt,s),children:v===k?ee("img",{src:v,alt:S,className:dt,draggable:!1,onError:w(v)}):on(mr,{children:[ee("img",{src:v,alt:S,className:u(dt,"dark:hidden"),draggable:!1,onError:w(v)}),ee("img",{src:k,alt:S,className:u(dt,"hidden dark:block"),draggable:!1,onError:w(k)})]})})}import{REGEXP_ONLY_DIGITS as hr}from"input-otp";import{useCallback as kr}from"react";import*as an from"react";import{OTPInput as fr,OTPInputContext as gr}from"input-otp";import{MinusIcon as Hs}from"lucide-react";import{jsx as _e,jsxs as yr}from"react/jsx-runtime";function un({className:e,containerClassName:t,...n}){return _e(fr,{"data-slot":"input-otp",containerClassName:u("flex items-center gap-2 has-disabled:opacity-50",t),className:u("disabled:cursor-not-allowed",e),...n})}function ln({className:e,...t}){return _e("div",{"data-slot":"input-otp-group",className:u("flex items-center",e),...t})}function dn({index:e,className:t,...n}){let r=an.useContext(gr),{char:a,hasFakeCaret:i,isActive:s}=r?.slots[e]??{};return yr("div",{"data-slot":"input-otp-slot","data-active":s,className:u("data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",t),...n,children:[a,i&&_e("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:_e("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}import{useCallback as ae,useEffect as Ue,useRef as be,useState as $}from"react";import{useEffect as br,useState as Rr}from"react";function qe(e){let[,t]=Rr(0);return br(()=>{if(e==null||Date.now()>=e)return;let n=setInterval(()=>{t(r=>r+1),Date.now()>=e&&clearInterval(n)},1e3);return()=>clearInterval(n)},[e]),e!=null?Math.max(0,Math.ceil((e-Date.now())/1e3)):0}var xr={pl:{emailLabel:"E-mail",emailPlaceholder:"m@example.com",sendCode:"Wy\u015Blij kod",sending:"Wysy\u0142anie\u2026",invalidEmail:"Podaj poprawny adres e-mail.",codeSentTo:"Wys\u0142ali\u015Bmy kod na {email}.",changeEmail:"Zmie\u0144",codeLabel:"Kod z e-maila",verify:"Zaloguj si\u0119",verifying:"Sprawdzanie\u2026",codeIncomplete:"Wpisz wszystkie 6 cyfr kodu.",spamHint:"Nie widzisz e-maila? Sprawd\u017A folder spam.",validity:"Kod jest wa\u017Cny 10 minut.",resend:"Wy\u015Blij ponownie",resendIn:"Wy\u015Blij ponownie za {seconds}\xA0s",resendNew:"Wy\u015Blij nowy kod",resent:"Wys\u0142ali\u015Bmy nowy kod.",haveCodePrompt:"Masz ju\u017C kod?",haveCode:"Mam ju\u017C kod",noCode:"Nie masz kodu? Wy\u015Blij go",stepEmail:"Krok 1 z 2: podaj adres e-mail.",stepCode:"Krok 2 z 2: wpisz kod z e-maila.",wrongCode:"Nieprawid\u0142owy kod. Spr\xF3buj jeszcze raz.",expired:"Kod wygas\u0142. Wy\u015Blij nowy kod.",tooManyAttempts:"Zbyt wiele b\u0142\u0119dnych pr\xF3b. Wy\u015Blij nowy kod albo zmie\u0144 adres e-mail.",rateLimited:"Zbyt wiele pr\xF3b. Spr\xF3buj ponownie za {time}.",alreadySent:"Kod zosta\u0142 ju\u017C wys\u0142any. Nowy mo\u017Cesz poprosi\u0107 za {time}.",emailNotFound:"Nie znale\u017Ali\u015Bmy konta z tym adresem e-mail.",deliveryFailed:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu. Spr\xF3buj ponownie.",deliveryUnavailable:"Nie mo\u017Cemy teraz wys\u0142a\u0107 kodu na ten adres. Spr\xF3buj p\xF3\u017Aniej.",captchaRequired:"Potwierd\u017A, \u017Ce jeste\u015B cz\u0142owiekiem, aby wys\u0142a\u0107 kod.",captchaInvalid:"Nie uda\u0142o si\u0119 zweryfikowa\u0107. Spr\xF3buj ponownie.",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.",captchaRequired:"Complete the security check before requesting a code.",captchaInvalid:"Verification failed. Please try again.",network:"Cannot reach the server. Check your connection and try again.",generic:"Something went wrong. Please try again."}};function eo(e,...t){let n={...Ce(xr,e)};for(let r of t)if(r!=null)for(let[a,i]of Object.entries(r))i!=null&&(n[a]=i);return n}function cn(e){let t=Math.max(1,Math.ceil(e));return t<=60?`${t}\xA0s`:`${Math.ceil(t/60)}\xA0min`}function pt(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 Ve(e,t,n){return{...Sr(e,t,n),failure:t}}function Sr(e,t,n){let r=cn(n??mn);switch(t){case"invalidEmail":return{kind:"error",text:e.invalidEmail};case"emailNotFound":return{kind:"error",text:e.emailNotFound};case"wrongCode":return{kind:"error",text:e.wrongCode};case"expired":return{kind:"error",text:e.expired};case"tooManyAttempts":return{kind:"error",text:e.tooManyAttempts};case"rateLimited":return{kind:"error",text:pt(e.rateLimited,{time:r})};case"alreadySent":return{kind:"info",text:pt(e.alreadySent,{time:r})};case"deliveryFailed":return{kind:"error",text:e.deliveryFailed};case"deliveryUnavailable":return{kind:"error",text:e.deliveryUnavailable};case"captchaRequired":return{kind:"error",text:e.captchaRequired};case"captchaInvalid":return{kind:"error",text:e.captchaInvalid};case"network":return{kind:"error",text:e.network};default:return{kind:"error",text:e.generic}}}function ao(e){let{storageKey:t}=e,n=be(e);n.current=e;let[r,a]=$("email"),[i,s]=$(e.initialEmail??""),[o,g]=$(""),[m,l]=$(),[y,c]=$(),[f,b]=$(!1),[x,v]=$(),[k,S]=$(),[w,h]=$(),[C,U]=$(!1),[j,J]=$(""),[N,Y]=$(0),A=be(!1),_=be("email"),V=be(null),F=be(null),re=be("email"),Se=qe(y),B=ae(T=>{_.current=T,Y(O=>O+1)},[]);Ue(()=>{N!==0&&(_.current==="email"?V:F).current?.focus()},[N]),Ue(()=>{if(a("email"),g(""),l(void 0),c(void 0),b(!1),v(void 0),S(void 0),t==null)return;let T=Pe(t);T!=null&&(s(T.email),l(T.challengeId),c(T.resendAt>Date.now()?T.resendAt:void 0),a("code"))},[t]),Ue(()=>{re.current!==r&&(re.current=r,J(r==="code"?n.current.texts.stepCode:n.current.texts.stepEmail))},[r]),Ue(()=>{r==="code"&&N===0&&B(f?"email":"code")},[r]);let R=ae((T,O,L,M)=>{T!=="wrongCode"&&T!=="invalidEmail"&&T!=="alreadySent"&&n.current.onFailure?.(T,L);let se=Ve(n.current.texts,T,O);return M!=null?{...se,text:M}:se},[]),X=ae((T,O,L,M)=>{let se=Date.now(),bt=se+(L??mn)*1e3;s(T),a("code"),b(!1),l(O),c(bt),g(""),v(void 0),S(M),t!=null&&Le(t,{email:T,challengeId:O,resendAt:bt,sentAt:se}),B("code")},[t,B]),Q=ae(async T=>{if(A.current)return;let O=i.trim();if(!pn(O)){S(Ve(n.current.texts,"invalidEmail")),B("email");return}if(A.current=!0,h(T),S(void 0),n.current.beforeSend&&!await n.current.beforeSend()){A.current=!1,h(void 0),S(Ve(n.current.texts,"captchaInvalid"));return}let L;try{L=await n.current.adapter.send(O,{resend:T==="resend"})}catch(se){L={ok:!1,kind:"network",cause:se}}if(A.current=!1,h(void 0),L.ok){X(O,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(O,void 0,L.retryIn,M);return}L.retryIn!=null&&T==="resend"&&c(Date.now()+L.retryIn*1e3),S(M),T==="send"&&B("email")},[i,X,R,B]),he=ae(async T=>{let O=T??o;if(A.current||C||x!=null)return;let L=i.trim();if(f&&!pn(L)){S(Ve(n.current.texts,"invalidEmail")),B("email");return}if(O.length!==de){S({kind:"error",text:n.current.texts.codeIncomplete}),B("code");return}A.current=!0,h("verify"),S(void 0);let M;try{M=await n.current.adapter.verify({email:L,code:O,challengeId:m})}catch(se){M={ok:!1,kind:"network",cause:se}}if(A.current=!1,h(void 0),M.ok){t!=null&&me(t),U(!0),n.current.onVerified?.(M.value,L);return}switch(S(R(M.kind,M.retryIn,M.cause,M.message)),M.kind){case"expired":case"tooManyAttempts":v(M.kind),g(""),t!=null&&me(t);break;case"invalidEmail":case"emailNotFound":B(f?"email":"code");break;case"network":case"unknown":case"deliveryFailed":case"deliveryUnavailable":B("code");break;default:g(""),B("code")}},[o,m,x,C,i,R,f,B,t]),Ye=ae(T=>{s(T),S(O=>O?.kind==="error"?void 0:O)},[]),hn=ae(T=>{g(T.replace(/\D/g,"").slice(0,de)),S(O=>O?.kind==="error"?void 0:O)},[]),kn=ae(()=>{a("email"),b(!1),g(""),l(void 0),c(void 0),v(void 0),S(void 0),t!=null&&me(t),B("email")},[t,B]),Nn=ae(()=>{a("code"),b(!0),g(""),l(void 0),c(void 0),v(void 0),S(void 0),B("email")},[B]);return{step:r,email:i,setEmail:Ye,code:o,setCode:hn,needsEmail:f,busy:w,isBusy:w!=null||C,done:C,notice:k,dead:x,secondsLeft:Se,announcement:j,emailRef:V,codeRef:F,sendCode:()=>Q("send"),resend:()=>Q("resend"),submitCode:he,changeEmail:kn,haveCode:Nn}}import{jsx as mt}from"react/jsx-runtime";function Nr(e){return e.replace(/[\s-]/g,"")}function Tr(e){e!=null&&(e.style.boxSizing="border-box",e.style.padding="0")}function fn({id:e,name:t,value:n,onChange:r,onComplete:a,disabled:i,invalid:s,inputRef:o,autoFocus:g,slotClassName:m,slotStyle:l,className:y,...c}){let f=kr(x=>{Tr(x),typeof o=="function"?o(x):o!=null&&(o.current=x)},[o]),b={className:u("h-11 w-auto min-w-0 flex-1 rounded-md border first:rounded-md last:rounded-md text-base","dark:border-foreground/30 dark:data-[active=true]:border-foreground/70 dark:data-[active=true]:ring-foreground/25","dark:aria-invalid:border-destructive-foreground dark:data-[active=true]:aria-invalid:border-destructive-foreground dark:aria-invalid:ring-destructive-foreground/30 dark:data-[active=true]:aria-invalid:ring-destructive-foreground/30",m),style:l,"aria-invalid":s?!0:void 0};return mt(un,{ref:f,id:e,name:t,maxLength:de,value:n,onChange:r,onComplete:a,disabled:i,autoFocus:g,inputMode:"numeric",autoComplete:"one-time-code",pattern:hr,pasteTransformer:Nr,"aria-invalid":s?!0:void 0,"aria-label":c["aria-label"],"aria-describedby":c["aria-describedby"],containerClassName:u("w-full",y),children:mt(ln,{className:"w-full gap-1.5 sm:gap-2",children:Array.from({length:de},(x,v)=>mt(dn,{index:v,...b},v))})})}import{jsx as G,jsxs as Qe}from"react/jsx-runtime";var ce="bg-[var(--bitsnap-returns-button-background,#18181b)] text-[color:var(--bitsnap-returns-button-foreground,#fafafa)] hover:bg-[var(--bitsnap-returns-button-hover-background,#000000)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",W="border border-[color:var(--bitsnap-returns-border,#e4e4e7)] bg-transparent text-[color:var(--bitsnap-returns-foreground,#18181b)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",Re="bg-[var(--bitsnap-returns-input-background,#ffffff)] dark:bg-[var(--bitsnap-returns-input-background,#ffffff)] border-[color:var(--bitsnap-returns-border,#e4e4e7)] text-[color:var(--bitsnap-returns-foreground,#18181b)] placeholder:text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] focus-visible:border-[color:var(--bitsnap-returns-focus-ring,#71717a)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",gn=u(Re,"data-[active=true]:border-[color:var(--bitsnap-returns-focus-ring,#71717a)] data-[active=true]:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50");function te({title:e,description:t,onBack:n,lead:r,className:a,children:i}){let s=z(),o=d("header"),g=d("title"),m=d("description"),l=d("backButton");return Qe("section",{className:u("flex flex-col gap-5",a),children:[r,Qe("div",{"data-bitsnap-returns-slot":"header",className:u("flex flex-col gap-2",o.className),style:o.style,children:[n!=null&&G(P,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"backButton",className:u("self-start -ml-3 text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",l.className),style:l.style,onClick:n,children:s("back")}),G("h2",{"data-bitsnap-returns-slot":"title",className:u("text-2xl font-semibold",g.className),style:g.style,children:e}),t!=null&&G("p",{"data-bitsnap-returns-slot":"description",className:u("text-sm",m.className),style:m.style,children:t})]}),i]})}function H({errorKey:e,onRetry:t}){let n=z(),r=d("error"),a=d("secondaryButton");return Qe("div",{role:"alert","data-bitsnap-returns-slot":"error",className:u("flex flex-col items-start gap-2 text-sm",r.className),style:r.style,children:[G("p",{children:n(e)}),t!=null&&G(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,a.className),style:a.style,onClick:t,children:n("errorRetry")})]})}function We({children:e}){let t=d("emptyState");return G("p",{"data-bitsnap-returns-slot":"emptyState",className:u("py-6 text-center text-sm",t.className),style:t.style,children:e})}function le({rows:e=3}){let t=z(),n=d("skeleton");return G("div",{role:"status","aria-busy":"true","aria-label":t("loading"),className:"flex flex-col gap-3",children:Array.from({length:e},(r,a)=>G(Et,{"data-bitsnap-returns-slot":"skeleton",className:u("h-16 w-full bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",n.className),style:n.style},a))})}function xe({status:e}){let t=z(),n=d("statusBadge");return G("span",{"data-bitsnap-returns-slot":"statusBadge","data-status":e,className:u("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",n.className),style:n.style,children:t(Kt(e))})}function ft(){let e=z();return t=>e(jt(t))}function He({page:e,total:t,hasNext:n,hasPrevious:r,isFetching:a,onNext:i,onPrevious:s}){let o=z(),g=d("pagination"),m=d("secondaryButton");return!n&&!r?null:Qe("nav",{"data-bitsnap-returns-slot":"pagination",className:u("flex items-center justify-between gap-3 text-sm",g.className),style:g.style,children:[G(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,m.className),style:m.style,disabled:!r||a,onClick:s,children:o("paginationPrevious")}),G("span",{"aria-live":"polite",children:o("paginationInfo",{page:e,total:t})}),G(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,m.className),style:m.style,disabled:!n||a,onClick:i,children:o("paginationNext")})]})}import{jsx as K,jsxs as ne}from"react/jsx-runtime";function Ko({onSubmitted:e,className:t,...n}){let r=D("ReturnsEmailStep"),a=z(),i=Z(),s=Fe(),[o,g]=we(r.lastEmail??""),m=d("emailForm"),l=d("emailInput"),y=d("submitButton");async function c(f){f.preventDefault(),!s.isStarting&&await s.start(o)&&e?.(o.trim())}return K(te,{className:t,lead:K(ct,{projectId:r.projectID,locale:i,...n}),title:a("emailStepTitle"),description:a("emailStepDescription"),children:ne("form",{"data-bitsnap-returns-slot":"emailForm",className:u("flex flex-col gap-4",m.className),style:m.style,onSubmit:c,children:[ne("div",{className:"flex flex-col gap-2",children:[K(Te,{htmlFor:"bitsnap-returns-email",children:a("emailLabel")}),K(Tt,{id:"bitsnap-returns-email",type:"email",name:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",spellCheck:!1,autoFocus:!0,required:!0,value:o,placeholder:a("emailPlaceholder"),disabled:s.isStarting,"data-bitsnap-returns-slot":"emailInput",className:u(Re,l.className),style:l.style,onChange:f=>g(f.target.value)})]}),s.errorKey!=null&&K(H,{errorKey:s.errorKey}),ne(P,{type:"submit",disabled:s.isStarting,"data-bitsnap-returns-slot":"submitButton",className:u(ce,y.className),style:y.style,children:[s.isStarting&&K(ye,{}),a("emailSubmit")]})]})})}function jo({onVerified:e,onBack:t,className:n,...r}){let a=D("ReturnsCodeStep"),i=z(),s=Z(),o=Fe(),[g,m]=we(""),[l,y]=we(!1),[c,f]=we(!1),[b,x]=we(1),v=yn(null),k=yn(!1),S=qe(o.challenge?.resendAvailableAt),w=d("codeForm"),h=d("codeInput"),C=d("submitButton"),U=d("resendButton"),j=o.isVerifying||o.isStarting,J="bitsnap-returns-code",N=`${J}-hint`;wr(()=>{j||v.current?.focus()},[b,j]);async function Y(F){if(!(j||k.current)){if(F.length!==de){y(!0),x(re=>re+1);return}k.current=!0,y(!1),f(!1);try{await o.verify(F)?e?.():(m(""),x(re=>re+1))}finally{k.current=!1}}}async function A(F){F.preventDefault(),await Y(g)}async function _(){y(!1),f(!1),await o.resend()&&(m(""),f(!0)),x(F=>F+1)}function V(){a.setChallenge(void 0),t?.()}return K(te,{className:n,onBack:t!=null?V:void 0,lead:K(ct,{projectId:a.projectID,locale:s,...r}),title:i("codeStepTitle"),description:i("codeStepDescription",{email:o.challenge?.email??""}),children:ne("form",{"data-bitsnap-returns-slot":"codeForm",className:u("flex flex-col gap-4",w.className),style:w.style,noValidate:!0,onSubmit:A,children:[ne("div",{className:"flex flex-col gap-2",children:[K(Te,{htmlFor:J,children:i("codeLabel")}),K(fn,{id:J,name:"code",inputRef:v,value:g,disabled:j,invalid:o.errorKey!=null||l,"aria-describedby":N,slotClassName:u(gn,h.className),slotStyle:h.style,onChange:F=>{m(F.replace(/\D/g,"")),y(!1)},onComplete:F=>void Y(F)}),ne("p",{id:N,className:"text-xs",children:[i("codeValidity")," ",i("codeSpamHint")]})]}),ne("div",{className:"min-h-10",children:[l&&K("p",{role:"alert",className:"text-sm",children:i("codeIncomplete")}),!l&&o.errorKey!=null&&K(H,{errorKey:o.errorKey}),!l&&o.errorKey==null&&c&&K("p",{role:"status",className:"text-sm",children:i("resendSent")})]}),ne("div",{className:"flex flex-wrap items-center gap-3",children:[ne(P,{type:"submit",disabled:j||o.challenge==null,"data-bitsnap-returns-slot":"submitButton",className:u("h-11",ce,C.className),style:C.style,children:[o.isVerifying&&K(ye,{"aria-hidden":!0}),i("codeSubmit")]}),ne(P,{type:"button",variant:"secondary",disabled:j||S>0||o.challenge==null,"data-bitsnap-returns-slot":"resendButton",className:u("h-11",W,U.className),style:U.style,onClick:()=>void _(),children:[o.isStarting&&K(ye,{"aria-hidden":!0}),S>0?i("resendIn",{seconds:S}):i("resend")]})]})]})})}function bn(){let e=z(),t=Fe(),n=d("logoutButton");return K(P,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"logoutButton",className:u("text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",n.className),style:n.style,onClick:t.logout,children:e("logout")})}import{useEffect as Cr,useState as yt}from"react";import{timestampDate as Er}from"@bufbuild/protobuf/wkt";function pe(e,t){if(e==null)return"";let n=Er(e);try{return new Intl.DateTimeFormat(t,{dateStyle:"medium"}).format(n)}catch{return n.toISOString().slice(0,10)}}function ve(e,t,n){let r=typeof e=="bigint"?e:BigInt(Math.trunc(e));try{let a=new Intl.NumberFormat(n,{style:"currency",currency:t}),i=a.resolvedOptions().maximumFractionDigits??2;return a.format(Rn(r,i))}catch{return`${Rn(r,2)} ${t}`}}function Rn(e,t){let n=e<BigInt(0),r=n?-e:e;if(t<=0)return`${n?"-":""}${r}`;let a=BigInt(10)**BigInt(t),i=r/a,s=(r%a).toString().padStart(t,"0");return`${n?"-":""}${i}.${s}`}function xn(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.trunc(e)),Math.max(0,t)):0}function gt(e){return e.eligible&&e.availableQuantity>0}function vn(e,t){return e.map(n=>({lineId:n,quantity:t[n]??0})).filter(n=>n.quantity>0)}import{Fragment as Sn,jsx as p,jsxs as E}from"react/jsx-runtime";function la({onSelectOrder:e,onOpenMyReturns:t,showLogout:n=!0,pageSize:r,className:a}){D("ReturnsOrderList");let i=z(),s=Z(),o=tn({pageSize:r}),g=d("orderList"),m=d("orderCard"),l=d("orderReference"),y=d("orderDate"),c=d("orderTotal"),f=d("secondaryButton");return E(te,{className:a,title:i("ordersTitle"),description:i("ordersDescription"),children:[(n||t!=null)&&E("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t!=null?p(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,f.className),style:f.style,onClick:t,children:i("myReturnsLink")}):p("span",{}),n&&p(bn,{})]}),o.isLoading?p(le,{}):o.errorKey!=null?p(H,{errorKey:o.errorKey,onRetry:o.refetch}):o.orders.length===0?p(We,{children:i("ordersEmpty")}):E(Sn,{children:[p("ul",{"data-bitsnap-returns-slot":"orderList",className:u("flex flex-col gap-3",g.className),style:g.style,children:o.orders.map(b=>E("li",{"data-bitsnap-returns-slot":"orderCard",className:u("flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[E("div",{className:"flex flex-col gap-1",children:[p("span",{"data-bitsnap-returns-slot":"orderReference",className:u("font-medium",l.className),style:l.style,children:i("orderTitle",{reference:b.displayReference})}),p("span",{"data-bitsnap-returns-slot":"orderDate",className:u("text-sm",y.className),style:y.style,children:pe(b.purchasedAt,s)}),p("span",{className:"text-sm",children:i("orderReturnableLines",{count:b.returnableLineCount})})]}),E("div",{className:"flex items-center gap-4",children:[p("span",{"data-bitsnap-returns-slot":"orderTotal",className:u("font-medium",c.className),style:c.style,children:ve(b.totalMinor,b.currency,s)}),p(P,{type:"button",variant:"secondary",size:"sm","aria-label":`${i("orderSelect")}: ${i("orderTitle",{reference:b.displayReference})}`,"data-bitsnap-returns-slot":"secondaryButton",className:u(W,f.className),style:f.style,onClick:()=>e?.(b.canonicalOrderId),children:i("orderSelect")})]})]},b.canonicalOrderId))}),p(He,{page:o.page,total:o.total,hasNext:o.hasNext,hasPrevious:o.hasPrevious,isFetching:o.isFetching,onNext:o.next,onPrevious:o.previous})]})]})}function da({orderId:e,onContinue:t,onBack:n,initialItems:r,initialNote:a,className:i}){D("ReturnsOrderDetail");let s=Ee();Cr(()=>{s.track("return_started",{},{order_ref:null})},[s]);let o=z(),g=Z(),{order:m,returnHistory:l,isLoading:y,errorKey:c,refetch:f}=ut(e),[b,x]=yt(()=>Object.fromEntries((r??[]).map(R=>[R.lineId,R.quantity]))),[v,k]=yt(a??""),[S,w]=yt(!1),h=d("lineList"),C=d("line"),U=d("lineName"),j=d("linePrice"),J=d("lineQuantityControl"),N=d("quantityButton"),Y=d("quantityInput"),A=d("lineIneligibleReason"),_=d("noteInput"),V=d("submitButton"),F=d("history"),re=d("historyEntry");function Se(R,X){w(!1),x(Q=>({...Q,[R.lineId]:xn(X,R.availableQuantity)}))}function B(R){if(R.preventDefault(),m==null)return;let X=vn(m.lines.filter(gt).map(Q=>Q.lineId),b);if(X.length===0){w(!0);return}t?.({items:X,note:v.trim()})}return p(te,{className:i,onBack:n,title:o("orderDetailTitle",{reference:m?.displayReference??""}),description:o("orderDetailDescription"),children:y?p(le,{}):c!=null?p(H,{errorKey:c,onRetry:f}):m==null?null:E("form",{className:"flex flex-col gap-5",onSubmit:B,children:[p("ul",{"data-bitsnap-returns-slot":"lineList",className:u("flex flex-col gap-3",h.className),style:h.style,children:m.lines.map(R=>{let X=gt(R),Q=b[R.lineId]??0,he=`bitsnap-returns-quantity-${R.lineId}`;return E("li",{"data-bitsnap-returns-slot":"line","data-selected":Q>0?"":void 0,"data-ineligible":X?void 0:"",className:u("flex flex-col gap-3 border p-4",C.className),style:C.style,children:[E("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[p("span",{"data-bitsnap-returns-slot":"lineName",className:u("font-medium",U.className),style:U.style,children:R.name}),p("span",{"data-bitsnap-returns-slot":"linePrice",className:u("text-sm",j.className),style:j.style,children:ve(R.paidUnitMinor,R.currency,g)})]}),X?E("div",{role:"group","aria-label":o("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"lineQuantityControl",className:u("flex items-center gap-2",J.className),style:J.style,children:[p(P,{type:"button",variant:"secondary",size:"icon-sm","aria-label":o("quantityDecrease",{name:R.name}),"aria-controls":he,disabled:Q<=0,"data-bitsnap-returns-slot":"quantityButton",className:u(W,N.className),style:N.style,onClick:()=>Se(R,Q-1),children:p("span",{"aria-hidden":"true",children:"-"})}),p("input",{id:he,type:"number",inputMode:"numeric",min:0,max:R.availableQuantity,step:1,value:Q,"aria-label":o("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"quantityInput",className:u("h-8 w-16 rounded-md border px-2 text-center text-sm outline-none focus-visible:ring-[3px]",Re,Y.className),style:Y.style,onChange:Ye=>Se(R,Ye.target.valueAsNumber)}),p(P,{type:"button",variant:"secondary",size:"icon-sm","aria-label":o("quantityIncrease",{name:R.name}),"aria-controls":he,disabled:Q>=R.availableQuantity,"data-bitsnap-returns-slot":"quantityButton",className:u(W,N.className),style:N.style,onClick:()=>Se(R,Q+1),children:p("span",{"aria-hidden":"true",children:"+"})}),p("span",{className:"text-sm",children:o("quantityOfAvailable",{available:R.availableQuantity})})]}):p("p",{"data-bitsnap-returns-slot":"lineIneligibleReason",className:u("text-sm",A.className),style:A.style,children:R.exclusionReason!==""?R.exclusionReason:o("lineIneligibleFallback")})]},R.lineId)})}),E("div",{className:"flex flex-col gap-2",children:[p(Te,{htmlFor:"bitsnap-returns-note",children:o("noteLabel")}),p(Ct,{id:"bitsnap-returns-note",name:"note",rows:3,maxLength:1e3,value:v,placeholder:o("notePlaceholder"),"data-bitsnap-returns-slot":"noteInput",className:u(Re,"dark:border-[color:var(--bitsnap-returns-border,#e4e4e7)] dark:placeholder:text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] dark:focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]",_.className),style:_.style,onChange:R=>k(R.target.value)})]}),S&&p(H,{errorKey:"selectionEmpty"}),p(P,{type:"submit","data-bitsnap-returns-slot":"submitButton",className:u(ce,V.className),style:V.style,children:o("selectionContinue")}),l.length>0&&E("div",{className:"flex flex-col gap-2",children:[p("h3",{className:"text-sm font-medium",children:o("previousReturnsTitle")}),p("ul",{"data-bitsnap-returns-slot":"history",className:u("flex flex-col gap-2",F.className),style:F.style,children:l.map(R=>E("li",{"data-bitsnap-returns-slot":"historyEntry",className:u("flex flex-wrap items-center justify-between gap-2 text-sm",re.className),style:re.style,children:[p("span",{children:R.reference}),p("span",{children:pe(R.createdAt,g)}),p(xe,{status:R.status})]},R.id))})]})]})})}function ca({orderId:e,items:t,note:n,onSubmitted:r,onBack:a,className:i}){D("ReturnsConfirmation");let s=z(),o=Z(),{order:g,isLoading:m,errorKey:l,refetch:y}=ut(e),c=nn(),f=d("summary"),b=d("line"),x=d("lineName"),v=d("linePrice"),k=d("submitButton");async function S(w){if(w.preventDefault(),c.isPending)return;let h=await c.submit({orderId:e,items:t.map(C=>({lineId:C.lineId,quantity:C.quantity})),note:n});h!=null&&r?.(h.id,h)}return p(te,{className:i,onBack:a,title:s("confirmationTitle"),description:s("confirmationDescription"),children:m?p(le,{rows:2}):l!=null?p(H,{errorKey:l,onRetry:y}):E("form",{className:"flex flex-col gap-5",onSubmit:S,children:[E("div",{"data-bitsnap-returns-slot":"summary",className:u("flex flex-col gap-3 border p-4",f.className),style:f.style,children:[p("h3",{className:"text-sm font-medium",children:s("confirmationSummary")}),p("ul",{className:"flex flex-col gap-3",children:t.map(w=>{let h=g?.lines.find(C=>C.lineId===w.lineId);return E("li",{"data-bitsnap-returns-slot":"line",className:u("flex flex-wrap items-baseline justify-between gap-2",b.className),style:b.style,children:[p("span",{"data-bitsnap-returns-slot":"lineName",className:u("font-medium",x.className),style:x.style,children:h?.name??w.lineId}),E("span",{"data-bitsnap-returns-slot":"linePrice",className:u("text-sm",v.className),style:v.style,children:[s("confirmationQuantity",{quantity:w.quantity}),h!=null&&` \xB7 ${ve(h.paidUnitMinor*BigInt(w.quantity),h.currency,o)}`]})]},w.lineId)})}),n!=null&&n!==""&&E("div",{className:"flex flex-col gap-1 text-sm",children:[p("span",{className:"font-medium",children:s("confirmationNote")}),p("span",{className:"whitespace-pre-wrap",children:n})]})]}),c.errorKey!=null&&p(H,{errorKey:c.errorKey}),E(P,{type:"submit",disabled:c.isPending||t.length===0,"data-bitsnap-returns-slot":"submitButton",className:u(ce,k.className),style:k.style,children:[c.isPending&&p(ye,{}),s("confirmationSubmit")]})]})})}function pa({returnId:e,onContinue:t,onOpenMyReturns:n,className:r}){D("ReturnsResult");let a=z(),{request:i,isLoading:s,errorKey:o,refetch:g}=je(e),m=d("successState"),l=d("returnReference"),y=d("returnInstructions"),c=d("submitButton"),f=d("secondaryButton");return E("section",{className:u("flex flex-col gap-5",r),children:[E("div",{role:"status","data-bitsnap-returns-slot":"successState",className:u("flex flex-col gap-4 border p-5",m.className),style:m.style,children:[p("h2",{className:"text-2xl font-semibold",children:a("successTitle")}),p("p",{className:"text-sm",children:a("successDescription")}),s?p(le,{rows:2}):o!=null?p(H,{errorKey:o,onRetry:g}):i!=null&&E(Sn,{children:[E("div",{className:"flex flex-col gap-1",children:[p("span",{className:"text-sm",children:a("successReference")}),p("span",{"data-bitsnap-returns-slot":"returnReference",className:u("text-lg font-semibold",l.className),style:l.style,children:i.reference})]}),i.returnInstructions!==""&&E("div",{className:"flex flex-col gap-1",children:[p("span",{className:"text-sm font-medium",children:a("successInstructions")}),p("p",{"data-bitsnap-returns-slot":"returnInstructions",className:u("whitespace-pre-wrap border p-3 text-sm",y.className),style:y.style,children:i.returnInstructions})]})]})]}),E("div",{className:"flex flex-wrap gap-3",children:[p(P,{type:"button","data-bitsnap-returns-slot":"submitButton",className:u(ce,c.className),style:c.style,onClick:t,children:a("successDone")}),n!=null&&p(P,{type:"button",variant:"secondary","data-bitsnap-returns-slot":"secondaryButton",className:u(W,f.className),style:f.style,onClick:n,children:a("myReturnsLink")})]})]})}import{Fragment as Ir,jsx as I,jsxs as q}from"react/jsx-runtime";function Na({onSelectReturn:e,onBack:t,pageSize:n,className:r}){D("ReturnsMyReturnsList");let a=z(),i=Z(),s=ft(),o=rn({pageSize:n}),g=d("returnList"),m=d("returnCard"),l=d("returnReference"),y=d("secondaryButton");return I(te,{className:r,onBack:t,title:a("myReturnsTitle"),description:a("myReturnsDescription"),children:o.isLoading?I(le,{}):o.errorKey!=null?I(H,{errorKey:o.errorKey,onRetry:o.refetch}):o.returns.length===0?I(We,{children:a("myReturnsEmpty")}):q(Ir,{children:[I("ul",{"data-bitsnap-returns-slot":"returnList",className:u("flex flex-col gap-3",g.className),style:g.style,children:o.returns.map(c=>q("li",{"data-bitsnap-returns-slot":"returnCard",className:u("flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[q("div",{className:"flex flex-col gap-1",children:[I("span",{"data-bitsnap-returns-slot":"returnReference",className:u("font-medium",l.className),style:l.style,children:c.reference}),I("span",{className:"text-sm",children:pe(c.createdAt,i)}),q("span",{className:"text-sm",children:[a("myReturnRefund"),": ",s(c.refundStatus)]})]}),q("div",{className:"flex items-center gap-3",children:[I(xe,{status:c.status}),I(P,{type:"button",variant:"secondary",size:"sm","aria-label":`${a("myReturnOpen")}: ${c.reference}`,"data-bitsnap-returns-slot":"secondaryButton",className:u(W,y.className),style:y.style,onClick:()=>e?.(c.id),children:a("myReturnOpen")})]})]},c.id))}),I(He,{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}=je(e),l=d("summary"),y=d("lineList"),c=d("line"),f=d("lineName"),b=d("returnInstructions"),x=d("history"),v=d("historyEntry");return I(te,{className:n,onBack:t,title:s!=null?r("myReturnTitle",{reference:s.reference}):r("myReturnDetailTitle"),children:o?I(le,{}):g!=null?I(H,{errorKey:g,onRetry:m}):s!=null&&q("div",{className:"flex flex-col gap-5",children:[q("div",{"data-bitsnap-returns-slot":"summary",className:u("flex flex-col gap-2 border p-4 text-sm",l.className),style:l.style,children:[q("div",{className:"flex items-center justify-between gap-2",children:[I(xe,{status:s.status}),q("span",{children:[r("myReturnCreatedAt"),":"," ",pe(s.createdAt,a)]})]}),q("span",{children:[r("myReturnRefund"),": ",i(s.refundStatus),s.refundAmountMinor>BigInt(0)&&` \xB7 ${ve(s.refundAmountMinor,s.currency,a)}`]}),s.customerNote!==""&&q("span",{className:"whitespace-pre-wrap",children:[r("myReturnNote"),": ",s.customerNote]})]}),s.returnInstructions!==""&&I("p",{"data-bitsnap-returns-slot":"returnInstructions",className:u("whitespace-pre-wrap border p-3 text-sm",b.className),style:b.style,children:s.returnInstructions}),q("div",{className:"flex flex-col gap-2",children:[I("h3",{className:"text-sm font-medium",children:r("myReturnLines")}),I("ul",{"data-bitsnap-returns-slot":"lineList",className:u("flex flex-col gap-3",y.className),style:y.style,children:s.lines.map(k=>q("li",{"data-bitsnap-returns-slot":"line",className:u("flex flex-wrap items-baseline justify-between gap-2 border p-4",c.className),style:c.style,children:[I("span",{"data-bitsnap-returns-slot":"lineName",className:u("font-medium",f.className),style:f.style,children:k.name}),I("span",{className:"text-sm",children:r("myReturnLineQuantities",{requested:k.requestedQuantity,approved:k.approvedQuantity,received:k.receivedQuantity})})]},k.lineId))})]}),s.history.length>0&&q("div",{className:"flex flex-col gap-2",children:[I("h3",{className:"text-sm font-medium",children:r("myReturnHistory")}),I("ul",{"data-bitsnap-returns-slot":"history",className:u("flex flex-col gap-2",x.className),style:x.style,children:s.history.map(k=>q("li",{"data-bitsnap-returns-slot":"historyEntry",className:u("flex flex-wrap items-center justify-between gap-2 text-sm",v.className),style:v.style,children:[I(xe,{status:k.status}),I("span",{children:pe(k.createdAt,a)})]},k.id))})]})]})})}export{Zt as a,pr as b,ct as c,Te as d,ye as e,Ut as f,xr as g,eo as h,pt as i,ao as j,fn as k,Pr as l,Ot as m,Ge as n,d as o,ot as p,Xt as q,z as r,Z as s,D as t,Xn as u,ls as v,Fe as w,tn as x,ut as y,nn as z,rn as A,je as B,le as C,Ko as D,jo as E,la as F,da as G,ca as H,pa as I,Na as J,Ta as K};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as It,b as Lt}from"./chunk-KOVKUJAW.mjs";import{b as St,d as Ze,e as ie,f as ht,h as kt,i as Nt,k as P,l as Tt,n as wt,o as Et,p as Ct}from"./chunk-TMEII7BM.mjs";import{a as u}from"./chunk-5R6AGO3Z.mjs";import{l as Rt,m as Ee,n as xt}from"./chunk-J6WKSO33.mjs";import{a as Ce,b as vt,f as Ie}from"./chunk-OFPRIENJ.mjs";var Pr=["root","header","title","description","backButton","stepIndicator","error","emptyState","skeleton","emailForm","emailInput","codeForm","codeInput","resendButton","logoutButton","orderList","orderCard","orderReference","orderDate","orderTotal","pagination","lineList","line","lineName","linePrice","lineQuantityControl","quantityButton","quantityInput","lineIneligibleReason","noteInput","summary","submitButton","secondaryButton","successState","returnReference","returnInstructions","returnList","returnCard","statusBadge","history","historyEntry"],Tn={fontFamily:"--bitsnap-returns-font-family",fontSize:"--bitsnap-returns-font-size",background:"--bitsnap-returns-background",surface:"--bitsnap-returns-surface",foreground:"--bitsnap-returns-foreground",mutedForeground:"--bitsnap-returns-muted-foreground",border:"--bitsnap-returns-border",buttonBackground:"--bitsnap-returns-button-background",buttonForeground:"--bitsnap-returns-button-foreground",buttonHoverBackground:"--bitsnap-returns-button-hover-background",hoverSurface:"--bitsnap-returns-hover-surface",focusRing:"--bitsnap-returns-focus-ring",error:"--bitsnap-returns-error",success:"--bitsnap-returns-success",warning:"--bitsnap-returns-warning",badgeBackground:"--bitsnap-returns-badge-background",badgeForeground:"--bitsnap-returns-badge-foreground",inputBackground:"--bitsnap-returns-input-background",radius:"--bitsnap-returns-radius"},wn={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",success:"#16a34a",warning:"#d97706",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",inputBackground:"#ffffff",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",success:"#4ade80",warning:"#fbbf24",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",inputBackground:"#27272a",radius:"8px"}},En=[{token:"background",variable:"--background"},{token:"foreground",variable:"--foreground"},{token:"surface",variable:"--card"},{token:"foreground",variable:"--card-foreground"},{token:"surface",variable:"--popover"},{token:"foreground",variable:"--popover-foreground"},{token:"buttonBackground",variable:"--primary"},{token:"buttonForeground",variable:"--primary-foreground"},{token:"surface",variable:"--secondary"},{token:"foreground",variable:"--secondary-foreground"},{token:"hoverSurface",variable:"--accent"},{token:"foreground",variable:"--accent-foreground"},{token:"mutedForeground",variable:"--muted-foreground"},{token:"border",variable:"--border"},{token:"border",variable:"--input"},{token:"focusRing",variable:"--ring"},{token:"error",variable:"--destructive"},{token:"radius",variable:"--radius"}];function $e(e){let t=It(e,{defaultTheme:"light",presets:wn,variables:Tn,shadcnVariables:En});return{theme:t.theme,tokens:t.tokens,elements:t.elements,boundaryClassName:t.theme,boundaryStyle:t.boundaryStyle}}function Pt(e,t){return Lt(e.elements,t)}import{createContext as Cn,useContext as In,useMemo as Ln}from"react";import{jsx as Pn}from"react/jsx-runtime";var At=Cn($e());function Ot({appearance:e,children:t}){let n=Ln(()=>$e(e),[e]);return Pn(At.Provider,{value:n,children:t})}function Ge(){return In(At)}function d(e){let t=Ge();return Pt(t,e)??{}}function Bt(e){return e==="test"||e===1?1:0}var zt={title:["emailStepTitle"],email:["emailLabel"],sendCode:["emailSubmit"],code:["codeLabel"],verify:["codeSubmit"],orders:["ordersTitle"],submit:["confirmationSubmit"],note:["noteLabel"],history:["myReturnsTitle","myReturnsLink"]};function Mt(e){if(e==null)return;let t={};for(let[n,r]of Object.entries(zt)){let a=e[n];if(typeof a=="string")for(let i of r)t[i]=a}for(let n of Object.keys(e)){if(n in zt)continue;let r=e[n];typeof r=="string"&&(t[n]=r)}return t}function Dt(e,t){let n=t?.brandColor?.trim();return n==null||n===""?e:{...e,tokens:{...wt(n),...e?.tokens}}}function Xe(e,t){return typeof e=="object"&&e!=null?{pageSize:e.pageSize??20,explicitPageToken:void 0}:typeof e=="number"||t!==void 0?{pageSize:e??20,explicitPageToken:t??""}:{pageSize:20,explicitPageToken:void 0}}var An={en:{back:"Back",stepIndicator:"Step {current} of {total}",loading:"Loading",myReturnsLink:"My returns",emailStepTitle:"Return a product",emailStepDescription:"Enter the email address you used for the order. We will send you a verification code.",emailLabel:"Email address",emailPlaceholder:"name@example.com",emailSubmit:"Send code",codeStepTitle:"Enter the code",codeStepDescription:"We sent a verification code to {email}.",codeLabel:"Verification code",codeSubmit:"Verify",resend:"Send the code again",resendIn:"Send again in {seconds} s",resendSent:"We sent a new code.",codeSpamHint:"Can't see the email? Check your spam folder.",codeValidity:"The code is valid for 10 minutes.",codeIncomplete:"Enter all 6 digits of the code.",logout:"Sign out",ordersTitle:"Your orders",ordersDescription:"Choose the order that contains the product to return.",ordersEmpty:"There are no orders eligible for return.",orderTitle:"Order {reference}",orderReturnableLines:"Products available to return: {count}",orderSelect:"Choose",paginationPrevious:"Previous",paginationNext:"Next",paginationInfo:"Page {page}, {total} orders",orderDetailTitle:"Order {reference}",orderDetailDescription:"Select the products and quantities to return.",quantityLabel:"Quantity to return: {name}",quantityDecrease:"Decrease quantity: {name}",quantityIncrease:"Increase quantity: {name}",quantityOfAvailable:"of {available}",lineIneligibleFallback:"This product cannot be returned.",noteLabel:"Note (optional)",notePlaceholder:"Tell us why you are returning the product",selectionContinue:"Continue",selectionEmpty:"Select at least one item to return.",previousReturnsTitle:"Earlier returns for this order",confirmationTitle:"Confirm the return",confirmationDescription:"Check the products before you submit the request.",confirmationSummary:"Products to return",confirmationQuantity:"Quantity: {quantity}",confirmationNote:"Your note",confirmationSubmit:"Submit return request",successTitle:"Return request submitted",successDescription:"We received your request and will keep you posted.",successReference:"Request number",successInstructions:"What to do next",successDone:"Back to orders",myReturnsTitle:"My returns",myReturnsDescription:"Track the status of your return requests.",myReturnsEmpty:"You have not submitted any return requests yet.",myReturnOpen:"Details",myReturnDetailTitle:"Return details",myReturnTitle:"Return {reference}",myReturnCreatedAt:"Submitted",myReturnRefund:"Refund",myReturnLines:"Products",myReturnLineQuantities:"Requested: {requested}, approved: {approved}, received: {received}",myReturnNote:"Your note",myReturnHistory:"History",statusSubmitted:"Submitted",statusApproved:"Approved",statusRejected:"Rejected",statusAwaitingReceipt:"Awaiting the package",statusReceived:"Package received",statusCompleted:"Completed",statusCancelled:"Cancelled",statusRefunded:"Refunded",statusFallback:"In progress",refundStatusNotStarted:"Not started",refundStatusPending:"Refund in progress",refundStatusSucceeded:"Refunded",refundStatusFailed:"Refund failed",refundStatusFallback:"Unknown",errorGeneric:"Something went wrong. Please try again.",errorNetwork:"Cannot reach the server. Check your connection and try again.",errorInvalidEmail:"Enter a valid email address.",errorInvalidCode:"The code is invalid or has expired.",errorSessionExpired:"Your session has expired. Verify your email again.",errorOrderNotFound:"We could not find this order.",errorReturnNotFound:"We could not find this return request.",errorQuantityUnavailable:"The selected quantity is no longer available for return.",errorItemNotReturnable:"One of the selected products cannot be returned.",errorReturnsDisabled:"Returns are not available in this shop.",errorRateLimited:"Too many attempts. Please try again later.",errorIdempotencyConflict:"This request was already submitted with different contents. Reload and try again.",errorDeliveryFailed:"We could not send the code. Please try again.",errorRetry:"Try again"},pl:{back:"Wstecz",stepIndicator:"Krok {current} z {total}",loading:"\u0141adowanie",myReturnsLink:"Moje zwroty",emailStepTitle:"Zwr\xF3\u0107 produkt",emailStepDescription:"Podaj adres e-mail u\u017Cyty w zam\xF3wieniu. Wy\u015Blemy na niego kod weryfikacyjny.",emailLabel:"Adres e-mail",emailPlaceholder:"jan@example.com",emailSubmit:"Wy\u015Blij kod",codeStepTitle:"Wpisz kod",codeStepDescription:"Wys\u0142ali\u015Bmy kod weryfikacyjny na adres {email}.",codeLabel:"Kod weryfikacyjny",codeSubmit:"Zweryfikuj",resend:"Wy\u015Blij kod ponownie",resendIn:"Wy\u015Blij ponownie za {seconds} s",resendSent:"Wys\u0142ali\u015Bmy nowy kod.",codeSpamHint:"Nie widzisz e-maila? Sprawd\u017A folder spam.",codeValidity:"Kod jest wa\u017Cny 10 minut.",codeIncomplete:"Wpisz wszystkie 6 cyfr kodu.",logout:"Wyloguj si\u0119",ordersTitle:"Twoje zam\xF3wienia",ordersDescription:"Wybierz zam\xF3wienie z produktem do zwrotu.",ordersEmpty:"Brak zam\xF3wie\u0144, kt\xF3re mo\u017Cna zwr\xF3ci\u0107.",orderTitle:"Zam\xF3wienie {reference}",orderReturnableLines:"Produkty do zwrotu: {count}",orderSelect:"Wybierz",paginationPrevious:"Poprzednia",paginationNext:"Nast\u0119pna",paginationInfo:"Strona {page}, zam\xF3wie\u0144: {total}",orderDetailTitle:"Zam\xF3wienie {reference}",orderDetailDescription:"Wybierz produkty i ilo\u015Bci do zwrotu.",quantityLabel:"Ilo\u015B\u0107 do zwrotu: {name}",quantityDecrease:"Zmniejsz ilo\u015B\u0107: {name}",quantityIncrease:"Zwi\u0119ksz ilo\u015B\u0107: {name}",quantityOfAvailable:"z {available}",lineIneligibleFallback:"Ten produkt nie podlega zwrotowi.",noteLabel:"Uwagi (opcjonalnie)",notePlaceholder:"Napisz, dlaczego zwracasz produkt",selectionContinue:"Dalej",selectionEmpty:"Wybierz co najmniej jedn\u0105 sztuk\u0119 do zwrotu.",previousReturnsTitle:"Wcze\u015Bniejsze zwroty tego zam\xF3wienia",confirmationTitle:"Potwierd\u017A zwrot",confirmationDescription:"Sprawd\u017A produkty przed wys\u0142aniem zg\u0142oszenia.",confirmationSummary:"Produkty do zwrotu",confirmationQuantity:"Ilo\u015B\u0107: {quantity}",confirmationNote:"Twoje uwagi",confirmationSubmit:"Wy\u015Blij zg\u0142oszenie zwrotu",successTitle:"Zg\u0142oszenie zwrotu zosta\u0142o wys\u0142ane",successDescription:"Otrzymali\u015Bmy zg\u0142oszenie i b\u0119dziemy informowa\u0107 o jego statusie.",successReference:"Numer zg\u0142oszenia",successInstructions:"Co dalej",successDone:"Wr\xF3\u0107 do zam\xF3wie\u0144",myReturnsTitle:"Moje zwroty",myReturnsDescription:"Sprawd\u017A status swoich zg\u0142osze\u0144 zwrotu.",myReturnsEmpty:"Nie masz jeszcze \u017Cadnych zg\u0142osze\u0144 zwrotu.",myReturnOpen:"Szczeg\xF3\u0142y",myReturnDetailTitle:"Szczeg\xF3\u0142y zwrotu",myReturnTitle:"Zwrot {reference}",myReturnCreatedAt:"Zg\u0142oszono",myReturnRefund:"Zwrot \u015Brodk\xF3w",myReturnLines:"Produkty",myReturnLineQuantities:"Zg\u0142oszono: {requested}, zaakceptowano: {approved}, odebrano: {received}",myReturnNote:"Twoje uwagi",myReturnHistory:"Historia",statusSubmitted:"Zg\u0142oszony",statusApproved:"Zaakceptowany",statusRejected:"Odrzucony",statusAwaitingReceipt:"Oczekiwanie na paczk\u0119",statusReceived:"Paczka odebrana",statusCompleted:"Zako\u0144czony",statusCancelled:"Anulowany",statusRefunded:"\u015Arodki zwr\xF3cone",statusFallback:"W trakcie",refundStatusNotStarted:"Nie rozpocz\u0119to",refundStatusPending:"Zwrot \u015Brodk\xF3w w toku",refundStatusSucceeded:"\u015Arodki zwr\xF3cone",refundStatusFailed:"Zwrot \u015Brodk\xF3w nie powi\xF3d\u0142 si\u0119",refundStatusFallback:"Nieznany",errorGeneric:"Co\u015B posz\u0142o nie tak. Spr\xF3buj ponownie.",errorNetwork:"Brak po\u0142\u0105czenia z serwerem. Sprawd\u017A internet i spr\xF3buj ponownie.",errorInvalidEmail:"Podaj poprawny adres e-mail.",errorInvalidCode:"Kod jest nieprawid\u0142owy lub wygas\u0142.",errorSessionExpired:"Sesja wygas\u0142a. Zweryfikuj adres e-mail ponownie.",errorOrderNotFound:"Nie znaleziono tego zam\xF3wienia.",errorReturnNotFound:"Nie znaleziono tego zg\u0142oszenia zwrotu.",errorQuantityUnavailable:"Wybrana ilo\u015B\u0107 nie jest ju\u017C dost\u0119pna do zwrotu.",errorItemNotReturnable:"Jeden z wybranych produkt\xF3w nie podlega zwrotowi.",errorReturnsDisabled:"Zwroty nie s\u0105 dost\u0119pne w tym sklepie.",errorRateLimited:"Zbyt wiele pr\xF3b. Spr\xF3buj ponownie p\xF3\u017Aniej.",errorIdempotencyConflict:"To zg\u0142oszenie zosta\u0142o ju\u017C wys\u0142ane z inn\u0105 zawarto\u015Bci\u0105. Od\u015Bwie\u017C stron\u0119 i spr\xF3buj ponownie.",errorDeliveryFailed:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu. Spr\xF3buj ponownie.",errorRetry:"Spr\xF3buj ponownie"}};function Je(e,t){return vt(An,e,t)}function Ft(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>Object.prototype.hasOwnProperty.call(t,r)?String(t[r]):n)}var On={submitted:"statusSubmitted",approved:"statusApproved",rejected:"statusRejected",awaiting_receipt:"statusAwaitingReceipt",received:"statusReceived",completed:"statusCompleted",cancelled:"statusCancelled",refunded:"statusRefunded"},zn={not_started:"refundStatusNotStarted",pending:"refundStatusPending",succeeded:"refundStatusSucceeded",failed:"refundStatusFailed"};function Kt(e){return On[e]??"statusFallback"}function jt(e){return zn[e]??"refundStatusFallback"}import{createContext as Bn,useCallback as Mn,useContext as _t,useMemo as Dn}from"react";import{jsx as Fn}from"react/jsx-runtime";var et=Bn({locale:"pl-PL",texts:Je("pl-PL")});function qt({texts:e,locale:t,children:n}){let r=t??Ie(),a=Dn(()=>({locale:r,texts:Je(r,e)}),[r,e]);return Fn(et.Provider,{value:a,children:n})}function z(){let{texts:e}=_t(et);return Mn((t,n)=>n==null?e[t]:Ft(e[t],n),[e])}function Z(){return _t(et).locale}import{createClient as _n}from"@connectrpc/connect";import{createConnectQueryKey as qn,TransportProvider as Un}from"@connectrpc/connect-query";import{QueryClient as Vn,QueryClientContext as Qn,QueryClientProvider as Wn,useQueryClient as Hn}from"@tanstack/react-query";import{createContext as Yn,useCallback as ze,useContext as Ht,useEffect as Wt,useMemo as Be,useRef as Zn,useState as ke}from"react";function tt(){try{return typeof window<"u"?window.sessionStorage:void 0}catch{return}}function Ut(e,t,n){return`bitsnap-login-pending:${e}:${encodeURIComponent(n??"")}:${encodeURIComponent(t??"")}`}function Le(e,t){try{tt()?.setItem(e,JSON.stringify(t))}catch{}}function me(e){try{tt()?.removeItem(e)}catch{}}function Pe(e,t=Date.now()){let n=tt();if(n!=null)try{let r=n.getItem(e);if(r==null)return;let a=JSON.parse(r);if(a!=null&&typeof a.email=="string"&&a.email!==""&&typeof a.sentAt=="number"&&typeof a.resendAt=="number"&&(a.challengeId==null||typeof a.challengeId=="string")&&t-a.sentAt<6e5)return{email:a.email,challengeId:a.challengeId,resendAt:a.resendAt,sentAt:a.sentAt};n.removeItem(e)}catch{try{n.removeItem(e)}catch{}}}import{timestampMs as Kn}from"@bufbuild/protobuf/wkt";var jn="bitsnap-returns-session:";function nt(e){return`${jn}${e}`}function Ae(){try{return typeof window<"u"?window.sessionStorage:void 0}catch{return}}function Vt(e,t,n=Date.now()){if(e==null)return;let r=nt(t);try{let a=e.getItem(r);if(a==null)return;let i=JSON.parse(a);if(i!=null&&typeof i=="object"&&typeof i.token=="string"&&i.token.length>0&&typeof i.expiresAt=="number"&&i.expiresAt>n){let{token:s,expiresAt:o}=i;return{token:s,expiresAt:o}}e.removeItem(r)}catch{try{e.removeItem(r)}catch{}}}function Qt(e,t,n){try{e?.setItem(nt(t),JSON.stringify(n))}catch{}}function rt(e,t){try{e?.removeItem(nt(t))}catch{}}function Oe(e){return e==null?void 0:Kn(e)}import{jsx as ue}from"react/jsx-runtime";var Yt=Yn(void 0);function D(e){let t=Ht(Yt);if(t==null)throw new Error(`${e} must be rendered inside <ReturnsProvider>`);return t}function st(){return qn({schema:Ze,cardinality:void 0})}var $n=2**31-1;function Gn({projectID:e,environment:t,transport:n,panelAccessToken:r,className:a,children:i}){let s=Hn(),{boundaryClassName:o,boundaryStyle:g}=Ge(),m=d("root"),[l,y]=ke({status:"hydrating"}),[c,f]=ke(),[b,x]=ke(),[v,k]=ke(),S=Ut("returns",e),w=Zn(void 0),h=ze(N=>{if(x(N),N==null){me(S);return}k(N.email),Le(S,{email:N.email,challengeId:N.challengeId,resendAt:N.resendAvailableAt,sentAt:Date.now()})},[S]),C=ze(()=>{s.removeQueries({queryKey:st()})},[s]),U=ze(()=>{rt(Ae(),e),h(void 0),y({status:"anonymous"}),C()},[e,C,h]),j=ze(N=>{Qt(Ae(),e,N),f(void 0),h(void 0),y({status:"authenticated",token:N.token,expiresAt:N.expiresAt})},[e,h]);Wt(()=>{let N=!1,Y=Ae();if(r==null||r===""){let A=w.current!=null;if(w.current=void 0,A){U();return}let _=Vt(Y,e),V=_==null?Pe(S):void 0;V?.challengeId!=null&&(x({challengeId:V.challengeId,email:V.email,resendAvailableAt:V.resendAt}),k(V.email)),y(_!=null?{status:"authenticated",token:_.token,expiresAt:_.expiresAt}:{status:"anonymous"});return}return w.current=r,rt(Y,e),C(),f(void 0),y({status:"exchanging"}),_n(Ze,n).exchangePanelSession({projectId:e,accessToken:r,environment:t}).then(A=>{if(N)return;let _=Oe(A.expiresAt);if(A.sessionToken===""||_==null)throw new Error("EMPTY_SESSION");j({token:A.sessionToken,expiresAt:_})}).catch(A=>{N||(f(A),y({status:"anonymous"}))}),()=>{N=!0}},[r,e,t,n]),Wt(()=>{if(l.status!=="authenticated"||l.expiresAt==null)return;let N=l.expiresAt-Date.now();if(N<=0){U();return}let Y=setTimeout(U,Math.min(N,$n));return()=>clearTimeout(Y)},[l.status,l.expiresAt,U]);let J=Be(()=>({projectID:e,environment:t,status:l.status,token:l.token,exchangeError:c,challenge:b,setChallenge:h,lastEmail:v,authenticate:j,clearSession:U}),[e,t,l.status,l.token,c,b,h,v,j,U]);return ue(Yt.Provider,{value:J,children:ue("div",{"data-bitsnap-returns":"root","data-bitsnap-returns-slot":"root",className:u("bitsnap-react",o,a,m.className),style:{...g,...m.style},children:i})})}function Xn({projectID:e,host:t,environment:n,appearance:r,texts:a,theme:i,locale:s,panelAccessToken:o,className:g,analytics:m,children:l}){let y=xt(e,m,"returns"),c=Ht(Qn),[f]=ke(()=>c==null?new Vn({defaultOptions:{queries:{staleTime:5e3}}}):void 0),b=t??kt(),x=Be(()=>Nt(b),[b]),v=i?.brandColor,k=Be(()=>Dt(r,{brandColor:v}),[r,v]),S=Be(()=>Mt(a),[a]),w=ue(Rt,{value:y,children:ue(Un,{transport:x,children:ue(Ot,{appearance:k,children:ue(qt,{texts:S,locale:s,children:ue(Gn,{projectID:e,environment:Bt(n),transport:x,panelAccessToken:o,className:g,children:l})})})})});return c==null&&f!=null?ue(Wn,{client:f,children:w}):w}var ls=Xn;import{useMutation as it,useQuery as Me}from"@connectrpc/connect-query";import{useQueryClient as rr}from"@tanstack/react-query";import{useCallback as oe,useEffect as Jt,useRef as sr,useState as or}from"react";import{Code as er,ConnectError as tr}from"@connectrpc/connect";import{Code as Ne,ConnectError as Jn}from"@connectrpc/connect";function Zt(e){let t=Jn.from(e);switch(t.code){case Ne.ResourceExhausted:return"rateLimited";case Ne.Unavailable:case Ne.DeadlineExceeded:case Ne.Canceled:return"network";case Ne.Unknown:return e instanceof TypeError||t.cause instanceof TypeError?"network":"unknown";default:return"unknown"}}var nr="SESSION_EXPIRED",$t={INVALID_EMAIL:"errorInvalidEmail",INVALID_OR_EXPIRED_CODE:"errorInvalidCode",SESSION_EXPIRED:"errorSessionExpired",ORDER_NOT_FOUND:"errorOrderNotFound",RETURN_NOT_FOUND:"errorReturnNotFound",QUANTITY_UNAVAILABLE:"errorQuantityUnavailable",ITEM_NOT_RETURNABLE:"errorItemNotReturnable",INVALID_RETURN_ITEMS:"errorItemNotReturnable",RETURNS_DISABLED:"errorReturnsDisabled",SUBMISSION_RATE_LIMITED:"errorRateLimited",IDEMPOTENCY_CONFLICT:"errorIdempotencyConflict",VERIFICATION_DELIVERY_FAILED:"errorDeliveryFailed"};function Gt(e){if(e==null||typeof e!="object")return;let{rawMessage:t,message:n}=e;if(typeof t=="string"&&t.length>0)return t;if(typeof n=="string")return Object.keys($t).find(r=>n.includes(r))}function ot(e){return Gt(e)===nr}function Xt(e){let t=Gt(e),n=t!=null?$t[t]:void 0;if(n!=null)return n;if(e!=null&&typeof e=="object"){if(tr.from(e).code===er.ResourceExhausted)return"errorRateLimited";if(Zt(e)==="network")return"errorNetwork"}return"errorGeneric"}function at(){let e=typeof globalThis<"u"?globalThis.crypto:void 0;if(typeof e?.randomUUID=="function")return e.randomUUID();let t=new Uint8Array(16);if(typeof e?.getRandomValues=="function")e.getRandomValues(t);else for(let n=0;n<t.length;n++)t[n]=Math.floor(Math.random()*256);return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function fe(e){return e==null?null:e instanceof Error?e:new Error(String(e))}function ge(e){return e==null?void 0:Xt(e)}function De(e,t){Jt(()=>{ot(e)&&t()},[e,t])}function en(e){let[t,n]=or([""]);return Jt(()=>{n([""])},[e]),{pageToken:t[t.length-1]??"",page:t.length,push:r=>n(a=>[...a,r]),pop:()=>n(r=>r.length>1?r.slice(0,-1):r)}}function Fe(){let e=D("useReturnSession"),t=it(ie.returns.startReturnSession),n=it(ie.returns.verifyReturnSession),{setChallenge:r,authenticate:a,clearSession:i}=e,s=Z().toLowerCase().startsWith("en")?"en":"pl",o=oe(async f=>{n.reset();let b=f.trim(),x=await t.mutateAsync({projectId:e.projectID,email:b,environment:e.environment,locale:s});return r({challengeId:x.challengeId,email:b,resendAvailableAt:Date.now()+Math.max(0,x.resendAfterSeconds)*1e3}),x},[e.projectID,e.environment,s,r,t,n]),g=oe(async f=>{let b=await n.mutateAsync({projectId:e.projectID,challengeId:f.challengeId,code:f.code,environment:e.environment}),x=Oe(b.expiresAt);if(b.sessionToken===""||x==null)throw new Error("EMPTY_SESSION");return a({token:b.sessionToken,expiresAt:x}),b},[e.projectID,e.environment,a,n]),m=oe(async f=>{try{return await o(f),!0}catch{return!1}},[o]),l=oe(async f=>{if(e.challenge==null)return!1;try{return await g({challengeId:e.challenge.challengeId,code:f.trim()}),!0}catch{return!1}},[e.challenge,g]),y=oe(()=>e.challenge!=null?m(e.challenge.email):Promise.resolve(!1),[e.challenge,m]),c=fe(t.error??n.error??e.exchangeError);return{status:e.status,isAuthenticated:e.status==="authenticated",challenge:e.challenge,isStarting:t.isPending,isVerifying:n.isPending,starting:t.isPending,verifying:n.isPending,error:c,errorKey:ge(c),start:m,startSession:o,verifySession:g,verify:l,resend:y,logout:i}}function Ke(e){return e.status==="hydrating"||e.status==="exchanging"}function tn(e,t){let n=D("useReturnOrders"),{pageSize:r,explicitPageToken:a}=Xe(e,t),i=en(n.token),s=Me(ie.returns.listReturnOrders,{projectId:n.projectID,sessionToken:n.token??"",pageSize:r,pageToken:a??i.pageToken},{enabled:n.token!=null});De(s.error,n.clearSession);let o=s.data?.nextPageToken??"";return{orders:s.data?.orders??[],total:s.data?.total??0,data:s.data,isLoading:Ke(n)||s.isLoading,isFetching:s.isFetching,error:fe(s.error),errorKey:ge(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:i.page,hasNext:o!=="",hasPrevious:i.page>1,next:()=>{o!==""&&i.push(o)},previous:i.pop,refetch:()=>s.refetch()}}function ut(e){let t=D("useReturnableOrder"),n=Me(ie.returns.getReturnableOrder,{projectId:t.projectID,sessionToken:t.token??"",canonicalOrderId:e??""},{enabled:t.token!=null&&e!=null&&e!==""});return De(n.error,t.clearSession),{order:n.data?.order,returnHistory:n.data?.returnHistory??[],data:n.data,isLoading:e!=null&&e!==""&&(Ke(t)||n.isLoading),error:fe(n.error),errorKey:ge(n.error),status:n.status,isError:n.isError,isSuccess:n.isSuccess,refetch:()=>n.refetch()}}function nn(){let e=D("useCreateReturn"),t=rr(),n=it(ie.returns.createReturnRequest),r=Ee(),a=sr(void 0),{clearSession:i}=e,s=oe(async(l,y)=>{try{let c=await n.mutateAsync({projectId:e.projectID,sessionToken:e.token??"",canonicalOrderId:l.orderId,items:l.items,note:l.note??"",idempotencyKey:y});return t.invalidateQueries({queryKey:st()}),r.track("return_submitted",{reason_code:"unspecified",item_count:l.items.length},{order_ref:null}),c}catch(c){throw ot(c)&&i(),c}},[e.projectID,e.token,n,t,i,r]),o=oe(async l=>{a.current??=at();try{let y=await s(l,a.current);return a.current=void 0,y.request}catch{return}},[s]),g=oe(async l=>{if(e.token==null)throw new Error("Verify your email to continue.");return s({orderId:l.canonicalOrderID,items:l.items,note:l.note},l.idempotencyKey??at())},[e.token,s]),m=oe((l,y)=>{g(l).then(c=>y?.onSuccess?.(c),c=>y?.onError?.(fe(c)))},[g]);return{submit:o,isPending:n.isPending,error:fe(n.error),errorKey:ge(n.error),mutateAsync:g,mutate:m,data:n.data,reset:n.reset,status:n.status,isError:n.isError,isSuccess:n.isSuccess}}function rn(e,t){let n=D("useMyReturns"),{pageSize:r,explicitPageToken:a}=Xe(e,t),i=en(n.token),s=Me(ie.returns.listMyReturns,{projectId:n.projectID,sessionToken:n.token??"",pageSize:r,pageToken:a??i.pageToken},{enabled:n.token!=null});De(s.error,n.clearSession);let o=s.data?.nextPageToken??"";return{returns:s.data?.returns??[],total:s.data?.total??0,data:s.data,isLoading:Ke(n)||s.isLoading,isFetching:s.isFetching,error:fe(s.error),errorKey:ge(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:i.page,hasNext:o!=="",hasPrevious:i.page>1,next:()=>{o!==""&&i.push(o)},previous:i.pop,refetch:()=>s.refetch()}}function je(e){let t=D("useMyReturn"),n=Me(ie.returns.getMyReturn,{projectId:t.projectID,sessionToken:t.token??"",returnId:e},{enabled:t.token!=null});return De(n.error,t.clearSession),{request:n.data?.request,isLoading:Ke(t)||n.isLoading,error:n.error,errorKey:ge(n.error),refetch:()=>n.refetch()}}import{useEffect as wr,useRef as yn,useState as we}from"react";import*as sn from"@radix-ui/react-label";import{jsx as ar}from"react/jsx-runtime";function Te({className:e,...t}){return ar(sn.Root,{"data-slot":"label",className:u("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}import{Loader2Icon as ir}from"lucide-react";import{jsx as ur}from"react/jsx-runtime";function ye({className:e,...t}){return ur(ir,{role:"status","aria-label":"Loading",className:u("size-4 animate-spin",e),...t})}import{useState as lr}from"react";import{Fragment as mr,jsx as ee,jsxs as on}from"react/jsx-runtime";var dr={pl:{alt:"Logo sklepu"},en:{alt:"Shop logo"}},lt="flex h-10 items-center",dt="block max-h-10 max-w-48 w-auto object-contain";function cr(){return on("span",{role:"img","aria-label":"Bitsnap",className:"inline-flex items-center gap-1.5",children:[ee("svg",{"aria-hidden":"true",width:"29",height:"27",viewBox:"0 0 33 30",fill:"none",stroke:"currentColor",strokeWidth:"3.04",strokeLinecap:"round",children:ee("path",{d:"M20.2 1.8h0M22.8 6.2h0M22.8 10.6h0M22.8 15h0M22.8 19.4h0M22.8 23.8h0M20.2 28.2h0M27.1 10.6h0M27.1 15h0M27.1 19.4h0M31.5 15h0M1.5 1.8h0M5.4 1.8h0M9.3 1.8h0M13.2 1.8h0M5.4 15h0M9.3 15h0M13.2 15h0M5.4 28.2h0M9.3 28.2h0M13.2 28.2h0M1.5 6.2h0M1.5 10.6h0M1.5 15h0M1.5 19.4h0M1.5 23.8h0M1.5 28.2h0M16.7 19.4h0M16.7 23.8h0M16.7 6.2h0M16.7 10.6h0"})}),ee("span",{"aria-hidden":"true",className:"text-xl tracking-wider",children:"bitsnap."})]})}function pr(e,t){return ht(St,{projectId:e},{enabled:t,staleTime:1/0,retry:!1,refetchOnWindowFocus:!1})}function ct({projectId:e,name:t,locale:n,showLogo:r=!0,logoUrl:a,logoDarkUrl:i,className:s}){let[o,g]=lr([]),m=a||i,l=e?.trim()??"",{data:y,isPending:c}=pr(l,r&&!m&&l!=="");if(!r)return null;if(!m&&l!==""&&c)return ee("div",{className:u(lt,s),"aria-hidden":"true"});let f=(m?a||i:y?.logoUrl||y?.logoDarkUrl)||"",b=(m?i||a:y?.logoDarkUrl||y?.logoUrl)||"",x=h=>h!==""&&!o.includes(h),v=x(f)?f:x(b)?b:"",k=x(b)?b:x(f)?f:"";if(v===""&&k==="")return ee("div",{className:u(lt,s),children:ee(cr,{})});let S=t||y?.name||Ce(dr,n??Ie()).alt,w=h=>()=>g(C=>C.includes(h)?C:[...C,h]);return ee("div",{className:u(lt,s),children:v===k?ee("img",{src:v,alt:S,className:dt,draggable:!1,onError:w(v)}):on(mr,{children:[ee("img",{src:v,alt:S,className:u(dt,"dark:hidden"),draggable:!1,onError:w(v)}),ee("img",{src:k,alt:S,className:u(dt,"hidden dark:block"),draggable:!1,onError:w(k)})]})})}import{REGEXP_ONLY_DIGITS as hr}from"input-otp";import{useCallback as kr}from"react";import*as an from"react";import{OTPInput as fr,OTPInputContext as gr}from"input-otp";import{MinusIcon as Hs}from"lucide-react";import{jsx as _e,jsxs as yr}from"react/jsx-runtime";function un({className:e,containerClassName:t,...n}){return _e(fr,{"data-slot":"input-otp",containerClassName:u("flex items-center gap-2 has-disabled:opacity-50",t),className:u("disabled:cursor-not-allowed",e),...n})}function ln({className:e,...t}){return _e("div",{"data-slot":"input-otp-group",className:u("flex items-center",e),...t})}function dn({index:e,className:t,...n}){let r=an.useContext(gr),{char:a,hasFakeCaret:i,isActive:s}=r?.slots[e]??{};return yr("div",{"data-slot":"input-otp-slot","data-active":s,className:u("data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",t),...n,children:[a,i&&_e("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:_e("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}import{useCallback as ae,useEffect as Ue,useRef as be,useState as $}from"react";import{useEffect as br,useState as Rr}from"react";function qe(e){let[,t]=Rr(0);return br(()=>{if(e==null||Date.now()>=e)return;let n=setInterval(()=>{t(r=>r+1),Date.now()>=e&&clearInterval(n)},1e3);return()=>clearInterval(n)},[e]),e!=null?Math.max(0,Math.ceil((e-Date.now())/1e3)):0}var xr={pl:{emailLabel:"E-mail",emailPlaceholder:"m@example.com",sendCode:"Wy\u015Blij kod",sending:"Wysy\u0142anie\u2026",invalidEmail:"Podaj poprawny adres e-mail.",codeSentTo:"Wys\u0142ali\u015Bmy kod na {email}.",changeEmail:"Zmie\u0144",codeLabel:"Kod z e-maila",verify:"Zaloguj si\u0119",verifying:"Sprawdzanie\u2026",codeIncomplete:"Wpisz wszystkie 6 cyfr kodu.",spamHint:"Nie widzisz e-maila? Sprawd\u017A folder spam.",validity:"Kod jest wa\u017Cny 10 minut.",resend:"Wy\u015Blij ponownie",resendIn:"Wy\u015Blij ponownie za {seconds}\xA0s",resendNew:"Wy\u015Blij nowy kod",resent:"Wys\u0142ali\u015Bmy nowy kod.",haveCodePrompt:"Masz ju\u017C kod?",haveCode:"Mam ju\u017C kod",noCode:"Nie masz kodu? Wy\u015Blij go",stepEmail:"Krok 1 z 2: podaj adres e-mail.",stepCode:"Krok 2 z 2: wpisz kod z e-maila.",wrongCode:"Nieprawid\u0142owy kod. Spr\xF3buj jeszcze raz.",expired:"Kod wygas\u0142. Wy\u015Blij nowy kod.",tooManyAttempts:"Zbyt wiele b\u0142\u0119dnych pr\xF3b. Wy\u015Blij nowy kod albo zmie\u0144 adres e-mail.",rateLimited:"Zbyt wiele pr\xF3b. Spr\xF3buj ponownie za {time}.",alreadySent:"Kod zosta\u0142 ju\u017C wys\u0142any. Nowy mo\u017Cesz poprosi\u0107 za {time}.",emailNotFound:"Nie znale\u017Ali\u015Bmy konta z tym adresem e-mail.",deliveryFailed:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu. Spr\xF3buj ponownie.",deliveryUnavailable:"Nie mo\u017Cemy teraz wys\u0142a\u0107 kodu na ten adres. Spr\xF3buj p\xF3\u017Aniej.",captchaRequired:"Potwierd\u017A, \u017Ce jeste\u015B cz\u0142owiekiem, aby wys\u0142a\u0107 kod.",captchaInvalid:"Nie uda\u0142o si\u0119 zweryfikowa\u0107. Spr\xF3buj ponownie.",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.",captchaRequired:"Complete the security check before requesting a code.",captchaInvalid:"Verification failed. Please try again.",network:"Cannot reach the server. Check your connection and try again.",generic:"Something went wrong. Please try again."}};function eo(e,...t){let n={...Ce(xr,e)};for(let r of t)if(r!=null)for(let[a,i]of Object.entries(r))i!=null&&(n[a]=i);return n}function cn(e){let t=Math.max(1,Math.ceil(e));return t<=60?`${t}\xA0s`:`${Math.ceil(t/60)}\xA0min`}function pt(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 Ve(e,t,n){return{...Sr(e,t,n),failure:t}}function Sr(e,t,n){let r=cn(n??mn);switch(t){case"invalidEmail":return{kind:"error",text:e.invalidEmail};case"emailNotFound":return{kind:"error",text:e.emailNotFound};case"wrongCode":return{kind:"error",text:e.wrongCode};case"expired":return{kind:"error",text:e.expired};case"tooManyAttempts":return{kind:"error",text:e.tooManyAttempts};case"rateLimited":return{kind:"error",text:pt(e.rateLimited,{time:r})};case"alreadySent":return{kind:"info",text:pt(e.alreadySent,{time:r})};case"deliveryFailed":return{kind:"error",text:e.deliveryFailed};case"deliveryUnavailable":return{kind:"error",text:e.deliveryUnavailable};case"captchaRequired":return{kind:"error",text:e.captchaRequired};case"captchaInvalid":return{kind:"error",text:e.captchaInvalid};case"network":return{kind:"error",text:e.network};default:return{kind:"error",text:e.generic}}}function ao(e){let{storageKey:t}=e,n=be(e);n.current=e;let[r,a]=$("email"),[i,s]=$(e.initialEmail??""),[o,g]=$(""),[m,l]=$(),[y,c]=$(),[f,b]=$(!1),[x,v]=$(),[k,S]=$(),[w,h]=$(),[C,U]=$(!1),[j,J]=$(""),[N,Y]=$(0),A=be(!1),_=be("email"),V=be(null),F=be(null),re=be("email"),Se=qe(y),B=ae(T=>{_.current=T,Y(O=>O+1)},[]);Ue(()=>{N!==0&&(_.current==="email"?V:F).current?.focus()},[N]),Ue(()=>{if(a("email"),g(""),l(void 0),c(void 0),b(!1),v(void 0),S(void 0),t==null)return;let T=Pe(t);T!=null&&(s(T.email),l(T.challengeId),c(T.resendAt>Date.now()?T.resendAt:void 0),a("code"))},[t]),Ue(()=>{re.current!==r&&(re.current=r,J(r==="code"?n.current.texts.stepCode:n.current.texts.stepEmail))},[r]),Ue(()=>{r==="code"&&N===0&&B(f?"email":"code")},[r]);let R=ae((T,O,L,M)=>{T!=="wrongCode"&&T!=="invalidEmail"&&T!=="alreadySent"&&n.current.onFailure?.(T,L);let se=Ve(n.current.texts,T,O);return M!=null?{...se,text:M}:se},[]),X=ae((T,O,L,M)=>{let se=Date.now(),bt=se+(L??mn)*1e3;s(T),a("code"),b(!1),l(O),c(bt),g(""),v(void 0),S(M),t!=null&&Le(t,{email:T,challengeId:O,resendAt:bt,sentAt:se}),B("code")},[t,B]),Q=ae(async T=>{if(A.current)return;let O=i.trim();if(!pn(O)){S(Ve(n.current.texts,"invalidEmail")),B("email");return}if(A.current=!0,h(T),S(void 0),n.current.beforeSend&&!await n.current.beforeSend()){A.current=!1,h(void 0),S(Ve(n.current.texts,"captchaInvalid"));return}let L;try{L=await n.current.adapter.send(O,{resend:T==="resend"})}catch(se){L={ok:!1,kind:"network",cause:se}}if(A.current=!1,h(void 0),L.ok){X(O,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(O,void 0,L.retryIn,M);return}L.retryIn!=null&&T==="resend"&&c(Date.now()+L.retryIn*1e3),S(M),T==="send"&&B("email")},[i,X,R,B]),he=ae(async T=>{let O=T??o;if(A.current||C||x!=null)return;let L=i.trim();if(f&&!pn(L)){S(Ve(n.current.texts,"invalidEmail")),B("email");return}if(O.length!==de){S({kind:"error",text:n.current.texts.codeIncomplete}),B("code");return}A.current=!0,h("verify"),S(void 0);let M;try{M=await n.current.adapter.verify({email:L,code:O,challengeId:m})}catch(se){M={ok:!1,kind:"network",cause:se}}if(A.current=!1,h(void 0),M.ok){t!=null&&me(t),U(!0),n.current.onVerified?.(M.value,L);return}switch(S(R(M.kind,M.retryIn,M.cause,M.message)),M.kind){case"expired":case"tooManyAttempts":v(M.kind),g(""),t!=null&&me(t);break;case"invalidEmail":case"emailNotFound":B(f?"email":"code");break;case"network":case"unknown":case"deliveryFailed":case"deliveryUnavailable":B("code");break;default:g(""),B("code")}},[o,m,x,C,i,R,f,B,t]),Ye=ae(T=>{s(T),S(O=>O?.kind==="error"?void 0:O)},[]),hn=ae(T=>{g(T.replace(/\D/g,"").slice(0,de)),S(O=>O?.kind==="error"?void 0:O)},[]),kn=ae(()=>{a("email"),b(!1),g(""),l(void 0),c(void 0),v(void 0),S(void 0),t!=null&&me(t),B("email")},[t,B]),Nn=ae(()=>{a("code"),b(!0),g(""),l(void 0),c(void 0),v(void 0),S(void 0),B("email")},[B]);return{step:r,email:i,setEmail:Ye,code:o,setCode:hn,needsEmail:f,busy:w,isBusy:w!=null||C,done:C,notice:k,dead:x,secondsLeft:Se,announcement:j,emailRef:V,codeRef:F,sendCode:()=>Q("send"),resend:()=>Q("resend"),submitCode:he,changeEmail:kn,haveCode:Nn}}import{jsx as mt}from"react/jsx-runtime";function Nr(e){return e.replace(/[\s-]/g,"")}function Tr(e){e!=null&&(e.style.boxSizing="border-box",e.style.padding="0")}function fn({id:e,name:t,value:n,onChange:r,onComplete:a,disabled:i,invalid:s,inputRef:o,autoFocus:g,slotClassName:m,slotStyle:l,className:y,...c}){let f=kr(x=>{Tr(x),typeof o=="function"?o(x):o!=null&&(o.current=x)},[o]),b={className:u("h-11 w-auto min-w-0 flex-1 rounded-md border first:rounded-md last:rounded-md text-base","dark:border-foreground/30 dark:data-[active=true]:border-foreground/70 dark:data-[active=true]:ring-foreground/25","dark:aria-invalid:border-destructive-foreground dark:data-[active=true]:aria-invalid:border-destructive-foreground dark:aria-invalid:ring-destructive-foreground/30 dark:data-[active=true]:aria-invalid:ring-destructive-foreground/30",m),style:l,"aria-invalid":s?!0:void 0};return mt(un,{ref:f,id:e,name:t,maxLength:de,value:n,onChange:r,onComplete:a,disabled:i,autoFocus:g,inputMode:"numeric",autoComplete:"one-time-code",pattern:hr,pasteTransformer:Nr,"aria-invalid":s?!0:void 0,"aria-label":c["aria-label"],"aria-describedby":c["aria-describedby"],containerClassName:u("w-full",y),children:mt(ln,{className:"w-full gap-1.5 sm:gap-2",children:Array.from({length:de},(x,v)=>mt(dn,{index:v,...b},v))})})}import{jsx as G,jsxs as Qe}from"react/jsx-runtime";var ce="bg-[var(--bitsnap-returns-button-background,#18181b)] text-[color:var(--bitsnap-returns-button-foreground,#fafafa)] hover:bg-[var(--bitsnap-returns-button-hover-background,#000000)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",W="border border-[color:var(--bitsnap-returns-border,#e4e4e7)] bg-transparent text-[color:var(--bitsnap-returns-foreground,#18181b)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",Re="bg-[var(--bitsnap-returns-input-background,#ffffff)] dark:bg-[var(--bitsnap-returns-input-background,#ffffff)] border-[color:var(--bitsnap-returns-border,#e4e4e7)] text-[color:var(--bitsnap-returns-foreground,#18181b)] placeholder:text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] focus-visible:border-[color:var(--bitsnap-returns-focus-ring,#71717a)] focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50",gn=u(Re,"data-[active=true]:border-[color:var(--bitsnap-returns-focus-ring,#71717a)] data-[active=true]:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]/50");function te({title:e,description:t,onBack:n,lead:r,className:a,children:i}){let s=z(),o=d("header"),g=d("title"),m=d("description"),l=d("backButton");return Qe("section",{className:u("flex flex-col gap-5",a),children:[r,Qe("div",{"data-bitsnap-returns-slot":"header",className:u("flex flex-col gap-2",o.className),style:o.style,children:[n!=null&&G(P,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"backButton",className:u("self-start -ml-3 text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",l.className),style:l.style,onClick:n,children:s("back")}),G("h2",{"data-bitsnap-returns-slot":"title",className:u("text-2xl font-semibold",g.className),style:g.style,children:e}),t!=null&&G("p",{"data-bitsnap-returns-slot":"description",className:u("text-sm",m.className),style:m.style,children:t})]}),i]})}function H({errorKey:e,onRetry:t}){let n=z(),r=d("error"),a=d("secondaryButton");return Qe("div",{role:"alert","data-bitsnap-returns-slot":"error",className:u("flex flex-col items-start gap-2 text-sm",r.className),style:r.style,children:[G("p",{children:n(e)}),t!=null&&G(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,a.className),style:a.style,onClick:t,children:n("errorRetry")})]})}function We({children:e}){let t=d("emptyState");return G("p",{"data-bitsnap-returns-slot":"emptyState",className:u("py-6 text-center text-sm",t.className),style:t.style,children:e})}function le({rows:e=3}){let t=z(),n=d("skeleton");return G("div",{role:"status","aria-busy":"true","aria-label":t("loading"),className:"flex flex-col gap-3",children:Array.from({length:e},(r,a)=>G(Et,{"data-bitsnap-returns-slot":"skeleton",className:u("h-16 w-full bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",n.className),style:n.style},a))})}function xe({status:e}){let t=z(),n=d("statusBadge");return G("span",{"data-bitsnap-returns-slot":"statusBadge","data-status":e,className:u("inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",n.className),style:n.style,children:t(Kt(e))})}function ft(){let e=z();return t=>e(jt(t))}function He({page:e,total:t,hasNext:n,hasPrevious:r,isFetching:a,onNext:i,onPrevious:s}){let o=z(),g=d("pagination"),m=d("secondaryButton");return!n&&!r?null:Qe("nav",{"data-bitsnap-returns-slot":"pagination",className:u("flex items-center justify-between gap-3 text-sm",g.className),style:g.style,children:[G(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,m.className),style:m.style,disabled:!r||a,onClick:s,children:o("paginationPrevious")}),G("span",{"aria-live":"polite",children:o("paginationInfo",{page:e,total:t})}),G(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,m.className),style:m.style,disabled:!n||a,onClick:i,children:o("paginationNext")})]})}import{jsx as K,jsxs as ne}from"react/jsx-runtime";function Ko({onSubmitted:e,className:t,...n}){let r=D("ReturnsEmailStep"),a=z(),i=Z(),s=Fe(),[o,g]=we(r.lastEmail??""),m=d("emailForm"),l=d("emailInput"),y=d("submitButton");async function c(f){f.preventDefault(),!s.isStarting&&await s.start(o)&&e?.(o.trim())}return K(te,{className:t,lead:K(ct,{projectId:r.projectID,locale:i,...n}),title:a("emailStepTitle"),description:a("emailStepDescription"),children:ne("form",{"data-bitsnap-returns-slot":"emailForm",className:u("flex flex-col gap-4",m.className),style:m.style,onSubmit:c,children:[ne("div",{className:"flex flex-col gap-2",children:[K(Te,{htmlFor:"bitsnap-returns-email",children:a("emailLabel")}),K(Tt,{id:"bitsnap-returns-email",type:"email",name:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",spellCheck:!1,autoFocus:!0,required:!0,value:o,placeholder:a("emailPlaceholder"),disabled:s.isStarting,"data-bitsnap-returns-slot":"emailInput",className:u(Re,l.className),style:l.style,onChange:f=>g(f.target.value)})]}),s.errorKey!=null&&K(H,{errorKey:s.errorKey}),ne(P,{type:"submit",disabled:s.isStarting,"data-bitsnap-returns-slot":"submitButton",className:u(ce,y.className),style:y.style,children:[s.isStarting&&K(ye,{}),a("emailSubmit")]})]})})}function jo({onVerified:e,onBack:t,className:n,...r}){let a=D("ReturnsCodeStep"),i=z(),s=Z(),o=Fe(),[g,m]=we(""),[l,y]=we(!1),[c,f]=we(!1),[b,x]=we(1),v=yn(null),k=yn(!1),S=qe(o.challenge?.resendAvailableAt),w=d("codeForm"),h=d("codeInput"),C=d("submitButton"),U=d("resendButton"),j=o.isVerifying||o.isStarting,J="bitsnap-returns-code",N=`${J}-hint`;wr(()=>{j||v.current?.focus()},[b,j]);async function Y(F){if(!(j||k.current)){if(F.length!==de){y(!0),x(re=>re+1);return}k.current=!0,y(!1),f(!1);try{await o.verify(F)?e?.():(m(""),x(re=>re+1))}finally{k.current=!1}}}async function A(F){F.preventDefault(),await Y(g)}async function _(){y(!1),f(!1),await o.resend()&&(m(""),f(!0)),x(F=>F+1)}function V(){a.setChallenge(void 0),t?.()}return K(te,{className:n,onBack:t!=null?V:void 0,lead:K(ct,{projectId:a.projectID,locale:s,...r}),title:i("codeStepTitle"),description:i("codeStepDescription",{email:o.challenge?.email??""}),children:ne("form",{"data-bitsnap-returns-slot":"codeForm",className:u("flex flex-col gap-4",w.className),style:w.style,noValidate:!0,onSubmit:A,children:[ne("div",{className:"flex flex-col gap-2",children:[K(Te,{htmlFor:J,children:i("codeLabel")}),K(fn,{id:J,name:"code",inputRef:v,value:g,disabled:j,invalid:o.errorKey!=null||l,"aria-describedby":N,slotClassName:u(gn,h.className),slotStyle:h.style,onChange:F=>{m(F.replace(/\D/g,"")),y(!1)},onComplete:F=>void Y(F)}),ne("p",{id:N,className:"text-xs",children:[i("codeValidity")," ",i("codeSpamHint")]})]}),ne("div",{className:"min-h-10",children:[l&&K("p",{role:"alert",className:"text-sm",children:i("codeIncomplete")}),!l&&o.errorKey!=null&&K(H,{errorKey:o.errorKey}),!l&&o.errorKey==null&&c&&K("p",{role:"status",className:"text-sm",children:i("resendSent")})]}),ne("div",{className:"flex flex-wrap items-center gap-3",children:[ne(P,{type:"submit",disabled:j||o.challenge==null,"data-bitsnap-returns-slot":"submitButton",className:u("h-11",ce,C.className),style:C.style,children:[o.isVerifying&&K(ye,{"aria-hidden":!0}),i("codeSubmit")]}),ne(P,{type:"button",variant:"secondary",disabled:j||S>0||o.challenge==null,"data-bitsnap-returns-slot":"resendButton",className:u("h-11",W,U.className),style:U.style,onClick:()=>void _(),children:[o.isStarting&&K(ye,{"aria-hidden":!0}),S>0?i("resendIn",{seconds:S}):i("resend")]})]})]})})}function bn(){let e=z(),t=Fe(),n=d("logoutButton");return K(P,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"logoutButton",className:u("text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",n.className),style:n.style,onClick:t.logout,children:e("logout")})}import{useEffect as Cr,useState as yt}from"react";import{timestampDate as Er}from"@bufbuild/protobuf/wkt";function pe(e,t){if(e==null)return"";let n=Er(e);try{return new Intl.DateTimeFormat(t,{dateStyle:"medium"}).format(n)}catch{return n.toISOString().slice(0,10)}}function ve(e,t,n){let r=typeof e=="bigint"?e:BigInt(Math.trunc(e));try{let a=new Intl.NumberFormat(n,{style:"currency",currency:t}),i=a.resolvedOptions().maximumFractionDigits??2;return a.format(Rn(r,i))}catch{return`${Rn(r,2)} ${t}`}}function Rn(e,t){let n=e<BigInt(0),r=n?-e:e;if(t<=0)return`${n?"-":""}${r}`;let a=BigInt(10)**BigInt(t),i=r/a,s=(r%a).toString().padStart(t,"0");return`${n?"-":""}${i}.${s}`}function xn(e,t){return Number.isFinite(e)?Math.min(Math.max(0,Math.trunc(e)),Math.max(0,t)):0}function gt(e){return e.eligible&&e.availableQuantity>0}function vn(e,t){return e.map(n=>({lineId:n,quantity:t[n]??0})).filter(n=>n.quantity>0)}import{Fragment as Sn,jsx as p,jsxs as E}from"react/jsx-runtime";function la({onSelectOrder:e,onOpenMyReturns:t,showLogout:n=!0,pageSize:r,className:a}){D("ReturnsOrderList");let i=z(),s=Z(),o=tn({pageSize:r}),g=d("orderList"),m=d("orderCard"),l=d("orderReference"),y=d("orderDate"),c=d("orderTotal"),f=d("secondaryButton");return E(te,{className:a,title:i("ordersTitle"),description:i("ordersDescription"),children:[(n||t!=null)&&E("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t!=null?p(P,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:u(W,f.className),style:f.style,onClick:t,children:i("myReturnsLink")}):p("span",{}),n&&p(bn,{})]}),o.isLoading?p(le,{}):o.errorKey!=null?p(H,{errorKey:o.errorKey,onRetry:o.refetch}):o.orders.length===0?p(We,{children:i("ordersEmpty")}):E(Sn,{children:[p("ul",{"data-bitsnap-returns-slot":"orderList",className:u("flex flex-col gap-3",g.className),style:g.style,children:o.orders.map(b=>E("li",{"data-bitsnap-returns-slot":"orderCard",className:u("flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[E("div",{className:"flex flex-col gap-1",children:[p("span",{"data-bitsnap-returns-slot":"orderReference",className:u("font-medium",l.className),style:l.style,children:i("orderTitle",{reference:b.displayReference})}),p("span",{"data-bitsnap-returns-slot":"orderDate",className:u("text-sm",y.className),style:y.style,children:pe(b.purchasedAt,s)}),p("span",{className:"text-sm",children:i("orderReturnableLines",{count:b.returnableLineCount})})]}),E("div",{className:"flex items-center gap-4",children:[p("span",{"data-bitsnap-returns-slot":"orderTotal",className:u("font-medium",c.className),style:c.style,children:ve(b.totalMinor,b.currency,s)}),p(P,{type:"button",variant:"secondary",size:"sm","aria-label":`${i("orderSelect")}: ${i("orderTitle",{reference:b.displayReference})}`,"data-bitsnap-returns-slot":"secondaryButton",className:u(W,f.className),style:f.style,onClick:()=>e?.(b.canonicalOrderId),children:i("orderSelect")})]})]},b.canonicalOrderId))}),p(He,{page:o.page,total:o.total,hasNext:o.hasNext,hasPrevious:o.hasPrevious,isFetching:o.isFetching,onNext:o.next,onPrevious:o.previous})]})]})}function da({orderId:e,onContinue:t,onBack:n,initialItems:r,initialNote:a,className:i}){D("ReturnsOrderDetail");let s=Ee();Cr(()=>{s.track("return_started",{},{order_ref:null})},[s]);let o=z(),g=Z(),{order:m,returnHistory:l,isLoading:y,errorKey:c,refetch:f}=ut(e),[b,x]=yt(()=>Object.fromEntries((r??[]).map(R=>[R.lineId,R.quantity]))),[v,k]=yt(a??""),[S,w]=yt(!1),h=d("lineList"),C=d("line"),U=d("lineName"),j=d("linePrice"),J=d("lineQuantityControl"),N=d("quantityButton"),Y=d("quantityInput"),A=d("lineIneligibleReason"),_=d("noteInput"),V=d("submitButton"),F=d("history"),re=d("historyEntry");function Se(R,X){w(!1),x(Q=>({...Q,[R.lineId]:xn(X,R.availableQuantity)}))}function B(R){if(R.preventDefault(),m==null)return;let X=vn(m.lines.filter(gt).map(Q=>Q.lineId),b);if(X.length===0){w(!0);return}t?.({items:X,note:v.trim()})}return p(te,{className:i,onBack:n,title:o("orderDetailTitle",{reference:m?.displayReference??""}),description:o("orderDetailDescription"),children:y?p(le,{}):c!=null?p(H,{errorKey:c,onRetry:f}):m==null?null:E("form",{className:"flex flex-col gap-5",onSubmit:B,children:[p("ul",{"data-bitsnap-returns-slot":"lineList",className:u("flex flex-col gap-3",h.className),style:h.style,children:m.lines.map(R=>{let X=gt(R),Q=b[R.lineId]??0,he=`bitsnap-returns-quantity-${R.lineId}`;return E("li",{"data-bitsnap-returns-slot":"line","data-selected":Q>0?"":void 0,"data-ineligible":X?void 0:"",className:u("flex flex-col gap-3 border p-4",C.className),style:C.style,children:[E("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[p("span",{"data-bitsnap-returns-slot":"lineName",className:u("font-medium",U.className),style:U.style,children:R.name}),p("span",{"data-bitsnap-returns-slot":"linePrice",className:u("text-sm",j.className),style:j.style,children:ve(R.paidUnitMinor,R.currency,g)})]}),X?E("div",{role:"group","aria-label":o("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"lineQuantityControl",className:u("flex items-center gap-2",J.className),style:J.style,children:[p(P,{type:"button",variant:"secondary",size:"icon-sm","aria-label":o("quantityDecrease",{name:R.name}),"aria-controls":he,disabled:Q<=0,"data-bitsnap-returns-slot":"quantityButton",className:u(W,N.className),style:N.style,onClick:()=>Se(R,Q-1),children:p("span",{"aria-hidden":"true",children:"-"})}),p("input",{id:he,type:"number",inputMode:"numeric",min:0,max:R.availableQuantity,step:1,value:Q,"aria-label":o("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"quantityInput",className:u("h-8 w-16 rounded-md border px-2 text-center text-sm outline-none focus-visible:ring-[3px]",Re,Y.className),style:Y.style,onChange:Ye=>Se(R,Ye.target.valueAsNumber)}),p(P,{type:"button",variant:"secondary",size:"icon-sm","aria-label":o("quantityIncrease",{name:R.name}),"aria-controls":he,disabled:Q>=R.availableQuantity,"data-bitsnap-returns-slot":"quantityButton",className:u(W,N.className),style:N.style,onClick:()=>Se(R,Q+1),children:p("span",{"aria-hidden":"true",children:"+"})}),p("span",{className:"text-sm",children:o("quantityOfAvailable",{available:R.availableQuantity})})]}):p("p",{"data-bitsnap-returns-slot":"lineIneligibleReason",className:u("text-sm",A.className),style:A.style,children:R.exclusionReason!==""?R.exclusionReason:o("lineIneligibleFallback")})]},R.lineId)})}),E("div",{className:"flex flex-col gap-2",children:[p(Te,{htmlFor:"bitsnap-returns-note",children:o("noteLabel")}),p(Ct,{id:"bitsnap-returns-note",name:"note",rows:3,maxLength:1e3,value:v,placeholder:o("notePlaceholder"),"data-bitsnap-returns-slot":"noteInput",className:u(Re,"dark:border-[color:var(--bitsnap-returns-border,#e4e4e7)] dark:placeholder:text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] dark:focus-visible:ring-[color:var(--bitsnap-returns-focus-ring,#71717a)]",_.className),style:_.style,onChange:R=>k(R.target.value)})]}),S&&p(H,{errorKey:"selectionEmpty"}),p(P,{type:"submit","data-bitsnap-returns-slot":"submitButton",className:u(ce,V.className),style:V.style,children:o("selectionContinue")}),l.length>0&&E("div",{className:"flex flex-col gap-2",children:[p("h3",{className:"text-sm font-medium",children:o("previousReturnsTitle")}),p("ul",{"data-bitsnap-returns-slot":"history",className:u("flex flex-col gap-2",F.className),style:F.style,children:l.map(R=>E("li",{"data-bitsnap-returns-slot":"historyEntry",className:u("flex flex-wrap items-center justify-between gap-2 text-sm",re.className),style:re.style,children:[p("span",{children:R.reference}),p("span",{children:pe(R.createdAt,g)}),p(xe,{status:R.status})]},R.id))})]})]})})}function ca({orderId:e,items:t,note:n,onSubmitted:r,onBack:a,className:i}){D("ReturnsConfirmation");let s=z(),o=Z(),{order:g,isLoading:m,errorKey:l,refetch:y}=ut(e),c=nn(),f=d("summary"),b=d("line"),x=d("lineName"),v=d("linePrice"),k=d("submitButton");async function S(w){if(w.preventDefault(),c.isPending)return;let h=await c.submit({orderId:e,items:t.map(C=>({lineId:C.lineId,quantity:C.quantity})),note:n});h!=null&&r?.(h.id,h)}return p(te,{className:i,onBack:a,title:s("confirmationTitle"),description:s("confirmationDescription"),children:m?p(le,{rows:2}):l!=null?p(H,{errorKey:l,onRetry:y}):E("form",{className:"flex flex-col gap-5",onSubmit:S,children:[E("div",{"data-bitsnap-returns-slot":"summary",className:u("flex flex-col gap-3 border p-4",f.className),style:f.style,children:[p("h3",{className:"text-sm font-medium",children:s("confirmationSummary")}),p("ul",{className:"flex flex-col gap-3",children:t.map(w=>{let h=g?.lines.find(C=>C.lineId===w.lineId);return E("li",{"data-bitsnap-returns-slot":"line",className:u("flex flex-wrap items-baseline justify-between gap-2",b.className),style:b.style,children:[p("span",{"data-bitsnap-returns-slot":"lineName",className:u("font-medium",x.className),style:x.style,children:h?.name??w.lineId}),E("span",{"data-bitsnap-returns-slot":"linePrice",className:u("text-sm",v.className),style:v.style,children:[s("confirmationQuantity",{quantity:w.quantity}),h!=null&&` \xB7 ${ve(h.paidUnitMinor*BigInt(w.quantity),h.currency,o)}`]})]},w.lineId)})}),n!=null&&n!==""&&E("div",{className:"flex flex-col gap-1 text-sm",children:[p("span",{className:"font-medium",children:s("confirmationNote")}),p("span",{className:"whitespace-pre-wrap",children:n})]})]}),c.errorKey!=null&&p(H,{errorKey:c.errorKey}),E(P,{type:"submit",disabled:c.isPending||t.length===0,"data-bitsnap-returns-slot":"submitButton",className:u(ce,k.className),style:k.style,children:[c.isPending&&p(ye,{}),s("confirmationSubmit")]})]})})}function pa({returnId:e,onContinue:t,onOpenMyReturns:n,className:r}){D("ReturnsResult");let a=z(),{request:i,isLoading:s,errorKey:o,refetch:g}=je(e),m=d("successState"),l=d("returnReference"),y=d("returnInstructions"),c=d("submitButton"),f=d("secondaryButton");return E("section",{className:u("flex flex-col gap-5",r),children:[E("div",{role:"status","data-bitsnap-returns-slot":"successState",className:u("flex flex-col gap-4 border p-5",m.className),style:m.style,children:[p("h2",{className:"text-2xl font-semibold",children:a("successTitle")}),p("p",{className:"text-sm",children:a("successDescription")}),s?p(le,{rows:2}):o!=null?p(H,{errorKey:o,onRetry:g}):i!=null&&E(Sn,{children:[E("div",{className:"flex flex-col gap-1",children:[p("span",{className:"text-sm",children:a("successReference")}),p("span",{"data-bitsnap-returns-slot":"returnReference",className:u("text-lg font-semibold",l.className),style:l.style,children:i.reference})]}),i.returnInstructions!==""&&E("div",{className:"flex flex-col gap-1",children:[p("span",{className:"text-sm font-medium",children:a("successInstructions")}),p("p",{"data-bitsnap-returns-slot":"returnInstructions",className:u("whitespace-pre-wrap border p-3 text-sm",y.className),style:y.style,children:i.returnInstructions})]})]})]}),E("div",{className:"flex flex-wrap gap-3",children:[p(P,{type:"button","data-bitsnap-returns-slot":"submitButton",className:u(ce,c.className),style:c.style,onClick:t,children:a("successDone")}),n!=null&&p(P,{type:"button",variant:"secondary","data-bitsnap-returns-slot":"secondaryButton",className:u(W,f.className),style:f.style,onClick:n,children:a("myReturnsLink")})]})]})}import{Fragment as Ir,jsx as I,jsxs as q}from"react/jsx-runtime";function Na({onSelectReturn:e,onBack:t,pageSize:n,className:r}){D("ReturnsMyReturnsList");let a=z(),i=Z(),s=ft(),o=rn({pageSize:n}),g=d("returnList"),m=d("returnCard"),l=d("returnReference"),y=d("secondaryButton");return I(te,{className:r,onBack:t,title:a("myReturnsTitle"),description:a("myReturnsDescription"),children:o.isLoading?I(le,{}):o.errorKey!=null?I(H,{errorKey:o.errorKey,onRetry:o.refetch}):o.returns.length===0?I(We,{children:a("myReturnsEmpty")}):q(Ir,{children:[I("ul",{"data-bitsnap-returns-slot":"returnList",className:u("flex flex-col gap-3",g.className),style:g.style,children:o.returns.map(c=>q("li",{"data-bitsnap-returns-slot":"returnCard",className:u("flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[q("div",{className:"flex flex-col gap-1",children:[I("span",{"data-bitsnap-returns-slot":"returnReference",className:u("font-medium",l.className),style:l.style,children:c.reference}),I("span",{className:"text-sm",children:pe(c.createdAt,i)}),q("span",{className:"text-sm",children:[a("myReturnRefund"),": ",s(c.refundStatus)]})]}),q("div",{className:"flex items-center gap-3",children:[I(xe,{status:c.status}),I(P,{type:"button",variant:"secondary",size:"sm","aria-label":`${a("myReturnOpen")}: ${c.reference}`,"data-bitsnap-returns-slot":"secondaryButton",className:u(W,y.className),style:y.style,onClick:()=>e?.(c.id),children:a("myReturnOpen")})]})]},c.id))}),I(He,{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}=je(e),l=d("summary"),y=d("lineList"),c=d("line"),f=d("lineName"),b=d("returnInstructions"),x=d("history"),v=d("historyEntry");return I(te,{className:n,onBack:t,title:s!=null?r("myReturnTitle",{reference:s.reference}):r("myReturnDetailTitle"),children:o?I(le,{}):g!=null?I(H,{errorKey:g,onRetry:m}):s!=null&&q("div",{className:"flex flex-col gap-5",children:[q("div",{"data-bitsnap-returns-slot":"summary",className:u("flex flex-col gap-2 border p-4 text-sm",l.className),style:l.style,children:[q("div",{className:"flex items-center justify-between gap-2",children:[I(xe,{status:s.status}),q("span",{children:[r("myReturnCreatedAt"),":"," ",pe(s.createdAt,a)]})]}),q("span",{children:[r("myReturnRefund"),": ",i(s.refundStatus),s.refundAmountMinor>BigInt(0)&&` \xB7 ${ve(s.refundAmountMinor,s.currency,a)}`]}),s.customerNote!==""&&q("span",{className:"whitespace-pre-wrap",children:[r("myReturnNote"),": ",s.customerNote]})]}),s.returnInstructions!==""&&I("p",{"data-bitsnap-returns-slot":"returnInstructions",className:u("whitespace-pre-wrap border p-3 text-sm",b.className),style:b.style,children:s.returnInstructions}),q("div",{className:"flex flex-col gap-2",children:[I("h3",{className:"text-sm font-medium",children:r("myReturnLines")}),I("ul",{"data-bitsnap-returns-slot":"lineList",className:u("flex flex-col gap-3",y.className),style:y.style,children:s.lines.map(k=>q("li",{"data-bitsnap-returns-slot":"line",className:u("flex flex-wrap items-baseline justify-between gap-2 border p-4",c.className),style:c.style,children:[I("span",{"data-bitsnap-returns-slot":"lineName",className:u("font-medium",f.className),style:f.style,children:k.name}),I("span",{className:"text-sm",children:r("myReturnLineQuantities",{requested:k.requestedQuantity,approved:k.approvedQuantity,received:k.receivedQuantity})})]},k.lineId))})]}),s.history.length>0&&q("div",{className:"flex flex-col gap-2",children:[I("h3",{className:"text-sm font-medium",children:r("myReturnHistory")}),I("ul",{"data-bitsnap-returns-slot":"history",className:u("flex flex-col gap-2",x.className),style:x.style,children:s.history.map(k=>q("li",{"data-bitsnap-returns-slot":"historyEntry",className:u("flex flex-wrap items-center justify-between gap-2 text-sm",v.className),style:v.style,children:[I(xe,{status:k.status}),I("span",{children:pe(k.createdAt,a)})]},k.id))})]})]})})}export{Zt as a,pr as b,ct as c,Te as d,ye as e,Ut as f,xr as g,eo as h,pt as i,ao as j,fn as k,Pr as l,Ot as m,Ge as n,d as o,ot as p,Xt as q,z as r,Z as s,D as t,Xn as u,ls as v,Fe as w,tn as x,ut as y,nn as z,rn as A,je as B,le as C,Ko as D,jo as E,la as F,da as G,ca as H,pa as I,Na as J,Ta as K};
|
|
2
|
+
//# sourceMappingURL=chunk-KO7Z3E23.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/appearance-core.ts"],"names":["omitUndefined","tokens","result","key","value","hasAnyElement","elements","element","resolveBoundaryStyle","variables","shadcnVariables","style","token","variable","resolveAppearanceCore","appearance","config","theme","getSlotAppearance","slot"],"mappings":"AA8DO,0rBAASA,CAAAA,CACdC,CAAAA,CACgC,CAChC,IAAMC,CAAAA,CAAkC,CAAC,CAAA,CAEzC,GAAA,CAAA,GAAW,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQH,CAAM,CAAA,CAC1CG,CAAAA,EAAS,IAAA,EAAA,CACXF,CAAAA,CAAOC,CAAG,CAAA,CAAIC,CAAAA,CAAAA,CAIlB,OAAOF,CACT,CAEO,SAASG,CAAAA,CACdC,CAAAA,CACS,CACT,OAAO,MAAA,CAAO,MAAA,CAAmCA,CAAQ,CAAA,CAAE,IAAA,CACxDC,CAAAA,EACCA,CAAAA,EAAW,IAAA,EAAA,CAASA,CAAAA,CAAQ,SAAA,EAAa,IAAA,EAAQA,CAAAA,CAAQ,KAAA,EAAS,IAAA,CACtE,CACF,CAMO,SAASC,CAAAA,CACdP,CAAAA,CACAQ,CAAAA,CACAC,CAAAA,CACe,CACf,IAAMC,CAAAA,CAAgC,CAAC,CAAA,CAEvC,GAAA,CAAA,GAAW,CAACC,CAAAA,CAAOC,CAAQ,CAAA,GAAK,MAAA,CAAO,OAAA,CAAgBJ,CAAS,CAAA,CAAG,CACjE,IAAML,CAAAA,CAAQH,CAAAA,CAAOW,CAAc,CAAA,CAC/BR,CAAAA,EAAS,IAAA,EAAA,CACXO,CAAAA,CAAME,CAAQ,CAAA,CAAIT,CAAAA,CAEtB,CAEA,GAAA,CAAA,GAAW,CAAE,KAAA,CAAAQ,CAAAA,CAAO,QAAA,CAAAC,CAAS,CAAA,GAAKH,CAAAA,CAAiB,CACjD,IAAMN,CAAAA,CAAQH,CAAAA,CAAOW,CAAK,CAAA,CACtBR,CAAAA,EAAS,IAAA,EAAA,CACXO,CAAAA,CAAME,CAAQ,CAAA,CAAIT,CAAAA,CAEtB,CAEA,OAAOO,CACT,CAOO,SAASG,CAAAA,CAKdC,CAAAA,CAOAC,CAAAA,CAC4C,CAC5C,IAAMC,CAAAA,kCAAeF,CAAAA,2BAAY,OAAA,SAASC,CAAAA,CAAO,cAAA,CAE3Cf,CAAAA,CAASD,CAAAA,CAAqB,CAClC,GAAGgB,CAAAA,CAAO,OAAA,CAAQC,CAAK,CAAA,CACvB,mBAAGF,CAAAA,6BAAY,QACjB,CAAC,CAAA,CAEKT,CAAAA,kCAAWS,CAAAA,6BAAY,UAAA,SAAY,CAAC,GAAA,CAE1C,MAAO,CACL,KAAA,CAAAE,CAAAA,CACA,YAAA,iBACEF,CAAAA,6BAAY,OAAA,EAAS,IAAA,EACrB,MAAA,CAAO,IAAA,CAAKd,CAAM,CAAA,CAAE,MAAA,CAAS,CAAA,EAC7BI,CAAAA,CAAcC,CAAQ,CAAA,CACxB,MAAA,CAAAL,CAAAA,CACA,QAAA,CAAAK,CAAAA,CACA,aAAA,CAAeE,CAAAA,CACbP,CAAAA,CACAe,CAAAA,CAAO,SAAA,CACPA,CAAAA,CAAO,eACT,CACF,CACF,CAGO,SAASE,CAAAA,CACdZ,CAAAA,CACAa,CAAAA,CAC4B,CAC5B,OAAOb,CAAAA,CAASa,CAAI,CACtB,CAAA,6BAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-
|
|
1
|
+
{"version":3,"sources":["../src/lib/appearance-core.ts"],"names":["omitUndefined","tokens","result","key","value","hasAnyElement","elements","element","resolveBoundaryStyle","variables","shadcnVariables","style","token","variable","resolveAppearanceCore","appearance","config","theme","getSlotAppearance","slot"],"mappings":"AA8DO,0rBAASA,CAAAA,CACdC,CAAAA,CACgC,CAChC,IAAMC,CAAAA,CAAkC,CAAC,CAAA,CAEzC,GAAA,CAAA,GAAW,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQH,CAAM,CAAA,CAC1CG,CAAAA,EAAS,IAAA,EAAA,CACXF,CAAAA,CAAOC,CAAG,CAAA,CAAIC,CAAAA,CAAAA,CAIlB,OAAOF,CACT,CAEO,SAASG,CAAAA,CACdC,CAAAA,CACS,CACT,OAAO,MAAA,CAAO,MAAA,CAAmCA,CAAQ,CAAA,CAAE,IAAA,CACxDC,CAAAA,EACCA,CAAAA,EAAW,IAAA,EAAA,CAASA,CAAAA,CAAQ,SAAA,EAAa,IAAA,EAAQA,CAAAA,CAAQ,KAAA,EAAS,IAAA,CACtE,CACF,CAMO,SAASC,CAAAA,CACdP,CAAAA,CACAQ,CAAAA,CACAC,CAAAA,CACe,CACf,IAAMC,CAAAA,CAAgC,CAAC,CAAA,CAEvC,GAAA,CAAA,GAAW,CAACC,CAAAA,CAAOC,CAAQ,CAAA,GAAK,MAAA,CAAO,OAAA,CAAgBJ,CAAS,CAAA,CAAG,CACjE,IAAML,CAAAA,CAAQH,CAAAA,CAAOW,CAAc,CAAA,CAC/BR,CAAAA,EAAS,IAAA,EAAA,CACXO,CAAAA,CAAME,CAAQ,CAAA,CAAIT,CAAAA,CAEtB,CAEA,GAAA,CAAA,GAAW,CAAE,KAAA,CAAAQ,CAAAA,CAAO,QAAA,CAAAC,CAAS,CAAA,GAAKH,CAAAA,CAAiB,CACjD,IAAMN,CAAAA,CAAQH,CAAAA,CAAOW,CAAK,CAAA,CACtBR,CAAAA,EAAS,IAAA,EAAA,CACXO,CAAAA,CAAME,CAAQ,CAAA,CAAIT,CAAAA,CAEtB,CAEA,OAAOO,CACT,CAOO,SAASG,CAAAA,CAKdC,CAAAA,CAOAC,CAAAA,CAC4C,CAC5C,IAAMC,CAAAA,kCAAeF,CAAAA,2BAAY,OAAA,SAASC,CAAAA,CAAO,cAAA,CAE3Cf,CAAAA,CAASD,CAAAA,CAAqB,CAClC,GAAGgB,CAAAA,CAAO,OAAA,CAAQC,CAAK,CAAA,CACvB,mBAAGF,CAAAA,6BAAY,QACjB,CAAC,CAAA,CAEKT,CAAAA,kCAAWS,CAAAA,6BAAY,UAAA,SAAY,CAAC,GAAA,CAE1C,MAAO,CACL,KAAA,CAAAE,CAAAA,CACA,YAAA,iBACEF,CAAAA,6BAAY,OAAA,EAAS,IAAA,EACrB,MAAA,CAAO,IAAA,CAAKd,CAAM,CAAA,CAAE,MAAA,CAAS,CAAA,EAC7BI,CAAAA,CAAcC,CAAQ,CAAA,CACxB,MAAA,CAAAL,CAAAA,CACA,QAAA,CAAAK,CAAAA,CACA,aAAA,CAAeE,CAAAA,CACbP,CAAAA,CACAe,CAAAA,CAAO,SAAA,CACPA,CAAAA,CAAO,eACT,CACF,CACF,CAGO,SAASE,CAAAA,CACdZ,CAAAA,CACAa,CAAAA,CAC4B,CAC5B,OAAOb,CAAAA,CAASa,CAAI,CACtB,CAAA,6BAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-attachments/dist/chunk-KOYBZORL.js","sourcesContent":["import type { CSSProperties } from \"react\";\n\n/**\n * Generic building blocks shared by the appearance modules (checkout, and\n * later returns). Each module supplies its own token to CSS variable map, theme\n * presets and shadcn mapping, and keeps its own public types. Everything here\n * is pure so it can be tested without a DOM.\n */\n\n/** Caller overrides for a single slot. */\nexport type SlotAppearance = {\n /** Merged after the built-in classes with `cn`, so Tailwind conflicts resolve. */\n className?: string;\n /** Merged after the built-in inline styles. */\n style?: CSSProperties;\n};\n\n/** Typed partial map of slot name to its overrides. */\nexport type AppearanceElements<Slot extends string> = Partial<\n Record<Slot, SlotAppearance>\n>;\n\n/** CSS custom property used for each token. */\nexport type TokenVariables<Token extends string> = Readonly<\n Record<Token, string>\n>;\n\n/**\n * Remaps a token onto a shadcn theme variable (`--background`, `--ring`, ...)\n * so shared UI primitives follow the module's tokens. Only written when the\n * token is in effect.\n */\nexport type ShadcnVariableMapping<Token extends string> = readonly {\n token: Token;\n variable: string;\n}[];\n\nexport type AppearanceCoreConfig<Token extends string, Theme extends string> = {\n /** Theme used when the caller does not select one. */\n defaultTheme: Theme;\n /** Partial token sets applied underneath the caller tokens. */\n presets: Record<Theme, Partial<Record<Token, string>>>;\n variables: TokenVariables<Token>;\n shadcnVariables: ShadcnVariableMapping<Token>;\n};\n\nexport type ResolvedAppearanceCore<\n Token extends string,\n Theme extends string,\n Slot extends string,\n> = {\n theme: Theme;\n /** `true` as soon as the caller passed a theme, a token or a slot override. */\n isCustomized: boolean;\n /** Tokens that are in effect. Empty entries were dropped. */\n tokens: Partial<Record<Token, string>>;\n elements: AppearanceElements<Slot>;\n /** Inline custom properties for the theme boundary. */\n boundaryStyle: CSSProperties;\n};\n\n/** Drops `undefined`/`null` tokens so unset values keep the stylesheet default. */\nexport function omitUndefined<Token extends string>(\n tokens: Partial<Record<Token, string>>,\n): Partial<Record<Token, string>> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(tokens)) {\n if (value != null) {\n result[key] = value;\n }\n }\n\n return result as Partial<Record<Token, string>>;\n}\n\nexport function hasAnyElement<Slot extends string>(\n elements: AppearanceElements<Slot>,\n): boolean {\n return Object.values<SlotAppearance | undefined>(elements).some(\n (element) =>\n element != null && (element.className != null || element.style != null),\n );\n}\n\n/**\n * Token to CSS variable resolution, followed by the shadcn remapping. Only\n * tokens that are in effect produce a variable.\n */\nexport function resolveBoundaryStyle<Token extends string>(\n tokens: Partial<Record<Token, string>>,\n variables: TokenVariables<Token>,\n shadcnVariables: ShadcnVariableMapping<Token>,\n): CSSProperties {\n const style: Record<string, string> = {};\n\n for (const [token, variable] of Object.entries<string>(variables)) {\n const value = tokens[token as Token];\n if (value != null) {\n style[variable] = value;\n }\n }\n\n for (const { token, variable } of shadcnVariables) {\n const value = tokens[token];\n if (value != null) {\n style[variable] = value;\n }\n }\n\n return style as CSSProperties;\n}\n\n/**\n * Resolves theme, tokens, slot overrides and the boundary style. The resolver\n * never invents values: a token is only present when the caller provided it or\n * selected a theme preset that carries it.\n */\nexport function resolveAppearanceCore<\n Token extends string,\n Theme extends string,\n Slot extends string,\n>(\n appearance:\n | {\n theme?: Theme;\n tokens?: Partial<Record<Token, string>>;\n elements?: AppearanceElements<Slot>;\n }\n | undefined,\n config: AppearanceCoreConfig<Token, Theme>,\n): ResolvedAppearanceCore<Token, Theme, Slot> {\n const theme: Theme = appearance?.theme ?? config.defaultTheme;\n\n const tokens = omitUndefined<Token>({\n ...config.presets[theme],\n ...appearance?.tokens,\n });\n\n const elements = appearance?.elements ?? {};\n\n return {\n theme,\n isCustomized:\n appearance?.theme != null ||\n Object.keys(tokens).length > 0 ||\n hasAnyElement(elements),\n tokens,\n elements,\n boundaryStyle: resolveBoundaryStyle(\n tokens,\n config.variables,\n config.shadcnVariables,\n ),\n };\n}\n\n/** Caller overrides for a slot, if any were provided. */\nexport function getSlotAppearance<Slot extends string>(\n elements: AppearanceElements<Slot>,\n slot: Slot,\n): SlotAppearance | undefined {\n return elements[slot];\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkI2RHVELRjs = require('./chunk-I2RHVELR.js');var _chunkMDAFPGPAjs = require('./chunk-MDAFPGPA.js');var _chunkEK3D44XWjs = require('./chunk-EK3D44XW.js');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var a=_react.createContext.call(void 0, _chunkMDAFPGPAjs.b.call(void 0, )),u= exports.a =({children:c,analytics:s})=>{let n=_chunkMDAFPGPAjs.b.call(void 0, ),l=_chunkEK3D44XWjs.n.call(void 0, n.projectID,s,"panel");return _jsxruntime.jsx.call(void 0, _chunkI2RHVELRjs.j,{children:_jsxruntime.jsx.call(void 0, a.Provider,{value:{...n},children:_jsxruntime.jsx.call(void 0, _chunkEK3D44XWjs.l,{value:l,children:_jsxruntime.jsx.call(void 0, "div",{className:"bitsnap-react",children:c})})})})},C= exports.b =()=>_react.useContext.call(void 0, a);exports.a = u; exports.b = C;
|
|
2
|
+
//# sourceMappingURL=chunk-KYSMT6ZK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/chat-attachments/dist/chunk-KYSMT6ZK.js","../src/panel/PanelProvider.tsx"],"names":["PanelContext","createContext","getPanelConfig","PanelProvider","children","analytics","config","instrument","useInstrument","jsx","RpcProvider","InstrumentProvider","usePanelConfig","useContext"],"mappings":"AAAA,+HAAuC,sDAAwC,sDAA+C,8BCApF,+CA2BhC,IAlBJA,CAAAA,CAAeC,kCAAAA,gCAA2BC,CAAgB,CAAA,CAEnDC,CAAAA,aASR,CAAC,CAAE,QAAA,CAAAC,CAAAA,CAAU,SAAA,CAAAC,CAAU,CAAA,CAAA,EAAM,CAChC,IAAMC,CAAAA,CAASJ,gCAAAA,CAAe,CACxBK,CAAAA,CAAaC,gCAAAA,CAAcF,CAAO,SAAA,CAAWD,CAAAA,CAAW,OAAO,CAAA,CACrE,OACEI,6BAAAA,kBAACC,CAAA,CACC,QAAA,CAAAD,6BAAAA,CAACT,CAAa,QAAA,CAAb,CAAsB,KAAA,CAAO,CAAE,GAAGM,CAAO,CAAA,CACxC,QAAA,CAAAG,6BAAAA,kBAACE,CAAA,CAAmB,KAAA,CAAOJ,CAAAA,CACzB,QAAA,CAAAE,6BAAAA,KAAC,CAAA,CAAI,SAAA,CAAU,eAAA,CAAiB,QAAA,CAAAL,CAAAA,CAAS,CAAA,CAC3C,CAAA,CACF,CAAA,CACF,CAEJ,CAAA,CAEaQ,CAAAA,aAAiB,CAAA,CAAA,EAAMC,+BAAAA,CAAuB,CAAA,CAAA,6BAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-attachments/dist/chunk-KYSMT6ZK.js","sourcesContent":[null,"import { createContext, useContext } from \"react\";\nimport {\n InstrumentProvider,\n useInstrument,\n type AnalyticsOption,\n} from \"../analytics/instrument\";\nimport { RpcProvider } from \"../rpc-provider\";\nimport { getPanelConfig, type PanelConfig } from \"./config\";\n\nconst PanelContext = createContext<PanelConfig>(getPanelConfig());\n\nexport const PanelProvider: React.FC<{\n children: React.ReactNode;\n /**\n * Usage statistics for your Bitsnap dashboard (panel logins, orders viewed,\n * downloads, course progress). On by default; `false` turns it off. An\n * object lets you forward every event: `{ onEvent }`. Nothing is stored on\n * the visitor's device.\n */\n analytics?: AnalyticsOption;\n}> = ({ children, analytics }) => {\n const config = getPanelConfig();\n const instrument = useInstrument(config.projectID, analytics, \"panel\");\n return (\n <RpcProvider>\n <PanelContext.Provider value={{ ...config }}>\n <InstrumentProvider value={instrument}>\n <div className=\"bitsnap-react\">{children}</div>\n </InstrumentProvider>\n </PanelContext.Provider>\n </RpcProvider>\n );\n};\n\nexport const usePanelConfig = () => useContext(PanelContext);\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{j as i}from"./chunk-TMEII7BM.mjs";import{b as t}from"./chunk-CUPG4B5W.mjs";import{l as o,n as r}from"./chunk-J6WKSO33.mjs";import{createContext as p,useContext as P}from"react";import{jsx as e}from"react/jsx-runtime";var a=p(t()),u=({children:c,analytics:s})=>{let n=t(),l=r(n.projectID,s,"panel");return e(i,{children:e(a.Provider,{value:{...n},children:e(o,{value:l,children:e("div",{className:"bitsnap-react",children:c})})})})},C=()=>P(a);export{u as a,C as b};
|
|
2
|
+
//# sourceMappingURL=chunk-LRUBBPTV.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/panel/config.ts","../src/panel/session-storage.ts"],"names":["config","allowedReturnOrigins","setPanelConfig","newConfig","getPanelConfig","setProjectID","projectID","setTheme","theme","setLoginURL","loginURL","setHost","host","setAllowedReturnOrigins","origins","getAllowedReturnOrigins","panelSessionKey"],"mappings":"AAEA,iLAAIA,CAAAA,CAAsB,CACxB,SAAA,CAAW,KAAA,CAAA,CACX,QAAA,CAAU,cAAA,CACV,KAAA,CAAO,KAAA,CAAA,CACP,IAAA,CAAM,KAAA,CAAA,CACN,oBAAA,CAAsB,CAAC,CACzB,CAAA,CAEIC,CAAAA,CAAiC,CAAC,CAAA,CAU/B,SAASC,CAAAA,CAAeC,CAAAA,CAAuC,CACpEH,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,GAAGG,CAAU,CACrC,CAEO,SAASC,CAAAA,CAAAA,CAA8B,CAC5C,OAAOJ,CACT,CAEO,SAASK,CAAAA,CAAaC,CAAAA,CAAyB,CACpDN,CAAAA,CAAO,SAAA,CAAYM,CACrB,CAEO,SAASC,CAAAA,CAASC,CAAAA,CAA6B,CACpDR,CAAAA,CAAO,KAAA,CAAQQ,CACjB,CAEO,SAASC,CAAAA,CAAYC,CAAAA,CAAwB,CAClDV,CAAAA,CAAO,QAAA,CAAWU,CACpB,CAEO,SAASC,CAAAA,CAAQC,CAAAA,CAAoB,CAC1CZ,CAAAA,CAAO,IAAA,CAAOY,CAChB,CAEO,SAASC,CAAAA,CAAwBC,CAAAA,CAAyB,CAC/Db,CAAAA,CAAuBa,CAAAA,CACvBd,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,oBAAA,CAAsBc,CAAQ,CACtD,CAEO,SAASC,CAAAA,CAAAA,CAAoC,CAClD,OAAOd,CACT,CCnDA,IAAMe,CAAAA,CAAkB,CAACV,CAAAA,CAAmBM,CAAAA,CAAAA,EAC1C,CAAA,sBAAA,EAAyB,kBAAA,kBAAmBA,CAAAA,SAAQ,sBAAoB,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBN,CAAS,CAAC,CAAA,CAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-
|
|
1
|
+
{"version":3,"sources":["../src/panel/config.ts","../src/panel/session-storage.ts"],"names":["config","allowedReturnOrigins","setPanelConfig","newConfig","getPanelConfig","setProjectID","projectID","setTheme","theme","setLoginURL","loginURL","setHost","host","setAllowedReturnOrigins","origins","getAllowedReturnOrigins","panelSessionKey"],"mappings":"AAEA,iLAAIA,CAAAA,CAAsB,CACxB,SAAA,CAAW,KAAA,CAAA,CACX,QAAA,CAAU,cAAA,CACV,KAAA,CAAO,KAAA,CAAA,CACP,IAAA,CAAM,KAAA,CAAA,CACN,oBAAA,CAAsB,CAAC,CACzB,CAAA,CAEIC,CAAAA,CAAiC,CAAC,CAAA,CAU/B,SAASC,CAAAA,CAAeC,CAAAA,CAAuC,CACpEH,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,GAAGG,CAAU,CACrC,CAEO,SAASC,CAAAA,CAAAA,CAA8B,CAC5C,OAAOJ,CACT,CAEO,SAASK,CAAAA,CAAaC,CAAAA,CAAyB,CACpDN,CAAAA,CAAO,SAAA,CAAYM,CACrB,CAEO,SAASC,CAAAA,CAASC,CAAAA,CAA6B,CACpDR,CAAAA,CAAO,KAAA,CAAQQ,CACjB,CAEO,SAASC,CAAAA,CAAYC,CAAAA,CAAwB,CAClDV,CAAAA,CAAO,QAAA,CAAWU,CACpB,CAEO,SAASC,CAAAA,CAAQC,CAAAA,CAAoB,CAC1CZ,CAAAA,CAAO,IAAA,CAAOY,CAChB,CAEO,SAASC,CAAAA,CAAwBC,CAAAA,CAAyB,CAC/Db,CAAAA,CAAuBa,CAAAA,CACvBd,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,oBAAA,CAAsBc,CAAQ,CACtD,CAEO,SAASC,CAAAA,CAAAA,CAAoC,CAClD,OAAOd,CACT,CCnDA,IAAMe,CAAAA,CAAkB,CAACV,CAAAA,CAAmBM,CAAAA,CAAAA,EAC1C,CAAA,sBAAA,EAAyB,kBAAA,kBAAmBA,CAAAA,SAAQ,sBAAoB,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBN,CAAS,CAAC,CAAA,CAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-attachments/dist/chunk-MDAFPGPA.js","sourcesContent":["import type { GetThemeOutput } from \"./types\";\n\nlet config: PanelConfig = {\n projectID: undefined,\n loginURL: \"/panel/login\",\n theme: undefined,\n host: undefined,\n allowedReturnOrigins: [],\n};\n\nlet allowedReturnOrigins: string[] = [];\n\nexport interface PanelConfig {\n projectID?: string;\n loginURL?: string;\n theme?: GetThemeOutput;\n host?: string;\n allowedReturnOrigins: string[];\n}\n\nexport function setPanelConfig(newConfig: Partial<PanelConfig>): void {\n config = { ...config, ...newConfig };\n}\n\nexport function getPanelConfig(): PanelConfig {\n return config;\n}\n\nexport function setProjectID(projectID: string): void {\n config.projectID = projectID;\n}\n\nexport function setTheme(theme: GetThemeOutput): void {\n config.theme = theme;\n}\n\nexport function setLoginURL(loginURL: string): void {\n config.loginURL = loginURL;\n}\n\nexport function setHost(host: string): void {\n config.host = host;\n}\n\nexport function setAllowedReturnOrigins(origins: string[]): void {\n allowedReturnOrigins = origins;\n config = { ...config, allowedReturnOrigins: origins };\n}\n\nexport function getAllowedReturnOrigins(): string[] {\n return allowedReturnOrigins;\n}\n","const panelSessionKey = (projectID: string, host?: string) =>\n `bitsnap-panel-session:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nconst panelEmailKey = (projectID: string, host?: string) =>\n `bitsnap-panel-email:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nexport function getPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return undefined;\n const token = window.localStorage.getItem(panelSessionKey(projectID, host));\n return token ?? undefined;\n}\n\nexport function savePanelSession(projectID: string | undefined, token: string, email: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.setItem(panelSessionKey(projectID, host), token);\n window.localStorage.setItem(panelEmailKey(projectID, host), email);\n}\n\nexport function getPanelEmail(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return null;\n return window.localStorage.getItem(panelEmailKey(projectID, host));\n}\n\nexport function clearPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.removeItem(panelSessionKey(projectID, host));\n window.localStorage.removeItem(panelEmailKey(projectID, host));\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/texts.ts","../src/components/checkout/texts.ts","../src/components/checkout/locale.ts"],"names":["pickLocaleTable","tables","locale","mergeTexts","table","overrides","result","key","value","resolveTexts","lookupText","texts","CHECKOUT_TEXT_TABLES","resolveCheckoutTexts","getCheckoutText","DEFAULT_LOCALE","localeStorageKey","activeLocale","setLocale","getLocale"],"mappings":"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","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-free-pwyw/dist/chunk-Q337IQNA.js","sourcesContent":["/**\n * Shared text machinery: typed string tables per locale, the locale fallback\n * and a merge with caller overrides. Each module (checkout, later returns)\n * supplies its own key type and default tables.\n */\n\n/** Strings of one locale, keyed by text key. */\nexport type TextTable<Key extends string> = Record<Key, string>;\n\n/** Default tables for the supported locales. */\nexport type LocaleTables<Key extends string> = {\n en: TextTable<Key>;\n pl: TextTable<Key>;\n};\n\n/**\n * Picks the table for a locale. Any locale starting with `en` (case\n * insensitive, so `en`, `en-US`, `EN-gb`) gets English; everything else,\n * including unknown locales, gets the Polish default.\n */\nexport function pickLocaleTable<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n): TextTable<Key> {\n return locale.toLowerCase().startsWith(\"en\") ? tables.en : tables.pl;\n}\n\n/**\n * Merges caller overrides over a table. Overrides apply regardless of the\n * locale; `undefined`/`null` entries are ignored so the default stays.\n */\nexport function mergeTexts<Key extends string>(\n table: TextTable<Key>,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n const result: Record<string, string> = { ...table };\n\n if (overrides != null) {\n for (const [key, value] of Object.entries<string | undefined>(overrides)) {\n if (value != null) {\n result[key] = value;\n }\n }\n }\n\n return result as TextTable<Key>;\n}\n\n/** Locale table merged with the caller overrides. */\nexport function resolveTexts<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n return mergeTexts(pickLocaleTable(tables, locale), overrides);\n}\n\n/** Looks up a single text. Unknown keys return the key itself. */\nexport function lookupText<Key extends string>(\n texts: TextTable<Key>,\n key: Key,\n): string {\n return (texts as Record<string, string | undefined>)[key] ?? key;\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string the checkout renders. Pass a partial object through the\n * `texts` prop of `BitsnapCheckout` to override any of them, whatever the\n * locale.\n */\nexport type CheckoutTexts = {\n /** Drawer title. */\n cart: string;\n /** Shown when the cart has no products. */\n emptyCart: string;\n /** Label next to the total price. */\n total: string;\n /** Delivery note next to the total price. */\n delivery: string;\n /** Country selector placeholder. */\n chooseCountry: string;\n /** Checkout button label. */\n nextStep: string;\n /** Error shown when some products are out of stock. */\n unavailableProducts: string;\n /** Error shown when the checkout fails and the server gave no reason. */\n checkoutFailed: string;\n /** Error shown when the shop has no payment gateway connected. */\n noPaymentGateway: string;\n /** Error shown when the payment gateway of the shop is not set up. */\n gatewayNotConfigured: string;\n /** Error shown when delivery of the shop is not set up. */\n shippingNotConfigured: string;\n /** Error shown when the cart mixes subscriptions with one-time products. */\n mixedRecurring: string;\n /** Error shown when the cart currency cannot be paid in. */\n currencyUnsupported: string;\n /** Error shown when a price changed after the product was added. */\n priceChanged: string;\n /** Accessible name of the close button of the drawer. */\n close: string;\n /** Remove button of a cart line (also read together with the product name). */\n remove: string;\n /** Accessible name of the quantity control and its input. */\n quantity: string;\n /** Accessible name of the \"+\" quantity button. */\n increaseQuantity: string;\n /** Accessible name of the \"-\" quantity button. */\n decreaseQuantity: string;\n /** Accessible name of the cart button when it only shows an icon. */\n openCart: string;\n /** Hidden label of the number of products badge; the number is appended after a colon. */\n cartItemsCount: string;\n /** Label before the lowest price of the last 30 days; the price is appended. */\n lowestPrice30Days: string;\n /** Shown instead of the lowest price when the price has no history. */\n noPriceHistory: string;\n /** Error shown when redirecting to the payment failed. */\n redirectFailed: string;\n /** Error shown when a subscription is added to the cart. */\n subscriptionUnsupported: string;\n /** Country search placeholder. */\n searchCountry: string;\n /** Shown when the country search has no match. */\n noCountriesFound: string;\n /** Hint under the checkout button when no country is chosen. */\n countryRequired: string;\n /** Title of the Apple Pay and Google Pay sheet total. */\n paymentForCart: string;\n /** Coupon label in the Google Pay sheet; the code is appended. */\n coupon: string;\n /** Note under the cart total. */\n extrasCalculatedNext: string;\n /** Error shown when the products of the cart could not be loaded. */\n loadFailed: string;\n /** Button that loads the cart again. */\n retry: string;\n /** Heading of the payment method choice (shown only when the shop offers paying by hand). */\n paymentMethodLegend: string;\n /** Option that pays through the shop's online gateway. */\n paymentMethodOnline: string;\n /** Hint under the online option. */\n paymentMethodOnlineDescription: string;\n /** Manual option when the seller takes bank transfers only. */\n paymentMethodManualTransfer: string;\n /** Manual option when the seller takes BLIK transfers to a phone number only. */\n paymentMethodManualBlik: string;\n /** Manual option when the seller takes both. */\n paymentMethodManualBoth: string;\n /** What paying by hand means: the details come after the order is placed. */\n paymentMethodManualDescription: string;\n /** Shown with a selected manual option that includes BLIK to a phone number. */\n paymentMethodManualBlikNote: string;\n /** Cash on delivery option. */\n paymentMethodCod: string;\n /** Hint under the cash on delivery option. */\n paymentMethodCodDescription: string;\n /** Error shown when the shop refused cash on delivery for the order. */\n paymentMethodCodUnavailable: string;\n /** Status while the provider confirms a payment started from an express button. */\n expressPending: string;\n /** Status after the provider confirmed the payment. */\n expressConfirmed: string;\n /** Status when the provider reports a failed payment. */\n expressFailed: string;\n /** Status when the buyer cancelled the provider's payment flow. */\n expressCancelled: string;\n /** Shown while the payment is still unconfirmed after a page return. */\n expressPendingLong: string;\n /** Error shown when the provider's button could not be loaded. */\n expressLoadFailed: string;\n /** Error shown when the cart cannot be paid with this provider right now. */\n expressCartUnavailable: string;\n /** Error shown when another tab/provider changed the same cart line. */\n expressCartConflict: string;\n /** Shown when the server total changed between mounting and paying. */\n expressPriceChanged: string;\n /** Error shown when a product could not be added before the InPost binding. */\n expressProductUnavailable: string;\n};\n\nexport type CheckoutTextKey = keyof CheckoutTexts;\n\nexport const CHECKOUT_TEXT_TABLES: LocaleTables<CheckoutTextKey> = {\n en: {\n cart: \"Cart\",\n emptyCart: \"Your cart is empty.\",\n total: \"Total:\",\n delivery: \"+ delivery\",\n chooseCountry: \"Choose a country\",\n nextStep: \"Next step\",\n unavailableProducts: \"Not all products are available.\",\n checkoutFailed: \"Something went wrong. Please try again later.\",\n noPaymentGateway:\n \"This shop doesn't accept online payments yet. Try again later or contact the seller.\",\n gatewayNotConfigured:\n \"Payments in this shop are not set up correctly. Try again later or contact the seller.\",\n shippingNotConfigured:\n \"Delivery in this shop is not configured yet. Try again later or contact the seller.\",\n mixedRecurring:\n \"Subscriptions and one-time products cannot be paid for together. Pay for them in separate orders.\",\n currencyUnsupported:\n \"The shop doesn't accept payments in this currency. Contact the seller.\",\n priceChanged: \"The product price has changed. Refresh the page to see the current price.\",\n close: \"Close cart\",\n remove: \"Remove\",\n quantity: \"Quantity\",\n increaseQuantity: \"Increase quantity\",\n decreaseQuantity: \"Decrease quantity\",\n openCart: \"Open cart\",\n cartItemsCount: \"Items in cart\",\n lowestPrice30Days: \"Lowest price in the last 30 days:\",\n noPriceHistory: \"No price data for the last 30 days\",\n redirectFailed: \"Could not redirect to the payment. Please try again later.\",\n subscriptionUnsupported: \"Subscriptions cannot be added to the cart yet.\",\n searchCountry: \"Find a country\",\n noCountriesFound: \"No countries found\",\n countryRequired: \"Choose a country to continue.\",\n paymentForCart: \"Cart payment\",\n coupon: \"Coupon\",\n extrasCalculatedNext:\n \"Discounts, shipping and taxes are calculated at the next step\",\n loadFailed: \"Could not load your cart.\",\n retry: \"Try again\",\n paymentMethodLegend: \"How would you like to pay?\",\n paymentMethodOnline: \"Pay online\",\n paymentMethodOnlineDescription:\n \"Card, BLIK code or instant bank payment. You pay right away.\",\n paymentMethodManualTransfer: \"Bank transfer\",\n paymentMethodManualBlik: \"BLIK – transfer to a phone number\",\n paymentMethodManualBoth: \"Bank transfer or BLIK to a phone number\",\n paymentMethodManualDescription:\n \"You pay in your bank's app. We show the payment details after you place the order, and the order waits for your payment.\",\n paymentMethodManualBlikNote:\n \"This is not a BLIK code payment – you do not enter a 6‑digit code.\",\n paymentMethodCod: \"Cash on delivery\",\n paymentMethodCodDescription:\n \"You pay the courier in cash or by card when you receive the parcel.\",\n paymentMethodCodUnavailable:\n \"Cash on delivery is not available for this order. Choose another way to pay.\",\n expressPending: \"Confirming your payment…\",\n expressConfirmed: \"Payment confirmed. Thank you!\",\n expressFailed: \"The payment failed. Your cart is unchanged.\",\n expressCancelled: \"Payment cancelled. Your cart is unchanged.\",\n expressPendingLong:\n \"We are still confirming your payment. We will check again when you come back to this page.\",\n expressLoadFailed:\n \"Could not load this payment button. Try again later or use the regular checkout.\",\n expressCartUnavailable:\n \"This cart cannot be paid with this method right now. Try again later.\",\n expressCartConflict:\n \"Your cart changed in another tab or in the provider's app. Review the quantities and try again.\",\n expressPriceChanged:\n \"Your cart total changed. Check the new total and try again.\",\n expressProductUnavailable:\n \"This product cannot be paid for right now. Try again later.\",\n },\n pl: {\n cart: \"Koszyk\",\n emptyCart: \"Brak produktów w koszyku.\",\n total: \"Suma:\",\n delivery: \"+ dostawa\",\n chooseCountry: \"Wybierz kraj\",\n nextStep: \"Następny krok\",\n unavailableProducts: \"Nie wszystkie produkty są dostępne w magazynie.\",\n checkoutFailed: \"Coś poszło nie tak. Spróbuj ponownie później.\",\n noPaymentGateway:\n \"Ten sklep nie przyjmuje jeszcze płatności online. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n gatewayNotConfigured:\n \"Płatności w tym sklepie nie są poprawnie skonfigurowane. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n shippingNotConfigured:\n \"Dostawa w tym sklepie nie jest jeszcze skonfigurowana. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n mixedRecurring:\n \"Subskrypcji i produktów jednorazowych nie można opłacić razem. Opłać je w osobnych zamówieniach.\",\n currencyUnsupported:\n \"Sklep nie przyjmuje płatności w tej walucie. Skontaktuj się ze sprzedawcą.\",\n priceChanged: \"Cena produktu się zmieniła. Odśwież stronę, aby zobaczyć aktualną cenę.\",\n close: \"Zamknij koszyk\",\n remove: \"Usuń\",\n quantity: \"Ilość\",\n increaseQuantity: \"Zwiększ ilość\",\n decreaseQuantity: \"Zmniejsz ilość\",\n openCart: \"Otwórz koszyk\",\n cartItemsCount: \"Produktów w koszyku\",\n lowestPrice30Days: \"Najniższa cena z 30 dni:\",\n noPriceHistory: \"Brak danych o cenie z ostatnich 30 dni\",\n redirectFailed:\n \"Nie udało się przekierować do płatności. Spróbuj ponownie później.\",\n subscriptionUnsupported: \"Subskrypcji nie można jeszcze dodać do koszyka.\",\n searchCountry: \"Znajdź kraj\",\n noCountriesFound: \"Nie znaleziono krajów\",\n countryRequired: \"Wybierz kraj, aby przejść dalej.\",\n paymentForCart: \"Płatność za koszyk\",\n coupon: \"Kupon\",\n extrasCalculatedNext: \"Rabaty, dostawa i podatki w następnym kroku\",\n loadFailed: \"Nie udało się wczytać koszyka.\",\n retry: \"Spróbuj ponownie\",\n paymentMethodLegend: \"Jak chcesz zapłacić?\",\n paymentMethodOnline: \"Zapłać online\",\n paymentMethodOnlineDescription:\n \"Karta, kod BLIK lub szybki przelew. Płacisz od razu.\",\n paymentMethodManualTransfer: \"Przelew bankowy\",\n paymentMethodManualBlik: \"BLIK – przelew na telefon\",\n paymentMethodManualBoth: \"Przelew lub BLIK na telefon\",\n paymentMethodManualDescription:\n \"Zapłacisz w aplikacji swojego banku. Dane do płatności pokażemy po złożeniu zamówienia, a zamówienie poczeka na Twoją wpłatę.\",\n paymentMethodManualBlikNote:\n \"To nie jest płatność kodem BLIK – nie wpisujesz 6‑cyfrowego kodu.\",\n paymentMethodCod: \"Płatność przy odbiorze\",\n paymentMethodCodDescription:\n \"Zapłacisz kurierowi gotówką lub kartą, gdy odbierzesz przesyłkę.\",\n paymentMethodCodUnavailable:\n \"Płatność przy odbiorze nie jest dostępna dla tego zamówienia. Wybierz inną formę płatności.\",\n expressPending: \"Potwierdzamy płatność…\",\n expressConfirmed: \"Płatność potwierdzona. Dziękujemy!\",\n expressFailed: \"Płatność się nie udała. Koszyk pozostał bez zmian.\",\n expressCancelled: \"Płatność została anulowana. Koszyk pozostał bez zmian.\",\n expressPendingLong:\n \"Nadal potwierdzamy Twoją płatność. Sprawdzimy ponownie, gdy wrócisz na tę stronę.\",\n expressLoadFailed:\n \"Nie udało się wczytać przycisku płatności. Spróbuj ponownie później lub skorzystaj ze zwykłego koszyka.\",\n expressCartUnavailable:\n \"Tego koszyka nie można teraz opłacić tą metodą. Spróbuj ponownie później.\",\n expressCartConflict:\n \"Koszyk zmienił się w innej karcie lub w aplikacji przewoźnika. Sprawdź ilości i spróbuj ponownie.\",\n expressPriceChanged:\n \"Suma koszyka się zmieniła. Sprawdź nową sumę i spróbuj ponownie.\",\n expressProductUnavailable:\n \"Nie można teraz zapłacić za ten produkt. Spróbuj ponownie później.\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveCheckoutTexts(\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): CheckoutTexts {\n return resolveTexts(CHECKOUT_TEXT_TABLES, locale, overrides);\n}\n\nexport function getCheckoutText(\n key: CheckoutTextKey,\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): string {\n return lookupText(resolveCheckoutTexts(locale, overrides), key);\n}\n","import { pickLocaleTable } from \"@/src/lib/texts\";\nimport { CHECKOUT_TEXT_TABLES } from \"./texts\";\n\nexport const DEFAULT_LOCALE = \"pl-PL\" as const;\nconst localeStorageKey = \"bitsnap-locale\";\n\nlet activeLocale: string | undefined;\n\nexport function setLocale(locale?: string): void {\n const value = locale?.trim();\n activeLocale = value\n ? value.toLowerCase() === \"en\"\n ? \"en-US\"\n : value.toLowerCase() === \"pl\"\n ? DEFAULT_LOCALE\n : value\n : undefined;\n if (typeof localStorage !== \"undefined\") {\n if (activeLocale == null) {\n localStorage.removeItem(localeStorageKey);\n } else {\n localStorage.setItem(localeStorageKey, activeLocale);\n }\n }\n}\n\nexport function getLocale(): string {\n if (activeLocale != null) {\n return activeLocale;\n }\n if (typeof localStorage !== \"undefined\") {\n return localStorage.getItem(localeStorageKey) ?? DEFAULT_LOCALE;\n }\n return DEFAULT_LOCALE;\n}\n\nexport function translate(key: string, locale: string = getLocale()): string {\n return (\n (pickLocaleTable(CHECKOUT_TEXT_TABLES, locale) as Record<string, string>)[\n key\n ] ?? key\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/texts.ts","../src/components/checkout/texts.ts","../src/components/checkout/locale.ts"],"names":["pickLocaleTable","tables","locale","mergeTexts","table","overrides","result","key","value","resolveTexts","lookupText","texts","CHECKOUT_TEXT_TABLES","resolveCheckoutTexts","getCheckoutText","DEFAULT_LOCALE","localeStorageKey","activeLocale","setLocale","getLocale"],"mappings":"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","file":"/home/emems/.t3/worktrees/bitsnap-react/chat-attachments/dist/chunk-Q337IQNA.js","sourcesContent":["/**\n * Shared text machinery: typed string tables per locale, the locale fallback\n * and a merge with caller overrides. Each module (checkout, later returns)\n * supplies its own key type and default tables.\n */\n\n/** Strings of one locale, keyed by text key. */\nexport type TextTable<Key extends string> = Record<Key, string>;\n\n/** Default tables for the supported locales. */\nexport type LocaleTables<Key extends string> = {\n en: TextTable<Key>;\n pl: TextTable<Key>;\n};\n\n/**\n * Picks the table for a locale. Any locale starting with `en` (case\n * insensitive, so `en`, `en-US`, `EN-gb`) gets English; everything else,\n * including unknown locales, gets the Polish default.\n */\nexport function pickLocaleTable<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n): TextTable<Key> {\n return locale.toLowerCase().startsWith(\"en\") ? tables.en : tables.pl;\n}\n\n/**\n * Merges caller overrides over a table. Overrides apply regardless of the\n * locale; `undefined`/`null` entries are ignored so the default stays.\n */\nexport function mergeTexts<Key extends string>(\n table: TextTable<Key>,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n const result: Record<string, string> = { ...table };\n\n if (overrides != null) {\n for (const [key, value] of Object.entries<string | undefined>(overrides)) {\n if (value != null) {\n result[key] = value;\n }\n }\n }\n\n return result as TextTable<Key>;\n}\n\n/** Locale table merged with the caller overrides. */\nexport function resolveTexts<Key extends string>(\n tables: LocaleTables<Key>,\n locale: string,\n overrides?: Partial<TextTable<Key>>,\n): TextTable<Key> {\n return mergeTexts(pickLocaleTable(tables, locale), overrides);\n}\n\n/** Looks up a single text. Unknown keys return the key itself. */\nexport function lookupText<Key extends string>(\n texts: TextTable<Key>,\n key: Key,\n): string {\n return (texts as Record<string, string | undefined>)[key] ?? key;\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string the checkout renders. Pass a partial object through the\n * `texts` prop of `BitsnapCheckout` to override any of them, whatever the\n * locale.\n */\nexport type CheckoutTexts = {\n /** Drawer title. */\n cart: string;\n /** Shown when the cart has no products. */\n emptyCart: string;\n /** Label next to the total price. */\n total: string;\n /** Delivery note next to the total price. */\n delivery: string;\n /** Country selector placeholder. */\n chooseCountry: string;\n /** Checkout button label. */\n nextStep: string;\n /** Error shown when some products are out of stock. */\n unavailableProducts: string;\n /** Error shown when the checkout fails and the server gave no reason. */\n checkoutFailed: string;\n /** Error shown when the shop has no payment gateway connected. */\n noPaymentGateway: string;\n /** Error shown when the payment gateway of the shop is not set up. */\n gatewayNotConfigured: string;\n /** Error shown when delivery of the shop is not set up. */\n shippingNotConfigured: string;\n /** Error shown when the cart mixes subscriptions with one-time products. */\n mixedRecurring: string;\n /** Error shown when the cart currency cannot be paid in. */\n currencyUnsupported: string;\n /** Error shown when a price changed after the product was added. */\n priceChanged: string;\n /** Accessible name of the close button of the drawer. */\n close: string;\n /** Remove button of a cart line (also read together with the product name). */\n remove: string;\n /** Accessible name of the quantity control and its input. */\n quantity: string;\n /** Accessible name of the \"+\" quantity button. */\n increaseQuantity: string;\n /** Accessible name of the \"-\" quantity button. */\n decreaseQuantity: string;\n /** Accessible name of the cart button when it only shows an icon. */\n openCart: string;\n /** Hidden label of the number of products badge; the number is appended after a colon. */\n cartItemsCount: string;\n /** Label before the lowest price of the last 30 days; the price is appended. */\n lowestPrice30Days: string;\n /** Shown instead of the lowest price when the price has no history. */\n noPriceHistory: string;\n /** Error shown when redirecting to the payment failed. */\n redirectFailed: string;\n /** Error shown when a subscription is added to the cart. */\n subscriptionUnsupported: string;\n /** Country search placeholder. */\n searchCountry: string;\n /** Shown when the country search has no match. */\n noCountriesFound: string;\n /** Hint under the checkout button when no country is chosen. */\n countryRequired: string;\n /** Title of the Apple Pay and Google Pay sheet total. */\n paymentForCart: string;\n /** Coupon label in the Google Pay sheet; the code is appended. */\n coupon: string;\n /** Note under the cart total. */\n extrasCalculatedNext: string;\n /** Error shown when the products of the cart could not be loaded. */\n loadFailed: string;\n /** Button that loads the cart again. */\n retry: string;\n /** Heading of the payment method choice (shown only when the shop offers paying by hand). */\n paymentMethodLegend: string;\n /** Option that pays through the shop's online gateway. */\n paymentMethodOnline: string;\n /** Hint under the online option. */\n paymentMethodOnlineDescription: string;\n /** Manual option when the seller takes bank transfers only. */\n paymentMethodManualTransfer: string;\n /** Manual option when the seller takes BLIK transfers to a phone number only. */\n paymentMethodManualBlik: string;\n /** Manual option when the seller takes both. */\n paymentMethodManualBoth: string;\n /** What paying by hand means: the details come after the order is placed. */\n paymentMethodManualDescription: string;\n /** Shown with a selected manual option that includes BLIK to a phone number. */\n paymentMethodManualBlikNote: string;\n /** Cash on delivery option. */\n paymentMethodCod: string;\n /** Hint under the cash on delivery option. */\n paymentMethodCodDescription: string;\n /** Error shown when the shop refused cash on delivery for the order. */\n paymentMethodCodUnavailable: string;\n /** Status while the provider confirms a payment started from an express button. */\n expressPending: string;\n /** Status after the provider confirmed the payment. */\n expressConfirmed: string;\n /** Status when the provider reports a failed payment. */\n expressFailed: string;\n /** Status when the buyer cancelled the provider's payment flow. */\n expressCancelled: string;\n /** Shown while the payment is still unconfirmed after a page return. */\n expressPendingLong: string;\n /** Error shown when the provider's button could not be loaded. */\n expressLoadFailed: string;\n /** Error shown when the cart cannot be paid with this provider right now. */\n expressCartUnavailable: string;\n /** Error shown when another tab/provider changed the same cart line. */\n expressCartConflict: string;\n /** Shown when the server total changed between mounting and paying. */\n expressPriceChanged: string;\n /** Error shown when a product could not be added before the InPost binding. */\n expressProductUnavailable: string;\n};\n\nexport type CheckoutTextKey = keyof CheckoutTexts;\n\nexport const CHECKOUT_TEXT_TABLES: LocaleTables<CheckoutTextKey> = {\n en: {\n cart: \"Cart\",\n emptyCart: \"Your cart is empty.\",\n total: \"Total:\",\n delivery: \"+ delivery\",\n chooseCountry: \"Choose a country\",\n nextStep: \"Next step\",\n unavailableProducts: \"Not all products are available.\",\n checkoutFailed: \"Something went wrong. Please try again later.\",\n noPaymentGateway:\n \"This shop doesn't accept online payments yet. Try again later or contact the seller.\",\n gatewayNotConfigured:\n \"Payments in this shop are not set up correctly. Try again later or contact the seller.\",\n shippingNotConfigured:\n \"Delivery in this shop is not configured yet. Try again later or contact the seller.\",\n mixedRecurring:\n \"Subscriptions and one-time products cannot be paid for together. Pay for them in separate orders.\",\n currencyUnsupported:\n \"The shop doesn't accept payments in this currency. Contact the seller.\",\n priceChanged: \"The product price has changed. Refresh the page to see the current price.\",\n close: \"Close cart\",\n remove: \"Remove\",\n quantity: \"Quantity\",\n increaseQuantity: \"Increase quantity\",\n decreaseQuantity: \"Decrease quantity\",\n openCart: \"Open cart\",\n cartItemsCount: \"Items in cart\",\n lowestPrice30Days: \"Lowest price in the last 30 days:\",\n noPriceHistory: \"No price data for the last 30 days\",\n redirectFailed: \"Could not redirect to the payment. Please try again later.\",\n subscriptionUnsupported: \"Subscriptions cannot be added to the cart yet.\",\n searchCountry: \"Find a country\",\n noCountriesFound: \"No countries found\",\n countryRequired: \"Choose a country to continue.\",\n paymentForCart: \"Cart payment\",\n coupon: \"Coupon\",\n extrasCalculatedNext:\n \"Discounts, shipping and taxes are calculated at the next step\",\n loadFailed: \"Could not load your cart.\",\n retry: \"Try again\",\n paymentMethodLegend: \"How would you like to pay?\",\n paymentMethodOnline: \"Pay online\",\n paymentMethodOnlineDescription:\n \"Card, BLIK code or instant bank payment. You pay right away.\",\n paymentMethodManualTransfer: \"Bank transfer\",\n paymentMethodManualBlik: \"BLIK – transfer to a phone number\",\n paymentMethodManualBoth: \"Bank transfer or BLIK to a phone number\",\n paymentMethodManualDescription:\n \"You pay in your bank's app. We show the payment details after you place the order, and the order waits for your payment.\",\n paymentMethodManualBlikNote:\n \"This is not a BLIK code payment – you do not enter a 6‑digit code.\",\n paymentMethodCod: \"Cash on delivery\",\n paymentMethodCodDescription:\n \"You pay the courier in cash or by card when you receive the parcel.\",\n paymentMethodCodUnavailable:\n \"Cash on delivery is not available for this order. Choose another way to pay.\",\n expressPending: \"Confirming your payment…\",\n expressConfirmed: \"Payment confirmed. Thank you!\",\n expressFailed: \"The payment failed. Your cart is unchanged.\",\n expressCancelled: \"Payment cancelled. Your cart is unchanged.\",\n expressPendingLong:\n \"We are still confirming your payment. We will check again when you come back to this page.\",\n expressLoadFailed:\n \"Could not load this payment button. Try again later or use the regular checkout.\",\n expressCartUnavailable:\n \"This cart cannot be paid with this method right now. Try again later.\",\n expressCartConflict:\n \"Your cart changed in another tab or in the provider's app. Review the quantities and try again.\",\n expressPriceChanged:\n \"Your cart total changed. Check the new total and try again.\",\n expressProductUnavailable:\n \"This product cannot be paid for right now. Try again later.\",\n },\n pl: {\n cart: \"Koszyk\",\n emptyCart: \"Brak produktów w koszyku.\",\n total: \"Suma:\",\n delivery: \"+ dostawa\",\n chooseCountry: \"Wybierz kraj\",\n nextStep: \"Następny krok\",\n unavailableProducts: \"Nie wszystkie produkty są dostępne w magazynie.\",\n checkoutFailed: \"Coś poszło nie tak. Spróbuj ponownie później.\",\n noPaymentGateway:\n \"Ten sklep nie przyjmuje jeszcze płatności online. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n gatewayNotConfigured:\n \"Płatności w tym sklepie nie są poprawnie skonfigurowane. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n shippingNotConfigured:\n \"Dostawa w tym sklepie nie jest jeszcze skonfigurowana. Spróbuj ponownie później lub skontaktuj się ze sprzedawcą.\",\n mixedRecurring:\n \"Subskrypcji i produktów jednorazowych nie można opłacić razem. Opłać je w osobnych zamówieniach.\",\n currencyUnsupported:\n \"Sklep nie przyjmuje płatności w tej walucie. Skontaktuj się ze sprzedawcą.\",\n priceChanged: \"Cena produktu się zmieniła. Odśwież stronę, aby zobaczyć aktualną cenę.\",\n close: \"Zamknij koszyk\",\n remove: \"Usuń\",\n quantity: \"Ilość\",\n increaseQuantity: \"Zwiększ ilość\",\n decreaseQuantity: \"Zmniejsz ilość\",\n openCart: \"Otwórz koszyk\",\n cartItemsCount: \"Produktów w koszyku\",\n lowestPrice30Days: \"Najniższa cena z 30 dni:\",\n noPriceHistory: \"Brak danych o cenie z ostatnich 30 dni\",\n redirectFailed:\n \"Nie udało się przekierować do płatności. Spróbuj ponownie później.\",\n subscriptionUnsupported: \"Subskrypcji nie można jeszcze dodać do koszyka.\",\n searchCountry: \"Znajdź kraj\",\n noCountriesFound: \"Nie znaleziono krajów\",\n countryRequired: \"Wybierz kraj, aby przejść dalej.\",\n paymentForCart: \"Płatność za koszyk\",\n coupon: \"Kupon\",\n extrasCalculatedNext: \"Rabaty, dostawa i podatki w następnym kroku\",\n loadFailed: \"Nie udało się wczytać koszyka.\",\n retry: \"Spróbuj ponownie\",\n paymentMethodLegend: \"Jak chcesz zapłacić?\",\n paymentMethodOnline: \"Zapłać online\",\n paymentMethodOnlineDescription:\n \"Karta, kod BLIK lub szybki przelew. Płacisz od razu.\",\n paymentMethodManualTransfer: \"Przelew bankowy\",\n paymentMethodManualBlik: \"BLIK – przelew na telefon\",\n paymentMethodManualBoth: \"Przelew lub BLIK na telefon\",\n paymentMethodManualDescription:\n \"Zapłacisz w aplikacji swojego banku. Dane do płatności pokażemy po złożeniu zamówienia, a zamówienie poczeka na Twoją wpłatę.\",\n paymentMethodManualBlikNote:\n \"To nie jest płatność kodem BLIK – nie wpisujesz 6‑cyfrowego kodu.\",\n paymentMethodCod: \"Płatność przy odbiorze\",\n paymentMethodCodDescription:\n \"Zapłacisz kurierowi gotówką lub kartą, gdy odbierzesz przesyłkę.\",\n paymentMethodCodUnavailable:\n \"Płatność przy odbiorze nie jest dostępna dla tego zamówienia. Wybierz inną formę płatności.\",\n expressPending: \"Potwierdzamy płatność…\",\n expressConfirmed: \"Płatność potwierdzona. Dziękujemy!\",\n expressFailed: \"Płatność się nie udała. Koszyk pozostał bez zmian.\",\n expressCancelled: \"Płatność została anulowana. Koszyk pozostał bez zmian.\",\n expressPendingLong:\n \"Nadal potwierdzamy Twoją płatność. Sprawdzimy ponownie, gdy wrócisz na tę stronę.\",\n expressLoadFailed:\n \"Nie udało się wczytać przycisku płatności. Spróbuj ponownie później lub skorzystaj ze zwykłego koszyka.\",\n expressCartUnavailable:\n \"Tego koszyka nie można teraz opłacić tą metodą. Spróbuj ponownie później.\",\n expressCartConflict:\n \"Koszyk zmienił się w innej karcie lub w aplikacji przewoźnika. Sprawdź ilości i spróbuj ponownie.\",\n expressPriceChanged:\n \"Suma koszyka się zmieniła. Sprawdź nową sumę i spróbuj ponownie.\",\n expressProductUnavailable:\n \"Nie można teraz zapłacić za ten produkt. Spróbuj ponownie później.\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveCheckoutTexts(\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): CheckoutTexts {\n return resolveTexts(CHECKOUT_TEXT_TABLES, locale, overrides);\n}\n\nexport function getCheckoutText(\n key: CheckoutTextKey,\n locale: string,\n overrides?: Partial<CheckoutTexts>,\n): string {\n return lookupText(resolveCheckoutTexts(locale, overrides), key);\n}\n","import { pickLocaleTable } from \"@/src/lib/texts\";\nimport { CHECKOUT_TEXT_TABLES } from \"./texts\";\n\nexport const DEFAULT_LOCALE = \"pl-PL\" as const;\nconst localeStorageKey = \"bitsnap-locale\";\n\nlet activeLocale: string | undefined;\n\nexport function setLocale(locale?: string): void {\n const value = locale?.trim();\n activeLocale = value\n ? value.toLowerCase() === \"en\"\n ? \"en-US\"\n : value.toLowerCase() === \"pl\"\n ? DEFAULT_LOCALE\n : value\n : undefined;\n if (typeof localStorage !== \"undefined\") {\n if (activeLocale == null) {\n localStorage.removeItem(localeStorageKey);\n } else {\n localStorage.setItem(localeStorageKey, activeLocale);\n }\n }\n}\n\nexport function getLocale(): string {\n if (activeLocale != null) {\n return activeLocale;\n }\n if (typeof localStorage !== \"undefined\") {\n return localStorage.getItem(localeStorageKey) ?? DEFAULT_LOCALE;\n }\n return DEFAULT_LOCALE;\n}\n\nexport function translate(key: string, locale: string = getLocale()): string {\n return (\n (pickLocaleTable(CHECKOUT_TEXT_TABLES, locale) as Record<string, string>)[\n key\n ] ?? key\n );\n}\n"]}
|