bitsnap-react 1.11.1 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +37 -7
  2. package/dist/CartProvider-WPJWECBS.mjs +2 -0
  3. package/dist/CartProvider-YPZ3HD7W.js +2 -0
  4. package/dist/CartProvider-YPZ3HD7W.js.map +1 -0
  5. package/dist/analytics.js +1 -1
  6. package/dist/analytics.js.map +1 -1
  7. package/dist/analytics.mjs +1 -1
  8. package/dist/catalog.js +1 -1
  9. package/dist/catalog.js.map +1 -1
  10. package/dist/catalog.mjs +1 -1
  11. package/dist/chunk-3ITTSNWG.js +2 -0
  12. package/dist/chunk-3ITTSNWG.js.map +1 -0
  13. package/dist/chunk-4BV5IUZH.js +2 -0
  14. package/dist/chunk-4BV5IUZH.js.map +1 -0
  15. package/dist/{chunk-UFIOJGJZ.js → chunk-4ZFIL5S7.js} +2 -2
  16. package/dist/chunk-4ZFIL5S7.js.map +1 -0
  17. package/dist/{chunk-JUDR4EZA.mjs → chunk-DRAKVCD7.mjs} +2 -2
  18. package/dist/{chunk-HWQNT6XU.mjs → chunk-G3VVAVG7.mjs} +2 -2
  19. package/dist/chunk-GJNFDUJN.mjs +4 -0
  20. package/dist/chunk-GJNFDUJN.mjs.map +1 -0
  21. package/dist/{chunk-ETGHIHWR.mjs → chunk-HBPSSGYN.mjs} +2 -2
  22. package/dist/{chunk-WGJTXDIS.js → chunk-HDLCLZOK.js} +2 -2
  23. package/dist/chunk-HDLCLZOK.js.map +1 -0
  24. package/dist/{chunk-3IVLQILF.js → chunk-I6BRDRPB.js} +2 -2
  25. package/dist/chunk-I6BRDRPB.js.map +1 -0
  26. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  27. package/dist/chunk-KOYBZORL.js.map +1 -1
  28. package/dist/{chunk-VPBFEAFQ.js → chunk-MZSLLGFS.js} +2 -2
  29. package/dist/chunk-MZSLLGFS.js.map +1 -0
  30. package/dist/{chunk-UCL4Y7L3.js → chunk-STVEBT6M.js} +2 -2
  31. package/dist/chunk-STVEBT6M.js.map +1 -0
  32. package/dist/{chunk-IJLHU2MA.mjs → chunk-T2YSOHJM.mjs} +2 -2
  33. package/dist/{chunk-IJLHU2MA.mjs.map → chunk-T2YSOHJM.mjs.map} +1 -1
  34. package/dist/chunk-T3PAOMHI.mjs +2 -0
  35. package/dist/chunk-T3PAOMHI.mjs.map +1 -0
  36. package/dist/chunk-VDLJW4JJ.mjs +2 -0
  37. package/dist/chunk-VDLJW4JJ.mjs.map +1 -0
  38. package/dist/{chunk-DWRBPP32.mjs → chunk-VF62KDNS.mjs} +2 -2
  39. package/dist/chunk-VRL3IF5J.js +4 -0
  40. package/dist/chunk-VRL3IF5J.js.map +1 -0
  41. package/dist/chunk-XIHGWNTS.js.map +1 -1
  42. package/dist/consent.js.map +1 -1
  43. package/dist/course.js +1 -1
  44. package/dist/course.js.map +1 -1
  45. package/dist/course.mjs +1 -1
  46. package/dist/embed/analytics.js +1 -1
  47. package/dist/errors.js.map +1 -1
  48. package/dist/index.css +1 -1
  49. package/dist/index.css.map +1 -1
  50. package/dist/index.d.mts +97 -2
  51. package/dist/index.d.ts +97 -2
  52. package/dist/index.js +1 -1
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +1 -1
  55. package/dist/index.mjs.map +1 -1
  56. package/dist/internal.js.map +1 -1
  57. package/dist/methods-FVDH6Y57.mjs +2 -0
  58. package/dist/methods-ISVX5JQ7.js +2 -0
  59. package/dist/methods-ISVX5JQ7.js.map +1 -0
  60. package/dist/models.js.map +1 -1
  61. package/dist/returns.js +1 -1
  62. package/dist/returns.js.map +1 -1
  63. package/dist/returns.mjs +1 -1
  64. package/package.json +2 -2
  65. package/dist/CartProvider-QY2DMNCC.js +0 -2
  66. package/dist/CartProvider-QY2DMNCC.js.map +0 -1
  67. package/dist/CartProvider-XMHPQRWC.mjs +0 -2
  68. package/dist/chunk-2PK36NGB.mjs +0 -4
  69. package/dist/chunk-2PK36NGB.mjs.map +0 -1
  70. package/dist/chunk-2X32DDUM.mjs +0 -2
  71. package/dist/chunk-2X32DDUM.mjs.map +0 -1
  72. package/dist/chunk-3IVLQILF.js.map +0 -1
  73. package/dist/chunk-FBTYZHXM.js +0 -4
  74. package/dist/chunk-FBTYZHXM.js.map +0 -1
  75. package/dist/chunk-G2UOTVS5.mjs +0 -2
  76. package/dist/chunk-G2UOTVS5.mjs.map +0 -1
  77. package/dist/chunk-Q25D7OAO.js +0 -2
  78. package/dist/chunk-Q25D7OAO.js.map +0 -1
  79. package/dist/chunk-UCL4Y7L3.js.map +0 -1
  80. package/dist/chunk-UFIOJGJZ.js.map +0 -1
  81. package/dist/chunk-VPBFEAFQ.js.map +0 -1
  82. package/dist/chunk-WGJTXDIS.js.map +0 -1
  83. package/dist/chunk-YBGAYEJQ.js +0 -2
  84. package/dist/chunk-YBGAYEJQ.js.map +0 -1
  85. package/dist/methods-ALO22YWQ.mjs +0 -2
  86. package/dist/methods-ZBX4BTDE.js +0 -2
  87. package/dist/methods-ZBX4BTDE.js.map +0 -1
  88. /package/dist/{CartProvider-XMHPQRWC.mjs.map → CartProvider-WPJWECBS.mjs.map} +0 -0
  89. /package/dist/{chunk-JUDR4EZA.mjs.map → chunk-DRAKVCD7.mjs.map} +0 -0
  90. /package/dist/{chunk-HWQNT6XU.mjs.map → chunk-G3VVAVG7.mjs.map} +0 -0
  91. /package/dist/{chunk-ETGHIHWR.mjs.map → chunk-HBPSSGYN.mjs.map} +0 -0
  92. /package/dist/{chunk-DWRBPP32.mjs.map → chunk-VF62KDNS.mjs.map} +0 -0
  93. /package/dist/{methods-ALO22YWQ.mjs.map → methods-FVDH6Y57.mjs.map} +0 -0
@@ -1,2 +0,0 @@
1
- import{a as ct,b as dt}from"./chunk-KOVKUJAW.mjs";import{c as Y,d as F,e as st,f as U,g as it,i as ut,k as D}from"./chunk-G2UOTVS5.mjs";import{f as tt,k as et,l as rt,m as ot,n as nt,p as at}from"./chunk-IJLHU2MA.mjs";var It=["root","grid","card","cardLink","image","imagePlaceholder","body","name","description","price","comparePrice","badge","actions","addToCartButton","selectButton","message","pagination","paginationButton","pageIndicator","emptyState","error","retryButton","skeleton"],wt={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"},Et={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"}},_t=[];function lt(t){let e=ct(t,{defaultTheme:"light",presets:Et,variables:wt,shadcnVariables:_t});return{theme:e.theme,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle}}function q(t,e){return dt(t.elements,e)}function pt(t,e){try{return new Intl.NumberFormat(t,{style:"currency",currency:e,currencyDisplay:"symbol"})}catch{return}}function H(t,e,r=D){let o=t/100,n=pt(r,e)??pt(D,e);return n!=null?n.format(o):`${o.toFixed(2)} ${e}`}import{useCallback as gt,useEffect as Bt,useMemo as jt,useState as z}from"react";var Dt=24,Ot=48,M=class extends Error{status;constructor(e,r){super(e),this.name="ProductListError",this.status=r}};function O(t){return t==null||!Number.isFinite(t)?Dt:Math.min(Ot,Math.max(1,Math.floor(t)))}function mt(t,e){return Math.max(1,Math.ceil(t/e))}function N(t){return t.replace(/\/+$/,"")}function Nt(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=t.search?.trim();return r&&e.set("search",r),`${N(t.host)}/api/integrations/${encodeURIComponent(t.projectID)}/public-commerce/product-list?${e.toString()}`}function Rt(t){return typeof t=="object"&&t!=null&&Array.isArray(t.items)&&typeof t.totalCount=="number"}async function ft(t,e){let r=await fetch(Y(Nt(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(!Rt(o))throw new M("Unexpected product list response");return o}function G(t){let{projectID:e,locale:r,search:o,initialData:n}=t,[a]=z(()=>U),i=t.host??a,d=O(t.pageSize),c=JSON.stringify([e,i,r??null,o?.trim()??null,d]),[m,u]=z({queryKey:c,page:1});m.queryKey!==c&&u({queryKey:c,page:1});let[b,v]=z(0),[f,l]=z(()=>({requestKey:n!=null?`${c}|1|0`:"",data:n,error:void 0})),g=f.data?.totalCount??0,P=mt(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;Bt(()=>{if(T)return;let y=new AbortController;return ft({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(w=>({requestKey:C,data:w.data,error:x instanceof Error?x:new Error(String(x))}))}),()=>y.abort()},[C,T]);let I=gt(y=>{let x=Math.max(1,Math.floor(y));u({queryKey:c,page:g>0?Math.min(x,P):x})},[c,g,P]),A=gt(()=>v(y=>y+1),[]);return jt(()=>({products:f.data?.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])}import{createContext as ht,useCallback as V,useContext as xt,useEffect as R,useMemo as B,useRef as K,useState as Mt}from"react";function Pt(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 bt(t,e){let[{Bitsnap:r},{getProjectID:o,setProjectID:n}]=await Promise.all([import("./methods-ALO22YWQ.mjs"),import("./CartProvider-XMHPQRWC.mjs")]),a=Pt({projectID:o(),host:U,defaultHost:st},e);if(!a.ok)return Ft(a.reason);if(a.setProjectID!=null&&n(a.setProjectID),a.setHost!=null&&it(a.setHost),await r.addProductToCart(t.cartItemId??t.id,1,void 0,{name:t.name,price:t.price,currency:t.currency,analytics:et})!=null)throw new Error("Could not add the product to the cart");e.analytics!=null&&Q(e.analytics,t),e.showCart&&r.showCart()}function Ft(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,Ut=1e3;function yt(t,e=Ut){let r=new Set,o=new Map,n=[],a=[],i,d,c=!1;function m(){for(d!==void 0&&clearTimeout(d),d=void 0;n.length>0;){let l=n.slice(0,$),g=a.slice(0,$);n=n.slice($),a=a.slice($);try{t({productIds:l,positions:g})}catch{}}}function u(){m();try{tt()?.flush()}catch{}}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),i?.unobserve(g.target),!r.has(P.id)&&(r.add(P.id),n.push(P.id),a.push(P.position)))}n.length>0&&d===void 0&&(d=setTimeout(m,e),d.unref?.())},{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{return()=>{}}},flush:m,destroy(){try{m(),i?.disconnect(),c&&(window.removeEventListener("pagehide",u,!0),document.removeEventListener("visibilitychange",b,!0),c=!1)}catch{}i=void 0,o.clear()}}}var Ht={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 Lt(t,e){return ut(Ht,t,e)}function X(t,e){return t.replace(/\{(\w+)\}/g,(r,o)=>o in e?String(e[o]):r)}import{Fragment as At,jsx as s,jsxs as S}from"react/jsx-runtime";var Tt=ht(void 0),zt={observe:()=>()=>{},clicked:()=>{}},vt=ht(zt);function j(){let t=xt(Tt);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:F(e,o?.className),style:o?.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",Ct=`${Z} w-full`,$t=`${Ct} no-underline`;function Kt({product:t,onAdd:e}){let{texts:r}=j(),[o,n]=Mt("idle"),a=p("addToCartButton",Ct),i=p("message","mt-2 text-xs");R(()=>{if(o!=="added")return;let m=setTimeout(()=>n("idle"),2e3);return()=>clearTimeout(m)},[o]);let d=V(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 S(At,{children:[s("button",{type:"button",...a,disabled:o==="adding","aria-label":`${c}: ${t.name}`,onClick:d,children:c}),o==="error"?s("p",{...i,role:"alert",children:r.addToCartError}):null]})}function Vt({product:t,position:e,href:r,onAdd:o,renderItem:n}){let{texts:a,locale:i}=j(),d=xt(vt),c=K(null);R(()=>{if(c.current!=null)return d.observe(c.current,t.id,e)},[d,t.id,e]);let m=V(()=>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",$t),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 s("li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:n(t,{href:r,price:A,compareAtPrice:y,texts:a,locale:i,addToCart:o,trackClick:m})});let x=t.image?.thumbnailUrl??t.image?.url,w=t.available?t.isRecurring?a.subscription:null:a.unavailable;return S("li",{ref:c,...u,"data-unavailable":t.available?void 0:"",children:[S("a",{...b,href:r,onClick:m,children:[x!=null?s("div",{...v,children:s("img",{src:x,alt:"",loading:"lazy",decoding:"async",className:"h-full w-full object-cover"})}):s("div",{...f,"aria-hidden":"true"}),S("div",{...l,children:[s("h3",{...g,children:t.name}),t.shortDescription?s("p",{...P,children:t.shortDescription}):null,S("p",{...h,children:[t.priceFrom?X(a.priceFrom,{price:A}):A,y!=null?S(At,{children:[S("span",{className:"sr-only",children:[a.originalPrice,": "]}),s("del",{...k,children:y})]}):null]})]})]}),w!=null?s("span",{...C,"data-kind":t.available?"subscription":"unavailable",children:w}):null,s("div",{...T,children:t.available?t.addToCart?s(Kt,{product:t,onAdd:o}):s("a",{...I,href:r,onClick:m,children:t.variantCount>1?a.chooseOptions:a.viewProduct}):s("button",{type:"button",...I,disabled:!0,children:a.unavailable})})]})}var St="m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0";function qt({count:t,label:e}){let r=p("grid",St),o=p("skeleton","aspect-[3/4] animate-pulse");return s("div",{...r,role:"status","aria-busy":"true","aria-label":e,children:Array.from({length:t},(n,a)=>s("div",{...o,"aria-hidden":"true"},a))})}function Gt({page:t,pageCount:e,isLoading:r,onPage:o}){let{texts:n}=j(),a=p("pagination","mt-8 flex items-center justify-center gap-4"),i=p("paginationButton",Z),d=p("pageIndicator","text-sm");return S("nav",{...a,"aria-label":n.pagination,children:[s("button",{type:"button",...i,"aria-disabled":r||t<=1,onClick:()=>{!r&&t>1&&o(t-1)},children:n.previousPage}),s("span",{...d,"aria-live":"polite",children:X(n.pageOf,{page:t,pageCount:e})}),s("button",{type:"button",...i,"aria-disabled":r||t>=e,onClick:()=>{!r&&t<e&&o(t+1)},children:n.nextPage})]})}function Qt({options:t,productHref:e,renderItem:r,onAddToCart:o,showCartOnAdd:n}){let{texts:a}=j(),{products:i,page:d,pageCount:c,setPage:m,isLoading:u,error:b,refetch:v}=G(t),f=ot(),l=t.search?.trim()?"search":"catalog",g=O(t.pageSize),P=K(!1);R(()=>{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=B(()=>yt(({productIds:L,positions:_})=>f.track("product_impression",{list_id:l,product_ids:L,positions:_})),[f,l]);R(()=>()=>h.destroy(),[h]);let k=B(()=>({observe:h.observe,clicked:(L,_)=>f.track("product_clicked",{list_id:l,position:_},{product_id:L.id})}),[h,f,l]),C=K(null),T=K(!1),I=V(L=>{T.current=!0,m(L)},[m]);R(()=>{u||!T.current||(T.current=!1,C.current?.focus({preventScroll:!0}),C.current?.scrollIntoView({block:"start"}))},[u]);let A=p("grid",St),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"),w=p("retryButton",Z),{projectID:J,host:W}=t,kt=V(L=>async()=>{if(o!=null){await at(()=>o(L)),Q(f,L);return}await bt(L,{projectID:J,host:W,showCart:n,analytics:f})},[o,J,W,n,f]),E;return u&&i.length===0?E=s(qt,{count:Math.min(O(t.pageSize),8),label:a.loading}):b!=null?E=S("div",{...x,role:"alert",children:[s("p",{children:a.error}),s("button",{type:"button",...w,onClick:v,children:a.retry})]}):i.length===0?E=s("p",{...y,children:a.empty}):E=s("ul",{...A,"aria-busy":u||void 0,className:F(A.className,u&&"opacity-60"),children:i.map((L,_)=>s(Vt,{product:L,position:(d-1)*g+_,href:e(L),onAdd:kt(L),renderItem:r},L.id))}),s(vt.Provider,{value:k,children:S("div",{ref:C,tabIndex:-1,className:"p-1 outline-none scroll-mt-4",children:[E,c>1&&b==null?s(Gt,{page:d,pageCount:c,isLoading:u,onPage:I}):null]})})}var Xt=t=>`/p/${encodeURIComponent(t.uniqueSlug)}`;function Zt({productHref:t=Xt,appearance:e,texts:r,renderItem:o,onAddToCart:n,showCartOnAdd:a=!0,className:i,analytics:d,...c}){let m=nt(c.projectID,d,"catalog"),u=c.locale??D,b=B(()=>lt(e),[e]),v=B(()=>Lt(u,r),[u,r]),f=B(()=>({appearance:b,texts:v,locale:u}),[b,v,u]),l=q(b,"root");return s(rt,{value:m,children:s(Tt.Provider,{value:f,children:s("div",{"data-bitsnap-products":"root","data-bitsnap-products-slot":"root",className:F("bitsnap-react",b.boundaryClassName,i,l?.className),style:{...b.boundaryStyle,...l?.style},children:s(Qt,{options:c,productHref:t,renderItem:o,onAddToCart:n,showCartOnAdd:a})})})})}export{It as a,H as b,G as c,Zt as d};
2
- //# sourceMappingURL=chunk-2X32DDUM.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/products/appearance.ts","../src/components/products/format.ts","../src/components/products/useProducts.ts","../src/components/products/fetch.ts","../src/components/products/ProductList.tsx","../src/components/products/cart-target.ts","../src/components/products/add-to-cart.ts","../src/components/products/impressions.ts","../src/components/products/texts.ts"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport {\n getSlotAppearance,\n resolveAppearanceCore,\n type AppearanceElements,\n type ShadcnVariableMapping,\n type SlotAppearance,\n} from \"@/src/lib/appearance-core\";\n\n/**\n * Product list appearance API.\n *\n * It mirrors `CheckoutAppearance` and `ReturnsAppearance` (theme, tokens,\n * elements) so a shop can reuse one brand object for all of them. The resolver\n * is pure: it turns the caller input into a theme name, the tokens in effect,\n * the slot overrides and the inline style for the theme boundary.\n */\n\nexport type ProductListTheme = \"light\" | \"dark\";\n\nexport type ProductListAppearanceTokens = {\n /** Font family of the list. The library never loads fonts. */\n fontFamily?: string;\n /** 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","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { HOST } from \"../checkout/constants\";\nimport {\n clampPageSize,\n fetchProductList,\n pageCountFor,\n type ProductListData,\n type PublicListProduct,\n} from \"./fetch\";\n\nexport type UseProductsOptions = {\n /** Project (shop) ID. */\n projectID: string;\n /**\n * Origin of the Bitsnap backend. Defaults to the library host\n * (`https://bitsnap.pl`, or what `setCustomHost` had set when the component\n * first rendered; later `setCustomHost` calls do not move an existing list).\n * On a custom domain pass the domain itself, or an empty string for\n * same-origin requests.\n */\n host?: string;\n locale?: string;\n /** Products per page, 1 to 48. Defaults to 24. */\n pageSize?: number;\n search?: string;\n /**\n * First page, loaded on the server. It is always used for the first request\n * of the mounted list (the first fetch is skipped and the products are\n * available on the first render), so it has to be the page the props ask\n * for: page 1 with the same `pageSize`, `locale` and `search`. Later changes\n * of the props fetch again.\n */\n initialData?: ProductListData;\n};\n\nexport type UseProductsResult = {\n /** Products of the current page. Keeps the previous page while loading. */\n products: PublicListProduct[];\n totalCount: number;\n /** Current page, starting at 1. */\n page: number;\n pageCount: number;\n setPage: (page: number) => void;\n /** `true` until the current page is available, also during server rendering. */\n isLoading: boolean;\n error: Error | undefined;\n /** Loads the current page again. */\n refetch: () => void;\n};\n\ntype Snapshot = {\n /** Request the data belongs to; empty when it is not tied to one. */\n requestKey: string;\n data: ProductListData | undefined;\n error: Error | undefined;\n};\n\n/**\n * Loads the product catalog page by page. It uses a plain `fetch` without\n * credentials, never reads global state (`setProjectID`, `setCustomHost`) other\n * than the default host, and does nothing during server rendering - pass\n * `initialData` to render products in the server HTML.\n */\nexport function useProducts(options: UseProductsOptions): UseProductsResult {\n const { projectID, locale, search, initialData } = options;\n // The library host is a mutable global; read it once so a later\n // `setCustomHost` does not change the query of a mounted list.\n const [defaultHost] = useState(() => HOST);\n const host = options.host ?? defaultHost;\n const pageSize = clampPageSize(options.pageSize);\n\n // Everything that identifies a list; a change resets the page.\n const queryKey = JSON.stringify([\n projectID,\n host,\n locale ?? null,\n search?.trim() ?? null,\n pageSize,\n ]);\n\n const [pageState, setPageState] = useState({ queryKey, page: 1 });\n if (pageState.queryKey !== queryKey) {\n // Another list: start from page 1 (adjusting state while rendering).\n setPageState({ queryKey, page: 1 });\n }\n const [reloads, setReloads] = useState(0);\n const [snapshot, setSnapshot] = useState<Snapshot>(() => ({\n requestKey: initialData != null ? `${queryKey}|1|0` : \"\",\n data: initialData,\n error: undefined,\n }));\n\n // A page past the end (the catalog shrank) falls back to the last page once\n // the total is known.\n const totalCount = snapshot.data?.totalCount ?? 0;\n const pageCount = pageCountFor(totalCount, pageSize);\n const requestedPage = pageState.queryKey === queryKey ? pageState.page : 1;\n const page = totalCount > 0 ? Math.min(requestedPage, pageCount) : requestedPage;\n\n const requestKey = `${queryKey}|${page}|${reloads}`;\n\n const isCurrent = snapshot.requestKey === requestKey;\n\n useEffect(() => {\n if (isCurrent) {\n return;\n }\n\n const controller = new AbortController();\n fetchProductList(\n {\n projectID,\n host,\n locale,\n search,\n limit: pageSize,\n offset: (page - 1) * pageSize,\n },\n controller.signal,\n ).then(\n (data) => {\n if (controller.signal.aborted) {\n return;\n }\n setSnapshot({ requestKey, data, error: undefined });\n },\n (error: unknown) => {\n if (controller.signal.aborted) {\n return;\n }\n setSnapshot((previous) => ({\n requestKey,\n data: previous.data,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n },\n );\n\n return () => controller.abort();\n // `requestKey` carries projectID, host, locale, search, pageSize, page and\n // the reload counter.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [requestKey, isCurrent]);\n\n const setPage = useCallback(\n (next: number) => {\n const target = Math.max(1, Math.floor(next));\n setPageState({\n queryKey,\n page: totalCount > 0 ? Math.min(target, pageCount) : target,\n });\n },\n [queryKey, totalCount, pageCount],\n );\n\n const refetch = useCallback(() => setReloads((value) => value + 1), []);\n\n return useMemo(\n () => ({\n products: snapshot.data?.items ?? [],\n totalCount,\n page,\n pageCount,\n setPage,\n isLoading: !isCurrent,\n error: isCurrent ? snapshot.error : undefined,\n refetch,\n }),\n [snapshot, totalCount, page, pageCount, setPage, isCurrent, refetch],\n );\n}\n","import { withClientParam } from \"@/src/lib/client-header\";\nimport type { BitsnapModels } from \"@/src/models\";\n\nexport type PublicListProduct = BitsnapModels.PublicListProduct;\nexport type ProductListData = BitsnapModels.ProductListResponse;\n\nexport const DEFAULT_PAGE_SIZE = 24;\nexport const MAX_PAGE_SIZE = 48;\n\nexport type ProductListQuery = {\n projectID: string;\n /** Origin of the Bitsnap backend (or of a custom domain), without a path. */\n host: string;\n locale?: string;\n search?: string;\n limit: number;\n offset: number;\n};\n\nexport class ProductListError extends Error {\n readonly status: number | undefined;\n\n constructor(message: string, status?: number) {\n super(message);\n this.name = \"ProductListError\";\n this.status = status;\n }\n}\n\n/** Page size within what the backend accepts (1 to 48, default 24). */\nexport function clampPageSize(pageSize?: number): number {\n if (pageSize == null || !Number.isFinite(pageSize)) {\n return DEFAULT_PAGE_SIZE;\n }\n return Math.min(MAX_PAGE_SIZE, Math.max(1, Math.floor(pageSize)));\n}\n\nexport function pageCountFor(totalCount: number, pageSize: number): number {\n return Math.max(1, Math.ceil(totalCount / pageSize));\n}\n\n/** Origin without trailing slashes, so equal hosts compare equal as strings. */\nexport function normalizeHost(host: string): string {\n return host.replace(/\\/+$/, \"\");\n}\n\nexport function buildProductListURL(query: ProductListQuery): string {\n const params = new URLSearchParams();\n params.set(\"limit\", String(query.limit));\n params.set(\"offset\", String(query.offset));\n if (query.locale) {\n params.set(\"locale\", query.locale);\n }\n const search = query.search?.trim();\n if (search) {\n params.set(\"search\", search);\n }\n\n const host = normalizeHost(query.host);\n return `${host}/api/integrations/${encodeURIComponent(\n query.projectID,\n )}/public-commerce/product-list?${params.toString()}`;\n}\n\nfunction isProductListData(value: unknown): value is ProductListData {\n return (\n typeof value === \"object\" &&\n value != null &&\n Array.isArray((value as ProductListData).items) &&\n typeof (value as ProductListData).totalCount === \"number\"\n );\n}\n\n/**\n * Loads one page of the catalog with a plain, credential-less `fetch`. It does\n * not touch the global project ID or host.\n */\nexport async function fetchProductList(\n query: ProductListQuery,\n signal?: AbortSignal,\n): Promise<ProductListData> {\n const response = await fetch(withClientParam(buildProductListURL(query)), {\n method: \"GET\",\n credentials: \"omit\",\n headers: { Accept: \"application/json\" },\n signal,\n });\n\n if (!response.ok) {\n throw new ProductListError(\n `Could not load products (${response.status})`,\n response.status,\n );\n }\n\n const payload: unknown = await response.json();\n if (!isProductListData(payload)) {\n throw new ProductListError(\"Unexpected product list response\");\n }\n\n return payload;\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport {\n InstrumentProvider,\n useInstrument,\n useInstrumentContext,\n withCartAnalyticsMuted,\n type AnalyticsOption,\n type Instrument,\n} from \"@/src/analytics/instrument\";\nimport { DEFAULT_LOCALE } from \"../checkout/locale\";\nimport { addProductToCart, trackProductAdded } from \"./add-to-cart\";\nimport {\n getProductListSlotAppearance,\n resolveProductListAppearance,\n type ProductListAppearance,\n type ProductListSlotName,\n type ResolvedProductListAppearance,\n} from \"./appearance\";\nimport { clampPageSize, type PublicListProduct } from \"./fetch\";\nimport { formatProductPrice } from \"./format\";\nimport { createImpressionTracker } from \"./impressions\";\nimport {\n fillProductListText,\n resolveProductListTexts,\n type ProductListTexts,\n} from \"./texts\";\nimport { useProducts, type UseProductsOptions } from \"./useProducts\";\n\n/** What `renderItem` gets next to the product. */\nexport type ProductListItemContext = {\n /** Product page URL from `productHref`. */\n href: string;\n /** Price formatted for the locale and currency, without the \"from\" prefix. */\n price: string;\n /** Formatted regular price when the product is discounted. */\n compareAtPrice: string | null;\n texts: ProductListTexts;\n locale: string;\n /** Adds the product to the cart the way the built-in button does. */\n addToCart: () => Promise<void>;\n /**\n * Reports a click on the product (`product_clicked`). Call it from the link\n * a custom card renders; the built-in card does it itself.\n */\n trackClick: () => void;\n};\n\nexport type ProductListProps = UseProductsOptions & {\n /**\n * Product page URL. Defaults to the relative `/p/{uniqueSlug}`, which works\n * on a Bitsnap custom domain. Embedded on another site, return the full\n * URL of the product page.\n */\n productHref?: (product: PublicListProduct) => string;\n appearance?: ProductListAppearance;\n /** Text overrides, applied whatever the locale. */\n texts?: Partial<ProductListTexts>;\n /** Replaces the content of a card. The card frame stays. */\n renderItem?: (\n product: PublicListProduct,\n context: ProductListItemContext,\n ) => ReactNode;\n /**\n * Called by the \"Add to cart\" button instead of the default action\n * (`Bitsnap.addProductToCart`). A rejected promise shows the error message.\n */\n onAddToCart?: (product: PublicListProduct) => void | Promise<void>;\n /** Open the cart drawer after the default add to cart. Defaults to `true`. */\n showCartOnAdd?: boolean;\n className?: string;\n /**\n * Usage statistics for your Bitsnap dashboard (list views, impressions,\n * clicks, add to cart). On by default; `false` turns it off. An object\n * lets you forward every event: `{ onEvent }`. Nothing is stored on the\n * visitor's device.\n */\n analytics?: AnalyticsOption;\n};\n\ntype ListContext = {\n appearance: ResolvedProductListAppearance;\n texts: ProductListTexts;\n locale: string;\n};\n\nconst ProductListContext = createContext<ListContext | undefined>(undefined);\n\ntype CardAnalytics = {\n observe: (element: Element, id: string, position: number) => () => void;\n clicked: (product: PublicListProduct, position: number) => void;\n};\n\nconst noCardAnalytics: CardAnalytics = {\n observe: () => () => {},\n clicked: () => {},\n};\n\nconst CardAnalyticsContext = createContext<CardAnalytics>(noCardAnalytics);\n\nfunction useListContext(): ListContext {\n const value = useContext(ProductListContext);\n if (value == null) {\n throw new Error(\"ProductList parts must be rendered inside ProductList\");\n }\n return value;\n}\n\n/** Stable slot attribute, built-in classes and the caller overrides for a slot. */\nfunction useSlot(slot: ProductListSlotName, className?: string) {\n const { appearance } = useListContext();\n const override = getProductListSlotAppearance(appearance, slot);\n\n return {\n \"data-bitsnap-products-slot\": slot,\n className: cn(className, override?.className),\n style: override?.style,\n };\n}\n\nconst BUTTON_CLASS =\n \"inline-flex cursor-pointer items-center justify-center px-4 py-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50\";\nconst BLOCK_BUTTON_CLASS = `${BUTTON_CLASS} w-full`;\nconst LINK_BUTTON_CLASS = `${BLOCK_BUTTON_CLASS} no-underline`;\n\ntype AddStatus = \"idle\" | \"adding\" | \"added\" | \"error\";\n\nfunction AddToCartButton({\n product,\n onAdd,\n}: {\n product: PublicListProduct;\n onAdd: () => Promise<void>;\n}) {\n const { texts } = useListContext();\n const [status, setStatus] = useState<AddStatus>(\"idle\");\n const button = useSlot(\"addToCartButton\", BLOCK_BUTTON_CLASS);\n const message = useSlot(\"message\", \"mt-2 text-xs\");\n\n useEffect(() => {\n if (status !== \"added\") {\n return;\n }\n const timer = setTimeout(() => setStatus(\"idle\"), 2000);\n return () => clearTimeout(timer);\n }, [status]);\n\n const click = useCallback(async () => {\n setStatus(\"adding\");\n try {\n await onAdd();\n setStatus(\"added\");\n } catch (error) {\n console.error(\"bitsnap-react: could not add to the cart\", error);\n setStatus(\"error\");\n }\n }, [onAdd]);\n\n const label =\n status === \"adding\"\n ? texts.addingToCart\n : status === \"added\"\n ? texts.addedToCart\n : texts.addToCart;\n\n return (\n <>\n <button\n type=\"button\"\n {...button}\n disabled={status === \"adding\"}\n aria-label={`${label}: ${product.name}`}\n onClick={click}\n >\n {label}\n </button>\n {status === \"error\" ? (\n <p {...message} role=\"alert\">\n {texts.addToCartError}\n </p>\n ) : null}\n </>\n );\n}\n\nfunction ProductCard({\n product,\n position,\n href,\n onAdd,\n renderItem,\n}: {\n product: PublicListProduct;\n /** Index in the whole catalog (not in the current page). */\n position: number;\n href: string;\n onAdd: () => Promise<void>;\n renderItem?: ProductListProps[\"renderItem\"];\n}) {\n const { texts, locale } = useListContext();\n const analytics = useContext(CardAnalyticsContext);\n const element = useRef<HTMLLIElement>(null);\n useEffect(() => {\n if (element.current == null) {\n return;\n }\n return analytics.observe(element.current, product.id, position);\n }, [analytics, product.id, position]);\n const trackClick = useCallback(\n () => analytics.clicked(product, position),\n [analytics, product, position],\n );\n const card = useSlot(\n \"card\",\n \"relative flex flex-col overflow-hidden border transition-colors\",\n );\n const cardLink = useSlot(\"cardLink\", \"flex flex-1 flex-col no-underline\");\n const imageFrame = useSlot(\"image\", \"aspect-square w-full overflow-hidden\");\n const placeholder = useSlot(\"imagePlaceholder\", \"aspect-square w-full\");\n const body = useSlot(\"body\", \"flex flex-1 flex-col gap-1 p-4\");\n const name = useSlot(\"name\", \"text-base font-medium leading-snug\");\n const description = useSlot(\"description\", \"line-clamp-2 text-sm\");\n const price = useSlot(\"price\", \"mt-auto pt-2 text-base font-semibold\");\n const comparePrice = useSlot(\"comparePrice\", \"ml-2 text-sm font-normal\");\n const badge = useSlot(\n \"badge\",\n \"absolute left-3 top-3 px-2 py-0.5 text-xs font-medium\",\n );\n const actions = useSlot(\"actions\", \"p-4 pt-0\");\n const selectButton = useSlot(\"selectButton\", LINK_BUTTON_CLASS);\n\n const formattedPrice = formatProductPrice(\n product.price,\n product.currency,\n locale,\n );\n const formattedCompare =\n product.compareAtPrice != null && product.compareAtPrice > product.price\n ? formatProductPrice(product.compareAtPrice, product.currency, locale)\n : null;\n\n if (renderItem != null) {\n return (\n <li\n ref={element}\n {...card}\n data-unavailable={product.available ? undefined : \"\"}\n >\n {renderItem(product, {\n href,\n price: formattedPrice,\n compareAtPrice: formattedCompare,\n texts,\n locale,\n addToCart: onAdd,\n trackClick,\n })}\n </li>\n );\n }\n\n const imageSource = product.image?.thumbnailUrl ?? product.image?.url;\n const badgeText = !product.available\n ? texts.unavailable\n : product.isRecurring\n ? texts.subscription\n : null;\n\n return (\n <li ref={element} {...card} data-unavailable={product.available ? undefined : \"\"}>\n <a {...cardLink} href={href} onClick={trackClick}>\n {imageSource != null ? (\n <div {...imageFrame}>\n <img\n src={imageSource}\n alt=\"\"\n loading=\"lazy\"\n decoding=\"async\"\n className=\"h-full w-full object-cover\"\n />\n </div>\n ) : (\n <div {...placeholder} aria-hidden=\"true\" />\n )}\n <div {...body}>\n <h3 {...name}>{product.name}</h3>\n {product.shortDescription ? (\n <p {...description}>{product.shortDescription}</p>\n ) : null}\n <p {...price}>\n {product.priceFrom\n ? fillProductListText(texts.priceFrom, { price: formattedPrice })\n : formattedPrice}\n {formattedCompare != null ? (\n <>\n <span className=\"sr-only\">{texts.originalPrice}: </span>\n <del {...comparePrice}>{formattedCompare}</del>\n </>\n ) : null}\n </p>\n </div>\n </a>\n {badgeText != null ? (\n <span\n {...badge}\n data-kind={product.available ? \"subscription\" : \"unavailable\"}\n >\n {badgeText}\n </span>\n ) : null}\n <div {...actions}>\n {!product.available ? (\n <button type=\"button\" {...selectButton} disabled>\n {texts.unavailable}\n </button>\n ) : product.addToCart ? (\n <AddToCartButton product={product} onAdd={onAdd} />\n ) : (\n <a {...selectButton} href={href} onClick={trackClick}>\n {product.variantCount > 1 ? texts.chooseOptions : texts.viewProduct}\n </a>\n )}\n </div>\n </li>\n );\n}\n\nconst GRID_CLASS =\n \"m-0 grid list-none grid-cols-[repeat(auto-fill,minmax(min(100%,15rem),1fr))] gap-5 p-0\";\n\nfunction SkeletonGrid({ count, label }: { count: number; label: string }) {\n const grid = useSlot(\"grid\", GRID_CLASS);\n const skeleton = useSlot(\"skeleton\", \"aspect-[3/4] animate-pulse\");\n\n return (\n <div {...grid} role=\"status\" aria-busy=\"true\" aria-label={label}>\n {Array.from({ length: count }, (_, index) => (\n <div key={index} {...skeleton} aria-hidden=\"true\" />\n ))}\n </div>\n );\n}\n\nfunction Pagination({\n page,\n pageCount,\n isLoading,\n onPage,\n}: {\n page: number;\n pageCount: number;\n isLoading: boolean;\n onPage: (page: number) => void;\n}) {\n const { texts } = useListContext();\n const nav = useSlot(\n \"pagination\",\n \"mt-8 flex items-center justify-center gap-4\",\n );\n const button = useSlot(\"paginationButton\", BUTTON_CLASS);\n const indicator = useSlot(\"pageIndicator\", \"text-sm\");\n\n return (\n <nav {...nav} aria-label={texts.pagination}>\n <button\n type=\"button\"\n {...button}\n aria-disabled={isLoading || page <= 1}\n onClick={() => {\n if (!isLoading && page > 1) {\n onPage(page - 1);\n }\n }}\n >\n {texts.previousPage}\n </button>\n <span {...indicator} aria-live=\"polite\">\n {fillProductListText(texts.pageOf, { page, pageCount })}\n </span>\n <button\n type=\"button\"\n {...button}\n aria-disabled={isLoading || page >= pageCount}\n onClick={() => {\n if (!isLoading && page < pageCount) {\n onPage(page + 1);\n }\n }}\n >\n {texts.nextPage}\n </button>\n </nav>\n );\n}\n\nfunction ProductListContent({\n options,\n productHref,\n renderItem,\n onAddToCart,\n showCartOnAdd,\n}: {\n options: UseProductsOptions;\n productHref: (product: PublicListProduct) => string;\n renderItem?: ProductListProps[\"renderItem\"];\n onAddToCart?: ProductListProps[\"onAddToCart\"];\n showCartOnAdd: boolean;\n}) {\n const { texts } = useListContext();\n const { products, page, pageCount, setPage, isLoading, error, refetch } =\n useProducts(options);\n const instrument = useInstrumentContext();\n // The search text is never reported, only that the list was searched.\n const listId = options.search?.trim() ? \"search\" : \"catalog\";\n const pageSize = clampPageSize(options.pageSize);\n\n const viewed = useRef(false);\n useEffect(() => {\n if (viewed.current || isLoading || error != null) {\n return;\n }\n viewed.current = true;\n instrument.track(\"product_list_viewed\", {\n list_id: listId,\n item_count: products.length,\n });\n }, [instrument, isLoading, error, listId, products.length]);\n\n const impressions = useMemo(\n () =>\n createImpressionTracker(({ productIds, positions }) =>\n instrument.track(\"product_impression\", {\n list_id: listId,\n product_ids: productIds,\n positions,\n }),\n ),\n [instrument, listId],\n );\n useEffect(() => () => impressions.destroy(), [impressions]);\n const cardAnalytics = useMemo<CardAnalytics>(\n () => ({\n observe: impressions.observe,\n clicked: (product, position) =>\n instrument.track(\n \"product_clicked\",\n { list_id: listId, position },\n { product_id: product.id },\n ),\n }),\n [impressions, instrument, listId],\n );\n\n // After a page change by the user, move focus to the products (the button\n // that was pressed stays where it is, but the content above it changes) and\n // bring them into view once the page has loaded.\n const content = useRef<HTMLDivElement>(null);\n const movedPage = useRef(false);\n const changePage = useCallback(\n (next: number) => {\n movedPage.current = true;\n setPage(next);\n },\n [setPage],\n );\n useEffect(() => {\n if (isLoading || !movedPage.current) {\n return;\n }\n movedPage.current = false;\n content.current?.focus({ preventScroll: true });\n content.current?.scrollIntoView({ block: \"start\" });\n }, [isLoading]);\n\n const grid = useSlot(\"grid\", GRID_CLASS);\n const empty = useSlot(\"emptyState\", \"py-12 text-center text-sm\");\n const errorSlot = useSlot(\"error\", \"flex flex-col items-center gap-3 py-12 text-center text-sm\");\n const retry = useSlot(\"retryButton\", BUTTON_CLASS);\n\n const { projectID, host } = options;\n const addFor = useCallback(\n (product: PublicListProduct) => async () => {\n if (onAddToCart != null) {\n // The list reports the add itself; a cart helper called inside must not report it again.\n await withCartAnalyticsMuted(() => onAddToCart(product));\n trackProductAdded(instrument, product);\n return;\n }\n await addProductToCart(product, {\n projectID,\n host,\n showCart: showCartOnAdd,\n analytics: instrument,\n });\n },\n [onAddToCart, projectID, host, showCartOnAdd, instrument],\n );\n\n let body: ReactNode;\n if (isLoading && products.length === 0) {\n body = (\n <SkeletonGrid\n count={Math.min(clampPageSize(options.pageSize), 8)}\n label={texts.loading}\n />\n );\n } else if (error != null) {\n body = (\n <div {...errorSlot} role=\"alert\">\n <p>{texts.error}</p>\n <button type=\"button\" {...retry} onClick={refetch}>\n {texts.retry}\n </button>\n </div>\n );\n } else if (products.length === 0) {\n body = <p {...empty}>{texts.empty}</p>;\n } else {\n body = (\n <ul\n {...grid}\n aria-busy={isLoading || undefined}\n className={cn(grid.className, isLoading && \"opacity-60\")}\n >\n {products.map((product, index) => (\n <ProductCard\n key={product.id}\n product={product}\n position={(page - 1) * pageSize + index}\n href={productHref(product)}\n onAdd={addFor(product)}\n renderItem={renderItem}\n />\n ))}\n </ul>\n );\n }\n\n return (\n <CardAnalyticsContext.Provider value={cardAnalytics}>\n <div\n ref={content}\n tabIndex={-1}\n className=\"p-1 outline-none scroll-mt-4\"\n >\n {body}\n {pageCount > 1 && error == null ? (\n <Pagination\n page={page}\n pageCount={pageCount}\n isLoading={isLoading}\n onPage={changePage}\n />\n ) : null}\n </div>\n </CardAnalyticsContext.Provider>\n );\n}\n\nconst defaultProductHref = (product: PublicListProduct) =>\n `/p/${encodeURIComponent(product.uniqueSlug)}`;\n\n/**\n * Responsive grid of the shop's products with pagination, loading, empty and\n * error states. Cards link to the product page and can add to the cart.\n *\n * ```tsx\n * <ProductList projectID=\"…\" locale=\"pl-PL\" initialData={firstPage} />\n * ```\n *\n * It renders on the server: pass `initialData` (the first page, fetched on the\n * server) to have the products in the HTML; without it the server renders the\n * loading skeleton and the browser fetches the first page.\n */\nexport function ProductList({\n productHref = defaultProductHref,\n appearance,\n texts,\n renderItem,\n onAddToCart,\n showCartOnAdd = true,\n className,\n analytics,\n ...options\n}: ProductListProps) {\n const instrument: Instrument = useInstrument(\n options.projectID,\n analytics,\n \"catalog\",\n );\n const locale = options.locale ?? DEFAULT_LOCALE;\n const resolvedAppearance = useMemo(\n () => resolveProductListAppearance(appearance),\n [appearance],\n );\n const resolvedTexts = useMemo(\n () => resolveProductListTexts(locale, texts),\n [locale, texts],\n );\n const context = useMemo(\n () => ({ appearance: resolvedAppearance, texts: resolvedTexts, locale }),\n [resolvedAppearance, resolvedTexts, locale],\n );\n const root = getProductListSlotAppearance(resolvedAppearance, \"root\");\n\n return (\n <InstrumentProvider value={instrument}>\n <ProductListContext.Provider value={context}>\n <div\n data-bitsnap-products=\"root\"\n data-bitsnap-products-slot=\"root\"\n className={cn(\n \"bitsnap-react\",\n resolvedAppearance.boundaryClassName,\n className,\n root?.className,\n )}\n style={\n { ...resolvedAppearance.boundaryStyle, ...root?.style } as CSSProperties\n }\n >\n <ProductListContent\n options={options}\n productHref={productHref}\n renderItem={renderItem}\n onAddToCart={onAddToCart}\n showCartOnAdd={showCartOnAdd}\n />\n </div>\n </ProductListContext.Provider>\n </InstrumentProvider>\n );\n}\n","import { normalizeHost } from \"./fetch\";\n\nexport type CartState = {\n /** Project the page cart is set up for, `null` or `undefined` when none yet. */\n projectID: string | null | undefined;\n /** Backend origin the page cart currently talks to. */\n host: string;\n /** Backend origin used when the page did not choose another one. */\n defaultHost: string;\n};\n\nexport type CartTarget = {\n projectID: string;\n /** Omitted or empty keeps the current host. */\n host?: string;\n};\n\nexport type CartPlan =\n | { ok: true; setProjectID: string | null; setHost: string | null }\n | { ok: false; reason: string };\n\n/**\n * Decides, without changing anything, whether the page cart can serve the\n * target and what has to be filled in first. Both the project and the host are\n * checked before the caller changes either of them, so a refused click leaves\n * the page cart untouched.\n */\nexport function planCartTarget(state: CartState, target: CartTarget): CartPlan {\n if (state.projectID != null && state.projectID !== target.projectID) {\n return {\n ok: false,\n reason: `the page cart already belongs to project \"${state.projectID}\"`,\n };\n }\n\n let setHost: string | null = null;\n const targetHost = target.host ? normalizeHost(target.host) : \"\";\n const currentHost = normalizeHost(state.host);\n if (targetHost && targetHost !== currentHost) {\n if (currentHost !== normalizeHost(state.defaultHost)) {\n return {\n ok: false,\n reason: `the page cart already uses the host \"${state.host}\"`,\n };\n }\n setHost = targetHost;\n }\n\n return {\n ok: true,\n setProjectID: state.projectID == null ? target.projectID : null,\n setHost,\n };\n}\n","import { noopInstrument, type Instrument } from \"@/src/analytics/instrument\";\nimport { DEFAULT_HOST, HOST, setCustomHost } from \"../checkout/constants\";\nimport { planCartTarget } from \"./cart-target\";\nimport type { PublicListProduct } from \"./fetch\";\n\nexport type AddToCartTarget = {\n projectID: string;\n /** Backend origin the cart talks to. Omitted or empty keeps the current one. */\n host?: string;\n /** Open the cart drawer afterwards. */\n showCart: boolean;\n /** Where `add_to_cart` is reported. Omitted: nothing is reported. */\n analytics?: Instrument;\n};\n\n/** `add_to_cart` for a product of the list (quantity 1, price in minor units). */\nexport function trackProductAdded(\n instrument: Instrument,\n product: PublicListProduct,\n) {\n const variant =\n product.cartItemId != null && product.cartItemId !== product.id\n ? product.cartItemId\n : null;\n instrument.track(\n \"add_to_cart\",\n { qty: 1, value_minor: product.price, currency: product.currency },\n { product_id: product.id, variant_id: variant },\n );\n}\n\n/**\n * Default \"add to cart\" action of `ProductList`: `Bitsnap.addProductToCart`\n * with quantity 1, then the cart drawer.\n *\n * The checkout is a heavy module (RPC client, cart state, payment buttons), so\n * it is loaded on the first click and never ends up in the first paint of a\n * catalog page. The cart only knows one project and one host at a time, and\n * they are page-wide (the cart is kept in localStorage, `setProjectID` also\n * changes the panel configuration). So the list only fills them in when the\n * page has not set them yet; when the page already works for another project\n * or host, nothing is changed and the call fails (pass `onAddToCart` to the\n * list in that case).\n */\nexport async function addProductToCart(\n product: PublicListProduct,\n target: AddToCartTarget,\n): Promise<void> {\n const [{ Bitsnap }, { getProjectID, setProjectID }] = await Promise.all([\n import(\"../checkout/methods\"),\n import(\"../checkout/CartProvider\"),\n ]);\n\n const plan = planCartTarget(\n { projectID: getProjectID(), host: HOST, defaultHost: DEFAULT_HOST },\n target,\n );\n if (!plan.ok) {\n return failConflict(plan.reason);\n }\n if (plan.setProjectID != null) {\n setProjectID(plan.setProjectID);\n }\n if (plan.setHost != null) {\n setCustomHost(plan.setHost);\n }\n\n // Single-variant products are added by their variant, not the product ID.\n const error = await Bitsnap.addProductToCart(\n product.cartItemId ?? product.id,\n 1,\n undefined,\n {\n name: product.name,\n price: product.price,\n currency: product.currency,\n // Reported below from the list's own data.\n analytics: noopInstrument,\n },\n );\n if (error != null) {\n throw new Error(\"Could not add the product to the cart\");\n }\n if (target.analytics != null) {\n trackProductAdded(target.analytics, product);\n }\n\n if (target.showCart) {\n Bitsnap.showCart();\n }\n}\n\nfunction failConflict(reason: string): never {\n console.warn(\n `bitsnap-react: ProductList did not add to the cart because ${reason}. ` +\n \"Pass onAddToCart to use another cart.\",\n );\n throw new Error(\"The page cart belongs to another project or host\");\n}\n","import { getTracker } from \"@/src/analytics/core\";\n\n/** Matches the contract's `positions` / `product_ids` array limit. */\nconst MAX_PER_EVENT = 50;\nconst FLUSH_DELAY_MS = 1000;\n\nexport type ImpressionBatch = { productIds: string[]; positions: number[] };\n\n/**\n * Collects the products that were at least half visible, each one once, and\n * hands them over in batches. Without `IntersectionObserver` nothing is\n * reported. Never throws.\n */\nexport function createImpressionTracker(\n onBatch: (batch: ImpressionBatch) => void,\n delayMs = FLUSH_DELAY_MS,\n) {\n const seen = new Set<string>();\n const targets = new Map<Element, { id: string; position: number }>();\n let pendingIds: string[] = [];\n let pendingPositions: number[] = [];\n let observer: IntersectionObserver | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let listening = false;\n\n function flush() {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n while (pendingIds.length > 0) {\n const productIds = pendingIds.slice(0, MAX_PER_EVENT);\n const positions = pendingPositions.slice(0, MAX_PER_EVENT);\n pendingIds = pendingIds.slice(MAX_PER_EVENT);\n pendingPositions = pendingPositions.slice(MAX_PER_EVENT);\n try {\n onBatch({ productIds, positions });\n } catch {}\n }\n }\n\n // The tracker flushes its own queue on `pagehide`; ours must be in it by then.\n function flushAll() {\n flush();\n try {\n getTracker()?.flush();\n } catch {}\n }\n const onVisibility = () => {\n if (typeof document !== \"undefined\" && document.visibilityState === \"hidden\") flushAll();\n };\n\n function listen() {\n if (listening || typeof window === \"undefined\") return;\n listening = true;\n window.addEventListener(\"pagehide\", flushAll, true);\n document.addEventListener(\"visibilitychange\", onVisibility, true);\n }\n\n function getObserver(): IntersectionObserver | undefined {\n if (observer) return observer;\n if (typeof IntersectionObserver === \"undefined\") return undefined;\n observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n const target = targets.get(entry.target);\n if (!target || !entry.isIntersecting || entry.intersectionRatio < 0.5) continue;\n targets.delete(entry.target);\n observer?.unobserve(entry.target);\n if (seen.has(target.id)) continue;\n seen.add(target.id);\n pendingIds.push(target.id);\n pendingPositions.push(target.position);\n }\n if (pendingIds.length > 0 && timer === undefined) {\n timer = setTimeout(flush, delayMs);\n (timer as { unref?: () => void }).unref?.();\n }\n },\n { threshold: [0.5] },\n );\n listen();\n return observer;\n }\n\n return {\n /** Starts watching a card. Returns a function that stops. */\n observe(element: Element, id: string, position: number): () => void {\n try {\n if (seen.has(id)) return () => {};\n const watcher = getObserver();\n if (!watcher) return () => {};\n targets.set(element, { id, position });\n watcher.observe(element);\n return () => {\n targets.delete(element);\n watcher.unobserve(element);\n };\n } catch {\n return () => {};\n }\n },\n flush,\n destroy() {\n try {\n flush();\n observer?.disconnect();\n if (listening) {\n window.removeEventListener(\"pagehide\", flushAll, true);\n document.removeEventListener(\"visibilitychange\", onVisibility, true);\n listening = false;\n }\n } catch {}\n observer = undefined;\n targets.clear();\n },\n };\n}\n","import {\n lookupText,\n resolveTexts,\n type LocaleTables,\n} from \"@/src/lib/texts\";\n\n/**\n * Every string `ProductList` renders. Pass a partial object through the\n * `texts` prop to override any of them, whatever the locale. Placeholders\n * (`{price}`, `{page}`, `{pageCount}`) are filled by the component.\n */\nexport type ProductListTexts = {\n /** \"Add to cart\" button of products that can be bought straight from the list. */\n addToCart: string;\n /** Button label while the product is being added. */\n addingToCart: string;\n /** Button label after the product was added. */\n addedToCart: string;\n /** Message shown when adding to the cart failed. */\n addToCartError: string;\n /** Link of products with variants, to pick one on the product page. */\n chooseOptions: string;\n /** Link of products that cannot be added from the list (subscriptions). */\n viewProduct: string;\n /** Label of products that are out of stock. */\n unavailable: string;\n /** Badge of subscription products. */\n subscription: string;\n /** Price of products whose variants differ in price. `{price}` is the lowest one. */\n priceFrom: string;\n /** Screen reader label of the struck-through regular price. */\n originalPrice: string;\n /** Accessible label of the loading skeleton. */\n loading: string;\n /** Shown when the shop has no products (or none matches the search). */\n empty: string;\n /** Shown when the products could not be loaded. */\n error: string;\n /** Retry button of the error state. */\n retry: string;\n /** Accessible label of the pagination. */\n pagination: string;\n previousPage: string;\n nextPage: string;\n /** Page indicator. `{page}` and `{pageCount}` are filled in. */\n pageOf: string;\n};\n\nexport type ProductListTextKey = keyof ProductListTexts;\n\nexport const PRODUCT_LIST_TEXT_TABLES: LocaleTables<ProductListTextKey> = {\n en: {\n addToCart: \"Add to cart\",\n addingToCart: \"Adding…\",\n addedToCart: \"Added to cart\",\n addToCartError: \"Could not add to the cart. Try again.\",\n chooseOptions: \"Choose\",\n viewProduct: \"View\",\n unavailable: \"Unavailable\",\n subscription: \"Subscription\",\n priceFrom: \"from {price}\",\n originalPrice: \"Original price\",\n loading: \"Loading products\",\n empty: \"There are no products to show.\",\n error: \"Could not load the products.\",\n retry: \"Try again\",\n pagination: \"Pagination\",\n previousPage: \"Previous\",\n nextPage: \"Next\",\n pageOf: \"Page {page} of {pageCount}\",\n },\n pl: {\n addToCart: \"Dodaj do koszyka\",\n addingToCart: \"Dodawanie…\",\n addedToCart: \"Dodano do koszyka\",\n addToCartError: \"Nie udało się dodać do koszyka. Spróbuj ponownie.\",\n chooseOptions: \"Wybierz\",\n viewProduct: \"Zobacz\",\n unavailable: \"Niedostępny\",\n subscription: \"Subskrypcja\",\n priceFrom: \"od {price}\",\n originalPrice: \"Cena przed obniżką\",\n loading: \"Ładowanie produktów\",\n empty: \"Brak produktów do wyświetlenia.\",\n error: \"Nie udało się załadować produktów.\",\n retry: \"Spróbuj ponownie\",\n pagination: \"Paginacja\",\n previousPage: \"Poprzednia\",\n nextPage: \"Następna\",\n pageOf: \"Strona {page} z {pageCount}\",\n },\n};\n\n/** Default texts for a locale merged with the caller overrides. */\nexport function resolveProductListTexts(\n locale: string,\n overrides?: Partial<ProductListTexts>,\n): ProductListTexts {\n return resolveTexts(PRODUCT_LIST_TEXT_TABLES, locale, overrides);\n}\n\nexport function getProductListText(\n key: ProductListTextKey,\n locale: string,\n overrides?: Partial<ProductListTexts>,\n): string {\n return lookupText(resolveProductListTexts(locale, overrides), key);\n}\n\n/** Replaces `{name}` placeholders. Unknown placeholders stay untouched. */\nexport function fillProductListText(\n text: string,\n values: Record<string, string | number>,\n): string {\n return text.replace(/\\{(\\w+)\\}/g, (match, name: string) =>\n name in values ? String(values[name]) : match,\n );\n}\n"],"mappings":"0NA2DO,IAAMA,GAA0B,CACrC,OACA,OACA,OACA,WACA,QACA,mBACA,OACA,OACA,cACA,QACA,eACA,QACA,UACA,kBACA,eACA,UACA,aACA,mBACA,gBACA,aACA,QACA,cACA,UACF,EA8BaC,GAA+B,CAC1C,WAAY,iCACZ,SAAU,+BACV,WAAY,gCACZ,QAAS,6BACT,WAAY,gCACZ,gBAAiB,sCACjB,OAAQ,4BACR,iBAAkB,uCAClB,iBAAkB,uCAClB,sBAAuB,6CACvB,aAAc,mCACd,UAAW,gCACX,MAAO,2BACP,gBAAiB,sCACjB,gBAAiB,sCACjB,OAAQ,2BACV,EASaC,GAGT,CACF,MAAO,CACL,WAAY,UACZ,QAAS,UACT,WAAY,UACZ,gBAAiB,UACjB,OAAQ,UACR,iBAAkB,UAClB,iBAAkB,UAClB,sBAAuB,UACvB,aAAc,UACd,UAAW,UACX,MAAO,UACP,gBAAiB,UACjB,gBAAiB,UACjB,OAAQ,KACV,EACA,KAAM,CACJ,WAAY,UACZ,QAAS,UACT,WAAY,UACZ,gBAAiB,UACjB,OAAQ,UACR,iBAAkB,UAClB,iBAAkB,UAClB,sBAAuB,UACvB,aAAc,UACd,UAAW,UACX,MAAO,UACP,gBAAiB,UACjB,gBAAiB,UACjB,OAAQ,KACV,CACF,EAGMC,GACJ,CAAC,EAEI,SAASC,GACdC,EAC+B,CAC/B,IAAMC,EAAWC,GAIfF,EAAY,CACZ,aAAc,QACd,QAASH,GACT,UAAWD,GACX,gBAAiBE,EACnB,CAAC,EAED,MAAO,CACL,MAAOG,EAAS,MAChB,OAAQA,EAAS,OACjB,SAAUA,EAAS,SACnB,kBAA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ACpB,IAAMyB,GAAwB9E,EAAQhB,CAAK,EAC3C,CAACgB,EAAQhB,CAAK,CAChB,EACM+F,EAAU1B,EACd,KAAO,CAAE,WAAYsB,EAAoB,MAAOE,EAAe,OAAA7E,CAAO,GACtE,CAAC2E,EAAoBE,EAAe7E,CAAM,CAC5C,EACMgF,EAAOxG,EAA6BmG,EAAoB,MAAM,EAEpE,OACEjH,EAACuH,GAAA,CAAmB,MAAOnC,EAC3B,SAAApF,EAACE,GAAmB,SAAnB,CAA4B,MAAOmH,EAClC,SAAArH,EAAC,OACC,wBAAsB,OACtB,6BAA2B,OAC3B,UAAWe,EACT,gBACAkG,EAAmB,kBACnBtG,EACA2G,GAAM,SACR,EACA,MACE,CAAE,GAAGL,EAAmB,cAAe,GAAGK,GAAM,KAAM,EAGxD,SAAAtH,EAAC2E,GAAA,CACC,QAASC,EACT,YAAaC,EACb,WAAYxC,EACZ,YAAayC,EACb,cAAeC,EACjB,EACF,EACF,EACA,CAEJ","names":["PRODUCT_LIST_SLOT_NAMES","PRODUCT_LIST_TOKEN_VARIABLES","PRODUCT_LIST_THEME_PRESETS","PRODUCT_LIST_SHADCN_VARIABLES","resolveProductListAppearance","appearance","resolved","resolveAppearanceCore","getProductListSlotAppearance","slot","getSlotAppearance","createFormatter","locale","currency","formatProductPrice","amount","DEFAULT_LOCALE","value","formatter","useCallback","useEffect","useMemo","useState","DEFAULT_PAGE_SIZE","MAX_PAGE_SIZE","ProductListError","message","status","clampPageSize","pageSize","pageCountFor","totalCount","normalizeHost","host","buildProductListURL","query","params","search","isProductListData","value","fetchProductList","signal","response","withClientParam","payload","useProducts","options","projectID","locale","search","initialData","defaultHost","useState","HOST","host","pageSize","clampPageSize","queryKey","pageState","setPageState","reloads","setReloads","snapshot","setSnapshot","totalCount","pageCount","pageCountFor","requestedPage","page","requestKey","isCurrent","useEffect","controller","fetchProductList","data","error","previous","setPage","useCallback","next","target","refetch","value","useMemo","createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","planCartTarget","state","target","setHost","targetHost","normalizeHost","currentHost","trackProductAdded","instrument","product","variant","addProductToCart","target","Bitsnap","getProjectID","setProjectID","plan","planCartTarget","HOST","DEFAULT_HOST","failConflict","setCustomHost","noopInstrument","reason","MAX_PER_EVENT","FLUSH_DELAY_MS","createImpressionTracker","onBatch","delayMs","seen","targets","pendingIds","pendingPositions","observer","timer","listening","flush","productIds","positions","flushAll","getTracker","onVisibility","listen","getObserver","entries","entry","target","element","id","position","watcher","PRODUCT_LIST_TEXT_TABLES","resolveProductListTexts","locale","overrides","resolveTexts","fillProductListText","text","values","match","name","Fragment","jsx","jsxs","ProductListContext","createContext","noCardAnalytics","CardAnalyticsContext","useListContext","value","useContext","useSlot","slot","className","appearance","override","getProductListSlotAppearance","cn","BUTTON_CLASS","BLOCK_BUTTON_CLASS","LINK_BUTTON_CLASS","AddToCartButton","product","onAdd","texts","status","setStatus","useState","button","message","useEffect","timer","click","useCallback","error","label","ProductCard","position","href","renderItem","locale","analytics","element","useRef","trackClick","card","cardLink","imageFrame","placeholder","body","name","description","price","comparePrice","badge","actions","selectButton","formattedPrice","formatProductPrice","formattedCompare","imageSource","badgeText","fillProductListText","GRID_CLASS","SkeletonGrid","count","grid","skeleton","_","index","Pagination","page","pageCount","isLoading","onPage","nav","indicator","ProductListContent","options","productHref","onAddToCart","showCartOnAdd","products","setPage","refetch","useProducts","instrument","useInstrumentContext","listId","pageSize","clampPageSize","viewed","impressions","useMemo","createImpressionTracker","productIds","positions","cardAnalytics","content","movedPage","changePage","next","empty","errorSlot","retry","projectID","host","addFor","withCartAnalyticsMuted","trackProductAdded","addProductToCart","defaultProductHref","ProductList","useInstrument","DEFAULT_LOCALE","resolvedAppearance","resolveProductListAppearance","resolvedTexts","resolveProductListTexts","context","root","InstrumentProvider"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-3IVLQILF.js","../src/panel/config.ts","../src/panel/PanelProvider.tsx","../src/panel/session-storage.ts"],"names":["config","allowedReturnOrigins","setPanelConfig","newConfig","getPanelConfig","setProjectID","projectID","setTheme","theme","setLoginURL","loginURL","setHost","host","setAllowedReturnOrigins","origins","getAllowedReturnOrigins","PanelContext","createContext","PanelProvider","children","analytics","instrument","useInstrument","jsx","RpcProvider","InstrumentProvider","usePanelConfig","useContext","panelSessionKey"],"mappings":"AAAA,mOAAuC,sDAA+C,ICElFA,CAAAA,CAAsB,CACxB,SAAA,CAAW,KAAA,CAAA,CACX,QAAA,CAAU,cAAA,CACV,KAAA,CAAO,KAAA,CAAA,CACP,IAAA,CAAM,KAAA,CAAA,CACN,oBAAA,CAAsB,CAAC,CACzB,CAAA,CAEIC,CAAAA,CAAiC,CAAC,CAAA,CAU/B,SAASC,CAAAA,CAAeC,CAAAA,CAAuC,CACpEH,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,GAAGG,CAAU,CACrC,CAEO,SAASC,CAAAA,CAAAA,CAA8B,CAC5C,OAAOJ,CACT,CAEO,SAASK,CAAAA,CAAaC,CAAAA,CAAyB,CACpDN,CAAAA,CAAO,SAAA,CAAYM,CACrB,CAEO,SAASC,CAAAA,CAASC,CAAAA,CAA6B,CACpDR,CAAAA,CAAO,KAAA,CAAQQ,CACjB,CAEO,SAASC,CAAAA,CAAYC,CAAAA,CAAwB,CAClDV,CAAAA,CAAO,QAAA,CAAWU,CACpB,CAEO,SAASC,CAAAA,CAAQC,CAAAA,CAAoB,CAC1CZ,CAAAA,CAAO,IAAA,CAAOY,CAChB,CAEO,SAASC,CAAAA,CAAwBC,CAAAA,CAAyB,CAC/Db,CAAAA,CAAuBa,CAAAA,CACvBd,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,oBAAA,CAAsBc,CAAQ,CACtD,CAEO,SAASC,CAAAA,CAAAA,CAAoC,CAClD,OAAOd,CACT,CCnDA,8BAA0C,+CA2BhC,IAlBJe,CAAAA,CAAeC,kCAAAA,CAA2Bb,CAAe,CAAC,CAAA,CAEnDc,CAAAA,aASR,CAAC,CAAE,QAAA,CAAAC,CAAAA,CAAU,SAAA,CAAAC,CAAU,CAAA,CAAA,EAAM,CAChC,IAAMpB,CAAAA,CAASI,CAAAA,CAAe,CAAA,CACxBiB,CAAAA,CAAaC,gCAAAA,CAActB,CAAO,SAAA,CAAWoB,CAAAA,CAAW,OAAO,CAAA,CACrE,OACEG,6BAAAA,kBAACC,CAAA,CACC,QAAA,CAAAD,6BAAAA,CAACP,CAAa,QAAA,CAAb,CAAsB,KAAA,CAAO,CAAE,GAAGhB,CAAO,CAAA,CACxC,QAAA,CAAAuB,6BAAAA,kBAACE,CAAA,CAAmB,KAAA,CAAOJ,CAAAA,CACzB,QAAA,CAAAE,6BAAAA,KAAC,CAAA,CAAI,SAAA,CAAU,eAAA,CAAiB,QAAA,CAAAJ,CAAAA,CAAS,CAAA,CAC3C,CAAA,CACF,CAAA,CACF,CAEJ,CAAA,CAEaO,CAAAA,aAAiB,CAAA,CAAA,EAAMC,+BAAAA,CAAuB,CAAA,CClC3D,IAAMC,CAAAA,CAAkB,CAACtB,CAAAA,CAAmBM,CAAAA,CAAAA,EAC1C,CAAA,sBAAA,EAAyB,kBAAA,kBAAmBA,CAAAA,SAAQ,sBAAoB,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBN,CAAS,CAAC,CAAA,CAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-3IVLQILF.js","sourcesContent":[null,"import type { GetThemeOutput } from \"./types\";\n\nlet config: PanelConfig = {\n projectID: undefined,\n loginURL: \"/panel/login\",\n theme: undefined,\n host: undefined,\n allowedReturnOrigins: [],\n};\n\nlet allowedReturnOrigins: string[] = [];\n\nexport interface PanelConfig {\n projectID?: string;\n loginURL?: string;\n theme?: GetThemeOutput;\n host?: string;\n allowedReturnOrigins: string[];\n}\n\nexport function setPanelConfig(newConfig: Partial<PanelConfig>): void {\n config = { ...config, ...newConfig };\n}\n\nexport function getPanelConfig(): PanelConfig {\n return config;\n}\n\nexport function setProjectID(projectID: string): void {\n config.projectID = projectID;\n}\n\nexport function setTheme(theme: GetThemeOutput): void {\n config.theme = theme;\n}\n\nexport function setLoginURL(loginURL: string): void {\n config.loginURL = loginURL;\n}\n\nexport function setHost(host: string): void {\n config.host = host;\n}\n\nexport function setAllowedReturnOrigins(origins: string[]): void {\n allowedReturnOrigins = origins;\n config = { ...config, allowedReturnOrigins: origins };\n}\n\nexport function getAllowedReturnOrigins(): string[] {\n return allowedReturnOrigins;\n}\n","import { createContext, useContext } from \"react\";\nimport {\n InstrumentProvider,\n useInstrument,\n type AnalyticsOption,\n} from \"../analytics/instrument\";\nimport { RpcProvider } from \"../rpc-provider\";\nimport { getPanelConfig, type PanelConfig } from \"./config\";\n\nconst PanelContext = createContext<PanelConfig>(getPanelConfig());\n\nexport const PanelProvider: React.FC<{\n children: React.ReactNode;\n /**\n * Usage statistics for your Bitsnap dashboard (panel logins, orders viewed,\n * downloads, course progress). On by default; `false` turns it off. An\n * object lets you forward every event: `{ onEvent }`. Nothing is stored on\n * the visitor's device.\n */\n analytics?: AnalyticsOption;\n}> = ({ children, analytics }) => {\n const config = getPanelConfig();\n const instrument = useInstrument(config.projectID, analytics, \"panel\");\n return (\n <RpcProvider>\n <PanelContext.Provider value={{ ...config }}>\n <InstrumentProvider value={instrument}>\n <div className=\"bitsnap-react\">{children}</div>\n </InstrumentProvider>\n </PanelContext.Provider>\n </RpcProvider>\n );\n};\n\nexport const usePanelConfig = () => useContext(PanelContext);\n","const panelSessionKey = (projectID: string, host?: string) =>\n `bitsnap-panel-session:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nconst panelEmailKey = (projectID: string, host?: string) =>\n `bitsnap-panel-email:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nexport function getPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return undefined;\n const token = window.localStorage.getItem(panelSessionKey(projectID, host));\n return token ?? undefined;\n}\n\nexport function savePanelSession(projectID: string | undefined, token: string, email: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.setItem(panelSessionKey(projectID, host), token);\n window.localStorage.setItem(panelEmailKey(projectID, host), email);\n}\n\nexport function getPanelEmail(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return null;\n return window.localStorage.getItem(panelEmailKey(projectID, host));\n}\n\nexport function clearPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.removeItem(panelSessionKey(projectID, host));\n window.localStorage.removeItem(panelEmailKey(projectID, host));\n}\n"]}
@@ -1,4 +0,0 @@
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunkUCL4Y7L3js = require('./chunk-UCL4Y7L3.js');var _chunk3IVLQILFjs = require('./chunk-3IVLQILF.js');var _chunkUFIOJGJZjs = require('./chunk-UFIOJGJZ.js');var _chunkQ25D7OAOjs = require('./chunk-Q25D7OAO.js');var _chunkWGJTXDISjs = require('./chunk-WGJTXDIS.js');var _react = require('@formkit/auto-animate/react');var _react3 = require('react'); var Sn = _interopRequireWildcard(_react3); var mt = _interopRequireWildcard(_react3);var _jsxruntime = require('react/jsx-runtime');function de({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card",className:_chunkQ25D7OAOjs.d.call(void 0, "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function ye({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-header",className:_chunkQ25D7OAOjs.d.call(void 0, "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function be({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-title",className:_chunkQ25D7OAOjs.d.call(void 0, "leading-none font-semibold",e),...t})}function Tt({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-description",className:_chunkQ25D7OAOjs.d.call(void 0, "text-muted-foreground text-sm",e),...t})}function ue({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-content",className:_chunkQ25D7OAOjs.d.call(void 0, "px-6",e),...t})}var _inputotp = require('input-otp');var _lucidereact = require('lucide-react');function In({className:e,containerClassName:t,...r}){return _jsxruntime.jsx.call(void 0, _inputotp.OTPInput,{"data-slot":"input-otp",containerClassName:_chunkQ25D7OAOjs.d.call(void 0, "flex items-center gap-2 has-disabled:opacity-50",t),className:_chunkQ25D7OAOjs.d.call(void 0, "disabled:cursor-not-allowed",e),...r})}function Lt({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"input-otp-group",className:_chunkQ25D7OAOjs.d.call(void 0, "flex items-center",e),...t})}function Se({index:e,className:t,...r}){let n=Sn.useContext(_inputotp.OTPInputContext),{char:a,hasFakeCaret:o,isActive:i}=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _2 => _2.slots, 'access', _3 => _3[e]]), () => ({}));return _jsxruntime.jsxs.call(void 0, "div",{"data-slot":"input-otp-slot","data-active":i,className:_chunkQ25D7OAOjs.d.call(void 0, "data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",t),...r,children:[a,o&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:_jsxruntime.jsx.call(void 0, "div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function Rn({...e}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"input-otp-separator",role:"separator",...e,children:_jsxruntime.jsx.call(void 0, _lucidereact.MinusIcon,{})})}function _r(){return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var V=_r;var Fr="return_url",Ut="__return_url",qr="accessToken";function Ze(e){let t=new URLSearchParams(e).get(Fr);return t?An(t):null}function Je(e){typeof window>"u"||(e?window.sessionStorage.setItem(Ut,e):window.sessionStorage.removeItem(Ut))}function Ue(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(Ut);return e?An(e):null}function Br(e,t){return t.some(r=>{if(e===r)return!0;let n=new URL(r).hostname,a=new URL(e).hostname;return a.endsWith(`.${n}`)||a===n})}function An(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!Br(t.origin,_chunk3IVLQILFjs.h.call(void 0, ))?null:t.toString()}catch (e2){return null}}function Oe(e,t){let r=new URL(e);return r.searchParams.set(qr,t),r.toString()}if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];_chunk3IVLQILFjs.h.call(void 0, ).length===0&&_chunk3IVLQILFjs.g.call(void 0, Array.from(new Set(t)))}var $r=({projectID:e,host:t,reveal:r,email:n,setEmail:a,loginUser:o,isLoginLoading:i,errMsg:c})=>{let{projectID:s,host:y}=_chunk3IVLQILFjs.j.call(void 0, );if(typeof window<"u"&&_chunk3IVLQILFjs.k.call(void 0, _nullishCoalesce(e, () => (s)),_nullishCoalesce(t, () => (y)))!=null)return window.location.href=window.location.href.replaceAll("login",""),null;let[d,k]=_react3.useState.call(void 0, !1),x=l=>/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(l.trim())?k(!0):k(!1),u=l=>{let{value:b}=l.target;x(b),a(b)};function h(){r()}function C(l){l.preventDefault(),o()}return _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex max-w-sm flex-1 flex-col justify-center space-y-12",children:_jsxruntime.jsx.call(void 0, "div",{className:_chunkQ25D7OAOjs.d.call(void 0, "flex min-w-sm flex-col gap-6"),children:_jsxruntime.jsxs.call(void 0, de,{children:[_jsxruntime.jsxs.call(void 0, ye,{children:[_jsxruntime.jsx.call(void 0, be,{className:"text-2xl",children:"Zaloguj si\u0119"}),_jsxruntime.jsx.call(void 0, Tt,{children:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz."})]}),_jsxruntime.jsx.call(void 0, ue,{children:_jsxruntime.jsxs.call(void 0, "form",{onSubmit:C,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-6",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"grid gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.a,{htmlFor:"email",children:"Email"}),_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.r,{id:"email",onChange:u,type:"email",placeholder:"m@example.com",required:!0}),_jsxruntime.jsx.call(void 0, "span",{className:_chunkQ25D7OAOjs.d.call(void 0, !d&&n.length>0?"font-bold text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!d&&n.length>0?"Nieprawid\u0142owy adres email":"Wpisz sw\xF3j adres email"})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{type:"submit",disabled:i,className:"relative w-full",onClick:o,children:[i&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, V,{})}),"Zaloguj si\u0119"]}),c.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xs font-medium text-red-500",children:c})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-4 text-center text-sm",children:["Masz ju\u017C kod?"," ",_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:h,className:"underline underline-offset-4",children:"Mam ju\u017C kod"})]})]})})]})})})},Vr=({projectID:e,host:t,email:r,reveal:n,setEmail:a,isLoginLoading:o,loginUserResponse:i,setLoginUserResponse:c,setResponseStatus:s,errMsg:y})=>{let d=_chunkWGJTXDISjs.m.call(void 0, ),{mutateAsync:k,isPending:x}=_chunkUFIOJGJZjs.l.call(void 0, _chunkUFIOJGJZjs.j.publicApi.userPanelLoginWithCode),[u,h]=_react3.useState.call(void 0, ""),[C,l]=_react3.useState.call(void 0, !1),[b,R]=_react3.useState.call(void 0, !1),[F,q]=_react3.useState.call(void 0, 0),A=U=>/^\d+$/.test(U.trim())?l(!0):l(!1),L=U=>{A(U),h(U)};async function j(){if(R(!0),u.length==0){l(!1);return}let U=parseInt(u),K=await k({code:U}),fe,xe,ne;if(K.result.case==="accessToken"?(l(!0),fe="ok",xe=void 0,ne=K.result.value):(l(!1),fe="error",xe=K.result.value,ne=void 0),fe==="error"&&(l(!1),console.warn("error:",`Kod b\u0142\u0119du: ${xe}`),console.warn("Nieprawid\u0142owy kod, spr\xF3buj ponownie.")),fe==="ok"){d.track("panel_login",{}),ne&&_chunk3IVLQILFjs.l.call(void 0, e,ne,r,t);let g=typeof window<"u"?Ue():null;setTimeout(()=>{if(ne&&g){window.location.href=Oe(g,ne);return}window.location.reload()},100)}}function D(){let U=setInterval(()=>{q(K=>K>0?K-1:(clearInterval(U),0))},1e3);return()=>{clearInterval(U)}}_react3.useEffect.call(void 0, ()=>{_optionalChain([i, 'optionalAccess', _4 => _4.status])==="ok"&&_optionalChain([i, 'optionalAccess', _5 => _5.retryIn])>0&&(q(i.retryIn),D())},[i]);function H(){a(""),c(null),s("default"),n()}function pe(U){U.preventDefault(),j()}return _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex max-w-md flex-1 flex-col justify-center space-y-8",children:_jsxruntime.jsx.call(void 0, "div",{className:_chunkQ25D7OAOjs.d.call(void 0, "flex min-w-sm flex-col gap-6"),children:_jsxruntime.jsxs.call(void 0, de,{children:[_jsxruntime.jsxs.call(void 0, ye,{children:[_jsxruntime.jsx.call(void 0, be,{className:"text-2xl",children:"Wpisz kod z maila"}),_jsxruntime.jsx.call(void 0, Tt,{children:"Sprawd\u017A czy przypadkiem nie wyl\u0105dowa\u0142 w spamie."})]}),_jsxruntime.jsxs.call(void 0, ue,{children:[_jsxruntime.jsxs.call(void 0, "form",{onSubmit:pe,className:"flex flex-col gap-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"grid gap-2",children:_jsxruntime.jsx.call(void 0, "div",{className:"my-5 flex w-full items-center justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-2",children:[_jsxruntime.jsxs.call(void 0, In,{id:"verify-code",maxLength:6,pattern:_inputotp.REGEXP_ONLY_DIGITS,onChange:U=>{L(U)},children:[_jsxruntime.jsxs.call(void 0, Lt,{children:[_jsxruntime.jsx.call(void 0, Se,{index:0}),_jsxruntime.jsx.call(void 0, Se,{index:1}),_jsxruntime.jsx.call(void 0, Se,{index:2})]}),_jsxruntime.jsx.call(void 0, Rn,{}),_jsxruntime.jsxs.call(void 0, Lt,{children:[_jsxruntime.jsx.call(void 0, Se,{index:3}),_jsxruntime.jsx.call(void 0, Se,{index:4}),_jsxruntime.jsx.call(void 0, Se,{index:5})]})]}),_jsxruntime.jsx.call(void 0, "span",{className:_chunkQ25D7OAOjs.d.call(void 0, !C&&b?"text-red-500":"text-neutral-700 dark:text-neutral-400","text-xs"),children:!C&&b?u.length==0?"Kod nie mo\u017Ce by\u0107 pusty":"Kod musi sk\u0142ada\u0107 si\u0119 z cyfr":"Wpisz kod z maila"})]})})}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{type:"submit",disabled:o||x,className:"relative w-full",children:[(o||x)&&_jsxruntime.jsx.call(void 0, "div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:_jsxruntime.jsx.call(void 0, V,{})}),"Zaloguj si\u0119"]}),y.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xs font-medium text-red-500",children:y})]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-4 text-center text-sm",children:["Nie masz kodu?"," ",_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:H,className:"underline underline-offset-4",children:"Wr\xF3\u0107"})]})]})]})})})},Wr=({analytics:e})=>{let{theme:t,allowedReturnOrigins:r,projectID:n,host:a}=_chunk3IVLQILFjs.j.call(void 0, ),o=_chunkWGJTXDISjs.n.call(void 0, n,e,"panel"),i={"--button-background-color":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _6 => _6.colors, 'optionalAccess', _7 => _7.brand]), () => ("#FFFFFF")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _8 => _8.colors, 'optionalAccess', _9 => _9.brandDark]), () => ("#000000")),"--button-text-color":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _10 => _10.colors, 'optionalAccess', _11 => _11.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([t, 'optionalAccess', _12 => _12.colors, 'optionalAccess', _13 => _13.brand]), () => ("#FFFFFF"))},[c,s]=_react3.useState.call(void 0, "login"),[y]=_react.useAutoAnimate.call(void 0, {duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1}),d=()=>s(L=>L==="login"?"verifyCode":"login"),[k,x]=_react3.useState.call(void 0, ""),[u,h]=_react3.useState.call(void 0, "default"),[C,l]=_react3.useState.call(void 0, null),{mutateAsync:b,isPending:R}=_chunkUFIOJGJZjs.l.call(void 0, _chunkUFIOJGJZjs.j.publicApi.userPanelLogin),[F,q]=_react3.useState.call(void 0, "");_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window)return;let L=Ze(window.location.search);L&&Je(L);let j=_nullishCoalesce(L, () => (Ue()));if(!j)return;let D=_chunk3IVLQILFjs.k.call(void 0, n,a);D&&(window.location.href=Oe(j,D))},[r,n,a]);async function A(){q(""),h("default");let L=await b({email:k}),j=L.result.case==="success"?"ok":"error",D=0,H;L.result.case==="success"&&(D=L.result.value.retryIn),j==="error"&&(H="Nieprawid\u0142owy adres email, spr\xF3buj ponownie."),l({status:j,retryIn:D,message:H}),j==="ok"&&c==="login"?d():j==="ok"&&c==="verifyCode"?h("success"):j==="error"&&q(_nullishCoalesce(H, () => ("Nieprawid\u0142owy adres email, spr\xF3buj ponownie.")))}return _jsxruntime.jsx.call(void 0, _chunkWGJTXDISjs.l,{value:o,children:_jsxruntime.jsx.call(void 0, "div",{className:"bg-white text-black dark:bg-black dark:text-white",children:_jsxruntime.jsxs.call(void 0, "div",{className:"font-inter flex h-screen w-screen flex-col p-4",style:i,ref:y,children:[_jsxruntime.jsxs.call(void 0, "header",{children:[_optionalChain([t, 'optionalAccess', _14 => _14.logoDarkURL])&&_jsxruntime.jsx.call(void 0, "img",{src:_optionalChain([t, 'optionalAccess', _15 => _15.logoDarkURL]),className:"hidden dark:inline",alt:"Company Logo",draggable:!1}),_optionalChain([t, 'optionalAccess', _16 => _16.logoURL])&&_jsxruntime.jsx.call(void 0, "img",{src:_optionalChain([t, 'optionalAccess', _17 => _17.logoURL]),className:"dark:hidden",alt:"Company Logo",draggable:!1})]}),c==="login"&&_jsxruntime.jsx.call(void 0, $r,{projectID:n,host:a,reveal:d,email:k,setEmail:x,loginUser:A,isLoginLoading:R,errMsg:F}),c==="verifyCode"&&_jsxruntime.jsx.call(void 0, Vr,{projectID:n,host:a,email:k,reveal:d,setEmail:x,loginUser:A,isLoginLoading:R,loginUserResponse:C,setLoginUserResponse:l,responseStatus:u,setResponseStatus:h,errMsg:F})]})})})},Zr= exports.n =({analytics:e}={})=>_jsxruntime.jsx.call(void 0, Wr,{analytics:e});function Tn(e){let[t,r]=_react3.useState.call(void 0, ()=>{if(typeof window>"u")return e;let a=new URLSearchParams(window.location.search),o={};return Object.keys(e).forEach(i=>{let c=a.get(i);if(c!==null)try{o[i]=JSON.parse(c)}catch (e3){o[i]=c}}),{...e,...o}}),n=_react3.useCallback.call(void 0, a=>{r(o=>{let i={...o,...a};if(typeof window<"u"){let c=new URLSearchParams;Object.keys(i).forEach(y=>{let d=i[y];d!=null&&c.set(y,JSON.stringify(d))});let s=`${window.location.pathname}?${c.toString()}`;window.history.pushState({},"",s)}return i})},[]);return _react3.useEffect.call(void 0, ()=>{let a=()=>{let o=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(c=>{let s=o.get(c);if(s!==null)try{i[c]=JSON.parse(s)}catch (e4){i[c]=s}}),r({...e,...i})};return window.addEventListener("popstate",a),()=>window.removeEventListener("popstate",a)},[e]),[t,n]}function Ln(e,t){if(e!=null)return e;let r=_optionalChain([t, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]);if(!(r==null||r===""))return{tokens:_chunkUFIOJGJZjs.t.call(void 0, r)}}var _reactswitch = require('@radix-ui/react-switch'); var ct = _interopRequireWildcard(_reactswitch);function Un({className:e,...t}){return _jsxruntime.jsx.call(void 0, ct.Root,{"data-slot":"switch",className:_chunkQ25D7OAOjs.d.call(void 0, "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:_jsxruntime.jsx.call(void 0, ct.Thumb,{"data-slot":"switch-thumb",className:_chunkQ25D7OAOjs.d.call(void 0, "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function Xr({}){let[e,t]=_react3.useState.call(void 0, {disableAll:!1});return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Powiadomienia"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-2",children:[_jsxruntime.jsx.call(void 0, Un,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:r=>t(n=>({...n,disableAll:r}))}),_jsxruntime.jsxs.call(void 0, _chunkUCL4Y7L3js.a,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var On=Xr;function zn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:_chunkQ25D7OAOjs.d.call(void 0, "mx-auto flex w-full justify-center",e),...t})}function Mn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "ul",{"data-slot":"pagination-content",className:_chunkQ25D7OAOjs.d.call(void 0, "flex flex-row items-center gap-1",e),...t})}function Pe({...e}){return _jsxruntime.jsx.call(void 0, "li",{"data-slot":"pagination-item",...e})}function ze({className:e,isActive:t,size:r="icon",...n}){return _jsxruntime.jsx.call(void 0, "a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:_chunkQ25D7OAOjs.d.call(void 0, _chunkUFIOJGJZjs.p.call(void 0, {variant:t?"outline":"ghost",size:r}),e),...n})}function _n({className:e,...t}){return _jsxruntime.jsxs.call(void 0, ze,{"aria-label":"Go to previous page",size:"default",className:_chunkQ25D7OAOjs.d.call(void 0, "gap-1 px-2.5 sm:pl-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeftIcon,{}),_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Previous"})]})}function jn({className:e,...t}){return _jsxruntime.jsxs.call(void 0, ze,{"aria-label":"Go to next page",size:"default",className:_chunkQ25D7OAOjs.d.call(void 0, "gap-1 px-2.5 sm:pr-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Next"}),_jsxruntime.jsx.call(void 0, _lucidereact.ChevronRightIcon,{})]})}function zt({className:e,...t}){return _jsxruntime.jsxs.call(void 0, "span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:_chunkQ25D7OAOjs.d.call(void 0, "flex size-9 items-center justify-center",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.MoreHorizontalIcon,{className:"size-4"}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"More pages"})]})}var oa=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),ia=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),sa={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},la={draft:"text-neutral-400",unpaid:"text-yellow-500",paid:"text-green-600",overdue:"text-red-500",cancelled:"text-neutral-400 line-through",completed:"text-green-600",processing:"text-blue-500",refunded:"text-purple-500"};function ca({openOrderDetails:e,projectID:t,accessToken:r}){let[n,a]=_react3.useState.call(void 0, 0),o=20,{data:i,isFetching:c}=_chunkUFIOJGJZjs.k.call(void 0, _chunkUFIOJGJZjs.j.publicApi.getOrders,{projectId:t,accessToken:r,offset:n,limit:o}),s=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _20 => _20.orders]), () => ([])),y=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _21 => _21.totalCount]), () => (0)),d=Math.floor(n/o)+1,k=Math.ceil(y/o),x=u=>{a(u)};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),c?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,h)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.u,{className:"h-4 w-24"}),_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.u,{className:"h-3 w-32"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2 text-right",children:[_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.u,{className:"ml-auto h-4 w-16"}),_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.u,{className:"ml-auto h-3 w-12"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-3",children:_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.u,{className:"h-3 w-40"})})]},h))}):s.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:s.map(u=>_jsxruntime.jsxs.call(void 0, "button",{onClick:()=>e(u.id),className:"block rounded-xl bg-white p-4 text-left shadow-sm transition-colors hover:bg-neutral-50 dark:bg-neutral-800 dark:hover:bg-neutral-700",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:ia(u.totalAmount,u.currency)}),_jsxruntime.jsx.call(void 0, "p",{className:`text-xs font-medium ${_nullishCoalesce(la[u.status], () => ("text-neutral-400"))}`,children:_nullishCoalesce(sa[u.status], () => (u.status))})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:_jsxruntime.jsxs.call(void 0, "span",{children:["Data:"," ",u.createdAt?oa(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),k>1&&!c&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-4 flex justify-center",children:_jsxruntime.jsx.call(void 0, zn,{children:_jsxruntime.jsxs.call(void 0, Mn,{children:[d>1&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, _n,{onClick:()=>x(n-o)})}),d>2&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, ze,{onClick:()=>x(0),children:"1"})}),d>3&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, zt,{})}),[d-1,d,d+1].filter(u=>u>0&&u<=k).map(u=>_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, ze,{onClick:()=>x((u-1)*o),isActive:d===u,children:u})},u)),d<k-2&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, zt,{})}),d<k&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, ze,{onClick:()=>x((k-1)*o),children:k})}),d<k&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, jn,{onClick:()=>x(n+o)})})]})})})]})]})}var Fn=ca;var Bn=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),ua={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},ma={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function pa({projectID:e}){let[t,r]=_react3.useState.call(void 0, []),[n,a]=_react3.useState.call(void 0, !0);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Plany"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),n?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-col gap-4",children:t.map(o=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-start justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:o.tierName}),o.configName&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:o.configName})]}),_jsxruntime.jsx.call(void 0, "span",{className:`text-sm font-medium ${_nullishCoalesce(ma[o.status], () => ("text-neutral-500"))}`,children:_nullishCoalesce(ua[o.status], () => (o.status))})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",o.billingDay]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data startu:"})," ",Bn(o.startDate)]}),o.endDate&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",Bn(o.endDate)]})]})]},o.id))})]})}var Hn=pa;function ya(e,t,r,n){typeof window>"u"||(t&&_chunk3IVLQILFjs.n.call(void 0, r,n),window.location.href=e)}function ba({projectID:e,host:t,loginURL:r,screen:n,params:a,setParams:o,setActiveScreen:i}){let{status:c,exchangeError:s}=_chunkUCL4Y7L3js.j.call(void 0, "PanelReturns"),y=_chunkUCL4Y7L3js.i.call(void 0, ),d=c==="anonymous"&&(s==null||_chunkUCL4Y7L3js.g.call(void 0, s));_react3.useEffect.call(void 0, ()=>{d&&ya(r,s!=null,e,t)},[d,r,s,e,t]);let[k,x]=_react3.useState.call(void 0, "orders"),[u,h]=_react3.useState.call(void 0, {items:[],note:""}),[C,l]=_react3.useState.call(void 0, );if(c==="anonymous"&&!d)return _jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"flex flex-col items-start gap-3",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:y(_chunkUCL4Y7L3js.h.call(void 0, s))}),_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.q,{type:"button",onClick:()=>window.location.reload(),children:y("errorRetry")})]});if(c!=="authenticated")return _jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.s,{});let b=R=>{x(R),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(n==="return-details"&&a.returnId)return _jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.A,{returnId:a.returnId,onBack:()=>b("myReturns")});if(k==="myReturns")return _jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.z,{onBack:()=>b("orders"),onSelectReturn:R=>{o({state:"return-details",returnId:R,orderId:void 0}),i("return-details")}});if(k==="result"&&C!=null)return _jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.y,{returnId:C,onContinue:()=>b("orders"),onOpenMyReturns:()=>b("myReturns")});if(a.orderId){let R=a.orderId;return k==="confirmation"?_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.x,{orderId:R,items:u.items,note:u.note,onBack:()=>x("orders"),onSubmitted:F=>{l(F),h({items:[],note:""}),x("result"),o({orderId:void 0})}}):_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.w,{orderId:R,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{h({items:[],note:""}),o({orderId:void 0})},onContinue:F=>{h(F),x("confirmation")}})}return _jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.v,{showLogout:!1,onSelectOrder:R=>{h({items:[],note:""}),x("orders"),o({orderId:R})},onOpenMyReturns:()=>b("myReturns")})}function jt({accessToken:e,appearance:t,texts:r,...n}){return _jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.k,{projectID:n.projectID,host:n.host,appearance:t,texts:r,panelAccessToken:e,children:_jsxruntime.jsx.call(void 0, ba,{...n})})}var ha=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,va=e=>[...e.matchAll(ha)].map(r=>({url:r[0],startIndex:r.index,endIndex:r.index+r[0].length-1})),wa=(e,t)=>{let r="",n=0;t.sort((a,o)=>a.startIndex-o.startIndex);for(let{startIndex:a,endIndex:o,replacementText:i}of t)r+=e.slice(n,a),r+=i,n=o+1;return r+=e.slice(n),r},Gn=e=>{let t=va(e);return _jsxruntime.jsx.call(void 0, "p",{dangerouslySetInnerHTML:{__html:wa(e,t.map(r=>(r.replacementText=`<a key=${r.url} href=${r.url} style="text-decoration: underline;" target="_blank">
2
- ${r.url}
3
- </a>`,r)))}})};var _protobuf = require('@bufbuild/protobuf');var _hlsjs = require('hls.js'); var _hlsjs2 = _interopRequireDefault(_hlsjs);function $n(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="playing")}function Vn(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="paused")}function Wn(e,t){typeof navigator>"u"||typeof navigator.mediaSession>"u"||e!=null&&isNaN(e)||t!=null&&isNaN(t)||navigator.mediaSession.setPositionState({playbackRate:1,duration:e,position:t})}function Zn(e){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.metadata=new MediaMetadata({title:e.title,artwork:e.artwork?[{type:"image/png",src:e.artwork}]:void 0}),navigator.mediaSession.setActionHandler("play",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("pause",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("stop",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekbackward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekforward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekto",t=>{e.action(t)}))}function Jn(){navigator.mediaSession.metadata=null}var Ia=_react3.forwardRef.call(void 0, ({chapters:e,styles:t,updateCurrentTime:r,setCurrentTimeHandler:n,title:a,imageURL:o,uniqueProductID:i,onChapterChange:c},s)=>{let y;(G=>(G[G.Playing=0]="Playing",G[G.Paused=1]="Paused"))(y||={});let[d,k]=_react3.useState.call(void 0, 1);_react3.useEffect.call(void 0, ()=>{switch(d){case 0:$n();break;case 1:Vn();break}},[d]),_react3.useImperativeHandle.call(void 0, s,()=>({selectChapter:p=>{He(p)}}));let[x,u]=_react3.useState.call(void 0, void 0),[h,C]=_react3.useState.call(void 0, void 0),l=_react3.useRef.call(void 0, null),b=_react3.useRef.call(void 0, void 0),R=_react3.useRef.call(void 0, void 0),F=_react3.useRef.call(void 0, null),q=_react3.useRef.call(void 0, null),[A,L]=_react3.useState.call(void 0, !0),[j,D]=_react3.useState.call(void 0, !1),[H,pe]=_react3.useState.call(void 0, !Ra());function U(p){p<10||localStorage.setItem(`__player__${i}_${_optionalChain([q, 'access', _22 => _22.current, 'optionalAccess', _23 => _23.id])}`,`${p}`)}function K(){let p=localStorage.getItem(`__player__${i}_${_optionalChain([q, 'access', _24 => _24.current, 'optionalAccess', _25 => _25.id])}`);if(p!=null)try{let O=parseInt(p);return isNaN(O)||O<0?void 0:O}catch (e5){return}}function fe(){let p=localStorage.getItem(`__player__${i}_last_chapter`);if(p!=null)return p}function xe(p){localStorage.setItem(`__player__${i}_last_chapter`,p)}function ne(p){localStorage.removeItem(`__player__${i}_${p}`)}function g(){l.current!=null&&(l.current.onloadeddata=()=>{if(l.current!=null){if(l.current.readyState<2&&pe(!0),l.current.readyState>=2&&pe(!1),!j){let p=K();p!=null&&ot(p),D(!0)}if(A){L(!1);try{vt()}catch(p){console.log("play error",p)}}}},l.current.onplay=()=>{},l.current.onseeked=()=>{},l.current.onseeking=()=>{},l.current.onpause=()=>{},l.current.onended=()=>{re()},Zn({title:_nullishCoalesce(a, () => ("")),artwork:o,action:p=>{switch(p.action){case"play":vt();break;case"pause":wt();break;case"seekbackward":at(-15);break;case"seekforward":at(15);break;case"seekto":p.seekTime&&ot(p.seekTime);break;case"stop":wt();break;default:break}}}),Ce())}function re(){if(e==null||e.length==0)return;let p=e.findIndex(G=>G.id==_optionalChain([q, 'access', _26 => _26.current, 'optionalAccess', _27 => _27.id]));p==-1||(ne(e[p].id),p+1>=e.length)||He(e[p+1])}function Ce(){Ie(),R.current==null&&(R.current=setTimeout(()=>{Ie(),R.current=void 0,Ce()},500))}function Be(){R.current!=null&&clearTimeout(R.current)}function Ie(){l.current!=null&&(k(l.current.paused?1:0),C(l.current.duration),u(l.current.currentTime),U(l.current.currentTime),Wn(l.current.duration,l.current.currentTime),l.current.networkState===l.current.NETWORK_LOADING&&l.current.readyState<=l.current.HAVE_FUTURE_DATA?pe(!0):pe(!1),r&&r(l.current.currentTime))}function vt(){_optionalChain([l, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.play, 'call', _30 => _30(), 'access', _31 => _31.then, 'call', _32 => _32(), 'access', _33 => _33.catch, 'call', _34 => _34()]),Ie()}function wt(){_optionalChain([l, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.pause, 'call', _37 => _37()]),Ie()}function Rr(){if(d===0){wt();return}vt()}function at(p){if(l.current==null)return;let O=l.current.currentTime+p;if(O<0){l.current.currentTime=0;return}if(O>l.current.duration){l.current.currentTime=l.current.duration;return}l.current.currentTime+=p}function ot(p){if(l.current!=null){if(u(p),p<0){l.current.currentTime=0;return}if(p>l.current.duration){l.current.currentTime=l.current.duration;return}l.current.currentTime=p}}function Ar(){l.current!=null&&(l.current.onplay=null,l.current.onseeked=null,l.current.onseeking=null,l.current.onpause=null,l.current.onended=null,l.current.src="",_optionalChain([b, 'access', _38 => _38.current, 'optionalAccess', _39 => _39.destroy, 'call', _40 => _40()]))}function tn(p){if(p.length==0)return;let O=fe();if(O==null){He(p[0]);return}let G=p.find(Re=>Re.id==O);if(G==null){He(p[0]);return}He(G)}function He(p){D(!1),L(!0),q.current=p,Dr(p.publicUrl),_optionalChain([c, 'optionalCall', _41 => _41(p)]),xe(p.id)}function Dr(p){l.current!=null&&(l.current.canPlayType("application/vnd.apple.mpegurl")?l.current.src=p:_hlsjs2.default.isSupported()&&(b.current==null&&(b.current=new _hlsjs2.default,_optionalChain([b, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.attachMedia, 'call', _44 => _44(l.current)])),_optionalChain([b, 'access', _45 => _45.current, 'optionalAccess', _46 => _46.loadSource, 'call', _47 => _47(p)])))}_react3.useEffect.call(void 0, ()=>{l.current!=null&&(g(),tn(e))},[l.current]),_react3.useEffect.call(void 0, ()=>{tn(e)},[e]),_react3.useEffect.call(void 0, ()=>(_optionalChain([n, 'optionalCall', _48 => _48(ot)]),()=>{u(void 0),_optionalChain([l, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.pause, 'call', _51 => _51()]),Ar(),Jn()}),[]);let nn=p=>{let O=Math.floor(p/3600),G=Math.floor(p/60)%60,Re=Math.floor(p%60),Lr=O>0?O<10?`0${O}:`:`${O}:`:"",Er=Re<10?`0${Re}`:`${Re}`;return isNaN(Re)||isNaN(G)||isNaN(O)?"":`${Lr}${G}:${Er}`},Tr=p=>{let O=parseFloat(p.value)/parseFloat(p.max)*100;F.current.style.setProperty("--seek-before-width",O+"%");let G=h*O/100;ot(G)};return _jsxruntime.jsxs.call(void 0, "div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:F,children:[_jsxruntime.jsx.call(void 0, "video",{ref:l,className:"hidden",poster:o,title:a}),_jsxruntime.jsx.call(void 0, "input",{type:"range",min:"0",max:h!=null?Math.floor(h).toString():100,value:_nullishCoalesce(x, () => (0)),onChange:p=>Tr(p.target),className:"w-full"}),_jsxruntime.jsxs.call(void 0, "section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[_jsxruntime.jsx.call(void 0, "span",{id:"current-time",children:nn(x)}),_jsxruntime.jsx.call(void 0, "span",{id:"duration",children:nn(h)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.q,{variant:"outline",onClick:()=>at(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),_jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{variant:"outline",onClick:Rr,"aria-label":"Play Or Pause",children:[d===1&&_jsxruntime.jsx.call(void 0, _lucidereact.Play,{className:"h-5 w-5"}),d===0&&_jsxruntime.jsx.call(void 0, _lucidereact.Pause,{className:"h-5 w-5"})]}),_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.q,{variant:"outline",onClick:()=>at(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),H&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex w-full justify-center",children:_jsxruntime.jsx.call(void 0, V,{})})]})});function Ra(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1}var Qn=Ia;var Aa={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs"},en:{returnsNavLabel:"Returns",openCourse:"Open the course"}};function Ye(e=_chunkQ25D7OAOjs.m.call(void 0, )){return _chunkQ25D7OAOjs.h.call(void 0, Aa,e)}function Xn(){let[e,t]=mt.useState(13);return mt.useEffect(()=>{let r=setTimeout(()=>t(66),500);return()=>clearTimeout(r)},[]),_jsxruntime.jsx.call(void 0, "div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}function me(e,...t){console.warn(e,...t)}function Ft(e){console.error(e)}var La=({accessToken:e,product:t,styles:r,reveal:n,onOpenCourse:a})=>{let o=t.productType,i=_chunkWGJTXDISjs.m.call(void 0, ),c=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),s=_react3.useRef.call(void 0, null),[y]=_react.useAutoAnimate.call(void 0, ),[d,k]=_react3.useState.call(void 0, null),{mutateAsync:x,isPending:u}=_chunkUFIOJGJZjs.l.call(void 0, _chunkUFIOJGJZjs.j.publicApi.userPanelGetFileDetails),h=_react3.useRef.call(void 0, void 0),[C,l]=_react3.useState.call(void 0, null),[b,R]=_react3.useState.call(void 0, null),[F,q]=_react3.useState.call(void 0, !1),{mutateAsync:A,isPending:L}=_chunkUFIOJGJZjs.l.call(void 0, _chunkUFIOJGJZjs.j.publicApi.userPanelGetAudiobookDetails),{mutateAsync:j,isPending:D}=_chunkUFIOJGJZjs.l.call(void 0, _chunkUFIOJGJZjs.j.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[H,pe]=_react3.useState.call(void 0, null),[U,K]=_react3.useState.call(void 0, null);async function fe(){try{let g=await x({accessId:t.accessId,accessToken:e});if(g.result.case==="success"){k(g.result.value.files);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Ft("B\u0142\u0105d podczas pobierania danych:"+g)}}async function xe(){try{let g=await A({accessId:t.accessId,accessToken:e});if(g.result.case==="audiobook"){l(g.result.value);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Ft("B\u0142\u0105d podczas pobierania danych:"+g)}}async function ne(){try{let g=await j({accessId:t.accessId,accessToken:e,isBrowser:!0});if(g.result.case==="success"){R(g.result.value.audiobookDownloadDetails),q(g.result.value.isAvailableToDownloadInMobileApp===!0);return}else me("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),me("Kod b\u0142\u0119du: ",g.result.value)}catch(g){me("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Ft("B\u0142\u0105d podczas pobierania danych:"+g)}}return _react3.useEffect.call(void 0, ()=>{o===1&&(xe().then().catch(),ne().then().catch())},[]),_react3.useEffect.call(void 0, ()=>{if(C!=null&&b!=null){let g=C.chapters;if(!g)return;let re=g.map(Ce=>{let Be=_optionalChain([b, 'optionalAccess', _52 => _52.find, 'call', _53 => _53(Ie=>Ie.chapterId===Ce.id)]);if(Be!=null)return{...Ce,publicUrl:Be.publicUrl,downloadableUrl:Be.downloadableUrl,duration:Be.duration}}).filter(Ce=>Ce!=null);re!=null&&re.length>0&&K(re)}},[C,b]),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:_jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{onClick:()=>n(),variant:"ghost",className:"w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-6 w-6"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-inter text-sm font-medium",children:"Wr\xF3\u0107"})]})}),_jsxruntime.jsxs.call(void 0, "main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full max-w-xl flex-col gap-6",children:[o===2&&_jsxruntime.jsxs.call(void 0, "div",{ref:y,className:"flex flex-col space-y-4 rounded bg-white p-6 drop-shadow-xl dark:border dark:border-neutral-700 dark:bg-neutral-800 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-x-4",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(d==null||d.length==0)&&_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.q,{onClick:fe,"aria-label":"Download Product",className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:u?_jsxruntime.jsx.call(void 0, V,{}):"Wy\u015Bwietl"})]}),u&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-2",children:[_jsxruntime.jsx.call(void 0, Xn,{}),_jsxruntime.jsx.call(void 0, "p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),d!=null&&d.length>0&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-start justify-start gap-2",children:d.map((g,re)=>_jsxruntime.jsxs.call(void 0, "a",{target:"_blank",className:"flex w-fit items-center gap-2 rounded-md bg-neutral-800 px-3 py-2 text-neutral-200 dark:bg-neutral-200 dark:text-neutral-800",href:g,download:!0,onClick:c,children:[`Plik numer ${re+1}`,_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})]},re))})]}),o===4&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.q,{onClick:()=>a(t.accessId),className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:Ye().openCourse})}),o===1&&_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col space-y-6 rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:_nullishCoalesce(_optionalChain([H, 'optionalAccess', _54 => _54.name]), () => ("Odtwarzacz"))}),_optionalChain([H, 'optionalAccess', _55 => _55.description])&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:_optionalChain([H, 'optionalAccess', _56 => _56.description])}),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:L?_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, V,{}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:U!=null?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsx.call(void 0, Qn,{ref:s,chapters:U,title:_nullishCoalesce(_nullishCoalesce(_optionalChain([C, 'optionalAccess', _57 => _57.name]), () => (t.productName)), () => (void 0)),imageURL:_nullishCoalesce(_nullishCoalesce(_optionalChain([C, 'optionalAccess', _58 => _58.coverImage]), () => (t.productImageUrl)), () => (void 0)),styles:r,setCurrentTimeHandler:g=>{h.current=g},uniqueProductID:t.productId,onChapterChange:g=>{pe(g)}})}):_jsxruntime.jsx.call(void 0, "p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 mb-3 text-xs",children:F?"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji r\xF3wnie\u017C bez dost\u0119pu do internetu.":"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji."}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-3",children:[_jsxruntime.jsx.call(void 0, "a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),_jsxruntime.jsx.call(void 0, "a",{href:"https://docs.bitsnap.pl/guides/audiobook",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:o===1&&_jsxruntime.jsx.call(void 0, "div",{className:"max-h-96 w-full overflow-y-auto",children:L?_jsxruntime.jsxs.call(void 0, "div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[_jsxruntime.jsx.call(void 0, V,{}),_jsxruntime.jsx.call(void 0, "p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),U==null?_jsxruntime.jsx.call(void 0, "p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):_jsxruntime.jsx.call(void 0, "ul",{className:"flex w-full flex-col gap-2",children:U.map((g,re)=>_jsxruntime.jsxs.call(void 0, "li",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "button",{className:_chunkQ25D7OAOjs.d.call(void 0, "w-full rounded-lg p-2 text-left transition hover:bg-neutral-200 active:bg-neutral-200 dark:hover:bg-neutral-700 dark:active:bg-neutral-700",_optionalChain([H, 'optionalAccess', _59 => _59.id])==g.id?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800 dark:text-neutral-300"),onClick:()=>{s.current.selectChapter(g)},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",children:g.name}),g.duration&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs text-neutral-500",children:[Math.floor(g.duration/60),":",String(Math.floor(g.duration%60)).padStart(2,"0")]})]}),g.description&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 text-xs",children:g.description})]}),C&&C.isDownloadable&&g.downloadableUrl&&_jsxruntime.jsx.call(void 0, "a",{href:g.downloadableUrl,onClick:c,children:_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})})]},re))})]})})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"w-full max-w-3xl space-y-6 rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-3xl font-semibold",children:t.productName}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),_jsxruntime.jsx.call(void 0, "img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},rr=La;var za=({accessToken:e,projectID:t,loginURL:r,styles:n,activeScreen:a,params:o,setParams:i,openCourse:c})=>{let{data:s,isLoading:y}=_chunkUFIOJGJZjs.k.call(void 0, _chunkUFIOJGJZjs.j.publicApi.userPanelGetProducts,{accessToken:e});if(y)return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-dark font-inter font-medium dark:text-white",children:"\u0141adowanie..."}),_jsxruntime.jsx.call(void 0, V,{})]});if(s&&s.result.case==="failure")return console.warn("error:",`Kod b\u0142\u0119du: ${s.result.value}`),_chunk3IVLQILFjs.n.call(void 0, t),window.location.href=r,null;let d=s&&s.result.case==="success"?s.result.value.products:[];return _jsxruntime.jsx.call(void 0, Ma,{accessToken:e,products:d,styles:n,loginURL:r,activeScreen:a,params:o,setParams:i,openCourse:c})},ar=za,Ma=({accessToken:e,products:t,styles:r,loginURL:n,activeScreen:a,params:o,setParams:i,openCourse:c})=>{if(t.length===0)return window.location.href=n,null;let[s,y]=_react3.useState.call(void 0, o.product?_protobuf.fromJsonString.call(void 0, _chunkUFIOJGJZjs.e,o.product):void 0),d=u=>{u==null?(y(void 0),i({product:void 0,state:"products"})):i({product:_protobuf.toJsonString.call(void 0, _chunkUFIOJGJZjs.e,u),state:"products"})};function k(u){switch(u){case 1:return"Audio";case 2:return"Plik";case 3:return"Bilet";case 4:return"Kurs";default:return}}function x(u){if(u.productType===4){c(u.accessId);return}y(u),d(u)}return a==="products"&&s!=null?_jsxruntime.jsx.call(void 0, rr,{accessToken:e,product:s,styles:r,reveal:d,onOpenCourse:c}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:_optionalChain([t, 'optionalAccess', _60 => _60.map, 'call', _61 => _61((u,h)=>_jsxruntime.jsxs.call(void 0, "section",{onClick:()=>x(u),className:"w-full max-w-xs cursor-pointer rounded drop-shadow-xl dark:border dark:border-slate-600 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&_jsxruntime.jsx.call(void 0, "div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium text-white dark:text-slate-100",children:k(u.productType)})}),_jsxruntime.jsx.call(void 0, "div",{className:"jusitfy-center flex max-h-40 items-center",children:_jsxruntime.jsx.call(void 0, "img",{src:u.productImageUrl,alt:`Product ${h} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-xl font-semibold",children:u.productName}),_jsxruntime.jsx.call(void 0, "p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:Gn(u.productDescription)}),_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.q,{onClick:C=>{C.stopPropagation(),x(u)},className:"w-full text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:r,children:"Zobacz"})]})]},h))])})]})};function Ba({activeScreen:e,setActiveScreen:t,setParams:r,styles:n,theme:a,logout:o}){return _jsxruntime.jsxs.call(void 0, "header",{className:"md:border-r-neutral-150 md:bg-beige-50 fixed right-0 bottom-0 left-0 z-10 flex h-12 w-full items-center bg-neutral-800 md:static md:z-0 md:min-h-screen md:w-auto md:border-r dark:md:border-r-neutral-900",children:[_jsxruntime.jsx.call(void 0, Ha,{activeScreen:e,setActiveScreen:t,setParams:r}),_jsxruntime.jsx.call(void 0, Ga,{activeScreen:e,setActiveScreen:t,setParams:r,theme:a,logout:o})]})}var sr=Ba;function Ha({activeScreen:e,setActiveScreen:t,setParams:r}){let{returnsNavLabel:n}=Ye();return _jsxruntime.jsxs.call(void 0, "nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[_jsxruntime.jsx.call(void 0, ft,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r}),_jsxruntime.jsx.call(void 0, ft,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r}),_jsxruntime.jsx.call(void 0, ft,{panelScreen:"returns",label:n,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:r}),_jsxruntime.jsx.call(void 0, ft,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r})]})}function ft({panelScreen:e,label:t,imageURL:r,icon:n,activeScreen:a,setActiveScreen:o,setParams:i}){return _jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{onClick:()=>{o(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:_chunkQ25D7OAOjs.d.call(void 0, "flex flex-col gap-0",a===e?"opacity-100":"opacity-50"),children:[_nullishCoalesce(n, () => (_jsxruntime.jsx.call(void 0, "img",{src:r,alt:t,className:"scale-75"}))),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-white",children:t})]})}function gt({panelScreen:e,label:t,imageURL:r,darkImageURL:n,icon:a,activeScreen:o,setActiveScreen:i,setParams:c,isExpanded:s}){return _jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{onClick:()=>{i(e),c({product:void 0,state:e})},variant:o===e?"secondary":"ghost",className:"justify-start",children:[a!=null?_jsxruntime.jsx.call(void 0, "span",{className:_chunkQ25D7OAOjs.d.call(void 0, "inline-flex h-5 w-5 items-center justify-center",s?"mr-4":"mr-2"),children:a}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:r,alt:t,className:_chunkQ25D7OAOjs.d.call(void 0, "aspect-auto h-5 w-5 dark:hidden",s?"mr-4":"mr-2")}),_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:_chunkQ25D7OAOjs.d.call(void 0, "hidden aspect-auto h-5 w-5 dark:inline",s?"mr-4":"mr-2")})]}),s&&_jsxruntime.jsx.call(void 0, "span",{className:"md:text-medium hidden md:inline",children:t})]})}function Ga({activeScreen:e,setActiveScreen:t,setParams:r,theme:n,logout:a}){let[o]=_react.useAutoAnimate.call(void 0, ),[i,c]=_react3.useState.call(void 0, !0),{returnsNavLabel:s}=Ye();return _jsxruntime.jsxs.call(void 0, "div",{ref:o,className:_chunkQ25D7OAOjs.d.call(void 0, "hidden px-4 pt-4 pb-12 md:flex md:h-full md:flex-col dark:bg-neutral-900",i?"md:w-52":"md:w-16"),children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-between",children:_jsxruntime.jsx.call(void 0, $a,{theme:n,isExpanded:i})}),_jsxruntime.jsx.call(void 0, or,{className:"my-6"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-1 flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, gt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),_jsxruntime.jsx.call(void 0, gt,{panelScreen:"orders",label:"Zam\xF3wienia",imageURL:"/icons/category-dark-24x24.svg",darkImageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),_jsxruntime.jsx.call(void 0, gt,{panelScreen:"returns",label:s,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i}),_jsxruntime.jsx.call(void 0, gt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:r,isExpanded:i})]}),_jsxruntime.jsx.call(void 0, or,{className:"mb-6"}),_jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{onClick:a,children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),i&&_jsxruntime.jsx.call(void 0, "p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function or({className:e}){return _jsxruntime.jsxs.call(void 0, "div",{className:_chunkQ25D7OAOjs.d.call(void 0, "relative h-px w-full bg-neutral-300",e),children:[_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function $a({theme:e,isExpanded:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[e==null&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(_optionalChain([e, 'optionalAccess', _62 => _62.logoDarkURL])||_optionalChain([e, 'optionalAccess', _63 => _63.logoURL]))&&_jsxruntime.jsx.call(void 0, "img",{src:_nullishCoalesce(e.logoDarkURL, () => (e.logoURL)),alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),_optionalChain([e, 'optionalAccess', _64 => _64.logoURL])&&_jsxruntime.jsx.call(void 0, "img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}function Wa({email:e,logout:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Profil"}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex-1 md:flex-none",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm text-neutral-500",children:"Email"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex w-full flex-col items-center space-y-2",children:_jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{onClick:t,className:"max-w-64 md:hidden",children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),_jsxruntime.jsx.call(void 0, "p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var cr=Wa;var Qa=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./course.js"))).then(e=>({default:e.PanelCourse})));function Bt(e){return _jsxruntime.jsx.call(void 0, _react3.Suspense,{fallback:_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-2 p-2",role:"status",children:_jsxruntime.jsx.call(void 0, V,{})}),children:_jsxruntime.jsx.call(void 0, Qa,{...e})})}function to({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:_lucidereact.CheckCircle2},completed:{color:"bg-blue-100 text-blue-700",icon:_lucidereact.CheckCircle2},canceled:{color:"bg-red-100 text-red-700",icon:_lucidereact.AlertCircle},sent:{color:"bg-purple-100 text-purple-700",icon:_lucidereact.Truck},processing:{color:"bg-yellow-100 text-yellow-700",icon:_lucidereact.Loader2}},r=t[e]||t.created,n=r.icon,a={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return _jsxruntime.jsxs.call(void 0, "span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${r.color}`,children:[n&&_jsxruntime.jsx.call(void 0, n,{className:"h-4 w-4"}),a[e]||e]})}function no({orderID:e,email:t}){let[r,n]=_react3.useState.call(void 0, ""),a=_chunkUFIOJGJZjs.l.call(void 0, _chunkUFIOJGJZjs.j.publicApi.addPublicOrderComment);return _jsxruntime.jsxs.call(void 0, "form",{onSubmit:async i=>{if(i.preventDefault(),!!r.trim())try{await a.mutateAsync({projectId:"",orderId:e,message:r.trim(),accessToken:t}),n("")}catch(c){console.error("Failed to add comment:",c)}},className:"mt-4 space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.a,{htmlFor:"comment",children:"Dodaj komentarz"}),_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.v,{id:"comment",value:r,onChange:i=>n(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:a.isPending}),_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.q,{type:"submit",disabled:!r.trim()||a.isPending,children:a.isPending?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function mr(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function pr(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function ro({orderID:e,initialEmail:t,onBack:r,accessToken:n,analytics:a}){let{theme:o,projectID:i}=_chunk3IVLQILFjs.j.call(void 0, ),c=_chunkWGJTXDISjs.n.call(void 0, i,a,"order"),[s,y]=_react3.useState.call(void 0, t||""),[d,k]=_react3.useState.call(void 0, !1),{data:x,isLoading:u,error:h,refetch:C}=_chunkUFIOJGJZjs.k.call(void 0, _chunkUFIOJGJZjs.j.publicApi.getPublicOrderDetails,{projectId:_nullishCoalesce(i, () => ("")),orderId:e,email:s||void 0,accessToken:n},{enabled:!!e}),l=_optionalChain([x, 'optionalAccess', _65 => _65.result, 'access', _66 => _66.case])==="order"?x.result.value:null,b=_nullishCoalesce(_optionalChain([l, 'optionalAccess', _67 => _67.isVerified]), () => (!1)),R=l!=null;_react3.useEffect.call(void 0, ()=>{R&&c.track("panel_order_viewed",{},{order_ref:null})},[c,R]);let F=()=>{C(),k(!1)},q={"--button-background-color":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _68 => _68.colors, 'optionalAccess', _69 => _69.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _70 => _70.colors, 'optionalAccess', _71 => _71.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _72 => _72.colors, 'optionalAccess', _73 => _73.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _74 => _74.colors, 'optionalAccess', _75 => _75.brand]), () => ("#000000"))};return u?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):h||!l?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsx.call(void 0, de,{className:"w-full max-w-md",children:_jsxruntime.jsx.call(void 0, ue,{className:"pt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle,{className:"mx-auto h-12 w-12 text-red-500"}),_jsxruntime.jsx.call(void 0, "h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):_jsxruntime.jsx.call(void 0, "div",{className:"w-full bg-white py-8 dark:bg-black",style:q,children:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full px-4",children:[r&&_jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{onClick:r,variant:"ghost",className:"mb-4 w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mb-6 flex items-center gap-4",children:[_optionalChain([o, 'optionalAccess', _76 => _76.logoURL])&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:o.logoURL,alt:"Project logo",className:`h-12 w-auto ${o.logoDarkURL?"dark:hidden":""}`}),o.logoDarkURL&&_jsxruntime.jsx.call(void 0, "img",{src:o.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",l.orderId]})]})]}),_jsxruntime.jsxs.call(void 0, de,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, ye,{children:_jsxruntime.jsxs.call(void 0, be,{className:"flex items-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Package,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),_jsxruntime.jsxs.call(void 0, ue,{className:"space-y-6",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, to,{status:l.status}),l.processingStatus&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm text-neutral-600",children:["\xB7 ",l.processingStatus]})]}),_jsxruntime.jsxs.call(void 0, "p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",mr(l.createdAt)]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:b?"":"text-neutral-500",children:l.customerName})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Email:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:b?"":"text-neutral-500",children:l.customerEmail})]}),l.customerPhone&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Telefon:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:b?"":"text-neutral-500",children:l.customerPhone})]})]})]}),!b&&_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{onClick:()=>k(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),_jsxruntime.jsxs.call(void 0, de,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, ye,{children:_jsxruntime.jsx.call(void 0, be,{children:"Produkty"})}),_jsxruntime.jsxs.call(void 0, ue,{className:"space-y-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:l.items.map((A,L)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[A.imageUrl&&_jsxruntime.jsx.call(void 0, "img",{src:A.imageUrl,alt:A.name,className:"h-16 w-16 rounded object-cover"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:A.name}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"text-right",children:_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:pr(Number(A.price),A.currency)})})]},L))}),(l.deliveryAddress||l.deliveryMethod)&&_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsxs.call(void 0, "h3",{className:"mb-3 flex items-center font-semibold",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Truck,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[l.deliveryAddress&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Adres:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:b?"":"text-neutral-500",children:l.deliveryAddress})]}),l.deliveryMethod&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Metoda:"})," ",l.deliveryMethod]}),l.trackingNumber&&b&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Tracking:"})," ",l.trackingNumber]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-lg font-bold",children:[_jsxruntime.jsx.call(void 0, "span",{children:"Suma:"}),_jsxruntime.jsx.call(void 0, "span",{children:pr(Number(l.totalAmount),l.currency)})]})})]})]}),_jsxruntime.jsxs.call(void 0, de,{children:[_jsxruntime.jsx.call(void 0, ye,{children:_jsxruntime.jsxs.call(void 0, be,{children:["Komentarze ",l.commentCount>0&&`(${l.commentCount})`]})}),_jsxruntime.jsxs.call(void 0, ue,{children:[l.comments.length>0?_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:l.comments.map(A=>_jsxruntime.jsxs.call(void 0, "div",{className:"border-b pb-4 last:border-b-0",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"mb-1 flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:A.authorName||"System"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500",children:mr(A.createdAt)}),A.authorType==="admin"&&_jsxruntime.jsx.call(void 0, "span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),_jsxruntime.jsx.call(void 0, "p",{className:b?"":"text-neutral-500",children:A.message})]},A.id))}):_jsxruntime.jsx.call(void 0, "p",{className:"text-neutral-600",children:"Brak komentarzy."}),b?_jsxruntime.jsx.call(void 0, no,{orderID:l.orderId,email:s}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-4",children:_jsxruntime.jsxs.call(void 0, _chunkUFIOJGJZjs.q,{onClick:()=>k(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),d&&_jsxruntime.jsx.call(void 0, "div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:_jsxruntime.jsxs.call(void 0, de,{className:"w-full max-w-md",children:[_jsxruntime.jsx.call(void 0, ye,{children:_jsxruntime.jsx.call(void 0, be,{children:"Zweryfikuj sw\xF3j email"})}),_jsxruntime.jsxs.call(void 0, ue,{className:"space-y-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.a,{htmlFor:"verify-email",children:"Adres email"}),_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.r,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:s,onChange:A=>y(A.target.value)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.q,{variant:"outline",onClick:()=>k(!1),className:"flex-1",children:"Anuluj"}),_jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.q,{onClick:F,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function ao(e){return _jsxruntime.jsx.call(void 0, ro,{...e})}var $t=ao;var so=({returnsAppearance:e,returnsTexts:t,analytics:r}={})=>{let{projectID:n,theme:a,loginURL:o,host:i}=_chunk3IVLQILFjs.j.call(void 0, ),c=_chunkWGJTXDISjs.n.call(void 0, n,r,"panel"),s=_chunk3IVLQILFjs.k.call(void 0, n,i),y=_chunk3IVLQILFjs.m.call(void 0, n,i),{mutateAsync:d}=_chunkUFIOJGJZjs.l.call(void 0, _chunkUFIOJGJZjs.j.publicApi.userPanelLogout);async function k(){s&&await d({accessToken:s}),typeof window<"u"&&(_chunk3IVLQILFjs.n.call(void 0, n,i),window.location.reload())}let[x]=_react.useAutoAnimate.call(void 0, ),u=D=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(D),[h,C]=Tn({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[l,b]=_react3.useState.call(void 0, u(h.state)?h.state:"products"),R=D=>{C({state:"order-details",orderId:D}),b("order-details")},F=()=>{C({state:"orders",orderId:void 0}),b("orders")},q=D=>C({orderId:void 0,returnId:void 0,course:void 0,item:void 0,...D}),A=D=>{C({state:"course",course:D,item:void 0,product:void 0}),b("course")},L=()=>{C({state:"products",course:void 0,item:void 0,product:void 0}),b("products")};_react3.useEffect.call(void 0, ()=>{u(h.state)&&(h.state==="course"||l==="course")&&b(h.state)},[h.state]);let j={"--button-background-color":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _77 => _77.colors, 'optionalAccess', _78 => _78.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _79 => _79.colors, 'optionalAccess', _80 => _80.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _81 => _81.colors, 'optionalAccess', _82 => _82.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([a, 'optionalAccess', _83 => _83.colors, 'optionalAccess', _84 => _84.brand]), () => ("#000000"))};return _react3.useEffect.call(void 0, ()=>{if(s==null||s.length===0){window.location.href=_nullishCoalesce(o, () => ("/panel/login"));return}},[]),_react3.useEffect.call(void 0, ()=>{if(s==null||s.length===0){window.location.href=_nullishCoalesce(o, () => ("/panel/login"));return}},[l]),_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window||!s)return;let D=Ze(window.location.search);D&&Je(D);let H=_nullishCoalesce(D, () => (Ue()));H&&(window.location.href=Oe(H,s))},[s]),_jsxruntime.jsx.call(void 0, _chunkWGJTXDISjs.l,{value:c,children:_jsxruntime.jsxs.call(void 0, "div",{ref:x,className:"font-inter relative min-h-screen w-screen bg-beige-100 text-black dark:bg-black dark:text-white md:flex",children:[_jsxruntime.jsx.call(void 0, sr,{activeScreen:l,setActiveScreen:b,setParams:q,styles:j,theme:a,logout:k}),_jsxruntime.jsxs.call(void 0, "main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[l==="products"&&_jsxruntime.jsx.call(void 0, ar,{projectID:_nullishCoalesce(n, () => ("")),accessToken:s,loginURL:_nullishCoalesce(o, () => ("/panel/login")),styles:j,activeScreen:l,params:h,setParams:C,openCourse:A}),l==="course"&&h.course&&s&&_jsxruntime.jsx.call(void 0, Bt,{accessId:h.course,accessToken:s,theme:a,itemId:h.item,onItemChange:D=>C({item:D}),onBack:L}),l==="notifications"&&_jsxruntime.jsx.call(void 0, On,{}),l==="plans"&&_jsxruntime.jsx.call(void 0, Hn,{projectID:_nullishCoalesce(n, () => (""))}),l==="orders"&&_jsxruntime.jsx.call(void 0, Fn,{projectID:_nullishCoalesce(n, () => ("")),accessToken:_nullishCoalesce(s, () => ("")),openOrderDetails:R}),l==="order-details"&&h.orderId&&_jsxruntime.jsx.call(void 0, $t,{orderID:h.orderId,onBack:F}),(l==="returns"||l==="return-details")&&s&&_jsxruntime.jsx.call(void 0, jt,{projectID:_nullishCoalesce(n, () => ("")),host:i,accessToken:s,loginURL:_nullishCoalesce(o, () => ("/panel/login")),appearance:Ln(e,_optionalChain([a, 'optionalAccess', _85 => _85.colors, 'optionalAccess', _86 => _86.brand])),texts:t,screen:l,params:h,setParams:C,setActiveScreen:b}),l==="profile"&&_jsxruntime.jsx.call(void 0, cr,{email:y,logout:k})]})]})})},lo= exports.q =so;var _reactquery = require('@tanstack/react-query');var _connect = require('@connectrpc/connect');var _connectweb = require('@connectrpc/connect-web');var ve;(n=>{function e(a){return _connect.createClient.call(void 0, _chunkUFIOJGJZjs.f,r(a))}n.get=e;let t=new Map;function r(a){let o=t.get(a);return o==null&&(o=_connectweb.createConnectTransport.call(void 0, {useBinaryFormat:!0,baseUrl:a+"/api/rpc",interceptors:[_chunkQ25D7OAOjs.b]}),t.set(a,o)),o}})(ve = exports.a||={});var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);function _(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Pr(e,t){let r=typeof navigator>"u"?"pl-PL":navigator.language;return Intl.NumberFormat(r,{style:"currency",currency:t,currencyDisplay:"symbol"}).format(e/100)}var dc=_zod2.default.object({event:_zod2.default.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:_zod2.default.string().optional(),value:_zod2.default.number().optional(),currency:_zod2.default.string().optional(),content_name:_zod2.default.string().optional(),items:_zod2.default.array(_zod2.default.object({id:_zod2.default.string(),name:_zod2.default.string(),price:_zod2.default.number().default(0),currency:_zod2.default.string().default("PLN"),quantity:_zod2.default.number().default(1)})).optional()});function Vt(e){typeof window>"u"||(mo(e),fo(e),go(e))}function mo(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=po(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function po(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _87 => _87.items, 'optionalAccess', _88 => _88.reduce, 'call', _89 => _89((o,i)=>o+(i.price||0)*(i.quantity||1),0)]))), () => (0)),r=_optionalChain([e, 'access', _90 => _90.items, 'optionalAccess', _91 => _91.map, 'call', _92 => _92(o=>({item_id:o.id,item_name:o.name||o.id,price:_((o.price||0)/100,2),quantity:o.quantity||1}))]),n={currency:e.currency||"PLN",value:_(t/100,2)};r&&r.length>0&&(n.items=r);let a;switch(e.event){case"purchase":a="purchase",n.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":a="add_to_cart";break;case"viewCart":a="view_cart";break;case"removeFromCart":a="remove_from_cart";break;case"initiateCheckout":a="begin_checkout";break;case"customizeProduct":a="customize_product";break;default:a=e.event}return{event:a,ecommerce:n,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function fo(e){if(typeof window.fbq>"u")return;let t="",r="",n={};switch(e.event){case"purchase":t="track",r="Purchase",n={category_name:e.step,...e};break;case"lead":t="track",r="Lead",n={category_name:e.step,...e};break;case"addToCart":t="track",r="Add to Cart",n={category_name:e.step,...e};break;case"customizeProduct":t="track",r="Customize Product",n={category_name:e.step,...e};break;case"viewCart":t="track",r="View Cart",n={category_name:e.step,...e};break;case"removeFromCart":t="track",r="Remove from Cart",n={category_name:e.step,...e};break;case"initiateCheckout":t="track",r="Initiate Checkout",n={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,r,n),window.fbq(t,r,n)}function go(e){try{if(typeof window.ttq>"u")return;let t=yo(e);if(!t)return;window.location.search.includes("analytics")&&console.log("Pushing TikTok event",t.eventName,t.eventPayload),window.ttq.track(t.eventName,t.eventPayload)}catch(t){console.warn("cannot send tiktok analytics event",t)}}function yo(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _93 => _93.items, 'optionalAccess', _94 => _94.reduce, 'call', _95 => _95((o,i)=>o+(i.price||0)*(i.quantity||1),0)]))), () => (0)),r=_optionalChain([e, 'access', _96 => _96.items, 'optionalAccess', _97 => _97.map, 'call', _98 => _98(o=>({content_id:o.id,content_type:"product",content_name:o.name||o.id,quantity:o.quantity||1,price:_((o.price||0)/100,2)}))])||[];r.length===0&&e.content_name&&r.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:_(t/100,2)});let n={currency:e.currency||"PLN",value:_(t/100,2)};r.length>0&&(n.contents=r);let a=null;switch(e.event){case"purchase":a="Purchase";break;case"addToCart":a="AddToCart";break;case"initiateCheckout":a="InitiateCheckout";break;case"customizeProduct":a="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:a,eventPayload:n}}function hr(e){let{items:t,googlePayConfig:r,checkout:n,result:a,cartRequiresShipping:o}=e;if(a.totalAmount==null)return;let i=[];return o&&(i.push("SHIPPING_ADDRESS"),i.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:i,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:r.gateway,gatewayMerchantId:r.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:o},shippingAddressRequired:o,shippingOptionRequired:o,shippingOptionParameters:o?{shippingOptions:a.methods.slice(0,5).map(s=>({id:s.id,label:s.name+` - ${Pr(s.amount,a.currency)}`,description:_nullishCoalesce(s.description, () => (""))})),defaultSelectedOptionId:a.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:r.merchantId+"",merchantName:r.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"P\u0142atno\u015B\u0107 za koszyk",totalPrice:`${_(a.totalAmount/100,2)}`,currencyCode:a.currency,countryCode:a.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:bo(t,a.methods,_nullishCoalesce(a.selectedDeliveryMethod, () => ((a.methods.length>0?a.methods[0].id:void 0))),n.couponCode,a.couponValue)}}}function bo(e,t,r,n,a){let o=[],i=0;for(let s of e)s.details!=null&&(i+=s.details.price*s.quantity,o.push({label:s.details.name+" x "+s.quantity,price:`${_(s.details.price/100,2)}`,type:"LINE_ITEM",status:"FINAL"}));let c=t.find(s=>s.id===r);return c!=null&&o.push({label:c.name,price:`${_(c.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),n!=null&&a!=null&&o.push({label:`Kupon ${n}`,price:`${_(a/100,2)}`,type:"DISCOUNT",status:"FINAL"}),i>0&&o.push({label:"Subtotal",price:`${_(i/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),o}function et(e,t){return`${_chunkQ25D7OAOjs.f}/api/integrations/${e}/public-commerce${t}`}function we(e){return typeof e=="object"&&e!=null&&"ERR"in e}function J(e,t,r){return{ERR:!0,error:e,type:t,data:r}}function vr(e,t){return _optionalChain([t, 'optionalAccess', _99 => _99.find, 'call', _100 => _100(r=>r.id===e||(_nullishCoalesce(_optionalChain([r, 'access', _101 => _101.variants, 'optionalAccess', _102 => _102.some, 'call', _103 => _103(n=>n.id===e)]), () => (!1))))])}function wr(e,t){let r=new Set(t.map(n=>n.productID));return Array.from(new Set(e.filter(n=>!r.has(n))))}var _zustand = require('zustand');var Fe=_zustand.create.call(void 0, e=>({isCartVisible:!1,numberOfProductsInCart:0,showCart:()=>e(t=>({...t,isCartVisible:!0})),hideCart:()=>e(t=>({...t,isCartVisible:!1})),setNumberOfProductsInCart:t=>e(r=>({...r,numberOfProductsInCart:t}))}));var Co="__m_a",Cr=_react3.createContext.call(void 0, void 0),Jt= exports.E =void 0;function Bc(e){_chunk3IVLQILFjs.a.call(void 0, {projectID:e}),Jt= exports.E =e,typeof window<"u"&&_chunk3IVLQILFjs.g.call(void 0, [window.location.origin])}function nt(){return _nullishCoalesce(_nullishCoalesce(Jt, () => (_optionalChain([document, 'access', _104 => _104.querySelector, 'call', _105 => _105('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _106 => _106.getAttribute, 'call', _107 => _107("data-id")]))), () => (void 0))}function No(){return _nullishCoalesce(_optionalChain([document, 'access', _108 => _108.querySelector, 'call', _109 => _109('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _110 => _110.getAttribute, 'call', _111 => _111("data-custom-host")]), () => (void 0))}var So=({children:e,locale:t})=>{let r=new _reactquery.QueryClient;_react3.useEffect.call(void 0, ()=>{tt()},[]);let n=nt();if(n==null)return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{});let a=Yt(n,t);return _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:r,children:_jsxruntime.jsx.call(void 0, Cr.Provider,{value:a,children:e})})},qe=async(e,t)=>{let r=[];_optionalChain([t, 'optionalAccess', _112 => _112.items])!=null&&t.items.length>0?r=t.items:r=_nullishCoalesce(_optionalChain([z, 'call', _113 => _113(), 'optionalAccess', _114 => _114.products]), () => ([]));let n=Array.from(new Set(r.map(c=>c.productID))),a=new URLSearchParams;a.set("ids",n.join(",")),a.set("locale",_nullishCoalesce(_optionalChain([t, 'optionalAccess', _115 => _115.locale]), () => (_chunkQ25D7OAOjs.m.call(void 0, ))));let o=await fetch(_chunkQ25D7OAOjs.c.call(void 0, et(e,`/products?${a.toString()}`)),{method:"GET"});if(o.status!=200)return[];let i=await o.json();return r.flatMap(c=>{let s=vr(c.productID,i.result);return s==null?[]:[{...c,details:Lo(c.productID,s),catalogProductID:s.id}]})},Hc= exports.H =()=>{let e=_react3.useContext.call(void 0, Cr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Gc= exports.I =So,Io=_zod2.default.object({isAvailable:_zod2.default.boolean(),merchantId:_zod2.default.string(),merchantName:_zod2.default.string(),gateway:_zod2.default.string(),gatewayId:_zod2.default.string()}),Ro=_zod2.default.object({id:_zod2.default.string(),productID:_zod2.default.string(),quantity:_zod2.default.number(),priceVersion:_zod2.default.string().optional(),metadata:_zod2.default.record(_zod2.default.string(),_zod2.default.string().optional()).optional()}),Ao=_zod2.default.object({country:_zod2.default.string().optional(),couponCode:_zod2.default.string().optional(),selectedDeliveryMethod:_zod2.default.string().optional(),postalCode:_zod2.default.string().optional(),email:_zod2.default.string().optional(),products:_zod2.default.array(Ro).optional(),googlePayConfig:Io.optional()}),Kt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},Nr="checkout";function z(){try{let e=localStorage.getItem(Nr);return e==null?Kt:Ao.parse(JSON.parse(e))}catch (e6){return Kt}}async function kr(e,t){let r=await qe(e,{items:t.map((o,i)=>({...o,id:`price-check-${i}`}))});if(we(r))return r;let n=wr(t.map(o=>o.productID),r);if(n.length>0)return J("item-ids-not-found","notFound",n);let a=z();a.products==null&&(a.products=[]),a.products.push(...t.map(o=>({id:Math.random().toString(36).substring(7),productID:o.productID,quantity:o.quantity,priceVersion:_optionalChain([r, 'access', _116 => _116.find, 'call', _117 => _117(i=>i.productID===o.productID), 'optionalAccess', _118 => _118.details, 'optionalAccess', _119 => _119.pricing, 'optionalAccess', _120 => _120.priceVersion]),metadata:o.metadata}))),Do(t,r),Vt({event:"addToCart",currency:"PLN",items:t.map(o=>({id:o.productID,name:_nullishCoalesce(o.name, () => ("")),price:_nullishCoalesce(o.price, () => (0)),quantity:o.quantity,currency:_nullishCoalesce(o.currency, () => ("PLN"))}))}),te(a),tt()}function Do(e,t){for(let r of e)try{let n=t.find(c=>c.productID===r.productID),a=_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'optionalAccess', _121 => _121.details, 'optionalAccess', _122 => _122.pricing, 'optionalAccess', _123 => _123.effectivePrice]), () => (_optionalChain([n, 'optionalAccess', _124 => _124.details, 'optionalAccess', _125 => _125.price]))), () => (r.price)),o=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _126 => _126.details, 'optionalAccess', _127 => _127.currency]), () => (r.currency));if(a==null||o==null)continue;let i=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _128 => _128.catalogProductID]), () => (r.productID));(_nullishCoalesce(r.analytics, () => (_chunkWGJTXDISjs.o.call(void 0, )))).track("add_to_cart",{qty:r.quantity,value_minor:Math.round(a*r.quantity),currency:o},{product_id:i,variant_id:i!==r.productID?r.productID:null})}catch (e7){}}function xr(e){let t=z(),r={...t,products:_optionalChain([t, 'optionalAccess', _129 => _129.products, 'optionalAccess', _130 => _130.filter, 'call', _131 => _131(n=>!e.includes(n.productID)&&!e.includes(n.id))])};Vt({event:"removeFromCart",items:e.map(n=>({id:n,name:"",price:0,quantity:1,currency:"PLN"}))}),te(r),tt()}function te(e){localStorage.setItem(Nr,JSON.stringify(e))}var Yt=(e,t=_chunkQ25D7OAOjs.m.call(void 0, ))=>{let r=No();return r!=null&&_chunkQ25D7OAOjs.g.call(void 0, r),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await ve.get(_chunkQ25D7OAOjs.f).isOneClickPaymentAvailable({projectId:e})).applePay}catch(n){return console.error("Error checking if Apple Pay is available",n),!1}},async getGooglePayConfiguration(n){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let a=await To(e);if(_optionalChain([a, 'optionalAccess', _132 => _132.isAvailable])!=!0)return{isAvailable:!1};let o=z();if(o==null)return console.log("checkout is null"),{isAvailable:!1};let i=await qe(e,{locale:t,items:n.items.map(d=>({id:Math.random().toString(36).substring(7),quantity:d.quantity,metadata:d.metadata,productID:d.productID}))});if(we(i))return{isAvailable:!1};let c=await ve.get(_chunkQ25D7OAOjs.f).getPreOrderDetails({items:i.map(d=>_protobuf.create.call(void 0, _chunkUFIOJGJZjs.c,{id:d.productID,quantity:d.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod});if(c.totalAmount==null)return{isAvailable:!1};let s=i.find(d=>_optionalChain([d, 'access', _133 => _133.details, 'optionalAccess', _134 => _134.isDeliverable])==!0)!=null,y=await hr({items:i,googlePayConfig:a,checkout:o,cartRequiresShipping:s,result:c});return y==null?{isAvailable:!1}:{isAvailable:!0,config:y}}catch(a){return console.error("Error resolving Google Pay configuration",a),{isAvailable:!1}}},async clearCart(){let n=structuredClone(Kt);n.country=_optionalChain([z, 'call', _135 => _135(), 'optionalAccess', _136 => _136.country]),te(n),tt()},async getAvailableCountries(){let n=await fetch(_chunkQ25D7OAOjs.c.call(void 0, et(e,"/countries")),{method:"GET"});if(n.status!=200)return[];try{return _zod2.default.array(_zod2.default.object({name:_zod2.default.string(),code:_zod2.default.string()})).parse(await n.json())}catch(a){return J(a.toString(),"internal")}},async getCountry(){let n=_optionalChain([z, 'call', _137 => _137(), 'optionalAccess', _138 => _138.country]);if(n==null){n="PL";let a=z();a.country=n,te(a)}return n},async getNumberOfElementsInCart(){return _nullishCoalesce(_optionalChain([z, 'call', _139 => _139(), 'optionalAccess', _140 => _140.products, 'optionalAccess', _141 => _141.reduce, 'call', _142 => _142((n,a)=>n+a.quantity,0)]), () => (0))},async getProducts(){return await qe(e,{locale:t})},async removeProductFromCart(n){return xr([n.id])},async setCountry(n){let a=z();a.country=n,te(a)},async setCouponCodeIfPossible(n){let a=z();a.couponCode=n,te(a)},async setPostalCode(n){let a=z();a.postalCode=n,te(a)},async setDeliveryMethod(n){let a=z();a.selectedDeliveryMethod=n,te(a)},async setEmail(n){let a=z();a.email=n,te(a)},async addProduct(n){return await kr(e,[n])},async updateQuantity(n){let a=z();a.products=_optionalChain([a, 'access', _143 => _143.products, 'optionalAccess', _144 => _144.map, 'call', _145 => _145(o=>(o.id===n.id&&(o.quantity=n.quantity),o))]),te(a),tt()},async redirectToNextStep(){let n=z();if(n.products==null||n.products.length==0)return J("cart-is-empty","badInput");let a=n.products.reduce((c,s)=>(s.metadata!=null&&Object.keys(s.metadata).forEach(y=>{let d=_optionalChain([s, 'access', _146 => _146.metadata, 'optionalAccess', _147 => _147[y]]);d!=null&&(c[y]=d)}),c),{}),o={items:n.products.map(c=>({id:c.productID,quantity:c.quantity,priceVersion:c.priceVersion})),askForNote:!0,countries:n.country?[n.country]:void 0,metadata:a,locale:t},i=await Zt(o);return we(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url}},async justRedirectToPayment(n){let a={items:[{id:n.productID,quantity:1}],askForNote:!1,details:n.email||n.name?{name:n.name,email:n.email}:void 0,locale:_nullishCoalesce(n.locale, () => (t))};a=Qt(a),n.country==null&&(n.country="pl"),a.details==null&&(a.details={}),a.details.address==null&&(a.details.address={}),a.details.address.country=n.country,n.marketingAgreement===!0&&(a.additionalAgreements=[{id:Co,name:"",required:!0,answer:!0}]);let o=await Zt(a);return we(o)?o:{url:o.url}},async completeApplePayPayment(n){let a=z();if(a==null)return J("Checkout not found");let o=await qe(e,{locale:t});if(we(o))return o;try{let i=_optionalChain([n, 'access', _148 => _148.shippingContact, 'optionalAccess', _149 => _149.givenName]);_optionalChain([n, 'access', _150 => _150.shippingContact, 'optionalAccess', _151 => _151.familyName])!=null?i+=" "+_optionalChain([n, 'access', _152 => _152.shippingContact, 'optionalAccess', _153 => _153.familyName]):_optionalChain([n, 'access', _154 => _154.billingContact, 'optionalAccess', _155 => _155.familyName])!=null&&(i+=" "+_optionalChain([n, 'access', _156 => _156.billingContact, 'optionalAccess', _157 => _157.familyName]));let c={},s=Pt();s!=null&&(c.ref=s);let y=await ve.get(_chunkQ25D7OAOjs.f).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(n.token.paymentData),paymentMethod:JSON.stringify(n.token.paymentMethod),transactionIdentifier:n.token.transactionIdentifier,order:_protobuf.create.call(void 0, _chunkUFIOJGJZjs.d,{items:o.map(d=>({id:d.productID,quantity:d.quantity})),couponCode:a.couponCode,email:_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _158 => _158.shippingContact, 'optionalAccess', _159 => _159.emailAddress]), () => (_optionalChain([n, 'access', _160 => _160.billingContact, 'optionalAccess', _161 => _161.emailAddress]))), () => (a.email)), () => (void 0)),phone:_nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _162 => _162.shippingContact, 'optionalAccess', _163 => _163.phoneNumber]), () => (_optionalChain([n, 'access', _164 => _164.billingContact, 'optionalAccess', _165 => _165.phoneNumber]))), () => (void 0)),selectedDeliveryMethod:a.selectedDeliveryMethod,postCode:a.postalCode,projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkUFIOJGJZjs.a,{line1:_nullishCoalesce(_optionalChain([n, 'access', _166 => _166.shippingContact, 'optionalAccess', _167 => _167.addressLines, 'optionalAccess', _168 => _168[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([n, 'access', _169 => _169.shippingContact, 'optionalAccess', _170 => _170.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([n, 'access', _171 => _171.shippingContact, 'optionalAccess', _172 => _172.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([n, 'access', _173 => _173.shippingContact, 'optionalAccess', _174 => _174.postalCode]), () => ("")),name:i}),billingAddress:_protobuf.create.call(void 0, _chunkUFIOJGJZjs.b,{name:_nullishCoalesce(_optionalChain([n, 'access', _175 => _175.billingContact, 'optionalAccess', _176 => _176.givenName]), () => (" "+(_nullishCoalesce(_optionalChain([n, 'access', _177 => _177.billingContact, 'optionalAccess', _178 => _178.familyName]), () => (""))))),line1:_nullishCoalesce(_optionalChain([n, 'access', _179 => _179.billingContact, 'optionalAccess', _180 => _180.addressLines, 'optionalAccess', _181 => _181[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([n, 'access', _182 => _182.billingContact, 'optionalAccess', _183 => _183.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([n, 'access', _184 => _184.billingContact, 'optionalAccess', _185 => _185.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([n, 'access', _186 => _186.billingContact, 'optionalAccess', _187 => _187.postalCode]), () => (""))}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:y.isSuccess,redirectURL:y.redirectUrl}}catch(i){return console.error(i),J("Failed to authorize payment")}},async completeGooglePayPayment(n){let a=z();if(a==null)return J("Checkout not found");let o=await qe(e,{locale:t});if(we(o))return o;try{let i=_optionalChain([n, 'access', _188 => _188.paymentData, 'access', _189 => _189.shippingAddress, 'optionalAccess', _190 => _190.name]),c={},s=Pt();s!=null&&(c.ref=s);let y=await ve.get(_chunkQ25D7OAOjs.f).authorizeOneClickPayment({gateway:1,paymentData:n.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:n.paymentData.paymentMethodData.type,transactionIdentifier:"",order:_protobuf.create.call(void 0, _chunkUFIOJGJZjs.d,{items:o.map(d=>({id:d.productID,quantity:d.quantity})),couponCode:a.couponCode,email:_nullishCoalesce(n.paymentData.email, () => (void 0)),phone:_nullishCoalesce(_optionalChain([n, 'access', _191 => _191.paymentData, 'access', _192 => _192.shippingAddress, 'optionalAccess', _193 => _193.phoneNumber]), () => (void 0)),selectedDeliveryMethod:_nullishCoalesce(_optionalChain([n, 'access', _194 => _194.paymentData, 'access', _195 => _195.shippingOptionData, 'optionalAccess', _196 => _196.id]), () => (a.selectedDeliveryMethod)),postCode:_optionalChain([n, 'access', _197 => _197.paymentData, 'access', _198 => _198.shippingAddress, 'optionalAccess', _199 => _199.postalCode]),projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkUFIOJGJZjs.a,{line1:_nullishCoalesce(_optionalChain([n, 'access', _200 => _200.paymentData, 'access', _201 => _201.shippingAddress, 'optionalAccess', _202 => _202.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([n, 'access', _203 => _203.paymentData, 'access', _204 => _204.shippingAddress, 'optionalAccess', _205 => _205.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([n, 'access', _206 => _206.paymentData, 'access', _207 => _207.shippingAddress, 'optionalAccess', _208 => _208.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([n, 'access', _209 => _209.paymentData, 'access', _210 => _210.shippingAddress, 'optionalAccess', _211 => _211.postalCode]), () => ("")),name:i}),billingAddress:_protobuf.create.call(void 0, _chunkUFIOJGJZjs.b,{name:_optionalChain([n, 'access', _212 => _212.paymentData, 'access', _213 => _213.paymentMethodData, 'access', _214 => _214.info, 'optionalAccess', _215 => _215.billingAddress, 'optionalAccess', _216 => _216.name]),line1:_nullishCoalesce(_optionalChain([n, 'access', _217 => _217.paymentData, 'access', _218 => _218.paymentMethodData, 'access', _219 => _219.info, 'optionalAccess', _220 => _220.billingAddress, 'optionalAccess', _221 => _221.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([n, 'access', _222 => _222.paymentData, 'access', _223 => _223.paymentMethodData, 'access', _224 => _224.info, 'optionalAccess', _225 => _225.billingAddress, 'optionalAccess', _226 => _226.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([n, 'access', _227 => _227.paymentData, 'access', _228 => _228.paymentMethodData, 'access', _229 => _229.info, 'optionalAccess', _230 => _230.billingAddress, 'optionalAccess', _231 => _231.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([n, 'access', _232 => _232.paymentData, 'access', _233 => _233.paymentMethodData, 'access', _234 => _234.info, 'optionalAccess', _235 => _235.billingAddress, 'optionalAccess', _236 => _236.postalCode]), () => (""))}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:y.isSuccess,redirectURL:y.redirectUrl}}catch(i){return console.error(i),J("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(n){let a=z();if(a==null)return J("Checkout not found");n&&n.expectedItems!=null&&n.expectedItems.length>0&&(a.products&&xr(a.products.map(s=>s.productID)),await kr(e,n.expectedItems));let o=await qe(e,{locale:t});if(we(o))return o;let i=await ve.get(_chunkQ25D7OAOjs.f).getPreOrderDetails({items:o.map(s=>_protobuf.create.call(void 0, _chunkUFIOJGJZjs.c,{id:s.productID,quantity:s.quantity})),projectId:e,postCode:a.postalCode,couponCode:a.couponCode,countryCode:a.country,selectedDeliveryMethod:a.selectedDeliveryMethod}),c=o.map(s=>({amount:`${_(s.quantity*(_nullishCoalesce(_optionalChain([s, 'access', _237 => _237.details, 'optionalAccess', _238 => _238.price]), () => (0)))/100,2)}`,label:_optionalChain([s, 'access', _239 => _239.details, 'optionalAccess', _240 => _240.name])+" - "+s.quantity,type:"final"}));if(i.selectedDeliveryMethod!=null){let s=i.methods.find(y=>y.id==i.selectedDeliveryMethod);s!=null&&c.push({amount:`${_(s.amount/100,2)}`,label:s.name,type:"final"})}return i.couponCode!=null&&i.couponValue!=null&&c.push({amount:`-${_(i.couponValue/100,2)}`,label:i.couponCode,type:"final"}),{countryCode:_nullishCoalesce(a.country, () => ("PL")),merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${_((_nullishCoalesce(i.totalAmount, () => (0)))/100,2)}`,label:"P\u0142atno\u015B\u0107 za koszyk",type:"final"},shippingMethods:i.methods.map(s=>({amount:`${_(s.amount/100,2)}`,detail:_nullishCoalesce(s.description, () => ("")),identifier:s.id,label:s.name,dateComponentsRange:{startDateComponents:{days:_nullishCoalesce(s.minDays, () => (1)),hours:0,months:0,years:0},endDateComponents:{days:_nullishCoalesce(s.maxDays, () => (14)),hours:0,months:0,years:0}}})),lineItems:c,currencyCode:"PLN"}}}};async function To(e){let t=z();if(_optionalChain([t, 'access', _241 => _241.googlePayConfig, 'optionalAccess', _242 => _242.isAvailable])!=!0){let r=await ve.get(_chunkQ25D7OAOjs.f).isOneClickPaymentAvailable({projectId:e});r.googlePay==!0&&r.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:r.googlePayConfig.gateway,gatewayId:r.googlePayConfig.gatewayMerchantId,merchantName:r.googlePayConfig.merchantName,merchantId:r.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return te(t),t.googlePayConfig}function Lo(e,t){if(e==t.id){let n=_optionalChain([t, 'access', _243 => _243.variants, 'optionalAccess', _244 => _244.findIndex, 'call', _245 => _245(a=>a.id===e)]);if(n!=null&&n!=-1){let a=t.variants[n];return{...t,availableQuantity:a.availableQuantity,isDeliverable:a.isDeliverable,images:_nullishCoalesce(a.images, () => (t.images)),name:t.name+" "+a.name,price:a.price,currency:a.currency,pricing:a.pricing}}return t}let r=_optionalChain([t, 'access', _246 => _246.variants, 'optionalAccess', _247 => _247.find, 'call', _248 => _248(n=>n.id===e)]);return r==null?t:{...t,id:r.id,name:t.name+" "+r.name,price:r.price,currency:r.currency,pricing:r.pricing,metadata:t.metadata,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:_nullishCoalesce(r.images, () => (t.images))}}function tt(){let e=z(),t=0;if(e==null){Fe.setState(r=>({...r,numberOfProductsInCart:t}));return}t=_nullishCoalesce(_optionalChain([e, 'access', _249 => _249.products, 'optionalAccess', _250 => _250.reduce, 'call', _251 => _251((r,n)=>r+n.quantity,0)]), () => (0)),Fe.setState(r=>({...r,numberOfProductsInCart:t}))}var Uo=200,Oo= exports.v ="item-ids-not-found",rt="internal-error",Sr={"no-payment-gateway":"noPaymentGateway","gateway-not-configured":"gatewayNotConfigured","shipping-not-configured":"shippingNotConfigured","mixed-recurring":"mixedRecurring","currency-unsupported":"currencyUnsupported","price-changed":"priceChanged","product-not-found":"unavailableProducts","product-not-available":"unavailableProducts"},zo=new Set(["internal","invalid-request"]),Mo=new Set(["product-not-available","product-not-found"]);function _o(e){return typeof e=="string"&&Object.hasOwn(Sr,e)?Sr[e]:void 0}function jo(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function Fo(e){return/^[A-Za-z][A-Za-z0-9]*(?:[-_.:][A-Za-z0-9]+)*$/.test(e)&&!/^[A-Z][a-z]+$/.test(e)||/^\[object \w+\]$|^(?:undefined|null)$/.test(e)}function qo(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function Xt(e){let t=e.trim();if(!(t.length===0||t.length>Uo||/[\r\n]/.test(t)||jo(t)||Fo(t)||qo(t)))return t}var Bo=3;function ht(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=Bo)return{};let r=e,n=ht(r.error,t+1);if(n.message==null&&r.message!=null){let a=ht(r.message,t+1);n={...a,code:_nullishCoalesce(n.code, () => (a.code))}}return typeof r.code=="string"&&r.code.length>0&&(n.code=r.code),n}if(typeof e!="string")return{};try{let r=JSON.parse(e);return typeof r=="object"&&r!=null?ht(r,t+1):{}}catch (e8){}return{message:Xt(e)}}function Ho(e){let t;try{t=JSON.parse(e)}catch (e9){return{code:rt,message:Xt(e)}}if(typeof t=="string")return{code:rt,message:Xt(t)};if(typeof t!="object"||t==null)return{code:rt};let r=t,{message:n,code:a}=ht(r.error),o={code:typeof r.code=="string"&&r.code.length>0?r.code:_nullishCoalesce(a, () => (rt)),message:n};return Array.isArray(r.itemIds)&&(o.itemIds=r.itemIds.filter(i=>typeof i=="string")),o}function en(e,t){let{code:r,message:n,itemIds:a}=Ho(t),o=a!=null&&a.length>0;if(o&&(r===rt||Mo.has(r)))return J(Oo,"badInput",a);let i={message:n};return o&&(i.itemIds=a),J(r,e>=500?"internal":"badInput",i)}function Jc(e,t){let r=_o(e.error);if(r!=null)return t(r);if(e.type==="internal"||typeof e.error=="string"&&zo.has(e.error))return t("checkoutFailed");let n=_optionalChain([e, 'access', _252 => _252.data, 'optionalAccess', _253 => _253.message]);return typeof n=="string"&&n.length>0?n:t("checkoutFailed")}var Go;(n=>{async function e(a,o=1,i,c){let s=nt();if(s==null)throw new Error("No project ID found");let d=await Yt(s).addProduct({productID:a,quantity:o,metadata:i,...c});if(d!=null)return d}n.addProductToCart=e;function t(){Fe.setState({isCartVisible:!0})}n.showCart=t;function r(){Fe.setState({isCartVisible:!1})}n.hideCart=r})(Go = exports.y||={});async function Ir(e){try{return await e.text()}catch (e10){return""}}async function Zt(e){let t=nt();if(t==null)throw new Error("No project ID found");e=Qt(e),e.locale??=_chunkQ25D7OAOjs.m.call(void 0, );let r=await fetch(et(t,"/buy"),{method:"POST",headers:{..._chunkQ25D7OAOjs.a,..._chunkWGJTXDISjs.h.call(void 0, t),"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.status!=200){let a=en(r.status,await Ir(r));return console.warn("cannot create payment URL",r.status,a.error),a}return{url:(await r.json()).url}}async function ad(e){let t=nt();if(t==null)throw new Error("No project ID found");let r={..._chunkQ25D7OAOjs.a,..._chunkWGJTXDISjs.h.call(void 0, t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},n=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=_chunkQ25D7OAOjs.m.call(void 0, );let a=await fetch(_chunkQ25D7OAOjs.f+n,{method:"POST",headers:r,body:JSON.stringify(e)});return a.ok?{status:"ok",redirectURL:(await a.json()).url}:{...en(a.status,await Ir(a)),status:"error"}}function Pt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function Qt(e){let t=Pt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}exports.a = ve; exports.b = de; exports.c = ye; exports.d = be; exports.e = Tt; exports.f = ue; exports.g = In; exports.h = Lt; exports.i = Se; exports.j = Ze; exports.k = Je; exports.l = Ue; exports.m = Oe; exports.n = Zr; exports.o = Un; exports.p = $t; exports.q = lo; exports.r = _; exports.s = Pr; exports.t = Vt; exports.u = we; exports.v = Oo; exports.w = Jc; exports.x = Fe; exports.y = Go; exports.z = Zt; exports.A = ad; exports.B = Pt; exports.C = Qt; exports.D = Co; exports.E = Jt; exports.F = Bc; exports.G = nt; exports.H = Hc; exports.I = Gc; exports.J = Yt;
4
- //# sourceMappingURL=chunk-FBTYZHXM.js.map