bitsnap-react 1.17.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/CartProvider-ECQQH3PS.css +2 -0
- package/dist/CartProvider-ECQQH3PS.css.map +1 -0
- package/dist/CartProvider-OEI526IN.js +2 -0
- package/dist/{CartProvider-YVOHSMPE.js.map → CartProvider-OEI526IN.js.map} +1 -1
- package/dist/CartProvider-RYAA3JDA.mjs +2 -0
- package/dist/{PanelModelFiles-NYCOFPLY.js → PanelModelFiles-7HPXWONN.js} +2 -2
- package/dist/{PanelModelFiles-NYCOFPLY.js.map → PanelModelFiles-7HPXWONN.js.map} +1 -1
- package/dist/PanelModelFiles-JZFSF7BF.mjs +2 -0
- package/dist/PanelModelFiles-JZFSF7BF.mjs.map +1 -0
- package/dist/analytics.js +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.css +1 -1
- package/dist/catalog.css.map +1 -1
- package/dist/catalog.d.mts +2 -0
- package/dist/catalog.d.ts +2 -0
- package/dist/catalog.js +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/{chunk-ESF5ZVVF.js → chunk-4HGZZJEL.js} +2 -2
- package/dist/{chunk-ESF5ZVVF.js.map → chunk-4HGZZJEL.js.map} +1 -1
- package/dist/{chunk-HKNWW37T.mjs → chunk-4OVOKGGS.mjs} +2 -2
- package/dist/{chunk-A6VCP3A4.mjs → chunk-5X7TP3TQ.mjs} +2 -2
- package/dist/{chunk-2UDAB2C5.mjs → chunk-CF45RDMD.mjs} +2 -2
- package/dist/{chunk-2UDAB2C5.mjs.map → chunk-CF45RDMD.mjs.map} +1 -1
- package/dist/{chunk-C3BBJOVV.js → chunk-DP2NOHCI.js} +2 -2
- package/dist/{chunk-C3BBJOVV.js.map → chunk-DP2NOHCI.js.map} +1 -1
- package/dist/{chunk-L7Q7OKM5.mjs → chunk-EVIDNS22.mjs} +2 -2
- package/dist/{chunk-SYN5KU3O.js → chunk-G4V2KWTV.js} +2 -2
- package/dist/{chunk-SYN5KU3O.js.map → chunk-G4V2KWTV.js.map} +1 -1
- package/dist/{chunk-X3LVYIJR.mjs → chunk-GEBRXFT3.mjs} +2 -2
- package/dist/chunk-GWF3MRUP.js +2 -0
- package/dist/chunk-GWF3MRUP.js.map +1 -0
- package/dist/{chunk-MIMQTH2G.js → chunk-JA62KNAQ.js} +2 -2
- package/dist/{chunk-MIMQTH2G.js.map → chunk-JA62KNAQ.js.map} +1 -1
- package/dist/{chunk-BZXV77PT.mjs → chunk-JHJ3ZZF4.mjs} +2 -2
- package/dist/{chunk-M2G74N43.mjs → chunk-UPAOIY4R.mjs} +2 -2
- package/dist/chunk-V5ECGBFW.js +5 -0
- package/dist/chunk-V5ECGBFW.js.map +1 -0
- package/dist/{chunk-4BL7TLK3.js → chunk-VNV5BD4X.js} +2 -2
- package/dist/{chunk-4BL7TLK3.js.map → chunk-VNV5BD4X.js.map} +1 -1
- package/dist/chunk-WJO5GSY3.mjs +5 -0
- package/dist/chunk-WJO5GSY3.mjs.map +1 -0
- package/dist/{chunk-5FZAROP6.js → chunk-ZATPBYOA.js} +2 -2
- package/dist/{chunk-5FZAROP6.js.map → chunk-ZATPBYOA.js.map} +1 -1
- package/dist/chunk-ZHTMK5TA.mjs +2 -0
- package/dist/chunk-ZHTMK5TA.mjs.map +1 -0
- package/dist/course.d.mts +10 -0
- package/dist/course.d.ts +10 -0
- package/dist/course.js +1 -1
- package/dist/course.js.map +1 -1
- package/dist/course.mjs +1 -1
- package/dist/course.mjs.map +1 -1
- package/dist/embed/analytics.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/methods-AULQDKVS.mjs +2 -0
- package/dist/methods-OJEZREBK.css +2 -0
- package/dist/methods-OJEZREBK.css.map +1 -0
- package/dist/methods-PMH5VQ25.js +2 -0
- package/dist/{methods-3W34GRYL.js.map → methods-PMH5VQ25.js.map} +1 -1
- package/dist/returns.js +1 -1
- package/dist/returns.mjs +1 -1
- package/dist/viewer3d.css +1 -1
- package/dist/viewer3d.css.map +1 -1
- package/dist/viewer3d.mjs +1 -1
- package/package.json +2 -2
- package/dist/CartProvider-DGRZDTYC.mjs +0 -2
- package/dist/CartProvider-PDEV6GCV.css +0 -2
- package/dist/CartProvider-PDEV6GCV.css.map +0 -1
- package/dist/CartProvider-YVOHSMPE.js +0 -2
- package/dist/PanelModelFiles-RV7OHUUZ.mjs +0 -2
- package/dist/PanelModelFiles-RV7OHUUZ.mjs.map +0 -1
- package/dist/chunk-2NL5FCXC.mjs +0 -4
- package/dist/chunk-2NL5FCXC.mjs.map +0 -1
- package/dist/chunk-4ETIDGYZ.mjs +0 -2
- package/dist/chunk-4ETIDGYZ.mjs.map +0 -1
- package/dist/chunk-555KFWGY.js +0 -4
- package/dist/chunk-555KFWGY.js.map +0 -1
- package/dist/chunk-6GCCNBEU.js +0 -2
- package/dist/chunk-6GCCNBEU.js.map +0 -1
- package/dist/methods-3W34GRYL.js +0 -2
- package/dist/methods-LUJSKSQ4.mjs +0 -2
- package/dist/methods-QAZED7TJ.css +0 -2
- package/dist/methods-QAZED7TJ.css.map +0 -1
- /package/dist/{CartProvider-DGRZDTYC.mjs.map → CartProvider-RYAA3JDA.mjs.map} +0 -0
- /package/dist/{chunk-HKNWW37T.mjs.map → chunk-4OVOKGGS.mjs.map} +0 -0
- /package/dist/{chunk-A6VCP3A4.mjs.map → chunk-5X7TP3TQ.mjs.map} +0 -0
- /package/dist/{chunk-L7Q7OKM5.mjs.map → chunk-EVIDNS22.mjs.map} +0 -0
- /package/dist/{chunk-X3LVYIJR.mjs.map → chunk-GEBRXFT3.mjs.map} +0 -0
- /package/dist/{chunk-BZXV77PT.mjs.map → chunk-JHJ3ZZF4.mjs.map} +0 -0
- /package/dist/{chunk-M2G74N43.mjs.map → chunk-UPAOIY4R.mjs.map} +0 -0
- /package/dist/{methods-LUJSKSQ4.mjs.map → methods-AULQDKVS.mjs.map} +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{C as xn,F as wn,G as Cn,H as Nn,I as In,J as Sn,K as En,a as ir,b as sn,c as Tt,d as We,e as Rt,f as ln,h as dn,i as cn,j as un,k as pn,p as hn,q as bn,r as Pn,t as vn,u as kn}from"./chunk-4OVOKGGS.mjs";import{b as Pe,c as mt,d as mn,e as fn,f as Ve}from"./chunk-5X7TP3TQ.mjs";import{a as sr,g as ut,h as pt}from"./chunk-CUPG4B5W.mjs";import{a as tr,b as rr,c as Nt,d as nr,e as rn,f as nn,k as H,l as Ge,m as oe,q as I,r as Lt,t as gn,u as Je,v as yn}from"./chunk-EVIDNS22.mjs";import{a as j}from"./chunk-5R6AGO3Z.mjs";import{a as Xt,b as tn,c as er,e as Z,f as an}from"./chunk-GEBRXFT3.mjs";import{h as or,l as It,m as St,n as Ke,o as on}from"./chunk-CF45RDMD.mjs";import{a as Et,c as Se,e as ar,f as S}from"./chunk-VNYHJT6V.mjs";import{useAutoAnimate as ca}from"@formkit/auto-animate/react";import{useEffect as Dn,useMemo as On}from"react";import{jsx as ft}from"react/jsx-runtime";function Ee({className:e,...t}){return ft("div",{"data-slot":"card",className:j("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function Oe({className:e,...t}){return ft("div",{"data-slot":"card-header",className:j("@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 Ue({className:e,...t}){return ft("div",{"data-slot":"card-title",className:j("leading-none font-semibold",e),...t})}function Tn({className:e,...t}){return ft("div",{"data-slot":"card-description",className:j("text-muted-foreground text-sm",e),...t})}function Te({className:e,...t}){return ft("div",{"data-slot":"card-content",className:j("px-6",e),...t})}import{CircleCheck as ea}from"lucide-react";import{useId as ta}from"react";import{jsx as F,jsxs as Q}from"react/jsx-runtime";var ra="text-muted-foreground text-xs leading-5",na="dark:border-foreground/30 dark:focus-visible:border-foreground/70 dark:focus-visible:ring-foreground/25 dark:aria-invalid:border-destructive-foreground dark:aria-invalid:ring-destructive-foreground/30",oa=new Set(["invalidEmail","emailNotFound","deliveryUnavailable"]),lr="inline-flex min-h-11 items-center px-1 text-sm underline underline-offset-4 hover:no-underline focus-visible:ring-[3px] focus-visible:ring-ring/50 rounded-sm outline-none disabled:opacity-50 disabled:no-underline";function Ln({login:e,texts:t,allowHaveCode:n=!0,emailPlaceholder:a,emailInputId:r,codeInputId:o,className:i,buttonClassName:d,children:c}){let l=ta(),b=r??`${l}-email`,P=o??`${l}-code`,w=`${l}-notice`,h=`${l}-hint`,{notice:y}=e,u=y?.kind==="error",m=e.busy==="send",p=e.busy==="verify",x=e.busy==="resend",U=j("h-11 w-full",d),le=y?.kind==="success",E=Q("div",{id:w,className:"min-h-10 text-sm leading-5",children:[F("p",{role:"alert",className:"font-medium text-red-700 dark:text-red-400",children:u?y.text:null}),Q("p",{role:"status",className:j("flex items-start gap-1.5",le?"font-medium text-emerald-700 dark:text-emerald-400":"text-foreground"),children:[le&&F(ea,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),F("span",{children:y!=null&&!u?y.text:null})]})]}),de=u&&e.step==="email"&&(y.failure==null||oa.has(y.failure)),Ce=F("p",{className:"sr-only",role:"status","aria-live":"polite",children:e.announcement}),ee=Q("div",{className:"grid gap-2",children:[F(We,{htmlFor:b,children:t.emailLabel}),F(Lt,{id:b,ref:e.emailRef,name:"email",type:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoFocus:!0,required:!0,className:j("h-11 text-base disabled:opacity-100 disabled:text-foreground/70",na),placeholder:a??t.emailPlaceholder,value:e.email,disabled:e.isBusy,"aria-invalid":de?!0:void 0,"aria-describedby":w,onChange:Y=>e.setEmail(Y.target.value)})]});if(e.step==="email")return Q("form",{noValidate:!0,className:j("flex flex-col gap-4",i),onSubmit:Y=>{Y.preventDefault(),e.sendCode()},children:[Ce,ee,E,Q(I,{type:"submit",disabled:e.isBusy,"aria-busy":m,className:U,children:[m&&F(Rt,{"aria-hidden":!0}),m?t.sending:t.sendCode]}),n&&Q("p",{className:"flex flex-wrap items-center justify-center text-center text-sm",children:[t.haveCodePrompt!==""&&F("span",{children:t.haveCodePrompt}),F("button",{type:"button",className:lr,disabled:e.isBusy,onClick:e.haveCode,children:t.haveCode})]})]});let[A,fe]=t.codeSentTo.split("{email}"),J=e.dead!=null,He=J?t.resendNew:e.secondsLeft>0?cn(t.resendIn,{seconds:e.secondsLeft}):t.resend;return Q("form",{noValidate:!0,className:j("flex flex-col gap-4",i),onSubmit:Y=>{Y.preventDefault(),e.submitCode()},children:[Ce,e.needsEmail?ee:Q("div",{className:"flex flex-wrap items-center justify-between gap-x-2",children:[Q("p",{className:"min-w-0 flex-[1_1_14rem] text-sm leading-5 break-words",children:[A,F("strong",{className:"font-semibold",children:e.email}),"\u2060",fe]}),F("button",{type:"button",className:j(lr,"-ml-1 shrink-0"),disabled:e.isBusy,onClick:e.changeEmail,children:t.changeEmail})]}),c,Q("div",{className:"grid gap-2",children:[F(We,{htmlFor:P,children:t.codeLabel}),F(pn,{id:P,name:"code",inputRef:e.codeRef,value:e.code,onChange:e.setCode,onComplete:Y=>void e.submitCode(Y),disabled:e.isBusy||J,invalid:u&&!e.needsEmail,"aria-describedby":`${w} ${h}`}),Q("p",{id:h,className:ra,children:[t.validity," ",t.spamHint]})]}),E,Q(I,{type:"submit",disabled:e.isBusy||J,"aria-busy":p,className:U,children:[p&&F(Rt,{"aria-hidden":!0}),p?t.verifying:t.verify]}),e.needsEmail?F("div",{className:"flex justify-center",children:F("button",{type:"button",className:lr,disabled:e.isBusy,onClick:e.changeEmail,children:t.noCode})}):Q(I,{type:"button",variant:J?"default":"outline",disabled:e.isBusy||!J&&e.secondsLeft>0,"aria-busy":x,className:J?U:"h-11 w-full",onClick:()=>void e.resend(),children:[x&&F(Rt,{"aria-hidden":!0}),He]})]})}function dr(e){switch(e){case 1:return"emailNotFound";case 2:return"invalidEmail";case 3:return"wrongCode";case 14:return"expired";case 15:return"tooManyAttempts";case 13:return"rateLimited";case 12:return"deliveryFailed";case 11:return"deliveryUnavailable";default:return"unknown"}}var aa={pl:{title:"Zaloguj si\u0119",description:"Wy\u015Blemy do Ciebie kod na maila, dzi\u0119ki kt\xF3remu si\u0119 zalogujesz.",codeTitle:"Wpisz kod z maila",codeDescription:"Kod ma 6 cyfr."},en:{title:"Sign in",description:"We will email you a code that signs you in.",codeTitle:"Enter the code from the email",codeDescription:"The code has 6 digits."}};function Rn(e=S(),t){return{...dn(e,t),...Et(aa,e),...ia(t,["title","description","codeTitle","codeDescription"])}}function ia(e,t){let n={};for(let a of t){let r=e?.[a];r!=null&&(n[a]=r)}return n}var sa="return_url",cr="__return_url",la="accessToken";function gt(e){let t=new URLSearchParams(e).get(sa);return t?An(t):null}function yt(e){typeof window>"u"||(e?window.sessionStorage.setItem(cr,e):window.sessionStorage.removeItem(cr))}function Ye(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(cr);return e?An(e):null}function da(e,t){return t.some(n=>{if(e===n)return!0;let a=new URL(n).hostname,r=new URL(e).hostname;return r.endsWith(`.${a}`)||r===a})}function An(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!da(t.origin,pt())?null:t.toString()}catch{return null}}function Ze(e,t){let n=new URL(e);return n.searchParams.set(la,t),n.toString()}import{jsx as ae,jsxs as Mn}from"react/jsx-runtime";if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];pt().length===0&&ut(Array.from(new Set(t)))}var ua=({texts:e,projectID:t,host:n,locale:a,logo:r})=>{let o=St(),{mutateAsync:i}=oe(H.publicApi.userPanelLogin),{mutateAsync:d}=oe(H.publicApi.userPanelLoginWithCode),c=On(()=>({async send(h){try{let y=await i({email:h});return y.result.case==="success"?{ok:!0,retryIn:y.result.value.retryIn||void 0,challengeId:y.result.value.challengeId||void 0}:{ok:!1,kind:dr(y.result.case==="failure"?y.result.value:0)}}catch(y){return{ok:!1,kind:ir(y),cause:y}}},async verify({email:h,code:y,challengeId:u}){try{let m=await d({code:parseInt(y,10),email:h,challengeId:u});return m.result.case==="accessToken"&&m.result.value?{ok:!0,value:{accessToken:m.result.value}}:{ok:!1,kind:dr(m.result.case==="failure"?m.result.value:0)}}catch(m){return{ok:!1,kind:ir(m),cause:m}}}}),[i,d]),l=un({adapter:c,texts:e,storageKey:ln("panel",t,n),onVerified:({accessToken:h},y)=>{o.track("panel_login",{}),mn(t,h,y,n);let u=typeof window<"u"?Ye():null;setTimeout(()=>{if(u){window.location.href=Ze(u,h);return}window.location.reload()},100)}}),b=l.step==="code",P=b&&!l.needsEmail?e.codeTitle:e.title,w=b&&!l.needsEmail?e.codeDescription:e.description;return ae("main",{className:"mx-auto flex w-full max-w-sm flex-1 flex-col justify-start pt-4 sm:pt-[12vh]",children:Mn(Ee,{children:[ae(Tt,{projectId:t,locale:a,className:"px-4 sm:px-6",...r}),Mn(Oe,{className:"px-4 sm:px-6",children:[ae(Ue,{role:"heading","aria-level":1,className:"text-2xl",children:P}),ae(Tn,{children:w})]}),ae(Te,{className:"px-4 sm:px-6",children:ae(Ln,{login:l,texts:e,emailInputId:"email",codeInputId:"verify-code"})})]})})},pa=({analytics:e,texts:t,locale:n,showLogo:a,logoUrl:r,logoDarkUrl:o})=>{let{theme:i,allowedReturnOrigins:d,projectID:c,host:l}=Pe(),b=Ke(c,e,"panel"),P=On(()=>Rn(n??S(),t),[n,t]),w={"--button-background-color":i?.colors?.brand??"#FFFFFF","--button-background-color-dark":i?.colors?.brandDark??"#000000","--button-text-color":i?.colors?.brandDark??"#000000","--button-text-color-dark":i?.colors?.brand??"#FFFFFF"},[h]=ca({duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1});return Dn(()=>{typeof window>"u"||mt(c,l)!=null&&(window.location.href=window.location.href.replaceAll("login",""))},[c,l]),Dn(()=>{if(typeof window>"u"||window.parent!==window)return;let y=gt(window.location.search);y&&yt(y);let u=y??Ye();if(!u)return;let m=mt(c,l);m&&(window.location.href=Ze(u,m))},[d,c,l]),ae(It,{value:b,children:ae("div",{className:"bg-white text-black dark:bg-black dark:text-white",children:ae("div",{className:"font-inter flex min-h-screen w-full flex-col p-4",style:w,ref:h,children:ae(ua,{texts:P,projectID:c,host:l,locale:n,logo:{showLogo:a,logoUrl:r??i?.logoURL,logoDarkUrl:o??i?.logoDarkURL}})})})})},ma=(e={})=>ae(pa,{...e});import{useAutoAnimate as Gi}from"@formkit/auto-animate/react";import{useEffect as Ot,useState as Po}from"react";import{useState as fa,useCallback as ga,useEffect as ya}from"react";function Un(e){let[t,n]=fa(()=>{if(typeof window>"u")return e;let r=new URLSearchParams(window.location.search),o={};return Object.keys(e).forEach(i=>{let d=r.get(i);if(d!==null)try{o[i]=JSON.parse(d)}catch{o[i]=d}}),{...e,...o}}),a=ga(r=>{n(o=>{let i={...o,...r};if(typeof window<"u"){let d=new URLSearchParams;Object.keys(i).forEach(l=>{let b=i[l];b!=null&&d.set(l,JSON.stringify(b))});let c=`${window.location.pathname}?${d.toString()}`;window.history.pushState({},"",c)}return i})},[]);return ya(()=>{let r=()=>{let o=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(d=>{let c=o.get(d);if(c!==null)try{i[d]=JSON.parse(c)}catch{i[d]=c}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,a]}function _n(e,t){if(e!=null)return e;let n=t?.trim();if(!(n==null||n===""))return{tokens:gn(n)}}var ha={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs",libraryNavLabel:"Biblioteka",ordersNavLabel:"Zam\xF3wienia",accountNavLabel:"Konto",navigationLabel:"Panel klienta",logout:"Wyloguj si\u0119",profileHeading:"Profil",emailLabel:"E-mail",noData:"Brak danych",languageLabel:"J\u0119zyk",polishLanguage:"Polski",englishLanguage:"English",plansHeading:"Plany",plansUnavailable:"Plany nie s\u0105 obecnie dost\u0119pne w panelu.",notificationsHeading:"Powiadomienia",notificationsUnavailable:"Ustawienia powiadomie\u0144 nie s\u0105 obecnie dost\u0119pne w panelu.",ordersHeading:"Historia zam\xF3wie\u0144",ordersDescription:"Twoje zam\xF3wienia",ordersEmpty:"Brak zam\xF3wie\u0144.",ordersError:"Nie uda\u0142o si\u0119 pobra\u0107 zam\xF3wie\u0144.",retry:"Spr\xF3buj ponownie",orderLabel:"Zam\xF3wienie",customerLabel:"Klient",dateLabel:"Data",ordersEnd:"To ju\u017C wszystkie Twoje zam\xF3wienia.",previousPage:"Poprzednia strona",nextPage:"Nast\u0119pna strona",paginationLabel:"Strony zam\xF3wie\u0144",statusDraft:"Szkic",statusUnpaid:"Nieop\u0142acone",statusPaid:"Op\u0142acone",statusOverdue:"Zaleg\u0142e",statusCancelled:"Anulowane",statusCompleted:"Zako\u0144czone",statusProcessing:"Przetwarzane",statusRefunded:"Zwr\xF3cone"},en:{returnsNavLabel:"Returns",openCourse:"Open the course",libraryNavLabel:"Library",ordersNavLabel:"Orders",accountNavLabel:"Account",navigationLabel:"Customer panel",logout:"Log out",profileHeading:"Profile",emailLabel:"Email",noData:"No data",languageLabel:"Language",polishLanguage:"Polski",englishLanguage:"English",plansHeading:"Plans",plansUnavailable:"Plans are currently unavailable in the panel.",notificationsHeading:"Notifications",notificationsUnavailable:"Notification settings are currently unavailable in the panel.",ordersHeading:"Order history",ordersDescription:"Your orders",ordersEmpty:"No orders yet.",ordersError:"Could not load your orders.",retry:"Try again",orderLabel:"Order",customerLabel:"Customer",dateLabel:"Date",ordersEnd:"You\u2019ve reached the end of your orders.",previousPage:"Previous page",nextPage:"Next page",paginationLabel:"Order pages",statusDraft:"Draft",statusUnpaid:"Unpaid",statusPaid:"Paid",statusOverdue:"Overdue",statusCancelled:"Cancelled",statusCompleted:"Completed",statusProcessing:"Processing",statusRefunded:"Refunded"}};function ue(e=S()){return Et(ha,e)}import{jsx as zn,jsxs as ba}from"react/jsx-runtime";function ur({}){let e=ue();return ba("section",{children:[zn("h3",{className:"text-2xl",children:e.notificationsHeading}),zn("p",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:e.notificationsUnavailable})]})}import{useState as Pa}from"react";import{Fragment as Ca,jsx as M,jsxs as G}from"react/jsx-runtime";var va=e=>new Date(e*1e3).toLocaleDateString(S(),{year:"numeric",month:"short",day:"numeric"}),ka=(e,t)=>new Intl.NumberFormat(S(),{style:"currency",currency:t.toUpperCase()}).format(e/100),xa={draft:"text-neutral-600 dark:text-neutral-400",unpaid:"text-amber-700 dark:text-amber-300",paid:"text-green-700 dark:text-green-400",overdue:"text-red-700 dark:text-red-400",cancelled:"text-neutral-600 line-through dark:text-neutral-400",completed:"text-green-700 dark:text-green-400",processing:"text-blue-700 dark:text-blue-400",refunded:"text-purple-700 dark:text-purple-400"};function wa({openOrderDetails:e,projectID:t,accessToken:n}){let a=ue(),r={draft:a.statusDraft,unpaid:a.statusUnpaid,paid:a.statusPaid,overdue:a.statusOverdue,cancelled:a.statusCancelled,completed:a.statusCompleted,processing:a.statusProcessing,refunded:a.statusRefunded},[o,i]=Pa(0),d=20,{data:c,isFetching:l,isError:b,refetch:P}=Ge(H.publicApi.getOrders,{projectId:t,accessToken:n,offset:o,limit:d}),w=c?.orders??[],h=c?.totalCount??0,y=Math.floor(o/d)+1,u=Math.ceil(h/d),m=p=>{i(p)};return G(Ca,{children:[M("h3",{className:"text-2xl",children:a.ordersHeading}),M("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:a.ordersDescription}),l?M("div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((p,x)=>G("div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[G("div",{className:"flex items-center justify-between gap-3",children:[G("div",{className:"space-y-2",children:[M(Je,{className:"h-4 w-24"}),M(Je,{className:"h-3 w-32"})]}),G("div",{className:"space-y-2 text-right",children:[M(Je,{className:"ml-auto h-4 w-16"}),M(Je,{className:"ml-auto h-3 w-12"})]})]}),M("div",{className:"mt-3",children:M(Je,{className:"h-3 w-40"})})]},x))}):b?G("div",{role:"alert",className:"mt-6 space-y-3",children:[M("p",{children:a.ordersError}),M(I,{onClick:()=>void P(),className:"min-h-11 focus-visible:outline-2 focus-visible:outline-current",children:a.retry})]}):w.length===0?M("div",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:a.ordersEmpty}):G("div",{children:[M("div",{className:"mt-6 flex w-full flex-col gap-3",children:w.map(p=>G("button",{onClick:()=>e(p.id),className:"block min-h-11 focus-visible:outline-2 focus-visible:outline-current 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:[G("div",{className:"flex items-center justify-between gap-3",children:[G("div",{className:"min-w-0 break-words",children:[G("p",{className:"font-medium",children:[a.orderLabel," #",p.id]}),M("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:p.customerName||a.customerLabel})]}),G("div",{className:"shrink-0 text-right",children:[M("p",{className:"font-semibold",children:ka(p.totalAmount,p.currency)}),M("p",{className:`text-xs font-medium ${xa[p.status]??"text-neutral-400"}`,children:r[p.status]??p.status})]})]}),M("div",{className:"mt-2 flex items-center justify-between gap-3 text-xs text-neutral-500 dark:text-neutral-400",children:G("span",{children:[a.dateLabel,":"," ",p.createdAt?va(Number(p.createdAt.seconds)):"-"]})})]},p.id))}),y>=u&&M("p",{className:"mt-6 text-center text-sm text-neutral-600 dark:text-neutral-400",children:a.ordersEnd}),u>1&&G("nav",{"aria-label":a.paginationLabel,className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:[y>1&&M(I,{variant:"outline",className:"min-h-11",onClick:()=>m(o-d),children:a.previousPage}),Array.from(new Set([1,y-1,y,y+1,u])).filter(p=>p>0&&p<=u).sort((p,x)=>p-x).map(p=>M(I,{variant:p===y?"secondary":"ghost",className:"min-h-11 min-w-11","aria-current":p===y?"page":void 0,onClick:()=>m((p-1)*d),children:p},p)),y<u&&M(I,{variant:"outline",className:"min-h-11",onClick:()=>m(o+d),children:a.nextPage})]})]})]})}var jn=wa;import{jsx as Fn,jsxs as Na}from"react/jsx-runtime";function pr({projectID:e}){let t=ue();return Na("section",{children:[Fn("h3",{className:"text-2xl",children:t.plansHeading}),Fn("p",{className:"mt-6 text-sm text-neutral-600 dark:text-neutral-400",children:t.plansUnavailable})]})}import{useEffect as Ia,useState as mr}from"react";import{jsx as ie,jsxs as Ta}from"react/jsx-runtime";function Sa(e,t,n,a){typeof window>"u"||(t&&Ve(n,a),window.location.href=e)}function Ea({projectID:e,host:t,loginURL:n,screen:a,params:r,setParams:o,setActiveScreen:i}){let{status:d,exchangeError:c}=vn("PanelReturns"),l=Pn(),b=d==="anonymous"&&(c==null||hn(c));Ia(()=>{b&&Sa(n,c!=null,e,t)},[b,n,c,e,t]);let[P,w]=mr("orders"),[h,y]=mr({items:[],note:""}),[u,m]=mr();if(d==="anonymous"&&!b)return Ta("div",{role:"alert",className:"flex flex-col items-start gap-3",children:[ie("p",{className:"text-sm",children:l(bn(c))}),ie(I,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(d!=="authenticated")return ie(xn,{});let p=x=>{w(x),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(a==="return-details"&&r.returnId)return ie(En,{returnId:r.returnId,onBack:()=>p("myReturns")});if(P==="myReturns")return ie(Sn,{onBack:()=>p("orders"),onSelectReturn:x=>{o({state:"return-details",returnId:x,orderId:void 0}),i("return-details")}});if(P==="result"&&u!=null)return ie(In,{returnId:u,onContinue:()=>p("orders"),onOpenMyReturns:()=>p("myReturns")});if(r.orderId){let x=r.orderId;return P==="confirmation"?ie(Nn,{orderId:x,items:h.items,note:h.note,onBack:()=>w("orders"),onSubmitted:U=>{m(U),y({items:[],note:""}),w("result"),o({orderId:void 0})}}):ie(Cn,{orderId:x,initialItems:h.items.length>0?h.items:void 0,initialNote:h.note,onBack:()=>{y({items:[],note:""}),o({orderId:void 0})},onContinue:U=>{y(U),w("confirmation")}})}return ie(wn,{showLogout:!1,onSelectOrder:x=>{y({items:[],note:""}),w("orders"),o({orderId:x})},onOpenMyReturns:()=>p("myReturns")})}function fr({accessToken:e,appearance:t,texts:n,...a}){return ie(kn,{projectID:a.projectID,host:a.host,appearance:t,texts:n,panelAccessToken:e,children:ie(Ea,{...a})})}import{lazy as gi,Suspense as yi,useEffect as kr,useState as hi}from"react";import{BookOpen as bi,Files as Pi,Headphones as vi,Ticket as ki}from"lucide-react";var La={hello:"Hej \u{1F44B}",intro:"Poni\u017Cej znajdziesz swoje produkty",loading:"\u0141adowanie produkt\xF3w\u2026",empty:"Nie masz jeszcze produkt\xF3w w tym sklepie. Twoje zakupy pojawi\u0105 si\u0119 tutaj.",audio:"Audio",files:"Pliki",course:"Kurs",ticket:"Bilet",listen:"S\u0142uchaj",openCourse:"Otw\xF3rz kurs",downloadFiles:"Pobierz pliki",showTicket:"Poka\u017C bilet",back:"Wr\xF3\u0107",yourFiles:"Twoje pliki",download:"Pobierz",retry:"Spr\xF3buj ponownie",fileError:"Nie uda\u0142o si\u0119 wczyta\u0107 plik\xF3w.",noFiles:"Brak plik\xF3w do pobrania.",ticketInfo:"Tw\xF3j zakupiony bilet",file:"Plik"},Ra={hello:"Hi \u{1F44B}",intro:"Your products are below",loading:"Loading products\u2026",empty:"You have no products in this shop yet. Your purchases will show up here.",audio:"Audio",files:"Files",course:"Course",ticket:"Ticket",listen:"Listen",openCourse:"Open course",downloadFiles:"Download files",showTicket:"Show ticket",back:"Back",yourFiles:"Your files",download:"Download",retry:"Try again",fileError:"Your files could not be loaded.",noFiles:"No files to download.",ticketInfo:"Your purchased ticket",file:"File"};function Qe(){return S().toLowerCase().startsWith("en")?Ra:La}import{jsx as Oa}from"react/jsx-runtime";var Aa=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,Da=e=>[...e.matchAll(Aa)].map(n=>({url:n[0],startIndex:n.index,endIndex:n.index+n[0].length-1})),Ma=(e,t)=>{let n="",a=0;t.sort((r,o)=>r.startIndex-o.startIndex);for(let{startIndex:r,endIndex:o,replacementText:i}of t)n+=e.slice(a,r),n+=i,a=o+1;return n+=e.slice(a),n},Hn=e=>{let t=Da(e);return Oa("p",{dangerouslySetInnerHTML:{__html:Ma(e,t.map(n=>(n.replacementText=`<a key=${n.url} href=${n.url} style="text-decoration: underline;" target="_blank">
|
|
2
|
+
${n.url}
|
|
3
|
+
</a>`,n)))}})};import{fromJsonString as xi}from"@bufbuild/protobuf";import{useAutoAnimate as li}from"@formkit/auto-animate/react";import{ChevronLeft as di,Download as ci}from"lucide-react";import{useEffect as to,useRef as ro,useState as je}from"react";import Ja from"hls.js";import{Pause as Ya,Play as Za,SkipBack as Qa,SkipForward as Xa}from"lucide-react";import{forwardRef as ei,useEffect as ze,useImperativeHandle as ti,useRef as K,useState as ke}from"react";import{jsx as gr,jsxs as _a}from"react/jsx-runtime";function Ua(){return _a("div",{className:"flex items-center gap-2",children:[gr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),gr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),gr("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var _e=Ua;import za from"hls.js";var ja=[401,403],$n="networkError",qn="mediaError";function Fa(e,t){if(e==null||e.fatal!==!0)return{action:"ignore"};let n=e.response?.code,a=e.type===$n?"network":e.type===qn?"media":"unknown",r=n==null?{kind:a}:{kind:a,status:n};return n!=null&&ja.includes(n)?{action:"expired",error:{kind:"network",status:n}}:e.type===$n&&!t.network?{action:"restart-load"}:e.type===qn&&!t.media?{action:"recover-media"}:{action:"fail",error:r}}function Bn(e){let t=e.HlsCtor??za,n=new t,a,r=!1,o=!1;return n.attachMedia(e.media),n.on(t.Events.ERROR,(i,d)=>{let c=Fa(d,{network:r,media:o});switch(c.action){case"expired":e.handlers?.onExpiredUrl?.(),e.handlers?.onError?.(c.error);break;case"restart-load":r=!0,n.startLoad();break;case"recover-media":o=!0,n.recoverMediaError();break;case"fail":e.handlers?.onError?.(c.error);break;case"ignore":break}}),{load(i){a=i,r=!1,o=!1,n.loadSource(i)},retry(){a!=null&&(r=!1,o=!1,n.loadSource(a))},destroy(){n.destroy()},get src(){return a}}}function Kn(e){try{return e.canPlayType("application/vnd.apple.mpegurl")!==""}catch{return!1}}function Gn(e){switch(e?.code){case 2:return{kind:"network"};case 3:case 4:return{kind:"media"};default:return{kind:"unknown"}}}var Ha={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",avif:"image/avif",svg:"image/svg+xml"},yr="512x512";function Xe(){return typeof navigator<"u"&&typeof navigator.mediaSession<"u"}function $a(e){if(typeof e!="string"||e.length===0)return{src:e,sizes:yr};let t=e.split(/[?#]/)[0],n=t.includes(".")?t.slice(t.lastIndexOf(".")+1).toLowerCase():"",a=Ha[n],r={src:e,sizes:yr};return a!=null&&(r.type=a),r}function qa(e){if(e==null)return;let t=Array.isArray(e)?e:[e],n=[];for(let a of t){if(typeof a=="string"){a.length>0&&n.push($a(a));continue}a!=null&&a.src.length>0&&n.push({src:a.src,sizes:a.sizes??yr,...a.type!=null?{type:a.type}:{}})}return n.length>0?n:void 0}function hr(e){!Xe()||typeof MediaMetadata>"u"||(navigator.mediaSession.metadata=new MediaMetadata({title:e.title,album:e.album,artist:e.artist,artwork:qa(e.artwork)}))}function Wn(){Xe()&&(navigator.mediaSession.playbackState="playing")}function Vn(){Xe()&&(navigator.mediaSession.playbackState="paused")}function Jn(e,t,n=1){if(!Xe()||e==null||!Number.isFinite(e)||e<=0||t!=null&&isNaN(t))return;let a=Math.min(Math.max(t??0,0),e),r=Number.isFinite(n)&&n>0?n:1;try{navigator.mediaSession.setPositionState({playbackRate:r,duration:e,position:a})}catch{}}var Yn=["play","pause","stop","seekbackward","seekforward","seekto","previoustrack","nexttrack"];function Zn(e){if(Xe()){hr({title:e.title,album:e.album,artist:e.artist,artwork:e.artwork});for(let t of Yn)try{navigator.mediaSession.setActionHandler(t,n=>{e.action(n)})}catch{}}}function Qn(){if(Xe()){navigator.mediaSession.metadata=null;for(let e of Yn)try{navigator.mediaSession.setActionHandler(e,null)}catch{}}}import{useEffect as Ba,useState as Ka}from"react";var Ga={play:"Odtw\xF3rz",pause:"Wstrzymaj",previous:"Poprzedni rozdzia\u0142",next:"Nast\u0119pny rozdzia\u0142",rewind:"Cofnij o 10 sekund",forward:"Przewi\u0144 o 10 sekund",progress:"Post\u0119p odtwarzania",of:"z",speed:"Pr\u0119dko\u015B\u0107",sleep:"Wy\u0142\u0105cznik czasowy",off:"Wy\u0142\u0105czony",end:"Koniec rozdzia\u0142u",cancel:"Anuluj wy\u0142\u0105cznik",error:"Nie uda\u0142o si\u0119 odtworzy\u0107 nagrania.",retry:"Spr\xF3buj ponownie",left:"zosta\u0142o",book:"ca\u0142a ksi\u0105\u017Cka",chapter:"rozdzia\u0142",chapters:"Rozdzia\u0142y",loading:"\u0141adowanie rozdzia\u0142\xF3w\u2026",empty:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia.",resume:"Kontynuuj",chapterName:"Rozdzia\u0142",download:"Pobierz rozdzia\u0142",playing:"Teraz odtwarzane",played:"Ods\u0142uchane"},Wa={play:"Play",pause:"Pause",previous:"Previous chapter",next:"Next chapter",rewind:"Rewind 10 seconds",forward:"Forward 10 seconds",progress:"Playback progress",of:"of",speed:"Speed",sleep:"Sleep timer",off:"Off",end:"End of chapter",cancel:"Cancel timer",error:"The recording could not be played.",retry:"Try again",left:"left",book:"whole book",chapter:"chapter",chapters:"Chapters",loading:"Loading chapters\u2026",empty:"No chapters to display.",resume:"Continue",chapterName:"Chapter",download:"Download chapter",playing:"Now playing",played:"Played"};function At(e){let[t,n]=Ka("pl");return Ba(()=>{try{n(S())}catch{}},[]),(e??t).toLowerCase().startsWith("en")?Wa:Ga}function ve(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return`${t>=3600?`${Math.floor(t/3600)}:`:""}${String(Math.floor(t/60)%60).padStart(2,"0")}:${String(t%60).padStart(2,"0")}`}var W={get(e){try{return localStorage.getItem(e)}catch{return null}},set(e,t){try{localStorage.setItem(e,t)}catch{}},remove(e){try{localStorage.removeItem(e)}catch{}}},br="__player__speed",Dt=[.75,1,1.25,1.5,1.75,2];import{jsx as D,jsxs as $}from"react/jsx-runtime";var ri=ei(({chapters:e,locale:t,styles:n,updateCurrentTime:a,setCurrentTimeHandler:r,title:o,imageURL:i,coverShownBeside:d,author:c,uniqueProductID:l,onChapterChange:b,onError:P,onExpiredUrl:w,onFinished:h},y)=>{let u=At(t),[m,p]=ke(1),x=K(1),[U,le]=ke(),[E,de]=ke("off"),[Ce,ee]=ke(0),A=K({mode:"off",deadline:0});function fe(){A.current={mode:"off",deadline:0},de("off"),ee(0)}function J(s){let g=Number(s)*60;A.current={mode:s,deadline:Number.isFinite(g)?Date.now()+g*1e3:0},de(s),ee(Number.isFinite(g)?g:0)}function He(s){Dt.includes(s)&&(p(s),x.current=s,W.set(br,String(s)),_.current&&(_.current.playbackRate=s),B())}ze(()=>{let s=Number(W.get(br));Dt.includes(s)&&He(s);let g=setInterval(()=>{let{mode:k,deadline:T}=A.current;if(k==="off"||k==="chapter")return;let be=Math.max(0,Math.ceil((T-Date.now())/1e3));ee(be),be===0&&(Me.current=!1,xt(),fe())},1e3);return()=>clearInterval(g)},[]);let Y;(k=>(k[k.Playing=0]="Playing",k[k.Paused=1]="Paused"))(Y||={});let[De,lt]=ke(1),[Ht,Ne]=ke(void 0),[C,ge]=ke(void 0),[$e,ce]=ke(!1),[vt,Fr]=ke(null),_=K(null),ye=K(null),kt=K(void 0),Go=K(null),te=K(null),$t=K(null),Me=K(!1),qe=K(!1),dt=K(null),qt=K(null),Bt=K(e),Hr=K(null),re=K({onChapterChange:b,onError:P,onExpiredUrl:w,onFinished:h,updateCurrentTime:a,title:o,imageURL:i,author:c});re.current={onChapterChange:b,onError:P,onExpiredUrl:w,onFinished:h,updateCurrentTime:a,title:o,imageURL:i,author:c};function Kt(s){!qe.current||!Number.isFinite(s)||s<0||W.set(`__player__${l}_${te.current?.id}`,`${Math.floor(s)}`)}function Wo(){let s=W.get(`__player__${l}_${te.current?.id}`);if(s!=null)try{let g=parseInt(s);return isNaN(g)||g<0?void 0:g}catch{return}}function Vo(){let s=W.get(`__player__${l}_last_chapter`);if(s!=null)return s}function $r(s){W.set(`__player__${l}_last_chapter`,s)}function qr(s){W.remove(`__player__${l}_${s}`)}function Gt(s){hr({title:s?.name??re.current.title??"",album:re.current.title,artist:re.current.author,artwork:re.current.imageURL})}function Br(s){$t.current=s,Fr(s),ce(!1),re.current.onError?.(s)}function Kr(){$t.current=null,Fr(null)}function Gr(){let s=_.current;if(s==null)return;let g=s.play();g!=null&&typeof g.catch=="function"&&g.catch(()=>{}),B()}function Wr(){Gr()}function xt(){_.current?.pause(),B()}function Jo(){if(De===0){xt();return}Wr()}function Ie(s){let g=_.current;if(g==null||!Number.isFinite(s))return;let k=Number.isFinite(g.duration)?g.duration:0,T=k>0?Math.min(Math.max(s,0),k):Math.max(s,0);Ne(T),g.currentTime=T,B()}function wt(s){let g=_.current;if(g==null)return;let k=Number.isFinite(g.duration)?g.duration:void 0,T=Math.max(g.currentTime+s,0);k!=null&&T>k&&(T=k),Ie(T)}function Wt(s){let g=_.current;if(g!=null){if(Kr(),ce(!0),Kn(g)){Vt(),g.src=s,g.load();return}if(Ja.isSupported()){ye.current==null&&(ye.current=Bn({media:g,handlers:{onError:k=>{Br(k)},onExpiredUrl:()=>{re.current.onExpiredUrl?.()}}})),ye.current.load(s);return}Vt(),g.src=s,g.load()}}function Vt(){ye.current?.destroy(),ye.current=null}function Ct(s,g){let k=g?.play===!0;te.current&&_.current&&!_.current.ended&&Kt(_.current.currentTime),qe.current=!1,dt.current=null,Me.current=k,te.current=s,le(s.id),Ne(0),ge(s.duration),Wt(s.publicUrl),Gt(s),re.current.onChapterChange?.(s),$r(s.id)}function Jt(s){if(s.length===0)return;let g=Vo(),k=(g!=null?s.find(T=>T.id===g):void 0)??s[0];Ct(k,{play:!1})}function Yt(){let s=Bt.current,g=te.current;if(s==null||s.length===0||g==null)return;let k=s.findIndex(be=>be.id===g.id);if(k===-1)return;let T=k+1;if(T>=s.length){Yo(g);return}Ct(s[T],{play:!0})}function Vr(){let s=Bt.current,g=te.current;if(g==null)return;let k=_.current;if(k!=null&&k.currentTime>3){Ie(0);return}let T=s==null?-1:s.findIndex(be=>be.id===g.id);if(T>0){Ct(s[T-1],{play:!0});return}Ie(0)}function Yo(s){qr(s.id),Me.current=!1,_.current?.pause(),lt(1),re.current.onFinished?.()}function Jr(){let s=te.current;if(s!=null){if(W.set(`__player__${l}_${s.id}_completed`,"true"),qr(s.id),A.current.mode==="chapter"){Me.current=!1,xt(),fe();return}Yt(),B()}}function Yr(){let s=_.current;if(s!=null){if(ce(!1),s.playbackRate=x.current,qt.current=null,!qe.current){qe.current=!0;let g=dt.current;if(dt.current=null,g!=null)Ie(g);else{let k=Wo();k!=null&&Ie(k)}}Me.current&&(Me.current=!1,Gr())}}function Zr(){let s=_.current?.error,g=te.current?.publicUrl;(s?.code===2||s?.code===4)&&ye.current==null&&g!=null&&qt.current!==g&&(qt.current=g,re.current.onExpiredUrl?.()),Br(Gn(s))}function Qr(){let g=te.current?.publicUrl??ye.current?.src;if(g==null)return;let T=_.current?.currentTime??0;Kr(),qe.current=!1,dt.current=T>0?T:null,Ne(T),ye.current!=null?ye.current.retry():Wt(g)}function Zo(s){switch(s.action){case"play":Wr();break;case"pause":case"stop":xt();break;case"seekbackward":wt(-(s.seekOffset??10));break;case"seekforward":wt(s.seekOffset??10);break;case"seekto":s.seekTime!=null&&Ie(s.seekTime);break;case"previoustrack":Vr();break;case"nexttrack":Yt();break;default:break}}ti(y,()=>({selectChapter:s=>{Ct(s,{play:!0})},retry:Qr,getError:()=>$t.current}));function B(){let s=_.current;s!=null&&(lt(s.paused?1:0),ge(s.duration),Ne(s.currentTime),s.ended||Kt(s.currentTime),Jn(s.duration,s.currentTime,s.playbackRate),s.networkState===s.NETWORK_LOADING&&s.readyState<=s.HAVE_FUTURE_DATA?ce(!0):ce(!1),re.current.updateCurrentTime?.(s.currentTime))}ze(()=>(Zn({title:o??"",album:o,artist:c,artwork:i,action:Zo}),()=>{Qn()}),[]),ze(()=>{Gt(te.current)},[o,c,i]),ze(()=>{let s=_.current;if(s!=null)return s.addEventListener("loadeddata",Yr),s.addEventListener("ended",Jr),s.addEventListener("error",Zr),s.addEventListener("timeupdate",B),s.addEventListener("play",B),s.addEventListener("pause",B),s.addEventListener("ratechange",B),B(),kt.current=setInterval(B,500),()=>{s.removeEventListener("loadeddata",Yr),s.removeEventListener("ended",Jr),s.removeEventListener("error",Zr),s.removeEventListener("timeupdate",B),s.removeEventListener("play",B),s.removeEventListener("pause",B),s.removeEventListener("ratechange",B),kt.current!=null&&(clearInterval(kt.current),kt.current=void 0),s.ended||Kt(s.currentTime),Ne(void 0),s.pause(),Vt(),s.removeAttribute("src"),s.load()}},[]),ze(()=>{r?.(Ie)},[]);let Zt=e.map(s=>`${s.id}|${s.publicUrl??""}`).join(`
|
|
4
|
+
`);ze(()=>{Bt.current=e;let s=Hr.current;if(s===Zt)return;if(Hr.current=Zt,s==null){Jt(e);return}let g=te.current;if(g==null){Jt(e);return}let k=e.find(T=>T.id===g.id);if(!(k!=null&&k.publicUrl===g.publicUrl)){if(k!=null){let T=_.current,be=T?.currentTime??0,Xo=T!=null&&!T.paused;te.current=k,qe.current=!1,dt.current=be>0?be:null,Me.current=Xo,Wt(k.publicUrl),Gt(k),re.current.onChapterChange?.(k),$r(k.id);return}Jt(e)}},[Zt]),ze(()=>{switch(De){case 0:Wn();break;case 1:Vn();break}},[De]);let Be=e.findIndex(s=>s.id===U),he=Number.isFinite(C)&&C>0?C:e[Be]?.duration??0,ct=Math.min(Math.max(Ht??0,0),he||1/0),Xr=e.length>0&&e.every(s=>Number.isFinite(s.duration)&&s.duration>0),Qo=Math.max(0,he-ct+(Xr?e.slice(Be+1).reduce((s,g)=>s+g.duration,0):0))/m,Qt=Math.ceil(Qo/60),en=`${Math.floor(Qt/60)>0?`${Math.floor(Qt/60)} h `:""}${Qt%60} min`;return $("div",{id:"audio-player-container",className:"bitsnap-audio-player flex min-w-0 flex-col gap-3 text-neutral-900 dark:text-neutral-100",style:{...n,"--seek-before-width":`${he>0?ct/he*100:0}%`},ref:Go,"data-player-error":vt?.kind,children:[D("video",{ref:_,className:"hidden",poster:i,title:o}),$("div",{className:j("flex min-w-0 items-center gap-3",d&&"lg:hidden"),children:[i&&D("img",{src:i,alt:"",className:"h-16 w-16 shrink-0 rounded object-contain"}),$("div",{className:"min-w-0 break-words",children:[D("p",{className:"font-semibold",children:e[Be]?.name??o}),c&&D("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:c})]})]}),vt&&$("div",{role:"alert",className:"rounded-lg bg-red-50 p-3 text-red-800 dark:bg-red-950 dark:text-red-200",children:[D("p",{children:u.error}),D(I,{variant:"outline",onClick:Qr,children:u.retry})]}),D("input",{type:"range",min:"0",max:he||100,value:ct,disabled:!he,"aria-label":u.progress,"aria-valuetext":`${ve(ct)} ${u.of} ${ve(he)}`,onChange:s=>Ie(Number(s.target.value))}),$("section",{className:"flex w-full justify-between text-sm tabular-nums",children:[D("span",{id:"current-time",children:ve(ct)}),D("span",{id:"duration",children:ve(he)})]}),he>0&&$("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:[u.left==="left"?`${en} ${u.left}`:`${u.left} ${en}`," ","\xB7 ",Xr?u.book:u.chapter," (",m,"\xD7)"]}),$("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[D(I,{variant:"outline",onClick:Vr,disabled:Be<0,"aria-label":u.previous,children:D(Qa,{className:"h-5 w-5"})}),$(I,{variant:"outline",onClick:()=>wt(-10),"aria-label":u.rewind,children:["\u2212",10]}),D(I,{variant:"outline",onClick:Jo,"aria-label":De===1?u.play:u.pause,children:De===1?D(Za,{className:"h-5 w-5"}):D(Ya,{className:"h-5 w-5"})}),$(I,{variant:"outline",onClick:()=>wt(10),"aria-label":u.forward,children:["+",10]}),D(I,{variant:"outline",onClick:Yt,disabled:Be<0||Be>=e.length-1,"aria-label":u.next,children:D(Xa,{className:"h-5 w-5"})})]}),$("div",{className:"flex flex-wrap gap-3 md:grid md:grid-cols-2",children:[$("label",{className:"flex flex-1 items-center gap-2 text-sm md:flex-col md:items-start md:whitespace-nowrap",children:[u.speed,D("select",{"aria-label":u.speed,value:m,onChange:s=>He(Number(s.target.value)),children:Dt.map(s=>$("option",{value:s,children:[s,"\xD7"]},s))})]}),$("label",{className:"flex flex-1 items-center gap-2 text-sm md:flex-col md:items-start md:whitespace-nowrap",children:[u.sleep,$("select",{"aria-label":u.sleep,value:E,onChange:s=>J(s.target.value),children:[D("option",{value:"off",children:u.off}),[15,30,45,60].map(s=>$("option",{value:s,children:[s," min"]},s)),D("option",{value:"chapter",children:u.end})]})]})]}),E!=="off"&&$("div",{className:"flex items-center justify-between gap-2 text-sm",children:[D("span",{role:"timer",children:E==="chapter"?u.end:ve(Ce)}),D(I,{variant:"outline",onClick:fe,children:u.cancel})]}),$e&&D("div",{role:"status",className:"flex justify-center",children:D(_e,{})})]})}),Xn=ri;import{Check as ni,Download as oi,Play as ai}from"lucide-react";import{useEffect as ii,useState as eo}from"react";import{Fragment as si,jsx as se,jsxs as tt}from"react/jsx-runtime";function Pr({chapters:e,currentID:t,productID:n,onSelect:a,downloadable:r,onDownload:o,loading:i,locale:d}){let c=At(d),[l,b]=eo(null),[P,w]=eo([]);ii(()=>{let u=`__player__${n}_`,m=W.get(`${u}last_chapter`),p=Number(m&&W.get(`${u}${m}`));b(m&&p>0&&Number.isFinite(p)?{id:m,time:p}:null),w((e??[]).filter(x=>W.get(`${u}${x.id}_completed`)==="true"||Number(W.get(`${u}${x.id}`))>0).map(x=>x.id))},[e,n,t]);let h=e?.findIndex(u=>u.id===l?.id)??-1,y=e?.findIndex(u=>u.id===t)??-1;return tt("div",{className:"max-h-96 w-full overflow-y-auto",children:[se("h2",{className:"mb-3 text-xl font-semibold",children:c.chapters}),i?se("p",{role:"status",children:c.loading}):e?.length?tt(si,{children:[l&&h>=0&&tt("button",{type:"button",className:"mb-3 min-h-11 rounded-lg border border-neutral-300 px-3 py-2 text-left dark:border-neutral-600",onClick:()=>a(e[h]),children:[c.resume,": ",c.chapterName," ",h+1,","," ",ve(l.time)]}),se("ul",{className:"flex w-full flex-col gap-2",children:e.map((u,m)=>{let p=u.id===t,x=m<y||P.includes(u.id);return tt("li",{className:"flex min-w-0 items-center gap-2",children:[tt("button",{type:"button","aria-current":p?"true":void 0,className:`min-h-11 min-w-0 flex-1 rounded-lg p-3 text-left hover:bg-neutral-200 dark:hover:bg-neutral-700 ${p?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800"}`,onClick:()=>a(u),children:[tt("span",{className:"flex items-center gap-2",children:[p?se(ai,{className:"size-4 shrink-0","aria-label":c.playing}):x?se(ni,{className:"size-4 shrink-0","aria-label":c.played}):null,se("span",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:u.name}),!!u.duration&&se("span",{className:"shrink-0 text-xs tabular-nums text-neutral-600 dark:text-neutral-300",children:ve(u.duration)})]}),u.description&&se("span",{className:"mt-2 block text-xs",children:u.description})]}),r&&u.downloadableUrl&&se("a",{href:u.downloadableUrl,onClick:o,"aria-label":`${c.download} ${m+1}`,className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",children:se(oi,{className:"size-4","aria-hidden":"true"})})]},u.id)})})]}):se("p",{children:c.empty})]})}import{Fragment as Mt,jsx as N,jsxs as V}from"react/jsx-runtime";function xe(e,...t){console.warn(e,...t)}function vr(e){console.error(e)}var ui=({accessToken:e,product:t,styles:n,reveal:a})=>{let r=Qe(),o=t.productType,i=St(),d=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),c=ro(null),[l]=li(),[b,P]=je(!1),[w,h]=je(null),{mutateAsync:y,isPending:u}=oe(H.publicApi.userPanelGetFileDetails),m=ro(void 0),[p,x]=je(null),[U,le]=je(null),[E,de]=je(!1),{mutateAsync:Ce,isPending:ee}=oe(H.publicApi.userPanelGetAudiobookDetails),{mutateAsync:A,isPending:fe}=oe(H.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[J,He]=je(null),[Y,De]=je(null);async function lt(){P(!1);try{let C=await y({accessId:t.accessId,accessToken:e});if(C.result.case==="success"){h(C.result.value.files);return}else P(!0),xe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),xe("Kod b\u0142\u0119du: ",C.result.value)}catch(C){P(!0),xe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),vr("B\u0142\u0105d podczas pobierania danych:"+C)}}async function Ht(){try{let C=await Ce({accessId:t.accessId,accessToken:e});if(C.result.case==="audiobook"){x(C.result.value);return}else xe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),xe("Kod b\u0142\u0119du: ",C.result.value)}catch(C){xe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),vr("B\u0142\u0105d podczas pobierania danych:"+C)}}async function Ne(){try{let C=await A({accessId:t.accessId,accessToken:e,isBrowser:!0});if(C.result.case==="success"){le(C.result.value.audiobookDownloadDetails),de(C.result.value.isAvailableToDownloadInMobileApp===!0);return}else xe("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),xe("Kod b\u0142\u0119du: ",C.result.value)}catch(C){xe("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),vr("B\u0142\u0105d podczas pobierania danych:"+C)}}return to(()=>{o===2&<(),o===1&&(Ht().then().catch(),Ne().then().catch())},[]),to(()=>{if(p!=null&&U!=null){let C=p.chapters;if(!C)return;let ge=C.map($e=>{let ce=U?.find(vt=>vt.chapterId===$e.id);if(ce!=null)return{...$e,publicUrl:ce.publicUrl,downloadableUrl:ce.downloadableUrl,duration:ce.duration}}).filter($e=>$e!=null);ge!=null&&ge.length>0&&De(ge)}},[p,U]),V("div",{children:[N("div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:V(I,{onClick:()=>a(),variant:"ghost",className:"min-h-11 w-fit",children:[N(di,{className:"h-6 w-6"}),N("span",{className:"font-inter text-sm font-medium",children:r.back})]})}),V("main",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[V("header",{className:"flex min-w-0 flex-col gap-4 rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900 lg:row-span-2 lg:self-start",children:[N("img",{src:t.productImageUrl,alt:t.productName,width:384,height:384,draggable:!1,className:"aspect-square max-h-72 w-full object-contain"}),N("h2",{className:"text-2xl font-semibold",children:t.productName})]}),V("div",{className:"flex min-w-0 flex-col gap-6",children:[o===2&&V("section",{ref:l,className:"flex flex-col gap-4 rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:[N("h3",{className:"text-xl font-semibold",children:r.yourFiles}),u&&N("div",{role:"status","aria-label":r.loading,children:N(_e,{})}),b&&V("div",{role:"alert",children:[N("p",{children:r.fileError}),N(I,{className:"min-h-11",onClick:lt,children:r.retry})]}),w?.length===0&&N("p",{children:r.noFiles}),w&&N("ul",{className:"flex flex-col gap-3",children:w.map((C,ge)=>V("li",{className:"flex min-w-0 flex-wrap items-center justify-between gap-3",children:[N("span",{className:"min-w-0 break-all text-sm",children:no(C)||`${r.file} ${ge+1}`}),V("a",{target:"_blank",rel:"noopener noreferrer",href:C,download:!0,onClick:d,className:"inline-flex min-h-11 items-center gap-2 rounded-md bg-neutral-900 px-3 py-2 text-sm text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 dark:bg-neutral-100 dark:text-neutral-900","aria-label":`${r.download}: ${no(C)||`${r.file} ${ge+1}`}`,children:[r.download,N(ci,{className:"size-4","aria-hidden":"true"})]})]},C))})]}),o===3&&V("section",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:[N("h3",{className:"text-lg font-semibold",children:r.ticket}),N("p",{className:"mt-2 font-medium",children:t.productName}),N("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-300",children:r.ticketInfo})]}),o===1&&N(Mt,{children:V("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:[N("h4",{className:"text-xl font-semibold",children:J?.name??"Odtwarzacz"}),J?.description&&N("p",{className:"text-sm",children:J?.description}),N(Mt,{children:ee?V("div",{className:"flex gap-2",children:[N(_e,{}),N("p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):N(Mt,{children:Y!=null?N(Mt,{children:N(Xn,{ref:c,coverShownBeside:!0,chapters:Y,author:typeof p?.author=="string"?p.author:void 0,onExpiredUrl:()=>{Ne()},title:p?.name??t.productName??void 0,imageURL:p?.coverImage??t.productImageUrl??void 0,styles:n,setCurrentTimeHandler:C=>{m.current=C},uniqueProductID:t.productId,onChapterChange:C=>{He(C)}})}):N("p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),V("div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[N("p",{className:"mt-3 mb-3 text-xs",children:E?"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."}),V("div",{className:"flex gap-3",children:[N("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:N("img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),N("a",{href:"https://play.google.com/store/apps/details?id=com.bitsnap.Bitsnap",children:N("img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),N("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&&N(Pr,{chapters:Y,currentID:J?.id,productID:t.productId,loading:ee,downloadable:p?.isDownloadable===!0,onDownload:d,onSelect:C=>c.current?.selectChapter(C)})})]}),N("section",{className:"rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-700 dark:bg-neutral-900",children:N("p",{className:"whitespace-pre-wrap text-sm text-neutral-600 dark:text-neutral-300",children:t.productDescription})})]})]})},oo=ui;function no(e){try{return decodeURIComponent(new URL(e,"https://bitsnap.pl").pathname.split("/").pop()||"")}catch{return""}}import{useTransport as pi}from"@connectrpc/connect-query";import{useEffect as mi,useState as fi}from"react";function ao(e,t){let n=pi(),[a,r]=fi({status:"loading"});return mi(()=>{if(!e){r({status:"hidden"});return}let o=!1;return r({status:"loading"}),import("./model-files-client-HHDXJDTS.mjs").then(({listModelFiles:i})=>i(n,e,t)).catch(()=>({status:"hidden"})).then(i=>{o||r(i)}),()=>{o=!0}},[n,e,t]),a}import{Fragment as lo,jsx as O,jsxs as Le}from"react/jsx-runtime";var wi=gi(()=>import("./PanelModelFiles-JZFSF7BF.mjs")),Ci=({accessToken:e,projectID:t,loginURL:n,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d})=>{let{host:c}=Pe(),{data:l,isLoading:b,error:P,refetch:w}=Ge(H.publicApi.userPanelGetProducts,{accessToken:e}),h=ao(e,t),y=Ni({products:b?{status:"loading"}:P!=null?{status:"error"}:l?.result.case==="success"?{status:"ok",count:l.result.value.products.length}:l?.result.case==="failure"?{status:"failure",unauthorized:l.result.value===9}:{status:"error"},modelFiles:h});if(kr(()=>{y.kind==="signed-out"&&(Ve(t,c),window.location.href=n)},[y.kind,t,c,n]),y.kind==="loading"||y.kind==="signed-out")return O("div",{role:"status","aria-label":Qe().loading,"aria-busy":"true",className:"grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:Array.from({length:6},(x,U)=>O("div",{"aria-hidden":"true",className:"h-72 rounded-xl bg-neutral-100 motion-safe:animate-pulse dark:bg-neutral-800"},U))});let u=l&&l.result.case==="success"?l.result.value.products:[],m=h.status==="ready"?h.models:[],p=m.length>0?O(yi,{fallback:null,children:O(wi,{accessToken:e,models:m,buttonStyle:a})}):null;return y.kind==="error"?Le(lo,{children:[O(Si,{onRetry:()=>void w()}),p]}):y.kind==="empty"?O(Ii,{}):O(Ei,{accessToken:e,products:u,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d,filesSection:p})};function Ni({products:e,modelFiles:t}){if(e.status==="failure"&&e.unauthorized)return{kind:"signed-out"};if(e.status==="loading")return{kind:"loading"};if(e.status==="ok"&&e.count>0)return{kind:"list"};if(t.status==="loading")return{kind:"loading"};if(e.status==="failure"||e.status==="error")return t.status==="unauthorized"?{kind:"signed-out"}:{kind:"error"};let n=t.status==="ready"?t.models.length:0;return e.count===0&&n===0?{kind:"empty"}:{kind:"list"}}function Ii(){let e=Qe();return Le("div",{className:"flex flex-col items-start gap-1","data-testid":"panel-empty",children:[O("h3",{className:"text-2xl",children:e.hello}),O("p",{className:"text-sm text-neutral-500",children:e.empty})]})}function Si({onRetry:e}){let t=S().toLowerCase().startsWith("en");return Le("div",{className:"flex flex-col items-start gap-3",role:"alert","data-testid":"panel-error",children:[O("p",{className:"text-sm text-neutral-600 dark:text-neutral-300",children:t?"Your products could not be loaded.":"Nie uda\u0142o si\u0119 wczyta\u0107 Twoich produkt\xF3w."}),O(I,{type:"button",onClick:e,className:"text-sm",children:t?"Try again":"Spr\xF3buj ponownie"})]})}var so=Ci,Ei=({accessToken:e,products:t,styles:n,filesSection:a,activeScreen:r,params:o,setParams:i,openCourse:d})=>{let c=Qe(),[l,b]=hi(()=>io(o.product,t));kr(()=>{b(io(o.product,t))},[o.product,t]);let P=h=>{b(h),i({product:h?h.accessId||h.productId:void 0,state:"products"})};kr(()=>{r==="products"&&l?.productType===4&&d(l.accessId)},[r,l,d]);function w(h){if(h.productType===4){d(h.accessId);return}P(h)}return r==="products"&&l?.productType===4?null:r==="products"&&l!=null?O(oo,{accessToken:e,product:l,styles:n,reveal:P,onOpenCourse:d}):Le(lo,{children:[O("h3",{className:"text-2xl",children:c.hello}),t.length>0&&O("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:c.intro}),O("div",{className:"mt-6 grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5",children:t.map(h=>{let[y,u,m]=h.productType===1?[c.audio,c.listen,vi]:h.productType===4?[c.course,c.openCourse,bi]:h.productType===3?[c.ticket,c.showTicket,ki]:[c.files,c.downloadFiles,Pi];return Le("button",{type:"button",onClick:()=>w(h),className:"flex min-h-11 min-w-0 flex-col overflow-hidden rounded-xl border border-neutral-200 bg-white text-left text-neutral-900 transition-colors hover:border-neutral-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:hover:border-neutral-500",children:[Le("span",{className:"flex w-full flex-col gap-3 bg-neutral-100 p-3 dark:bg-neutral-800",children:[Le("span",{className:"flex w-fit items-center gap-1.5 rounded-md bg-white px-2 py-1 text-xs font-medium dark:bg-neutral-900",children:[O(m,{className:"size-4","aria-hidden":"true"}),y]}),O("img",{src:h.productImageUrl,alt:h.productName,draggable:!1,className:"aspect-square w-full object-contain"})]}),Le("span",{className:"flex flex-1 flex-col gap-3 p-3",children:[O("span",{className:"line-clamp-2 font-semibold",children:h.productName}),O("span",{className:"line-clamp-2 text-sm text-neutral-600 dark:text-neutral-300",children:Hn(h.productDescription)}),O("span",{className:"mt-auto pt-2 text-sm font-medium underline underline-offset-4",children:u})]})]},h.accessId||h.productId)})}),a]})};function io(e,t){if(!e)return;let n=t.find(a=>(a.accessId||a.productId)===e||a.productId===e);if(n)return n;try{let a=xi(rn,e);return t.find(r=>a.accessId?r.accessId===a.accessId:r.productId===a.productId)}catch{return}}import{LogOut as Di}from"lucide-react";import{Library as Ti,Receipt as Li,Undo2 as Ri,User as Ai}from"lucide-react";var co=[{screen:"products",label:"libraryNavLabel",icon:Ti},{screen:"orders",label:"ordersNavLabel",icon:Li},{screen:"returns",label:"returnsNavLabel",icon:Ri},{screen:"profile",label:"accountNavLabel",icon:Ai}];function uo(e){return e==="course"?"products":e==="order-details"?"orders":e==="return-details"?"returns":e}import{jsx as Fe,jsxs as ht}from"react/jsx-runtime";function xr({activeScreen:e,setActiveScreen:t,setParams:n,theme:a,logout:r,email:o,projectID:i}){let d=ue(),{data:c}=sn(i??"",!!i);return ht("header",{className:"flex h-14 shrink-0 items-center border-b border-neutral-200 bg-white px-4 md:h-dvh md:w-56 md:flex-col md:items-stretch md:border-r md:border-b-0 md:py-5 dark:border-neutral-800 dark:bg-neutral-900",children:[ht("div",{className:"flex min-w-0 items-center gap-3 md:mb-6 md:flex-col md:items-start",children:[Fe(Tt,{projectId:i,logoUrl:a?.logoURL,logoDarkUrl:a?.logoDarkURL,name:c?.name,className:"shrink-0"}),c?.name&&Fe("span",{title:c.name,className:"truncate text-sm font-medium md:line-clamp-2 md:whitespace-normal",children:c.name})]}),Fe("nav",{"aria-label":d.navigationLabel,className:"fixed inset-x-0 bottom-0 z-10 flex h-[calc(56px+env(safe-area-inset-bottom))] items-start justify-around border-t border-neutral-200 bg-white pb-[env(safe-area-inset-bottom)] md:static md:h-auto md:flex-1 md:flex-col md:justify-start md:gap-2 md:border-0 md:bg-transparent md:pb-0 dark:border-neutral-800 dark:bg-neutral-900",children:co.map(({screen:l,label:b,icon:P})=>{let w=uo(e)===l;return ht("button",{type:"button","aria-current":w?"page":void 0,onClick:()=>{t(l),n({product:void 0,state:l})},className:j("flex h-14 min-h-11 min-w-0 flex-1 flex-col items-center justify-center gap-1 px-1 text-[11px] focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-current md:h-11 md:w-full md:flex-none md:flex-row md:justify-start md:gap-3 md:rounded-md md:px-3 md:text-sm",w?"bg-neutral-100 font-semibold text-black dark:bg-neutral-800 dark:text-white":"text-neutral-600 hover:bg-neutral-100 dark:text-neutral-400 dark:hover:bg-neutral-800"),children:[Fe(P,{className:"h-5 w-5 shrink-0","aria-hidden":"true"}),Fe("span",{children:d[b]})]},l)})}),ht("div",{className:"hidden border-t border-neutral-200 pt-4 md:block dark:border-neutral-800",children:[o&&Fe("p",{title:o,className:"mb-3 truncate text-sm text-neutral-600 dark:text-neutral-400",children:o}),ht("button",{type:"button",onClick:r,className:"flex min-h-11 w-full items-center gap-3 rounded-md px-3 text-sm text-red-700 hover:bg-red-50 focus-visible:outline-2 focus-visible:outline-current dark:text-red-400 dark:hover:bg-neutral-800",children:[Fe(Di,{className:"h-4 w-4","aria-hidden":"true"}),d.logout]})]})]})}import{useState as Mi}from"react";import{LogOut as Oi}from"lucide-react";import{jsx as Re,jsxs as rt}from"react/jsx-runtime";function wr({email:e,logout:t,onLocaleChange:n}){let[a,r]=Mi(S),o=ue(a);return rt("section",{className:"w-full max-w-xl",children:[Re("h3",{className:"text-2xl",children:o.accountNavLabel}),Re("h4",{className:"mt-6 mb-2 text-sm font-medium text-neutral-600 dark:text-neutral-400",children:o.profileHeading}),rt("div",{className:"divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white dark:divide-neutral-800 dark:border-neutral-800 dark:bg-neutral-900",children:[rt("div",{className:"p-4",children:[Re("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:o.emailLabel}),Re("p",{className:"mt-1 break-words",children:e||o.noData})]}),rt("label",{className:"flex min-h-11 flex-wrap items-center justify-between gap-3 p-4",children:[Re("span",{children:o.languageLabel}),rt("select",{value:a.toLowerCase().startsWith("en")?"en-US":"pl-PL",onChange:i=>{ar(i.target.value),r(i.target.value),n?.()},className:"min-h-11 rounded-md border border-neutral-300 bg-white px-3 focus-visible:outline-2 focus-visible:outline-current dark:border-neutral-700 dark:bg-neutral-900",children:[Re("option",{value:"pl-PL",children:o.polishLanguage}),Re("option",{value:"en-US",children:o.englishLanguage})]})]})]}),rt("button",{type:"button",onClick:t,className:"mt-6 flex min-h-11 w-full items-center gap-3 rounded-lg border border-neutral-200 bg-white px-4 py-3 text-red-700 hover:bg-red-50 focus-visible:outline-2 focus-visible:outline-current dark:border-neutral-800 dark:bg-neutral-900 dark:text-red-400 dark:hover:bg-neutral-800",children:[Re(Oi,{className:"h-5 w-5","aria-hidden":"true"}),o.logout]})]})}import{lazy as Ui,Suspense as _i}from"react";import{jsx as bt}from"react/jsx-runtime";var zi=Ui(()=>import("./course.mjs").then(e=>({default:e.PanelCourse})));function Cr(e){return bt(_i,{fallback:bt("div",{className:"flex items-center gap-2 p-2",role:"status",children:bt(_e,{})}),children:bt("div",{className:"[--course-mobile-bottom:calc(56px+env(safe-area-inset-bottom))] md:[--course-mobile-bottom:0px]",children:bt(zi,{...e})})})}import{AlertCircle as yo,CheckCircle2 as po,ChevronLeft as ji,Loader2 as Ir,Lock as mo,Package as Fi,Truck as ho}from"lucide-react";import{useEffect as Hi,useState as Nr}from"react";import{Fragment as bo,jsx as f,jsxs as v}from"react/jsx-runtime";function $i({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:po},completed:{color:"bg-blue-100 text-blue-700",icon:po},canceled:{color:"bg-red-100 text-red-700",icon:yo},sent:{color:"bg-purple-100 text-purple-700",icon:ho},processing:{color:"bg-yellow-100 text-yellow-700",icon:Ir}},n=t[e]||t.created,a=n.icon,r={created:"Utworzone",paid:"Op\u0142acone",completed:"Zako\u0144czone",canceled:"Anulowane",sent:"Wys\u0142ane",processing:"Przetwarzane"};return v("span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${n.color}`,children:[a&&f(a,{className:"h-4 w-4"}),r[e]||e]})}function qi({orderID:e,email:t}){let[n,a]=Nr(""),r=oe(H.publicApi.addPublicOrderComment);return v("form",{onSubmit:async i=>{if(i.preventDefault(),!!n.trim())try{await r.mutateAsync({projectId:"",orderId:e,message:n.trim(),accessToken:t}),a("")}catch(d){console.error("Failed to add comment:",d)}},className:"mt-4 space-y-2",children:[f(We,{htmlFor:"comment",children:"Dodaj komentarz"}),f(yn,{id:"comment",value:n,onChange:i=>a(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),f(I,{type:"submit",disabled:!n.trim()||r.isPending,children:r.isPending?v(bo,{children:[f(Ir,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function fo(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function go(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function Bi({orderID:e,initialEmail:t,onBack:n,accessToken:a,analytics:r}){let{theme:o,projectID:i}=Pe(),d=Ke(i,r,"order"),[c,l]=Nr(t||""),[b,P]=Nr(!1),{data:w,isLoading:h,error:y,refetch:u}=Ge(H.publicApi.getPublicOrderDetails,{projectId:i??"",orderId:e,email:c||void 0,accessToken:a},{enabled:!!e}),m=w?.result.case==="order"?w.result.value:null,p=m?.isVerified??!1,x=m!=null;Hi(()=>{x&&d.track("panel_order_viewed",{},{order_ref:null})},[d,x]);let U=()=>{u(),P(!1)},le={"--button-background-color":o?.colors?.brand??"#000000","--button-background-color-dark":o?.colors?.brandDark??"#ffffff","--button-text-color":o?.colors?.brandDark??"#000000","--button-text-color-dark":o?.colors?.brand??"#000000"};return h?f("div",{className:"flex min-h-screen items-center justify-center",children:v("div",{className:"text-center",children:[f(Ir,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),f("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):y||!m?f("div",{className:"flex min-h-screen items-center justify-center",children:f(Ee,{className:"w-full max-w-md",children:f(Te,{className:"pt-6",children:v("div",{className:"text-center",children:[f(yo,{className:"mx-auto h-12 w-12 text-red-500"}),f("h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),f("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):f("div",{className:"w-full bg-white py-8 dark:bg-black",style:le,children:v("div",{className:"w-full px-4",children:[n&&v(I,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[f(ji,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),v("div",{className:"mb-6 flex items-center gap-4",children:[o?.logoURL&&v(bo,{children:[f("img",{src:o.logoURL,alt:"Project logo",className:`h-12 w-auto ${o.logoDarkURL?"dark:hidden":""}`}),o.logoDarkURL&&f("img",{src:o.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),v("div",{children:[f("h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),v("p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",m.orderId]})]})]}),v(Ee,{className:"mb-6",children:[f(Oe,{children:v(Ue,{className:"flex items-center",children:[f(Fi,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),v(Te,{className:"space-y-6",children:[v("div",{children:[v("div",{className:"flex items-center gap-2",children:[f($i,{status:m.status}),m.processingStatus&&v("span",{className:"text-sm text-neutral-600",children:["\xB7 ",m.processingStatus]})]}),v("p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",fo(m.createdAt)]})]}),v("div",{className:"border-t pt-4",children:[f("h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),v("div",{className:"space-y-2",children:[v("div",{children:[f("span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",f("span",{className:p?"":"text-neutral-500",children:m.customerName})]}),v("div",{children:[f("span",{className:"font-medium",children:"Email:"})," ",f("span",{className:p?"":"text-neutral-500",children:m.customerEmail})]}),m.customerPhone&&v("div",{children:[f("span",{className:"font-medium",children:"Telefon:"})," ",f("span",{className:p?"":"text-neutral-500",children:m.customerPhone})]})]})]}),!p&&f("div",{className:"border-t pt-4",children:v(I,{onClick:()=>P(!0),variant:"outline",className:"w-full",children:[f(mo,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),v(Ee,{className:"mb-6",children:[f(Oe,{children:f(Ue,{children:"Produkty"})}),v(Te,{className:"space-y-6",children:[f("div",{className:"space-y-4",children:m.items.map((E,de)=>v("div",{className:"flex items-center gap-4",children:[E.imageUrl&&f("img",{src:E.imageUrl,alt:E.name,className:"h-16 w-16 rounded object-cover"}),v("div",{className:"flex-1",children:[f("p",{className:"font-medium",children:E.name}),v("p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",E.quantity]})]}),f("div",{className:"text-right",children:f("p",{className:"font-medium",children:go(Number(E.price),E.currency)})})]},de))}),(m.deliveryAddress||m.deliveryMethod)&&v("div",{className:"border-t pt-4",children:[v("h3",{className:"mb-3 flex items-center font-semibold",children:[f(ho,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),v("div",{className:"space-y-2",children:[m.deliveryAddress&&v("div",{children:[f("span",{className:"font-medium",children:"Adres:"})," ",f("span",{className:p?"":"text-neutral-500",children:m.deliveryAddress})]}),m.deliveryMethod&&v("div",{children:[f("span",{className:"font-medium",children:"Metoda:"})," ",m.deliveryMethod]}),m.trackingNumber&&p&&v("div",{children:[f("span",{className:"font-medium",children:"Tracking:"})," ",m.trackingNumber]})]})]}),f("div",{className:"border-t pt-4",children:v("div",{className:"flex justify-between text-lg font-bold",children:[f("span",{children:"Suma:"}),f("span",{children:go(Number(m.totalAmount),m.currency)})]})})]})]}),v(Ee,{children:[f(Oe,{children:v(Ue,{children:["Komentarze ",m.commentCount>0&&`(${m.commentCount})`]})}),v(Te,{children:[m.comments.length>0?f("div",{className:"space-y-4",children:m.comments.map(E=>v("div",{className:"border-b pb-4 last:border-b-0",children:[v("div",{className:"mb-1 flex items-center gap-2",children:[f("span",{className:"font-medium",children:E.authorName||"System"}),f("span",{className:"text-xs text-neutral-500",children:fo(E.createdAt)}),E.authorType==="admin"&&f("span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),f("p",{className:p?"":"text-neutral-500",children:E.message})]},E.id))}):f("p",{className:"text-neutral-600",children:"Brak komentarzy."}),p?f(qi,{orderID:m.orderId,email:c}):f("div",{className:"mt-4",children:v(I,{onClick:()=>P(!0),variant:"outline",className:"w-full",children:[f(mo,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),b&&f("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:v(Ee,{className:"w-full max-w-md",children:[f(Oe,{children:f(Ue,{children:"Zweryfikuj sw\xF3j email"})}),v(Te,{className:"space-y-4",children:[f("p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),v("div",{className:"space-y-2",children:[f(We,{htmlFor:"verify-email",children:"Adres email"}),f(Lt,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:c,onChange:E=>l(E.target.value)})]}),v("div",{className:"flex gap-2",children:[f(I,{variant:"outline",onClick:()=>P(!1),className:"flex-1",children:"Anuluj"}),f(I,{onClick:U,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function Ki(e){return f(Bi,{...e})}var Sr=Ki;import{jsx as pe,jsxs as vo}from"react/jsx-runtime";var Wi=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:a,theme:r,loginURL:o,host:i}=Pe(),[,d]=Po(0),c=Ke(a,n,"panel"),l=mt(a,i),b=fn(a,i),{mutateAsync:P}=oe(H.publicApi.userPanelLogout);async function w(){l&&await P({accessToken:l}),typeof window<"u"&&(Ve(a,i),window.location.reload())}let[h]=Gi(),y=A=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(A),[u,m]=Un({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[p,x]=Po(y(u.state)?u.state:"products"),U=A=>{m({state:"order-details",orderId:A}),x("order-details")},le=()=>{m({state:"orders",orderId:void 0}),x("orders")},E=A=>m({orderId:void 0,returnId:void 0,course:void 0,item:void 0,...A}),de=A=>{m({state:"course",course:A,item:void 0,product:void 0}),x("course")},Ce=()=>{m({state:"products",course:void 0,item:void 0,product:void 0}),x("products")};Ot(()=>{y(u.state)&&(u.state==="course"||p==="course")&&x(u.state)},[u.state]);let ee={"--button-background-color":r?.colors?.brand??"#000000","--button-background-color-dark":r?.colors?.brandDark??"#ffffff","--button-text-color":r?.colors?.brandDark??"#000000","--button-text-color-dark":r?.colors?.brand??"#000000"};return Ot(()=>{if(l==null||l.length===0){window.location.href=o??"/panel/login";return}},[]),Ot(()=>{if(l==null||l.length===0){window.location.href=o??"/panel/login";return}},[p]),Ot(()=>{if(typeof window>"u"||window.parent!==window||!l)return;let A=gt(window.location.search);A&&yt(A);let fe=A??Ye();fe&&(window.location.href=Ze(fe,l))},[l]),pe(It,{value:c,children:vo("div",{ref:h,className:"font-inter relative flex h-dvh w-full flex-col bg-beige-100 text-black dark:bg-black dark:text-white md:flex-row",children:[pe(xr,{activeScreen:p,setActiveScreen:x,setParams:E,styles:ee,theme:r,logout:w,email:b,projectID:a}),vo("main",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto w-full p-5 pb-[calc(76px+env(safe-area-inset-bottom))] md:pb-5",children:[p==="products"&&pe(so,{projectID:a??"",accessToken:l,loginURL:o??"/panel/login",styles:ee,activeScreen:p,params:u,setParams:m,openCourse:de}),p==="course"&&u.course&&l&&pe(Cr,{accessId:u.course,accessToken:l,theme:r,itemId:u.item,onItemChange:A=>m({item:A}),onBack:Ce}),p==="notifications"&&pe(ur,{}),p==="plans"&&pe(pr,{projectID:a??""}),p==="orders"&&pe(jn,{projectID:a??"",accessToken:l??"",openOrderDetails:U}),p==="order-details"&&u.orderId&&pe(Sr,{orderID:u.orderId,onBack:le}),(p==="returns"||p==="return-details")&&l&&pe(fr,{projectID:a??"",host:i,accessToken:l,loginURL:o??"/panel/login",appearance:_n(e,r?.colors?.brand),texts:t,screen:p,params:u,setParams:m,setActiveScreen:x}),p==="profile"&&pe(wr,{email:b,logout:w,onLocaleChange:()=>d(A=>A+1)})]})]})})},Vi=Wi;import{create as we}from"@bufbuild/protobuf";import{QueryClient as ps,QueryClientProvider as ms}from"@tanstack/react-query";import{createContext as fs,useContext as gs,useEffect as Mo,useState as ys}from"react";import{createClient as Ji}from"@connectrpc/connect";import{createConnectTransport as Yi}from"@connectrpc/connect-web";var me;(a=>{function e(r){return Ji(nn,n(r))}a.get=e;let t=new Map;function n(r){let o=t.get(r);return o==null&&(o=Yi({useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[tn]}),t.set(r,o)),o}})(me||={});import L from"zod";import X from"zod";function z(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function ko(e,t){let n=typeof navigator>"u"?"pl-PL":navigator.language;return Intl.NumberFormat(n,{style:"currency",currency:t,currencyDisplay:"symbol"}).format(e/100)}var ju=X.object({event:X.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:X.string().optional(),value:X.number().optional(),currency:X.string().optional(),content_name:X.string().optional(),items:X.array(X.object({id:X.string(),name:X.string(),price:X.number().default(0),currency:X.string().default("PLN"),quantity:X.number().default(1)})).optional()});function Er(e){typeof window>"u"||(Zi(e),Xi(e),es(e))}function Zi(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=Qi(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function Qi(e){let t=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,n=e.items?.map(o=>({item_id:o.id,item_name:o.name||o.id,price:z((o.price||0)/100,2),quantity:o.quantity||1})),a={currency:e.currency||"PLN",value:z(t/100,2)};n&&n.length>0&&(a.items=n);let r;switch(e.event){case"purchase":r="purchase",a.transaction_id=e.step||`txn_${Date.now()}`;break;case"addToCart":r="add_to_cart";break;case"viewCart":r="view_cart";break;case"removeFromCart":r="remove_from_cart";break;case"initiateCheckout":r="begin_checkout";break;case"customizeProduct":r="customize_product";break;default:r=e.event}return{event:r,ecommerce:a,...e.step&&{step:e.step},...e.content_name&&{content_name:e.content_name}}}function Xi(e){if(typeof window.fbq>"u")return;let t="",n="",a={};switch(e.event){case"purchase":t="track",n="Purchase",a={category_name:e.step,...e};break;case"lead":t="track",n="Lead",a={category_name:e.step,...e};break;case"addToCart":t="track",n="Add to Cart",a={category_name:e.step,...e};break;case"customizeProduct":t="track",n="Customize Product",a={category_name:e.step,...e};break;case"viewCart":t="track",n="View Cart",a={category_name:e.step,...e};break;case"removeFromCart":t="track",n="Remove from Cart",a={category_name:e.step,...e};break;case"initiateCheckout":t="track",n="Initiate Checkout",a={category_name:e.step,...e};break;default:break}window.location.search.includes("analytics")&&console.log("Pushing FB event",t,n,a),window.fbq(t,n,a)}function es(e){try{if(typeof window.ttq>"u")return;let t=ts(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 ts(e){let t=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,n=e.items?.map(o=>({content_id:o.id,content_type:"product",content_name:o.name||o.id,quantity:o.quantity||1,price:z((o.price||0)/100,2)}))||[];n.length===0&&e.content_name&&n.push({content_id:e.step||"unknown",content_type:"product",content_name:e.content_name,quantity:1,price:z(t/100,2)});let a={currency:e.currency||"PLN",value:z(t/100,2)};n.length>0&&(a.contents=n);let r=null;switch(e.event){case"purchase":r="Purchase";break;case"addToCart":r="AddToCart";break;case"initiateCheckout":r="InitiateCheckout";break;case"customizeProduct":r="CustomizeProduct";break;case"viewCart":return;case"removeFromCart":return;case"lead":return;default:return null}return{eventName:r,eventPayload:a}}function xo(e){let{items:t,googlePayConfig:n,checkout:a,result:r,cartRequiresShipping:o}=e,i=e.locale??S();if(r.totalAmount==null)return;let d=[];return o&&(d.push("SHIPPING_ADDRESS"),d.push("SHIPPING_OPTION")),{apiVersion:2,apiVersionMinor:0,callbackIntents:d,allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["MASTERCARD","VISA"]},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:n.gateway,gatewayMerchantId:n.gatewayId}}}],emailRequired:!0,shippingAddressParameters:{phoneNumberRequired:o},shippingAddressRequired:o,shippingOptionRequired:o,shippingOptionParameters:o?{shippingOptions:r.methods.slice(0,5).map(l=>({id:l.id,label:l.name+` - ${ko(l.amount,r.currency)}`,description:l.description??""})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:Se("paymentForCart",i,e.texts),totalPrice:`${z(r.totalAmount/100,2)}`,currencyCode:r.currency,countryCode:r.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:rs(t,r.methods,r.selectedDeliveryMethod??(r.methods.length>0?r.methods[0].id:void 0),a.couponCode,r.couponValue,Se("coupon",i,e.texts))}}}function rs(e,t,n,a,r,o="Coupon"){let i=[],d=0;for(let l of e){if(l.details==null)continue;let b=l.details.pricing?.effectivePrice??l.details.price;d+=b*l.quantity,i.push({label:l.details.name+" x "+l.quantity,price:`${z(b/100,2)}`,type:"LINE_ITEM",status:"FINAL"})}let c=t.find(l=>l.id===n);return c!=null&&i.push({label:c.name,price:`${z(c.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),a!=null&&r!=null&&i.push({label:`${o} ${a}`,price:`${z(r/100,2)}`,type:"DISCOUNT",status:"FINAL"}),d>0&&i.push({label:"Subtotal",price:`${z(d/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),i}function nt(e,t){return`${Z}/api/integrations/${e}/public-commerce${t}`}function Ae(e){return typeof e=="object"&&e!=null&&"ERR"in e}function q(e,t,n){return{ERR:!0,error:e,type:t,data:n}}function wo(e,t){return t?.find(n=>n.id===e||(n.variants?.some(a=>a.id===e)??!1))}function Co(e,t){let n=new Set(t.map(a=>a.productID));return Array.from(new Set(e.filter(a=>!n.has(a))))}function No(e,t){let n=e?.trim();if(!(n==null||n.length===0))try{let a=new URL(n,t);return a.protocol!=="http:"&&a.protocol!=="https:"?void 0:a.href}catch{return}}import{create as ns}from"zustand";var ot=ns(e=>({isCartVisible:!1,notice:void 0,setNotice:t=>e(n=>({...n,notice:t})),numberOfProductsInCart:0,showCart:()=>e(t=>({...t,isCartVisible:!0})),hideCart:()=>e(t=>({...t,isCartVisible:!1})),setNumberOfProductsInCart:t=>e(n=>({...n,numberOfProductsInCart:t}))}));import{createContext as os,useContext as Tr,useMemo as Io}from"react";import{jsx as as}from"react/jsx-runtime";var Ut=os({});function ep({texts:e,locale:t,children:n}){let a=Io(()=>({texts:e,locale:t}),[e,t]);return as(Ut.Provider,{value:a,children:n})}function So(){return Tr(Ut)}function tp(e){let{texts:t,locale:n}=Tr(Ut);return Se(e,n??S(),t)}function rp(){let{texts:e,locale:t}=Tr(Ut),n=t??S();return Io(()=>a=>Se(a,n,e),[n,e])}var Rr="bitsnap-pending-order";function Lo(e,t){let n=new Map;for(let r of t)n.set(r.id,(n.get(r.id)??0)+r.quantity);let a=[];for(let r of e){let o=n.get(r.id);o==null?a.push(r):r.quantity>o&&a.push({...r,quantity:r.quantity-o})}return a}var is=60*1e3;function Ro(e,t=Date.now,n=is){let a;return r=>{let o=`${r.orderId}:${r.ts}`,i=t();return a?.key===o&&i-a.at<n?Promise.reject(new Error("pending order was asked about recently")):(a={key:o,at:i},e(r))}}function ss(e){if(!(e==null||e.length===0))try{let t=new URL(e,"https://bitsnap.invalid").pathname,n=/\/payment\/common\/([^/]+)\/([^/]+)\/?$/.exec(t);return n==null?void 0:{projectId:decodeURIComponent(n[1]),orderId:decodeURIComponent(n[2])}}catch{return}}function ls(e){if(e==null||e.length===0)return!1;try{let t=new URL(e,"https://bitsnap.invalid").pathname;return/\/payment\/manualPayment\/[^/]+\/[^/]+\/?$/.test(t)}catch{return!1}}function ds(e,t=Date.now(),n={}){if(ls(e.url))return;let a=ss(e.url),r=Eo(e.orderId)??a?.orderId,o=Eo(e.projectId)??a?.projectId;if(!(r==null||o==null))return{orderId:r,projectId:o,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:n.lines??[],ts:t}}function ap(e,t={}){let n=ds(e,t.now,t);return n!=null&&cs(n,t.storage)}function Eo(e){return e!=null&&e.length>0?e:void 0}function _t(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function cs(e,t=_t()){try{return t?.setItem(Rr,JSON.stringify(e)),t!=null}catch{return!1}}function To(e=_t()){try{let t=e?.getItem(Rr);if(t==null)return;let n=JSON.parse(t);if(typeof n=="object"&&n!=null&&typeof n.orderId=="string"&&typeof n.projectId=="string"&&typeof n.ts=="number"&&n.orderId.length>0){let{orderId:a,projectId:r,cartProjectId:o,ts:i,lines:d}=n;return{orderId:a,projectId:r,...typeof o=="string"?{cartProjectId:o}:{},lines:Array.isArray(d)?d.filter(c=>typeof c?.id=="string"&&typeof c.quantity=="number"):[],ts:i}}}catch{}Lr(e)}function Lr(e=_t()){try{e?.removeItem(Rr)}catch{}}function Ao(e){let t=e.details?.status??us(e.details?.$unknown);return t==="created"||t==="placed"||t==="paid"||t==="canceled"?t:"unknown"}function us(e){if(Array.isArray(e)){for(let t of e)if(t?.no===3&&t.wireType===2&&t.data instanceof Uint8Array){let n=0,a=0;for(let r=0;a<t.data.length&&r<35;r+=7){let o=t.data[a++];if(n|=(o&127)<<r,!(o&128))break}if(a+n!==t.data.length)return;try{return new TextDecoder().decode(t.data.subarray(a))}catch{return}}}}async function Do(e){let t=e.storage??_t(),n=To(t);if(n==null)return"none";if((e.now??Date.now)()-n.ts>864e5)return Lr(t),"expired";if(e.projectId!=null&&n.cartProjectId!=null&&n.cartProjectId!==e.projectId)return"pending";let r;try{r=await e.fetchStatus(n)}catch{return"pending"}let o=To(t);if(o?.orderId!==n.orderId||o.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch{return"pending"}return Lr(t),"paid"}return"pending"}import{Fragment as Ts,jsx as Dr}from"react/jsx-runtime";var hs="__m_a",jo=fs(void 0),Or=void 0;function Rp(e){sr({projectID:e}),Or=e,typeof window<"u"&&ut([window.location.origin])}function st(){return Or??document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-id")??void 0}function bs(){return document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-custom-host")??void 0}var Ps=({children:e,locale:t})=>{let[n]=ys(()=>new ps),a=So();Mo(()=>{it()},[]);let r=st();if(Mo(()=>{if(r==null)return;let i=()=>{xs(r).then(c=>{c==="paid"&&n.invalidateQueries({queryKey:["cart"]})})},d=()=>{document.visibilityState==="visible"&&i()};return i(),window.addEventListener("pageshow",i),document.addEventListener("visibilitychange",d),()=>{window.removeEventListener("pageshow",i),document.removeEventListener("visibilitychange",d)}},[r,n]),r==null)return Dr(Ts,{});let o=_r(r,t??a.locale,a.texts);return Dr(ms,{client:n,children:Dr(jo.Provider,{value:o,children:e})})},Ar,vs=Ro(async e=>Ao(await me.get(Z).getOrder({id:e.orderId,projectId:e.projectId})));function Ap(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}=R()??jt;return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}}function Dp(){return(R()?.products??[]).map(e=>({id:e.id,quantity:e.quantity}))}function ks(e){let t=R();ne({...t,products:Lo(t?.products??[],e)}),it()}function xs(e){return Ar??=Do({projectId:e,fetchStatus:vs,removeLines:ks}).catch(t=>{console.warn("cannot check the pending order",t)}).finally(()=>{Ar=void 0}),Ar}var at=async(e,t)=>{let n=[];t?.items!=null&&t.items.length>0?n=t.items:n=R()?.products??[];let a=Array.from(new Set(n.map(i=>i.productID)));if(a.length===0)return[];let r=new URLSearchParams;r.set("ids",a.join(",")),r.set("locale",t?.locale??S());let o;try{let i=await fetch(er(nt(e,`/products?${r.toString()}`)),{method:"GET"});if(i.status!=200)return q("products-load-failed","internal");o=await i.json()}catch(i){return console.warn("cannot load the products of the cart",i),q("products-load-failed","internal")}return n.flatMap(i=>{let d=wo(i.productID,o.result);return d==null?[]:[{...i,details:Es(i.productID,d),catalogProductID:d.id}]})},Mp=()=>{let e=gs(jo);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Op=Ps,ws=L.object({isAvailable:L.boolean(),merchantId:L.string(),merchantName:L.string(),gateway:L.string(),gatewayId:L.string()}),Cs=L.object({id:L.string(),productID:L.string(),quantity:L.number(),priceVersion:L.string().optional(),metadata:L.record(L.string(),L.string().optional()).optional(),url:L.string().optional()}),Ns=L.object({country:L.string().optional(),couponCode:L.string().optional(),selectedDeliveryMethod:L.string().optional(),postalCode:L.string().optional(),email:L.string().optional(),products:L.array(Cs).optional(),googlePayConfig:ws.optional()}),jt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},Fo="checkout";function R(){try{let e=localStorage.getItem(Fo);return e==null?jt:Ns.parse(JSON.parse(e))}catch{return jt}}async function Oo(e,t){let n=await at(e,{items:t.map((o,i)=>({...o,id:`price-check-${i}`}))});if(Ae(n))return n;let a=Co(t.map(o=>o.productID),n);if(a.length>0)return q("item-ids-not-found","notFound",a);let r=R();r.products==null&&(r.products=[]),r.products.push(...t.map(o=>({id:Math.random().toString(36).substring(7),productID:o.productID,quantity:o.quantity,priceVersion:n.find(i=>i.productID===o.productID)?.details?.pricing?.priceVersion,metadata:o.metadata,url:No(o.url,typeof window<"u"?window.location.href:void 0)}))),Is(t,n),Er({event:"addToCart",currency:"PLN",items:t.map(o=>({id:o.productID,name:o.name??"",price:o.price??0,quantity:o.quantity,currency:o.currency??"PLN"}))}),ne(r),it()}function Is(e,t){for(let n of e)try{let a=t.find(d=>d.productID===n.productID),r=a?.details?.pricing?.effectivePrice??a?.details?.price??n.price,o=a?.details?.currency??n.currency;if(r==null||o==null)continue;let i=a?.catalogProductID??n.productID;(n.analytics??on()).track("add_to_cart",{qty:n.quantity,value_minor:Math.round(r*n.quantity),currency:o},{product_id:i,variant_id:i!==n.productID?n.productID:null})}catch{}}function Uo(e){let t=R(),n={...t,products:t?.products?.filter(a=>!e.includes(a.productID)&&!e.includes(a.id))};Er({event:"removeFromCart",items:e.map(a=>({id:a,name:"",price:0,quantity:1,currency:"PLN"}))}),ne(n),it()}function ne(e){localStorage.setItem(Fo,JSON.stringify(e))}function _o(e,t){if(e.products==null||e.products.length==0)return;let n=e.products.reduce((a,r)=>(r.metadata!=null&&Object.keys(r.metadata).forEach(o=>{let i=r.metadata?.[o];i!=null&&(a[o]=i)}),a),{});return{items:e.products.map(a=>({id:a.productID,quantity:a.quantity,priceVersion:a.priceVersion})),askForNote:!0,countries:e.country?[e.country]:void 0,metadata:n,locale:t}}var _r=(e,t=S(),n)=>{let a=bs();return a!=null&&an(a),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await me.get(Z).isOneClickPaymentAvailable({projectId:e})).applePay}catch(r){return console.error("Error checking if Apple Pay is available",r),!1}},async getGooglePayConfiguration(r){if(typeof window>"u"||typeof document>"u")return{isAvailable:!1};try{let o=await Ss(e);if(o?.isAvailable!=!0)return{isAvailable:!1};let i=R();if(i==null)return console.log("checkout is null"),{isAvailable:!1};let d=await at(e,{locale:t,items:r.items.map(P=>({id:Math.random().toString(36).substring(7),quantity:P.quantity,metadata:P.metadata,productID:P.productID}))});if(Ae(d))return{isAvailable:!1};let c=await me.get(Z).getPreOrderDetails({items:d.map(P=>we(Nt,{id:P.productID,quantity:P.quantity})),projectId:e,postCode:i.postalCode,couponCode:i.couponCode,countryCode:i.country,selectedDeliveryMethod:i.selectedDeliveryMethod});if(c.totalAmount==null)return{isAvailable:!1};let l=d.find(P=>P.details?.isDeliverable==!0)!=null,b=await xo({items:d,googlePayConfig:o,checkout:i,cartRequiresShipping:l,result:c,locale:t,texts:n});return b==null?{isAvailable:!1}:{isAvailable:!0,config:b}}catch(o){return console.error("Error resolving Google Pay configuration",o),{isAvailable:!1}}},async clearCart(){let r=structuredClone(jt);r.country=R()?.country,ne(r),it()},async getAvailableCountries(){let r=await fetch(er(nt(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return L.array(L.object({name:L.string(),code:L.string()})).parse(await r.json())}catch(o){return q(o.toString(),"internal")}},async getCountry(){let r=R()?.country;if(r==null){r="PL";let o=R();o.country=r,ne(o)}return r},async getNumberOfElementsInCart(){return R()?.products?.reduce((r,o)=>r+o.quantity,0)??0},async getProducts(){return await at(e,{locale:t})},async removeProductFromCart(r){return Uo([r.id])},async setCountry(r){let o=R();o.country=r,ne(o)},async setCouponCodeIfPossible(r){let o=R();o.couponCode=r,ne(o)},async setPostalCode(r){let o=R();o.postalCode=r,ne(o)},async setDeliveryMethod(r){let o=R();o.selectedDeliveryMethod=r,ne(o)},async setEmail(r){let o=R();o.email=r,ne(o)},async addProduct(r){return await Oo(e,[r])},async updateQuantity(r){let o=R();o.products=o.products?.map(i=>(i.id===r.id&&(i.quantity=r.quantity),i)),ne(o),it()},async getPaymentMethodChoice(){let r=_o(R(),t);return r==null?null:zo(r)},async redirectToNextStep(r){let o=_o(R(),t);if(o==null)return q("cart-is-empty","badInput");r?.paymentMethod!=null&&(o.paymentMethod=r.paymentMethod);let i=await Mr(o);return Ae(i)?(console.warn("cannot create payment URL",i.error),i):{url:i.url,...i.orderId!=null?{orderId:i.orderId}:{},...i.projectId!=null?{projectId:i.projectId}:{}}},async justRedirectToPayment(r){let o={items:[{id:r.productID,quantity:1}],askForNote:!1,details:r.email||r.name?{name:r.name,email:r.email}:void 0,locale:r.locale??t};o=Ur(o),r.country==null&&(r.country="pl"),o.details==null&&(o.details={}),o.details.address==null&&(o.details.address={}),o.details.address.country=r.country,r.marketingAgreement===!0&&(o.additionalAgreements=[{id:hs,name:"",required:!0,answer:!0}]);let i=await Mr(o);return Ae(i)?i:{url:i.url}},async getApplePayPreview(r){let o=R();try{let i=await me.get(Z).getPreOrderDetails({items:r.items.map(d=>we(Nt,{id:d.productID,quantity:d.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod});return i.totalAmount==null||i.currency.length===0?q("pre-order-unavailable","internal"):{countryCode:i.country||o.country||"PL",currencyCode:i.currency,totalAmount:`${z(i.totalAmount/100,2)}`}}catch(i){return console.warn("cannot load the Apple Pay preview",i),q("pre-order-unavailable","internal")}},async completeApplePayPayment(r){let o=R();if(o==null)return q("Checkout not found");let i=await at(e,{locale:t});if(Ae(i))return i;try{let d=r.shippingContact?.givenName;r.shippingContact?.familyName!=null?d+=" "+r.shippingContact?.familyName:r.billingContact?.familyName!=null&&(d+=" "+r.billingContact?.familyName);let c={},l=zt();l!=null&&(c.ref=l);let b=await me.get(Z).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:we(nr,{items:i.map(P=>({id:P.productID,quantity:P.quantity})),couponCode:o.couponCode,email:r.shippingContact?.emailAddress??r.billingContact?.emailAddress??o.email??void 0,phone:r.shippingContact?.phoneNumber??r.billingContact?.phoneNumber??void 0,selectedDeliveryMethod:o.selectedDeliveryMethod,postCode:o.postalCode,projectId:e}),shippingAddress:we(tr,{line1:r.shippingContact?.addressLines?.[0]??"",city:r.shippingContact?.locality??"",country:r.shippingContact?.countryCode??"",zipCode:r.shippingContact?.postalCode??"",name:d}),billingAddress:we(rr,{name:r.billingContact?.givenName??" "+(r.billingContact?.familyName??""),line1:r.billingContact?.addressLines?.[0]??"",city:r.billingContact?.locality??"",country:r.billingContact?.countryCode??"",zipCode:r.billingContact?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:b.isSuccess,redirectURL:b.redirectUrl}}catch(d){return console.error(d),q("Failed to authorize payment")}},async completeGooglePayPayment(r){let o=R();if(o==null)return q("Checkout not found");let i=await at(e,{locale:t});if(Ae(i))return i;try{let d=r.paymentData.shippingAddress?.name,c={},l=zt();l!=null&&(c.ref=l);let b=await me.get(Z).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:we(nr,{items:i.map(P=>({id:P.productID,quantity:P.quantity})),couponCode:o.couponCode,email:r.paymentData.email??void 0,phone:r.paymentData.shippingAddress?.phoneNumber??void 0,selectedDeliveryMethod:r.paymentData.shippingOptionData?.id??o.selectedDeliveryMethod,postCode:r.paymentData.shippingAddress?.postalCode,projectId:e}),shippingAddress:we(tr,{line1:r.paymentData.shippingAddress?.address1??"",city:r.paymentData.shippingAddress?.locality??"",country:r.paymentData.shippingAddress?.countryCode??"",zipCode:r.paymentData.shippingAddress?.postalCode??"",name:d}),billingAddress:we(rr,{name:r.paymentData.paymentMethodData.info?.billingAddress?.name,line1:r.paymentData.paymentMethodData.info?.billingAddress?.address1??"",city:r.paymentData.paymentMethodData.info?.billingAddress?.locality??"",country:r.paymentData.paymentMethodData.info?.billingAddress?.countryCode??"",zipCode:r.paymentData.paymentMethodData.info?.billingAddress?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:b.isSuccess,redirectURL:b.redirectUrl}}catch(d){return console.error(d),q("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(r){let o=R();if(o==null)return q("Checkout not found");r&&r.expectedItems!=null&&r.expectedItems.length>0&&(o.products&&Uo(o.products.map(l=>l.productID)),await Oo(e,r.expectedItems));let i=await at(e,{locale:t});if(Ae(i))return i;let d=await me.get(Z).getPreOrderDetails({items:i.map(l=>we(Nt,{id:l.productID,quantity:l.quantity})),projectId:e,postCode:o.postalCode,couponCode:o.couponCode,countryCode:o.country,selectedDeliveryMethod:o.selectedDeliveryMethod}),c=i.map(l=>({amount:`${z(l.quantity*(l.details?.pricing?.effectivePrice??l.details?.price??0)/100,2)}`,label:l.details?.name+" - "+l.quantity,type:"final"}));if(d.selectedDeliveryMethod!=null){let l=d.methods.find(b=>b.id==d.selectedDeliveryMethod);l!=null&&c.push({amount:`${z(l.amount/100,2)}`,label:l.name,type:"final"})}return d.couponCode!=null&&d.couponValue!=null&&c.push({amount:`-${z(d.couponValue/100,2)}`,label:d.couponCode,type:"final"}),{countryCode:d.country||o.country||"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${z((d.totalAmount??0)/100,2)}`,label:Se("paymentForCart",t,n),type:"final"},shippingMethods:d.methods.map(l=>({amount:`${z(l.amount/100,2)}`,detail:l.description??"",identifier:l.id,label:l.name,dateComponentsRange:{startDateComponents:{days:l.minDays??1,hours:0,months:0,years:0},endDateComponents:{days:l.maxDays??14,hours:0,months:0,years:0}}})),lineItems:c,currencyCode:d.currency||i[0]?.details?.currency||"PLN"}}}};async function Ss(e){let t=R();if(t.googlePayConfig?.isAvailable!=!0){let n=await me.get(Z).isOneClickPaymentAvailable({projectId:e});n.googlePay==!0&&n.googlePayConfig!=null?t.googlePayConfig={isAvailable:!0,gateway:n.googlePayConfig.gateway,gatewayId:n.googlePayConfig.gatewayMerchantId,merchantName:n.googlePayConfig.merchantName,merchantId:n.googlePayConfig.merchantId}:t.googlePayConfig={isAvailable:!1,gateway:"",gatewayId:"",merchantName:"",merchantId:""}}return ne(t),t.googlePayConfig}function Es(e,t){if(e==t.id){let a=t.variants?.findIndex(r=>r.id===e);if(a!=null&&a!=-1){let r=t.variants[a];return{...t,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:r.images??t.images,name:t.name+" "+r.name,baseName:t.name,variantName:r.name,price:r.price,currency:r.currency,pricing:r.pricing}}return t}let n=t.variants?.find(a=>a.id===e);return n==null?t:{...t,id:n.id,name:t.name+" "+n.name,baseName:t.name,variantName:n.name,price:n.price,currency:n.currency,pricing:n.pricing,metadata:t.metadata,availableQuantity:n.availableQuantity,isDeliverable:n.isDeliverable,images:n.images??t.images}}function it(){let e=R(),t=0;if(e==null){ot.setState(n=>({...n,numberOfProductsInCart:t}));return}t=e.products?.reduce((n,a)=>n+a.quantity,0)??0,ot.setState(n=>({...n,numberOfProductsInCart:t}))}var Ls=200,Rs="item-ids-not-found",Pt="internal-error",Ho={"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"},As=new Set(["internal","invalid-request"]),Ds=new Set(["product-not-available","product-not-found"]);function Ms(e){return typeof e=="string"&&Object.hasOwn(Ho,e)?Ho[e]:void 0}function Os(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function Us(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 _s(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function zr(e){let t=e.trim();if(!(t.length===0||t.length>Ls||/[\r\n]/.test(t)||Os(t)||Us(t)||_s(t)))return t}var zs=3;function Ft(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=zs)return{};let n=e,a=Ft(n.error,t+1);if(a.message==null&&n.message!=null){let r=Ft(n.message,t+1);a={...r,code:a.code??r.code}}return typeof n.code=="string"&&n.code.length>0&&(a.code=n.code),a}if(typeof e!="string")return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!=null?Ft(n,t+1):{}}catch{}return{message:zr(e)}}function js(e){let t;try{t=JSON.parse(e)}catch{return{code:Pt,message:zr(e)}}if(typeof t=="string")return{code:Pt,message:zr(t)};if(typeof t!="object"||t==null)return{code:Pt};let n=t,{message:a,code:r}=Ft(n.error),o={code:typeof n.code=="string"&&n.code.length>0?n.code:r??Pt,message:a};return Array.isArray(n.itemIds)&&(o.itemIds=n.itemIds.filter(i=>typeof i=="string")),o}function jr(e,t){let{code:n,message:a,itemIds:r}=js(t),o=r!=null&&r.length>0;if(o&&(n===Pt||Ds.has(n)))return q(Rs,"badInput",r);let i={message:a};return o&&(i.itemIds=r),q(n,e>=500?"internal":"badInput",i)}function Fp(e,t){let n=Ms(e.error);if(n!=null)return t(n);if(e.type==="internal"||typeof e.error=="string"&&As.has(e.error))return t("checkoutFailed");let a=e.data?.message;return typeof a=="string"&&a.length>0?a:t("checkoutFailed")}var Fs=["online","manual","cod"],Hs=["bankTransfer","blik"];function $o(e,t){if(!Array.isArray(e))return[];let n=[];for(let a of e)t.includes(a)&&!n.includes(a)&&n.push(a);return n}function $s(e){if(typeof e!="object"||e==null)return null;let t=e.choice;if(typeof t!="object"||t==null)return null;let n=$o(t.methods,Fs);return n.length<2?null:{methods:n,manualAccountTypes:$o(t.manualAccountTypes,Hs)}}function $p(e){if(e==null)return null;let t=e.methods.filter(n=>n!=="cod");return t.length<2?null:{...e,methods:t}}function qp(e,t){return t!=null&&e.methods.includes(t)?t:e.methods[0]}function Bp(e){let t=e.includes("bankTransfer"),n=e.includes("blik");return n&&!t?"paymentMethodManualBlik":t&&!n?"paymentMethodManualTransfer":"paymentMethodManualBoth"}async function qo(e,t,n=5e3){let a=typeof AbortController>"u"?void 0:new AbortController,r=setTimeout(()=>a?.abort(),n);try{let o=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:a?.signal});return o.ok?$s(await o.json()):null}catch{return null}finally{clearTimeout(r)}}var qs;(a=>{async function e(r,o=1,i,d){let c=st();if(c==null)throw new Error("No project ID found");let b=await _r(c).addProduct({productID:r,quantity:o,metadata:i,...d});if(b!=null)return b}a.addProductToCart=e;function t(){ot.setState({isCartVisible:!0})}a.showCart=t;function n(){ot.setState({isCartVisible:!1})}a.hideCart=n})(qs||={});async function Bo(e){try{return await e.text()}catch{return""}}function Ko(e,t){return t=Ur(t),t.locale??=S(),{headers:{...Xt,...or(e),"Content-Type":"application/json"},body:JSON.stringify(t)}}async function zo(e){let t=st();return t==null?null:qo(nt(t,"/payment-methods"),Ko(t,e))}async function Mr(e){let t=st();if(t==null)throw new Error("No project ID found");let n=await fetch(nt(t,"/buy"),{method:"POST",...Ko(t,e)});if(n.status!=200){let r=jr(n.status,await Bo(n));return console.warn("cannot create payment URL",n.status,r.error),r}let a=await n.json();return{url:a.url,...a.orderId!=null?{orderId:a.orderId}:{},...a.projectId!=null?{projectId:a.projectId}:{}}}async function em(e){let t=st();if(t==null)throw new Error("No project ID found");let n={...Xt,...or(t),"Content-Type":"application/json",...e.apiKey!=null?{Authorization:`Bearer ${e.apiKey}`}:{}},a=e.testMode?`/api/payment/link/auto/${t}/test`:`/api/payment/link/auto/${t}`;delete e.apiKey,delete e.testMode,e.locale??=S();let r=await fetch(Z+a,{method:"POST",headers:n,body:JSON.stringify(e)});return r.ok?{status:"ok",redirectURL:(await r.json()).url}:{...jr(r.status,await Bo(r)),status:"error"}}function zt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function Ur(e){let t=zt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}export{me as a,Ee as b,Oe as c,Ue as d,Te as e,Ln as f,gt as g,yt as h,Ye as i,Ze as j,ma as k,Sr as l,Vi as m,z as n,ko as o,Er as p,Ae as q,Rs as r,Fp as s,$p as t,qp as u,Bp as v,ot as w,qs as x,zo as y,Mr as z,em as A,zt as B,Ur as C,ep as D,tp as E,rp as F,ap as G,hs as H,Or as I,Rp as J,st as K,Ap as L,Dp as M,xs as N,Mp as O,Op as P,_r as Q};
|
|
5
|
+
//# sourceMappingURL=chunk-WJO5GSY3.mjs.map
|