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
package/AGENTS.md
CHANGED
|
@@ -76,6 +76,11 @@ For Astro, omit `"use client"`, and mount with `client:load` or `client:visible`
|
|
|
76
76
|
- For the panel, configure `setProjectID` and `setLoginURL("/panel/login")` on
|
|
77
77
|
the client before mounting `<PanelProvider><Panel /></PanelProvider>`.
|
|
78
78
|
Mount `<PanelProvider><PanelLogin /></PanelProvider>` at that login URL.
|
|
79
|
+
`PanelLogin` takes optional `locale` (`"en"`; Polish by default) and `texts`.
|
|
80
|
+
- The e-mail-code logins (`PanelLogin`, `BitsnapReturns`, notifications) show
|
|
81
|
+
the shop logo from the shop settings above the form (Bitsnap's logo when the
|
|
82
|
+
shop has none). `showLogo={false}` hides it; `logoUrl` / `logoDarkUrl`
|
|
83
|
+
replace it (notifications: `showLoginLogo`, `projectLogo`).
|
|
79
84
|
|
|
80
85
|
## Avoid these mistakes
|
|
81
86
|
|
package/README.md
CHANGED
|
@@ -22,6 +22,49 @@ It uses modern React patterns and libraries like:
|
|
|
22
22
|
- Protocol Buffers for data serialization
|
|
23
23
|
- Tailwind CSS for styling
|
|
24
24
|
|
|
25
|
+
## 1.17.0
|
|
26
|
+
|
|
27
|
+
Changes after 1.16.0, in the e-mail + 6-digit-code logins of `PanelLogin`,
|
|
28
|
+
`BitsnapReturns` and the notifications login dialog.
|
|
29
|
+
|
|
30
|
+
- **Shop logo on every login step.** The logo from the shop settings (light
|
|
31
|
+
and dark variant) shows above the form, as does Bitsnap's logo when the shop
|
|
32
|
+
has none. The height is reserved while it loads, so the form does not jump.
|
|
33
|
+
A variant that does not load is replaced by the other one; Bitsnap's logo
|
|
34
|
+
shows only when none loads. The image's alt text is the shop name, else
|
|
35
|
+
"Logo sklepu" / "Shop logo" by locale.
|
|
36
|
+
- **`PanelLogin`: the logo moved** from the page header (alt "Company Logo",
|
|
37
|
+
`theme.logoURL` / `theme.logoDarkURL`) into the login card, above the title.
|
|
38
|
+
The theme logos are still used, per variant: `logoUrl` replaces only the
|
|
39
|
+
light theme logo and `logoDarkUrl` only the dark one.
|
|
40
|
+
The card is top-aligned instead of vertically centred.
|
|
41
|
+
- **New props.** `PanelLogin` and `BitsnapReturns`: `showLogo` (default
|
|
42
|
+
`true`), `logoUrl` (light background), `logoDarkUrl` (dark background).
|
|
43
|
+
Notifications: `showLoginLogo` (default `true`; `projectLogo`,
|
|
44
|
+
`projectLogoDark` and `projectName` are used first). The notifications
|
|
45
|
+
component reads the shop logo when it mounts, so the dialog has it on open.
|
|
46
|
+
- **`BitsnapReturns`:** the logo sits above the step indicator.
|
|
47
|
+
- **New login flow states.** E-mail step and code step, with a code restored
|
|
48
|
+
after a reload (`sessionStorage`, 10 minutes); "I already have a code" asks
|
|
49
|
+
for the e-mail first; a throttled resend is reported as "already sent" (not
|
|
50
|
+
as a new code); countdown from the server's `retryIn`; rate limit, expired
|
|
51
|
+
code, too many attempts, e-mail not found, delivery failed or unavailable and
|
|
52
|
+
network errors each have their own message; one live region announces
|
|
53
|
+
"step 1 of 2" / "step 2 of 2".
|
|
54
|
+
- **Returns texts: new optional keys** `resendSent`, `codeSpamHint`,
|
|
55
|
+
`codeValidity`, `codeIncomplete` and `errorNetwork`. They are optional in
|
|
56
|
+
`ReturnsTexts`, so code that builds a complete texts object still compiles.
|
|
57
|
+
- **Notifications login: new text keys** `loginVerifyButton`,
|
|
58
|
+
`loginResendInText`, `loginResentMessage`, `loginExpiredError`,
|
|
59
|
+
`loginTooManyAttemptsError`, `loginRateLimitedError`, `loginNetworkError`,
|
|
60
|
+
`loginSpamHint`, `loginValidityHint`, `loginVerifyingButton`,
|
|
61
|
+
`loginStepEmailHint`, `loginStepCodeHint`, `loginAlreadySentMessage`,
|
|
62
|
+
`loginEmailNotFoundError`, `loginDeliveryUnavailableError`,
|
|
63
|
+
`loginResendNewCodeButton`, `loginNoCodeButton` and
|
|
64
|
+
`loginCodeIncompleteError`; all optional.
|
|
65
|
+
- The server must provide `GetLoginBranding` (public API) for the shop logo;
|
|
66
|
+
without it the logos given as props, or Bitsnap's, are used.
|
|
67
|
+
|
|
25
68
|
## Capabilities
|
|
26
69
|
|
|
27
70
|
### Cart Management:
|
|
@@ -1189,6 +1232,19 @@ function LoginPage() {
|
|
|
1189
1232
|
}
|
|
1190
1233
|
```
|
|
1191
1234
|
|
|
1235
|
+
Customers sign in with an e-mail and a 6-digit code. The code field fills in
|
|
1236
|
+
from the keyboard suggestion or a paste (spaces and dashes are ignored) and
|
|
1237
|
+
submits on the sixth digit. A pending code survives a reload or an app switch
|
|
1238
|
+
(`sessionStorage`, up to 10 minutes). Texts are Polish by default; pass
|
|
1239
|
+
`locale="en"` for English, and `texts` to override any string:
|
|
1240
|
+
|
|
1241
|
+
```tsx
|
|
1242
|
+
<PanelLogin locale="en" texts={{ title: "Welcome back", wrongCode: "That code is wrong." }} />
|
|
1243
|
+
```
|
|
1244
|
+
|
|
1245
|
+
The returns widget and the notifications login use the same code field and
|
|
1246
|
+
messages.
|
|
1247
|
+
|
|
1192
1248
|
## Complete Example
|
|
1193
1249
|
|
|
1194
1250
|
### App Entry Point
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{I as c,J as d,K as e,L as f,M as g,N as h,O as i,P as j,Q as k,R as l}from"./chunk-2NL5FCXC.mjs";import"./chunk-HKNWW37T.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-A6VCP3A4.mjs";import"./chunk-CUPG4B5W.mjs";import"./chunk-L7Q7OKM5.mjs";import"./chunk-5R6AGO3Z.mjs";import"./chunk-X3LVYIJR.mjs";import"./chunk-2UDAB2C5.mjs";import{e as a,f as b}from"./chunk-VNYHJT6V.mjs";import"./chunk-MDCP5JNP.mjs";import"./chunk-U6FLIRIV.mjs";export{c as MARKETING_AGREEMENT_ID,d as bitsnapProjectID,k as default,h as getCartLines,l as getCheckoutMethods,g as getCheckoutSelection,b as getLocale,f as getProjectID,i as reconcileOrderOfLastPayment,a as setLocale,e as setProjectID,j as useCartProvider};
|
|
2
|
+
//# sourceMappingURL=CartProvider-DGRZDTYC.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk555KFWGYjs = require('./chunk-555KFWGY.js');require('./chunk-5FZAROP6.js');require('./chunk-KOYBZORL.js');require('./chunk-4BL7TLK3.js');require('./chunk-SYN5KU3O.js');require('./chunk-ESF5ZVVF.js');require('./chunk-C3BBJOVV.js');var _chunk7RXW6XFYjs = require('./chunk-7RXW6XFY.js');require('./chunk-W3RGQYPD.js');require('./chunk-JSDGZ4NY.js');exports.MARKETING_AGREEMENT_ID = _chunk555KFWGYjs.I; exports.bitsnapProjectID = _chunk555KFWGYjs.J; exports.default = _chunk555KFWGYjs.Q; exports.getCartLines = _chunk555KFWGYjs.N; exports.getCheckoutMethods = _chunk555KFWGYjs.R; exports.getCheckoutSelection = _chunk555KFWGYjs.M; exports.getLocale = _chunk7RXW6XFYjs.f; exports.getProjectID = _chunk555KFWGYjs.L; exports.reconcileOrderOfLastPayment = _chunk555KFWGYjs.O; exports.setLocale = _chunk7RXW6XFYjs.e; exports.setProjectID = _chunk555KFWGYjs.K; exports.useCartProvider = _chunk555KFWGYjs.P;
|
|
2
|
+
//# sourceMappingURL=CartProvider-YVOHSMPE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-
|
|
1
|
+
{"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-YVOHSMPE.js"],"names":[],"mappings":"AAAA,+HAAsG,+BAA4B,+BAA4B,+BAA4B,+BAA4B,+BAA4B,+BAA4B,sDAA+C,+BAA4B,+BAA4B,siBAAmQ","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-YVOHSMPE.js"}
|
package/dist/analytics.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as Tracker, a as TrackerOptions, C as ClientEvent } from './instrument-
|
|
2
|
-
export {
|
|
1
|
+
import { T as Tracker, a as TrackerOptions, C as ClientEvent } from './instrument-eXaC8hc2.mjs';
|
|
2
|
+
export { k as AnalyticsOption, A as AppEventName, B as BrowserEventName, d as Channel, D as DEFAULT_ENDPOINT, E as Env, e as EventName, f as EventProps, l as Instrument, I as InstrumentProvider, P as PageType, S as Source, h as StorefrontEventName, b as TrackExtra, c as createTracker, g as getTracker, i as initTracker, n as noopInstrument, r as resetTracker, s as scoreBucket, u as useInstrument, j as useInstrumentContext } from './instrument-eXaC8hc2.mjs';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
package/dist/analytics.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as Tracker, a as TrackerOptions, C as ClientEvent } from './instrument-
|
|
2
|
-
export {
|
|
1
|
+
import { T as Tracker, a as TrackerOptions, C as ClientEvent } from './instrument-eXaC8hc2.js';
|
|
2
|
+
export { k as AnalyticsOption, A as AppEventName, B as BrowserEventName, d as Channel, D as DEFAULT_ENDPOINT, E as Env, e as EventName, f as EventProps, l as Instrument, I as InstrumentProvider, P as PageType, S as Source, h as StorefrontEventName, b as TrackExtra, c as createTracker, g as getTracker, i as initTracker, n as noopInstrument, r as resetTracker, s as scoreBucket, u as useInstrument, j as useInstrumentContext } from './instrument-eXaC8hc2.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
|
package/dist/analytics.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkC3BBJOVVjs = require('./chunk-C3BBJOVV.js');require('./chunk-W3RGQYPD.js');require('./chunk-JSDGZ4NY.js');exports.BitsnapAnalyticsProvider = _chunkC3BBJOVVjs.i; exports.DEFAULT_ENDPOINT = _chunkC3BBJOVVjs.c; exports.InstrumentProvider = _chunkC3BBJOVVjs.l; exports.createTracker = _chunkC3BBJOVVjs.d; exports.getTracker = _chunkC3BBJOVVjs.f; exports.initTracker = _chunkC3BBJOVVjs.e; exports.noopInstrument = _chunkC3BBJOVVjs.k; exports.resetTracker = _chunkC3BBJOVVjs.g; exports.scoreBucket = _chunkC3BBJOVVjs.r; exports.startAutoPageViews = _chunkC3BBJOVVjs.b; exports.useAnalytics = _chunkC3BBJOVVjs.j; exports.useInstrument = _chunkC3BBJOVVjs.n; exports.useInstrumentContext = _chunkC3BBJOVVjs.m;
|
|
2
2
|
//# sourceMappingURL=analytics.js.map
|
package/dist/analytics.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-
|
|
1
|
+
import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-2UDAB2C5.mjs";import"./chunk-MDCP5JNP.mjs";import"./chunk-U6FLIRIV.mjs";export{s as BitsnapAnalyticsProvider,t as DEFAULT_ENDPOINT,i as InstrumentProvider,r as createTracker,o as getTracker,n as initTracker,c as noopInstrument,a as resetTracker,v as scoreBucket,e as startAutoPageViews,p as useAnalytics,u as useInstrument,m as useInstrumentContext};
|
|
2
2
|
//# sourceMappingURL=analytics.mjs.map
|
package/dist/catalog.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { k as AnalyticsOption } from './instrument-eXaC8hc2.mjs';
|
|
4
4
|
import { S as SlotAppearance, A as AppearanceElements } from './appearance-core-Dt2grZdl.mjs';
|
|
5
5
|
import { BitsnapModels } from './models.mjs';
|
|
6
6
|
import 'zod';
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { k as AnalyticsOption } from './instrument-eXaC8hc2.js';
|
|
4
4
|
import { S as SlotAppearance, A as AppearanceElements } from './appearance-core-Dt2grZdl.js';
|
|
5
5
|
import { BitsnapModels } from './models.js';
|
|
6
6
|
import 'zod';
|
package/dist/catalog.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6GCCNBEUjs = require('./chunk-6GCCNBEU.js');require('./chunk-KOYBZORL.js');require('./chunk-ESF5ZVVF.js');require('./chunk-C3BBJOVV.js');require('./chunk-7RXW6XFY.js');require('./chunk-W3RGQYPD.js');require('./chunk-JSDGZ4NY.js');exports.PRODUCT_LIST_SLOT_NAMES = _chunk6GCCNBEUjs.a; exports.ProductList = _chunk6GCCNBEUjs.d; exports.formatProductPrice = _chunk6GCCNBEUjs.b; exports.useProducts = _chunk6GCCNBEUjs.c;
|
|
2
2
|
//# sourceMappingURL=catalog.js.map
|
package/dist/catalog.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as o,b as e,c as f}from"./chunk-
|
|
1
|
+
import{a as o,b as e,c as f}from"./chunk-4ETIDGYZ.mjs";import{f as r}from"./chunk-M2G74N43.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-5R6AGO3Z.mjs";import"./chunk-X3LVYIJR.mjs";import"./chunk-2UDAB2C5.mjs";import"./chunk-VNYHJT6V.mjs";import"./chunk-MDCP5JNP.mjs";import"./chunk-U6FLIRIV.mjs";export{o as PRODUCT_LIST_SLOT_NAMES,f as ProductList,r as formatProductPrice,e as useProducts};
|
|
2
2
|
//# sourceMappingURL=catalog.mjs.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{C as Dn,F as En,G as Mn,H as On,I as Un,J as _n,K as jn,a as Mt,c as yn,d as ge,e as dt,f as Pn,h as bn,i as vn,j as kn,k as wn,p as Sn,q as Rn,r as Tn,t as An,u as Ln}from"./chunk-HKNWW37T.mjs";import{b as le,c as We,d as xn,e as Cn,f as Te}from"./chunk-A6VCP3A4.mjs";import{a as Ot,g as Ge,h as Ke}from"./chunk-CUPG4B5W.mjs";import{a as Tt,b as At,c as rt,d as Lt,e as Dt,f as pn,k as z,l as Re,m as Q,q as hn,r as N,s as st,u as Nn,v as Ae,w as In}from"./chunk-L7Q7OKM5.mjs";import{a as x}from"./chunk-5R6AGO3Z.mjs";import{a as St,b as mn,c as Rt,e as H,f as gn}from"./chunk-X3LVYIJR.mjs";import{h as Et,l as ot,m as at,n as Se,o as fn}from"./chunk-2UDAB2C5.mjs";import{a as it,c as fe,f as L}from"./chunk-VNYHJT6V.mjs";import{useAutoAnimate as xo}from"@formkit/auto-animate/react";import{useEffect as $n,useMemo as Gn}from"react";import{jsx as Ve}from"react/jsx-runtime";function ye({className:e,...t}){return Ve("div",{"data-slot":"card",className:x("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 Ve("div",{"data-slot":"card-header",className:x("@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 Ve("div",{"data-slot":"card-title",className:x("leading-none font-semibold",e),...t})}function zn({className:e,...t}){return Ve("div",{"data-slot":"card-description",className:x("text-muted-foreground text-sm",e),...t})}function he({className:e,...t}){return Ve("div",{"data-slot":"card-content",className:x("px-6",e),...t})}import{CircleCheck as po}from"lucide-react";import{useId as fo}from"react";import{jsx as _,jsxs as G}from"react/jsx-runtime";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=fo(),p=r??`${l}-email`,y=o??`${l}-code`,w=`${l}-notice`,u=`${l}-hint`,{notice:f}=e,b=f?.kind==="error",s=e.busy==="send",k=e.busy==="verify",T=e.busy==="resend",j=x("h-11 w-full",d),B=f?.kind==="success",A=G("div",{id:w,className:"min-h-10 text-sm leading-5",children:[_("p",{role:"alert",className:"font-medium text-red-700 dark:text-red-400",children:b?f.text:null}),G("p",{role:"status",className:x("flex items-start gap-1.5",B?"font-medium text-emerald-700 dark:text-emerald-400":"text-foreground"),children:[B&&_(po,{"aria-hidden":!0,className:"mt-0.5 size-4 shrink-0"}),_("span",{children:f!=null&&!b?f.text:null})]})]}),J=b&&e.step==="email"&&(f.failure==null||ho.has(f.failure)),ce=_("p",{className:"sr-only",role:"status","aria-live":"polite",children:e.announcement}),E=G("div",{className:"grid gap-2",children:[_(ge,{htmlFor:p,children:t.emailLabel}),_(st,{id:p,ref:e.emailRef,name:"email",type:"email",autoComplete:"email",inputMode:"email",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoFocus:!0,required:!0,className:x("h-11 text-base disabled:opacity-100 disabled:text-foreground/70",yo),placeholder: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 G("form",{noValidate:!0,className:x("flex flex-col gap-4",i),onSubmit:Y=>{Y.preventDefault(),e.sendCode()},children:[ce,E,A,G(N,{type:"submit",disabled:e.isBusy,"aria-busy":s,className:j,children:[s&&_(dt,{"aria-hidden":!0}),s?t.sending:t.sendCode]}),n&&G("p",{className:"flex flex-wrap items-center justify-center text-center text-sm",children:[t.haveCodePrompt!==""&&_("span",{children:t.haveCodePrompt}),_("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?vn(t.resendIn,{seconds:e.secondsLeft}):t.resend;return G("form",{noValidate:!0,className:x("flex flex-col gap-4",i),onSubmit:Y=>{Y.preventDefault(),e.submitCode()},children:[ce,e.needsEmail?E:G("div",{className:"flex flex-wrap items-center justify-between gap-x-2",children:[G("p",{className:"min-w-0 flex-[1_1_14rem] text-sm leading-5 break-words",children:[Z,_("strong",{className:"font-semibold",children:e.email}),"\u2060",pe]}),_("button",{type:"button",className:x(Ut,"-ml-1 shrink-0"),disabled:e.isBusy,onClick:e.changeEmail,children:t.changeEmail})]}),c,G("div",{className:"grid gap-2",children:[_(ge,{htmlFor:y,children:t.codeLabel}),_(wn,{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}`}),G("p",{id:u,className:go,children:[t.validity," ",t.spamHint]})]}),A,G(N,{type:"submit",disabled:e.isBusy||$,"aria-busy":k,className:j,children:[k&&_(dt,{"aria-hidden":!0}),k?t.verifying:t.verify]}),e.needsEmail?_("div",{className:"flex justify-center",children:_("button",{type:"button",className:Ut,disabled:e.isBusy,onClick:e.changeEmail,children:t.noCode})}):G(N,{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&&_(dt,{"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=L(),t){return{...bn(e,t),...it(Po,e),...bo(t,["title","description","codeTitle","codeDescription"])}}function bo(e,t){let n={};for(let a of t){let r=e?.[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,Ke())?null:t.toString()}catch{return null}}function De(e,t){let n=new URL(e);return n.searchParams.set(ko,t),n.toString()}import{jsx as X,jsxs as Hn}from"react/jsx-runtime";if(typeof window<"u"){let t=[window.location.origin,"https://bitsnap.pl","https://kursy.bitsnap.pl"];Ke().length===0&&Ge(Array.from(new Set(t)))}var Co=({texts:e,projectID:t,host:n,locale:a,logo:r})=>{let o=at(),{mutateAsync:i}=Q(z.publicApi.userPanelLogin),{mutateAsync:d}=Q(z.publicApi.userPanelLoginWithCode),c=Gn(()=>({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:Mt(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:Mt(s),cause:s}}}}),[i,d]),l=kn({adapter:c,texts:e,storageKey:Pn("panel",t,n),onVerified:({accessToken:u},f)=>{o.track("panel_login",{}),xn(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 X("main",{className:"mx-auto flex w-full max-w-sm flex-1 flex-col justify-start pt-4 sm:pt-[12vh]",children:Hn(ye,{children:[X(yn,{projectId:t,locale:a,className:"px-4 sm:px-6",...r}),Hn(xe,{className:"px-4 sm:px-6",children:[X(Ce,{role:"heading","aria-level":1,className:"text-2xl",children:y}),X(zn,{children:w})]}),X(he,{className:"px-4 sm:px-6",children:X(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}=le(),p=Se(c,e,"panel"),y=Gn(()=>qn(n??L(),t),[n,t]),w={"--button-background-color":i?.colors?.brand??"#FFFFFF","--button-background-color-dark":i?.colors?.brandDark??"#000000","--button-text-color":i?.colors?.brandDark??"#000000","--button-text-color-dark":i?.colors?.brand??"#FFFFFF"},[u]=xo({duration:300,easing:"ease-in-out",disrespectUserMotionPreference:!1});return $n(()=>{typeof window>"u"||We(c,l)!=null&&(window.location.href=window.location.href.replaceAll("login",""))},[c,l]),$n(()=>{if(typeof window>"u"||window.parent!==window)return;let f=Je(window.location.search);f&&Ze(f);let b=f??Le();if(!b)return;let s=We(c,l);s&&(window.location.href=De(b,s))},[d,c,l]),X(ot,{value:p,children:X("div",{className:"bg-white text-black dark:bg-black dark:text-white",children:X("div",{className:"font-inter flex min-h-screen w-full flex-col p-4",style:w,ref:u,children:X(Co,{texts:y,projectID:c,host:l,locale:n,logo:{showLogo:a,logoUrl:r??i?.logoURL,logoDarkUrl:o??i?.logoDarkURL}})})})})},Io=(e={})=>X(No,{...e});import{useAutoAnimate as Va}from"@formkit/auto-animate/react";import{useEffect as ht,useState as Ja}from"react";import{useState as So,useCallback as Ro,useEffect as To}from"react";function Kn(e){let[t,n]=So(()=>{if(typeof window>"u")return e;let r=new URLSearchParams(window.location.search),o={};return Object.keys(e).forEach(i=>{let d=r.get(i);if(d!==null)try{o[i]=JSON.parse(d)}catch{o[i]=d}}),{...e,...o}}),a=Ro(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 To(()=>{let r=()=>{let o=new URLSearchParams(window.location.search),i={};Object.keys(e).forEach(d=>{let c=o.get(d);if(c!==null)try{i[d]=JSON.parse(c)}catch{i[d]=c}}),n({...e,...i})};return window.addEventListener("popstate",r),()=>window.removeEventListener("popstate",r)},[e]),[t,a]}function Wn(e,t){if(e!=null)return e;let n=t?.trim();if(!(n==null||n===""))return{tokens:Nn(n)}}import*as ct from"@radix-ui/react-switch";import{jsx as Vn}from"react/jsx-runtime";function Jn({className:e,...t}){return Vn(ct.Root,{"data-slot":"switch",className:x("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:Vn(ct.Thumb,{"data-slot":"switch-thumb",className:x("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")})})}import{useState as Ao}from"react";import{Fragment as Do,jsx as Ye,jsxs as zt}from"react/jsx-runtime";function Lo({}){let[e,t]=Ao({disableAll:!1});return zt(Do,{children:[Ye("h3",{className:"text-2xl",children:"Powiadomienia"}),Ye("p",{className:"text-sm text-neutral-500",children:"Zarz\u0105dzaj swoimi powiadomieniami"}),Ye("div",{className:"mt-6",children:zt("div",{className:"flex items-center space-x-2",children:[Ye(Jn,{id:"disable-all-notifications",checked:e.disableAll,onCheckedChange:n=>t(a=>({...a,disableAll:n}))}),zt(ge,{htmlFor:"disable-all-notifications",className:"flex flex-col gap-1 text-base",children:["Wszystkie powiadomienia",Ye("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;import{ChevronLeftIcon as Eo,ChevronRightIcon as Mo,MoreHorizontalIcon as Oo}from"lucide-react";import{jsx as re,jsxs as qt}from"react/jsx-runtime";function Yn({className:e,...t}){return re("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:x("mx-auto flex w-full justify-center",e),...t})}function Qn({className:e,...t}){return re("ul",{"data-slot":"pagination-content",className:x("flex flex-row items-center gap-1",e),...t})}function Pe({...e}){return re("li",{"data-slot":"pagination-item",...e})}function Ee({className:e,isActive:t,size:n="icon",...a}){return re("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:x(hn({variant:t?"outline":"ghost",size:n}),e),...a})}function Xn({className:e,...t}){return qt(Ee,{"aria-label":"Go to previous page",size:"default",className:x("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[re(Eo,{}),re("span",{className:"hidden sm:block",children:"Previous"})]})}function er({className:e,...t}){return qt(Ee,{"aria-label":"Go to next page",size:"default",className:x("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[re("span",{className:"hidden sm:block",children:"Next"}),re(Mo,{})]})}function Ft({className:e,...t}){return qt("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:x("flex size-9 items-center justify-center",e),...t,children:[re(Oo,{className:"size-4"}),re("span",{className:"sr-only",children:"More pages"})]})}import{useState as Uo}from"react";import{Fragment as Bo,jsx as C,jsxs as K}from"react/jsx-runtime";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]=Uo(0),o=20,{data:i,isFetching:d}=Re(z.publicApi.getOrders,{projectId:t,accessToken:n,offset:a,limit:o}),c=i?.orders??[],l=i?.totalCount??0,p=Math.floor(a/o)+1,y=Math.ceil(l/o),w=u=>{r(u)};return K(Bo,{children:[C("h3",{className:"text-2xl",children:"Historia zam\xF3wie\u0144"}),C("p",{className:"text-sm text-neutral-500 dark:text-neutral-400",children:"Twoje zam\xF3wienia"}),d?C("div",{className:"mt-6 flex w-full flex-col gap-3",children:[...Array(5)].map((u,f)=>K("div",{className:"rounded-xl bg-white p-4 shadow-sm dark:bg-neutral-800",children:[K("div",{className:"flex items-center justify-between",children:[K("div",{className:"space-y-2",children:[C(Ae,{className:"h-4 w-24"}),C(Ae,{className:"h-3 w-32"})]}),K("div",{className:"space-y-2 text-right",children:[C(Ae,{className:"ml-auto h-4 w-16"}),C(Ae,{className:"ml-auto h-3 w-12"})]})]}),C("div",{className:"mt-3",children:C(Ae,{className:"h-3 w-40"})})]},f))}):c.length===0?C("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak zam\xF3wie\u0144."}):K("div",{children:[C("div",{className:"mt-6 flex w-full flex-col gap-3",children:c.map(u=>K("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:[K("div",{className:"flex items-center justify-between",children:[K("div",{children:[K("p",{className:"font-medium",children:["Zam\xF3wienie #",u.id]}),C("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:u.customerName||"Klient"})]}),K("div",{className:"text-right",children:[C("p",{className:"font-semibold",children:jo(u.totalAmount,u.currency)}),C("p",{className:`text-xs font-medium ${Fo[u.status]??"text-neutral-400"}`,children:zo[u.status]??u.status})]})]}),C("div",{className:"mt-2 flex items-center justify-between text-xs text-neutral-500 dark:text-neutral-400",children:K("span",{children:["Data:"," ",u.createdAt?_o(Number(u.createdAt.seconds)):"-"]})})]},u.id))}),y>1&&!d&&C("div",{className:"mt-4 flex justify-center",children:C(Yn,{children:K(Qn,{children:[p>1&&C(Pe,{children:C(Xn,{onClick:()=>w(a-o)})}),p>2&&C(Pe,{children:C(Ee,{onClick:()=>w(0),children:"1"})}),p>3&&C(Pe,{children:C(Ft,{})}),[p-1,p,p+1].filter(u=>u>0&&u<=y).map(u=>C(Pe,{children:C(Ee,{onClick:()=>w((u-1)*o),isActive:p===u,children:u})},u)),p<y-2&&C(Pe,{children:C(Ft,{})}),p<y&&C(Pe,{children:C(Ee,{onClick:()=>w((y-1)*o),children:y})}),p<y&&C(Pe,{children:C(er,{onClick:()=>w(a+o)})})]})})})]})]})}var tr=qo;import{useState as nr}from"react";import{Fragment as Ko,jsx as ee,jsxs as be}from"react/jsx-runtime";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]=nr([]),[a,r]=nr(!0);return be(Ko,{children:[ee("h3",{className:"text-2xl",children:"Plany"}),ee("p",{className:"text-sm text-neutral-500",children:"Twoje aktywne subskrypcje"}),a?ee("div",{className:"mt-6 text-sm text-neutral-400",children:"\u0141adowanie..."}):t.length===0?ee("div",{className:"mt-6 text-sm text-neutral-400",children:"Brak aktywnych plan\xF3w."}):ee("div",{className:"mt-6 flex flex-col gap-4",children:t.map(o=>be("div",{className:"rounded-xl bg-white p-5 shadow-sm dark:bg-neutral-800",children:[be("div",{className:"flex items-start justify-between",children:[be("div",{children:[ee("p",{className:"font-semibold",children:o.tierName}),o.configName&&ee("p",{className:"text-sm text-neutral-500",children:o.configName})]}),ee("span",{className:`text-sm font-medium ${Ho[o.status]??"text-neutral-500"}`,children:$o[o.status]??o.status})]}),be("div",{className:"mt-3 grid grid-cols-2 gap-2 text-sm text-neutral-600 dark:text-neutral-400",children:[be("div",{children:[ee("span",{className:"font-medium",children:"Dzie\u0144 rozliczenia:"})," ",o.billingDay]}),be("div",{children:[ee("span",{className:"font-medium",children:"Data startu:"})," ",rr(o.startDate)]}),o.endDate&&be("div",{children:[ee("span",{className:"font-medium",children:"Data zako\u0144czenia:"})," ",rr(o.endDate)]})]})]},o.id))})]})}var or=Go;import{useEffect as Wo,useState as Bt}from"react";import{jsx as te,jsxs as Zo}from"react/jsx-runtime";function Vo(e,t,n,a){typeof window>"u"||(t&&Te(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}=An("PanelReturns"),l=Tn(),p=d==="anonymous"&&(c==null||Sn(c));Wo(()=>{p&&Vo(n,c!=null,e,t)},[p,n,c,e,t]);let[y,w]=Bt("orders"),[u,f]=Bt({items:[],note:""}),[b,s]=Bt();if(d==="anonymous"&&!p)return Zo("div",{role:"alert",className:"flex flex-col items-start gap-3",children:[te("p",{className:"text-sm",children:l(Rn(c))}),te(N,{type:"button",onClick:()=>window.location.reload(),children:l("errorRetry")})]});if(d!=="authenticated")return te(Dn,{});let k=T=>{w(T),o({state:"returns",orderId:void 0,returnId:void 0}),i("returns")};if(a==="return-details"&&r.returnId)return te(jn,{returnId:r.returnId,onBack:()=>k("myReturns")});if(y==="myReturns")return te(_n,{onBack:()=>k("orders"),onSelectReturn:T=>{o({state:"return-details",returnId:T,orderId:void 0}),i("return-details")}});if(y==="result"&&b!=null)return te(Un,{returnId:b,onContinue:()=>k("orders"),onOpenMyReturns:()=>k("myReturns")});if(r.orderId){let T=r.orderId;return y==="confirmation"?te(On,{orderId:T,items:u.items,note:u.note,onBack:()=>w("orders"),onSubmitted:j=>{s(j),f({items:[],note:""}),w("result"),o({orderId:void 0})}}):te(Mn,{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 te(En,{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 te(Ln,{projectID:a.projectID,host:a.host,appearance:t,texts:n,panelAccessToken:e,children:te(Jo,{...a})})}import{lazy as ya,Suspense as ha,useEffect as Pa,useState as ba}from"react";import{jsx as Ht,jsxs as Qo}from"react/jsx-runtime";function Yo(){return Qo("div",{className:"flex items-center gap-2",children:[Ht("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.3s]"}),Ht("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current [animation-delay:-0.15s]"}),Ht("div",{className:"h-3 w-3 animate-bounce rounded-full bg-current"})]})}var oe=Yo;import{jsx as na}from"react/jsx-runtime";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 na("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)))}})};import{fromJsonString as va,toJsonString as ka}from"@bufbuild/protobuf";import{useAutoAnimate as la}from"@formkit/auto-animate/react";import{ChevronLeft as ua,Download as gr}from"lucide-react";import{useEffect as yr,useRef as hr,useState as Oe}from"react";import ur from"hls.js";import{Pause as ra,Play as oa}from"lucide-react";import{forwardRef as aa,useEffect as lt,useImperativeHandle as ia,useRef as Qe,useState as Me}from"react";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}import{jsx as ae,jsxs as ut}from"react/jsx-runtime";var sa=aa(({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]=Me(1);lt(()=>{switch(p){case 0:ir();break;case 1:sr();break}},[p]),ia(c,()=>({selectChapter:g=>{He(g)}}));let[w,u]=Me(void 0),[f,b]=Me(void 0),s=Qe(null),k=Qe(void 0),T=Qe(void 0),j=Qe(null),B=Qe(null),[A,J]=Me(!0),[ce,E]=Me(!1),[Z,pe]=Me(!da());function $(g){g<10||localStorage.setItem(`__player__${i}_${B.current?.id}`,`${g}`)}function Be(){let g=localStorage.getItem(`__player__${i}_${B.current?.id}`);if(g!=null)try{let M=parseInt(g);return isNaN(M)||M<0?void 0:M}catch{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: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==B.current?.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(){s.current?.play().then().catch(),Ne()}function It(){s.current?.pause(),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="",k.current?.destroy())}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),d?.(g),xt(g.id)}function co(g){s.current!=null&&(s.current.canPlayType("application/vnd.apple.mpegurl")?s.current.src=g:ur.isSupported()&&(k.current==null&&(k.current=new ur,k.current?.attachMedia(s.current)),k.current?.loadSource(g)))}lt(()=>{s.current!=null&&(v(),ln(e))},[s.current]),lt(()=>{ln(e)},[e]),lt(()=>(a?.(nt),()=>{u(void 0),s.current?.pause(),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 ut("div",{id:"audio-player-container",className:"flex flex-col",style:t,ref:j,children:[ae("video",{ref:s,className:"hidden",poster:o,title:r}),ae("input",{type:"range",min:"0",max:f!=null?Math.floor(f).toString():100,value:w??0,onChange:g=>lo(g.target),className:"w-full"}),ut("section",{className:"flex w-full items-center justify-between text-sm font-medium",children:[ae("span",{id:"current-time",children:un(w)}),ae("span",{id:"duration",children:un(f)})]}),ut("div",{className:"mt-6 flex items-center justify-center gap-x-12",children:[ae(N,{variant:"outline",onClick:()=>tt(-10),"aria-label":"Rewind 10 Seconds",children:"-10"}),ut(N,{variant:"outline",onClick:io,"aria-label":"Play Or Pause",children:[p===1&&ae(oa,{className:"h-5 w-5"}),p===0&&ae(ra,{className:"h-5 w-5"})]}),ae(N,{variant:"outline",onClick:()=>tt(10),"aria-label":"Fast Forward 10 Seconds",children:"+10"})]}),Z&&ae("div",{className:"mt-2 flex w-full justify-center",children:ae(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=L()){return it(ca,e)}import*as mt from"react";import{jsx as pr}from"react/jsx-runtime";function fr(){let[e,t]=mt.useState(13);return mt.useEffect(()=>{let n=setTimeout(()=>t(66),500);return()=>clearTimeout(n)},[]),pr("div",{className:"w-[60%] h-2 bg-gray-200 rounded-full overflow-hidden",children:pr("div",{className:"h-full bg-blue-600 transition-all duration-300",style:{width:`${e}%`}})})}import{Fragment as pt,jsx as P,jsxs as O}from"react/jsx-runtime";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=at(),d=()=>i.track("panel_download",{},{product_id:t.productId.length<=64?t.productId:null}),c=hr(null),[l]=la(),[p,y]=Oe(null),{mutateAsync:w,isPending:u}=Q(z.publicApi.userPanelGetFileDetails),f=hr(void 0),[b,s]=Oe(null),[k,T]=Oe(null),[j,B]=Oe(!1),{mutateAsync:A,isPending:J}=Q(z.publicApi.userPanelGetAudiobookDetails),{mutateAsync:ce,isPending:E}=Q(z.publicApi.userPanelGetAudiobookDetailsDownloadURLs),[Z,pe]=Oe(null),[$,Be]=Oe(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 yr(()=>{o===1&&(xt().then().catch(),Ct().then().catch())},[]),yr(()=>{if(b!=null&&k!=null){let v=b.chapters;if(!v)return;let ne=v.map(we=>{let $e=k?.find(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]),O("div",{children:[P("div",{className:"mb-3 space-y-4 rounded bg-white p-4 dark:bg-black",children:O(N,{onClick:()=>a(),variant:"ghost",className:"w-fit",children:[P(ua,{className:"h-6 w-6"}),P("span",{className:"font-inter text-sm font-medium",children:"Wr\xF3\u0107"})]})}),O("main",{className:"grid grid-cols-1 justify-center gap-6 sm:justify-start lg:grid-cols-2",children:[O("div",{className:"flex w-full max-w-xl flex-col gap-6",children:[o===2&&O("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:[O("div",{className:"flex items-center justify-between gap-x-4",children:[P("h4",{className:"text-xl font-semibold",children:"Twoje pliki"}),(p==null||p.length==0)&&P(N,{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?P(oe,{}):"Wy\u015Bwietl"})]}),u&&O("div",{className:"flex flex-col items-start gap-2",children:[P(fr,{}),P("p",{className:"font-bold transition hover:text-blue-600",children:"Trwa przygotowanie plik\xF3w..."})]}),p!=null&&p.length>0&&P("div",{className:"flex flex-col items-start justify-start gap-2",children:p.map((v,ne)=>O("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}`,P(gr,{width:14,height:14})]},ne))})]}),o===4&&P("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:P(N,{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&&P(pt,{children:O("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:[P("h4",{className:"text-xl font-semibold",children:Z?.name??"Odtwarzacz"}),Z?.description&&P("p",{className:"text-sm",children:Z?.description}),P(pt,{children:J?O("div",{className:"flex gap-2",children:[P(oe,{}),P("p",{className:"text-xl font-semibold",children:"Trwa pobierania audiobooka..."})]}):P(pt,{children:$!=null?P(pt,{children:P(mr,{ref:c,chapters:$,title:b?.name??t.productName??void 0,imageURL:b?.coverImage??t.productImageUrl??void 0,styles:n,setCurrentTimeHandler:v=>{f.current=v},uniqueProductID:t.productId,onChapterChange:v=>{pe(v)}})}):P("p",{className:"mt-2",children:"Wybierz rozdzia\u0142, kt\xF3ry ci\u0119 interesuje."})})}),O("div",{className:"rounded-xl bg-neutral-100 p-3 dark:bg-neutral-800",children:[P("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."}),O("div",{className:"flex gap-3",children:[P("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",children:P("img",{width:"100",src:"https://bitsnap.pl/appstore.svg",alt:"Pobierz aplikacje z AppStore"})}),P("a",{href:"https://docs.bitsnap.pl/guides/audiobook",children:P("img",{width:"100",src:"https://bitsnap.pl/playstore.svg",alt:"Pobierz aplikacj\u0119 z GooglePlay"})})]})]})]})}),P("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&&P("div",{className:"max-h-96 w-full overflow-y-auto",children:J?O("div",{className:"jusitfy-center flex flex-col items-center gap-2",children:[P(oe,{}),P("p",{children:"\u0141adowanie rozdzia\u0142\xF3w..."})]}):O("div",{children:[P("h2",{className:"mb-3 text-xl font-semibold",children:"Rozdzia\u0142y"}),$==null?P("p",{children:"Brak rozdzia\u0142\xF3w do wy\u015Bwietlenia."}):P("ul",{className:"flex w-full flex-col gap-2",children:$.map((v,ne)=>O("li",{className:"flex items-center justify-between",children:[O("button",{className:x("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",Z?.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:[O("div",{className:"flex items-center justify-between",children:[P("p",{className:"text-sm font-medium",children:v.name}),v.duration&&O("span",{className:"text-xs text-neutral-500",children:[Math.floor(v.duration/60),":",String(Math.floor(v.duration%60)).padStart(2,"0")]})]}),v.description&&P("p",{className:"mt-3 text-xs",children:v.description})]}),b&&b.isDownloadable&&v.downloadableUrl&&P("a",{href:v.downloadableUrl,onClick:d,children:P(gr,{width:14,height:14})})]},ne))})]})})})]}),O("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:[P("h2",{className:"text-3xl font-semibold",children:t.productName}),P("p",{className:"text-sm font-normal text-neutral-600 dark:text-neutral-300",children:t.productDescription}),P("img",{src:t.productImageUrl,alt:"Product Photo",width:384,height:384,className:"max-h-sm max-w-sm",draggable:!1})]})]})]})},Pr=ma;import{useTransport as pa}from"@connectrpc/connect-query";import{useEffect as fa,useState as ga}from"react";function br(e,t){let n=pa(),[a,r]=ga({status:"loading"});return fa(()=>{if(!e){r({status:"hidden"});return}let o=!1;return r({status:"loading"}),import("./model-files-client-HHDXJDTS.mjs").then(({listModelFiles:i})=>i(n,e,t)).catch(()=>({status:"hidden"})).then(i=>{o||r(i)}),()=>{o=!0}},[n,e,t]),a}import{Fragment as kr,jsx as D,jsxs as ve}from"react/jsx-runtime";var wa=ya(()=>import("./PanelModelFiles-RV7OHUUZ.mjs")),xa=({accessToken:e,projectID:t,loginURL:n,styles:a,activeScreen:r,params:o,setParams:i,openCourse:d})=>{let{host:c}=le(),{data:l,isLoading:p,error:y,refetch:w}=Re(z.publicApi.userPanelGetProducts,{accessToken:e}),u=br(e,t),f=Ca({products:p?{status:"loading"}:y!=null?{status:"error"}:l?.result.case==="success"?{status:"ok",count:l.result.value.products.length}:l?.result.case==="failure"?{status:"failure",unauthorized:l.result.value===9}:{status:"error"},modelFiles:u});if(Pa(()=>{f.kind==="signed-out"&&(Te(t,c),window.location.href=n)},[f.kind,t,c,n]),f.kind==="loading"||f.kind==="signed-out")return ve("div",{className:"flex items-center gap-2 bg-white p-2 dark:bg-black",children:[D("p",{className:"text-dark font-inter font-medium dark:text-white",children:L().toLowerCase().startsWith("en")?"Loading...":"\u0141adowanie..."}),D(oe,{})]});let b=l&&l.result.case==="success"?l.result.value.products:[],s=u.status==="ready"?u.models:[],k=s.length>0?D(ha,{fallback:null,children:D(wa,{accessToken:e,models:s,buttonStyle:a})}):null;return f.kind==="error"?ve(kr,{children:[D(Ia,{onRetry:()=>void w()}),k]}):f.kind==="empty"?D(Na,{}):D(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=L().toLowerCase().startsWith("en");return ve("div",{className:"flex flex-col items-start gap-1","data-testid":"panel-empty",children:[D("h3",{className:"text-2xl",children:e?"Hi \u{1F44B}":"Hej \u{1F44B}"}),D("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=L().toLowerCase().startsWith("en");return ve("div",{className:"flex flex-col items-start gap-3",role:"alert","data-testid":"panel-error",children:[D("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."}),D(N,{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]=ba(o.product?va(Dt,o.product):void 0),p=u=>{u==null?(l(void 0),i({product:void 0,state:"products"})):i({product:ka(Dt,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?D(Pr,{accessToken:e,product:c,styles:n,reveal:p,onOpenCourse:d}):ve(kr,{children:[D("h3",{className:"text-2xl",children:"Hej \u{1F44B}"}),t.length>0&&D("p",{className:"text-sm text-neutral-500",children:"Poni\u017Cej znajdziesz swoje produkty"}),D("div",{className:"mt-6 flex flex-wrap items-center justify-center gap-9 sm:justify-start",children:t?.map((u,f)=>ve("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:[ve("section",{className:"flex flex-col items-center space-y-2 rounded bg-slate-100 p-4 dark:bg-neutral-900",children:[u.productType&&D("div",{className:"w-fit self-end rounded bg-red-900 px-4 py-1",children:D("span",{className:"text-sm font-medium text-white dark:text-slate-100",children:y(u.productType)})}),D("div",{className:"jusitfy-center flex max-h-40 items-center",children:D("img",{src:u.productImageUrl,alt:`Product ${f} Photo`,draggable:!1,className:"aspect-auto max-h-40"})})]}),ve("div",{className:"space-y-4 rounded bg-white p-4 dark:bg-black",children:[D("h2",{className:"text-xl font-semibold",children:u.productName}),D("p",{title:u.productDescription,className:"line-clamp-3 text-sm font-normal text-neutral-600 dark:text-neutral-300",children:ar(u.productDescription)}),D(N,{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]})};import{useAutoAnimate as Ra}from"@formkit/auto-animate/react";import{LogOut as Ta,Undo2 as xr}from"lucide-react";import{useState as Aa}from"react";import{Fragment as Nr,jsx as I,jsxs as ie}from"react/jsx-runtime";function La({activeScreen:e,setActiveScreen:t,setParams:n,styles:a,theme:r,logout:o}){return ie("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:[I(Da,{activeScreen:e,setActiveScreen:t,setParams:n}),I(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 ie("nav",{className:"flex w-full items-center justify-evenly gap-4 md:hidden",children:[I(ft,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),I(ft,{panelScreen:"orders",label:"Faktury",imageURL:"/icons/category-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n}),I(ft,{panelScreen:"returns",label:a,icon:I(xr,{className:"h-5 w-5 text-white","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n}),I(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 ie(N,{onClick:()=>{o(e),i({product:void 0,state:e})},"aria-label":t,variant:null,className:x("flex flex-col gap-0",r===e?"opacity-100":"opacity-50"),children:[a??I("img",{src:n,alt:t,className:"scale-75"}),I("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 ie(N,{onClick:()=>{i(e),d({product:void 0,state:e})},variant:o===e?"secondary":"ghost",className:"justify-start",children:[r!=null?I("span",{className:x("inline-flex h-5 w-5 items-center justify-center",c?"mr-4":"mr-2"),children:r}):ie(Nr,{children:[I("img",{src:n,alt:t,className:x("aspect-auto h-5 w-5 dark:hidden",c?"mr-4":"mr-2")}),I("img",{src:a,alt:t,className:x("hidden aspect-auto h-5 w-5 dark:inline",c?"mr-4":"mr-2")})]}),c&&I("span",{className:"md:text-medium hidden md:inline",children:t})]})}function Ea({activeScreen:e,setActiveScreen:t,setParams:n,theme:a,logout:r}){let[o]=Ra(),[i,d]=Aa(!0),{returnsNavLabel:c}=Xe();return ie("div",{ref:o,className:x("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:[I("div",{className:"flex items-center justify-between",children:I(Ma,{theme:a,isExpanded:i})}),I(wr,{className:"my-6"}),ie("div",{className:"flex flex-1 flex-col gap-2",children:[I(gt,{panelScreen:"products",label:"Produkty",imageURL:"/icons/bitsnap-dark-24x24.svg",darkImageURL:"/icons/bitsnap-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),I(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}),I(gt,{panelScreen:"returns",label:c,icon:I(xr,{className:"h-5 w-5","aria-hidden":!0}),activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i}),I(gt,{panelScreen:"profile",label:"Profil",imageURL:"/icons/profile-dark-24x24.svg",darkImageURL:"/icons/profile-24x24.svg",activeScreen:e,setActiveScreen:t,setParams:n,isExpanded:i})]}),I(wr,{className:"mb-6"}),ie(N,{onClick:r,children:[I(Ta,{className:"mr-2",width:16,height:16}),i&&I("p",{className:"md:text-medium hidden md:inline md:text-center",children:"Wyloguj si\u0119"})]})]})}function wr({className:e}){return ie("div",{className:x("relative h-px w-full bg-neutral-300",e),children:[I("div",{className:"absolute -top-px left-0 h-1 w-1 rounded-full bg-neutral-500"}),I("div",{className:"absolute -top-px right-0 h-1 w-1 rounded-full bg-neutral-500"})]})}function Ma({theme:e,isExpanded:t}){return ie(Nr,{children:[e==null&&I("p",{className:"text-xl tracking-wider md:inline dark:text-neutral-200",children:"bitsnap."}),(e?.logoDarkURL||e?.logoURL)&&I("img",{src:e.logoDarkURL??e.logoURL,alt:"Company Logo",className:"hidden h-6 w-6 dark:inline",draggable:!1}),e?.logoURL&&I("img",{src:e.logoURL,alt:"Company Logo",className:"h-6 w-6 dark:hidden",draggable:!1})]})}import{LogOut as Oa}from"lucide-react";import{Fragment as _a,jsx as Ue,jsxs as Kt}from"react/jsx-runtime";function Ua({email:e,logout:t}){return Kt(_a,{children:[Ue("h3",{className:"text-2xl",children:"Profil"}),Kt("div",{className:"mt-6 flex-1 md:flex-none",children:[Ue("span",{className:"text-sm text-neutral-500",children:"Email"}),Ue("p",{className:"mt-2 text-base",children:e||"Brak danych"})]}),Ue("div",{className:"flex w-full flex-col items-center space-y-2",children:Kt(N,{onClick:t,className:"max-w-64 md:hidden",children:[Ue(Oa,{className:"mr-2",width:16,height:16}),Ue("p",{className:"text-medium inline text-center",children:"Wyloguj si\u0119"})]})})]})}var Ir=Ua;import{lazy as ja,Suspense as za}from"react";import{jsx as yt}from"react/jsx-runtime";var Fa=ja(()=>import("./course.mjs").then(e=>({default:e.PanelCourse})));function Wt(e){return yt(za,{fallback:yt("div",{className:"flex items-center gap-2 p-2",role:"status",children:yt(oe,{})}),children:yt(Fa,{...e})})}import{AlertCircle as Lr,CheckCircle2 as Sr,ChevronLeft as qa,Loader2 as Jt,Lock as Rr,Package as Ba,Truck as Dr}from"lucide-react";import{useEffect as $a,useState as Vt}from"react";import{Fragment as Er,jsx as m,jsxs as h}from"react/jsx-runtime";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:Sr},completed:{color:"bg-blue-100 text-blue-700",icon:Sr},canceled:{color:"bg-red-100 text-red-700",icon:Lr},sent:{color:"bg-purple-100 text-purple-700",icon:Dr},processing:{color:"bg-yellow-100 text-yellow-700",icon:Jt}},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 h("span",{className:`inline-flex items-center gap-1 rounded-full px-3 py-1 text-sm font-medium ${n.color}`,children:[a&&m(a,{className:"h-4 w-4"}),r[e]||e]})}function Ga({orderID:e,email:t}){let[n,a]=Vt(""),r=Q(z.publicApi.addPublicOrderComment);return h("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:[m(ge,{htmlFor:"comment",children:"Dodaj komentarz"}),m(In,{id:"comment",value:n,onChange:i=>a(i.target.value),placeholder:"Wpisz komentarz...",rows:3,disabled:r.isPending}),m(N,{type:"submit",disabled:!n.trim()||r.isPending,children:r.isPending?h(Er,{children:[m(Jt,{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}=le(),d=Se(i,r,"order"),[c,l]=Vt(t||""),[p,y]=Vt(!1),{data:w,isLoading:u,error:f,refetch:b}=Re(z.publicApi.getPublicOrderDetails,{projectId:i??"",orderId:e,email:c||void 0,accessToken:a},{enabled:!!e}),s=w?.result.case==="order"?w.result.value:null,k=s?.isVerified??!1,T=s!=null;$a(()=>{T&&d.track("panel_order_viewed",{},{order_ref:null})},[d,T]);let j=()=>{b(),y(!1)},B={"--button-background-color":o?.colors?.brand??"#000000","--button-background-color-dark":o?.colors?.brandDark??"#ffffff","--button-text-color":o?.colors?.brandDark??"#000000","--button-text-color-dark":o?.colors?.brand??"#000000"};return u?m("div",{className:"flex min-h-screen items-center justify-center",children:h("div",{className:"text-center",children:[m(Jt,{className:"mx-auto h-8 w-8 animate-spin text-neutral-400"}),m("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"\u0141adowanie zam\xF3wienia..."})]})}):f||!s?m("div",{className:"flex min-h-screen items-center justify-center",children:m(ye,{className:"w-full max-w-md",children:m(he,{className:"pt-6",children:h("div",{className:"text-center",children:[m(Lr,{className:"mx-auto h-12 w-12 text-red-500"}),m("h2",{className:"mt-4 text-xl font-semibold",children:"Zam\xF3wienie nie znalezione"}),m("p",{className:"mt-2 text-neutral-600 dark:text-neutral-400",children:"Nie znaleziono zam\xF3wienia o podanym numerze."})]})})})}):m("div",{className:"w-full bg-white py-8 dark:bg-black",style:B,children:h("div",{className:"w-full px-4",children:[n&&h(N,{onClick:n,variant:"ghost",className:"mb-4 w-fit",children:[m(qa,{className:"h-4 w-4"}),"Wr\xF3\u0107 do historii zam\xF3wie\u0144"]}),h("div",{className:"mb-6 flex items-center gap-4",children:[o?.logoURL&&h(Er,{children:[m("img",{src:o.logoURL,alt:"Project logo",className:`h-12 w-auto ${o.logoDarkURL?"dark:hidden":""}`}),o.logoDarkURL&&m("img",{src:o.logoDarkURL,alt:"Project logo",className:"hidden h-12 w-auto dark:block"})]}),h("div",{children:[m("h1",{className:"text-3xl font-bold",children:"Zam\xF3wienie"}),h("p",{className:"text-neutral-600 dark:text-neutral-400",children:["Numer zam\xF3wienia: #",s.orderId]})]})]}),h(ye,{className:"mb-6",children:[m(xe,{children:h(Ce,{className:"flex items-center",children:[m(Ba,{className:"mr-2 h-5 w-5"}),"Status zam\xF3wienia"]})}),h(he,{className:"space-y-6",children:[h("div",{children:[h("div",{className:"flex items-center gap-2",children:[m(Ha,{status:s.status}),s.processingStatus&&h("span",{className:"text-sm text-neutral-600",children:["\xB7 ",s.processingStatus]})]}),h("p",{className:"mt-2 text-sm text-neutral-600",children:["Zam\xF3wienie z\u0142o\u017Cone ",Tr(s.createdAt)]})]}),h("div",{className:"border-t pt-4",children:[m("h3",{className:"mb-3 font-semibold",children:"Dane klienta"}),h("div",{className:"space-y-2",children:[h("div",{children:[m("span",{className:"font-medium",children:"Imi\u0119 i nazwisko:"})," ",m("span",{className:k?"":"text-neutral-500",children:s.customerName})]}),h("div",{children:[m("span",{className:"font-medium",children:"Email:"})," ",m("span",{className:k?"":"text-neutral-500",children:s.customerEmail})]}),s.customerPhone&&h("div",{children:[m("span",{className:"font-medium",children:"Telefon:"})," ",m("span",{className:k?"":"text-neutral-500",children:s.customerPhone})]})]})]}),!k&&m("div",{className:"border-t pt-4",children:h(N,{onClick:()=>y(!0),variant:"outline",className:"w-full",children:[m(Rr,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),h(ye,{className:"mb-6",children:[m(xe,{children:m(Ce,{children:"Produkty"})}),h(he,{className:"space-y-6",children:[m("div",{className:"space-y-4",children:s.items.map((A,J)=>h("div",{className:"flex items-center gap-4",children:[A.imageUrl&&m("img",{src:A.imageUrl,alt:A.name,className:"h-16 w-16 rounded object-cover"}),h("div",{className:"flex-1",children:[m("p",{className:"font-medium",children:A.name}),h("p",{className:"text-sm text-neutral-600",children:["Ilo\u015B\u0107: ",A.quantity]})]}),m("div",{className:"text-right",children:m("p",{className:"font-medium",children:Ar(Number(A.price),A.currency)})})]},J))}),(s.deliveryAddress||s.deliveryMethod)&&h("div",{className:"border-t pt-4",children:[h("h3",{className:"mb-3 flex items-center font-semibold",children:[m(Dr,{className:"mr-2 h-5 w-5"}),"Informacje o dostawie"]}),h("div",{className:"space-y-2",children:[s.deliveryAddress&&h("div",{children:[m("span",{className:"font-medium",children:"Adres:"})," ",m("span",{className:k?"":"text-neutral-500",children:s.deliveryAddress})]}),s.deliveryMethod&&h("div",{children:[m("span",{className:"font-medium",children:"Metoda:"})," ",s.deliveryMethod]}),s.trackingNumber&&k&&h("div",{children:[m("span",{className:"font-medium",children:"Tracking:"})," ",s.trackingNumber]})]})]}),m("div",{className:"border-t pt-4",children:h("div",{className:"flex justify-between text-lg font-bold",children:[m("span",{children:"Suma:"}),m("span",{children:Ar(Number(s.totalAmount),s.currency)})]})})]})]}),h(ye,{children:[m(xe,{children:h(Ce,{children:["Komentarze ",s.commentCount>0&&`(${s.commentCount})`]})}),h(he,{children:[s.comments.length>0?m("div",{className:"space-y-4",children:s.comments.map(A=>h("div",{className:"border-b pb-4 last:border-b-0",children:[h("div",{className:"mb-1 flex items-center gap-2",children:[m("span",{className:"font-medium",children:A.authorName||"System"}),m("span",{className:"text-xs text-neutral-500",children:Tr(A.createdAt)}),A.authorType==="admin"&&m("span",{className:"rounded bg-blue-100 px-2 py-0.5 text-xs text-blue-700",children:"Admin"})]}),m("p",{className:k?"":"text-neutral-500",children:A.message})]},A.id))}):m("p",{className:"text-neutral-600",children:"Brak komentarzy."}),k?m(Ga,{orderID:s.orderId,email:c}):m("div",{className:"mt-4",children:h(N,{onClick:()=>y(!0),variant:"outline",className:"w-full",children:[m(Rr,{className:"mr-2 h-4 w-4"}),"Zweryfikuj sw\xF3j email"]})})]})]}),p&&m("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:h(ye,{className:"w-full max-w-md",children:[m(xe,{children:m(Ce,{children:"Zweryfikuj sw\xF3j email"})}),h(he,{className:"space-y-4",children:[m("p",{className:"text-sm text-neutral-700",children:"Podaj adres email u\u017Cyty przy sk\u0142adaniu zam\xF3wienia."}),h("div",{className:"space-y-2",children:[m(ge,{htmlFor:"verify-email",children:"Adres email"}),m(st,{id:"verify-email",type:"email",placeholder:"twoj@email.com",value:c,onChange:A=>l(A.target.value)})]}),h("div",{className:"flex gap-2",children:[m(N,{variant:"outline",onClick:()=>y(!1),className:"flex-1",children:"Anuluj"}),m(N,{onClick:j,className:"flex-1",children:"Zweryfikuj"})]})]})]})})]})})}function Wa(e){return m(Ka,{...e})}var Zt=Wa;import{jsx as se,jsxs as Mr}from"react/jsx-runtime";var Za=({returnsAppearance:e,returnsTexts:t,analytics:n}={})=>{let{projectID:a,theme:r,loginURL:o,host:i}=le(),d=Se(a,n,"panel"),c=We(a,i),l=Cn(a,i),{mutateAsync:p}=Q(z.publicApi.userPanelLogout);async function y(){c&&await p({accessToken:c}),typeof window<"u"&&(Te(a,i),window.location.reload())}let[w]=Va(),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]=Ja(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")};ht(()=>{u(f.state)&&(f.state==="course"||s==="course")&&k(f.state)},[f.state]);let ce={"--button-background-color":r?.colors?.brand??"#000000","--button-background-color-dark":r?.colors?.brandDark??"#ffffff","--button-text-color":r?.colors?.brandDark??"#000000","--button-text-color-dark":r?.colors?.brand??"#000000"};return ht(()=>{if(c==null||c.length===0){window.location.href=o??"/panel/login";return}},[]),ht(()=>{if(c==null||c.length===0){window.location.href=o??"/panel/login";return}},[s]),ht(()=>{if(typeof window>"u"||window.parent!==window||!c)return;let E=Je(window.location.search);E&&Ze(E);let Z=E??Le();Z&&(window.location.href=De(Z,c))},[c]),se(ot,{value:d,children:Mr("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:[se(Cr,{activeScreen:s,setActiveScreen:k,setParams:B,styles:ce,theme:r,logout:y}),Mr("main",{className:"flex h-[calc(100vh-80px)] flex-col overflow-y-auto w-full p-5 md:h-screen",children:[s==="products"&&se(vr,{projectID:a??"",accessToken:c,loginURL:o??"/panel/login",styles:ce,activeScreen:s,params:f,setParams:b,openCourse:A}),s==="course"&&f.course&&c&&se(Wt,{accessId:f.course,accessToken:c,theme:r,itemId:f.item,onItemChange:E=>b({item:E}),onBack:J}),s==="notifications"&&se(Zn,{}),s==="plans"&&se(or,{projectID:a??""}),s==="orders"&&se(tr,{projectID:a??"",accessToken:c??"",openOrderDetails:T}),s==="order-details"&&f.orderId&&se(Zt,{orderID:f.orderId,onBack:j}),(s==="returns"||s==="return-details")&&c&&se($t,{projectID:a??"",host:i,accessToken:c,loginURL:o??"/panel/login",appearance:Wn(e,r?.colors?.brand),texts:t,screen:s,params:f,setParams:b,setActiveScreen:k}),s==="profile"&&se(Ir,{email:l,logout:y})]})]})})},Ya=Za;import{create as me}from"@bufbuild/protobuf";import{QueryClient as gi,QueryClientProvider as yi}from"@tanstack/react-query";import{createContext as hi,useContext as Pi,useEffect as Vr,useState as bi}from"react";import{createClient as Qa}from"@connectrpc/connect";import{createConnectTransport as Xa}from"@connectrpc/connect-web";var de;(a=>{function e(r){return Qa(pn,n(r))}a.get=e;let t=new Map;function n(r){let o=t.get(r);return o==null&&(o=Xa({useBinaryFormat:!0,baseUrl:r+"/api/rpc",interceptors:[mn]}),t.set(r,o)),o}})(de||={});import S from"zod";import W from"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=W.object({event:W.enum(["purchase","addToCart","customizeProduct","viewCart","removeFromCart","initiateCheckout","lead"]),step:W.string().optional(),value:W.number().optional(),currency:W.string().optional(),content_name:W.string().optional(),items:W.array(W.object({id:W.string(),name:W.string(),price:W.number().default(0),currency:W.string().default("PLN"),quantity:W.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=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,n=e.items?.map(o=>({item_id:o.id,item_name:o.name||o.id,price: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=e.value??e.items?.reduce((o,i)=>o+(i.price||0)*(i.quantity||1),0)??0,n=e.items?.map(o=>({content_id:o.id,content_type:"product",content_name:o.name||o.id,quantity:o.quantity||1,price: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=e.locale??L();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:l.description??""})),defaultSelectedOptionId:r.selectedDeliveryMethod}:void 0,merchantInfo:{merchantId:n.merchantId+"",merchantName:n.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:fe("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,r.selectedDeliveryMethod??(r.methods.length>0?r.methods[0].id:void 0),a.couponCode,r.couponValue,fe("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=l.details.pricing?.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`${H}/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 t?.find(n=>n.id===e||(n.variants?.some(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=e?.trim();if(!(n==null||n.length===0))try{let a=new URL(n,t);return a.protocol!=="http:"&&a.protocol!=="https:"?void 0:a.href}catch{return}}import{create as ii}from"zustand";var je=ii(e=>({isCartVisible:!1,notice:void 0,setNotice:t=>e(n=>({...n,notice:t})),numberOfProductsInCart:0,showCart:()=>e(t=>({...t,isCartVisible:!0})),hideCart:()=>e(t=>({...t,isCartVisible:!1})),setNumberOfProductsInCart:t=>e(n=>({...n,numberOfProductsInCart:t}))}));import{createContext as si,useContext as Qt,useMemo as Fr}from"react";import{jsx as di}from"react/jsx-runtime";var Pt=si({});function Kl({texts:e,locale:t,children:n}){let a=Fr(()=>({texts:e,locale:t}),[e,t]);return di(Pt.Provider,{value:a,children:n})}function qr(){return Qt(Pt)}function Wl(e){let{texts:t,locale:n}=Qt(Pt);return fe(e,n??L(),t)}function Vl(){let{texts:e,locale:t}=Qt(Pt),n=t??L();return Fr(()=>a=>fe(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,(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 a?.key===o&&i-a.at<n?Promise.reject(new Error("pending order was asked about recently")):(a={key:o,at:i},e(r))}}function 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{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{return!1}}function mi(e,t=Date.now(),n={}){if(ui(e.url))return;let a=li(e.url),r=Br(e.orderId)??a?.orderId,o=Br(e.projectId)??a?.projectId;if(!(r==null||o==null))return{orderId:r,projectId:o,...n.cartProjectId!=null?{cartProjectId:n.cartProjectId}:{},lines:n.lines??[],ts:t}}function 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{return}}function pi(e,t=bt()){try{return t?.setItem(en,JSON.stringify(e)),t!=null}catch{return!1}}function $r(e=bt()){try{let t=e?.getItem(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 c?.id=="string"&&typeof c.quantity=="number"):[],ts:i}}}catch{}Xt(e)}function Xt(e=bt()){try{e?.removeItem(en)}catch{}}function Kr(e){let t=e.details?.status??fi(e.details?.$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(t?.no===3&&t.wireType===2&&t.data instanceof Uint8Array){let n=0,a=0;for(let r=0;a<t.data.length&&r<35;r+=7){let o=t.data[a++];if(n|=(o&127)<<r,!(o&128))break}if(a+n!==t.data.length)return;try{return new TextDecoder().decode(t.data.subarray(a))}catch{return}}}}async function Wr(e){let t=e.storage??bt(),n=$r(t);if(n==null)return"none";if((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{return"pending"}let o=$r(t);if(o?.orderId!==n.orderId||o.ts!==n.ts)return"pending";if(r==="paid"||r==="placed"){try{await e.removeLines(n.lines)}catch{return"pending"}return Xt(t),"paid"}return"pending"}import{Fragment as Di,jsx as nn}from"react/jsx-runtime";var vi="__m_a",Xr=hi(void 0),on=void 0;function Cu(e){Ot({projectID:e}),on=e,typeof window<"u"&&Ge([window.location.origin])}function qe(){return on??document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-id")??void 0}function ki(){return document.querySelector('script[data-id][data-name="internal-cart"]')?.getAttribute("data-custom-host")??void 0}var wi=({children:e,locale:t})=>{let[n]=bi(()=>new gi),a=qr();Vr(()=>{Fe()},[]);let r=qe();if(Vr(()=>{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 nn(Di,{});let o=sn(r,t??a.locale,a.texts);return nn(yi,{client:n,children:nn(Xr.Provider,{value:o,children:e})})},tn,xi=Gr(async e=>Kr(await de.get(H).getOrder({id:e.orderId,projectId:e.projectId})));function Nu(){let{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}=R()??kt;return{country:e,couponCode:t,selectedDeliveryMethod:n,postalCode:a}}function Iu(){return(R()?.products??[]).map(e=>({id:e.id,quantity:e.quantity}))}function Ci(e){let t=R();V({...t,products:Hr(t?.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=[];t?.items!=null&&t.items.length>0?n=t.items:n=R()?.products??[];let a=Array.from(new Set(n.map(i=>i.productID)));if(a.length===0)return[];let r=new URLSearchParams;r.set("ids",a.join(",")),r.set("locale",t?.locale??L());let o;try{let i=await fetch(Rt(_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=()=>{let e=Pi(Xr);if(e===void 0)throw new Error("useCartProvider must be used within a CartProvider");return e},Ru=wi,Ii=S.object({isAvailable:S.boolean(),merchantId:S.string(),merchantName:S.string(),gateway:S.string(),gatewayId:S.string()}),Si=S.object({id:S.string(),productID:S.string(),quantity:S.number(),priceVersion:S.string().optional(),metadata:S.record(S.string(),S.string().optional()).optional(),url:S.string().optional()}),Ri=S.object({country:S.string().optional(),couponCode:S.string().optional(),selectedDeliveryMethod:S.string().optional(),postalCode:S.string().optional(),email:S.string().optional(),products:S.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{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:n.find(i=>i.productID===o.productID)?.details?.pricing?.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:o.name??"",price:o.price??0,quantity:o.quantity,currency: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=a?.details?.pricing?.effectivePrice??a?.details?.price??n.price,o=a?.details?.currency??n.currency;if(r==null||o==null)continue;let i=a?.catalogProductID??n.productID;(n.analytics??fn()).track("add_to_cart",{qty:n.quantity,value_minor:Math.round(r*n.quantity),currency:o},{product_id:i,variant_id:i!==n.productID?n.productID:null})}catch{}}function Zr(e){let t=R(),n={...t,products:t?.products?.filter(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=r.metadata?.[o];i!=null&&(a[o]=i)}),a),{});return{items:e.products.map(a=>({id:a.productID,quantity:a.quantity,priceVersion:a.priceVersion})),askForNote:!0,countries:e.country?[e.country]:void 0,metadata:n,locale:t}}var sn=(e,t=L(),n)=>{let a=ki();return a!=null&&gn(a),{async checkIfApplePayIsAvailable(){if(typeof window>"u"||typeof document>"u"||!("ApplePaySession"in window))return!1;try{return(await de.get(H).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(o?.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(H).getPreOrderDetails({items:d.map(y=>me(rt,{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=>y.details?.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=R()?.country,V(r),Fe()},async getAvailableCountries(){let r=await fetch(Rt(_e(e,"/countries")),{method:"GET"});if(r.status!=200)return[];try{return S.array(S.object({name:S.string(),code:S.string()})).parse(await r.json())}catch(o){return F(o.toString(),"internal")}},async getCountry(){let r=R()?.country;if(r==null){r="PL";let o=R();o.country=r,V(o)}return r},async getNumberOfElementsInCart(){return R()?.products?.reduce((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=o.products?.map(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");r?.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: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(H).getPreOrderDetails({items:r.items.map(d=>me(rt,{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=r.shippingContact?.givenName;r.shippingContact?.familyName!=null?d+=" "+r.shippingContact?.familyName:r.billingContact?.familyName!=null&&(d+=" "+r.billingContact?.familyName);let c={},l=vt();l!=null&&(c.ref=l);let p=await de.get(H).authorizeOneClickPayment({gateway:0,paymentData:JSON.stringify(r.token.paymentData),paymentMethod:JSON.stringify(r.token.paymentMethod),transactionIdentifier:r.token.transactionIdentifier,order:me(Lt,{items:i.map(y=>({id:y.productID,quantity:y.quantity})),couponCode:o.couponCode,email:r.shippingContact?.emailAddress??r.billingContact?.emailAddress??o.email??void 0,phone:r.shippingContact?.phoneNumber??r.billingContact?.phoneNumber??void 0,selectedDeliveryMethod:o.selectedDeliveryMethod,postCode:o.postalCode,projectId:e}),shippingAddress:me(Tt,{line1:r.shippingContact?.addressLines?.[0]??"",city:r.shippingContact?.locality??"",country:r.shippingContact?.countryCode??"",zipCode:r.shippingContact?.postalCode??"",name:d}),billingAddress:me(At,{name:r.billingContact?.givenName??" "+(r.billingContact?.familyName??""),line1:r.billingContact?.addressLines?.[0]??"",city:r.billingContact?.locality??"",country:r.billingContact?.countryCode??"",zipCode:r.billingContact?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess: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=r.paymentData.shippingAddress?.name,c={},l=vt();l!=null&&(c.ref=l);let p=await de.get(H).authorizeOneClickPayment({gateway:1,paymentData:r.paymentData.paymentMethodData.tokenizationData.token,paymentMethod:r.paymentData.paymentMethodData.type,transactionIdentifier:"",order:me(Lt,{items:i.map(y=>({id:y.productID,quantity:y.quantity})),couponCode:o.couponCode,email:r.paymentData.email??void 0,phone:r.paymentData.shippingAddress?.phoneNumber??void 0,selectedDeliveryMethod:r.paymentData.shippingOptionData?.id??o.selectedDeliveryMethod,postCode:r.paymentData.shippingAddress?.postalCode,projectId:e}),shippingAddress:me(Tt,{line1:r.paymentData.shippingAddress?.address1??"",city:r.paymentData.shippingAddress?.locality??"",country:r.paymentData.shippingAddress?.countryCode??"",zipCode:r.paymentData.shippingAddress?.postalCode??"",name:d}),billingAddress:me(At,{name:r.paymentData.paymentMethodData.info?.billingAddress?.name,line1:r.paymentData.paymentMethodData.info?.billingAddress?.address1??"",city:r.paymentData.paymentMethodData.info?.billingAddress?.locality??"",country:r.paymentData.paymentMethodData.info?.billingAddress?.countryCode??"",zipCode:r.paymentData.paymentMethodData.info?.billingAddress?.postalCode??""}),metadata:Object.keys(c).length>0?JSON.stringify(c):void 0});return{isSuccess: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(H).getPreOrderDetails({items:i.map(l=>me(rt,{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*(l.details?.pricing?.effectivePrice??l.details?.price??0)/100,2)}`,label:l.details?.name+" - "+l.quantity,type:"final"}));if(d.selectedDeliveryMethod!=null){let l=d.methods.find(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((d.totalAmount??0)/100,2)}`,label:fe("paymentForCart",t,n),type:"final"},shippingMethods:d.methods.map(l=>({amount:`${U(l.amount/100,2)}`,detail:l.description??"",identifier:l.id,label:l.name,dateComponentsRange:{startDateComponents:{days:l.minDays??1,hours:0,months:0,years:0},endDateComponents:{days:l.maxDays??14,hours:0,months:0,years:0}}})),lineItems:c,currencyCode:d.currency||i[0]?.details?.currency||"PLN"}}}};async function Ai(e){let t=R();if(t.googlePayConfig?.isAvailable!=!0){let n=await de.get(H).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=t.variants?.findIndex(r=>r.id===e);if(a!=null&&a!=-1){let r=t.variants[a];return{...t,availableQuantity:r.availableQuantity,isDeliverable:r.isDeliverable,images:r.images??t.images,name:t.name+" "+r.name,baseName:t.name,variantName:r.name,price:r.price,currency:r.currency,pricing:r.pricing}}return t}let n=t.variants?.find(a=>a.id===e);return n==null?t:{...t,id:n.id,name:t.name+" "+n.name,baseName:t.name,variantName:n.name,price:n.price,currency:n.currency,pricing:n.pricing,metadata:t.metadata,availableQuantity:n.availableQuantity,isDeliverable:n.isDeliverable,images:n.images??t.images}}function Fe(){let e=R(),t=0;if(e==null){je.setState(n=>({...n,numberOfProductsInCart:t}));return}t=e.products?.reduce((n,a)=>n+a.quantity,0)??0,je.setState(n=>({...n,numberOfProductsInCart:t}))}var Ei=200,Mi="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: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{}return{message:dn(e)}}function Bi(e){let t;try{t=JSON.parse(e)}catch{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: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=e.data?.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(()=>a?.abort(),n);try{let o=await fetch(e,{method:"POST",headers:t.headers,body:t.body,signal:a?.signal});return o.ok?Gi(await o.json()):null}catch{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||={});async function oo(e){try{return await e.text()}catch{return""}}function ao(e,t){return t=an(t),t.locale??=L(),{headers:{...St,...Et(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={...St,...Et(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??=L();let r=await fetch(H+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}export{de as a,ye as b,xe as c,Ce as d,he as e,Fn as f,Je as g,Ze as h,Le as i,De as j,Io as k,Jn as l,Zt as m,Ya as n,U as o,Or as p,Yt as q,ke as r,Mi as s,Eu as t,Ou as u,Uu as v,_u as w,je as x,Ki as y,Qr as z,rn as A,Wu as B,vt as C,an as D,Kl as E,Wl as F,Vl as G,Yl as H,vi as I,on as J,Cu as K,qe as L,Nu as M,Iu as N,Ni as O,Su as P,Ru as Q,sn as R};
|
|
4
|
+
//# sourceMappingURL=chunk-2NL5FCXC.mjs.map
|