bitsnap-react 1.16.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +5 -0
- package/README.md +56 -0
- package/dist/CartProvider-DGRZDTYC.mjs +2 -0
- package/dist/CartProvider-YVOHSMPE.js +2 -0
- package/dist/{CartProvider-VGZMDVFJ.js.map → CartProvider-YVOHSMPE.js.map} +1 -1
- package/dist/analytics.d.mts +2 -2
- package/dist/analytics.d.ts +2 -2
- package/dist/analytics.js +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.d.mts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/chunk-2NL5FCXC.mjs +4 -0
- package/dist/chunk-2NL5FCXC.mjs.map +1 -0
- package/dist/{chunk-QQQ2JSPQ.mjs → chunk-2UDAB2C5.mjs} +2 -2
- package/dist/{chunk-QQQ2JSPQ.mjs.map → chunk-2UDAB2C5.mjs.map} +1 -1
- package/dist/{chunk-SRQOFCMO.js → chunk-4BL7TLK3.js} +2 -2
- package/dist/{chunk-SRQOFCMO.js.map → chunk-4BL7TLK3.js.map} +1 -1
- package/dist/{chunk-DPKWYLN7.mjs → chunk-4ETIDGYZ.mjs} +2 -2
- package/dist/chunk-555KFWGY.js +4 -0
- package/dist/chunk-555KFWGY.js.map +1 -0
- package/dist/chunk-5FZAROP6.js +2 -0
- package/dist/chunk-5FZAROP6.js.map +1 -0
- package/dist/{chunk-OZHXRKMX.js → chunk-6GCCNBEU.js} +2 -2
- package/dist/{chunk-OZHXRKMX.js.map → chunk-6GCCNBEU.js.map} +1 -1
- package/dist/chunk-A6VCP3A4.mjs +2 -0
- package/dist/{chunk-SULHGFYN.mjs.map → chunk-A6VCP3A4.mjs.map} +1 -1
- package/dist/chunk-BZXV77PT.mjs +2 -0
- package/dist/chunk-BZXV77PT.mjs.map +1 -0
- package/dist/{chunk-GQJDFLSL.js → chunk-C3BBJOVV.js} +2 -2
- package/dist/{chunk-GQJDFLSL.js.map → chunk-C3BBJOVV.js.map} +1 -1
- package/dist/{chunk-GXUNRJ5S.js → chunk-ESF5ZVVF.js} +2 -2
- package/dist/{chunk-GXUNRJ5S.js.map → chunk-ESF5ZVVF.js.map} +1 -1
- package/dist/chunk-HKNWW37T.mjs +2 -0
- package/dist/chunk-HKNWW37T.mjs.map +1 -0
- package/dist/chunk-L7Q7OKM5.mjs +2 -0
- package/dist/chunk-L7Q7OKM5.mjs.map +1 -0
- package/dist/{chunk-WKE6ECID.mjs → chunk-M2G74N43.mjs} +2 -2
- package/dist/chunk-MIMQTH2G.js +2 -0
- package/dist/chunk-MIMQTH2G.js.map +1 -0
- package/dist/chunk-SYN5KU3O.js +2 -0
- package/dist/chunk-SYN5KU3O.js.map +1 -0
- package/dist/{chunk-SXKJ26OA.mjs → chunk-X3LVYIJR.mjs} +2 -2
- package/dist/course.d.mts +3 -3
- package/dist/course.d.ts +3 -3
- package/dist/course.js +1 -1
- package/dist/course.mjs +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.d.mts +41 -12
- package/dist/index.d.ts +41 -12
- 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/{instrument-BE8ktMUv.d.ts → instrument-eXaC8hc2.d.mts} +1 -1
- package/dist/{instrument-BE8ktMUv.d.mts → instrument-eXaC8hc2.d.ts} +1 -1
- package/dist/methods-3W34GRYL.js +2 -0
- package/dist/{methods-WRONKK3D.js.map → methods-3W34GRYL.js.map} +1 -1
- package/dist/methods-LUJSKSQ4.mjs +2 -0
- package/dist/returns.d.mts +19 -10
- package/dist/returns.d.ts +19 -10
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/dist/{texts-tQtAGJCT.d.mts → texts-LGhuQfA9.d.mts} +28 -3
- package/dist/{texts-CIEFbJTN.d.ts → texts-m6XQGZ6w.d.ts} +28 -3
- package/dist/types-ClFCVzk_.d.ts +121 -0
- package/dist/types-D6LsoycW.d.mts +121 -0
- package/dist/viewer3d.mjs +1 -1
- package/package.json +2 -2
- package/dist/CartProvider-VGZMDVFJ.js +0 -2
- package/dist/CartProvider-ZY5OLTAF.mjs +0 -2
- package/dist/chunk-5AYH23UJ.mjs +0 -4
- package/dist/chunk-5AYH23UJ.mjs.map +0 -1
- package/dist/chunk-AGYS7Z6G.mjs +0 -2
- package/dist/chunk-AGYS7Z6G.mjs.map +0 -1
- package/dist/chunk-I3QXJJ7U.mjs +0 -2
- package/dist/chunk-I3QXJJ7U.mjs.map +0 -1
- package/dist/chunk-LL7ASBGY.js +0 -2
- package/dist/chunk-LL7ASBGY.js.map +0 -1
- package/dist/chunk-QERYM7RC.js +0 -2
- package/dist/chunk-QERYM7RC.js.map +0 -1
- package/dist/chunk-QXGK337V.mjs +0 -2
- package/dist/chunk-QXGK337V.mjs.map +0 -1
- package/dist/chunk-SULHGFYN.mjs +0 -2
- package/dist/chunk-WPOXLITY.js +0 -2
- package/dist/chunk-WPOXLITY.js.map +0 -1
- package/dist/chunk-Y5KWVTXT.js +0 -4
- package/dist/chunk-Y5KWVTXT.js.map +0 -1
- package/dist/methods-NJEP64AG.mjs +0 -2
- package/dist/methods-WRONKK3D.js +0 -2
- package/dist/types-DP1vxo5E.d.mts +0 -53
- package/dist/types-u8VwmC3j.d.ts +0 -53
- /package/dist/{CartProvider-ZY5OLTAF.mjs.map → CartProvider-DGRZDTYC.mjs.map} +0 -0
- /package/dist/{chunk-DPKWYLN7.mjs.map → chunk-4ETIDGYZ.mjs.map} +0 -0
- /package/dist/{chunk-WKE6ECID.mjs.map → chunk-M2G74N43.mjs.map} +0 -0
- /package/dist/{chunk-SXKJ26OA.mjs.map → chunk-X3LVYIJR.mjs.map} +0 -0
- /package/dist/{methods-NJEP64AG.mjs.map → methods-LUJSKSQ4.mjs.map} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk5FZAROP6js = require('./chunk-5FZAROP6.js');var _chunk4BL7TLK3js = require('./chunk-4BL7TLK3.js');var _chunkSYN5KU3Ojs = require('./chunk-SYN5KU3O.js');var _chunkESF5ZVVFjs = require('./chunk-ESF5ZVVF.js');var _chunkC3BBJOVVjs = require('./chunk-C3BBJOVV.js');var _chunk7RXW6XFYjs = require('./chunk-7RXW6XFY.js');var _react = require('@formkit/auto-animate/react');var _react3 = require('react'); var mt = _interopRequireWildcard(_react3);var _jsxruntime = require('react/jsx-runtime');function ye({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card",className:_chunkESF5ZVVFjs.g.call(void 0, "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function xe({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-header",className:_chunkESF5ZVVFjs.g.call(void 0, "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Ce({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-title",className:_chunkESF5ZVVFjs.g.call(void 0, "leading-none font-semibold",e),...t})}function zn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-description",className:_chunkESF5ZVVFjs.g.call(void 0, "text-muted-foreground text-sm",e),...t})}function he({className:e,...t}){return _jsxruntime.jsx.call(void 0, "div",{"data-slot":"card-content",className:_chunkESF5ZVVFjs.g.call(void 0, "px-6",e),...t})}var _lucidereact = require('lucide-react');var go="text-muted-foreground text-xs leading-5",yo="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",ho=new Set(["invalidEmail","emailNotFound","deliveryUnavailable"]),Ut="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 Fn({login:e,texts:t,allowHaveCode:n=!0,emailPlaceholder:a,emailInputId:r,codeInputId:o,className:i,buttonClassName:d,children:c}){let l=_react3.useId.call(void 0, ),p=_nullishCoalesce(r, () => (`${l}-email`)),y=_nullishCoalesce(o, () => (`${l}-code`)),w=`${l}-notice`,u=`${l}-hint`,{notice:f}=e,b=_optionalChain([f, 'optionalAccess', _2 => _2.kind])==="error",s=e.busy==="send",k=e.busy==="verify",T=e.busy==="resend",j=_chunkESF5ZVVFjs.g.call(void 0, "h-11 w-full",d),B=_optionalChain([f, 'optionalAccess', _3 => _3.kind])==="success",A=_jsxruntime.jsxs.call(void 0, "div",{id:w,className:"min-h-10 text-sm leading-5",children:[_jsxruntime.jsx.call(void 0, "p",{role:"alert",className:"font-medium text-red-700 dark:text-red-400",children:b?f.text:null}),_jsxruntime.jsxs.call(void 0, "p",{role:"status",className:_chunkESF5ZVVFjs.g.call(void 0, "flex items-start gap-1.5",B?"font-medium text-emerald-700 dark:text-emerald-400":"text-foreground"),children:[B&&_jsxruntime.jsx.call(void 0, _lucidereact.CircleCheck,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),_jsxruntime.jsx.call(void 0, "span",{children:f!=null&&!b?f.text:null})]})]}),J=b&&e.step==="email"&&(f.failure==null||ho.has(f.failure)),ce=_jsxruntime.jsx.call(void 0, "p",{className:"sr-only",role:"status","aria-live":"polite",children:e.announcement}),E=_jsxruntime.jsxs.call(void 0, "div",{className:"grid gap-2",children:[_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.d,{htmlFor:p,children:t.emailLabel}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.s,{id:p,ref:e.emailRef,name:"email",type:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoFocus:!0,required:!0,className:_chunkESF5ZVVFjs.g.call(void 0, "h-11 text-base disabled:opacity-100 disabled:text-foreground/70",yo),placeholder:_nullishCoalesce(a, () => (t.emailPlaceholder)),value:e.email,disabled:e.isBusy,"aria-invalid":J?!0:void 0,"aria-describedby":w,onChange:Y=>e.setEmail(Y.target.value)})]});if(e.step==="email")return _jsxruntime.jsxs.call(void 0, "form",{noValidate:!0,className:_chunkESF5ZVVFjs.g.call(void 0, "flex flex-col gap-4",i),onSubmit:Y=>{Y.preventDefault(),e.sendCode()},children:[ce,E,A,_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{type:"submit",disabled:e.isBusy,"aria-busy":s,className:j,children:[s&&_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.e,{"aria-hidden":!0}),s?t.sending:t.sendCode]}),n&&_jsxruntime.jsxs.call(void 0, "p",{className:"flex flex-wrap items-center justify-center text-center text-sm",children:[t.haveCodePrompt!==""&&_jsxruntime.jsx.call(void 0, "span",{children:t.haveCodePrompt}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:Ut,disabled:e.isBusy,onClick:e.haveCode,children:t.haveCode})]})]});let[Z,pe]=t.codeSentTo.split("{email}"),$=e.dead!=null,Be=$?t.resendNew:e.secondsLeft>0?_chunk5FZAROP6js.i.call(void 0, t.resendIn,{seconds:e.secondsLeft}):t.resend;return _jsxruntime.jsxs.call(void 0, "form",{noValidate:!0,className:_chunkESF5ZVVFjs.g.call(void 0, "flex flex-col gap-4",i),onSubmit:Y=>{Y.preventDefault(),e.submitCode()},children:[ce,e.needsEmail?E:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-wrap items-center justify-between gap-x-2",children:[_jsxruntime.jsxs.call(void 0, "p",{className:"min-w-0 flex-[1_1_14rem] text-sm leading-5 break-words",children:[Z,_jsxruntime.jsx.call(void 0, "strong",{className:"font-semibold",children:e.email}),"\u2060",pe]}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:_chunkESF5ZVVFjs.g.call(void 0, Ut,"-ml-1 shrink-0"),disabled:e.isBusy,onClick:e.changeEmail,children:t.changeEmail})]}),c,_jsxruntime.jsxs.call(void 0, "div",{className:"grid gap-2",children:[_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.d,{htmlFor:y,children:t.codeLabel}),_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.k,{id:y,name:"code",inputRef:e.codeRef,value:e.code,onChange:e.setCode,onComplete:Y=>void e.submitCode(Y),disabled:e.isBusy||$,invalid:b&&!e.needsEmail,"aria-describedby":`${w} ${u}`}),_jsxruntime.jsxs.call(void 0, "p",{id:u,className:go,children:[t.validity," ",t.spamHint]})]}),A,_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{type:"submit",disabled:e.isBusy||$,"aria-busy":k,className:j,children:[k&&_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.e,{"aria-hidden":!0}),k?t.verifying:t.verify]}),e.needsEmail?_jsxruntime.jsx.call(void 0, "div",{className:"flex justify-center",children:_jsxruntime.jsx.call(void 0, "button",{type:"button",className:Ut,disabled:e.isBusy,onClick:e.changeEmail,children:t.noCode})}):_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{type:"button",variant:$?"default":"outline",disabled:e.isBusy||!$&&e.secondsLeft>0,"aria-busy":T,className:$?j:"h-11 w-full",onClick:()=>void e.resend(),children:[T&&_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.e,{"aria-hidden":!0}),Be]})]})}function _t(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 Po={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 qn(e=_chunk7RXW6XFYjs.f.call(void 0, ),t){return{..._chunk5FZAROP6js.h.call(void 0, e,t),..._chunk7RXW6XFYjs.a.call(void 0, Po,e),...bo(t,["title","description","codeTitle","codeDescription"])}}function bo(e,t){let n={};for(let a of t){let r=_optionalChain([e, 'optionalAccess', _4 => _4[a]]);r!=null&&(n[a]=r)}return n}var vo="return_url",jt="__return_url",ko="accessToken";function Je(e){let t=new URLSearchParams(e).get(vo);return t?Bn(t):null}function Ze(e){typeof window>"u"||(e?window.sessionStorage.setItem(jt,e):window.sessionStorage.removeItem(jt))}function Le(){if(typeof window>"u")return null;let e=window.sessionStorage.getItem(jt);return e?Bn(e):null}function wo(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 Bn(e){try{let t=new URL(e);return t.protocol!=="https:"&&t.protocol!=="http:"||!wo(t.origin,_chunk4BL7TLK3js.h.call(void 0, ))?null:t.toString()}catch (e2){return null}}function De(e,t){let n=new URL(e);return n.searchParams.set(ko,t),n.toString()}if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];_chunk4BL7TLK3js.h.call(void 0, ).length===0&&_chunk4BL7TLK3js.g.call(void 0, Array.from(new Set(t)))}var Co=({texts:e,projectID:t,host:n,locale:a,logo:r})=>{let o=_chunkC3BBJOVVjs.m.call(void 0, ),{mutateAsync:i}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelLogin),{mutateAsync:d}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelLoginWithCode),c=_react3.useMemo.call(void 0, ()=>({async send(u){try{let f=await i({email:u});return f.result.case==="success"?{ok:!0,retryIn:f.result.value.retryIn||void 0,challengeId:f.result.value.challengeId||void 0}:{ok:!1,kind:_t(f.result.case==="failure"?f.result.value:0)}}catch(f){return{ok:!1,kind:_chunk5FZAROP6js.a.call(void 0, f),cause:f}}},async verify({email:u,code:f,challengeId:b}){try{let s=await d({code:parseInt(f,10),email:u,challengeId:b});return s.result.case==="accessToken"&&s.result.value?{ok:!0,value:{accessToken:s.result.value}}:{ok:!1,kind:_t(s.result.case==="failure"?s.result.value:0)}}catch(s){return{ok:!1,kind:_chunk5FZAROP6js.a.call(void 0, s),cause:s}}}}),[i,d]),l=_chunk5FZAROP6js.j.call(void 0, {adapter:c,texts:e,storageKey:_chunk5FZAROP6js.f.call(void 0, "panel",t,n),onVerified:({accessToken:u},f)=>{o.track("panel_login",{}),_chunk4BL7TLK3js.l.call(void 0, t,u,f,n);let b=typeof window<"u"?Le():null;setTimeout(()=>{if(b){window.location.href=De(b,u);return}window.location.reload()},100)}}),p=l.step==="code",y=p&&!l.needsEmail?e.codeTitle:e.title,w=p&&!l.needsEmail?e.codeDescription:e.description;return _jsxruntime.jsx.call(void 0, "main",{className:"mx-auto flex w-full max-w-sm flex-1 flex-col justify-start pt-4 sm:pt-[12vh]",children:_jsxruntime.jsxs.call(void 0, ye,{children:[_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.c,{projectId:t,locale:a,className:"px-4 sm:px-6",...r}),_jsxruntime.jsxs.call(void 0, xe,{className:"px-4 sm:px-6",children:[_jsxruntime.jsx.call(void 0, Ce,{role:"heading","aria-level":1,className:"text-2xl",children:y}),_jsxruntime.jsx.call(void 0, zn,{children:w})]}),_jsxruntime.jsx.call(void 0, he,{className:"px-4 sm:px-6",children:_jsxruntime.jsx.call(void 0, Fn,{login:l,texts:e,emailInputId:"email",codeInputId:"verify-code"})})]})})},No=({analytics:e,texts:t,locale:n,showLogo:a,logoUrl:r,logoDarkUrl:o})=>{let{theme:i,allowedReturnOrigins:d,projectID:c,host:l}=_chunk4BL7TLK3js.j.call(void 0, ),p=_chunkC3BBJOVVjs.n.call(void 0, c,e,"panel"),y=_react3.useMemo.call(void 0, ()=>qn(_nullishCoalesce(n, () => (_chunk7RXW6XFYjs.f.call(void 0, ))),t),[n,t]),w={"--button-background-color":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _5 => _5.colors, 'optionalAccess', _6 => _6.brand]), () => ("#FFFFFF")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _7 => _7.colors, 'optionalAccess', _8 => _8.brandDark]), () => ("#000000")),"--button-text-color":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _9 => _9.colors, 'optionalAccess', _10 => _10.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([i, 'optionalAccess', _11 => _11.colors, 'optionalAccess', _12 => _12.brand]), () => ("#FFFFFF"))},[u]=_react.useAutoAnimate.call(void 0, {duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1});return _react3.useEffect.call(void 0, ()=>{typeof window>"u"||_chunk4BL7TLK3js.k.call(void 0, c,l)!=null&&(window.location.href=window.location.href.replaceAll("login",""))},[c,l]),_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window)return;let f=Je(window.location.search);f&&Ze(f);let b=_nullishCoalesce(f, () => (Le()));if(!b)return;let s=_chunk4BL7TLK3js.k.call(void 0, c,l);s&&(window.location.href=De(b,s))},[d,c,l]),_jsxruntime.jsx.call(void 0, _chunkC3BBJOVVjs.l,{value:p,children:_jsxruntime.jsx.call(void 0, "div",{className:"bg-white text-black dark:bg-black dark:text-white",children:_jsxruntime.jsx.call(void 0, "div",{className:"font-inter flex min-h-screen w-full flex-col p-4",style:w,ref:u,children:_jsxruntime.jsx.call(void 0, Co,{texts:y,projectID:c,host:l,locale:n,logo:{showLogo:a,logoUrl:_nullishCoalesce(r, () => (_optionalChain([i, 'optionalAccess', _13 => _13.logoURL]))),logoDarkUrl:_nullishCoalesce(o, () => (_optionalChain([i, 'optionalAccess', _14 => _14.logoDarkURL])))}})})})})},Io= exports.k =(e={})=>_jsxruntime.jsx.call(void 0, No,{...e});function Kn(e){let[t,n]=_react3.useState.call(void 0, ()=>{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 (e3){o[i]=d}}),{...e,...o}}),a=_react3.useCallback.call(void 0, r=>{n(o=>{let i={...o,...r};if(typeof window<"u"){let d=new URLSearchParams;Object.keys(i).forEach(l=>{let p=i[l];p!=null&&d.set(l,JSON.stringify(p))});let c=`${window.location.pathname}?${d.toString()}`;window.history.pushState({},"",c)}return i})},[]);return _react3.useEffect.call(void 0, ()=>{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 (e4){i[d]=c}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,a]}function Wn(e,t){if(e!=null)return e;let n=_optionalChain([t, 'optionalAccess', _15 => _15.trim, 'call', _16 => _16()]);if(!(n==null||n===""))return{tokens:_chunkSYN5KU3Ojs.u.call(void 0, n)}}var _reactswitch = require('@radix-ui/react-switch'); var ct = _interopRequireWildcard(_reactswitch);function Jn({className:e,...t}){return _jsxruntime.jsx.call(void 0, ct.Root,{"data-slot":"switch",className:_chunkESF5ZVVFjs.g.call(void 0, "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:_jsxruntime.jsx.call(void 0, ct.Thumb,{"data-slot":"switch-thumb",className:_chunkESF5ZVVFjs.g.call(void 0, "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function Lo({}){let[e,t]=_react3.useState.call(void 0, {disableAll:!1});return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Powiadomienia"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center space-x-2",children:[_jsxruntime.jsx.call(void 0, Jn,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:n=>t(a=>({...a,disableAll:n}))}),_jsxruntime.jsxs.call(void 0, _chunk5FZAROP6js.d,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-neutral-500 md:text-sm",children:"Ten przycisk mo\u017Ce wy\u0142\u0105czy\u0107 wszystkie powiadomienia"})]})]})})]})}var Zn=Lo;function Yn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:_chunkESF5ZVVFjs.g.call(void 0, "mx-auto flex w-full justify-center",e),...t})}function Qn({className:e,...t}){return _jsxruntime.jsx.call(void 0, "ul",{"data-slot":"pagination-content",className:_chunkESF5ZVVFjs.g.call(void 0, "flex flex-row items-center gap-1",e),...t})}function Pe({...e}){return _jsxruntime.jsx.call(void 0, "li",{"data-slot":"pagination-item",...e})}function Ee({className:e,isActive:t,size:n="icon",...a}){return _jsxruntime.jsx.call(void 0, "a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:_chunkESF5ZVVFjs.g.call(void 0, _chunkSYN5KU3Ojs.q.call(void 0, {variant:t?"outline":"ghost",size:n}),e),...a})}function Xn({className:e,...t}){return _jsxruntime.jsxs.call(void 0, Ee,{"aria-label":"Go to previous page",size:"default",className:_chunkESF5ZVVFjs.g.call(void 0, "gap-1 px-2.5 sm:pl-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeftIcon,{}),_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Previous"})]})}function er({className:e,...t}){return _jsxruntime.jsxs.call(void 0, Ee,{"aria-label":"Go to next page",size:"default",className:_chunkESF5ZVVFjs.g.call(void 0, "gap-1 px-2.5 sm:pr-2.5",e),...t,children:[_jsxruntime.jsx.call(void 0, "span",{className:"hidden sm:block",children:"Next"}),_jsxruntime.jsx.call(void 0, _lucidereact.ChevronRightIcon,{})]})}function Ft({className:e,...t}){return _jsxruntime.jsxs.call(void 0, "span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:_chunkESF5ZVVFjs.g.call(void 0, "flex size-9 items-center justify-center",e),...t,children:[_jsxruntime.jsx.call(void 0, _lucidereact.MoreHorizontalIcon,{className:"size-4"}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"More pages"})]})}var _o=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),jo=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100),zo={draft:"Szkic",unpaid:"Nieop\u0142acona",paid:"Op\u0142acona",overdue:"Zaleg\u0142a",cancelled:"Anulowana",completed:"Zako\u0144czone",processing:"Przetwarzane",refunded:"Zwr\xF3cone"},Fo={draft:"text-neutral-400",unpaid:"text-yellow-500",paid:"text-green-600",overdue:"text-red-500",cancelled:"text-neutral-400 line-through",completed:"text-green-600",processing:"text-blue-500",refunded:"text-purple-500"};function qo({openOrderDetails:e,projectID:t,accessToken:n}){let[a,r]=_react3.useState.call(void 0, 0),o=20,{data:i,isFetching:d}=_chunkSYN5KU3Ojs.l.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.getOrders,{projectId:t,accessToken:n,offset:a,limit:o}),c=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _17 => _17.orders]), () => ([])),l=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _18 => _18.totalCount]), () => (0)),p=Math.floor(a/o)+1,y=Math.ceil(l/o),w=u=>{r(u)};return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),d?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,f)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.v,{className:"h-4 w-24"}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.v,{className:"h-3 w-32"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2 text-right",children:[_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.v,{className:"ml-auto h-4 w-16"}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.v,{className:"ml-auto h-3 w-12"})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-3",children:_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.v,{className:"h-3 w-40"})})]},f))}):c.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex w-full flex-col gap-3",children:c.map(u=>_jsxruntime.jsxs.call(void 0, "button",{onClick:()=>e(u.id),className:"block rounded-xl bg-white p-4 text-left shadow-sm transition-colors hover:bg-neutral-50 dark:bg-neutral-800 dark:hover:bg-neutral-700",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"text-right",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:jo(u.totalAmount,u.currency)}),_jsxruntime.jsx.call(void 0, "p",{className:`text-xs font-medium ${_nullishCoalesce(Fo[u.status], () => ("text-neutral-400"))}`,children:_nullishCoalesce(zo[u.status], () => (u.status))})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:_jsxruntime.jsxs.call(void 0, "span",{children:["Data:"," ",u.createdAt?_o(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),y>1&&!d&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-4 flex justify-center",children:_jsxruntime.jsx.call(void 0, Yn,{children:_jsxruntime.jsxs.call(void 0, Qn,{children:[p>1&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Xn,{onClick:()=>w(a-o)})}),p>2&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Ee,{onClick:()=>w(0),children:"1"})}),p>3&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Ft,{})}),[p-1,p,p+1].filter(u=>u>0&&u<=y).map(u=>_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Ee,{onClick:()=>w((u-1)*o),isActive:p===u,children:u})},u)),p<y-2&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Ft,{})}),p<y&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, Ee,{onClick:()=>w((y-1)*o),children:y})}),p<y&&_jsxruntime.jsx.call(void 0, Pe,{children:_jsxruntime.jsx.call(void 0, er,{onClick:()=>w(a+o)})})]})})})]})]})}var tr=qo;var rr=e=>new Date(e*1e3).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),$o={active:"Aktywny",cancelled:"Anulowany",paused:"Wstrzymany"},Ho={active:"text-green-600",cancelled:"text-red-500",paused:"text-yellow-500"};function Go({projectID:e}){let[t,n]=_react3.useState.call(void 0, []),[a,r]=_react3.useState.call(void 0, !0);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Plany"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),a?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-col gap-4",children:t.map(o=>_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-start justify-between",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-semibold",children:o.tierName}),o.configName&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:o.configName})]}),_jsxruntime.jsx.call(void 0, "span",{className:`text-sm font-medium ${_nullishCoalesce(Ho[o.status], () => ("text-neutral-500"))}`,children:_nullishCoalesce($o[o.status], () => (o.status))})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",o.billingDay]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data startu:"})," ",rr(o.startDate)]}),o.endDate&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",rr(o.endDate)]})]})]},o.id))})]})}var or=Go;function Vo(e,t,n,a){typeof window>"u"||(t&&_chunk4BL7TLK3js.n.call(void 0, n,a),window.location.href=e)}function Jo({projectID:e,host:t,loginURL:n,screen:a,params:r,setParams:o,setActiveScreen:i}){let{status:d,exchangeError:c}=_chunk5FZAROP6js.t.call(void 0, "PanelReturns"),l=_chunk5FZAROP6js.r.call(void 0, ),p=d==="anonymous"&&(c==null||_chunk5FZAROP6js.p.call(void 0, c));_react3.useEffect.call(void 0, ()=>{p&&Vo(n,c!=null,e,t)},[p,n,c,e,t]);let[y,w]=_react3.useState.call(void 0, "orders"),[u,f]=_react3.useState.call(void 0, {items:[],note:""}),[b,s]=_react3.useState.call(void 0, );if(d==="anonymous"&&!p)return _jsxruntime.jsxs.call(void 0, "div",{role:"alert",className:"flex flex-col items-start gap-3",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:l(_chunk5FZAROP6js.q.call(void 0, c))}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(d!=="authenticated")return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.C,{});let k=T=>{w(T),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(a==="return-details"&&r.returnId)return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.K,{returnId:r.returnId,onBack:()=>k("myReturns")});if(y==="myReturns")return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.J,{onBack:()=>k("orders"),onSelectReturn:T=>{o({state:"return-details",returnId:T,orderId:void 0}),i("return-details")}});if(y==="result"&&b!=null)return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.I,{returnId:b,onContinue:()=>k("orders"),onOpenMyReturns:()=>k("myReturns")});if(r.orderId){let T=r.orderId;return y==="confirmation"?_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.H,{orderId:T,items:u.items,note:u.note,onBack:()=>w("orders"),onSubmitted:j=>{s(j),f({items:[],note:""}),w("result"),o({orderId:void 0})}}):_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.G,{orderId:T,initialItems:u.items.length>0?u.items:void 0,initialNote:u.note,onBack:()=>{f({items:[],note:""}),o({orderId:void 0})},onContinue:j=>{f(j),w("confirmation")}})}return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.F,{showLogout:!1,onSelectOrder:T=>{f({items:[],note:""}),w("orders"),o({orderId:T})},onOpenMyReturns:()=>k("myReturns")})}function $t({accessToken:e,appearance:t,texts:n,...a}){return _jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.u,{projectID:a.projectID,host:a.host,appearance:t,texts:n,panelAccessToken:e,children:_jsxruntime.jsx.call(void 0, Jo,{...a})})}function Yo(){return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),_jsxruntime.jsx.call(void 0, "div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var oe=Yo;var Xo=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g,ea=e=>[...e.matchAll(Xo)].map(n=>({url:n[0],startIndex:n.index,endIndex:n.index+n[0].length-1})),ta=(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},ar=e=>{let t=ea(e);return _jsxruntime.jsx.call(void 0, "p",{dangerouslySetInnerHTML:{__html:ta(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)))}})};var _protobuf = require('@bufbuild/protobuf');var _hlsjs = require('hls.js'); var _hlsjs2 = _interopRequireDefault(_hlsjs);function ir(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="playing")}function sr(){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.playbackState="paused")}function dr(e,t){typeof navigator>"u"||typeof navigator.mediaSession>"u"||e!=null&&isNaN(e)||t!=null&&isNaN(t)||navigator.mediaSession.setPositionState({playbackRate:1,duration:e,position:t})}function cr(e){typeof navigator>"u"||typeof navigator.mediaSession>"u"||(navigator.mediaSession.metadata=new MediaMetadata({title:e.title,artwork:e.artwork?[{type:"image/png",src:e.artwork}]:void 0}),navigator.mediaSession.setActionHandler("play",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("pause",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("stop",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekbackward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekforward",t=>{e.action(t)}),navigator.mediaSession.setActionHandler("seekto",t=>{e.action(t)}))}function lr(){navigator.mediaSession.metadata=null}var sa=_react3.forwardRef.call(void 0, ({chapters:e,styles:t,updateCurrentTime:n,setCurrentTimeHandler:a,title:r,imageURL:o,uniqueProductID:i,onChapterChange:d},c)=>{let l;(q=>(q[q.Playing=0]="Playing",q[q.Paused=1]="Paused"))(l||={});let[p,y]=_react3.useState.call(void 0, 1);_react3.useEffect.call(void 0, ()=>{switch(p){case 0:ir();break;case 1:sr();break}},[p]),_react3.useImperativeHandle.call(void 0, c,()=>({selectChapter:g=>{He(g)}}));let[w,u]=_react3.useState.call(void 0, void 0),[f,b]=_react3.useState.call(void 0, void 0),s=_react3.useRef.call(void 0, null),k=_react3.useRef.call(void 0, void 0),T=_react3.useRef.call(void 0, void 0),j=_react3.useRef.call(void 0, null),B=_react3.useRef.call(void 0, null),[A,J]=_react3.useState.call(void 0, !0),[ce,E]=_react3.useState.call(void 0, !1),[Z,pe]=_react3.useState.call(void 0, !da());function $(g){g<10||localStorage.setItem(`__player__${i}_${_optionalChain([B, 'access', _19 => _19.current, 'optionalAccess', _20 => _20.id])}`,`${g}`)}function Be(){let g=localStorage.getItem(`__player__${i}_${_optionalChain([B, 'access', _21 => _21.current, 'optionalAccess', _22 => _22.id])}`);if(g!=null)try{let M=parseInt(g);return isNaN(M)||M<0?void 0:M}catch (e5){return}}function Y(){let g=localStorage.getItem(`__player__${i}_last_chapter`);if(g!=null)return g}function xt(g){localStorage.setItem(`__player__${i}_last_chapter`,g)}function Ct(g){localStorage.removeItem(`__player__${i}_${g}`)}function v(){s.current!=null&&(s.current.onloadeddata=()=>{if(s.current!=null){if(s.current.readyState<2&&pe(!0),s.current.readyState>=2&&pe(!1),!ce){let g=Be();g!=null&&nt(g),E(!0)}if(A){J(!1);try{Nt()}catch(g){console.log("play error",g)}}}},s.current.onplay=()=>{},s.current.onseeked=()=>{},s.current.onseeking=()=>{},s.current.onpause=()=>{},s.current.onended=()=>{ne()},cr({title:_nullishCoalesce(r, () => ("")),artwork:o,action:g=>{switch(g.action){case"play":Nt();break;case"pause":It();break;case"seekbackward":tt(-15);break;case"seekforward":tt(15);break;case"seekto":g.seekTime&&nt(g.seekTime);break;case"stop":It();break;default:break}}}),we())}function ne(){if(e==null||e.length==0)return;let g=e.findIndex(q=>q.id==_optionalChain([B, 'access', _23 => _23.current, 'optionalAccess', _24 => _24.id]));g==-1||(Ct(e[g].id),g+1>=e.length)||He(e[g+1])}function we(){Ne(),T.current==null&&(T.current=setTimeout(()=>{Ne(),T.current=void 0,we()},500))}function $e(){T.current!=null&&clearTimeout(T.current)}function Ne(){s.current!=null&&(y(s.current.paused?1:0),b(s.current.duration),u(s.current.currentTime),$(s.current.currentTime),dr(s.current.duration,s.current.currentTime),s.current.networkState===s.current.NETWORK_LOADING&&s.current.readyState<=s.current.HAVE_FUTURE_DATA?pe(!0):pe(!1),n&&n(s.current.currentTime))}function Nt(){_optionalChain([s, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.play, 'call', _27 => _27(), 'access', _28 => _28.then, 'call', _29 => _29(), 'access', _30 => _30.catch, 'call', _31 => _31()]),Ne()}function It(){_optionalChain([s, 'access', _32 => _32.current, 'optionalAccess', _33 => _33.pause, 'call', _34 => _34()]),Ne()}function io(){if(p===0){It();return}Nt()}function tt(g){if(s.current==null)return;let M=s.current.currentTime+g;if(M<0){s.current.currentTime=0;return}if(M>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime+=g}function nt(g){if(s.current!=null){if(u(g),g<0){s.current.currentTime=0;return}if(g>s.current.duration){s.current.currentTime=s.current.duration;return}s.current.currentTime=g}}function so(){s.current!=null&&(s.current.onplay=null,s.current.onseeked=null,s.current.onseeking=null,s.current.onpause=null,s.current.onended=null,s.current.src="",_optionalChain([k, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]))}function ln(g){if(g.length==0)return;let M=Y();if(M==null){He(g[0]);return}let q=g.find(Ie=>Ie.id==M);if(q==null){He(g[0]);return}He(q)}function He(g){E(!1),J(!0),B.current=g,co(g.publicUrl),_optionalChain([d, 'optionalCall', _38 => _38(g)]),xt(g.id)}function co(g){s.current!=null&&(s.current.canPlayType("application/vnd.apple.mpegurl")?s.current.src=g:_hlsjs2.default.isSupported()&&(k.current==null&&(k.current=new _hlsjs2.default,_optionalChain([k, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.attachMedia, 'call', _41 => _41(s.current)])),_optionalChain([k, 'access', _42 => _42.current, 'optionalAccess', _43 => _43.loadSource, 'call', _44 => _44(g)])))}_react3.useEffect.call(void 0, ()=>{s.current!=null&&(v(),ln(e))},[s.current]),_react3.useEffect.call(void 0, ()=>{ln(e)},[e]),_react3.useEffect.call(void 0, ()=>(_optionalChain([a, 'optionalCall', _45 => _45(nt)]),()=>{u(void 0),_optionalChain([s, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.pause, 'call', _48 => _48()]),so(),lr()}),[]);let un=g=>{let M=Math.floor(g/3600),q=Math.floor(g/60)%60,Ie=Math.floor(g%60),uo=M>0?M<10?`0${M}:`:`${M}:`:"",mo=Ie<10?`0${Ie}`:`${Ie}`;return isNaN(Ie)||isNaN(q)||isNaN(M)?"":`${uo}${q}:${mo}`},lo=g=>{let M=parseFloat(g.value)/parseFloat(g.max)*100;j.current.style.setProperty("--seek-before-width",M+"%");let q=f*M/100;nt(q)};return _jsxruntime.jsxs.call(void 0, "div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:j,children:[_jsxruntime.jsx.call(void 0, "video",{ref:s,className:"hidden",poster:o,title:r}),_jsxruntime.jsx.call(void 0, "input",{type:"range",min:"0",max:f!=null?Math.floor(f).toString():100,value:_nullishCoalesce(w, () => (0)),onChange:g=>lo(g.target),className:"w-full"}),_jsxruntime.jsxs.call(void 0, "section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[_jsxruntime.jsx.call(void 0, "span",{id:"current-time",children:un(w)}),_jsxruntime.jsx.call(void 0, "span",{id:"duration",children:un(f)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{variant:"outline",onClick:()=>tt(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{variant:"outline",onClick:io,"aria-label":"Play Or Pause",children:[p===1&&_jsxruntime.jsx.call(void 0, _lucidereact.Play,{className:"h-5 w-5"}),p===0&&_jsxruntime.jsx.call(void 0, _lucidereact.Pause,{className:"h-5 w-5"})]}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{variant:"outline",onClick:()=>tt(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),Z&&_jsxruntime.jsx.call(void 0, "div",{className:"mt-2 flex w-full justify-center",children:_jsxruntime.jsx.call(void 0, oe,{})})]})});function da(){return navigator.userAgent.toLowerCase().indexOf("safari/")>-1}var mr=sa;var ca={pl:{returnsNavLabel:"Zwroty",openCourse:"Otw\xF3rz kurs"},en:{returnsNavLabel:"Returns",openCourse:"Open the course"}};function Xe(e=_chunk7RXW6XFYjs.f.call(void 0, )){return _chunk7RXW6XFYjs.a.call(void 0, ca,e)}function fr(){let[e,t]=mt.useState(13);return mt.useEffect(()=>{let n=setTimeout(()=>t(66),500);return()=>clearTimeout(n)},[]),_jsxruntime.jsx.call(void 0, "div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:_jsxruntime.jsx.call(void 0, "div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}function ue(e,...t){console.warn(e,...t)}function Gt(e){console.error(e)}var ma=({accessToken:e,product:t,styles:n,reveal:a,onOpenCourse:r})=>{let o=t.productType,i=_chunkC3BBJOVVjs.m.call(void 0, ),d=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),c=_react3.useRef.call(void 0, null),[l]=_react.useAutoAnimate.call(void 0, ),[p,y]=_react3.useState.call(void 0, null),{mutateAsync:w,isPending:u}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelGetFileDetails),f=_react3.useRef.call(void 0, void 0),[b,s]=_react3.useState.call(void 0, null),[k,T]=_react3.useState.call(void 0, null),[j,B]=_react3.useState.call(void 0, !1),{mutateAsync:A,isPending:J}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelGetAudiobookDetails),{mutateAsync:ce,isPending:E}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[Z,pe]=_react3.useState.call(void 0, null),[$,Be]=_react3.useState.call(void 0, null);async function Y(){try{let v=await w({accessId:t.accessId,accessToken:e});if(v.result.case==="success"){y(v.result.value.files);return}else ue("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),ue("Kod b\u0142\u0119du: ",v.result.value)}catch(v){ue("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Gt("B\u0142\u0105d podczas pobierania danych:"+v)}}async function xt(){try{let v=await A({accessId:t.accessId,accessToken:e});if(v.result.case==="audiobook"){s(v.result.value);return}else ue("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),ue("Kod b\u0142\u0119du: ",v.result.value)}catch(v){ue("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Gt("B\u0142\u0105d podczas pobierania danych:"+v)}}async function Ct(){try{let v=await ce({accessId:t.accessId,accessToken:e,isBrowser:!0});if(v.result.case==="success"){T(v.result.value.audiobookDownloadDetails),B(v.result.value.isAvailableToDownloadInMobileApp===!0);return}else ue("Pobranie plik\xF3w nie powiod\u0142o si\u0119. Zalecamy kontakt."),ue("Kod b\u0142\u0119du: ",v.result.value)}catch(v){ue("Nieoczekiwany b\u0142\u0105d. Spr\xF3buj ponownie za chwil\u0119."),Gt("B\u0142\u0105d podczas pobierania danych:"+v)}}return _react3.useEffect.call(void 0, ()=>{o===1&&(xt().then().catch(),Ct().then().catch())},[]),_react3.useEffect.call(void 0, ()=>{if(b!=null&&k!=null){let v=b.chapters;if(!v)return;let ne=v.map(we=>{let $e=_optionalChain([k, 'optionalAccess', _49 => _49.find, 'call', _50 => _50(Ne=>Ne.chapterId===we.id)]);if($e!=null)return{...we,publicUrl:$e.publicUrl,downloadableUrl:$e.downloadableUrl,duration:$e.duration}}).filter(we=>we!=null);ne!=null&&ne.length>0&&Be(ne)}},[b,k]),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>a(),variant:"ghost",className:"w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-6 w-6"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-inter text-sm font-medium",children:"Wr\xF3\u0107"})]})}),_jsxruntime.jsxs.call(void 0, "main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex w-full max-w-xl flex-col gap-6",children:[o===2&&_jsxruntime.jsxs.call(void 0, "div",{ref:l,className:"flex flex-col space-y-4 rounded bg-white p-6 drop-shadow-xl dark:border dark:border-neutral-700 dark:bg-neutral-800 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between gap-x-4",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(p==null||p.length==0)&&_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:Y,"aria-label":"Download Product",className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:u?_jsxruntime.jsx.call(void 0, oe,{}):"Wy\u015Bwietl"})]}),u&&_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-2",children:[_jsxruntime.jsx.call(void 0, fr,{}),_jsxruntime.jsx.call(void 0, "p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),p!=null&&p.length>0&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-start justify-start gap-2",children:p.map((v,ne)=>_jsxruntime.jsxs.call(void 0, "a",{target:"_blank",className:"flex w-fit items-center gap-2 rounded-md bg-neutral-800 px-3 py-2 text-neutral-200 dark:bg-neutral-200 dark:text-neutral-800",href:v,download:!0,onClick:d,children:[`Plik numer ${ne+1}`,_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})]},ne))})]}),o===4&&_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center justify-center rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>r(t.accessId),className:"text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:Xe().openCourse})}),o===1&&_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col space-y-6 rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[_jsxruntime.jsx.call(void 0, "h4",{className:"text-xl font-semibold",children:_nullishCoalesce(_optionalChain([Z, 'optionalAccess', _51 => _51.name]), () => ("Odtwarzacz"))}),_optionalChain([Z, 'optionalAccess', _52 => _52.description])&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm",children:_optionalChain([Z, 'optionalAccess', _53 => _53.description])}),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:J?_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, oe,{}),_jsxruntime.jsx.call(void 0, "p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:$!=null?_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsx.call(void 0, mr,{ref:c,chapters:$,title:_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'optionalAccess', _54 => _54.name]), () => (t.productName)), () => (void 0)),imageURL:_nullishCoalesce(_nullishCoalesce(_optionalChain([b, 'optionalAccess', _55 => _55.coverImage]), () => (t.productImageUrl)), () => (void 0)),styles:n,setCurrentTimeHandler:v=>{f.current=v},uniqueProductID:t.productId,onChapterChange:v=>{pe(v)}})}):_jsxruntime.jsx.call(void 0, "p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),_jsxruntime.jsxs.call(void 0, "div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 mb-3 text-xs",children:j?"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji r\xF3wnie\u017C bez dost\u0119pu do internetu.":"Mo\u017Cesz s\u0142ucha\u0107 tego audiobooka w aplikacji."}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-3",children:[_jsxruntime.jsx.call(void 0, "a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),_jsxruntime.jsx.call(void 0, "a",{href:"https://docs.bitsnap.pl/guides/audiobook",children:_jsxruntime.jsx.call(void 0, "img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-center rounded-xl bg-white p-3 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:o===1&&_jsxruntime.jsx.call(void 0, "div",{className:"max-h-96 w-full overflow-y-auto",children:J?_jsxruntime.jsxs.call(void 0, "div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[_jsxruntime.jsx.call(void 0, oe,{}),_jsxruntime.jsx.call(void 0, "p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),$==null?_jsxruntime.jsx.call(void 0, "p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):_jsxruntime.jsx.call(void 0, "ul",{className:"flex w-full flex-col gap-2",children:$.map((v,ne)=>_jsxruntime.jsxs.call(void 0, "li",{className:"flex items-center justify-between",children:[_jsxruntime.jsxs.call(void 0, "button",{className:_chunkESF5ZVVFjs.g.call(void 0, "w-full rounded-lg p-2 text-left transition hover:bg-neutral-200 active:bg-neutral-200 dark:hover:bg-neutral-700 dark:active:bg-neutral-700",_optionalChain([Z, 'optionalAccess', _56 => _56.id])==v.id?"bg-neutral-200 dark:bg-neutral-700":"bg-neutral-100 dark:bg-neutral-800 dark:text-neutral-300"),onClick:()=>{c.current.selectChapter(v)},children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-between",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-medium",children:v.name}),v.duration&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-xs text-neutral-500",children:[Math.floor(v.duration/60),":",String(Math.floor(v.duration%60)).padStart(2,"0")]})]}),v.description&&_jsxruntime.jsx.call(void 0, "p",{className:"mt-3 text-xs",children:v.description})]}),b&&b.isDownloadable&&v.downloadableUrl&&_jsxruntime.jsx.call(void 0, "a",{href:v.downloadableUrl,onClick:d,children:_jsxruntime.jsx.call(void 0, _lucidereact.Download,{width:14,height:14})})]},ne))})]})})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"w-full max-w-3xl space-y-6 rounded-xl bg-white p-6 drop-shadow-xl dark:bg-neutral-900 dark:drop-shadow-none",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-3xl font-semibold",children:t.productName}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),_jsxruntime.jsx.call(void 0, "img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},Pr=ma;var _connectquery = require('@connectrpc/connect-query');function br(e,t){let n=_connectquery.useTransport.call(void 0, ),[a,r]=_react3.useState.call(void 0, {status:"loading"});return _react3.useEffect.call(void 0, ()=>{if(!e){r({status:"hidden"});return}let o=!1;return r({status:"loading"}),Promise.resolve().then(() => _interopRequireWildcard(require("./model-files-client-P4PORZJ6.js"))).then(({listModelFiles:i})=>i(n,e,t)).catch(()=>({status:"hidden"})).then(i=>{o||r(i)}),()=>{o=!0}},[n,e,t]),a}var wa=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./PanelModelFiles-NYCOFPLY.js")))),xa=({accessToken:e,projectID:t,loginURL:n,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d})=>{let{host:c}=_chunk4BL7TLK3js.j.call(void 0, ),{data:l,isLoading:p,error:y,refetch:w}=_chunkSYN5KU3Ojs.l.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelGetProducts,{accessToken:e}),u=br(e,t),f=Ca({products:p?{status:"loading"}:y!=null?{status:"error"}:_optionalChain([l, 'optionalAccess', _57 => _57.result, 'access', _58 => _58.case])==="success"?{status:"ok",count:l.result.value.products.length}:_optionalChain([l, 'optionalAccess', _59 => _59.result, 'access', _60 => _60.case])==="failure"?{status:"failure",unauthorized:l.result.value===9}:{status:"error"},modelFiles:u});if(_react3.useEffect.call(void 0, ()=>{f.kind==="signed-out"&&(_chunk4BL7TLK3js.n.call(void 0, t,c),window.location.href=n)},[f.kind,t,c,n]),f.kind==="loading"||f.kind==="signed-out")return _jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-dark font-inter font-medium dark:text-white",children:_chunk7RXW6XFYjs.f.call(void 0, ).toLowerCase().startsWith("en")?"Loading...":"\u0141adowanie..."}),_jsxruntime.jsx.call(void 0, oe,{})]});let b=l&&l.result.case==="success"?l.result.value.products:[],s=u.status==="ready"?u.models:[],k=s.length>0?_jsxruntime.jsx.call(void 0, _react3.Suspense,{fallback:null,children:_jsxruntime.jsx.call(void 0, wa,{accessToken:e,models:s,buttonStyle:a})}):null;return f.kind==="error"?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Ia,{onRetry:()=>void w()}),k]}):f.kind==="empty"?_jsxruntime.jsx.call(void 0, Na,{}):_jsxruntime.jsx.call(void 0, Sa,{accessToken:e,products:b,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d,filesSection:k})};function Ca({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 Na(){let e=_chunk7RXW6XFYjs.f.call(void 0, ).toLowerCase().startsWith("en");return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-1","data-testid":"panel-empty",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:e?"Hi \u{1F44B}":"Hej \u{1F44B}"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:e?"You have no products in this shop yet. Your purchases will show up here.":"Nie masz jeszcze produkt\xF3w w tym sklepie. Twoje zakupy pojawi\u0105 si\u0119 tutaj."})]})}function Ia({onRetry:e}){let t=_chunk7RXW6XFYjs.f.call(void 0, ).toLowerCase().startsWith("en");return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-start gap-3",role:"alert","data-testid":"panel-error",children:[_jsxruntime.jsx.call(void 0, "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."}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{type:"button",onClick:e,className:"text-sm",children:t?"Try again":"Spr\xF3buj ponownie"})]})}var vr=xa,Sa=({accessToken:e,products:t,styles:n,filesSection:a,activeScreen:r,params:o,setParams:i,openCourse:d})=>{let[c,l]=_react3.useState.call(void 0, o.product?_protobuf.fromJsonString.call(void 0, _chunkSYN5KU3Ojs.e,o.product):void 0),p=u=>{u==null?(l(void 0),i({product:void 0,state:"products"})):i({product:_protobuf.toJsonString.call(void 0, _chunkSYN5KU3Ojs.e,u),state:"products"})};function y(u){switch(u){case 1:return"Audio";case 2:return"Plik";case 3:return"Bilet";case 4:return"Kurs";default:return}}function w(u){if(u.productType===4){d(u.accessId);return}l(u),p(u)}return r==="products"&&c!=null?_jsxruntime.jsx.call(void 0, Pr,{accessToken:e,product:c,styles:n,reveal:p,onOpenCourse:d}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),t.length>0&&_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),_jsxruntime.jsx.call(void 0, "div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:_optionalChain([t, 'optionalAccess', _61 => _61.map, 'call', _62 => _62((u,f)=>_jsxruntime.jsxs.call(void 0, "section",{onClick:()=>w(u),className:"w-full max-w-xs cursor-pointer rounded drop-shadow-xl dark:border dark:border-slate-600 dark:drop-shadow-none",children:[_jsxruntime.jsxs.call(void 0, "section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&_jsxruntime.jsx.call(void 0, "div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:_jsxruntime.jsx.call(void 0, "span",{className:"text-sm font-medium text-white dark:text-slate-100",children:y(u.productType)})}),_jsxruntime.jsx.call(void 0, "div",{className:"jusitfy-center flex max-h-40 items-center",children:_jsxruntime.jsx.call(void 0, "img",{src:u.productImageUrl,alt:`Product ${f} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[_jsxruntime.jsx.call(void 0, "h2",{className:"text-xl font-semibold",children:u.productName}),_jsxruntime.jsx.call(void 0, "p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:ar(u.productDescription)}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:b=>{b.stopPropagation(),w(u)},className:"w-full text-sm font-medium transition-opacity duration-300 ease-in-out hover:opacity-80 active:opacity-80",style:n,children:"Zobacz"})]})]},f))])}),a]})};function La({activeScreen:e,setActiveScreen:t,setParams:n,styles:a,theme:r,logout:o}){return _jsxruntime.jsxs.call(void 0, "header",{className:"md:border-r-neutral-150 md:bg-beige-50 fixed right-0 bottom-0 left-0 z-10 flex h-12 w-full items-center bg-neutral-800 md:static md:z-0 md:min-h-screen md:w-auto md:border-r dark:md:border-r-neutral-900",children:[_jsxruntime.jsx.call(void 0, Da,{activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, Ea,{activeScreen:e,setActiveScreen:t,setParams:n,theme:r,logout:o})]})}var Cr=La;function Da({activeScreen:e,setActiveScreen:t,setParams:n}){let{returnsNavLabel:a}=Xe();return _jsxruntime.jsxs.call(void 0, "nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[_jsxruntime.jsx.call(void 0, ft,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, ft,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, ft,{panelScreen:"returns",label:a,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n}),_jsxruntime.jsx.call(void 0, ft,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n})]})}function ft({panelScreen:e,label:t,imageURL:n,icon:a,activeScreen:r,setActiveScreen:o,setParams:i}){return _jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>{o(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:_chunkESF5ZVVFjs.g.call(void 0, "flex flex-col gap-0",r===e?"opacity-100":"opacity-50"),children:[_nullishCoalesce(a, () => (_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:"scale-75"}))),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs font-normal text-white",children:t})]})}function gt({panelScreen:e,label:t,imageURL:n,darkImageURL:a,icon:r,activeScreen:o,setActiveScreen:i,setParams:d,isExpanded:c}){return _jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>{i(e),d({product:void 0,state:e})},variant:o===e?"secondary":"ghost",className:"justify-start",children:[r!=null?_jsxruntime.jsx.call(void 0, "span",{className:_chunkESF5ZVVFjs.g.call(void 0, "inline-flex h-5 w-5 items-center justify-center",c?"mr-4":"mr-2"),children:r}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:n,alt:t,className:_chunkESF5ZVVFjs.g.call(void 0, "aspect-auto h-5 w-5 dark:hidden",c?"mr-4":"mr-2")}),_jsxruntime.jsx.call(void 0, "img",{src:a,alt:t,className:_chunkESF5ZVVFjs.g.call(void 0, "hidden aspect-auto h-5 w-5 dark:inline",c?"mr-4":"mr-2")})]}),c&&_jsxruntime.jsx.call(void 0, "span",{className:"md:text-medium hidden md:inline",children:t})]})}function Ea({activeScreen:e,setActiveScreen:t,setParams:n,theme:a,logout:r}){let[o]=_react.useAutoAnimate.call(void 0, ),[i,d]=_react3.useState.call(void 0, !0),{returnsNavLabel:c}=Xe();return _jsxruntime.jsxs.call(void 0, "div",{ref:o,className:_chunkESF5ZVVFjs.g.call(void 0, "hidden px-4 pt-4 pb-12 md:flex md:h-full md:flex-col dark:bg-neutral-900",i?"md:w-52":"md:w-16"),children:[_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center justify-between",children:_jsxruntime.jsx.call(void 0, Ma,{theme:a,isExpanded:i})}),_jsxruntime.jsx.call(void 0, wr,{className:"my-6"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-1 flex-col gap-2",children:[_jsxruntime.jsx.call(void 0, gt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, gt,{panelScreen:"orders",label:"Zam\xF3wienia",imageURL:"/icons/category-dark-24x24.svg",darkImageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, gt,{panelScreen:"returns",label:c,icon:_jsxruntime.jsx.call(void 0, _lucidereact.Undo2,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),_jsxruntime.jsx.call(void 0, gt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i})]}),_jsxruntime.jsx.call(void 0, wr,{className:"mb-6"}),_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:r,children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),i&&_jsxruntime.jsx.call(void 0, "p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function wr({className:e}){return _jsxruntime.jsxs.call(void 0, "div",{className:_chunkESF5ZVVFjs.g.call(void 0, "relative h-px w-full bg-neutral-300",e),children:[_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),_jsxruntime.jsx.call(void 0, "div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function Ma({theme:e,isExpanded:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[e==null&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(_optionalChain([e, 'optionalAccess', _63 => _63.logoDarkURL])||_optionalChain([e, 'optionalAccess', _64 => _64.logoURL]))&&_jsxruntime.jsx.call(void 0, "img",{src:_nullishCoalesce(e.logoDarkURL, () => (e.logoURL)),alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),_optionalChain([e, 'optionalAccess', _65 => _65.logoURL])&&_jsxruntime.jsx.call(void 0, "img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}function Ua({email:e,logout:t}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-2xl",children:"Profil"}),_jsxruntime.jsxs.call(void 0, "div",{className:"mt-6 flex-1 md:flex-none",children:[_jsxruntime.jsx.call(void 0, "span",{className:"text-sm text-neutral-500",children:"Email"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),_jsxruntime.jsx.call(void 0, "div",{className:"flex w-full flex-col items-center space-y-2",children:_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:t,className:"max-w-64 md:hidden",children:[_jsxruntime.jsx.call(void 0, _lucidereact.LogOut,{className:"mr-2",width:16,height:16}),_jsxruntime.jsx.call(void 0, "p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var Ir=Ua;var Fa=_react3.lazy.call(void 0, ()=>Promise.resolve().then(() => _interopRequireWildcard(require("./course.js"))).then(e=>({default:e.PanelCourse})));function Wt(e){return _jsxruntime.jsx.call(void 0, _react3.Suspense,{fallback:_jsxruntime.jsx.call(void 0, "div",{className:"flex items-center gap-2 p-2",role:"status",children:_jsxruntime.jsx.call(void 0, oe,{})}),children:_jsxruntime.jsx.call(void 0, Fa,{...e})})}function Ha({status:e}){let t={created:{color:"bg-neutral-100 text-neutral-700",icon:null},paid:{color:"bg-green-100 text-green-700",icon:_lucidereact.CheckCircle2},completed:{color:"bg-blue-100 text-blue-700",icon:_lucidereact.CheckCircle2},canceled:{color:"bg-red-100 text-red-700",icon:_lucidereact.AlertCircle},sent:{color:"bg-purple-100 text-purple-700",icon:_lucidereact.Truck},processing:{color:"bg-yellow-100 text-yellow-700",icon:_lucidereact.Loader2}},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 _jsxruntime.jsxs.call(void 0, "span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${n.color}`,children:[a&&_jsxruntime.jsx.call(void 0, a,{className:"h-4 w-4"}),r[e]||e]})}function Ga({orderID:e,email:t}){let[n,a]=_react3.useState.call(void 0, ""),r=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.addPublicOrderComment);return _jsxruntime.jsxs.call(void 0, "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:[_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.d,{htmlFor:"comment",children:"Dodaj komentarz"}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.w,{id:"comment",value:n,onChange:i=>a(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{type:"submit",disabled:!n.trim()||r.isPending,children:r.isPending?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Wysy\u0142anie..."]}):"Dodaj komentarz"})]})}function Tr(e){return e?new Date(Number(e.seconds)*1e3).toLocaleDateString("pl-PL",{year:"numeric",month:"long",day:"numeric"}):"N/A"}function Ar(e,t){return new Intl.NumberFormat("pl-PL",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function Ka({orderID:e,initialEmail:t,onBack:n,accessToken:a,analytics:r}){let{theme:o,projectID:i}=_chunk4BL7TLK3js.j.call(void 0, ),d=_chunkC3BBJOVVjs.n.call(void 0, i,r,"order"),[c,l]=_react3.useState.call(void 0, t||""),[p,y]=_react3.useState.call(void 0, !1),{data:w,isLoading:u,error:f,refetch:b}=_chunkSYN5KU3Ojs.l.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.getPublicOrderDetails,{projectId:_nullishCoalesce(i, () => ("")),orderId:e,email:c||void 0,accessToken:a},{enabled:!!e}),s=_optionalChain([w, 'optionalAccess', _66 => _66.result, 'access', _67 => _67.case])==="order"?w.result.value:null,k=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _68 => _68.isVerified]), () => (!1)),T=s!=null;_react3.useEffect.call(void 0, ()=>{T&&d.track("panel_order_viewed",{},{order_ref:null})},[d,T]);let j=()=>{b(),y(!1)},B={"--button-background-color":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _69 => _69.colors, 'optionalAccess', _70 => _70.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _71 => _71.colors, 'optionalAccess', _72 => _72.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _73 => _73.colors, 'optionalAccess', _74 => _74.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([o, 'optionalAccess', _75 => _75.colors, 'optionalAccess', _76 => _76.brand]), () => ("#000000"))};return u?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Loader2,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):f||!s?_jsxruntime.jsx.call(void 0, "div",{className:"flex min-h-screen items-center justify-center",children:_jsxruntime.jsx.call(void 0, ye,{className:"w-full max-w-md",children:_jsxruntime.jsx.call(void 0, he,{className:"pt-6",children:_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.AlertCircle,{className:"mx-auto h-12 w-12 text-red-500"}),_jsxruntime.jsx.call(void 0, "h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),_jsxruntime.jsx.call(void 0, "p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):_jsxruntime.jsx.call(void 0, "div",{className:"w-full bg-white py-8 dark:bg-black",style:B,children:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full px-4",children:[n&&_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[_jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeft,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"mb-6 flex items-center gap-4",children:[_optionalChain([o, 'optionalAccess', _77 => _77.logoURL])&&_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "img",{src:o.logoURL,alt:"Project logo",className:`h-12 w-auto ${o.logoDarkURL?"dark:hidden":""}`}),o.logoDarkURL&&_jsxruntime.jsx.call(void 0, "img",{src:o.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",s.orderId]})]})]}),_jsxruntime.jsxs.call(void 0, ye,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, xe,{children:_jsxruntime.jsxs.call(void 0, Ce,{className:"flex items-center",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Package,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),_jsxruntime.jsxs.call(void 0, he,{className:"space-y-6",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, Ha,{status:s.status}),s.processingStatus&&_jsxruntime.jsxs.call(void 0, "span",{className:"text-sm text-neutral-600",children:["\xB7 ",s.processingStatus]})]}),_jsxruntime.jsxs.call(void 0, "p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",Tr(s.createdAt)]})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:k?"":"text-neutral-500",children:s.customerName})]}),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Email:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:k?"":"text-neutral-500",children:s.customerEmail})]}),s.customerPhone&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Telefon:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:k?"":"text-neutral-500",children:s.customerPhone})]})]})]}),!k&&_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>y(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),_jsxruntime.jsxs.call(void 0, ye,{className:"mb-6",children:[_jsxruntime.jsx.call(void 0, xe,{children:_jsxruntime.jsx.call(void 0, Ce,{children:"Produkty"})}),_jsxruntime.jsxs.call(void 0, he,{className:"space-y-6",children:[_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:s.items.map((A,J)=>_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center gap-4",children:[A.imageUrl&&_jsxruntime.jsx.call(void 0, "img",{src:A.imageUrl,alt:A.name,className:"h-16 w-16 rounded object-cover"}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex-1",children:[_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:A.name}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"text-right",children:_jsxruntime.jsx.call(void 0, "p",{className:"font-medium",children:Ar(Number(A.price),A.currency)})})]},J))}),(s.deliveryAddress||s.deliveryMethod)&&_jsxruntime.jsxs.call(void 0, "div",{className:"border-t pt-4",children:[_jsxruntime.jsxs.call(void 0, "h3",{className:"mb-3 flex items-center font-semibold",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Truck,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[s.deliveryAddress&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Adres:"})," ",_jsxruntime.jsx.call(void 0, "span",{className:k?"":"text-neutral-500",children:s.deliveryAddress})]}),s.deliveryMethod&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Metoda:"})," ",s.deliveryMethod]}),s.trackingNumber&&k&&_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:"Tracking:"})," ",s.trackingNumber]})]})]}),_jsxruntime.jsx.call(void 0, "div",{className:"border-t pt-4",children:_jsxruntime.jsxs.call(void 0, "div",{className:"flex justify-between text-lg font-bold",children:[_jsxruntime.jsx.call(void 0, "span",{children:"Suma:"}),_jsxruntime.jsx.call(void 0, "span",{children:Ar(Number(s.totalAmount),s.currency)})]})})]})]}),_jsxruntime.jsxs.call(void 0, ye,{children:[_jsxruntime.jsx.call(void 0, xe,{children:_jsxruntime.jsxs.call(void 0, Ce,{children:["Komentarze ",s.commentCount>0&&`(${s.commentCount})`]})}),_jsxruntime.jsxs.call(void 0, he,{children:[s.comments.length>0?_jsxruntime.jsx.call(void 0, "div",{className:"space-y-4",children:s.comments.map(A=>_jsxruntime.jsxs.call(void 0, "div",{className:"border-b pb-4 last:border-b-0",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"mb-1 flex items-center gap-2",children:[_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",children:A.authorName||"System"}),_jsxruntime.jsx.call(void 0, "span",{className:"text-xs text-neutral-500",children:Tr(A.createdAt)}),A.authorType==="admin"&&_jsxruntime.jsx.call(void 0, "span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),_jsxruntime.jsx.call(void 0, "p",{className:k?"":"text-neutral-500",children:A.message})]},A.id))}):_jsxruntime.jsx.call(void 0, "p",{className:"text-neutral-600",children:"Brak komentarzy."}),k?_jsxruntime.jsx.call(void 0, Ga,{orderID:s.orderId,email:c}):_jsxruntime.jsx.call(void 0, "div",{className:"mt-4",children:_jsxruntime.jsxs.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:()=>y(!0),variant:"outline",className:"w-full",children:[_jsxruntime.jsx.call(void 0, _lucidereact.Lock,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),p&&_jsxruntime.jsx.call(void 0, "div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:_jsxruntime.jsxs.call(void 0, ye,{className:"w-full max-w-md",children:[_jsxruntime.jsx.call(void 0, xe,{children:_jsxruntime.jsx.call(void 0, Ce,{children:"Zweryfikuj sw\xF3j email"})}),_jsxruntime.jsxs.call(void 0, he,{className:"space-y-4",children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),_jsxruntime.jsxs.call(void 0, "div",{className:"space-y-2",children:[_jsxruntime.jsx.call(void 0, _chunk5FZAROP6js.d,{htmlFor:"verify-email",children:"Adres email"}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.s,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:c,onChange:A=>l(A.target.value)})]}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex gap-2",children:[_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{variant:"outline",onClick:()=>y(!1),className:"flex-1",children:"Anuluj"}),_jsxruntime.jsx.call(void 0, _chunkSYN5KU3Ojs.r,{onClick:j,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function Wa(e){return _jsxruntime.jsx.call(void 0, Ka,{...e})}var Zt=Wa;var Za=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:a,theme:r,loginURL:o,host:i}=_chunk4BL7TLK3js.j.call(void 0, ),d=_chunkC3BBJOVVjs.n.call(void 0, a,n,"panel"),c=_chunk4BL7TLK3js.k.call(void 0, a,i),l=_chunk4BL7TLK3js.m.call(void 0, a,i),{mutateAsync:p}=_chunkSYN5KU3Ojs.m.call(void 0, _chunkSYN5KU3Ojs.k.publicApi.userPanelLogout);async function y(){c&&await p({accessToken:c}),typeof window<"u"&&(_chunk4BL7TLK3js.n.call(void 0, a,i),window.location.reload())}let[w]=_react.useAutoAnimate.call(void 0, ),u=E=>["products","notifications","profile","plans","orders","order-details","returns","return-details","course"].includes(E),[f,b]=Kn({product:void 0,state:"products",orderId:void 0,returnId:void 0,course:void 0,item:void 0}),[s,k]=_react3.useState.call(void 0, u(f.state)?f.state:"products"),T=E=>{b({state:"order-details",orderId:E}),k("order-details")},j=()=>{b({state:"orders",orderId:void 0}),k("orders")},B=E=>b({orderId:void 0,returnId:void 0,course:void 0,item:void 0,...E}),A=E=>{b({state:"course",course:E,item:void 0,product:void 0}),k("course")},J=()=>{b({state:"products",course:void 0,item:void 0,product:void 0}),k("products")};_react3.useEffect.call(void 0, ()=>{u(f.state)&&(f.state==="course"||s==="course")&&k(f.state)},[f.state]);let ce={"--button-background-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _78 => _78.colors, 'optionalAccess', _79 => _79.brand]), () => ("#000000")),"--button-background-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _80 => _80.colors, 'optionalAccess', _81 => _81.brandDark]), () => ("#ffffff")),"--button-text-color":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _82 => _82.colors, 'optionalAccess', _83 => _83.brandDark]), () => ("#000000")),"--button-text-color-dark":_nullishCoalesce(_optionalChain([r, 'optionalAccess', _84 => _84.colors, 'optionalAccess', _85 => _85.brand]), () => ("#000000"))};return _react3.useEffect.call(void 0, ()=>{if(c==null||c.length===0){window.location.href=_nullishCoalesce(o, () => ("/panel/login"));return}},[]),_react3.useEffect.call(void 0, ()=>{if(c==null||c.length===0){window.location.href=_nullishCoalesce(o, () => ("/panel/login"));return}},[s]),_react3.useEffect.call(void 0, ()=>{if(typeof window>"u"||window.parent!==window||!c)return;let E=Je(window.location.search);E&&Ze(E);let Z=_nullishCoalesce(E, () => (Le()));Z&&(window.location.href=De(Z,c))},[c]),_jsxruntime.jsx.call(void 0, _chunkC3BBJOVVjs.l,{value:d,children:_jsxruntime.jsxs.call(void 0, "div",{ref:w,className:"font-inter relative min-h-screen w-screen bg-beige-100 text-black dark:bg-black dark:text-white md:flex",children:[_jsxruntime.jsx.call(void 0, Cr,{activeScreen:s,setActiveScreen:k,setParams:B,styles:ce,theme:r,logout:y}),_jsxruntime.jsxs.call(void 0, "main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[s==="products"&&_jsxruntime.jsx.call(void 0, vr,{projectID:_nullishCoalesce(a, () => ("")),accessToken:c,loginURL:_nullishCoalesce(o, () => ("/panel/login")),styles:ce,activeScreen:s,params:f,setParams:b,openCourse:A}),s==="course"&&f.course&&c&&_jsxruntime.jsx.call(void 0, Wt,{accessId:f.course,accessToken:c,theme:r,itemId:f.item,onItemChange:E=>b({item:E}),onBack:J}),s==="notifications"&&_jsxruntime.jsx.call(void 0, Zn,{}),s==="plans"&&_jsxruntime.jsx.call(void 0, or,{projectID:_nullishCoalesce(a, () => (""))}),s==="orders"&&_jsxruntime.jsx.call(void 0, tr,{projectID:_nullishCoalesce(a, () => ("")),accessToken:_nullishCoalesce(c, () => ("")),openOrderDetails:T}),s==="order-details"&&f.orderId&&_jsxruntime.jsx.call(void 0, Zt,{orderID:f.orderId,onBack:j}),(s==="returns"||s==="return-details")&&c&&_jsxruntime.jsx.call(void 0, $t,{projectID:_nullishCoalesce(a, () => ("")),host:i,accessToken:c,loginURL:_nullishCoalesce(o, () => ("/panel/login")),appearance:Wn(e,_optionalChain([r, 'optionalAccess', _86 => _86.colors, 'optionalAccess', _87 => _87.brand])),texts:t,screen:s,params:f,setParams:b,setActiveScreen:k}),s==="profile"&&_jsxruntime.jsx.call(void 0, Ir,{email:l,logout:y})]})]})})},Ya= exports.n =Za;var _reactquery = require('@tanstack/react-query');var _connect = require('@connectrpc/connect');var _connectweb = require('@connectrpc/connect-web');var de;(a=>{function e(r){return _connect.createClient.call(void 0, _chunkSYN5KU3Ojs.f,n(r))}a.get=e;let t=new Map;function n(r){let o=t.get(r);return o==null&&(o=_connectweb.createConnectTransport.call(void 0, {useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[_chunkESF5ZVVFjs.b]}),t.set(r,o)),o}})(de = exports.a||={});var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);function U(e,t=2){return+(Math.round(+(e+"e+"+t))+"e-"+t)}function Or(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 Ll=_zod2.default.object({event:_zod2.default.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:_zod2.default.string().optional(),value:_zod2.default.number().optional(),currency:_zod2.default.string().optional(),content_name:_zod2.default.string().optional(),items:_zod2.default.array(_zod2.default.object({id:_zod2.default.string(),name:_zod2.default.string(),price:_zod2.default.number().default(0),currency:_zod2.default.string().default("PLN"),quantity:_zod2.default.number().default(1)})).optional()});function Yt(e){typeof window>"u"||(ei(e),ni(e),ri(e))}function ei(e){try{typeof window.dataLayer>"u"&&(window.dataLayer=[]);let t=ti(e);window.dataLayer.push(t)}catch(t){console.warn("cannot send google analytics event",t)}}function ti(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _88 => _88.items, 'optionalAccess', _89 => _89.reduce, 'call', _90 => _90((o,i)=>o+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _91 => _91.items, 'optionalAccess', _92 => _92.map, 'call', _93 => _93(o=>({item_id:o.id,item_name:o.name||o.id,price:U((o.price||0)/100,2),quantity:o.quantity||1}))]),a={currency:e.currency||"PLN",value:U(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 ni(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 ri(e){try{if(typeof window.ttq>"u")return;let t=oi(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 oi(e){let t=_nullishCoalesce(_nullishCoalesce(e.value, () => (_optionalChain([e, 'access', _94 => _94.items, 'optionalAccess', _95 => _95.reduce, 'call', _96 => _96((o,i)=>o+(i.price||0)*(i.quantity||1),0)]))), () => (0)),n=_optionalChain([e, 'access', _97 => _97.items, 'optionalAccess', _98 => _98.map, 'call', _99 => _99(o=>({content_id:o.id,content_type:"product",content_name:o.name||o.id,quantity:o.quantity||1,price:U((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:U(t/100,2)});let a={currency:e.currency||"PLN",value:U(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 Ur(e){let{items:t,googlePayConfig:n,checkout:a,result:r,cartRequiresShipping:o}=e,i=_nullishCoalesce(e.locale, () => (_chunk7RXW6XFYjs.f.call(void 0, )));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+` - ${Or(l.amount,r.currency)}`,description:_nullishCoalesce(l.description, () => (""))})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:_chunk7RXW6XFYjs.c.call(void 0, "paymentForCart",i,e.texts),totalPrice:`${U(r.totalAmount/100,2)}`,currencyCode:r.currency,countryCode:r.country,checkoutOption:"COMPLETE_IMMEDIATE_PURCHASE",displayItems:ai(t,r.methods,_nullishCoalesce(r.selectedDeliveryMethod, () => ((r.methods.length>0?r.methods[0].id:void 0))),a.couponCode,r.couponValue,_chunk7RXW6XFYjs.c.call(void 0, "coupon",i,e.texts))}}}function ai(e,t,n,a,r,o="Coupon"){let i=[],d=0;for(let l of e){if(l.details==null)continue;let p=_nullishCoalesce(_optionalChain([l, 'access', _100 => _100.details, 'access', _101 => _101.pricing, 'optionalAccess', _102 => _102.effectivePrice]), () => (l.details.price));d+=p*l.quantity,i.push({label:l.details.name+" x "+l.quantity,price:`${U(p/100,2)}`,type:"LINE_ITEM",status:"FINAL"})}let c=t.find(l=>l.id===n);return c!=null&&i.push({label:c.name,price:`${U(c.amount/100,2)}`,type:"SHIPPING_OPTION",status:"FINAL"}),a!=null&&r!=null&&i.push({label:`${o} ${a}`,price:`${U(r/100,2)}`,type:"DISCOUNT",status:"FINAL"}),d>0&&i.push({label:"Subtotal",price:`${U(d/100,2)}`,type:"SUBTOTAL",status:"FINAL"}),i}function _e(e,t){return`${_chunkESF5ZVVFjs.e}/api/integrations/${e}/public-commerce${t}`}function ke(e){return typeof e=="object"&&e!=null&&"ERR"in e}function F(e,t,n){return{ERR:!0,error:e,type:t,data:n}}function _r(e,t){return _optionalChain([t, 'optionalAccess', _103 => _103.find, 'call', _104 => _104(n=>n.id===e||(_nullishCoalesce(_optionalChain([n, 'access', _105 => _105.variants, 'optionalAccess', _106 => _106.some, 'call', _107 => _107(a=>a.id===e)]), () => (!1))))])}function jr(e,t){let n=new Set(t.map(a=>a.productID));return Array.from(new Set(e.filter(a=>!n.has(a))))}function zr(e,t){let n=_optionalChain([e, 'optionalAccess', _108 => _108.trim, 'call', _109 => _109()]);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 (e6){return}}var _zustand = require('zustand');var je=_zustand.create.call(void 0, 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}))}));var Pt=_react3.createContext.call(void 0, {});function Kl({texts:e,locale:t,children:n}){let a=_react3.useMemo.call(void 0, ()=>({texts:e,locale:t}),[e,t]);return _jsxruntime.jsx.call(void 0, Pt.Provider,{value:a,children:n})}function qr(){return _react3.useContext.call(void 0, Pt)}function Wl(e){let{texts:t,locale:n}=_react3.useContext.call(void 0, Pt);return _chunk7RXW6XFYjs.c.call(void 0, e,_nullishCoalesce(n, () => (_chunk7RXW6XFYjs.f.call(void 0, ))),t)}function Vl(){let{texts:e,locale:t}=_react3.useContext.call(void 0, Pt),n=_nullishCoalesce(t, () => (_chunk7RXW6XFYjs.f.call(void 0, )));return _react3.useMemo.call(void 0, ()=>a=>_chunk7RXW6XFYjs.c.call(void 0, a,n,e),[n,e])}var en="bitsnap-pending-order";function Hr(e,t){let n=new Map;for(let r of t)n.set(r.id,(_nullishCoalesce(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 ci=60*1e3;function Gr(e,t=Date.now,n=ci){let a;return r=>{let o=`${r.orderId}:${r.ts}`,i=t();return _optionalChain([a, 'optionalAccess', _110 => _110.key])===o&&i-a.at<n?Promise.reject(new Error("pending order was asked about recently")):(a={key:o,at:i},e(r))}}function li(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 (e7){return}}function ui(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 (e8){return!1}}function mi(e,t=Date.now(),n={}){if(ui(e.url))return;let a=li(e.url),r=_nullishCoalesce(Br(e.orderId), () => (_optionalChain([a, 'optionalAccess', _111 => _111.orderId]))),o=_nullishCoalesce(Br(e.projectId), () => (_optionalChain([a, 'optionalAccess', _112 => _112.projectId])));if(!(r==null||o==null))return{orderId:r,projectId:o,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:_nullishCoalesce(n.lines, () => ([])),ts:t}}function Yl(e,t={}){let n=mi(e,t.now,t);return n!=null&&pi(n,t.storage)}function Br(e){return e!=null&&e.length>0?e:void 0}function bt(){try{return typeof localStorage>"u"?void 0:localStorage}catch (e9){return}}function pi(e,t=bt()){try{return _optionalChain([t, 'optionalAccess', _113 => _113.setItem, 'call', _114 => _114(en,JSON.stringify(e))]),t!=null}catch (e10){return!1}}function $r(e=bt()){try{let t=_optionalChain([e, 'optionalAccess', _115 => _115.getItem, 'call', _116 => _116(en)]);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 _optionalChain([c, 'optionalAccess', _117 => _117.id])=="string"&&typeof c.quantity=="number"):[],ts:i}}}catch (e11){}Xt(e)}function Xt(e=bt()){try{_optionalChain([e, 'optionalAccess', _118 => _118.removeItem, 'call', _119 => _119(en)])}catch (e12){}}function Kr(e){let t=_nullishCoalesce(_optionalChain([e, 'access', _120 => _120.details, 'optionalAccess', _121 => _121.status]), () => (fi(_optionalChain([e, 'access', _122 => _122.details, 'optionalAccess', _123 => _123.$unknown]))));return t==="created"||t==="placed"||t==="paid"||t==="canceled"?t:"unknown"}function fi(e){if(Array.isArray(e)){for(let t of e)if(_optionalChain([t, 'optionalAccess', _124 => _124.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 (e13){return}}}}async function Wr(e){let t=_nullishCoalesce(e.storage, () => (bt())),n=$r(t);if(n==null)return"none";if((_nullishCoalesce(e.now, () => (Date.now)))()-n.ts>864e5)return Xt(t),"expired";if(e.projectId!=null&&n.cartProjectId!=null&&n.cartProjectId!==e.projectId)return"pending";let r;try{r=await e.fetchStatus(n)}catch (e14){return"pending"}let o=$r(t);if(_optionalChain([o, 'optionalAccess', _125 => _125.orderId])!==n.orderId||o.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch (e15){return"pending"}return Xt(t),"paid"}return"pending"}var vi="__m_a",Xr=_react3.createContext.call(void 0, void 0),on= exports.J =void 0;function Cu(e){_chunk4BL7TLK3js.a.call(void 0, {projectID:e}),on= exports.J =e,typeof window<"u"&&_chunk4BL7TLK3js.g.call(void 0, [window.location.origin])}function qe(){return _nullishCoalesce(_nullishCoalesce(on, () => (_optionalChain([document, 'access', _126 => _126.querySelector, 'call', _127 => _127('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _128 => _128.getAttribute, 'call', _129 => _129("data-id")]))), () => (void 0))}function ki(){return _nullishCoalesce(_optionalChain([document, 'access', _130 => _130.querySelector, 'call', _131 => _131('script[data-id][data-name="internal-cart"]'), 'optionalAccess', _132 => _132.getAttribute, 'call', _133 => _133("data-custom-host")]), () => (void 0))}var wi=({children:e,locale:t})=>{let[n]=_react3.useState.call(void 0, ()=>new _reactquery.QueryClient),a=qr();_react3.useEffect.call(void 0, ()=>{Fe()},[]);let r=qe();if(_react3.useEffect.call(void 0, ()=>{if(r==null)return;let i=()=>{Ni(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 _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{});let o=sn(r,_nullishCoalesce(t, () => (a.locale)),a.texts);return _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider,{client:n,children:_jsxruntime.jsx.call(void 0, Xr.Provider,{value:o,children:e})})},tn,xi=Gr(async e=>Kr(await de.get(_chunkESF5ZVVFjs.e).getOrder({id:e.orderId,projectId:e.projectId})));function Nu(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}=_nullishCoalesce(R(), () => (kt));return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}}function Iu(){return(_nullishCoalesce(_optionalChain([R, 'call', _134 => _134(), 'optionalAccess', _135 => _135.products]), () => ([]))).map(e=>({id:e.id,quantity:e.quantity}))}function Ci(e){let t=R();V({...t,products:Hr(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _136 => _136.products]), () => ([])),e)}),Fe()}function Ni(e){return tn??=Wr({projectId:e,fetchStatus:xi,removeLines:Ci}).catch(t=>{console.warn("cannot check the pending order",t)}).finally(()=>{tn=void 0}),tn}var ze=async(e,t)=>{let n=[];_optionalChain([t, 'optionalAccess', _137 => _137.items])!=null&&t.items.length>0?n=t.items:n=_nullishCoalesce(_optionalChain([R, 'call', _138 => _138(), 'optionalAccess', _139 => _139.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",_nullishCoalesce(_optionalChain([t, 'optionalAccess', _140 => _140.locale]), () => (_chunk7RXW6XFYjs.f.call(void 0, ))));let o;try{let i=await fetch(_chunkESF5ZVVFjs.c.call(void 0, _e(e,`/products?${r.toString()}`)),{method:"GET"});if(i.status!=200)return F("products-load-failed","internal");o=await i.json()}catch(i){return console.warn("cannot load the products of the cart",i),F("products-load-failed","internal")}return n.flatMap(i=>{let d=_r(i.productID,o.result);return d==null?[]:[{...i,details:Li(i.productID,d),catalogProductID:d.id}]})},Su= exports.P =()=>{let e=_react3.useContext.call(void 0, Xr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Ru= exports.Q =wi,Ii=_zod2.default.object({isAvailable:_zod2.default.boolean(),merchantId:_zod2.default.string(),merchantName:_zod2.default.string(),gateway:_zod2.default.string(),gatewayId:_zod2.default.string()}),Si=_zod2.default.object({id:_zod2.default.string(),productID:_zod2.default.string(),quantity:_zod2.default.number(),priceVersion:_zod2.default.string().optional(),metadata:_zod2.default.record(_zod2.default.string(),_zod2.default.string().optional()).optional(),url:_zod2.default.string().optional()}),Ri=_zod2.default.object({country:_zod2.default.string().optional(),couponCode:_zod2.default.string().optional(),selectedDeliveryMethod:_zod2.default.string().optional(),postalCode:_zod2.default.string().optional(),email:_zod2.default.string().optional(),products:_zod2.default.array(Si).optional(),googlePayConfig:Ii.optional()}),kt={country:void 0,couponCode:void 0,email:void 0,selectedDeliveryMethod:void 0,postalCode:void 0,products:[],googlePayConfig:void 0},eo="checkout";function R(){try{let e=localStorage.getItem(eo);return e==null?kt:Ri.parse(JSON.parse(e))}catch (e16){return kt}}async function Jr(e,t){let n=await ze(e,{items:t.map((o,i)=>({...o,id:`price-check-${i}`}))});if(ke(n))return n;let a=jr(t.map(o=>o.productID),n);if(a.length>0)return F("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:_optionalChain([n, 'access', _141 => _141.find, 'call', _142 => _142(i=>i.productID===o.productID), 'optionalAccess', _143 => _143.details, 'optionalAccess', _144 => _144.pricing, 'optionalAccess', _145 => _145.priceVersion]),metadata:o.metadata,url:zr(o.url,typeof window<"u"?window.location.href:void 0)}))),Ti(t,n),Yt({event:"addToCart",currency:"PLN",items:t.map(o=>({id:o.productID,name:_nullishCoalesce(o.name, () => ("")),price:_nullishCoalesce(o.price, () => (0)),quantity:o.quantity,currency:_nullishCoalesce(o.currency, () => ("PLN"))}))}),V(r),Fe()}function Ti(e,t){for(let n of e)try{let a=t.find(d=>d.productID===n.productID),r=_nullishCoalesce(_nullishCoalesce(_optionalChain([a, 'optionalAccess', _146 => _146.details, 'optionalAccess', _147 => _147.pricing, 'optionalAccess', _148 => _148.effectivePrice]), () => (_optionalChain([a, 'optionalAccess', _149 => _149.details, 'optionalAccess', _150 => _150.price]))), () => (n.price)),o=_nullishCoalesce(_optionalChain([a, 'optionalAccess', _151 => _151.details, 'optionalAccess', _152 => _152.currency]), () => (n.currency));if(r==null||o==null)continue;let i=_nullishCoalesce(_optionalChain([a, 'optionalAccess', _153 => _153.catalogProductID]), () => (n.productID));(_nullishCoalesce(n.analytics, () => (_chunkC3BBJOVVjs.o.call(void 0, )))).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 (e17){}}function Zr(e){let t=R(),n={...t,products:_optionalChain([t, 'optionalAccess', _154 => _154.products, 'optionalAccess', _155 => _155.filter, 'call', _156 => _156(a=>!e.includes(a.productID)&&!e.includes(a.id))])};Yt({event:"removeFromCart",items:e.map(a=>({id:a,name:"",price:0,quantity:1,currency:"PLN"}))}),V(n),Fe()}function V(e){localStorage.setItem(eo,JSON.stringify(e))}function Yr(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=_optionalChain([r, 'access', _157 => _157.metadata, 'optionalAccess', _158 => _158[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 sn=(e,t=_chunk7RXW6XFYjs.f.call(void 0, ),n)=>{let a=ki();return a!=null&&_chunkESF5ZVVFjs.f.call(void 0, a),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await de.get(_chunkESF5ZVVFjs.e).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 Ai(e);if(_optionalChain([o, 'optionalAccess', _159 => _159.isAvailable])!=!0)return{isAvailable:!1};let i=R();if(i==null)return console.log("checkout is null"),{isAvailable:!1};let d=await ze(e,{locale:t,items:r.items.map(y=>({id:Math.random().toString(36).substring(7),quantity:y.quantity,metadata:y.metadata,productID:y.productID}))});if(ke(d))return{isAvailable:!1};let c=await de.get(_chunkESF5ZVVFjs.e).getPreOrderDetails({items:d.map(y=>_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.c,{id:y.productID,quantity:y.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(y=>_optionalChain([y, 'access', _160 => _160.details, 'optionalAccess', _161 => _161.isDeliverable])==!0)!=null,p=await Ur({items:d,googlePayConfig:o,checkout:i,cartRequiresShipping:l,result:c,locale:t,texts:n});return p==null?{isAvailable:!1}:{isAvailable:!0,config:p}}catch(o){return console.error("Error resolving Google Pay configuration",o),{isAvailable:!1}}},async clearCart(){let r=structuredClone(kt);r.country=_optionalChain([R, 'call', _162 => _162(), 'optionalAccess', _163 => _163.country]),V(r),Fe()},async getAvailableCountries(){let r=await fetch(_chunkESF5ZVVFjs.c.call(void 0, _e(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return _zod2.default.array(_zod2.default.object({name:_zod2.default.string(),code:_zod2.default.string()})).parse(await r.json())}catch(o){return F(o.toString(),"internal")}},async getCountry(){let r=_optionalChain([R, 'call', _164 => _164(), 'optionalAccess', _165 => _165.country]);if(r==null){r="PL";let o=R();o.country=r,V(o)}return r},async getNumberOfElementsInCart(){return _nullishCoalesce(_optionalChain([R, 'call', _166 => _166(), 'optionalAccess', _167 => _167.products, 'optionalAccess', _168 => _168.reduce, 'call', _169 => _169((r,o)=>r+o.quantity,0)]), () => (0))},async getProducts(){return await ze(e,{locale:t})},async removeProductFromCart(r){return Zr([r.id])},async setCountry(r){let o=R();o.country=r,V(o)},async setCouponCodeIfPossible(r){let o=R();o.couponCode=r,V(o)},async setPostalCode(r){let o=R();o.postalCode=r,V(o)},async setDeliveryMethod(r){let o=R();o.selectedDeliveryMethod=r,V(o)},async setEmail(r){let o=R();o.email=r,V(o)},async addProduct(r){return await Jr(e,[r])},async updateQuantity(r){let o=R();o.products=_optionalChain([o, 'access', _170 => _170.products, 'optionalAccess', _171 => _171.map, 'call', _172 => _172(i=>(i.id===r.id&&(i.quantity=r.quantity),i))]),V(o),Fe()},async getPaymentMethodChoice(){let r=Yr(R(),t);return r==null?null:Qr(r)},async redirectToNextStep(r){let o=Yr(R(),t);if(o==null)return F("cart-is-empty","badInput");_optionalChain([r, 'optionalAccess', _173 => _173.paymentMethod])!=null&&(o.paymentMethod=r.paymentMethod);let i=await rn(o);return ke(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:_nullishCoalesce(r.locale, () => (t))};o=an(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:vi,name:"",required:!0,answer:!0}]);let i=await rn(o);return ke(i)?i:{url:i.url}},async getApplePayPreview(r){let o=R();try{let i=await de.get(_chunkESF5ZVVFjs.e).getPreOrderDetails({items:r.items.map(d=>_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.c,{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?F("pre-order-unavailable","internal"):{countryCode:i.country||o.country||"PL",currencyCode:i.currency,totalAmount:`${U(i.totalAmount/100,2)}`}}catch(i){return console.warn("cannot load the Apple Pay preview",i),F("pre-order-unavailable","internal")}},async completeApplePayPayment(r){let o=R();if(o==null)return F("Checkout not found");let i=await ze(e,{locale:t});if(ke(i))return i;try{let d=_optionalChain([r, 'access', _174 => _174.shippingContact, 'optionalAccess', _175 => _175.givenName]);_optionalChain([r, 'access', _176 => _176.shippingContact, 'optionalAccess', _177 => _177.familyName])!=null?d+=" "+_optionalChain([r, 'access', _178 => _178.shippingContact, 'optionalAccess', _179 => _179.familyName]):_optionalChain([r, 'access', _180 => _180.billingContact, 'optionalAccess', _181 => _181.familyName])!=null&&(d+=" "+_optionalChain([r, 'access', _182 => _182.billingContact, 'optionalAccess', _183 => _183.familyName]));let c={},l=vt();l!=null&&(c.ref=l);let p=await de.get(_chunkESF5ZVVFjs.e).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.d,{items:i.map(y=>({id:y.productID,quantity:y.quantity})),couponCode:o.couponCode,email:_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _184 => _184.shippingContact, 'optionalAccess', _185 => _185.emailAddress]), () => (_optionalChain([r, 'access', _186 => _186.billingContact, 'optionalAccess', _187 => _187.emailAddress]))), () => (o.email)), () => (void 0)),phone:_nullishCoalesce(_nullishCoalesce(_optionalChain([r, 'access', _188 => _188.shippingContact, 'optionalAccess', _189 => _189.phoneNumber]), () => (_optionalChain([r, 'access', _190 => _190.billingContact, 'optionalAccess', _191 => _191.phoneNumber]))), () => (void 0)),selectedDeliveryMethod:o.selectedDeliveryMethod,postCode:o.postalCode,projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _192 => _192.shippingContact, 'optionalAccess', _193 => _193.addressLines, 'optionalAccess', _194 => _194[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _195 => _195.shippingContact, 'optionalAccess', _196 => _196.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _197 => _197.shippingContact, 'optionalAccess', _198 => _198.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _199 => _199.shippingContact, 'optionalAccess', _200 => _200.postalCode]), () => ("")),name:d}),billingAddress:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.b,{name:_nullishCoalesce(_optionalChain([r, 'access', _201 => _201.billingContact, 'optionalAccess', _202 => _202.givenName]), () => (" "+(_nullishCoalesce(_optionalChain([r, 'access', _203 => _203.billingContact, 'optionalAccess', _204 => _204.familyName]), () => (""))))),line1:_nullishCoalesce(_optionalChain([r, 'access', _205 => _205.billingContact, 'optionalAccess', _206 => _206.addressLines, 'optionalAccess', _207 => _207[0]]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _208 => _208.billingContact, 'optionalAccess', _209 => _209.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _210 => _210.billingContact, 'optionalAccess', _211 => _211.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _212 => _212.billingContact, 'optionalAccess', _213 => _213.postalCode]), () => (""))}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:p.isSuccess,redirectURL:p.redirectUrl}}catch(d){return console.error(d),F("Failed to authorize payment")}},async completeGooglePayPayment(r){let o=R();if(o==null)return F("Checkout not found");let i=await ze(e,{locale:t});if(ke(i))return i;try{let d=_optionalChain([r, 'access', _214 => _214.paymentData, 'access', _215 => _215.shippingAddress, 'optionalAccess', _216 => _216.name]),c={},l=vt();l!=null&&(c.ref=l);let p=await de.get(_chunkESF5ZVVFjs.e).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.d,{items:i.map(y=>({id:y.productID,quantity:y.quantity})),couponCode:o.couponCode,email:_nullishCoalesce(r.paymentData.email, () => (void 0)),phone:_nullishCoalesce(_optionalChain([r, 'access', _217 => _217.paymentData, 'access', _218 => _218.shippingAddress, 'optionalAccess', _219 => _219.phoneNumber]), () => (void 0)),selectedDeliveryMethod:_nullishCoalesce(_optionalChain([r, 'access', _220 => _220.paymentData, 'access', _221 => _221.shippingOptionData, 'optionalAccess', _222 => _222.id]), () => (o.selectedDeliveryMethod)),postCode:_optionalChain([r, 'access', _223 => _223.paymentData, 'access', _224 => _224.shippingAddress, 'optionalAccess', _225 => _225.postalCode]),projectId:e}),shippingAddress:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.a,{line1:_nullishCoalesce(_optionalChain([r, 'access', _226 => _226.paymentData, 'access', _227 => _227.shippingAddress, 'optionalAccess', _228 => _228.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _229 => _229.paymentData, 'access', _230 => _230.shippingAddress, 'optionalAccess', _231 => _231.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _232 => _232.paymentData, 'access', _233 => _233.shippingAddress, 'optionalAccess', _234 => _234.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _235 => _235.paymentData, 'access', _236 => _236.shippingAddress, 'optionalAccess', _237 => _237.postalCode]), () => ("")),name:d}),billingAddress:_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.b,{name:_optionalChain([r, 'access', _238 => _238.paymentData, 'access', _239 => _239.paymentMethodData, 'access', _240 => _240.info, 'optionalAccess', _241 => _241.billingAddress, 'optionalAccess', _242 => _242.name]),line1:_nullishCoalesce(_optionalChain([r, 'access', _243 => _243.paymentData, 'access', _244 => _244.paymentMethodData, 'access', _245 => _245.info, 'optionalAccess', _246 => _246.billingAddress, 'optionalAccess', _247 => _247.address1]), () => ("")),city:_nullishCoalesce(_optionalChain([r, 'access', _248 => _248.paymentData, 'access', _249 => _249.paymentMethodData, 'access', _250 => _250.info, 'optionalAccess', _251 => _251.billingAddress, 'optionalAccess', _252 => _252.locality]), () => ("")),country:_nullishCoalesce(_optionalChain([r, 'access', _253 => _253.paymentData, 'access', _254 => _254.paymentMethodData, 'access', _255 => _255.info, 'optionalAccess', _256 => _256.billingAddress, 'optionalAccess', _257 => _257.countryCode]), () => ("")),zipCode:_nullishCoalesce(_optionalChain([r, 'access', _258 => _258.paymentData, 'access', _259 => _259.paymentMethodData, 'access', _260 => _260.info, 'optionalAccess', _261 => _261.billingAddress, 'optionalAccess', _262 => _262.postalCode]), () => (""))}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess:p.isSuccess,redirectURL:p.redirectUrl}}catch(d){return console.error(d),F("Failed to authorize payment")}return{isSuccess:!0}},async getApplePayPaymentRequest(r){let o=R();if(o==null)return F("Checkout not found");r&&r.expectedItems!=null&&r.expectedItems.length>0&&(o.products&&Zr(o.products.map(l=>l.productID)),await Jr(e,r.expectedItems));let i=await ze(e,{locale:t});if(ke(i))return i;let d=await de.get(_chunkESF5ZVVFjs.e).getPreOrderDetails({items:i.map(l=>_protobuf.create.call(void 0, _chunkSYN5KU3Ojs.c,{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:`${U(l.quantity*(_nullishCoalesce(_nullishCoalesce(_optionalChain([l, 'access', _263 => _263.details, 'optionalAccess', _264 => _264.pricing, 'optionalAccess', _265 => _265.effectivePrice]), () => (_optionalChain([l, 'access', _266 => _266.details, 'optionalAccess', _267 => _267.price]))), () => (0)))/100,2)}`,label:_optionalChain([l, 'access', _268 => _268.details, 'optionalAccess', _269 => _269.name])+" - "+l.quantity,type:"final"}));if(d.selectedDeliveryMethod!=null){let l=d.methods.find(p=>p.id==d.selectedDeliveryMethod);l!=null&&c.push({amount:`${U(l.amount/100,2)}`,label:l.name,type:"final"})}return d.couponCode!=null&&d.couponValue!=null&&c.push({amount:`-${U(d.couponValue/100,2)}`,label:d.couponCode,type:"final"}),{countryCode:d.country||o.country||"PL",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["visa","masterCard"],total:{amount:`${U((_nullishCoalesce(d.totalAmount, () => (0)))/100,2)}`,label:_chunk7RXW6XFYjs.c.call(void 0, "paymentForCart",t,n),type:"final"},shippingMethods:d.methods.map(l=>({amount:`${U(l.amount/100,2)}`,detail:_nullishCoalesce(l.description, () => ("")),identifier:l.id,label:l.name,dateComponentsRange:{startDateComponents:{days:_nullishCoalesce(l.minDays, () => (1)),hours:0,months:0,years:0},endDateComponents:{days:_nullishCoalesce(l.maxDays, () => (14)),hours:0,months:0,years:0}}})),lineItems:c,currencyCode:d.currency||_optionalChain([i, 'access', _270 => _270[0], 'optionalAccess', _271 => _271.details, 'optionalAccess', _272 => _272.currency])||"PLN"}}}};async function Ai(e){let t=R();if(_optionalChain([t, 'access', _273 => _273.googlePayConfig, 'optionalAccess', _274 => _274.isAvailable])!=!0){let n=await de.get(_chunkESF5ZVVFjs.e).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 V(t),t.googlePayConfig}function Li(e,t){if(e==t.id){let a=_optionalChain([t, 'access', _275 => _275.variants, 'optionalAccess', _276 => _276.findIndex, 'call', _277 => _277(r=>r.id===e)]);if(a!=null&&a!=-1){let r=t.variants[a];return{...t,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:_nullishCoalesce(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=_optionalChain([t, 'access', _278 => _278.variants, 'optionalAccess', _279 => _279.find, 'call', _280 => _280(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:_nullishCoalesce(n.images, () => (t.images))}}function Fe(){let e=R(),t=0;if(e==null){je.setState(n=>({...n,numberOfProductsInCart:t}));return}t=_nullishCoalesce(_optionalChain([e, 'access', _281 => _281.products, 'optionalAccess', _282 => _282.reduce, 'call', _283 => _283((n,a)=>n+a.quantity,0)]), () => (0)),je.setState(n=>({...n,numberOfProductsInCart:t}))}var Ei=200,Mi= exports.s ="item-ids-not-found",et="internal-error",to={"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"},Oi=new Set(["internal","invalid-request"]),Ui=new Set(["product-not-available","product-not-found"]);function _i(e){return typeof e=="string"&&Object.hasOwn(to,e)?to[e]:void 0}function ji(e){return/<\/?[a-z!?][^>]*>/i.test(e)}function zi(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 Fi(e){return/Error:/.test(e)||/\n\s+at /.test(e)}function dn(e){let t=e.trim();if(!(t.length===0||t.length>Ei||/[\r\n]/.test(t)||ji(t)||zi(t)||Fi(t)))return t}var qi=3;function wt(e,t=0){if(typeof e=="object"&&e!=null){if(Array.isArray(e)||t>=qi)return{};let n=e,a=wt(n.error,t+1);if(a.message==null&&n.message!=null){let r=wt(n.message,t+1);a={...r,code:_nullishCoalesce(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?wt(n,t+1):{}}catch (e18){}return{message:dn(e)}}function Bi(e){let t;try{t=JSON.parse(e)}catch (e19){return{code:et,message:dn(e)}}if(typeof t=="string")return{code:et,message:dn(t)};if(typeof t!="object"||t==null)return{code:et};let n=t,{message:a,code:r}=wt(n.error),o={code:typeof n.code=="string"&&n.code.length>0?n.code:_nullishCoalesce(r, () => (et)),message:a};return Array.isArray(n.itemIds)&&(o.itemIds=n.itemIds.filter(i=>typeof i=="string")),o}function cn(e,t){let{code:n,message:a,itemIds:r}=Bi(t),o=r!=null&&r.length>0;if(o&&(n===et||Ui.has(n)))return F(Mi,"badInput",r);let i={message:a};return o&&(i.itemIds=r),F(n,e>=500?"internal":"badInput",i)}function Eu(e,t){let n=_i(e.error);if(n!=null)return t(n);if(e.type==="internal"||typeof e.error=="string"&&Oi.has(e.error))return t("checkoutFailed");let a=_optionalChain([e, 'access', _284 => _284.data, 'optionalAccess', _285 => _285.message]);return typeof a=="string"&&a.length>0?a:t("checkoutFailed")}var $i=["online","manual","cod"],Hi=["bankTransfer","blik"];function no(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 Gi(e){if(typeof e!="object"||e==null)return null;let t=e.choice;if(typeof t!="object"||t==null)return null;let n=no(t.methods,$i);return n.length<2?null:{methods:n,manualAccountTypes:no(t.manualAccountTypes,Hi)}}function Ou(e){if(e==null)return null;let t=e.methods.filter(n=>n!=="cod");return t.length<2?null:{...e,methods:t}}function Uu(e,t){return t!=null&&e.methods.includes(t)?t:e.methods[0]}function _u(e){let t=e.includes("bankTransfer"),n=e.includes("blik");return n&&!t?"paymentMethodManualBlik":t&&!n?"paymentMethodManualTransfer":"paymentMethodManualBoth"}async function ro(e,t,n=5e3){let a=typeof AbortController>"u"?void 0:new AbortController,r=setTimeout(()=>_optionalChain([a, 'optionalAccess', _286 => _286.abort, 'call', _287 => _287()]),n);try{let o=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:_optionalChain([a, 'optionalAccess', _288 => _288.signal])});return o.ok?Gi(await o.json()):null}catch (e20){return null}finally{clearTimeout(r)}}var Ki;(a=>{async function e(r,o=1,i,d){let c=qe();if(c==null)throw new Error("No project ID found");let p=await sn(c).addProduct({productID:r,quantity:o,metadata:i,...d});if(p!=null)return p}a.addProductToCart=e;function t(){je.setState({isCartVisible:!0})}a.showCart=t;function n(){je.setState({isCartVisible:!1})}a.hideCart=n})(Ki = exports.y||={});async function oo(e){try{return await e.text()}catch (e21){return""}}function ao(e,t){return t=an(t),t.locale??=_chunk7RXW6XFYjs.f.call(void 0, ),{headers:{..._chunkESF5ZVVFjs.a,..._chunkC3BBJOVVjs.h.call(void 0, e),"Content-Type":"application/json"},body:JSON.stringify(t)}}async function Qr(e){let t=qe();return t==null?null:ro(_e(t,"/payment-methods"),ao(t,e))}async function rn(e){let t=qe();if(t==null)throw new Error("No project ID found");let n=await fetch(_e(t,"/buy"),{method:"POST",...ao(t,e)});if(n.status!=200){let r=cn(n.status,await oo(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 Wu(e){let t=qe();if(t==null)throw new Error("No project ID found");let n={..._chunkESF5ZVVFjs.a,..._chunkC3BBJOVVjs.h.call(void 0, 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??=_chunk7RXW6XFYjs.f.call(void 0, );let r=await fetch(_chunkESF5ZVVFjs.e+a,{method:"POST",headers:n,body:JSON.stringify(e)});return r.ok?{status:"ok",redirectURL:(await r.json()).url}:{...cn(r.status,await oo(r)),status:"error"}}function vt(){if(typeof localStorage>"u")return;let e=localStorage.getItem("bitsnap-ref");if(e!=null)return e}function an(e){let t=vt();return t==null||(e.metadata==null&&(e.metadata={}),e.metadata.ref=t),e}exports.a = de; exports.b = ye; exports.c = xe; exports.d = Ce; exports.e = he; exports.f = Fn; exports.g = Je; exports.h = Ze; exports.i = Le; exports.j = De; exports.k = Io; exports.l = Jn; exports.m = Zt; exports.n = Ya; exports.o = U; exports.p = Or; exports.q = Yt; exports.r = ke; exports.s = Mi; exports.t = Eu; exports.u = Ou; exports.v = Uu; exports.w = _u; exports.x = je; exports.y = Ki; exports.z = Qr; exports.A = rn; exports.B = Wu; exports.C = vt; exports.D = an; exports.E = Kl; exports.F = Wl; exports.G = Vl; exports.H = Yl; exports.I = vi; exports.J = on; exports.K = Cu; exports.L = qe; exports.M = Nu; exports.N = Iu; exports.O = Ni; exports.P = Su; exports.Q = Ru; exports.R = sn;
|
|
4
|
+
//# sourceMappingURL=chunk-555KFWGY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-555KFWGY.js","../src/panel/components/PanelLogin.tsx","../src/ui/card.tsx","../src/ui/email-code-login/EmailCodeLoginForm.tsx","../src/lib/render.text.tsx","../src/panel/audio-player/AudioPlayer.tsx"],"names":["Card","className","props","jsx","cn","CardHeader","CardTitle","CardDescription","CardContent","MUTED","DARK_FIELD","EMAIL_FAILURES","LINK","EmailCodeLoginForm","login","texts","allowHaveCode","emailPlaceholder","emailInputId","codeInputId","buttonClassName","children","uid","useId","emailId"],"mappings":"AAAA,ylCAAwM,sDAAiG,sDAAsJ,sDAA+E,sDAAyE,sDAAwD,oDCAhnB,0EACwB,+CCKnD,SAFKA,EAAAA,CAAK,CAAE,SAAA,CAAAC,CAAAA,CAAW,GAAGC,CAAM,CAAA,CAAgC,CAClE,OACEC,6BAAAA,KAAC,CAAA,CACC,WAAA,CAAU,MAAA,CACV,SAAA,CAAWC,gCAAAA,mFACT,CACAH,CACF,CAAA,CACC,GAAGC,CAAAA,CACN,CAEJ,CAEA,SAASG,EAAAA,CAAW,CAAE,SAAA,CAAAJ,CAAAA,CAAW,GAAGC,CAAM,CAAA,CAAgC,CACxE,OACEC,6BAAAA,KAAC,CAAA,CACC,WAAA,CAAU,aAAA,CACV,SAAA,CAAWC,gCAAAA,0JACT,CACAH,CACF,CAAA,CACC,GAAGC,CAAAA,CACN,CAEJ,CAEA,SAASI,EAAAA,CAAU,CAAE,SAAA,CAAAL,CAAAA,CAAW,GAAGC,CAAM,CAAA,CAAgC,CACvE,OACEC,6BAAAA,KAAC,CAAA,CACC,WAAA,CAAU,YAAA,CACV,SAAA,CAAWC,gCAAAA,4BAAG,CAA8BH,CAAS,CAAA,CACpD,GAAGC,CAAAA,CACN,CAEJ,CAEA,SAASK,EAAAA,CAAgB,CAAE,SAAA,CAAAN,CAAAA,CAAW,GAAGC,CAAM,CAAA,CAAgC,CAC7E,OACEC,6BAAAA,KAAC,CAAA,CACC,WAAA,CAAU,kBAAA,CACV,SAAA,CAAWC,gCAAAA,+BAAG,CAAiCH,CAAS,CAAA,CACvD,GAAGC,CAAAA,CACN,CAEJ,CAeA,SAASM,EAAAA,CAAY,CAAE,SAAA,CAAAP,CAAAA,CAAW,GAAGC,CAAM,CAAA,CAAgC,CACzE,OACEC,6BAAAA,KAAC,CAAA,CACC,WAAA,CAAU,cAAA,CACV,SAAA,CAAWC,gCAAAA,MAAG,CAAQH,CAAS,CAAA,CAC9B,GAAGC,CAAAA,CACN,CAEJ,CCvEA,2CAA4B,IA6BtBO,EAAAA,CAAQ,yCAAA,CAERC,EAAAA,CACJ,0MAAA,CAEIC,EAAAA,CAAiB,IAAI,GAAA,CAAI,CAAC,cAAA,CAAgB,eAAA,CAAiB,qBAAqB,CAAC,CAAA,CACjFC,EAAAA,CACJ,sNAAA,CAOK,SAASC,EAAAA,CAAmB,CACjC,KAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,CAAAA,CACA,aAAA,CAAAC,CAAAA,CAAgB,CAAA,CAAA,CAChB,gBAAA,CAAAC,CAAAA,CACA,YAAA,CAAAC,CAAAA,CACA,WAAA,CAAAC,CAAAA,CACA,SAAA,CAAAlB,CAAAA,CACA,eAAA,CAAAmB,CAAAA,CACA,QAAA,CAAAC,CACF,CAAA,CAA4B,CAC1B,IAAMC,CAAAA,CAAMC,2BAAAA,CAAM,CACZC,CAAAA,kBAAUN,CAAAA,SAAgB,CAAA,EAAA;ACGlB,QAAA;AC2FG,YAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-555KFWGY.js","sourcesContent":[null,"import { useAutoAnimate } from \"@formkit/auto-animate/react\";\nimport { useEffect, useMemo, type CSSProperties } from \"react\";\nimport {\n InstrumentProvider,\n useInstrument,\n useInstrumentContext,\n type AnalyticsOption,\n} from \"../../analytics/instrument\";\nimport { getLocale } from \"../../components/checkout/locale\";\nimport { rpcProvider, useMutation } from \"../../rpc-provider\";\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from \"../../ui/card\";\nimport { kindFromRpcError } from \"../../ui/email-code-login/errors\";\nimport {\n LoginBrandLogo,\n type LoginLogoOptions,\n} from \"../../ui/email-code-login/LoginBrandLogo\";\nimport { EmailCodeLoginForm } from \"../../ui/email-code-login/EmailCodeLoginForm\";\nimport { pendingLoginKey } from \"../../ui/email-code-login/pending\";\nimport {\n useEmailCodeLogin,\n type EmailCodeAdapter,\n} from \"../../ui/email-code-login/useEmailCodeLogin\";\nimport {\n getAllowedReturnOrigins,\n setAllowedReturnOrigins,\n} from \"../config\";\nimport { panelFailureKind } from \"../login-adapter\";\nimport { resolvePanelLoginTexts, type PanelLoginTexts } from \"../login-texts\";\nimport { usePanelConfig } from \"../PanelProvider\";\nimport type { PanelLoginProps } from \"../types\";\nimport {\n buildAccessTokenRedirect,\n getReturnURLFromSearch,\n persistReturnURL,\n readPersistedReturnURL,\n} from \"../return-url\";\nimport { getPanelSession, savePanelSession } from \"../session-storage\";\n\nif (typeof window !== \"undefined\") {\n const currentOrigin = window.location.origin;\n const knownSiblings = [\n currentOrigin,\n \"https://bitsnap.pl\",\n \"https://kursy.bitsnap.pl\",\n ];\n if (getAllowedReturnOrigins().length === 0) {\n setAllowedReturnOrigins(Array.from(new Set(knownSiblings)));\n }\n}\n\n\n/** Props of {@link PanelLogin}; `PanelLoginProps` of the package is a superset. */\nexport type PanelLoginComponentProps = Pick<\n PanelLoginProps,\n \"analytics\" | \"texts\" | \"locale\" | \"showLogo\" | \"logoUrl\" | \"logoDarkUrl\"\n>;\n\ntype PanelLoginResult = { accessToken: string };\n\nconst PanelLoginForm = ({\n texts,\n projectID,\n host,\n locale,\n logo,\n}: {\n texts: PanelLoginTexts;\n projectID?: string;\n host?: string;\n locale?: string;\n logo: LoginLogoOptions;\n}) => {\n const instrument = useInstrumentContext();\n const { mutateAsync: loginUserAsync } = useMutation(\n rpcProvider.publicApi.userPanelLogin,\n );\n const { mutateAsync: verifyCodeAsync } = useMutation(\n rpcProvider.publicApi.userPanelLoginWithCode,\n );\n\n const adapter = useMemo<EmailCodeAdapter<PanelLoginResult>>(\n () => ({\n async send(email) {\n try {\n const response = await loginUserAsync({ email });\n if (response.result.case === \"success\") {\n return {\n ok: true,\n retryIn: response.result.value.retryIn || undefined,\n challengeId: response.result.value.challengeId || undefined,\n };\n }\n return {\n ok: false,\n kind: panelFailureKind(\n response.result.case === \"failure\" ? response.result.value : 0,\n ),\n };\n } catch (cause) {\n return { ok: false, kind: kindFromRpcError(cause), cause };\n }\n },\n async verify({ email, code, challengeId }) {\n try {\n const response = await verifyCodeAsync({\n code: parseInt(code, 10),\n email,\n challengeId,\n });\n if (response.result.case === \"accessToken\" && response.result.value) {\n return { ok: true, value: { accessToken: response.result.value } };\n }\n return {\n ok: false,\n kind: panelFailureKind(\n response.result.case === \"failure\" ? response.result.value : 0,\n ),\n };\n } catch (cause) {\n return { ok: false, kind: kindFromRpcError(cause), cause };\n }\n },\n }),\n [loginUserAsync, verifyCodeAsync],\n );\n\n const login = useEmailCodeLogin<PanelLoginResult>({\n adapter,\n texts,\n storageKey: pendingLoginKey(\"panel\", projectID, host),\n onVerified: ({ accessToken }, email) => {\n instrument.track(\"panel_login\", {});\n savePanelSession(projectID, accessToken, email, host);\n const returnURL =\n typeof window !== \"undefined\" ? readPersistedReturnURL() : null;\n setTimeout(() => {\n if (returnURL) {\n window.location.href = buildAccessTokenRedirect(returnURL, accessToken);\n return;\n }\n window.location.reload();\n }, 100);\n },\n });\n\n const onCodeStep = login.step === \"code\";\n const title = onCodeStep && !login.needsEmail ? texts.codeTitle : texts.title;\n const description =\n onCodeStep && !login.needsEmail ? texts.codeDescription : texts.description;\n\n return (\n // Top-aligned: a vertically centred card moved when the step changed height.\n <main className=\"mx-auto flex w-full max-w-sm flex-1 flex-col justify-start pt-4 sm:pt-[12vh]\">\n <Card>\n <LoginBrandLogo\n projectId={projectID}\n locale={locale}\n className=\"px-4 sm:px-6\"\n {...logo}\n />\n <CardHeader className=\"px-4 sm:px-6\">\n <CardTitle role=\"heading\" aria-level={1} className=\"text-2xl\">\n {title}\n </CardTitle>\n <CardDescription>{description}</CardDescription>\n </CardHeader>\n <CardContent className=\"px-4 sm:px-6\">\n <EmailCodeLoginForm\n login={login}\n texts={texts}\n emailInputId=\"email\"\n codeInputId=\"verify-code\"\n />\n </CardContent>\n </Card>\n </main>\n );\n};\n\nconst PanelLoginComponentWrapper = ({\n analytics,\n texts: textOverrides,\n locale,\n showLogo,\n logoUrl,\n logoDarkUrl,\n}: PanelLoginComponentProps) => {\n const { theme, allowedReturnOrigins, projectID, host } = usePanelConfig();\n const instrument = useInstrument(projectID, analytics, \"panel\");\n const texts = useMemo(\n () => resolvePanelLoginTexts(locale ?? getLocale(), textOverrides),\n [locale, textOverrides],\n );\n\n const styles = {\n \"--button-background-color\": theme?.colors?.brand ?? \"#FFFFFF\",\n \"--button-background-color-dark\": theme?.colors?.brandDark ?? \"#000000\",\n \"--button-text-color\": theme?.colors?.brandDark ?? \"#000000\",\n \"--button-text-color-dark\": theme?.colors?.brand ?? \"#FFFFFF\",\n } as CSSProperties;\n\n const [parent] = useAutoAnimate({\n duration: 300,\n easing: \"ease-in-out\",\n disrespectUserMotionPreference: false,\n });\n\n // Already signed in: leave the login page. Declared before the return URL\n // effect below, so that one (a token redirect) wins when both apply.\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n if (getPanelSession(projectID, host) != null) {\n window.location.href = window.location.href.replaceAll(\"login\", \"\");\n }\n }, [projectID, host]);\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n if (window.parent !== window) return;\n\n const queryReturnURL = getReturnURLFromSearch(window.location.search);\n if (queryReturnURL) {\n persistReturnURL(queryReturnURL);\n }\n\n const returnURL = queryReturnURL ?? readPersistedReturnURL();\n if (!returnURL) return;\n\n const existingToken = getPanelSession(projectID, host);\n if (!existingToken) return;\n\n window.location.href = buildAccessTokenRedirect(returnURL, existingToken);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [allowedReturnOrigins, projectID, host]);\n\n return (\n <InstrumentProvider value={instrument}>\n <div className=\"bg-white text-black dark:bg-black dark:text-white\">\n <div\n className=\"font-inter flex min-h-screen w-full flex-col p-4\"\n style={styles}\n ref={parent}\n >\n <PanelLoginForm\n texts={texts}\n projectID={projectID}\n host={host}\n locale={locale}\n logo={{\n showLogo,\n logoUrl: logoUrl ?? theme?.logoURL,\n logoDarkUrl: logoDarkUrl ?? theme?.logoDarkURL,\n }}\n />\n </div>\n </div>\n </InstrumentProvider>\n );\n};\n\nexport const PanelLogin = (props: PanelLoginComponentProps = {}) => {\n return <PanelLoginComponentWrapper {...props} />;\n};\n","import * as React from \"react\"\n\nimport { cn } from \"@/src/lib/utils\"\n\nfunction Card({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card\"\n className={cn(\n \"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CardHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-header\"\n className={cn(\n \"@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\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CardTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-title\"\n className={cn(\"leading-none font-semibold\", className)}\n {...props}\n />\n )\n}\n\nfunction CardDescription({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-description\"\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...props}\n />\n )\n}\n\nfunction CardAction({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-action\"\n className={cn(\n \"col-start-2 row-span-2 row-start-1 self-start justify-self-end\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction CardContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-content\"\n className={cn(\"px-6\", className)}\n {...props}\n />\n )\n}\n\nfunction CardFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"card-footer\"\n className={cn(\"flex items-center px-6 [.border-t]:pt-6\", className)}\n {...props}\n />\n )\n}\n\nexport {\n Card,\n CardHeader,\n CardFooter,\n CardTitle,\n CardAction,\n CardDescription,\n CardContent,\n}\n","import { CircleCheck } from \"lucide-react\";\nimport { useId, type FormEvent, type ReactNode } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport { Button } from \"../button\";\nimport { Input } from \"../input\";\nimport { Label } from \"../label\";\nimport { Spinner } from \"../spinner\";\nimport { OtpCodeField } from \"./OtpCodeField\";\nimport { fillText, type EmailCodeTexts } from \"./texts\";\nimport { type EmailCodeLogin } from \"./useEmailCodeLogin\";\n\nexport type EmailCodeLoginFormProps = {\n login: EmailCodeLogin;\n texts: EmailCodeTexts;\n /** Offers \"I already have a code\" under the e-mail step. */\n allowHaveCode?: boolean;\n /** Overrides the e-mail input placeholder. */\n emailPlaceholder?: string;\n /** `id` of the e-mail input; unique per instance by default. */\n emailInputId?: string;\n /** `id` of the code input; unique per instance by default. */\n codeInputId?: string;\n className?: string;\n /** Classes of the two primary buttons (brand colors). */\n buttonClassName?: string;\n /** Shown above the fields of the code step, after the \"sent to\" line. */\n children?: ReactNode;\n};\n\nconst MUTED = \"text-muted-foreground text-xs leading-5\";\n/** Borders of the dark theme: the `input` token is nearly the card colour. */\nconst DARK_FIELD =\n \"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\";\n/** Failures about the address itself; a throttled or failed send is not. */\nconst EMAIL_FAILURES = new Set([\"invalidEmail\", \"emailNotFound\", \"deliveryUnavailable\"]);\nconst LINK =\n \"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\";\n\n/**\n * The two steps of the shared e-mail-code login. Markup only: all state comes\n * from {@link useEmailCodeLogin}. The surface wraps it in its own card or\n * dialog and renders the titles.\n */\nexport function EmailCodeLoginForm({\n login,\n texts,\n allowHaveCode = true,\n emailPlaceholder,\n emailInputId,\n codeInputId,\n className,\n buttonClassName,\n children,\n}: EmailCodeLoginFormProps) {\n const uid = useId();\n const emailId = emailInputId ?? `${uid}-email`;\n const codeId = codeInputId ?? `${uid}-code`;\n const noticeId = `${uid}-notice`;\n const hintId = `${uid}-hint`;\n\n const { notice } = login;\n const isError = notice?.kind === \"error\";\n const sending = login.busy === \"send\";\n const verifying = login.busy === \"verify\";\n const resending = login.busy === \"resend\";\n const buttonBase = cn(\"h-11 w-full\", buttonClassName);\n\n // Both live regions stay mounted (empty) so that a screen reader has\n // registered them before a message is put in; only their text changes.\n // The area reserves two lines, so a longer message does not push the buttons.\n const success = notice?.kind === \"success\";\n const noticeArea = (\n <div id={noticeId} className=\"min-h-10 text-sm leading-5\">\n <p\n role=\"alert\"\n className=\"font-medium text-red-700 dark:text-red-400\"\n >\n {isError ? notice.text : null}\n </p>\n <p\n role=\"status\"\n className={cn(\n \"flex items-start gap-1.5\",\n success\n ? \"font-medium text-emerald-700 dark:text-emerald-400\"\n : \"text-foreground\",\n )}\n >\n {success && <CircleCheck aria-hidden className=\"mt-0.5 size-4 shrink-0\" />}\n <span>{notice != null && !isError ? notice.text : null}</span>\n </p>\n </div>\n );\n const emailInvalid =\n isError &&\n login.step === \"email\" &&\n (notice.failure == null || EMAIL_FAILURES.has(notice.failure));\n\n const announcer = (\n <p className=\"sr-only\" role=\"status\" aria-live=\"polite\">\n {login.announcement}\n </p>\n );\n\n const emailField = (\n <div className=\"grid gap-2\">\n <Label htmlFor={emailId}>{texts.emailLabel}</Label>\n <Input\n id={emailId}\n ref={login.emailRef}\n name=\"email\"\n type=\"email\"\n autoComplete=\"email\"\n inputMode=\"email\"\n autoCapitalize=\"none\"\n autoCorrect=\"off\"\n spellCheck={false}\n autoFocus\n required\n className={cn(\n \"h-11 text-base disabled:opacity-100 disabled:text-foreground/70\",\n DARK_FIELD,\n )}\n placeholder={emailPlaceholder ?? texts.emailPlaceholder}\n value={login.email}\n disabled={login.isBusy}\n aria-invalid={emailInvalid ? true : undefined}\n aria-describedby={noticeId}\n onChange={(event) => login.setEmail(event.target.value)}\n />\n </div>\n );\n\n if (login.step === \"email\") {\n return (\n <form\n noValidate\n className={cn(\"flex flex-col gap-4\", className)}\n onSubmit={(event: FormEvent) => {\n event.preventDefault();\n void login.sendCode();\n }}\n >\n {announcer}\n {emailField}\n {noticeArea}\n <Button\n type=\"submit\"\n disabled={login.isBusy}\n aria-busy={sending}\n className={buttonBase}\n >\n {sending && <Spinner aria-hidden />}\n {sending ? texts.sending : texts.sendCode}\n </Button>\n {allowHaveCode && (\n <p className=\"flex flex-wrap items-center justify-center text-center text-sm\">\n {texts.haveCodePrompt !== \"\" && <span>{texts.haveCodePrompt}</span>}\n <button\n type=\"button\"\n className={LINK}\n disabled={login.isBusy}\n onClick={login.haveCode}\n >\n {texts.haveCode}\n </button>\n </p>\n )}\n </form>\n );\n }\n\n const [before, after] = texts.codeSentTo.split(\"{email}\");\n const dead = login.dead != null;\n const resendLabel = dead\n ? texts.resendNew\n : login.secondsLeft > 0\n ? fillText(texts.resendIn, { seconds: login.secondsLeft })\n : texts.resend;\n\n return (\n <form\n noValidate\n className={cn(\"flex flex-col gap-4\", className)}\n onSubmit={(event: FormEvent) => {\n event.preventDefault();\n void login.submitCode();\n }}\n >\n {announcer}\n {login.needsEmail ? (\n emailField\n ) : (\n <div className=\"flex flex-wrap items-center justify-between gap-x-2\">\n {/* The address moves to its own line before it is cut; the word\n joiner keeps the full stop with it. */}\n <p className=\"min-w-0 flex-[1_1_14rem] text-sm leading-5 break-words\">\n {before}\n <strong className=\"font-semibold\">{login.email}</strong>\n {\"\\u2060\"}\n {after}\n </p>\n <button\n type=\"button\"\n className={cn(LINK, \"-ml-1 shrink-0\")}\n disabled={login.isBusy}\n onClick={login.changeEmail}\n >\n {texts.changeEmail}\n </button>\n </div>\n )}\n {children}\n <div className=\"grid gap-2\">\n <Label htmlFor={codeId}>{texts.codeLabel}</Label>\n <OtpCodeField\n id={codeId}\n name=\"code\"\n inputRef={login.codeRef}\n value={login.code}\n onChange={login.setCode}\n onComplete={(value) => void login.submitCode(value)}\n disabled={login.isBusy || dead}\n invalid={isError && !login.needsEmail}\n aria-describedby={`${noticeId} ${hintId}`}\n />\n <p id={hintId} className={MUTED}>\n {texts.validity} {texts.spamHint}\n </p>\n </div>\n {noticeArea}\n <Button\n type=\"submit\"\n disabled={login.isBusy || dead}\n aria-busy={verifying}\n className={buttonBase}\n >\n {verifying && <Spinner aria-hidden />}\n {verifying ? texts.verifying : texts.verify}\n </Button>\n {login.needsEmail ? (\n <div className=\"flex justify-center\">\n <button\n type=\"button\"\n className={LINK}\n disabled={login.isBusy}\n onClick={login.changeEmail}\n >\n {texts.noCode}\n </button>\n </div>\n ) : (\n <Button\n type=\"button\"\n variant={dead ? \"default\" : \"outline\"}\n disabled={login.isBusy || (!dead && login.secondsLeft > 0)}\n aria-busy={resending}\n className={dead ? buttonBase : \"h-11 w-full\"}\n onClick={() => void login.resend()}\n >\n {resending && <Spinner aria-hidden />}\n {resendLabel}\n </Button>\n )}\n </form>\n );\n}\n","const URL_REGEX =\n /https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)/g;\n\ntype Replacements = {\n url: string;\n startIndex: number;\n endIndex: number;\n replacementText?: string;\n};\n\nconst findURLIndices = (text: string) => {\n const matches = [...text.matchAll(URL_REGEX)];\n return matches.map(\n (match) =>\n ({\n url: match[0],\n startIndex: match.index,\n endIndex: match.index + match[0].length - 1,\n }) as Replacements,\n );\n};\n\nconst replaceTextByIndices = (\n originalText: string,\n replacements: Replacements[],\n) => {\n let result = \"\";\n let lastIndex = 0;\n\n // Sort replacements by startIndex to handle them in order\n replacements.sort((a, b) => a.startIndex - b.startIndex);\n\n for (const { startIndex, endIndex, replacementText } of replacements) {\n // Append text before the current replacement\n result += originalText.slice(lastIndex, startIndex);\n // Append the replacement text\n result += replacementText;\n // Update lastIndex to after the replaced segment\n lastIndex = endIndex + 1;\n }\n\n // Append any remaining text after the last replacement\n result += originalText.slice(lastIndex);\n\n return result;\n};\n\nexport const renderText = (txt: string) => {\n const urlIndices = findURLIndices(txt);\n\n return (\n <p\n dangerouslySetInnerHTML={{\n __html: replaceTextByIndices(\n txt,\n urlIndices.map((el) => {\n el[\"replacementText\"] =\n `<a key=${el.url} href=${el.url} style=\"text-decoration: underline;\" target=\"_blank\">\n ${el.url}\n </a>`;\n return el;\n }),\n ),\n }}\n ></p>\n );\n};\n","import Hls from \"hls.js\";\nimport { Pause, Play } from \"lucide-react\";\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n type CSSProperties,\n} from \"react\";\nimport { Button } from \"../../ui/button\";\nimport LoadingIndicator from \"../LoadingIndicator\";\nimport {\n mediaSessionPause,\n mediaSessionPlay,\n mediaSessionUpdateDurationAndPosition,\n startMediaSessionCoordinator,\n stopMediaSessionCoordinator,\n} from \"./media.session.coordinator\";\n\nimport \"./audio-player.css\";\n\ntype ChapterWithPublicUrl = {\n id: string;\n multimediaId?: string;\n name: string;\n description?: string;\n publicUrl: string;\n downloadableUrl?: string;\n duration?: number;\n};\n\nexport type AudioPlayerMethods = {\n selectChapter: (chapter: ChapterWithPublicUrl) => void;\n};\n\ntype AudioPlayerProps = {\n chapters: ChapterWithPublicUrl[];\n styles: CSSProperties;\n updateCurrentTime?: (currentTime: number) => void;\n\n title?: string;\n imageURL?: string;\n\n setCurrentTimeHandler?: (seekTo: (second: number) => void) => void;\n uniqueProductID: string;\n\n onChapterChange?: (chapter: ChapterWithPublicUrl) => void;\n};\n\nconst AudioPlayer = forwardRef<AudioPlayerMethods, AudioPlayerProps>(\n (\n {\n chapters,\n styles,\n updateCurrentTime,\n setCurrentTimeHandler,\n title,\n imageURL,\n uniqueProductID,\n onChapterChange,\n },\n ref,\n ) => {\n enum PlayState {\n Playing,\n Paused,\n }\n\n const [playState, setPlayState] = useState<PlayState>(PlayState.Paused);\n\n useEffect(() => {\n switch (playState) {\n case PlayState.Playing:\n mediaSessionPlay();\n break;\n case PlayState.Paused:\n mediaSessionPause();\n break;\n }\n }, [playState]);\n\n useImperativeHandle(ref, () => {\n return {\n selectChapter: (chapter: ChapterWithPublicUrl) => {\n playChapter(chapter);\n },\n };\n });\n\n const [currentTime, setCurrentTime] = useState<number | undefined>(\n undefined,\n );\n const [duration, setDuration] = useState<number | undefined>(undefined);\n\n const videoRef = useRef<HTMLVideoElement | null>(null);\n const hlsRef = useRef<Hls | undefined>(undefined);\n const timerRef = useRef<number | undefined>(undefined);\n\n const audioPlayerContainerRef = useRef<HTMLDivElement>(null!);\n\n const currentChapterRef = useRef<ChapterWithPublicUrl | null>(null);\n\n const [playWhenReady, setPlayWhenReady] = useState(true);\n const [isStarted, setIsStarted] = useState(false);\n const [isLoading, setIsLoading] = useState(!isSafari());\n\n function saveLastPlayedTime(timeInSeconds: number) {\n if (timeInSeconds < 10) {\n return;\n }\n localStorage.setItem(\n `__player__${uniqueProductID}_${currentChapterRef.current?.id}`,\n `${timeInSeconds}`,\n );\n }\n\n function getLastPlayedTime(): number | undefined {\n const time = localStorage.getItem(\n `__player__${uniqueProductID}_${currentChapterRef.current?.id}`,\n );\n\n if (time == null) {\n return undefined;\n }\n try {\n const result = parseInt(time);\n\n if (isNaN(result) || result < 0) {\n return undefined;\n }\n\n return result;\n } catch (e) {\n return undefined;\n }\n }\n\n function getLastSelectedChapterID(): string | undefined {\n const lastSelectedChapterID = localStorage.getItem(\n `__player__${uniqueProductID}_last_chapter`,\n );\n if (lastSelectedChapterID == null) {\n return undefined;\n }\n return lastSelectedChapterID;\n }\n\n function setLastSelectedChapterID(chapterID: string) {\n localStorage.setItem(\n `__player__${uniqueProductID}_last_chapter`,\n chapterID,\n );\n }\n\n function deleteMemoryChapter(chapterID: string) {\n localStorage.removeItem(`__player__${uniqueProductID}_${chapterID}`);\n }\n\n function setupObservers() {\n if (videoRef.current == null) {\n return;\n }\n videoRef.current.onloadeddata = () => {\n if (videoRef.current == null) {\n return;\n }\n if (videoRef.current.readyState < 2) {\n setIsLoading(true);\n }\n if (videoRef.current.readyState >= 2) {\n setIsLoading(false);\n }\n\n if (!isStarted) {\n const lastPlayedTime = getLastPlayedTime();\n if (lastPlayedTime != undefined) {\n seekTo(lastPlayedTime);\n }\n setIsStarted(true);\n }\n if (playWhenReady) {\n setPlayWhenReady(false);\n try {\n play();\n } catch (e) {\n console.log(\"play error\", e);\n }\n }\n };\n videoRef.current.onplay = () => {};\n\n videoRef.current.onseeked = () => {};\n videoRef.current.onseeking = () => {};\n\n videoRef.current.onpause = () => {};\n\n videoRef.current.onended = () => {\n playNextChapter();\n };\n\n startMediaSessionCoordinator({\n title: title ?? \"\",\n artwork: imageURL,\n action: (details) => {\n switch (details.action) {\n case \"play\":\n play();\n break;\n case \"pause\":\n pause();\n break;\n case \"seekbackward\":\n seekBy(-15);\n break;\n case \"seekforward\":\n seekBy(15);\n break;\n case \"seekto\":\n if (details.seekTime) {\n seekTo(details.seekTime);\n }\n break;\n case \"stop\":\n pause();\n break;\n default:\n break;\n }\n },\n });\n\n startTimer();\n }\n\n function playNextChapter() {\n if (chapters == null || chapters.length == 0) {\n return;\n }\n const currentChapterIndex = chapters.findIndex(\n (chapter) => chapter.id == currentChapterRef.current?.id,\n );\n if (currentChapterIndex == -1) {\n return;\n }\n deleteMemoryChapter(chapters[currentChapterIndex].id);\n const nextChapterIndex = currentChapterIndex + 1;\n if (nextChapterIndex >= chapters.length) {\n return;\n }\n playChapter(chapters[currentChapterIndex + 1]);\n }\n\n function startTimer() {\n updatePlayerDetails();\n if (timerRef.current != null) return;\n\n timerRef.current = setTimeout(() => {\n updatePlayerDetails();\n timerRef.current = undefined;\n startTimer();\n }, 500) as unknown as number;\n }\n\n function stopTimer() {\n if (timerRef.current == null) return;\n clearTimeout(timerRef.current as unknown as number);\n }\n\n function updatePlayerDetails() {\n if (videoRef.current == null) {\n return;\n }\n setPlayState(\n videoRef.current.paused ? PlayState.Paused : PlayState.Playing,\n );\n setDuration(videoRef.current.duration);\n setCurrentTime(videoRef.current.currentTime);\n saveLastPlayedTime(videoRef.current.currentTime);\n mediaSessionUpdateDurationAndPosition(\n videoRef.current.duration,\n videoRef.current.currentTime,\n );\n if (\n videoRef.current.networkState === videoRef.current.NETWORK_LOADING &&\n videoRef.current.readyState <= videoRef.current.HAVE_FUTURE_DATA\n ) {\n setIsLoading(true);\n } else {\n setIsLoading(false);\n }\n if (updateCurrentTime) {\n updateCurrentTime(videoRef.current.currentTime);\n }\n }\n\n function play() {\n videoRef.current?.play().then().catch();\n updatePlayerDetails();\n }\n\n function pause() {\n videoRef.current?.pause();\n updatePlayerDetails();\n }\n\n function togglePlayState() {\n if (playState === PlayState.Playing) {\n pause();\n return;\n }\n play();\n }\n\n function seekBy(seconds: number) {\n if (videoRef.current == null) {\n return;\n }\n const newTime = videoRef.current.currentTime + seconds;\n if (newTime < 0) {\n videoRef.current.currentTime = 0;\n return;\n }\n if (newTime > videoRef.current.duration) {\n videoRef.current.currentTime = videoRef.current.duration;\n return;\n }\n videoRef.current.currentTime += seconds;\n }\n\n function seekTo(toSecond: number) {\n if (videoRef.current == null) {\n return;\n }\n setCurrentTime(toSecond);\n if (toSecond < 0) {\n videoRef.current.currentTime = 0;\n return;\n }\n if (toSecond > videoRef.current.duration) {\n videoRef.current.currentTime = videoRef.current.duration;\n return;\n }\n videoRef.current.currentTime = toSecond;\n }\n\n function destroyPlayer() {\n if (videoRef.current == null) {\n return;\n }\n videoRef.current.onplay = null;\n videoRef.current.onseeked = null;\n videoRef.current.onseeking = null;\n videoRef.current.onpause = null;\n videoRef.current.onended = null;\n videoRef.current.src = \"\";\n hlsRef.current?.destroy();\n }\n\n function loadChapters(chapters: ChapterWithPublicUrl[]) {\n if (chapters.length == 0) {\n return;\n }\n\n const chapterID = getLastSelectedChapterID();\n if (chapterID == null) {\n playChapter(chapters[0]);\n return;\n }\n\n const chapter = chapters.find((chapter) => chapter.id == chapterID);\n if (chapter == null) {\n playChapter(chapters[0]);\n return;\n }\n\n playChapter(chapter);\n }\n\n function playChapter(chapter: ChapterWithPublicUrl) {\n setIsStarted(false);\n setPlayWhenReady(true);\n currentChapterRef.current = chapter;\n playURL(chapter.publicUrl);\n onChapterChange?.(chapter);\n setLastSelectedChapterID(chapter.id);\n }\n\n function playURL(src: string) {\n if (videoRef.current == null) {\n return;\n }\n if (videoRef.current.canPlayType(\"application/vnd.apple.mpegurl\")) {\n videoRef.current.src = src;\n } else if (Hls.isSupported()) {\n if (hlsRef.current == null) {\n hlsRef.current = new Hls();\n hlsRef.current?.attachMedia(videoRef.current);\n }\n hlsRef.current?.loadSource(src);\n }\n }\n\n useEffect(() => {\n if (videoRef.current == null) {\n return;\n }\n setupObservers();\n loadChapters(chapters);\n }, [videoRef.current]);\n\n useEffect(() => {\n loadChapters(chapters);\n }, [chapters]);\n\n useEffect(() => {\n if (setCurrentTimeHandler != null) {\n setCurrentTimeHandler(seekTo);\n }\n\n return () => {\n setCurrentTime(undefined);\n videoRef.current?.pause();\n destroyPlayer();\n stopMediaSessionCoordinator();\n };\n }, []);\n\n const calculateTime = (secs: number) => {\n const hours = Math.floor(secs / 3600);\n const minutes = Math.floor(secs / 60) % 60;\n const seconds = Math.floor(secs % 60);\n const returnedHours =\n hours > 0 ? (hours < 10 ? `0${hours}:` : `${hours}:`) : \"\";\n const returnedSeconds = seconds < 10 ? `0${seconds}` : `${seconds}`;\n if (isNaN(seconds) || isNaN(minutes) || isNaN(hours)) {\n return \"\";\n }\n return `${returnedHours}${minutes}:${returnedSeconds}`;\n };\n\n const showRangeProgress = (rangeInput: HTMLInputElement) => {\n const barProgress =\n (parseFloat(rangeInput.value) / parseFloat(rangeInput.max)) * 100;\n audioPlayerContainerRef.current.style.setProperty(\n \"--seek-before-width\",\n barProgress + \"%\",\n );\n\n const selectedTime = (duration! * barProgress) / 100;\n seekTo(selectedTime);\n };\n\n return (\n <div\n id=\"audio-player-container\"\n className=\"flex flex-col\"\n style={styles}\n ref={audioPlayerContainerRef}\n >\n <video\n ref={videoRef}\n className=\"hidden\"\n poster={imageURL}\n title={title}\n ></video>\n\n <input\n type=\"range\"\n min=\"0\"\n max={duration != undefined ? Math.floor(duration).toString() : 100}\n value={currentTime ?? 0}\n onChange={(e) => showRangeProgress(e.target as HTMLInputElement)}\n className=\"w-full\"\n />\n\n <section className=\"flex w-full items-center justify-between text-sm font-medium\">\n <span id=\"current-time\">{calculateTime(currentTime!)}</span>\n <span id=\"duration\">{calculateTime(duration!)}</span>\n </section>\n <div className=\"mt-6 flex items-center justify-center gap-x-12\">\n <Button\n variant=\"outline\"\n onClick={() => seekBy(-10)}\n aria-label=\"Rewind 10 Seconds\"\n >\n -10\n </Button>\n <Button\n variant=\"outline\"\n onClick={togglePlayState}\n aria-label=\"Play Or Pause\"\n >\n {playState === PlayState.Paused && <Play className=\"h-5 w-5\" />}\n {playState === PlayState.Playing && <Pause className=\"h-5 w-5\" />}\n </Button>\n <Button\n variant=\"outline\"\n onClick={() => seekBy(10)}\n aria-label=\"Fast Forward 10 Seconds\"\n >\n +10\n </Button>\n </div>\n {isLoading && (\n <div className=\"mt-2 flex w-full justify-center\">\n <LoadingIndicator />\n </div>\n )}\n </div>\n );\n },\n);\n\nfunction isSafari() {\n return navigator.userAgent.toLowerCase().indexOf(\"safari/\") > -1;\n}\n\nexport default AudioPlayer;\n"]}
|