bitsnap-react 1.14.0 → 1.15.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/AGENTS.md +246 -0
- package/README.md +99 -51
- package/dist/CartProvider-64QEJ7A7.js +2 -0
- package/dist/CartProvider-64QEJ7A7.js.map +1 -0
- package/dist/{CartProvider-GLUQHAG3.mjs → CartProvider-XKK7A3C2.mjs} +2 -2
- 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/{chunk-MVOJMCZG.mjs → chunk-2TLWMYXW.mjs} +2 -2
- package/dist/{chunk-5DDLYVBG.js → chunk-7DG4UPWE.js} +2 -2
- package/dist/chunk-7DG4UPWE.js.map +1 -0
- package/dist/{chunk-VY7RNSFP.mjs → chunk-7TLJKYZD.mjs} +2 -2
- package/dist/{chunk-U5SAO2SH.mjs → chunk-AZQOW73L.mjs} +2 -2
- package/dist/{chunk-U5SAO2SH.mjs.map → chunk-AZQOW73L.mjs.map} +1 -1
- package/dist/{chunk-AWG5OAK7.js → chunk-DY2S42Q6.js} +2 -2
- package/dist/chunk-DY2S42Q6.js.map +1 -0
- package/dist/{chunk-7SYNGA3R.js → chunk-FGB5FJCI.js} +2 -2
- package/dist/chunk-FGB5FJCI.js.map +1 -0
- package/dist/{chunk-JXVAT2ZE.js → chunk-GLAJPUMA.js} +2 -2
- package/dist/chunk-GLAJPUMA.js.map +1 -0
- package/dist/{chunk-FLDI3BPY.js → chunk-H4WAQQVO.js} +2 -2
- package/dist/chunk-H4WAQQVO.js.map +1 -0
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/{chunk-3N2VK426.js → chunk-MG6VV5J2.js} +2 -2
- package/dist/chunk-MG6VV5J2.js.map +1 -0
- package/dist/{chunk-3OEKRPWV.mjs → chunk-PEVB3VL4.mjs} +2 -2
- package/dist/{chunk-3OEKRPWV.mjs.map → chunk-PEVB3VL4.mjs.map} +1 -1
- package/dist/{chunk-CYLZ5GYW.mjs → chunk-Q3DSK66F.mjs} +2 -2
- package/dist/{chunk-SKFE6TUP.mjs → chunk-RWEP6IUC.mjs} +2 -2
- package/dist/{chunk-GKFET34B.mjs → chunk-S4Z4O46O.mjs} +2 -2
- package/dist/{chunk-R2M6W4LD.js → chunk-VY6CZVVA.js} +3 -3
- package/dist/chunk-VY6CZVVA.js.map +1 -0
- package/dist/chunk-W3RGQYPD.js.map +1 -1
- package/dist/{chunk-PLS5RR27.js → chunk-XZYCQ655.js} +2 -2
- package/dist/chunk-XZYCQ655.js.map +1 -0
- package/dist/{chunk-VYYUTJZB.mjs → chunk-ZIWQ57GY.mjs} +2 -2
- package/dist/consent.js +14 -7
- package/dist/consent.js.map +1 -1
- package/dist/consent.mjs +14 -7
- package/dist/consent.mjs.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/embed/consent.js +14 -7
- 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 +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/methods-NUMVR53L.js +2 -0
- package/dist/methods-NUMVR53L.js.map +1 -0
- package/dist/methods-YKZZ6OVT.mjs +2 -0
- 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/package.json +17 -16
- package/dist/CartProvider-6D5WE2HA.js +0 -2
- package/dist/CartProvider-6D5WE2HA.js.map +0 -1
- package/dist/chunk-3N2VK426.js.map +0 -1
- package/dist/chunk-5DDLYVBG.js.map +0 -1
- package/dist/chunk-7SYNGA3R.js.map +0 -1
- package/dist/chunk-AWG5OAK7.js.map +0 -1
- package/dist/chunk-FLDI3BPY.js.map +0 -1
- package/dist/chunk-JXVAT2ZE.js.map +0 -1
- package/dist/chunk-PLS5RR27.js.map +0 -1
- package/dist/chunk-R2M6W4LD.js.map +0 -1
- package/dist/methods-N35A2OGE.mjs +0 -2
- package/dist/methods-WSICR2JH.js +0 -2
- package/dist/methods-WSICR2JH.js.map +0 -1
- /package/dist/{CartProvider-GLUQHAG3.mjs.map → CartProvider-XKK7A3C2.mjs.map} +0 -0
- /package/dist/{chunk-MVOJMCZG.mjs.map → chunk-2TLWMYXW.mjs.map} +0 -0
- /package/dist/{chunk-VY7RNSFP.mjs.map → chunk-7TLJKYZD.mjs.map} +0 -0
- /package/dist/{chunk-CYLZ5GYW.mjs.map → chunk-Q3DSK66F.mjs.map} +0 -0
- /package/dist/{chunk-SKFE6TUP.mjs.map → chunk-RWEP6IUC.mjs.map} +0 -0
- /package/dist/{chunk-GKFET34B.mjs.map → chunk-S4Z4O46O.mjs.map} +0 -0
- /package/dist/{chunk-VYYUTJZB.mjs.map → chunk-ZIWQ57GY.mjs.map} +0 -0
- /package/dist/{methods-N35A2OGE.mjs.map → methods-YKZZ6OVT.mjs.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunkAWG5OAK7js = require('./chunk-AWG5OAK7.js');var _chunk3N2VK426js = require('./chunk-3N2VK426.js');var wt=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],Et={fontFamily:"--bitsnap-products-font-family",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},_t={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px"}},Dt=[];function pt(t){let e=_chunkKOYBZORLjs.a.call(void 0, t,{defaultTheme:"light",presets:_t,variables:Et,shadcnVariables:Dt});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function q(t,e){return _chunkKOYBZORLjs.b.call(void 0, t.elements,e)}function mt(t,e){try{return new Intl.NumberFormat(t,{style:"currency",currency:e,currencyDisplay:"symbol"})}catch (e2){return}}function H(t,e,r=_chunkAWG5OAK7js.k){let o=t/100,n=_nullishCoalesce(mt(r,e), () => (mt(_chunkAWG5OAK7js.k,e)));return n!=null?n.format(o):`${o.toFixed(2)} ${e}`}var _react = require('react');var Ot=24,Nt=48,M=class extends Error{constructor(e,r){super(e),this.name="ProductListError",this.status=r}};function O(t){return t==null||!Number.isFinite(t)?Ot:Math.min(Nt,Math.max(1,Math.floor(t)))}function ft(t,e){return Math.max(1,Math.ceil(t/e))}function N(t){return t.replace(/\/+$/,"")}function Rt(t){let e=new URLSearchParams;e.set("limit",String(t.limit)),e.set("offset",String(t.offset)),t.locale&&e.set("locale",t.locale);let r=_optionalChain([t, 'access', _2 => _2.search, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);return r&&e.set("search",r),`${N(t.host)}/api/integrations/${encodeURIComponent(t.projectID)}/public-commerce/product-list?${e.toString()}`}function Bt(t){return typeof t=="object"&&t!=null&&Array.isArray(t.items)&&typeof t.totalCount=="number"}async function gt(t,e){let r=await fetch(_chunkAWG5OAK7js.c.call(void 0, Rt(t)),{method:"GET",credentials:"omit",headers:{Accept:"application/json"},signal:e});if(!r.ok)throw new M(`Could not load products (${r.status})`,r.status);let o=await r.json();if(!Bt(o))throw new M("Unexpected product list response");return o}function G(t){let{projectID:e,locale:r,search:o,initialData:n}=t,[s]=_react.useState.call(void 0, ()=>_chunkAWG5OAK7js.f),i=_nullishCoalesce(t.host, () => (s)),d=O(t.pageSize),c=JSON.stringify([e,i,_nullishCoalesce(r, () => (null)),_nullishCoalesce(_optionalChain([o, 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]), () => (null)),d]),[m,u]=_react.useState.call(void 0, {queryKey:c,page:1});m.queryKey!==c&&u({queryKey:c,page:1});let[b,v]=_react.useState.call(void 0, 0),[f,l]=_react.useState.call(void 0, ()=>({requestKey:n!=null?`${c}|1|0`:"",data:n,error:void 0})),g=_nullishCoalesce(_optionalChain([f, 'access', _7 => _7.data, 'optionalAccess', _8 => _8.totalCount]), () => (0)),P=ft(g,d),h=m.queryKey===c?m.page:1,k=g>0?Math.min(h,P):h,C=`${c}|${k}|${b}`,T=f.requestKey===C;_react.useEffect.call(void 0, ()=>{if(T)return;let y=new AbortController;return gt({projectID:e,host:i,locale:r,search:o,limit:d,offset:(k-1)*d},y.signal).then(x=>{y.signal.aborted||l({requestKey:C,data:x,error:void 0})},x=>{y.signal.aborted||l(E=>({requestKey:C,data:E.data,error:x instanceof Error?x:new Error(String(x))}))}),()=>y.abort()},[C,T]);let I=_react.useCallback.call(void 0, y=>{let x=Math.max(1,Math.floor(y));u({queryKey:c,page:g>0?Math.min(x,P):x})},[c,g,P]),A=_react.useCallback.call(void 0, ()=>v(y=>y+1),[]);return _react.useMemo.call(void 0, ()=>({products:_nullishCoalesce(_optionalChain([f, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.items]), () => ([])),totalCount:g,page:k,pageCount:P,setPage:I,isLoading:!T,error:T?f.error:void 0,refetch:A}),[f,g,k,P,I,T,A])}function bt(t,e){if(t.projectID!=null&&t.projectID!==e.projectID)return{ok:!1,reason:`the page cart already belongs to project "${t.projectID}"`};let r=null,o=e.host?N(e.host):"",n=N(t.host);if(o&&o!==n){if(n!==N(t.defaultHost))return{ok:!1,reason:`the page cart already uses the host "${t.host}"`};r=o}return{ok:!0,setProjectID:t.projectID==null?e.projectID:null,setHost:r}}function Q(t,e){let r=e.cartItemId!=null&&e.cartItemId!==e.id?e.cartItemId:null;t.track("add_to_cart",{qty:1,value_minor:e.price,currency:e.currency},{product_id:e.id,variant_id:r})}async function yt(t,e){let[{Bitsnap:r},{getProjectID:o,setProjectID:n}]=await Promise.all([Promise.resolve().then(() => _interopRequireWildcard(require("./methods-WSICR2JH.js"))),Promise.resolve().then(() => _interopRequireWildcard(require("./CartProvider-6D5WE2HA.js")))]),s=bt({projectID:o(),host:_chunkAWG5OAK7js.f,defaultHost:_chunkAWG5OAK7js.e},e);if(!s.ok)return Ut(s.reason);if(s.setProjectID!=null&&n(s.setProjectID),s.setHost!=null&&_chunkAWG5OAK7js.g.call(void 0, s.setHost),await r.addProductToCart(_nullishCoalesce(t.cartItemId, () => (t.id)),1,void 0,{url:e.url,name:t.name,price:t.price,currency:t.currency,analytics:_chunk3N2VK426js.k})!=null)throw new Error("Could not add the product to the cart");e.analytics!=null&&Q(e.analytics,t),e.showCart&&r.showCart()}function Ut(t){throw console.warn(`bitsnap-react: ProductList did not add to the cart because ${t}. Pass onAddToCart to use another cart.`),new Error("The page cart belongs to another project or host")}var $=50,Ht=1e3;function Lt(t,e=Ht){let r=new Set,o=new Map,n=[],s=[],i,d,c=!1;function m(){for(d!==void 0&&clearTimeout(d),d=void 0;n.length>0;){let l=n.slice(0,$),g=s.slice(0,$);n=n.slice($),s=s.slice($);try{t({productIds:l,positions:g})}catch (e3){}}}function u(){m();try{_optionalChain([_chunk3N2VK426js.f.call(void 0, ), 'optionalAccess', _11 => _11.flush, 'call', _12 => _12()])}catch (e4){}}let b=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&u()};function v(){c||typeof window>"u"||(c=!0,window.addEventListener("pagehide",u,!0),document.addEventListener("visibilitychange",b,!0))}function f(){if(i)return i;if(!(typeof IntersectionObserver>"u"))return i=new IntersectionObserver(l=>{for(let g of l){let P=o.get(g.target);!P||!g.isIntersecting||g.intersectionRatio<.5||(o.delete(g.target),_optionalChain([i, 'optionalAccess', _13 => _13.unobserve, 'call', _14 => _14(g.target)]),!r.has(P.id)&&(r.add(P.id),n.push(P.id),s.push(P.position)))}n.length>0&&d===void 0&&(d=setTimeout(m,e),_optionalChain([d, 'access', _15 => _15.unref, 'optionalCall', _16 => _16()]))},{threshold:[.5]}),v(),i}return{observe(l,g,P){try{if(r.has(g))return()=>{};let h=f();return h?(o.set(l,{id:g,position:P}),h.observe(l),()=>{o.delete(l),h.unobserve(l)}):()=>{}}catch (e5){return()=>{}}},flush:m,destroy(){try{m(),_optionalChain([i, 'optionalAccess', _17 => _17.disconnect, 'call', _18 => _18()]),c&&(window.removeEventListener("pagehide",u,!0),document.removeEventListener("visibilitychange",b,!0),c=!1)}catch (e6){}i=void 0,o.clear()}}}var Mt={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function ht(t,e){return _chunkAWG5OAK7js.i.call(void 0, Mt,t,e)}function X(t,e){return t.replace(/\{(\w+)\}/g,(r,o)=>o in e?String(e[o]):r)}var _jsxruntime = require('react/jsx-runtime');var vt=_react.createContext.call(void 0, void 0),$t={observe:()=>()=>{},clicked:()=>{}},Ct=_react.createContext.call(void 0, $t);function j(){let t=_react.useContext.call(void 0, vt);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function p(t,e){let{appearance:r}=j(),o=q(r,t);return{"data-bitsnap-products-slot":t,className:_chunkAWG5OAK7js.d.call(void 0, e,_optionalChain([o, 'optionalAccess', _19 => _19.className])),style:_optionalChain([o, 'optionalAccess', _20 => _20.style])}}var Z="inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",St=`${Z} w-full`,Kt=`${St} no-underline`;function Vt({product:t,onAdd:e}){let{texts:r}=j(),[o,n]=_react.useState.call(void 0, "idle"),s=p("addToCartButton",St),i=p("message","mt-2 text-xs");_react.useEffect.call(void 0, ()=>{if(o!=="added")return;let m=setTimeout(()=>n("idle"),2e3);return()=>clearTimeout(m)},[o]);let d=_react.useCallback.call(void 0, async()=>{n("adding");try{await e(),n("added")}catch(m){console.error("bitsnap-react: could not add to the cart",m),n("error")}},[e]),c=o==="adding"?r.addingToCart:o==="added"?r.addedToCart:r.addToCart;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...s,disabled:o==="adding","aria-label":`${c}: ${t.name}`,onClick:d,children:c}),o==="error"?_jsxruntime.jsx.call(void 0, "p",{...i,role:"alert",children:r.addToCartError}):null]})}function qt({product:t,position:e,href:r,onAdd:o,renderItem:n}){let{texts:s,locale:i}=j(),d=_react.useContext.call(void 0, Ct),c=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{if(c.current!=null)return d.observe(c.current,t.id,e)},[d,t.id,e]);let m=_react.useCallback.call(void 0, ()=>d.clicked(t,e),[d,t,e]),u=p("card","relative flex flex-col overflow-hidden border transition-colors"),b=p("cardLink","flex flex-1 flex-col no-underline"),v=p("image","aspect-square w-full overflow-hidden"),f=p("imagePlaceholder","aspect-square w-full"),l=p("body","flex flex-1 flex-col gap-1 p-4"),g=p("name","text-base font-medium leading-snug"),P=p("description","line-clamp-2 text-sm"),h=p("price","mt-auto pt-2 text-base font-semibold"),k=p("comparePrice","ml-2 text-sm font-normal"),C=p("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=p("actions","p-4 pt-0"),I=p("selectButton",Kt),A=H(t.price,t.currency,i),y=t.compareAtPrice!=null&&t.compareAtPrice>t.price?H(t.compareAtPrice,t.currency,i):null;if(n!=null)return _jsxruntime.jsx.call(void 0, "li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:n(t,{href:r,price:A,compareAtPrice:y,texts:s,locale:i,addToCart:o,trackClick:m})});let x=_nullishCoalesce(_optionalChain([t, 'access', _21 => _21.image, 'optionalAccess', _22 => _22.thumbnailUrl]), () => (_optionalChain([t, 'access', _23 => _23.image, 'optionalAccess', _24 => _24.url]))),E=t.available?t.isRecurring?s.subscription:null:s.unavailable;return _jsxruntime.jsxs.call(void 0, "li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:[_jsxruntime.jsxs.call(void 0, "a",{...b,href:r,onClick:m,children:[x!=null?_jsxruntime.jsx.call(void 0, "div",{...v,children:_jsxruntime.jsx.call(void 0, "img",{src:x,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):_jsxruntime.jsx.call(void 0, "div",{...f,"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{...l,children:[_jsxruntime.jsx.call(void 0, "h3",{...g,children:t.name}),t.shortDescription?_jsxruntime.jsx.call(void 0, "p",{...P,children:t.shortDescription}):null,_jsxruntime.jsxs.call(void 0, "p",{...h,children:[t.priceFrom?X(s.priceFrom,{price:A}):A,y!=null?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "span",{className:"sr-only",children:[s.originalPrice,": "]}),_jsxruntime.jsx.call(void 0, "del",{...k,children:y})]}):null]})]})]}),E!=null?_jsxruntime.jsx.call(void 0, "span",{...C,"data-kind":t.available?"subscription":"unavailable",children:E}):null,_jsxruntime.jsx.call(void 0, "div",{...T,children:t.available?t.addToCart?_jsxruntime.jsx.call(void 0, Vt,{product:t,onAdd:o}):_jsxruntime.jsx.call(void 0, "a",{...I,href:r,onClick:m,children:t.variantCount>1?s.chooseOptions:s.viewProduct}):_jsxruntime.jsx.call(void 0, "button",{type:"button",...I,disabled:!0,children:s.unavailable})})]})}var At="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0";function Gt({count:t,label:e}){let r=p("grid",At),o=p("skeleton","aspect-[3/4] animate-pulse");return _jsxruntime.jsx.call(void 0, "div",{...r,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(n,s)=>_jsxruntime.jsx.call(void 0, "div",{...o,"aria-hidden":"true"},s))})}function Qt({page:t,pageCount:e,isLoading:r,onPage:o}){let{texts:n}=j(),s=p("pagination","mt-8 flex items-center justify-center gap-4"),i=p("paginationButton",Z),d=p("pageIndicator","text-sm");return _jsxruntime.jsxs.call(void 0, "nav",{...s,"aria-label":n.pagination,children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,"aria-disabled":r||t<=1,onClick:()=>{!r&&t>1&&o(t-1)},children:n.previousPage}),_jsxruntime.jsx.call(void 0, "span",{...d,"aria-live":"polite",children:X(n.pageOf,{page:t,pageCount:e})}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,"aria-disabled":r||t>=e,onClick:()=>{!r&&t<e&&o(t+1)},children:n.nextPage})]})}function Xt({options:t,productHref:e,renderItem:r,onAddToCart:o,showCartOnAdd:n}){let{texts:s}=j(),{products:i,page:d,pageCount:c,setPage:m,isLoading:u,error:b,refetch:v}=G(t),f=_chunk3N2VK426js.m.call(void 0, ),l=_optionalChain([t, 'access', _25 => _25.search, 'optionalAccess', _26 => _26.trim, 'call', _27 => _27()])?"search":"catalog",g=O(t.pageSize),P=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{P.current||u||b!=null||(P.current=!0,f.track("product_list_viewed",{list_id:l,item_count:i.length}))},[f,u,b,l,i.length]);let h=_react.useMemo.call(void 0, ()=>Lt(({productIds:L,positions:w})=>f.track("product_impression",{list_id:l,product_ids:L,positions:w})),[f,l]);_react.useEffect.call(void 0, ()=>()=>h.destroy(),[h]);let k=_react.useMemo.call(void 0, ()=>({observe:h.observe,clicked:(L,w)=>f.track("product_clicked",{list_id:l,position:w},{product_id:L.id})}),[h,f,l]),C=_react.useRef.call(void 0, null),T=_react.useRef.call(void 0, !1),I=_react.useCallback.call(void 0, L=>{T.current=!0,m(L)},[m]);_react.useEffect.call(void 0, ()=>{u||!T.current||(T.current=!1,_optionalChain([C, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.focus, 'call', _30 => _30({preventScroll:!0})]),_optionalChain([C, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.scrollIntoView, 'call', _33 => _33({block:"start"})]))},[u]);let A=p("grid",At),y=p("emptyState","py-12 text-center text-sm"),x=p("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),E=p("retryButton",Z),{projectID:J,host:W}=t,It=_react.useCallback.call(void 0, (L,w)=>async()=>{if(o!=null){await _chunk3N2VK426js.p.call(void 0, ()=>o(L)),Q(f,L);return}await yt(L,{projectID:J,host:W,showCart:n,analytics:f,url:w})},[o,J,W,n,f]),_;return u&&i.length===0?_=_jsxruntime.jsx.call(void 0, Gt,{count:Math.min(O(t.pageSize),8),label:s.loading}):b!=null?_=_jsxruntime.jsxs.call(void 0, "div",{...x,role:"alert",children:[_jsxruntime.jsx.call(void 0, "p",{children:s.error}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...E,onClick:v,children:s.retry})]}):i.length===0?_=_jsxruntime.jsx.call(void 0, "p",{...y,children:s.empty}):_=_jsxruntime.jsx.call(void 0, "ul",{...A,"aria-busy":u||void 0,className:_chunkAWG5OAK7js.d.call(void 0, A.className,u&&"opacity-60"),children:i.map((L,w)=>{let Y=e(L);return _jsxruntime.jsx.call(void 0, qt,{product:L,position:(d-1)*g+w,href:Y,onAdd:It(L,Y),renderItem:r},L.id)})}),_jsxruntime.jsx.call(void 0, Ct.Provider,{value:k,children:_jsxruntime.jsxs.call(void 0, "div",{ref:C,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[_,c>1&&b==null?_jsxruntime.jsx.call(void 0, Qt,{page:d,pageCount:c,isLoading:u,onPage:I}):null]})})}var Zt=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Jt({productHref:t=Zt,appearance:e,texts:r,renderItem:o,onAddToCart:n,showCartOnAdd:s=!0,className:i,analytics:d,...c}){let m=_chunk3N2VK426js.n.call(void 0, c.projectID,d,"catalog"),u=_nullishCoalesce(c.locale, () => (_chunkAWG5OAK7js.k)),b=_react.useMemo.call(void 0, ()=>pt(e),[e]),v=_react.useMemo.call(void 0, ()=>ht(u,r),[u,r]),f=_react.useMemo.call(void 0, ()=>({appearance:b,texts:v,locale:u}),[b,v,u]),l=q(b,"root");return _jsxruntime.jsx.call(void 0, _chunk3N2VK426js.l,{value:m,children:_jsxruntime.jsx.call(void 0, vt.Provider,{value:f,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:_chunkAWG5OAK7js.d.call(void 0, "bitsnap-react",b.boundaryClassName,i,_optionalChain([l, 'optionalAccess', _34 => _34.className])),style:{...b.boundaryStyle,..._optionalChain([l, 'optionalAccess', _35 => _35.style])},children:_jsxruntime.jsx.call(void 0, Xt,{options:c,productHref:t,renderItem:o,onAddToCart:n,showCartOnAdd:s})})})})}exports.a = wt; exports.b = H; exports.c = G; exports.d = Jt;
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunkDY2S42Q6js = require('./chunk-DY2S42Q6.js');var _chunkMG6VV5J2js = require('./chunk-MG6VV5J2.js');var wt=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],Et={fontFamily:"--bitsnap-products-font-family",fontSize:"--bitsnap-products-font-size",background:"--bitsnap-products-background",surface:"--bitsnap-products-surface",foreground:"--bitsnap-products-foreground",mutedForeground:"--bitsnap-products-muted-foreground",border:"--bitsnap-products-border",buttonBackground:"--bitsnap-products-button-background",buttonForeground:"--bitsnap-products-button-foreground",buttonHoverBackground:"--bitsnap-products-button-hover-background",hoverSurface:"--bitsnap-products-hover-surface",focusRing:"--bitsnap-products-focus-ring",error:"--bitsnap-products-error",badgeBackground:"--bitsnap-products-badge-background",badgeForeground:"--bitsnap-products-badge-foreground",radius:"--bitsnap-products-radius"},_t={light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#f4f4f5",focusRing:"#71717a",error:"#dc2626",badgeBackground:"#f4f4f5",badgeForeground:"#3f3f46",radius:"8px"},dark:{background:"#18181b",surface:"#27272a",foreground:"#fafafa",mutedForeground:"#a1a1aa",border:"#3f3f46",buttonBackground:"#fafafa",buttonForeground:"#18181b",buttonHoverBackground:"#e4e4e7",hoverSurface:"#3f3f46",focusRing:"#a1a1aa",error:"#f87171",badgeBackground:"#3f3f46",badgeForeground:"#e4e4e7",radius:"8px"}},Dt=[];function pt(t){let e=_chunkKOYBZORLjs.a.call(void 0, t,{defaultTheme:"light",presets:_t,variables:Et,shadcnVariables:Dt});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function q(t,e){return _chunkKOYBZORLjs.b.call(void 0, t.elements,e)}function mt(t,e){try{return new Intl.NumberFormat(t,{style:"currency",currency:e,currencyDisplay:"symbol"})}catch (e2){return}}function H(t,e,r=_chunkDY2S42Q6js.k){let o=t/100,n=_nullishCoalesce(mt(r,e), () => (mt(_chunkDY2S42Q6js.k,e)));return n!=null?n.format(o):`${o.toFixed(2)} ${e}`}var _react = require('react');var Ot=24,Nt=48,M=class extends Error{constructor(e,r){super(e),this.name="ProductListError",this.status=r}};function O(t){return t==null||!Number.isFinite(t)?Ot:Math.min(Nt,Math.max(1,Math.floor(t)))}function ft(t,e){return Math.max(1,Math.ceil(t/e))}function N(t){return t.replace(/\/+$/,"")}function Rt(t){let e=new URLSearchParams;e.set("limit",String(t.limit)),e.set("offset",String(t.offset)),t.locale&&e.set("locale",t.locale);let r=_optionalChain([t, 'access', _2 => _2.search, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);return r&&e.set("search",r),`${N(t.host)}/api/integrations/${encodeURIComponent(t.projectID)}/public-commerce/product-list?${e.toString()}`}function Bt(t){return typeof t=="object"&&t!=null&&Array.isArray(t.items)&&typeof t.totalCount=="number"}async function gt(t,e){let r=await fetch(_chunkDY2S42Q6js.c.call(void 0, Rt(t)),{method:"GET",credentials:"omit",headers:{Accept:"application/json"},signal:e});if(!r.ok)throw new M(`Could not load products (${r.status})`,r.status);let o=await r.json();if(!Bt(o))throw new M("Unexpected product list response");return o}function G(t){let{projectID:e,locale:r,search:o,initialData:n}=t,[s]=_react.useState.call(void 0, ()=>_chunkDY2S42Q6js.f),i=_nullishCoalesce(t.host, () => (s)),d=O(t.pageSize),c=JSON.stringify([e,i,_nullishCoalesce(r, () => (null)),_nullishCoalesce(_optionalChain([o, 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]), () => (null)),d]),[m,u]=_react.useState.call(void 0, {queryKey:c,page:1});m.queryKey!==c&&u({queryKey:c,page:1});let[b,v]=_react.useState.call(void 0, 0),[f,l]=_react.useState.call(void 0, ()=>({requestKey:n!=null?`${c}|1|0`:"",data:n,error:void 0})),g=_nullishCoalesce(_optionalChain([f, 'access', _7 => _7.data, 'optionalAccess', _8 => _8.totalCount]), () => (0)),P=ft(g,d),h=m.queryKey===c?m.page:1,k=g>0?Math.min(h,P):h,C=`${c}|${k}|${b}`,T=f.requestKey===C;_react.useEffect.call(void 0, ()=>{if(T)return;let y=new AbortController;return gt({projectID:e,host:i,locale:r,search:o,limit:d,offset:(k-1)*d},y.signal).then(x=>{y.signal.aborted||l({requestKey:C,data:x,error:void 0})},x=>{y.signal.aborted||l(E=>({requestKey:C,data:E.data,error:x instanceof Error?x:new Error(String(x))}))}),()=>y.abort()},[C,T]);let I=_react.useCallback.call(void 0, y=>{let x=Math.max(1,Math.floor(y));u({queryKey:c,page:g>0?Math.min(x,P):x})},[c,g,P]),A=_react.useCallback.call(void 0, ()=>v(y=>y+1),[]);return _react.useMemo.call(void 0, ()=>({products:_nullishCoalesce(_optionalChain([f, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.items]), () => ([])),totalCount:g,page:k,pageCount:P,setPage:I,isLoading:!T,error:T?f.error:void 0,refetch:A}),[f,g,k,P,I,T,A])}function bt(t,e){if(t.projectID!=null&&t.projectID!==e.projectID)return{ok:!1,reason:`the page cart already belongs to project "${t.projectID}"`};let r=null,o=e.host?N(e.host):"",n=N(t.host);if(o&&o!==n){if(n!==N(t.defaultHost))return{ok:!1,reason:`the page cart already uses the host "${t.host}"`};r=o}return{ok:!0,setProjectID:t.projectID==null?e.projectID:null,setHost:r}}function Q(t,e){let r=e.cartItemId!=null&&e.cartItemId!==e.id?e.cartItemId:null;t.track("add_to_cart",{qty:1,value_minor:e.price,currency:e.currency},{product_id:e.id,variant_id:r})}async function yt(t,e){let[{Bitsnap:r},{getProjectID:o,setProjectID:n}]=await Promise.all([Promise.resolve().then(() => _interopRequireWildcard(require("./methods-NUMVR53L.js"))),Promise.resolve().then(() => _interopRequireWildcard(require("./CartProvider-64QEJ7A7.js")))]),s=bt({projectID:o(),host:_chunkDY2S42Q6js.f,defaultHost:_chunkDY2S42Q6js.e},e);if(!s.ok)return Ut(s.reason);if(s.setProjectID!=null&&n(s.setProjectID),s.setHost!=null&&_chunkDY2S42Q6js.g.call(void 0, s.setHost),await r.addProductToCart(_nullishCoalesce(t.cartItemId, () => (t.id)),1,void 0,{url:e.url,name:t.name,price:t.price,currency:t.currency,analytics:_chunkMG6VV5J2js.k})!=null)throw new Error("Could not add the product to the cart");e.analytics!=null&&Q(e.analytics,t),e.showCart&&r.showCart()}function Ut(t){throw console.warn(`bitsnap-react: ProductList did not add to the cart because ${t}. Pass onAddToCart to use another cart.`),new Error("The page cart belongs to another project or host")}var $=50,Ht=1e3;function Lt(t,e=Ht){let r=new Set,o=new Map,n=[],s=[],i,d,c=!1;function m(){for(d!==void 0&&clearTimeout(d),d=void 0;n.length>0;){let l=n.slice(0,$),g=s.slice(0,$);n=n.slice($),s=s.slice($);try{t({productIds:l,positions:g})}catch (e3){}}}function u(){m();try{_optionalChain([_chunkMG6VV5J2js.f.call(void 0, ), 'optionalAccess', _11 => _11.flush, 'call', _12 => _12()])}catch (e4){}}let b=()=>{typeof document<"u"&&document.visibilityState==="hidden"&&u()};function v(){c||typeof window>"u"||(c=!0,window.addEventListener("pagehide",u,!0),document.addEventListener("visibilitychange",b,!0))}function f(){if(i)return i;if(!(typeof IntersectionObserver>"u"))return i=new IntersectionObserver(l=>{for(let g of l){let P=o.get(g.target);!P||!g.isIntersecting||g.intersectionRatio<.5||(o.delete(g.target),_optionalChain([i, 'optionalAccess', _13 => _13.unobserve, 'call', _14 => _14(g.target)]),!r.has(P.id)&&(r.add(P.id),n.push(P.id),s.push(P.position)))}n.length>0&&d===void 0&&(d=setTimeout(m,e),_optionalChain([d, 'access', _15 => _15.unref, 'optionalCall', _16 => _16()]))},{threshold:[.5]}),v(),i}return{observe(l,g,P){try{if(r.has(g))return()=>{};let h=f();return h?(o.set(l,{id:g,position:P}),h.observe(l),()=>{o.delete(l),h.unobserve(l)}):()=>{}}catch (e5){return()=>{}}},flush:m,destroy(){try{m(),_optionalChain([i, 'optionalAccess', _17 => _17.disconnect, 'call', _18 => _18()]),c&&(window.removeEventListener("pagehide",u,!0),document.removeEventListener("visibilitychange",b,!0),c=!1)}catch (e6){}i=void 0,o.clear()}}}var Mt={en:{addToCart:"Add to cart",addingToCart:"Adding\u2026",addedToCart:"Added to cart",addToCartError:"Could not add to the cart. Try again.",chooseOptions:"Choose",viewProduct:"View",unavailable:"Unavailable",subscription:"Subscription",priceFrom:"from {price}",originalPrice:"Original price",loading:"Loading products",empty:"There are no products to show.",error:"Could not load the products.",retry:"Try again",pagination:"Pagination",previousPage:"Previous",nextPage:"Next",pageOf:"Page {page} of {pageCount}"},pl:{addToCart:"Dodaj do koszyka",addingToCart:"Dodawanie\u2026",addedToCart:"Dodano do koszyka",addToCartError:"Nie uda\u0142o si\u0119 doda\u0107 do koszyka. Spr\xF3buj ponownie.",chooseOptions:"Wybierz",viewProduct:"Zobacz",unavailable:"Niedost\u0119pny",subscription:"Subskrypcja",priceFrom:"od {price}",originalPrice:"Cena przed obni\u017Ck\u0105",loading:"\u0141adowanie produkt\xF3w",empty:"Brak produkt\xF3w do wy\u015Bwietlenia.",error:"Nie uda\u0142o si\u0119 za\u0142adowa\u0107 produkt\xF3w.",retry:"Spr\xF3buj ponownie",pagination:"Paginacja",previousPage:"Poprzednia",nextPage:"Nast\u0119pna",pageOf:"Strona {page} z {pageCount}"}};function ht(t,e){return _chunkDY2S42Q6js.i.call(void 0, Mt,t,e)}function X(t,e){return t.replace(/\{(\w+)\}/g,(r,o)=>o in e?String(e[o]):r)}var _jsxruntime = require('react/jsx-runtime');var vt=_react.createContext.call(void 0, void 0),$t={observe:()=>()=>{},clicked:()=>{}},Ct=_react.createContext.call(void 0, $t);function j(){let t=_react.useContext.call(void 0, vt);if(t==null)throw new Error("ProductList parts must be rendered inside ProductList");return t}function p(t,e){let{appearance:r}=j(),o=q(r,t);return{"data-bitsnap-products-slot":t,className:_chunkDY2S42Q6js.d.call(void 0, e,_optionalChain([o, 'optionalAccess', _19 => _19.className])),style:_optionalChain([o, 'optionalAccess', _20 => _20.style])}}var Z="inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50",St=`${Z} w-full`,Kt=`${St} no-underline`;function Vt({product:t,onAdd:e}){let{texts:r}=j(),[o,n]=_react.useState.call(void 0, "idle"),s=p("addToCartButton",St),i=p("message","mt-2 text-xs");_react.useEffect.call(void 0, ()=>{if(o!=="added")return;let m=setTimeout(()=>n("idle"),2e3);return()=>clearTimeout(m)},[o]);let d=_react.useCallback.call(void 0, async()=>{n("adding");try{await e(),n("added")}catch(m){console.error("bitsnap-react: could not add to the cart",m),n("error")}},[e]),c=o==="adding"?r.addingToCart:o==="added"?r.addedToCart:r.addToCart;return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...s,disabled:o==="adding","aria-label":`${c}: ${t.name}`,onClick:d,children:c}),o==="error"?_jsxruntime.jsx.call(void 0, "p",{...i,role:"alert",children:r.addToCartError}):null]})}function qt({product:t,position:e,href:r,onAdd:o,renderItem:n}){let{texts:s,locale:i}=j(),d=_react.useContext.call(void 0, Ct),c=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>{if(c.current!=null)return d.observe(c.current,t.id,e)},[d,t.id,e]);let m=_react.useCallback.call(void 0, ()=>d.clicked(t,e),[d,t,e]),u=p("card","relative flex flex-col overflow-hidden border transition-colors"),b=p("cardLink","flex flex-1 flex-col no-underline"),v=p("image","aspect-square w-full overflow-hidden"),f=p("imagePlaceholder","aspect-square w-full"),l=p("body","flex flex-1 flex-col gap-1 p-4"),g=p("name","text-base font-medium leading-snug"),P=p("description","line-clamp-2 text-sm"),h=p("price","mt-auto pt-2 text-base font-semibold"),k=p("comparePrice","ml-2 text-sm font-normal"),C=p("badge","absolute left-3 top-3 px-2 py-0.5 text-xs font-medium"),T=p("actions","p-4 pt-0"),I=p("selectButton",Kt),A=H(t.price,t.currency,i),y=t.compareAtPrice!=null&&t.compareAtPrice>t.price?H(t.compareAtPrice,t.currency,i):null;if(n!=null)return _jsxruntime.jsx.call(void 0, "li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:n(t,{href:r,price:A,compareAtPrice:y,texts:s,locale:i,addToCart:o,trackClick:m})});let x=_nullishCoalesce(_optionalChain([t, 'access', _21 => _21.image, 'optionalAccess', _22 => _22.thumbnailUrl]), () => (_optionalChain([t, 'access', _23 => _23.image, 'optionalAccess', _24 => _24.url]))),E=t.available?t.isRecurring?s.subscription:null:s.unavailable;return _jsxruntime.jsxs.call(void 0, "li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:[_jsxruntime.jsxs.call(void 0, "a",{...b,href:r,onClick:m,children:[x!=null?_jsxruntime.jsx.call(void 0, "div",{...v,children:_jsxruntime.jsx.call(void 0, "img",{src:x,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):_jsxruntime.jsx.call(void 0, "div",{...f,"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{...l,children:[_jsxruntime.jsx.call(void 0, "h3",{...g,children:t.name}),t.shortDescription?_jsxruntime.jsx.call(void 0, "p",{...P,children:t.shortDescription}):null,_jsxruntime.jsxs.call(void 0, "p",{...h,children:[t.priceFrom?X(s.priceFrom,{price:A}):A,y!=null?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "span",{className:"sr-only",children:[s.originalPrice,": "]}),_jsxruntime.jsx.call(void 0, "del",{...k,children:y})]}):null]})]})]}),E!=null?_jsxruntime.jsx.call(void 0, "span",{...C,"data-kind":t.available?"subscription":"unavailable",children:E}):null,_jsxruntime.jsx.call(void 0, "div",{...T,children:t.available?t.addToCart?_jsxruntime.jsx.call(void 0, Vt,{product:t,onAdd:o}):_jsxruntime.jsx.call(void 0, "a",{...I,href:r,onClick:m,children:t.variantCount>1?s.chooseOptions:s.viewProduct}):_jsxruntime.jsx.call(void 0, "button",{type:"button",...I,disabled:!0,children:s.unavailable})})]})}var At="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0";function Gt({count:t,label:e}){let r=p("grid",At),o=p("skeleton","aspect-[3/4] animate-pulse");return _jsxruntime.jsx.call(void 0, "div",{...r,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(n,s)=>_jsxruntime.jsx.call(void 0, "div",{...o,"aria-hidden":"true"},s))})}function Qt({page:t,pageCount:e,isLoading:r,onPage:o}){let{texts:n}=j(),s=p("pagination","mt-8 flex items-center justify-center gap-4"),i=p("paginationButton",Z),d=p("pageIndicator","text-sm");return _jsxruntime.jsxs.call(void 0, "nav",{...s,"aria-label":n.pagination,children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,"aria-disabled":r||t<=1,onClick:()=>{!r&&t>1&&o(t-1)},children:n.previousPage}),_jsxruntime.jsx.call(void 0, "span",{...d,"aria-live":"polite",children:X(n.pageOf,{page:t,pageCount:e})}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...i,"aria-disabled":r||t>=e,onClick:()=>{!r&&t<e&&o(t+1)},children:n.nextPage})]})}function Xt({options:t,productHref:e,renderItem:r,onAddToCart:o,showCartOnAdd:n}){let{texts:s}=j(),{products:i,page:d,pageCount:c,setPage:m,isLoading:u,error:b,refetch:v}=G(t),f=_chunkMG6VV5J2js.m.call(void 0, ),l=_optionalChain([t, 'access', _25 => _25.search, 'optionalAccess', _26 => _26.trim, 'call', _27 => _27()])?"search":"catalog",g=O(t.pageSize),P=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{P.current||u||b!=null||(P.current=!0,f.track("product_list_viewed",{list_id:l,item_count:i.length}))},[f,u,b,l,i.length]);let h=_react.useMemo.call(void 0, ()=>Lt(({productIds:L,positions:w})=>f.track("product_impression",{list_id:l,product_ids:L,positions:w})),[f,l]);_react.useEffect.call(void 0, ()=>()=>h.destroy(),[h]);let k=_react.useMemo.call(void 0, ()=>({observe:h.observe,clicked:(L,w)=>f.track("product_clicked",{list_id:l,position:w},{product_id:L.id})}),[h,f,l]),C=_react.useRef.call(void 0, null),T=_react.useRef.call(void 0, !1),I=_react.useCallback.call(void 0, L=>{T.current=!0,m(L)},[m]);_react.useEffect.call(void 0, ()=>{u||!T.current||(T.current=!1,_optionalChain([C, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.focus, 'call', _30 => _30({preventScroll:!0})]),_optionalChain([C, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.scrollIntoView, 'call', _33 => _33({block:"start"})]))},[u]);let A=p("grid",At),y=p("emptyState","py-12 text-center text-sm"),x=p("error","flex flex-col items-center gap-3 py-12 text-center text-sm"),E=p("retryButton",Z),{projectID:J,host:W}=t,It=_react.useCallback.call(void 0, (L,w)=>async()=>{if(o!=null){await _chunkMG6VV5J2js.p.call(void 0, ()=>o(L)),Q(f,L);return}await yt(L,{projectID:J,host:W,showCart:n,analytics:f,url:w})},[o,J,W,n,f]),_;return u&&i.length===0?_=_jsxruntime.jsx.call(void 0, Gt,{count:Math.min(O(t.pageSize),8),label:s.loading}):b!=null?_=_jsxruntime.jsxs.call(void 0, "div",{...x,role:"alert",children:[_jsxruntime.jsx.call(void 0, "p",{children:s.error}),_jsxruntime.jsx.call(void 0, "button",{type:"button",...E,onClick:v,children:s.retry})]}):i.length===0?_=_jsxruntime.jsx.call(void 0, "p",{...y,children:s.empty}):_=_jsxruntime.jsx.call(void 0, "ul",{...A,"aria-busy":u||void 0,className:_chunkDY2S42Q6js.d.call(void 0, A.className,u&&"opacity-60"),children:i.map((L,w)=>{let Y=e(L);return _jsxruntime.jsx.call(void 0, qt,{product:L,position:(d-1)*g+w,href:Y,onAdd:It(L,Y),renderItem:r},L.id)})}),_jsxruntime.jsx.call(void 0, Ct.Provider,{value:k,children:_jsxruntime.jsxs.call(void 0, "div",{ref:C,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[_,c>1&&b==null?_jsxruntime.jsx.call(void 0, Qt,{page:d,pageCount:c,isLoading:u,onPage:I}):null]})})}var Zt=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Jt({productHref:t=Zt,appearance:e,texts:r,renderItem:o,onAddToCart:n,showCartOnAdd:s=!0,className:i,analytics:d,...c}){let m=_chunkMG6VV5J2js.n.call(void 0, c.projectID,d,"catalog"),u=_nullishCoalesce(c.locale, () => (_chunkDY2S42Q6js.k)),b=_react.useMemo.call(void 0, ()=>pt(e),[e]),v=_react.useMemo.call(void 0, ()=>ht(u,r),[u,r]),f=_react.useMemo.call(void 0, ()=>({appearance:b,texts:v,locale:u}),[b,v,u]),l=q(b,"root");return _jsxruntime.jsx.call(void 0, _chunkMG6VV5J2js.l,{value:m,children:_jsxruntime.jsx.call(void 0, vt.Provider,{value:f,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:_chunkDY2S42Q6js.d.call(void 0, "bitsnap-react",b.boundaryClassName,i,_optionalChain([l, 'optionalAccess', _34 => _34.className])),style:{...b.boundaryStyle,..._optionalChain([l, 'optionalAccess', _35 => _35.style])},children:_jsxruntime.jsx.call(void 0, Xt,{options:c,productHref:t,renderItem:o,onAddToCart:n,showCartOnAdd:s})})})})}exports.a = wt; exports.b = H; exports.c = G; exports.d = Jt;
|
|
2
|
+
//# sourceMappingURL=chunk-GLAJPUMA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/private/tmp/bsr-src/dist/chunk-GLAJPUMA.js","../src/components/products/appearance.ts","../src/components/products/format.ts"],"names":["PRODUCT_LIST_SLOT_NAMES","PRODUCT_LIST_TOKEN_VARIABLES","PRODUCT_LIST_THEME_PRESETS","PRODUCT_LIST_SHADCN_VARIABLES","resolveProductListAppearance","appearance","resolved","resolveAppearanceCore","getProductListSlotAppearance","slot","getSlotAppearance","createFormatter","locale","currency","formatProductPrice","amount","DEFAULT_LOCALE","value","formatter"],"mappings":"AAAA,y/BAAgD,sDAAsF,sDAAiF,IC2D1MA,EAAAA,CAA0B,CACrC,MAAA,CACA,MAAA,CACA,MAAA,CACA,UAAA,CACA,OAAA,CACA,kBAAA,CACA,MAAA,CACA,MAAA,CACA,aAAA,CACA,OAAA,CACA,cAAA,CACA,OAAA,CACA,SAAA,CACA,iBAAA,CACA,cAAA,CACA,SAAA,CACA,YAAA,CACA,kBAAA,CACA,eAAA,CACA,YAAA,CACA,OAAA,CACA,aAAA,CACA,UACF,CAAA,CA8BaC,EAAAA,CAA+B,CAC1C,UAAA,CAAY,gCAAA,CACZ,QAAA,CAAU,8BAAA,CACV,UAAA,CAAY,+BAAA,CACZ,OAAA,CAAS,4BAAA,CACT,UAAA,CAAY,+BAAA,CACZ,eAAA,CAAiB,qCAAA,CACjB,MAAA,CAAQ,2BAAA,CACR,gBAAA,CAAkB,sCAAA,CAClB,gBAAA,CAAkB,sCAAA,CAClB,qBAAA,CAAuB,4CAAA,CACvB,YAAA,CAAc,kCAAA,CACd,SAAA,CAAW,+BAAA,CACX,KAAA,CAAO,0BAAA,CACP,eAAA,CAAiB,qCAAA,CACjB,eAAA,CAAiB,qCAAA,CACjB,MAAA,CAAQ,2BACV,CAAA,CASaC,EAAAA,CAGT,CACF,KAAA,CAAO,CACL,UAAA,CAAY,SAAA,CACZ,OAAA,CAAS,SAAA,CACT,UAAA,CAAY,SAAA,CACZ,eAAA,CAAiB,SAAA,CACjB,MAAA,CAAQ,SAAA,CACR,gBAAA,CAAkB,SAAA,CAClB,gBAAA,CAAkB,SAAA,CAClB,qBAAA,CAAuB,SAAA,CACvB,YAAA,CAAc,SAAA,CACd,SAAA,CAAW,SAAA,CACX,KAAA,CAAO,SAAA,CACP,eAAA,CAAiB,SAAA,CACjB,eAAA,CAAiB,SAAA,CACjB,MAAA,CAAQ,KACV,CAAA,CACA,IAAA,CAAM,CACJ,UAAA,CAAY,SAAA,CACZ,OAAA,CAAS,SAAA,CACT,UAAA,CAAY,SAAA,CACZ,eAAA,CAAiB,SAAA,CACjB,MAAA,CAAQ,SAAA,CACR,gBAAA,CAAkB,SAAA,CAClB,gBAAA,CAAkB,SAAA,CAClB,qBAAA,CAAuB,SAAA,CACvB,YAAA,CAAc,SAAA,CACd,SAAA,CAAW,SAAA,CACX,KAAA,CAAO,SAAA,CACP,eAAA,CAAiB,SAAA,CACjB,eAAA,CAAiB,SAAA,CACjB,MAAA,CAAQ,KACV,CACF,CAAA,CAGMC,EAAAA,CACJ,CAAC,CAAA,CAEI,SAASC,EAAAA,CACdC,CAAAA,CAC+B,CAC/B,IAAMC,CAAAA,CAAWC,gCAAAA,CAIfF,CAAY,CACZ,YAAA,CAAc,OAAA,CACd,OAAA,CAASH,EAAAA,CACT,SAAA,CAAWD,EAAAA,CACX,eAAA,CAAiBE,EACnB,CAAC,CAAA,CAED,MAAO,CACL,KAAA,CAAOG,CAAAA,CAAS,KAAA,CAChB,MAAA,CAAQA,CAAAA,CAAS,MAAA,CACjB,QAAA,CAAUA,CAAAA,CAAS,QAAA,CACnB,iBAAA,CAAmBA,CAAAA,CAAS,KAAA,CAC5B,aAAA,CAAeA,CAAAA,CAAS,aAC1B,CACF,CAGO,SAASE,CAAAA,CACdF,CAAAA,CACAG,CAAAA,CACuC,CACvC,OAAOC,gCAAAA,CAAkBJ,CAAS,QAAA,CAAUG,CAAI,CAClD,CChNA,SAASE,EAAAA,CACPC,CAAAA,CACAC,CAAAA,CAC+B,CAC/B,GAAI,CACF,OAAO,IAAI,IAAA,CAAK,YAAA,CAAaD,CAAAA,CAAQ,CACnC,KAAA,CAAO,UAAA,CACP,QAAA,CAAAC,CAAAA,CACA,eAAA,CAAiB,QACnB,CAAC,CACH,CAAA,UAAQ,CAEN,MACF,CACF,CAOO,SAASC,CAAAA,CACdC,CAAAA,CACAF,CAAAA,CACAD,CAAAA,CAAiBI,kBAAAA,CACT,CACR,IAAMC,CAAAA,CAAQF,CAAAA,CAAS,GAAA,CACjBG,CAAAA,kBACJP,EAAAA,CAAgBC,CAAAA,CAAQC,CAAQ,CAAA,SAChCF,EAAAA,CAAgBK,kBAAAA,CAAgBH,CAAQ,GAAA,CAE1C,OAAOK,CAAAA,EAAa,IAAA,CAChBA,CAAAA,CAAU,MAAA,CAAOD,CAAK,CAAA,CACtB,CAAA,EAAA","file":"/private/tmp/bsr-src/dist/chunk-GLAJPUMA.js","sourcesContent":[null,"import type { CSSProperties } from \"react\";\nimport {\n getSlotAppearance,\n resolveAppearanceCore,\n type AppearanceElements,\n type ShadcnVariableMapping,\n type SlotAppearance,\n} from \"@/src/lib/appearance-core\";\n\n/**\n * Product list appearance API.\n *\n * It mirrors `CheckoutAppearance` and `ReturnsAppearance` (theme, tokens,\n * elements) so a shop can reuse one brand object for all of them. The resolver\n * is pure: it turns the caller input into a theme name, the tokens in effect,\n * the slot overrides and the inline style for the theme boundary.\n */\n\nexport type ProductListTheme = \"light\" | \"dark\";\n\nexport type ProductListAppearanceTokens = {\n /** Font family of the list. The library never loads fonts. */\n fontFamily?: string;\n /** Base font size. */\n fontSize?: string;\n /** List background. */\n background?: string;\n /** Raised surfaces: cards, image placeholders, skeletons. */\n surface?: string;\n /** Main text color. */\n foreground?: string;\n /** Secondary text: descriptions, the struck-through price. */\n mutedForeground?: string;\n /** Borders of cards and buttons. */\n border?: string;\n /** \"Add to cart\" button background. */\n buttonBackground?: string;\n /** \"Add to cart\" button text. */\n buttonForeground?: string;\n /** \"Add to cart\" button background on hover. */\n buttonHoverBackground?: string;\n /** Hover surface of cards and secondary buttons. */\n hoverSurface?: string;\n /** Focus ring color. */\n focusRing?: string;\n /** Error and unavailable state color. */\n error?: string;\n /** Badge background (subscription, unavailable). */\n badgeBackground?: string;\n /** Badge text. */\n badgeForeground?: string;\n /** Corner radius of cards, images and buttons. */\n radius?: string;\n};\n\n/**\n * Stable slot names. They are exposed as `data-bitsnap-products-slot`\n * attributes so they can also be targeted from plain CSS.\n */\nexport const PRODUCT_LIST_SLOT_NAMES = [\n \"root\",\n \"grid\",\n \"card\",\n \"cardLink\",\n \"image\",\n \"imagePlaceholder\",\n \"body\",\n \"name\",\n \"description\",\n \"price\",\n \"comparePrice\",\n \"badge\",\n \"actions\",\n \"addToCartButton\",\n \"selectButton\",\n \"message\",\n \"pagination\",\n \"paginationButton\",\n \"pageIndicator\",\n \"emptyState\",\n \"error\",\n \"retryButton\",\n \"skeleton\",\n] as const;\n\nexport type ProductListSlotName = (typeof PRODUCT_LIST_SLOT_NAMES)[number];\n\nexport type ProductListSlotAppearance = SlotAppearance;\n\nexport type ProductListAppearanceElements =\n AppearanceElements<ProductListSlotName>;\n\nexport type ProductListAppearance = {\n /** `\"light\"` or `\"dark\"`. Omitted means `\"light\"`. */\n theme?: ProductListTheme;\n /** Partial overrides applied over the theme preset. */\n tokens?: ProductListAppearanceTokens;\n /** Per element `className`/`style` overrides. */\n elements?: ProductListAppearanceElements;\n};\n\nexport type ResolvedProductListAppearance = {\n theme: ProductListTheme;\n /** Tokens that are in effect (the theme preset plus caller overrides). */\n tokens: ProductListAppearanceTokens;\n elements: ProductListAppearanceElements;\n /** Theme marker class for the theme boundary. */\n boundaryClassName: string;\n /** Inline custom properties applied to the list root. */\n boundaryStyle: CSSProperties;\n};\n\n/** CSS custom property used for each token. */\nexport const PRODUCT_LIST_TOKEN_VARIABLES = {\n fontFamily: \"--bitsnap-products-font-family\",\n fontSize: \"--bitsnap-products-font-size\",\n background: \"--bitsnap-products-background\",\n surface: \"--bitsnap-products-surface\",\n foreground: \"--bitsnap-products-foreground\",\n mutedForeground: \"--bitsnap-products-muted-foreground\",\n border: \"--bitsnap-products-border\",\n buttonBackground: \"--bitsnap-products-button-background\",\n buttonForeground: \"--bitsnap-products-button-foreground\",\n buttonHoverBackground: \"--bitsnap-products-button-hover-background\",\n hoverSurface: \"--bitsnap-products-hover-surface\",\n focusRing: \"--bitsnap-products-focus-ring\",\n error: \"--bitsnap-products-error\",\n badgeBackground: \"--bitsnap-products-badge-background\",\n badgeForeground: \"--bitsnap-products-badge-foreground\",\n radius: \"--bitsnap-products-radius\",\n} as const;\n\nexport type ProductListTokenName = keyof typeof PRODUCT_LIST_TOKEN_VARIABLES;\n\n/**\n * Complete palettes. They carry colors and radius only, so typography is never\n * reset implicitly. `products.css` falls back to the light values, which keeps\n * the list usable even when the boundary style is missing.\n */\nexport const PRODUCT_LIST_THEME_PRESETS: Record<\n ProductListTheme,\n ProductListAppearanceTokens\n> = {\n light: {\n background: \"#ffffff\",\n surface: \"#f9fafb\",\n foreground: \"#18181b\",\n mutedForeground: \"#71717a\",\n border: \"#e4e4e7\",\n buttonBackground: \"#18181b\",\n buttonForeground: \"#fafafa\",\n buttonHoverBackground: \"#000000\",\n hoverSurface: \"#f4f4f5\",\n focusRing: \"#71717a\",\n error: \"#dc2626\",\n badgeBackground: \"#f4f4f5\",\n badgeForeground: \"#3f3f46\",\n radius: \"8px\",\n },\n dark: {\n background: \"#18181b\",\n surface: \"#27272a\",\n foreground: \"#fafafa\",\n mutedForeground: \"#a1a1aa\",\n border: \"#3f3f46\",\n buttonBackground: \"#fafafa\",\n buttonForeground: \"#18181b\",\n buttonHoverBackground: \"#e4e4e7\",\n hoverSurface: \"#3f3f46\",\n focusRing: \"#a1a1aa\",\n error: \"#f87171\",\n badgeBackground: \"#3f3f46\",\n badgeForeground: \"#e4e4e7\",\n radius: \"8px\",\n },\n};\n\n/** The list renders its own elements, so no shared primitive needs remapping. */\nconst PRODUCT_LIST_SHADCN_VARIABLES: ShadcnVariableMapping<ProductListTokenName> =\n [];\n\nexport function resolveProductListAppearance(\n appearance?: ProductListAppearance,\n): ResolvedProductListAppearance {\n const resolved = resolveAppearanceCore<\n ProductListTokenName,\n ProductListTheme,\n ProductListSlotName\n >(appearance, {\n defaultTheme: \"light\",\n presets: PRODUCT_LIST_THEME_PRESETS,\n variables: PRODUCT_LIST_TOKEN_VARIABLES,\n shadcnVariables: PRODUCT_LIST_SHADCN_VARIABLES,\n });\n\n return {\n theme: resolved.theme,\n tokens: resolved.tokens,\n elements: resolved.elements,\n boundaryClassName: resolved.theme,\n boundaryStyle: resolved.boundaryStyle,\n };\n}\n\n/** Caller overrides for a single slot, if any were provided. */\nexport function getProductListSlotAppearance(\n resolved: ResolvedProductListAppearance,\n slot: ProductListSlotName,\n): ProductListSlotAppearance | undefined {\n return getSlotAppearance(resolved.elements, slot);\n}\n","import { DEFAULT_LOCALE } from \"../checkout/locale\";\n\nfunction createFormatter(\n locale: string,\n currency: string,\n): Intl.NumberFormat | undefined {\n try {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n currencyDisplay: \"symbol\",\n });\n } catch {\n // RangeError: invalid locale or currency code.\n return undefined;\n }\n}\n\n/**\n * Formats a price in minor units (grosze, cents) for the locale, the same way\n * the cart does (`amount / 100`). An unknown locale falls back to Polish and an\n * invalid currency code to a plain number followed by the code.\n */\nexport function formatProductPrice(\n amount: number,\n currency: string,\n locale: string = DEFAULT_LOCALE,\n): string {\n const value = amount / 100;\n const formatter =\n createFormatter(locale, currency) ??\n createFormatter(DEFAULT_LOCALE, currency);\n\n return formatter != null\n ? formatter.format(value)\n : `${value.toFixed(2)} ${currency}`;\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunk7SYNGA3Rjs = require('./chunk-7SYNGA3R.js');var _chunkAWG5OAK7js = require('./chunk-AWG5OAK7.js');var _chunk3N2VK426js = require('./chunk-3N2VK426.js');var vr=["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"],zt={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"},Dt={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"}},Ot=[{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 ve(e){let r=_chunkKOYBZORLjs.a.call(void 0, e,{defaultTheme:"light",presets:Dt,variables:zt,shadcnVariables:Ot});return{theme:r.theme,tokens:r.tokens,elements:r.elements,boundaryClassName:r.theme,boundaryStyle:r.boundaryStyle}}function tt(e,r){return _chunkKOYBZORLjs.b.call(void 0, e.elements,r)}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var rt=_react.createContext.call(void 0, ve());function nt({appearance:e,children:r}){let t=_react.useMemo.call(void 0, ()=>ve(e),[e]);return _jsxruntime.jsx.call(void 0, rt.Provider,{value:t,children:r})}function Ne(){return _react.useContext.call(void 0, rt)}function l(e){let r=Ne();return _nullishCoalesce(tt(r,e), () => ({}))}function ot(e){return e==="test"||e===1?1:0}var st={title:["emailStepTitle"],email:["emailLabel"],sendCode:["emailSubmit"],code:["codeLabel"],verify:["codeSubmit"],orders:["ordersTitle"],submit:["confirmationSubmit"],note:["noteLabel"],history:["myReturnsTitle","myReturnsLink"]};function at(e){if(e==null)return;let r={};for(let[t,n]of Object.entries(st)){let o=e[t];if(typeof o=="string")for(let u of n)r[u]=o}for(let t of Object.keys(e)){if(t in st)continue;let n=e[t];typeof n=="string"&&(r[t]=n)}return r}function it(e,r){let t=_optionalChain([r, 'optionalAccess', _2 => _2.brandColor, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);return t==null||t===""?e:{...e,tokens:{..._chunk7SYNGA3Rjs.t.call(void 0, t),..._optionalChain([e, 'optionalAccess', _5 => _5.tokens])}}}function he(e,r){return typeof e=="object"&&e!=null?{pageSize:_nullishCoalesce(e.pageSize, () => (20)),explicitPageToken:void 0}:typeof e=="number"||r!==void 0?{pageSize:_nullishCoalesce(e, () => (20)),explicitPageToken:_nullishCoalesce(r, () => (""))}:{pageSize:20,explicitPageToken:void 0}}var _t={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",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.",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",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.",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 ke(e,r){return _chunkAWG5OAK7js.i.call(void 0, _t,e,r)}function ut(e,r){return e.replace(/\{(\w+)\}/g,(t,n)=>Object.prototype.hasOwnProperty.call(r,n)?String(r[n]):t)}var jt={submitted:"statusSubmitted",approved:"statusApproved",rejected:"statusRejected",awaiting_receipt:"statusAwaitingReceipt",received:"statusReceived",completed:"statusCompleted",cancelled:"statusCancelled",refunded:"statusRefunded"},Ut={not_started:"refundStatusNotStarted",pending:"refundStatusPending",succeeded:"refundStatusSucceeded",failed:"refundStatusFailed"};function lt(e){return _nullishCoalesce(jt[e], () => ("statusFallback"))}function ct(e){return _nullishCoalesce(Ut[e], () => ("refundStatusFallback"))}var Te=_react.createContext.call(void 0, {locale:"pl-PL",texts:ke("pl-PL")});function pt({texts:e,locale:r,children:t}){let n=_nullishCoalesce(r, () => (_chunkAWG5OAK7js.m.call(void 0, ))),o=_react.useMemo.call(void 0, ()=>({locale:n,texts:ke(n,e)}),[n,e]);return _jsxruntime.jsx.call(void 0, Te.Provider,{value:o,children:t})}function h(){let{texts:e}=_react.useContext.call(void 0, Te);return _react.useCallback.call(void 0, (r,t)=>t==null?e[r]:ut(e[r],t),[e])}function Y(){return _react.useContext.call(void 0, Te).locale}var _connect = require('@connectrpc/connect');var _connectquery = require('@connectrpc/connect-query');var _reactquery = require('@tanstack/react-query');var _wkt = require('@bufbuild/protobuf/wkt');var Zt="bitsnap-returns-session:";function we(e){return`${Zt}${e}`}function oe(){try{return typeof window<"u"?window.sessionStorage:void 0}catch (e2){return}}function mt(e,r,t=Date.now()){if(e==null)return;let n=we(r);try{let o=e.getItem(n);if(o==null)return;let u=JSON.parse(o);if(u!=null&&typeof u=="object"&&typeof u.token=="string"&&u.token.length>0&&typeof u.expiresAt=="number"&&u.expiresAt>t){let{token:s,expiresAt:a}=u;return{token:s,expiresAt:a}}e.removeItem(n)}catch (e3){try{e.removeItem(n)}catch (e4){}}}function yt(e,r,t){try{_optionalChain([e, 'optionalAccess', _6 => _6.setItem, 'call', _7 => _7(we(r),JSON.stringify(t))])}catch (e5){}}function Ie(e,r){try{_optionalChain([e, 'optionalAccess', _8 => _8.removeItem, 'call', _9 => _9(we(r))])}catch (e6){}}function ae(e){return e==null?void 0:_wkt.timestampMs.call(void 0, e)}var Rt=_react.createContext.call(void 0, void 0);function T(e){let r=_react.useContext.call(void 0, Rt);if(r==null)throw new Error(`${e} must be rendered inside <ReturnsProvider>`);return r}function Ce(){return _connectquery.createConnectQueryKey.call(void 0, {schema:_chunk7SYNGA3Rjs.i,cardinality:void 0})}var or=2**31-1;function ar({projectID:e,environment:r,transport:t,panelAccessToken:n,className:o,children:u}){let s=_reactquery.useQueryClient.call(void 0, ),{boundaryClassName:a,boundaryStyle:y}=Ne(),m=l("root"),[p,f]=_react.useState.call(void 0, {status:"hydrating"}),[c,b]=_react.useState.call(void 0, ),[g,C]=_react.useState.call(void 0, ),I=_react.useRef.call(void 0, void 0),N=_react.useCallback.call(void 0, ()=>{s.removeQueries({queryKey:Ce()})},[s]),B=_react.useCallback.call(void 0, ()=>{Ie(oe(),e),C(void 0),f({status:"anonymous"}),N()},[e,N]),w=_react.useCallback.call(void 0, k=>{yt(oe(),e,k),b(void 0),C(void 0),f({status:"authenticated",token:k.token,expiresAt:k.expiresAt})},[e]);_react.useEffect.call(void 0, ()=>{let k=!1,Q=oe();if(n==null||n===""){let O=I.current!=null;if(I.current=void 0,O){B();return}let q=mt(Q,e);f(q!=null?{status:"authenticated",token:q.token,expiresAt:q.expiresAt}:{status:"anonymous"});return}return I.current=n,Ie(Q,e),N(),b(void 0),f({status:"exchanging"}),_connect.createClient.call(void 0, _chunk7SYNGA3Rjs.i,t).exchangePanelSession({projectId:e,accessToken:n,environment:r}).then(O=>{if(k)return;let q=ae(O.expiresAt);if(O.sessionToken===""||q==null)throw new Error("EMPTY_SESSION");w({token:O.sessionToken,expiresAt:q})}).catch(O=>{k||(b(O),f({status:"anonymous"}))}),()=>{k=!0}},[n,e,r,t]),_react.useEffect.call(void 0, ()=>{if(p.status!=="authenticated"||p.expiresAt==null)return;let k=p.expiresAt-Date.now();if(k<=0){B();return}let Q=setTimeout(B,Math.min(k,or));return()=>clearTimeout(Q)},[p.status,p.expiresAt,B]);let P=_react.useMemo.call(void 0, ()=>({projectID:e,environment:r,status:p.status,token:p.token,exchangeError:c,challenge:g,setChallenge:C,authenticate:w,clearSession:B}),[e,r,p.status,p.token,c,g,w,B]);return _jsxruntime.jsx.call(void 0, Rt.Provider,{value:P,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-returns":"root","data-bitsnap-returns-slot":"root",className:_chunkAWG5OAK7js.d.call(void 0, "bitsnap-react",a,o,m.className),style:{...y,...m.style},children:u})})}function ir({projectID:e,host:r,environment:t,appearance:n,texts:o,theme:u,locale:s,panelAccessToken:a,className:y,analytics:m,children:p}){let f=_chunk3N2VK426js.n.call(void 0, e,m,"returns"),c=_react.useContext.call(void 0, _reactquery.QueryClientContext),[b]=_react.useState.call(void 0, ()=>c==null?new (0, _reactquery.QueryClient)({defaultOptions:{queries:{staleTime:5e3}}}):void 0),g=_nullishCoalesce(r, () => (_chunk7SYNGA3Rjs.m.call(void 0, ))),C=_react.useMemo.call(void 0, ()=>_chunk7SYNGA3Rjs.n.call(void 0, g),[g]),I=_optionalChain([u, 'optionalAccess', _10 => _10.brandColor]),N=_react.useMemo.call(void 0, ()=>it(n,{brandColor:I}),[n,I]),B=_react.useMemo.call(void 0, ()=>at(o),[o]),w=_jsxruntime.jsx.call(void 0, _chunk3N2VK426js.l,{value:f,children:_jsxruntime.jsx.call(void 0, _connectquery.TransportProvider,{transport:C,children:_jsxruntime.jsx.call(void 0, nt,{appearance:N,children:_jsxruntime.jsx.call(void 0, pt,{texts:B,locale:s,children:_jsxruntime.jsx.call(void 0, ar,{projectID:e,environment:ot(t),transport:C,panelAccessToken:a,className:y,children:p})})})})});return c==null&&b!=null?_jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:b,children:w}):w}var Xr=ir;var ur="SESSION_EXPIRED",bt={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 xt(e){if(e==null||typeof e!="object")return;let{rawMessage:r,message:t}=e;if(typeof r=="string"&&r.length>0)return r;if(typeof t=="string")return Object.keys(bt).find(n=>t.includes(n))}function Pe(e){return xt(e)===ur}function St(e){let r=xt(e);return_nullishCoalesce((r!=null?bt[r]:void 0), () => ("errorGeneric"))}function Le(){let e=typeof globalThis<"u"?globalThis.crypto:void 0;if(typeof _optionalChain([e, 'optionalAccess', _11 => _11.randomUUID])=="function")return e.randomUUID();let r=new Uint8Array(16);if(typeof _optionalChain([e, 'optionalAccess', _12 => _12.getRandomValues])=="function")e.getRandomValues(r);else for(let t=0;t<r.length;t++)r[t]=Math.floor(Math.random()*256);return Array.from(r,t=>t.toString(16).padStart(2,"0")).join("")}function $(e){return e==null?null:e instanceof Error?e:new Error(String(e))}function X(e){return e==null?void 0:St(e)}function ce(e,r){_react.useEffect.call(void 0, ()=>{Pe(e)&&r()},[e,r])}function Nt(e){let[r,t]=_react.useState.call(void 0, [""]);return _react.useEffect.call(void 0, ()=>{t([""])},[e]),{pageToken:_nullishCoalesce(r[r.length-1], () => ("")),page:r.length,push:n=>t(o=>[...o,n]),pop:()=>t(n=>n.length>1?n.slice(0,-1):n)}}function de(){let e=T("useReturnSession"),r=_connectquery.useMutation.call(void 0, _chunk7SYNGA3Rjs.j.returns.startReturnSession),t=_connectquery.useMutation.call(void 0, _chunk7SYNGA3Rjs.j.returns.verifyReturnSession),{setChallenge:n,authenticate:o,clearSession:u}=e,s=_react.useCallback.call(void 0, async c=>{t.reset();let b=c.trim(),g=await r.mutateAsync({projectId:e.projectID,email:b,environment:e.environment});return n({challengeId:g.challengeId,email:b,resendAvailableAt:Date.now()+Math.max(0,g.resendAfterSeconds)*1e3}),g},[e.projectID,e.environment,n,r,t]),a=_react.useCallback.call(void 0, async c=>{let b=await t.mutateAsync({projectId:e.projectID,challengeId:c.challengeId,code:c.code,environment:e.environment}),g=ae(b.expiresAt);if(b.sessionToken===""||g==null)throw new Error("EMPTY_SESSION");return o({token:b.sessionToken,expiresAt:g}),b},[e.projectID,e.environment,o,t]),y=_react.useCallback.call(void 0, async c=>{try{return await s(c),!0}catch (e7){return!1}},[s]),m=_react.useCallback.call(void 0, async c=>{if(e.challenge==null)return!1;try{return await a({challengeId:e.challenge.challengeId,code:c.trim()}),!0}catch (e8){return!1}},[e.challenge,a]),p=_react.useCallback.call(void 0, ()=>e.challenge!=null?y(e.challenge.email):Promise.resolve(!1),[e.challenge,y]),f=$(_nullishCoalesce(_nullishCoalesce(r.error, () => (t.error)), () => (e.exchangeError)));return{status:e.status,isAuthenticated:e.status==="authenticated",challenge:e.challenge,isStarting:r.isPending,isVerifying:t.isPending,starting:r.isPending,verifying:t.isPending,error:f,errorKey:X(f),start:y,startSession:s,verifySession:a,verify:m,resend:p,logout:u}}function pe(e){return e.status==="hydrating"||e.status==="exchanging"}function ht(e,r){let t=T("useReturnOrders"),{pageSize:n,explicitPageToken:o}=he(e,r),u=Nt(t.token),s=_connectquery.useQuery.call(void 0, _chunk7SYNGA3Rjs.j.returns.listReturnOrders,{projectId:t.projectID,sessionToken:_nullishCoalesce(t.token, () => ("")),pageSize:n,pageToken:_nullishCoalesce(o, () => (u.pageToken))},{enabled:t.token!=null});ce(s.error,t.clearSession);let a=_nullishCoalesce(_optionalChain([s, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.nextPageToken]), () => (""));return{orders:_nullishCoalesce(_optionalChain([s, 'access', _15 => _15.data, 'optionalAccess', _16 => _16.orders]), () => ([])),total:_nullishCoalesce(_optionalChain([s, 'access', _17 => _17.data, 'optionalAccess', _18 => _18.total]), () => (0)),data:s.data,isLoading:pe(t)||s.isLoading,isFetching:s.isFetching,error:$(s.error),errorKey:X(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:u.page,hasNext:a!=="",hasPrevious:u.page>1,next:()=>{a!==""&&u.push(a)},previous:u.pop,refetch:()=>s.refetch()}}function Be(e){let r=T("useReturnableOrder"),t=_connectquery.useQuery.call(void 0, _chunk7SYNGA3Rjs.j.returns.getReturnableOrder,{projectId:r.projectID,sessionToken:_nullishCoalesce(r.token, () => ("")),canonicalOrderId:_nullishCoalesce(e, () => (""))},{enabled:r.token!=null&&e!=null&&e!==""});return ce(t.error,r.clearSession),{order:_optionalChain([t, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.order]),returnHistory:_nullishCoalesce(_optionalChain([t, 'access', _21 => _21.data, 'optionalAccess', _22 => _22.returnHistory]), () => ([])),data:t.data,isLoading:e!=null&&e!==""&&(pe(r)||t.isLoading),error:$(t.error),errorKey:X(t.error),status:t.status,isError:t.isError,isSuccess:t.isSuccess,refetch:()=>t.refetch()}}function kt(){let e=T("useCreateReturn"),r=_reactquery.useQueryClient.call(void 0, ),t=_connectquery.useMutation.call(void 0, _chunk7SYNGA3Rjs.j.returns.createReturnRequest),n=_chunk3N2VK426js.m.call(void 0, ),o=_react.useRef.call(void 0, void 0),{clearSession:u}=e,s=_react.useCallback.call(void 0, async(p,f)=>{try{let c=await t.mutateAsync({projectId:e.projectID,sessionToken:_nullishCoalesce(e.token, () => ("")),canonicalOrderId:p.orderId,items:p.items,note:_nullishCoalesce(p.note, () => ("")),idempotencyKey:f});return r.invalidateQueries({queryKey:Ce()}),n.track("return_submitted",{reason_code:"unspecified",item_count:p.items.length},{order_ref:null}),c}catch(c){throw Pe(c)&&u(),c}},[e.projectID,e.token,t,r,u,n]),a=_react.useCallback.call(void 0, async p=>{o.current??=Le();try{let f=await s(p,o.current);return o.current=void 0,f.request}catch (e9){return}},[s]),y=_react.useCallback.call(void 0, async p=>{if(e.token==null)throw new Error("Verify your email to continue.");return s({orderId:p.canonicalOrderID,items:p.items,note:p.note},_nullishCoalesce(p.idempotencyKey, () => (Le())))},[e.token,s]),m=_react.useCallback.call(void 0, (p,f)=>{y(p).then(c=>_optionalChain([f, 'optionalAccess', _23 => _23.onSuccess, 'optionalCall', _24 => _24(c)]),c=>_optionalChain([f, 'optionalAccess', _25 => _25.onError, 'optionalCall', _26 => _26($(c))]))},[y]);return{submit:a,isPending:t.isPending,error:$(t.error),errorKey:X(t.error),mutateAsync:y,mutate:m,data:t.data,reset:t.reset,status:t.status,isError:t.isError,isSuccess:t.isSuccess}}function Tt(e,r){let t=T("useMyReturns"),{pageSize:n,explicitPageToken:o}=he(e,r),u=Nt(t.token),s=_connectquery.useQuery.call(void 0, _chunk7SYNGA3Rjs.j.returns.listMyReturns,{projectId:t.projectID,sessionToken:_nullishCoalesce(t.token, () => ("")),pageSize:n,pageToken:_nullishCoalesce(o, () => (u.pageToken))},{enabled:t.token!=null});ce(s.error,t.clearSession);let a=_nullishCoalesce(_optionalChain([s, 'access', _27 => _27.data, 'optionalAccess', _28 => _28.nextPageToken]), () => (""));return{returns:_nullishCoalesce(_optionalChain([s, 'access', _29 => _29.data, 'optionalAccess', _30 => _30.returns]), () => ([])),total:_nullishCoalesce(_optionalChain([s, 'access', _31 => _31.data, 'optionalAccess', _32 => _32.total]), () => (0)),data:s.data,isLoading:pe(t)||s.isLoading,isFetching:s.isFetching,error:$(s.error),errorKey:X(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:u.page,hasNext:a!=="",hasPrevious:u.page>1,next:()=>{a!==""&&u.push(a)},previous:u.pop,refetch:()=>s.refetch()}}function me(e){let r=T("useMyReturn"),t=_connectquery.useQuery.call(void 0, _chunk7SYNGA3Rjs.j.returns.getMyReturn,{projectId:r.projectID,sessionToken:_nullishCoalesce(r.token, () => ("")),returnId:e},{enabled:r.token!=null});return ce(t.error,r.clearSession),{request:_optionalChain([t, 'access', _33 => _33.data, 'optionalAccess', _34 => _34.request]),isLoading:pe(r)||t.isLoading,error:t.error,errorKey:X(t.error),refetch:()=>t.refetch()}}var _reactlabel = require('@radix-ui/react-label'); var wt = _interopRequireWildcard(_reactlabel);function te({className:e,...r}){return _jsxruntime.jsx.call(void 0, wt.Root,{"data-slot":"label",className:_chunkAWG5OAK7js.d.call(void 0, "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...r})}var _lucidereact = require('lucide-react');function re({className:e,...r}){return _jsxruntime.jsx.call(void 0, _lucidereact.Loader2Icon,{role:"status","aria-label":"Loading",className:_chunkAWG5OAK7js.d.call(void 0, "size-4 animate-spin",e),...r})}var H="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",L="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",G="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";function M({title:e,description:r,onBack:t,className:n,children:o}){let u=h(),s=l("header"),a=l("title"),y=l("description"),m=l("backButton");return _jsxruntime.jsxs.call(void 0, "section",{className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-5",n),children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"header",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-2",s.className),style:s.style,children:[t!=null&&_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"backButton",className:_chunkAWG5OAK7js.d.call(void 0, "self-start -ml-3 text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",m.className),style:m.style,onClick:t,children:u("back")}),_jsxruntime.jsx.call(void 0, "h2",{"data-bitsnap-returns-slot":"title",className:_chunkAWG5OAK7js.d.call(void 0, "text-2xl font-semibold",a.className),style:a.style,children:e}),r!=null&&_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"description",className:_chunkAWG5OAK7js.d.call(void 0, "text-sm",y.className),style:y.style,children:r})]}),o]})}function A({errorKey:e,onRetry:r}){let t=h(),n=l("error"),o=l("secondaryButton");return _jsxruntime.jsxs.call(void 0, "div",{role:"alert","data-bitsnap-returns-slot":"error",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col items-start gap-2 text-sm",n.className),style:n.style,children:[_jsxruntime.jsx.call(void 0, "p",{children:t(e)}),r!=null&&_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkAWG5OAK7js.d.call(void 0, L,o.className),style:o.style,onClick:r,children:t("errorRetry")})]})}function fe({children:e}){let r=l("emptyState");return _jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"emptyState",className:_chunkAWG5OAK7js.d.call(void 0, "py-6 text-center text-sm",r.className),style:r.style,children:e})}function U({rows:e=3}){let r=h(),t=l("skeleton");return _jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true","aria-label":r("loading"),className:"flex flex-col gap-3",children:Array.from({length:e},(n,o)=>_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.u,{"data-bitsnap-returns-slot":"skeleton",className:_chunkAWG5OAK7js.d.call(void 0, "h-16 w-full bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",t.className),style:t.style},o))})}function J({status:e}){let r=h(),t=l("statusBadge");return _jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"statusBadge","data-status":e,className:_chunkAWG5OAK7js.d.call(void 0, "inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",t.className),style:t.style,children:r(lt(e))})}function ze(){let e=h();return r=>e(ct(r))}function ge({page:e,total:r,hasNext:t,hasPrevious:n,isFetching:o,onNext:u,onPrevious:s}){let a=h(),y=l("pagination"),m=l("secondaryButton");return!t&&!n?null:_jsxruntime.jsxs.call(void 0, "nav",{"data-bitsnap-returns-slot":"pagination",className:_chunkAWG5OAK7js.d.call(void 0, "flex items-center justify-between gap-3 text-sm",y.className),style:y.style,children:[_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkAWG5OAK7js.d.call(void 0, L,m.className),style:m.style,disabled:!n||o,onClick:s,children:a("paginationPrevious")}),_jsxruntime.jsx.call(void 0, "span",{"aria-live":"polite",children:a("paginationInfo",{page:e,total:r})}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkAWG5OAK7js.d.call(void 0, L,m.className),style:m.style,disabled:!t||o,onClick:u,children:a("paginationNext")})]})}function Kn({onSubmitted:e,className:r}){T("ReturnsEmailStep");let t=h(),n=de(),[o,u]=_react.useState.call(void 0, ""),s=l("emailForm"),a=l("emailInput"),y=l("submitButton");async function m(p){p.preventDefault(),!n.isStarting&&await n.start(o)&&_optionalChain([e, 'optionalCall', _35 => _35(o.trim())])}return _jsxruntime.jsx.call(void 0, M,{className:r,title:t("emailStepTitle"),description:t("emailStepDescription"),children:_jsxruntime.jsxs.call(void 0, "form",{"data-bitsnap-returns-slot":"emailForm",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-4",s.className),style:s.style,onSubmit:m,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, te,{htmlFor:"bitsnap-returns-email",children:t("emailLabel")}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.r,{id:"bitsnap-returns-email",type:"email",name:"email",autoComplete:"email",required:!0,value:o,placeholder:t("emailPlaceholder"),disabled:n.isStarting,"data-bitsnap-returns-slot":"emailInput",className:_chunkAWG5OAK7js.d.call(void 0, G,a.className),style:a.style,onChange:p=>u(p.target.value)})]}),n.errorKey!=null&&_jsxruntime.jsx.call(void 0, A,{errorKey:n.errorKey}),_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{type:"submit",disabled:n.isStarting,"data-bitsnap-returns-slot":"submitButton",className:_chunkAWG5OAK7js.d.call(void 0, H,y.className),style:y.style,children:[n.isStarting&&_jsxruntime.jsx.call(void 0, re,{}),t("emailSubmit")]})]})})}function gr(e){let[r,t]=_react.useState.call(void 0, );return _react.useEffect.call(void 0, ()=>{if(e==null)return;t(Date.now());let n=setInterval(()=>{let o=Date.now();t(o),o>=e&&clearInterval(n)},1e3);return()=>clearInterval(n)},[e]),e!=null&&r!=null?Math.max(0,Math.ceil((e-r)/1e3)):0}function _n({onVerified:e,onBack:r,className:t}){T("ReturnsCodeStep");let n=h(),o=de(),[u,s]=_react.useState.call(void 0, ""),a=gr(_optionalChain([o, 'access', _36 => _36.challenge, 'optionalAccess', _37 => _37.resendAvailableAt])),y=l("codeForm"),m=l("codeInput"),p=l("submitButton"),f=l("resendButton"),c=o.isVerifying||o.isStarting;async function b(g){g.preventDefault(),!c&&await o.verify(u)&&_optionalChain([e, 'optionalCall', _38 => _38()])}return _jsxruntime.jsx.call(void 0, M,{className:t,onBack:r,title:n("codeStepTitle"),description:n("codeStepDescription",{email:_nullishCoalesce(_optionalChain([o, 'access', _39 => _39.challenge, 'optionalAccess', _40 => _40.email]), () => (""))}),children:_jsxruntime.jsxs.call(void 0, "form",{"data-bitsnap-returns-slot":"codeForm",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-4",y.className),style:y.style,onSubmit:b,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, te,{htmlFor:"bitsnap-returns-code",children:n("codeLabel")}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.r,{id:"bitsnap-returns-code",name:"code",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:u,disabled:c,"data-bitsnap-returns-slot":"codeInput",className:_chunkAWG5OAK7js.d.call(void 0, G,m.className),style:m.style,onChange:g=>s(g.target.value)})]}),o.errorKey!=null&&_jsxruntime.jsx.call(void 0, A,{errorKey:o.errorKey}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center gap-3",children:[_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{type:"submit",disabled:c||o.challenge==null,"data-bitsnap-returns-slot":"submitButton",className:_chunkAWG5OAK7js.d.call(void 0, H,p.className),style:p.style,children:[o.isVerifying&&_jsxruntime.jsx.call(void 0, re,{}),n("codeSubmit")]}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"secondary",disabled:c||a>0||o.challenge==null,"data-bitsnap-returns-slot":"resendButton",className:_chunkAWG5OAK7js.d.call(void 0, L,f.className),style:f.style,onClick:()=>void o.resend(),children:a>0?n("resendIn",{seconds:a}):n("resend")})]})]})})}function It(){let e=h(),r=de(),t=l("logoutButton");return _jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"logoutButton",className:_chunkAWG5OAK7js.d.call(void 0, "text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",t.className),style:t.style,onClick:r.logout,children:e("logout")})}function Z(e,r){if(e==null)return"";let t=_wkt.timestampDate.call(void 0, e);try{return new Intl.DateTimeFormat(r,{dateStyle:"medium"}).format(t)}catch (e10){return t.toISOString().slice(0,10)}}function ee(e,r,t){let n=typeof e=="bigint"?e:BigInt(Math.trunc(e));try{let o=new Intl.NumberFormat(t,{style:"currency",currency:r}),u=_nullishCoalesce(o.resolvedOptions().maximumFractionDigits, () => (2));return o.format(Et(n,u))}catch (e11){return`${Et(n,2)} ${r}`}}function Et(e,r){let t=e<BigInt(0),n=t?-e:e;if(r<=0)return`${t?"-":""}${n}`;let o=BigInt(10)**BigInt(r),u=n/o,s=(n%o).toString().padStart(r,"0");return`${t?"-":""}${u}.${s}`}function Ct(e,r){return Number.isFinite(e)?Math.min(Math.max(0,Math.trunc(e)),Math.max(0,r)):0}function Oe(e){return e.eligible&&e.availableQuantity>0}function Pt(e,r){return e.map(t=>({lineId:t,quantity:_nullishCoalesce(r[t], () => (0))})).filter(t=>t.quantity>0)}function cs({onSelectOrder:e,onOpenMyReturns:r,showLogout:t=!0,pageSize:n,className:o}){T("ReturnsOrderList");let u=h(),s=Y(),a=ht({pageSize:n}),y=l("orderList"),m=l("orderCard"),p=l("orderReference"),f=l("orderDate"),c=l("orderTotal"),b=l("secondaryButton");return _jsxruntime.jsxs.call(void 0, M,{className:o,title:u("ordersTitle"),description:u("ordersDescription"),children:[(t||r!=null)&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r!=null?_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkAWG5OAK7js.d.call(void 0, L,b.className),style:b.style,onClick:r,children:u("myReturnsLink")}):_jsxruntime.jsx.call(void 0, "span",{}),t&&_jsxruntime.jsx.call(void 0, It,{})]}),a.isLoading?_jsxruntime.jsx.call(void 0, U,{}):a.errorKey!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:a.errorKey,onRetry:a.refetch}):a.orders.length===0?_jsxruntime.jsx.call(void 0, fe,{children:u("ordersEmpty")}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"orderList",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-3",y.className),style:y.style,children:a.orders.map(g=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"orderCard",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderReference",className:_chunkAWG5OAK7js.d.call(void 0, "font-medium",p.className),style:p.style,children:u("orderTitle",{reference:g.displayReference})}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderDate",className:_chunkAWG5OAK7js.d.call(void 0, "text-sm",f.className),style:f.style,children:Z(g.purchasedAt,s)}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:u("orderReturnableLines",{count:g.returnableLineCount})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderTotal",className:_chunkAWG5OAK7js.d.call(void 0, "font-medium",c.className),style:c.style,children:ee(g.totalMinor,g.currency,s)}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"secondary",size:"sm","aria-label":`${u("orderSelect")}: ${u("orderTitle",{reference:g.displayReference})}`,"data-bitsnap-returns-slot":"secondaryButton",className:_chunkAWG5OAK7js.d.call(void 0, L,b.className),style:b.style,onClick:()=>_optionalChain([e, 'optionalCall', _41 => _41(g.canonicalOrderId)]),children:u("orderSelect")})]})]},g.canonicalOrderId))}),_jsxruntime.jsx.call(void 0, ge,{page:a.page,total:a.total,hasNext:a.hasNext,hasPrevious:a.hasPrevious,isFetching:a.isFetching,onNext:a.next,onPrevious:a.previous})]})]})}function ds({orderId:e,onContinue:r,onBack:t,initialItems:n,initialNote:o,className:u}){T("ReturnsOrderDetail");let s=_chunk3N2VK426js.m.call(void 0, );_react.useEffect.call(void 0, ()=>{s.track("return_started",{},{order_ref:null})},[s]);let a=h(),y=Y(),{order:m,returnHistory:p,isLoading:f,errorKey:c,refetch:b}=Be(e),[g,C]=_react.useState.call(void 0, ()=>Object.fromEntries((_nullishCoalesce(n, () => ([]))).map(R=>[R.lineId,R.quantity]))),[I,N]=_react.useState.call(void 0, _nullishCoalesce(o, () => (""))),[B,w]=_react.useState.call(void 0, !1),P=l("lineList"),k=l("line"),Q=l("lineName"),O=l("linePrice"),q=l("lineQuantityControl"),ne=l("quantityButton"),Me=l("quantityInput"),qe=l("lineIneligibleReason"),Ke=l("noteInput"),_e=l("submitButton"),je=l("history"),Ue=l("historyEntry");function Re(R,V){w(!1),C(F=>({...F,[R.lineId]:Ct(V,R.availableQuantity)}))}function At(R){if(R.preventDefault(),m==null)return;let V=Pt(m.lines.filter(Oe).map(F=>F.lineId),g);if(V.length===0){w(!0);return}_optionalChain([r, 'optionalCall', _42 => _42({items:V,note:I.trim()})])}return _jsxruntime.jsx.call(void 0, M,{className:u,onBack:t,title:a("orderDetailTitle",{reference:_nullishCoalesce(_optionalChain([m, 'optionalAccess', _43 => _43.displayReference]), () => (""))}),description:a("orderDetailDescription"),children:f?_jsxruntime.jsx.call(void 0, U,{}):c!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:c,onRetry:b}):m==null?null:_jsxruntime.jsxs.call(void 0, "form",{className:"flex flex-col gap-5",onSubmit:At,children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"lineList",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-3",P.className),style:P.style,children:m.lines.map(R=>{let V=Oe(R),F=_nullishCoalesce(g[R.lineId], () => (0)),be=`bitsnap-returns-quantity-${R.lineId}`;return _jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line","data-selected":F>0?"":void 0,"data-ineligible":V?void 0:"",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-3 border p-4",k.className),style:k.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunkAWG5OAK7js.d.call(void 0, "font-medium",Q.className),style:Q.style,children:R.name}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"linePrice",className:_chunkAWG5OAK7js.d.call(void 0, "text-sm",O.className),style:O.style,children:ee(R.paidUnitMinor,R.currency,y)})]}),V?_jsxruntime.jsxs.call(void 0, "div",{role:"group","aria-label":a("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"lineQuantityControl",className:_chunkAWG5OAK7js.d.call(void 0, "flex items-center gap-2",q.className),style:q.style,children:[_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"secondary",size:"icon-sm","aria-label":a("quantityDecrease",{name:R.name}),"aria-controls":be,disabled:F<=0,"data-bitsnap-returns-slot":"quantityButton",className:_chunkAWG5OAK7js.d.call(void 0, L,ne.className),style:ne.style,onClick:()=>Re(R,F-1),children:_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"-"})}),_jsxruntime.jsx.call(void 0, "input",{id:be,type:"number",inputMode:"numeric",min:0,max:R.availableQuantity,step:1,value:F,"aria-label":a("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"quantityInput",className:_chunkAWG5OAK7js.d.call(void 0, "h-8 w-16 rounded-md border px-2 text-center text-sm outline-none focus-visible:ring-[3px]",G,Me.className),style:Me.style,onChange:Bt=>Re(R,Bt.target.valueAsNumber)}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"secondary",size:"icon-sm","aria-label":a("quantityIncrease",{name:R.name}),"aria-controls":be,disabled:F>=R.availableQuantity,"data-bitsnap-returns-slot":"quantityButton",className:_chunkAWG5OAK7js.d.call(void 0, L,ne.className),style:ne.style,onClick:()=>Re(R,F+1),children:_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"+"})}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:a("quantityOfAvailable",{available:R.availableQuantity})})]}):_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"lineIneligibleReason",className:_chunkAWG5OAK7js.d.call(void 0, "text-sm",qe.className),style:qe.style,children:R.exclusionReason!==""?R.exclusionReason:a("lineIneligibleFallback")})]},R.lineId)})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, te,{htmlFor:"bitsnap-returns-note",children:a("noteLabel")}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.v,{id:"bitsnap-returns-note",name:"note",rows:3,maxLength:1e3,value:I,placeholder:a("notePlaceholder"),"data-bitsnap-returns-slot":"noteInput",className:_chunkAWG5OAK7js.d.call(void 0, G,"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)]",Ke.className),style:Ke.style,onChange:R=>N(R.target.value)})]}),B&&_jsxruntime.jsx.call(void 0, A,{errorKey:"selectionEmpty"}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"submit","data-bitsnap-returns-slot":"submitButton",className:_chunkAWG5OAK7js.d.call(void 0, H,_e.className),style:_e.style,children:a("selectionContinue")}),p.length>0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:a("previousReturnsTitle")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"history",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-2",je.className),style:je.style,children:p.map(R=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"historyEntry",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-wrap items-center justify-between gap-2 text-sm",Ue.className),style:Ue.style,children:[_jsxruntime.jsx.call(void 0, "span",{children:R.reference}),_jsxruntime.jsx.call(void 0, "span",{children:Z(R.createdAt,y)}),_jsxruntime.jsx.call(void 0, J,{status:R.status})]},R.id))})]})]})})}function ps({orderId:e,items:r,note:t,onSubmitted:n,onBack:o,className:u}){T("ReturnsConfirmation");let s=h(),a=Y(),{order:y,isLoading:m,errorKey:p,refetch:f}=Be(e),c=kt(),b=l("summary"),g=l("line"),C=l("lineName"),I=l("linePrice"),N=l("submitButton");async function B(w){if(w.preventDefault(),c.isPending)return;let P=await c.submit({orderId:e,items:r.map(k=>({lineId:k.lineId,quantity:k.quantity})),note:t});P!=null&&_optionalChain([n, 'optionalCall', _44 => _44(P.id,P)])}return _jsxruntime.jsx.call(void 0, M,{className:u,onBack:o,title:s("confirmationTitle"),description:s("confirmationDescription"),children:m?_jsxruntime.jsx.call(void 0, U,{rows:2}):p!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:p,onRetry:f}):_jsxruntime.jsxs.call(void 0, "form",{className:"flex flex-col gap-5",onSubmit:B,children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"summary",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-3 border p-4",b.className),style:b.style,children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:s("confirmationSummary")}),_jsxruntime.jsx.call(void 0, "ul",{className:"flex flex-col gap-3",children:r.map(w=>{let P=_optionalChain([y, 'optionalAccess', _45 => _45.lines, 'access', _46 => _46.find, 'call', _47 => _47(k=>k.lineId===w.lineId)]);return _jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-wrap items-baseline justify-between gap-2",g.className),style:g.style,children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunkAWG5OAK7js.d.call(void 0, "font-medium",C.className),style:C.style,children:_nullishCoalesce(_optionalChain([P, 'optionalAccess', _48 => _48.name]), () => (w.lineId))}),_jsxruntime.jsxs.call(void 0, "span",{"data-bitsnap-returns-slot":"linePrice",className:_chunkAWG5OAK7js.d.call(void 0, "text-sm",I.className),style:I.style,children:[s("confirmationQuantity",{quantity:w.quantity}),P!=null&&` \xB7 ${ee(P.paidUnitMinor*BigInt(w.quantity),P.currency,a)}`]})]},w.lineId)})}),t!=null&&t!==""&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:s("confirmationNote")}),_jsxruntime.jsx.call(void 0, "span",{className:"whitespace-pre-wrap",children:t})]})]}),c.errorKey!=null&&_jsxruntime.jsx.call(void 0, A,{errorKey:c.errorKey}),_jsxruntime.jsxs.call(void 0, _chunk7SYNGA3Rjs.q,{type:"submit",disabled:c.isPending||r.length===0,"data-bitsnap-returns-slot":"submitButton",className:_chunkAWG5OAK7js.d.call(void 0, H,N.className),style:N.style,children:[c.isPending&&_jsxruntime.jsx.call(void 0, re,{}),s("confirmationSubmit")]})]})})}function ms({returnId:e,onContinue:r,onOpenMyReturns:t,className:n}){T("ReturnsResult");let o=h(),{request:u,isLoading:s,errorKey:a,refetch:y}=me(e),m=l("successState"),p=l("returnReference"),f=l("returnInstructions"),c=l("submitButton"),b=l("secondaryButton");return _jsxruntime.jsxs.call(void 0, "section",{className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-5",n),children:[_jsxruntime.jsxs.call(void 0, "div",{role:"status","data-bitsnap-returns-slot":"successState",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-4 border p-5",m.className),style:m.style,children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-2xl font-semibold",children:o("successTitle")}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:o("successDescription")}),s?_jsxruntime.jsx.call(void 0, U,{rows:2}):a!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:a,onRetry:y}):u!=null&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:o("successReference")}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"returnReference",className:_chunkAWG5OAK7js.d.call(void 0, "text-lg font-semibold",p.className),style:p.style,children:u.reference})]}),u.returnInstructions!==""&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium",children:o("successInstructions")}),_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"returnInstructions",className:_chunkAWG5OAK7js.d.call(void 0, "whitespace-pre-wrap border p-3 text-sm",f.className),style:f.style,children:u.returnInstructions})]})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap gap-3",children:[_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button","data-bitsnap-returns-slot":"submitButton",className:_chunkAWG5OAK7js.d.call(void 0, H,c.className),style:c.style,onClick:r,children:o("successDone")}),t!=null&&_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"secondary","data-bitsnap-returns-slot":"secondaryButton",className:_chunkAWG5OAK7js.d.call(void 0, L,b.className),style:b.style,onClick:t,children:o("myReturnsLink")})]})]})}function Ts({onSelectReturn:e,onBack:r,pageSize:t,className:n}){T("ReturnsMyReturnsList");let o=h(),u=Y(),s=ze(),a=Tt({pageSize:t}),y=l("returnList"),m=l("returnCard"),p=l("returnReference"),f=l("secondaryButton");return _jsxruntime.jsx.call(void 0, M,{className:n,onBack:r,title:o("myReturnsTitle"),description:o("myReturnsDescription"),children:a.isLoading?_jsxruntime.jsx.call(void 0, U,{}):a.errorKey!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:a.errorKey,onRetry:a.refetch}):a.returns.length===0?_jsxruntime.jsx.call(void 0, fe,{children:o("myReturnsEmpty")}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"returnList",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-3",y.className),style:y.style,children:a.returns.map(c=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"returnCard",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"returnReference",className:_chunkAWG5OAK7js.d.call(void 0, "font-medium",p.className),style:p.style,children:c.reference}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:Z(c.createdAt,u)}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm",children:[o("myReturnRefund"),": ",s(c.refundStatus)]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-3",children:[_jsxruntime.jsx.call(void 0, J,{status:c.status}),_jsxruntime.jsx.call(void 0, _chunk7SYNGA3Rjs.q,{type:"button",variant:"secondary",size:"sm","aria-label":`${o("myReturnOpen")}: ${c.reference}`,"data-bitsnap-returns-slot":"secondaryButton",className:_chunkAWG5OAK7js.d.call(void 0, L,f.className),style:f.style,onClick:()=>_optionalChain([e, 'optionalCall', _49 => _49(c.id)]),children:o("myReturnOpen")})]})]},c.id))}),_jsxruntime.jsx.call(void 0, ge,{page:a.page,total:a.total,hasNext:a.hasNext,hasPrevious:a.hasPrevious,isFetching:a.isFetching,onNext:a.next,onPrevious:a.previous})]})})}function ws({returnId:e,onBack:r,className:t}){T("ReturnsMyReturnDetail");let n=h(),o=Y(),u=ze(),{request:s,isLoading:a,errorKey:y,refetch:m}=me(e),p=l("summary"),f=l("lineList"),c=l("line"),b=l("lineName"),g=l("returnInstructions"),C=l("history"),I=l("historyEntry");return _jsxruntime.jsx.call(void 0, M,{className:t,onBack:r,title:s!=null?n("myReturnTitle",{reference:s.reference}):n("myReturnDetailTitle"),children:a?_jsxruntime.jsx.call(void 0, U,{}):y!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:y,onRetry:m}):s!=null&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-5",children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"summary",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-2 border p-4 text-sm",p.className),style:p.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-2",children:[_jsxruntime.jsx.call(void 0, J,{status:s.status}),_jsxruntime.jsxs.call(void 0, "span",{children:[n("myReturnCreatedAt"),":"," ",Z(s.createdAt,o)]})]}),_jsxruntime.jsxs.call(void 0, "span",{children:[n("myReturnRefund"),": ",u(s.refundStatus),s.refundAmountMinor>BigInt(0)&&` \xB7 ${ee(s.refundAmountMinor,s.currency,o)}`]}),s.customerNote!==""&&_jsxruntime.jsxs.call(void 0, "span",{className:"whitespace-pre-wrap",children:[n("myReturnNote"),": ",s.customerNote]})]}),s.returnInstructions!==""&&_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"returnInstructions",className:_chunkAWG5OAK7js.d.call(void 0, "whitespace-pre-wrap border p-3 text-sm",g.className),style:g.style,children:s.returnInstructions}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:n("myReturnLines")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"lineList",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-3",f.className),style:f.style,children:s.lines.map(N=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-wrap items-baseline justify-between gap-2 border p-4",c.className),style:c.style,children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunkAWG5OAK7js.d.call(void 0, "font-medium",b.className),style:b.style,children:N.name}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:n("myReturnLineQuantities",{requested:N.requestedQuantity,approved:N.approvedQuantity,received:N.receivedQuantity})})]},N.lineId))})]}),s.history.length>0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:n("myReturnHistory")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"history",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-col gap-2",C.className),style:C.style,children:s.history.map(N=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"historyEntry",className:_chunkAWG5OAK7js.d.call(void 0, "flex flex-wrap items-center justify-between gap-2 text-sm",I.className),style:I.style,children:[_jsxruntime.jsx.call(void 0, J,{status:N.status}),_jsxruntime.jsx.call(void 0, "span",{children:Z(N.createdAt,o)})]},N.id))})]})]})})}exports.a = te; exports.b = re; exports.c = vr; exports.d = nt; exports.e = Ne; exports.f = l; exports.g = Pe; exports.h = St; exports.i = h; exports.j = T; exports.k = ir; exports.l = Xr; exports.m = de; exports.n = ht; exports.o = Be; exports.p = kt; exports.q = Tt; exports.r = me; exports.s = U; exports.t = Kn; exports.u = _n; exports.v = cs; exports.w = ds; exports.x = ps; exports.y = ms; exports.z = Ts; exports.A = ws;
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkKOYBZORLjs = require('./chunk-KOYBZORL.js');var _chunkFGB5FJCIjs = require('./chunk-FGB5FJCI.js');var _chunkDY2S42Q6js = require('./chunk-DY2S42Q6.js');var _chunkMG6VV5J2js = require('./chunk-MG6VV5J2.js');var vr=["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"],zt={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"},Dt={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"}},Ot=[{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 ve(e){let r=_chunkKOYBZORLjs.a.call(void 0, e,{defaultTheme:"light",presets:Dt,variables:zt,shadcnVariables:Ot});return{theme:r.theme,tokens:r.tokens,elements:r.elements,boundaryClassName:r.theme,boundaryStyle:r.boundaryStyle}}function tt(e,r){return _chunkKOYBZORLjs.b.call(void 0, e.elements,r)}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var rt=_react.createContext.call(void 0, ve());function nt({appearance:e,children:r}){let t=_react.useMemo.call(void 0, ()=>ve(e),[e]);return _jsxruntime.jsx.call(void 0, rt.Provider,{value:t,children:r})}function Ne(){return _react.useContext.call(void 0, rt)}function l(e){let r=Ne();return _nullishCoalesce(tt(r,e), () => ({}))}function ot(e){return e==="test"||e===1?1:0}var st={title:["emailStepTitle"],email:["emailLabel"],sendCode:["emailSubmit"],code:["codeLabel"],verify:["codeSubmit"],orders:["ordersTitle"],submit:["confirmationSubmit"],note:["noteLabel"],history:["myReturnsTitle","myReturnsLink"]};function at(e){if(e==null)return;let r={};for(let[t,n]of Object.entries(st)){let o=e[t];if(typeof o=="string")for(let u of n)r[u]=o}for(let t of Object.keys(e)){if(t in st)continue;let n=e[t];typeof n=="string"&&(r[t]=n)}return r}function it(e,r){let t=_optionalChain([r, 'optionalAccess', _2 => _2.brandColor, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]);return t==null||t===""?e:{...e,tokens:{..._chunkFGB5FJCIjs.t.call(void 0, t),..._optionalChain([e, 'optionalAccess', _5 => _5.tokens])}}}function he(e,r){return typeof e=="object"&&e!=null?{pageSize:_nullishCoalesce(e.pageSize, () => (20)),explicitPageToken:void 0}:typeof e=="number"||r!==void 0?{pageSize:_nullishCoalesce(e, () => (20)),explicitPageToken:_nullishCoalesce(r, () => (""))}:{pageSize:20,explicitPageToken:void 0}}var _t={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",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.",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",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.",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 ke(e,r){return _chunkDY2S42Q6js.i.call(void 0, _t,e,r)}function ut(e,r){return e.replace(/\{(\w+)\}/g,(t,n)=>Object.prototype.hasOwnProperty.call(r,n)?String(r[n]):t)}var jt={submitted:"statusSubmitted",approved:"statusApproved",rejected:"statusRejected",awaiting_receipt:"statusAwaitingReceipt",received:"statusReceived",completed:"statusCompleted",cancelled:"statusCancelled",refunded:"statusRefunded"},Ut={not_started:"refundStatusNotStarted",pending:"refundStatusPending",succeeded:"refundStatusSucceeded",failed:"refundStatusFailed"};function lt(e){return _nullishCoalesce(jt[e], () => ("statusFallback"))}function ct(e){return _nullishCoalesce(Ut[e], () => ("refundStatusFallback"))}var Te=_react.createContext.call(void 0, {locale:"pl-PL",texts:ke("pl-PL")});function pt({texts:e,locale:r,children:t}){let n=_nullishCoalesce(r, () => (_chunkDY2S42Q6js.m.call(void 0, ))),o=_react.useMemo.call(void 0, ()=>({locale:n,texts:ke(n,e)}),[n,e]);return _jsxruntime.jsx.call(void 0, Te.Provider,{value:o,children:t})}function h(){let{texts:e}=_react.useContext.call(void 0, Te);return _react.useCallback.call(void 0, (r,t)=>t==null?e[r]:ut(e[r],t),[e])}function Y(){return _react.useContext.call(void 0, Te).locale}var _connect = require('@connectrpc/connect');var _connectquery = require('@connectrpc/connect-query');var _reactquery = require('@tanstack/react-query');var _wkt = require('@bufbuild/protobuf/wkt');var Zt="bitsnap-returns-session:";function we(e){return`${Zt}${e}`}function oe(){try{return typeof window<"u"?window.sessionStorage:void 0}catch (e2){return}}function mt(e,r,t=Date.now()){if(e==null)return;let n=we(r);try{let o=e.getItem(n);if(o==null)return;let u=JSON.parse(o);if(u!=null&&typeof u=="object"&&typeof u.token=="string"&&u.token.length>0&&typeof u.expiresAt=="number"&&u.expiresAt>t){let{token:s,expiresAt:a}=u;return{token:s,expiresAt:a}}e.removeItem(n)}catch (e3){try{e.removeItem(n)}catch (e4){}}}function yt(e,r,t){try{_optionalChain([e, 'optionalAccess', _6 => _6.setItem, 'call', _7 => _7(we(r),JSON.stringify(t))])}catch (e5){}}function Ie(e,r){try{_optionalChain([e, 'optionalAccess', _8 => _8.removeItem, 'call', _9 => _9(we(r))])}catch (e6){}}function ae(e){return e==null?void 0:_wkt.timestampMs.call(void 0, e)}var Rt=_react.createContext.call(void 0, void 0);function T(e){let r=_react.useContext.call(void 0, Rt);if(r==null)throw new Error(`${e} must be rendered inside <ReturnsProvider>`);return r}function Ce(){return _connectquery.createConnectQueryKey.call(void 0, {schema:_chunkFGB5FJCIjs.i,cardinality:void 0})}var or=2**31-1;function ar({projectID:e,environment:r,transport:t,panelAccessToken:n,className:o,children:u}){let s=_reactquery.useQueryClient.call(void 0, ),{boundaryClassName:a,boundaryStyle:y}=Ne(),m=l("root"),[p,f]=_react.useState.call(void 0, {status:"hydrating"}),[c,b]=_react.useState.call(void 0, ),[g,C]=_react.useState.call(void 0, ),I=_react.useRef.call(void 0, void 0),N=_react.useCallback.call(void 0, ()=>{s.removeQueries({queryKey:Ce()})},[s]),B=_react.useCallback.call(void 0, ()=>{Ie(oe(),e),C(void 0),f({status:"anonymous"}),N()},[e,N]),w=_react.useCallback.call(void 0, k=>{yt(oe(),e,k),b(void 0),C(void 0),f({status:"authenticated",token:k.token,expiresAt:k.expiresAt})},[e]);_react.useEffect.call(void 0, ()=>{let k=!1,Q=oe();if(n==null||n===""){let O=I.current!=null;if(I.current=void 0,O){B();return}let q=mt(Q,e);f(q!=null?{status:"authenticated",token:q.token,expiresAt:q.expiresAt}:{status:"anonymous"});return}return I.current=n,Ie(Q,e),N(),b(void 0),f({status:"exchanging"}),_connect.createClient.call(void 0, _chunkFGB5FJCIjs.i,t).exchangePanelSession({projectId:e,accessToken:n,environment:r}).then(O=>{if(k)return;let q=ae(O.expiresAt);if(O.sessionToken===""||q==null)throw new Error("EMPTY_SESSION");w({token:O.sessionToken,expiresAt:q})}).catch(O=>{k||(b(O),f({status:"anonymous"}))}),()=>{k=!0}},[n,e,r,t]),_react.useEffect.call(void 0, ()=>{if(p.status!=="authenticated"||p.expiresAt==null)return;let k=p.expiresAt-Date.now();if(k<=0){B();return}let Q=setTimeout(B,Math.min(k,or));return()=>clearTimeout(Q)},[p.status,p.expiresAt,B]);let P=_react.useMemo.call(void 0, ()=>({projectID:e,environment:r,status:p.status,token:p.token,exchangeError:c,challenge:g,setChallenge:C,authenticate:w,clearSession:B}),[e,r,p.status,p.token,c,g,w,B]);return _jsxruntime.jsx.call(void 0, Rt.Provider,{value:P,children:_jsxruntime.jsx.call(void 0, "div",{"data-bitsnap-returns":"root","data-bitsnap-returns-slot":"root",className:_chunkDY2S42Q6js.d.call(void 0, "bitsnap-react",a,o,m.className),style:{...y,...m.style},children:u})})}function ir({projectID:e,host:r,environment:t,appearance:n,texts:o,theme:u,locale:s,panelAccessToken:a,className:y,analytics:m,children:p}){let f=_chunkMG6VV5J2js.n.call(void 0, e,m,"returns"),c=_react.useContext.call(void 0, _reactquery.QueryClientContext),[b]=_react.useState.call(void 0, ()=>c==null?new (0, _reactquery.QueryClient)({defaultOptions:{queries:{staleTime:5e3}}}):void 0),g=_nullishCoalesce(r, () => (_chunkFGB5FJCIjs.m.call(void 0, ))),C=_react.useMemo.call(void 0, ()=>_chunkFGB5FJCIjs.n.call(void 0, g),[g]),I=_optionalChain([u, 'optionalAccess', _10 => _10.brandColor]),N=_react.useMemo.call(void 0, ()=>it(n,{brandColor:I}),[n,I]),B=_react.useMemo.call(void 0, ()=>at(o),[o]),w=_jsxruntime.jsx.call(void 0, _chunkMG6VV5J2js.l,{value:f,children:_jsxruntime.jsx.call(void 0, _connectquery.TransportProvider,{transport:C,children:_jsxruntime.jsx.call(void 0, nt,{appearance:N,children:_jsxruntime.jsx.call(void 0, pt,{texts:B,locale:s,children:_jsxruntime.jsx.call(void 0, ar,{projectID:e,environment:ot(t),transport:C,panelAccessToken:a,className:y,children:p})})})})});return c==null&&b!=null?_jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:b,children:w}):w}var Xr=ir;var ur="SESSION_EXPIRED",bt={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 xt(e){if(e==null||typeof e!="object")return;let{rawMessage:r,message:t}=e;if(typeof r=="string"&&r.length>0)return r;if(typeof t=="string")return Object.keys(bt).find(n=>t.includes(n))}function Pe(e){return xt(e)===ur}function St(e){let r=xt(e);return_nullishCoalesce((r!=null?bt[r]:void 0), () => ("errorGeneric"))}function Le(){let e=typeof globalThis<"u"?globalThis.crypto:void 0;if(typeof _optionalChain([e, 'optionalAccess', _11 => _11.randomUUID])=="function")return e.randomUUID();let r=new Uint8Array(16);if(typeof _optionalChain([e, 'optionalAccess', _12 => _12.getRandomValues])=="function")e.getRandomValues(r);else for(let t=0;t<r.length;t++)r[t]=Math.floor(Math.random()*256);return Array.from(r,t=>t.toString(16).padStart(2,"0")).join("")}function $(e){return e==null?null:e instanceof Error?e:new Error(String(e))}function X(e){return e==null?void 0:St(e)}function ce(e,r){_react.useEffect.call(void 0, ()=>{Pe(e)&&r()},[e,r])}function Nt(e){let[r,t]=_react.useState.call(void 0, [""]);return _react.useEffect.call(void 0, ()=>{t([""])},[e]),{pageToken:_nullishCoalesce(r[r.length-1], () => ("")),page:r.length,push:n=>t(o=>[...o,n]),pop:()=>t(n=>n.length>1?n.slice(0,-1):n)}}function de(){let e=T("useReturnSession"),r=_connectquery.useMutation.call(void 0, _chunkFGB5FJCIjs.j.returns.startReturnSession),t=_connectquery.useMutation.call(void 0, _chunkFGB5FJCIjs.j.returns.verifyReturnSession),{setChallenge:n,authenticate:o,clearSession:u}=e,s=_react.useCallback.call(void 0, async c=>{t.reset();let b=c.trim(),g=await r.mutateAsync({projectId:e.projectID,email:b,environment:e.environment});return n({challengeId:g.challengeId,email:b,resendAvailableAt:Date.now()+Math.max(0,g.resendAfterSeconds)*1e3}),g},[e.projectID,e.environment,n,r,t]),a=_react.useCallback.call(void 0, async c=>{let b=await t.mutateAsync({projectId:e.projectID,challengeId:c.challengeId,code:c.code,environment:e.environment}),g=ae(b.expiresAt);if(b.sessionToken===""||g==null)throw new Error("EMPTY_SESSION");return o({token:b.sessionToken,expiresAt:g}),b},[e.projectID,e.environment,o,t]),y=_react.useCallback.call(void 0, async c=>{try{return await s(c),!0}catch (e7){return!1}},[s]),m=_react.useCallback.call(void 0, async c=>{if(e.challenge==null)return!1;try{return await a({challengeId:e.challenge.challengeId,code:c.trim()}),!0}catch (e8){return!1}},[e.challenge,a]),p=_react.useCallback.call(void 0, ()=>e.challenge!=null?y(e.challenge.email):Promise.resolve(!1),[e.challenge,y]),f=$(_nullishCoalesce(_nullishCoalesce(r.error, () => (t.error)), () => (e.exchangeError)));return{status:e.status,isAuthenticated:e.status==="authenticated",challenge:e.challenge,isStarting:r.isPending,isVerifying:t.isPending,starting:r.isPending,verifying:t.isPending,error:f,errorKey:X(f),start:y,startSession:s,verifySession:a,verify:m,resend:p,logout:u}}function pe(e){return e.status==="hydrating"||e.status==="exchanging"}function ht(e,r){let t=T("useReturnOrders"),{pageSize:n,explicitPageToken:o}=he(e,r),u=Nt(t.token),s=_connectquery.useQuery.call(void 0, _chunkFGB5FJCIjs.j.returns.listReturnOrders,{projectId:t.projectID,sessionToken:_nullishCoalesce(t.token, () => ("")),pageSize:n,pageToken:_nullishCoalesce(o, () => (u.pageToken))},{enabled:t.token!=null});ce(s.error,t.clearSession);let a=_nullishCoalesce(_optionalChain([s, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.nextPageToken]), () => (""));return{orders:_nullishCoalesce(_optionalChain([s, 'access', _15 => _15.data, 'optionalAccess', _16 => _16.orders]), () => ([])),total:_nullishCoalesce(_optionalChain([s, 'access', _17 => _17.data, 'optionalAccess', _18 => _18.total]), () => (0)),data:s.data,isLoading:pe(t)||s.isLoading,isFetching:s.isFetching,error:$(s.error),errorKey:X(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:u.page,hasNext:a!=="",hasPrevious:u.page>1,next:()=>{a!==""&&u.push(a)},previous:u.pop,refetch:()=>s.refetch()}}function Be(e){let r=T("useReturnableOrder"),t=_connectquery.useQuery.call(void 0, _chunkFGB5FJCIjs.j.returns.getReturnableOrder,{projectId:r.projectID,sessionToken:_nullishCoalesce(r.token, () => ("")),canonicalOrderId:_nullishCoalesce(e, () => (""))},{enabled:r.token!=null&&e!=null&&e!==""});return ce(t.error,r.clearSession),{order:_optionalChain([t, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.order]),returnHistory:_nullishCoalesce(_optionalChain([t, 'access', _21 => _21.data, 'optionalAccess', _22 => _22.returnHistory]), () => ([])),data:t.data,isLoading:e!=null&&e!==""&&(pe(r)||t.isLoading),error:$(t.error),errorKey:X(t.error),status:t.status,isError:t.isError,isSuccess:t.isSuccess,refetch:()=>t.refetch()}}function kt(){let e=T("useCreateReturn"),r=_reactquery.useQueryClient.call(void 0, ),t=_connectquery.useMutation.call(void 0, _chunkFGB5FJCIjs.j.returns.createReturnRequest),n=_chunkMG6VV5J2js.m.call(void 0, ),o=_react.useRef.call(void 0, void 0),{clearSession:u}=e,s=_react.useCallback.call(void 0, async(p,f)=>{try{let c=await t.mutateAsync({projectId:e.projectID,sessionToken:_nullishCoalesce(e.token, () => ("")),canonicalOrderId:p.orderId,items:p.items,note:_nullishCoalesce(p.note, () => ("")),idempotencyKey:f});return r.invalidateQueries({queryKey:Ce()}),n.track("return_submitted",{reason_code:"unspecified",item_count:p.items.length},{order_ref:null}),c}catch(c){throw Pe(c)&&u(),c}},[e.projectID,e.token,t,r,u,n]),a=_react.useCallback.call(void 0, async p=>{o.current??=Le();try{let f=await s(p,o.current);return o.current=void 0,f.request}catch (e9){return}},[s]),y=_react.useCallback.call(void 0, async p=>{if(e.token==null)throw new Error("Verify your email to continue.");return s({orderId:p.canonicalOrderID,items:p.items,note:p.note},_nullishCoalesce(p.idempotencyKey, () => (Le())))},[e.token,s]),m=_react.useCallback.call(void 0, (p,f)=>{y(p).then(c=>_optionalChain([f, 'optionalAccess', _23 => _23.onSuccess, 'optionalCall', _24 => _24(c)]),c=>_optionalChain([f, 'optionalAccess', _25 => _25.onError, 'optionalCall', _26 => _26($(c))]))},[y]);return{submit:a,isPending:t.isPending,error:$(t.error),errorKey:X(t.error),mutateAsync:y,mutate:m,data:t.data,reset:t.reset,status:t.status,isError:t.isError,isSuccess:t.isSuccess}}function Tt(e,r){let t=T("useMyReturns"),{pageSize:n,explicitPageToken:o}=he(e,r),u=Nt(t.token),s=_connectquery.useQuery.call(void 0, _chunkFGB5FJCIjs.j.returns.listMyReturns,{projectId:t.projectID,sessionToken:_nullishCoalesce(t.token, () => ("")),pageSize:n,pageToken:_nullishCoalesce(o, () => (u.pageToken))},{enabled:t.token!=null});ce(s.error,t.clearSession);let a=_nullishCoalesce(_optionalChain([s, 'access', _27 => _27.data, 'optionalAccess', _28 => _28.nextPageToken]), () => (""));return{returns:_nullishCoalesce(_optionalChain([s, 'access', _29 => _29.data, 'optionalAccess', _30 => _30.returns]), () => ([])),total:_nullishCoalesce(_optionalChain([s, 'access', _31 => _31.data, 'optionalAccess', _32 => _32.total]), () => (0)),data:s.data,isLoading:pe(t)||s.isLoading,isFetching:s.isFetching,error:$(s.error),errorKey:X(s.error),status:s.status,isError:s.isError,isSuccess:s.isSuccess,page:u.page,hasNext:a!=="",hasPrevious:u.page>1,next:()=>{a!==""&&u.push(a)},previous:u.pop,refetch:()=>s.refetch()}}function me(e){let r=T("useMyReturn"),t=_connectquery.useQuery.call(void 0, _chunkFGB5FJCIjs.j.returns.getMyReturn,{projectId:r.projectID,sessionToken:_nullishCoalesce(r.token, () => ("")),returnId:e},{enabled:r.token!=null});return ce(t.error,r.clearSession),{request:_optionalChain([t, 'access', _33 => _33.data, 'optionalAccess', _34 => _34.request]),isLoading:pe(r)||t.isLoading,error:t.error,errorKey:X(t.error),refetch:()=>t.refetch()}}var _reactlabel = require('@radix-ui/react-label'); var wt = _interopRequireWildcard(_reactlabel);function te({className:e,...r}){return _jsxruntime.jsx.call(void 0, wt.Root,{"data-slot":"label",className:_chunkDY2S42Q6js.d.call(void 0, "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...r})}var _lucidereact = require('lucide-react');function re({className:e,...r}){return _jsxruntime.jsx.call(void 0, _lucidereact.Loader2Icon,{role:"status","aria-label":"Loading",className:_chunkDY2S42Q6js.d.call(void 0, "size-4 animate-spin",e),...r})}var H="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",L="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",G="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";function M({title:e,description:r,onBack:t,className:n,children:o}){let u=h(),s=l("header"),a=l("title"),y=l("description"),m=l("backButton");return _jsxruntime.jsxs.call(void 0, "section",{className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-5",n),children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"header",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-2",s.className),style:s.style,children:[t!=null&&_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"backButton",className:_chunkDY2S42Q6js.d.call(void 0, "self-start -ml-3 text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",m.className),style:m.style,onClick:t,children:u("back")}),_jsxruntime.jsx.call(void 0, "h2",{"data-bitsnap-returns-slot":"title",className:_chunkDY2S42Q6js.d.call(void 0, "text-2xl font-semibold",a.className),style:a.style,children:e}),r!=null&&_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"description",className:_chunkDY2S42Q6js.d.call(void 0, "text-sm",y.className),style:y.style,children:r})]}),o]})}function A({errorKey:e,onRetry:r}){let t=h(),n=l("error"),o=l("secondaryButton");return _jsxruntime.jsxs.call(void 0, "div",{role:"alert","data-bitsnap-returns-slot":"error",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col items-start gap-2 text-sm",n.className),style:n.style,children:[_jsxruntime.jsx.call(void 0, "p",{children:t(e)}),r!=null&&_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkDY2S42Q6js.d.call(void 0, L,o.className),style:o.style,onClick:r,children:t("errorRetry")})]})}function fe({children:e}){let r=l("emptyState");return _jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"emptyState",className:_chunkDY2S42Q6js.d.call(void 0, "py-6 text-center text-sm",r.className),style:r.style,children:e})}function U({rows:e=3}){let r=h(),t=l("skeleton");return _jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true","aria-label":r("loading"),className:"flex flex-col gap-3",children:Array.from({length:e},(n,o)=>_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.u,{"data-bitsnap-returns-slot":"skeleton",className:_chunkDY2S42Q6js.d.call(void 0, "h-16 w-full bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",t.className),style:t.style},o))})}function J({status:e}){let r=h(),t=l("statusBadge");return _jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"statusBadge","data-status":e,className:_chunkDY2S42Q6js.d.call(void 0, "inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium",t.className),style:t.style,children:r(lt(e))})}function ze(){let e=h();return r=>e(ct(r))}function ge({page:e,total:r,hasNext:t,hasPrevious:n,isFetching:o,onNext:u,onPrevious:s}){let a=h(),y=l("pagination"),m=l("secondaryButton");return!t&&!n?null:_jsxruntime.jsxs.call(void 0, "nav",{"data-bitsnap-returns-slot":"pagination",className:_chunkDY2S42Q6js.d.call(void 0, "flex items-center justify-between gap-3 text-sm",y.className),style:y.style,children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkDY2S42Q6js.d.call(void 0, L,m.className),style:m.style,disabled:!n||o,onClick:s,children:a("paginationPrevious")}),_jsxruntime.jsx.call(void 0, "span",{"aria-live":"polite",children:a("paginationInfo",{page:e,total:r})}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkDY2S42Q6js.d.call(void 0, L,m.className),style:m.style,disabled:!t||o,onClick:u,children:a("paginationNext")})]})}function Kn({onSubmitted:e,className:r}){T("ReturnsEmailStep");let t=h(),n=de(),[o,u]=_react.useState.call(void 0, ""),s=l("emailForm"),a=l("emailInput"),y=l("submitButton");async function m(p){p.preventDefault(),!n.isStarting&&await n.start(o)&&_optionalChain([e, 'optionalCall', _35 => _35(o.trim())])}return _jsxruntime.jsx.call(void 0, M,{className:r,title:t("emailStepTitle"),description:t("emailStepDescription"),children:_jsxruntime.jsxs.call(void 0, "form",{"data-bitsnap-returns-slot":"emailForm",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-4",s.className),style:s.style,onSubmit:m,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, te,{htmlFor:"bitsnap-returns-email",children:t("emailLabel")}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.r,{id:"bitsnap-returns-email",type:"email",name:"email",autoComplete:"email",required:!0,value:o,placeholder:t("emailPlaceholder"),disabled:n.isStarting,"data-bitsnap-returns-slot":"emailInput",className:_chunkDY2S42Q6js.d.call(void 0, G,a.className),style:a.style,onChange:p=>u(p.target.value)})]}),n.errorKey!=null&&_jsxruntime.jsx.call(void 0, A,{errorKey:n.errorKey}),_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{type:"submit",disabled:n.isStarting,"data-bitsnap-returns-slot":"submitButton",className:_chunkDY2S42Q6js.d.call(void 0, H,y.className),style:y.style,children:[n.isStarting&&_jsxruntime.jsx.call(void 0, re,{}),t("emailSubmit")]})]})})}function gr(e){let[r,t]=_react.useState.call(void 0, );return _react.useEffect.call(void 0, ()=>{if(e==null)return;t(Date.now());let n=setInterval(()=>{let o=Date.now();t(o),o>=e&&clearInterval(n)},1e3);return()=>clearInterval(n)},[e]),e!=null&&r!=null?Math.max(0,Math.ceil((e-r)/1e3)):0}function _n({onVerified:e,onBack:r,className:t}){T("ReturnsCodeStep");let n=h(),o=de(),[u,s]=_react.useState.call(void 0, ""),a=gr(_optionalChain([o, 'access', _36 => _36.challenge, 'optionalAccess', _37 => _37.resendAvailableAt])),y=l("codeForm"),m=l("codeInput"),p=l("submitButton"),f=l("resendButton"),c=o.isVerifying||o.isStarting;async function b(g){g.preventDefault(),!c&&await o.verify(u)&&_optionalChain([e, 'optionalCall', _38 => _38()])}return _jsxruntime.jsx.call(void 0, M,{className:t,onBack:r,title:n("codeStepTitle"),description:n("codeStepDescription",{email:_nullishCoalesce(_optionalChain([o, 'access', _39 => _39.challenge, 'optionalAccess', _40 => _40.email]), () => (""))}),children:_jsxruntime.jsxs.call(void 0, "form",{"data-bitsnap-returns-slot":"codeForm",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-4",y.className),style:y.style,onSubmit:b,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, te,{htmlFor:"bitsnap-returns-code",children:n("codeLabel")}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.r,{id:"bitsnap-returns-code",name:"code",inputMode:"numeric",autoComplete:"one-time-code",required:!0,value:u,disabled:c,"data-bitsnap-returns-slot":"codeInput",className:_chunkDY2S42Q6js.d.call(void 0, G,m.className),style:m.style,onChange:g=>s(g.target.value)})]}),o.errorKey!=null&&_jsxruntime.jsx.call(void 0, A,{errorKey:o.errorKey}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center gap-3",children:[_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{type:"submit",disabled:c||o.challenge==null,"data-bitsnap-returns-slot":"submitButton",className:_chunkDY2S42Q6js.d.call(void 0, H,p.className),style:p.style,children:[o.isVerifying&&_jsxruntime.jsx.call(void 0, re,{}),n("codeSubmit")]}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"secondary",disabled:c||a>0||o.challenge==null,"data-bitsnap-returns-slot":"resendButton",className:_chunkDY2S42Q6js.d.call(void 0, L,f.className),style:f.style,onClick:()=>void o.resend(),children:a>0?n("resendIn",{seconds:a}):n("resend")})]})]})})}function It(){let e=h(),r=de(),t=l("logoutButton");return _jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"ghost",size:"sm","data-bitsnap-returns-slot":"logoutButton",className:_chunkDY2S42Q6js.d.call(void 0, "text-[color:var(--bitsnap-returns-muted-foreground,#71717a)] hover:bg-[var(--bitsnap-returns-hover-surface,#f4f4f5)]",t.className),style:t.style,onClick:r.logout,children:e("logout")})}function Z(e,r){if(e==null)return"";let t=_wkt.timestampDate.call(void 0, e);try{return new Intl.DateTimeFormat(r,{dateStyle:"medium"}).format(t)}catch (e10){return t.toISOString().slice(0,10)}}function ee(e,r,t){let n=typeof e=="bigint"?e:BigInt(Math.trunc(e));try{let o=new Intl.NumberFormat(t,{style:"currency",currency:r}),u=_nullishCoalesce(o.resolvedOptions().maximumFractionDigits, () => (2));return o.format(Et(n,u))}catch (e11){return`${Et(n,2)} ${r}`}}function Et(e,r){let t=e<BigInt(0),n=t?-e:e;if(r<=0)return`${t?"-":""}${n}`;let o=BigInt(10)**BigInt(r),u=n/o,s=(n%o).toString().padStart(r,"0");return`${t?"-":""}${u}.${s}`}function Ct(e,r){return Number.isFinite(e)?Math.min(Math.max(0,Math.trunc(e)),Math.max(0,r)):0}function Oe(e){return e.eligible&&e.availableQuantity>0}function Pt(e,r){return e.map(t=>({lineId:t,quantity:_nullishCoalesce(r[t], () => (0))})).filter(t=>t.quantity>0)}function cs({onSelectOrder:e,onOpenMyReturns:r,showLogout:t=!0,pageSize:n,className:o}){T("ReturnsOrderList");let u=h(),s=Y(),a=ht({pageSize:n}),y=l("orderList"),m=l("orderCard"),p=l("orderReference"),f=l("orderDate"),c=l("orderTotal"),b=l("secondaryButton");return _jsxruntime.jsxs.call(void 0, M,{className:o,title:u("ordersTitle"),description:u("ordersDescription"),children:[(t||r!=null)&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r!=null?_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"secondary",size:"sm","data-bitsnap-returns-slot":"secondaryButton",className:_chunkDY2S42Q6js.d.call(void 0, L,b.className),style:b.style,onClick:r,children:u("myReturnsLink")}):_jsxruntime.jsx.call(void 0, "span",{}),t&&_jsxruntime.jsx.call(void 0, It,{})]}),a.isLoading?_jsxruntime.jsx.call(void 0, U,{}):a.errorKey!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:a.errorKey,onRetry:a.refetch}):a.orders.length===0?_jsxruntime.jsx.call(void 0, fe,{children:u("ordersEmpty")}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"orderList",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-3",y.className),style:y.style,children:a.orders.map(g=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"orderCard",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderReference",className:_chunkDY2S42Q6js.d.call(void 0, "font-medium",p.className),style:p.style,children:u("orderTitle",{reference:g.displayReference})}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderDate",className:_chunkDY2S42Q6js.d.call(void 0, "text-sm",f.className),style:f.style,children:Z(g.purchasedAt,s)}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:u("orderReturnableLines",{count:g.returnableLineCount})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"orderTotal",className:_chunkDY2S42Q6js.d.call(void 0, "font-medium",c.className),style:c.style,children:ee(g.totalMinor,g.currency,s)}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"secondary",size:"sm","aria-label":`${u("orderSelect")}: ${u("orderTitle",{reference:g.displayReference})}`,"data-bitsnap-returns-slot":"secondaryButton",className:_chunkDY2S42Q6js.d.call(void 0, L,b.className),style:b.style,onClick:()=>_optionalChain([e, 'optionalCall', _41 => _41(g.canonicalOrderId)]),children:u("orderSelect")})]})]},g.canonicalOrderId))}),_jsxruntime.jsx.call(void 0, ge,{page:a.page,total:a.total,hasNext:a.hasNext,hasPrevious:a.hasPrevious,isFetching:a.isFetching,onNext:a.next,onPrevious:a.previous})]})]})}function ds({orderId:e,onContinue:r,onBack:t,initialItems:n,initialNote:o,className:u}){T("ReturnsOrderDetail");let s=_chunkMG6VV5J2js.m.call(void 0, );_react.useEffect.call(void 0, ()=>{s.track("return_started",{},{order_ref:null})},[s]);let a=h(),y=Y(),{order:m,returnHistory:p,isLoading:f,errorKey:c,refetch:b}=Be(e),[g,C]=_react.useState.call(void 0, ()=>Object.fromEntries((_nullishCoalesce(n, () => ([]))).map(R=>[R.lineId,R.quantity]))),[I,N]=_react.useState.call(void 0, _nullishCoalesce(o, () => (""))),[B,w]=_react.useState.call(void 0, !1),P=l("lineList"),k=l("line"),Q=l("lineName"),O=l("linePrice"),q=l("lineQuantityControl"),ne=l("quantityButton"),Me=l("quantityInput"),qe=l("lineIneligibleReason"),Ke=l("noteInput"),_e=l("submitButton"),je=l("history"),Ue=l("historyEntry");function Re(R,V){w(!1),C(F=>({...F,[R.lineId]:Ct(V,R.availableQuantity)}))}function At(R){if(R.preventDefault(),m==null)return;let V=Pt(m.lines.filter(Oe).map(F=>F.lineId),g);if(V.length===0){w(!0);return}_optionalChain([r, 'optionalCall', _42 => _42({items:V,note:I.trim()})])}return _jsxruntime.jsx.call(void 0, M,{className:u,onBack:t,title:a("orderDetailTitle",{reference:_nullishCoalesce(_optionalChain([m, 'optionalAccess', _43 => _43.displayReference]), () => (""))}),description:a("orderDetailDescription"),children:f?_jsxruntime.jsx.call(void 0, U,{}):c!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:c,onRetry:b}):m==null?null:_jsxruntime.jsxs.call(void 0, "form",{className:"flex flex-col gap-5",onSubmit:At,children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"lineList",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-3",P.className),style:P.style,children:m.lines.map(R=>{let V=Oe(R),F=_nullishCoalesce(g[R.lineId], () => (0)),be=`bitsnap-returns-quantity-${R.lineId}`;return _jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line","data-selected":F>0?"":void 0,"data-ineligible":V?void 0:"",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-3 border p-4",k.className),style:k.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunkDY2S42Q6js.d.call(void 0, "font-medium",Q.className),style:Q.style,children:R.name}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"linePrice",className:_chunkDY2S42Q6js.d.call(void 0, "text-sm",O.className),style:O.style,children:ee(R.paidUnitMinor,R.currency,y)})]}),V?_jsxruntime.jsxs.call(void 0, "div",{role:"group","aria-label":a("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"lineQuantityControl",className:_chunkDY2S42Q6js.d.call(void 0, "flex items-center gap-2",q.className),style:q.style,children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"secondary",size:"icon-sm","aria-label":a("quantityDecrease",{name:R.name}),"aria-controls":be,disabled:F<=0,"data-bitsnap-returns-slot":"quantityButton",className:_chunkDY2S42Q6js.d.call(void 0, L,ne.className),style:ne.style,onClick:()=>Re(R,F-1),children:_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"-"})}),_jsxruntime.jsx.call(void 0, "input",{id:be,type:"number",inputMode:"numeric",min:0,max:R.availableQuantity,step:1,value:F,"aria-label":a("quantityLabel",{name:R.name}),"data-bitsnap-returns-slot":"quantityInput",className:_chunkDY2S42Q6js.d.call(void 0, "h-8 w-16 rounded-md border px-2 text-center text-sm outline-none focus-visible:ring-[3px]",G,Me.className),style:Me.style,onChange:Bt=>Re(R,Bt.target.valueAsNumber)}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"secondary",size:"icon-sm","aria-label":a("quantityIncrease",{name:R.name}),"aria-controls":be,disabled:F>=R.availableQuantity,"data-bitsnap-returns-slot":"quantityButton",className:_chunkDY2S42Q6js.d.call(void 0, L,ne.className),style:ne.style,onClick:()=>Re(R,F+1),children:_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":"true",children:"+"})}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:a("quantityOfAvailable",{available:R.availableQuantity})})]}):_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"lineIneligibleReason",className:_chunkDY2S42Q6js.d.call(void 0, "text-sm",qe.className),style:qe.style,children:R.exclusionReason!==""?R.exclusionReason:a("lineIneligibleFallback")})]},R.lineId)})}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, te,{htmlFor:"bitsnap-returns-note",children:a("noteLabel")}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.v,{id:"bitsnap-returns-note",name:"note",rows:3,maxLength:1e3,value:I,placeholder:a("notePlaceholder"),"data-bitsnap-returns-slot":"noteInput",className:_chunkDY2S42Q6js.d.call(void 0, G,"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)]",Ke.className),style:Ke.style,onChange:R=>N(R.target.value)})]}),B&&_jsxruntime.jsx.call(void 0, A,{errorKey:"selectionEmpty"}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"submit","data-bitsnap-returns-slot":"submitButton",className:_chunkDY2S42Q6js.d.call(void 0, H,_e.className),style:_e.style,children:a("selectionContinue")}),p.length>0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:a("previousReturnsTitle")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"history",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-2",je.className),style:je.style,children:p.map(R=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"historyEntry",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-wrap items-center justify-between gap-2 text-sm",Ue.className),style:Ue.style,children:[_jsxruntime.jsx.call(void 0, "span",{children:R.reference}),_jsxruntime.jsx.call(void 0, "span",{children:Z(R.createdAt,y)}),_jsxruntime.jsx.call(void 0, J,{status:R.status})]},R.id))})]})]})})}function ps({orderId:e,items:r,note:t,onSubmitted:n,onBack:o,className:u}){T("ReturnsConfirmation");let s=h(),a=Y(),{order:y,isLoading:m,errorKey:p,refetch:f}=Be(e),c=kt(),b=l("summary"),g=l("line"),C=l("lineName"),I=l("linePrice"),N=l("submitButton");async function B(w){if(w.preventDefault(),c.isPending)return;let P=await c.submit({orderId:e,items:r.map(k=>({lineId:k.lineId,quantity:k.quantity})),note:t});P!=null&&_optionalChain([n, 'optionalCall', _44 => _44(P.id,P)])}return _jsxruntime.jsx.call(void 0, M,{className:u,onBack:o,title:s("confirmationTitle"),description:s("confirmationDescription"),children:m?_jsxruntime.jsx.call(void 0, U,{rows:2}):p!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:p,onRetry:f}):_jsxruntime.jsxs.call(void 0, "form",{className:"flex flex-col gap-5",onSubmit:B,children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"summary",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-3 border p-4",b.className),style:b.style,children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:s("confirmationSummary")}),_jsxruntime.jsx.call(void 0, "ul",{className:"flex flex-col gap-3",children:r.map(w=>{let P=_optionalChain([y, 'optionalAccess', _45 => _45.lines, 'access', _46 => _46.find, 'call', _47 => _47(k=>k.lineId===w.lineId)]);return _jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-wrap items-baseline justify-between gap-2",g.className),style:g.style,children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunkDY2S42Q6js.d.call(void 0, "font-medium",C.className),style:C.style,children:_nullishCoalesce(_optionalChain([P, 'optionalAccess', _48 => _48.name]), () => (w.lineId))}),_jsxruntime.jsxs.call(void 0, "span",{"data-bitsnap-returns-slot":"linePrice",className:_chunkDY2S42Q6js.d.call(void 0, "text-sm",I.className),style:I.style,children:[s("confirmationQuantity",{quantity:w.quantity}),P!=null&&` \xB7 ${ee(P.paidUnitMinor*BigInt(w.quantity),P.currency,a)}`]})]},w.lineId)})}),t!=null&&t!==""&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1 text-sm",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:s("confirmationNote")}),_jsxruntime.jsx.call(void 0, "span",{className:"whitespace-pre-wrap",children:t})]})]}),c.errorKey!=null&&_jsxruntime.jsx.call(void 0, A,{errorKey:c.errorKey}),_jsxruntime.jsxs.call(void 0, _chunkFGB5FJCIjs.q,{type:"submit",disabled:c.isPending||r.length===0,"data-bitsnap-returns-slot":"submitButton",className:_chunkDY2S42Q6js.d.call(void 0, H,N.className),style:N.style,children:[c.isPending&&_jsxruntime.jsx.call(void 0, re,{}),s("confirmationSubmit")]})]})})}function ms({returnId:e,onContinue:r,onOpenMyReturns:t,className:n}){T("ReturnsResult");let o=h(),{request:u,isLoading:s,errorKey:a,refetch:y}=me(e),m=l("successState"),p=l("returnReference"),f=l("returnInstructions"),c=l("submitButton"),b=l("secondaryButton");return _jsxruntime.jsxs.call(void 0, "section",{className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-5",n),children:[_jsxruntime.jsxs.call(void 0, "div",{role:"status","data-bitsnap-returns-slot":"successState",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-4 border p-5",m.className),style:m.style,children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-2xl font-semibold",children:o("successTitle")}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:o("successDescription")}),s?_jsxruntime.jsx.call(void 0, U,{rows:2}):a!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:a,onRetry:y}):u!=null&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:o("successReference")}),_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"returnReference",className:_chunkDY2S42Q6js.d.call(void 0, "text-lg font-semibold",p.className),style:p.style,children:u.reference})]}),u.returnInstructions!==""&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium",children:o("successInstructions")}),_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"returnInstructions",className:_chunkDY2S42Q6js.d.call(void 0, "whitespace-pre-wrap border p-3 text-sm",f.className),style:f.style,children:u.returnInstructions})]})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap gap-3",children:[_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button","data-bitsnap-returns-slot":"submitButton",className:_chunkDY2S42Q6js.d.call(void 0, H,c.className),style:c.style,onClick:r,children:o("successDone")}),t!=null&&_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"secondary","data-bitsnap-returns-slot":"secondaryButton",className:_chunkDY2S42Q6js.d.call(void 0, L,b.className),style:b.style,onClick:t,children:o("myReturnsLink")})]})]})}function Ts({onSelectReturn:e,onBack:r,pageSize:t,className:n}){T("ReturnsMyReturnsList");let o=h(),u=Y(),s=ze(),a=Tt({pageSize:t}),y=l("returnList"),m=l("returnCard"),p=l("returnReference"),f=l("secondaryButton");return _jsxruntime.jsx.call(void 0, M,{className:n,onBack:r,title:o("myReturnsTitle"),description:o("myReturnsDescription"),children:a.isLoading?_jsxruntime.jsx.call(void 0, U,{}):a.errorKey!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:a.errorKey,onRetry:a.refetch}):a.returns.length===0?_jsxruntime.jsx.call(void 0, fe,{children:o("myReturnsEmpty")}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"returnList",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-3",y.className),style:y.style,children:a.returns.map(c=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"returnCard",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-wrap items-center justify-between gap-3 border p-4",m.className),style:m.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-1",children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"returnReference",className:_chunkDY2S42Q6js.d.call(void 0, "font-medium",p.className),style:p.style,children:c.reference}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:Z(c.createdAt,u)}),_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm",children:[o("myReturnRefund"),": ",s(c.refundStatus)]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-3",children:[_jsxruntime.jsx.call(void 0, J,{status:c.status}),_jsxruntime.jsx.call(void 0, _chunkFGB5FJCIjs.q,{type:"button",variant:"secondary",size:"sm","aria-label":`${o("myReturnOpen")}: ${c.reference}`,"data-bitsnap-returns-slot":"secondaryButton",className:_chunkDY2S42Q6js.d.call(void 0, L,f.className),style:f.style,onClick:()=>_optionalChain([e, 'optionalCall', _49 => _49(c.id)]),children:o("myReturnOpen")})]})]},c.id))}),_jsxruntime.jsx.call(void 0, ge,{page:a.page,total:a.total,hasNext:a.hasNext,hasPrevious:a.hasPrevious,isFetching:a.isFetching,onNext:a.next,onPrevious:a.previous})]})})}function ws({returnId:e,onBack:r,className:t}){T("ReturnsMyReturnDetail");let n=h(),o=Y(),u=ze(),{request:s,isLoading:a,errorKey:y,refetch:m}=me(e),p=l("summary"),f=l("lineList"),c=l("line"),b=l("lineName"),g=l("returnInstructions"),C=l("history"),I=l("historyEntry");return _jsxruntime.jsx.call(void 0, M,{className:t,onBack:r,title:s!=null?n("myReturnTitle",{reference:s.reference}):n("myReturnDetailTitle"),children:a?_jsxruntime.jsx.call(void 0, U,{}):y!=null?_jsxruntime.jsx.call(void 0, A,{errorKey:y,onRetry:m}):s!=null&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-5",children:[_jsxruntime.jsxs.call(void 0, "div",{"data-bitsnap-returns-slot":"summary",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-2 border p-4 text-sm",p.className),style:p.style,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-2",children:[_jsxruntime.jsx.call(void 0, J,{status:s.status}),_jsxruntime.jsxs.call(void 0, "span",{children:[n("myReturnCreatedAt"),":"," ",Z(s.createdAt,o)]})]}),_jsxruntime.jsxs.call(void 0, "span",{children:[n("myReturnRefund"),": ",u(s.refundStatus),s.refundAmountMinor>BigInt(0)&&` \xB7 ${ee(s.refundAmountMinor,s.currency,o)}`]}),s.customerNote!==""&&_jsxruntime.jsxs.call(void 0, "span",{className:"whitespace-pre-wrap",children:[n("myReturnNote"),": ",s.customerNote]})]}),s.returnInstructions!==""&&_jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"returnInstructions",className:_chunkDY2S42Q6js.d.call(void 0, "whitespace-pre-wrap border p-3 text-sm",g.className),style:g.style,children:s.returnInstructions}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:n("myReturnLines")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"lineList",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-3",f.className),style:f.style,children:s.lines.map(N=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"line",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-wrap items-baseline justify-between gap-2 border p-4",c.className),style:c.style,children:[_jsxruntime.jsx.call(void 0, "span",{"data-bitsnap-returns-slot":"lineName",className:_chunkDY2S42Q6js.d.call(void 0, "font-medium",b.className),style:b.style,children:N.name}),_jsxruntime.jsx.call(void 0, "span",{className:"text-sm",children:n("myReturnLineQuantities",{requested:N.requestedQuantity,approved:N.approvedQuantity,received:N.receivedQuantity})})]},N.lineId))})]}),s.history.length>0&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-sm font-medium",children:n("myReturnHistory")}),_jsxruntime.jsx.call(void 0, "ul",{"data-bitsnap-returns-slot":"history",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-col gap-2",C.className),style:C.style,children:s.history.map(N=>_jsxruntime.jsxs.call(void 0, "li",{"data-bitsnap-returns-slot":"historyEntry",className:_chunkDY2S42Q6js.d.call(void 0, "flex flex-wrap items-center justify-between gap-2 text-sm",I.className),style:I.style,children:[_jsxruntime.jsx.call(void 0, J,{status:N.status}),_jsxruntime.jsx.call(void 0, "span",{children:Z(N.createdAt,o)})]},N.id))})]})]})})}exports.a = te; exports.b = re; exports.c = vr; exports.d = nt; exports.e = Ne; exports.f = l; exports.g = Pe; exports.h = St; exports.i = h; exports.j = T; exports.k = ir; exports.l = Xr; exports.m = de; exports.n = ht; exports.o = Be; exports.p = kt; exports.q = Tt; exports.r = me; exports.s = U; exports.t = Kn; exports.u = _n; exports.v = cs; exports.w = ds; exports.x = ps; exports.y = ms; exports.z = Ts; exports.A = ws;
|
|
2
|
+
//# sourceMappingURL=chunk-H4WAQQVO.js.map
|