bitsnap-react 1.22.0 → 1.23.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 +20 -0
- package/dist/BitsnapCart-GK3MQGP7.js +2 -0
- package/dist/BitsnapCart-GK3MQGP7.js.map +1 -0
- package/dist/BitsnapCart-ZC6LMXLO.mjs +2 -0
- package/dist/CartProvider-FJDBDV4N.js +2 -0
- package/dist/CartProvider-FJDBDV4N.js.map +1 -0
- package/dist/{CartProvider-YUV2Q523.mjs → CartProvider-P7BZVK2M.mjs} +2 -2
- package/dist/PanelModelFiles-EKQRLF46.js.map +1 -1
- package/dist/analytics.js +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/analytics.mjs +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/chat.js +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/chat.mjs +1 -1
- package/dist/{chunk-SAKZOHU7.js → chunk-2CL4B4KM.js} +2 -2
- package/dist/chunk-2CL4B4KM.js.map +1 -0
- package/dist/chunk-2D2TQK3R.js +2 -0
- package/dist/chunk-2D2TQK3R.js.map +1 -0
- package/dist/{chunk-C2AJ5B32.mjs → chunk-4AU5SEHU.mjs} +2 -2
- package/dist/chunk-6Q3VGPSF.js.map +1 -1
- package/dist/{chunk-ZFZR3CI5.js → chunk-7GSQV4NW.js} +2 -2
- package/dist/chunk-7GSQV4NW.js.map +1 -0
- package/dist/{chunk-WYRECFVW.js → chunk-CA5EJJW7.js} +2 -2
- package/dist/chunk-CA5EJJW7.js.map +1 -0
- package/dist/{chunk-U37ZH4YJ.js → chunk-DCICRN6G.js} +2 -2
- package/dist/chunk-DCICRN6G.js.map +1 -0
- package/dist/{chunk-QQSCVPOG.mjs → chunk-EVV25IKM.mjs} +2 -2
- package/dist/{chunk-QQSCVPOG.mjs.map → chunk-EVV25IKM.mjs.map} +1 -1
- package/dist/{chunk-MBSXTB6G.js → chunk-EVX5SQL2.js} +2 -2
- package/dist/chunk-EVX5SQL2.js.map +1 -0
- package/dist/chunk-FVZ4W7QG.js +5 -0
- package/dist/chunk-FVZ4W7QG.js.map +1 -0
- package/dist/chunk-GMQYQTUM.mjs +2 -0
- package/dist/chunk-GMQYQTUM.mjs.map +1 -0
- package/dist/{chunk-35ZQU353.js → chunk-I6QN3T6K.js} +2 -2
- package/dist/chunk-I6QN3T6K.js.map +1 -0
- package/dist/chunk-ILYJCT5S.js +2 -0
- package/dist/chunk-ILYJCT5S.js.map +1 -0
- package/dist/{chunk-QJOMFK4X.mjs → chunk-JRSQ2IGQ.mjs} +2 -2
- package/dist/chunk-JSDGZ4NY.js.map +1 -1
- package/dist/chunk-KOYBZORL.js.map +1 -1
- package/dist/{chunk-5MXBUGY3.mjs → chunk-M6QFQ3DR.mjs} +2 -2
- package/dist/chunk-MDAFPGPA.js.map +1 -1
- package/dist/{chunk-KFY6IOAA.js → chunk-MY6BPCRV.js} +2 -2
- package/dist/{chunk-ZFUE3AX5.mjs.map → chunk-MY6BPCRV.js.map} +1 -1
- package/dist/{chunk-QCIETNFZ.mjs → chunk-NMXTTD5M.mjs} +2 -2
- package/dist/chunk-PFKZ7KUU.js.map +1 -1
- package/dist/chunk-Q337IQNA.js.map +1 -1
- package/dist/{chunk-IVB3E4V3.mjs → chunk-RA6M3TJ3.mjs} +2 -2
- package/dist/{chunk-NCCP2UDM.mjs → chunk-SKQJESEB.mjs} +2 -2
- package/dist/chunk-STDV54FL.mjs +2 -0
- package/dist/chunk-STDV54FL.mjs.map +1 -0
- package/dist/{chunk-JS3KK56H.js → chunk-SZLSKIYU.js} +2 -2
- package/dist/chunk-SZLSKIYU.js.map +1 -0
- package/dist/chunk-W3RGQYPD.js.map +1 -1
- package/dist/{chunk-TVZLDLAV.mjs → chunk-W4EUYPJ3.mjs} +2 -2
- package/dist/chunk-Z3YOJ6NZ.js.map +1 -1
- package/dist/chunk-ZMEWUEZJ.mjs +5 -0
- package/dist/chunk-ZMEWUEZJ.mjs.map +1 -0
- package/dist/consent.js.map +1 -1
- package/dist/course.js +1 -1
- package/dist/course.js.map +1 -1
- package/dist/course.mjs +1 -1
- package/dist/embed/analytics.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/methods-IEHZTZEY.mjs +2 -0
- package/dist/methods-S4KBRY2I.js +2 -0
- package/dist/methods-S4KBRY2I.js.map +1 -0
- package/dist/model-files-client-P4PORZJ6.js.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/dist/viewer3d.js.map +1 -1
- package/dist/viewer3d.mjs +1 -1
- package/package.json +2 -2
- package/dist/BitsnapCart-AINUJQVF.mjs +0 -2
- package/dist/BitsnapCart-GP2UJSG4.js +0 -2
- package/dist/BitsnapCart-GP2UJSG4.js.map +0 -1
- package/dist/CartProvider-HTKGBPVA.js +0 -2
- package/dist/CartProvider-HTKGBPVA.js.map +0 -1
- package/dist/chunk-35ZQU353.js.map +0 -1
- package/dist/chunk-3TUL63IC.js +0 -2
- package/dist/chunk-3TUL63IC.js.map +0 -1
- package/dist/chunk-4JR74NXR.js +0 -2
- package/dist/chunk-4JR74NXR.js.map +0 -1
- package/dist/chunk-GLKBCVNH.mjs +0 -2
- package/dist/chunk-GLKBCVNH.mjs.map +0 -1
- package/dist/chunk-JS3KK56H.js.map +0 -1
- package/dist/chunk-KFY6IOAA.js.map +0 -1
- package/dist/chunk-MBSXTB6G.js.map +0 -1
- package/dist/chunk-QJBQ45R6.mjs +0 -5
- package/dist/chunk-QJBQ45R6.mjs.map +0 -1
- package/dist/chunk-SAKZOHU7.js.map +0 -1
- package/dist/chunk-SZNTXRFD.js +0 -5
- package/dist/chunk-SZNTXRFD.js.map +0 -1
- package/dist/chunk-U37ZH4YJ.js.map +0 -1
- package/dist/chunk-WYRECFVW.js.map +0 -1
- package/dist/chunk-ZFUE3AX5.mjs +0 -2
- package/dist/chunk-ZFZR3CI5.js.map +0 -1
- package/dist/methods-4Q37ITIM.js +0 -2
- package/dist/methods-4Q37ITIM.js.map +0 -1
- package/dist/methods-JLVRTNPE.mjs +0 -2
- /package/dist/{BitsnapCart-AINUJQVF.mjs.map → BitsnapCart-ZC6LMXLO.mjs.map} +0 -0
- /package/dist/{CartProvider-YUV2Q523.mjs.map → CartProvider-P7BZVK2M.mjs.map} +0 -0
- /package/dist/{chunk-C2AJ5B32.mjs.map → chunk-4AU5SEHU.mjs.map} +0 -0
- /package/dist/{chunk-QJOMFK4X.mjs.map → chunk-JRSQ2IGQ.mjs.map} +0 -0
- /package/dist/{chunk-5MXBUGY3.mjs.map → chunk-M6QFQ3DR.mjs.map} +0 -0
- /package/dist/{chunk-QCIETNFZ.mjs.map → chunk-NMXTTD5M.mjs.map} +0 -0
- /package/dist/{chunk-IVB3E4V3.mjs.map → chunk-RA6M3TJ3.mjs.map} +0 -0
- /package/dist/{chunk-NCCP2UDM.mjs.map → chunk-SKQJESEB.mjs.map} +0 -0
- /package/dist/{chunk-TVZLDLAV.mjs.map → chunk-W4EUYPJ3.mjs.map} +0 -0
- /package/dist/{methods-JLVRTNPE.mjs.map → methods-IEHZTZEY.mjs.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as at,B as kn,C as Ve,D as Ae,E as Lo,J as $e,K as ce,L as xt,M as _o,O as it,P as st,Q as lt,R as Uo,S as zt,T as wn,U as Oo,V as Mo,W as Bo,X as jo,Z as In,a as jt,b as et,c as tt,d as nt,e as ot,f as So,l as Q,n as Ro,o as Ao,p as Pn,q as Do,r as Ke,s as xn,y as rt,z}from"./chunk-QJBQ45R6.mjs";import{a as bo,b as Co,c as Po,e as de,f as xo,g as ko,h as wo,j as Io}from"./chunk-TVZLDLAV.mjs";import{a as To,b as No}from"./chunk-KOVKUJAW.mjs";import{a as vn,e as ye,f as qt,g as Re,j as bn,k as $,l as Cn,o as Eo}from"./chunk-ZFUE3AX5.mjs";import{a as u}from"./chunk-5R6AGO3Z.mjs";import{a as yo,e as ue}from"./chunk-C2AJ5B32.mjs";import{l as Pe,m as xe,n as me,q as ho}from"./chunk-QQSCVPOG.mjs";import{c as vo,e as hn,f as Ne}from"./chunk-OFPRIENJ.mjs";import{useEffect as Ut,useId as $s,useRef as Qs}from"react";import ie from"zod";import{useAutoAnimate as zs}from"@formkit/auto-animate/react";import*as Ee from"@radix-ui/react-dialog";import{useCallback as Gs,useRef as Fs,useState as Ws}from"react";import{createPortal as Hs}from"react-dom";import{createContext as La,useContext as _a,useMemo as Ua}from"react";var Ta=["root","overlay","panel","header","title","closeButton","productList","product","productImage","productName","productPrice","quantityControl","quantityInput","quantityButton","removeButton","summary","totalLabel","totalValue","deliveryText","summaryNote","countryLabel","countryTrigger","countryDropdown","countrySearch","countryOption","paymentButtons","paymentMethods","paymentMethodOption","checkoutButton","emptyState","error","skeleton"],Na={fontFamily:"--bitsnap-checkout-font-family",fontSize:"--bitsnap-checkout-font-size",background:"--bitsnap-checkout-background",surface:"--bitsnap-checkout-surface",foreground:"--bitsnap-checkout-foreground",mutedForeground:"--bitsnap-checkout-muted-foreground",border:"--bitsnap-checkout-border",buttonBackground:"--bitsnap-checkout-button-background",buttonForeground:"--bitsnap-checkout-button-foreground",buttonHoverBackground:"--bitsnap-checkout-button-hover-background",hoverSurface:"--bitsnap-checkout-hover-surface",focusRing:"--bitsnap-checkout-focus-ring",error:"--bitsnap-checkout-error",overlay:"--bitsnap-checkout-overlay",radius:"--bitsnap-checkout-radius"},Ra={dark:{},light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#e4e4e7",focusRing:"#71717a",error:"#dc2626",overlay:"rgb(0 0 0 / 0.35)"}},Aa=[{token:"background",variable:"--background"},{token:"foreground",variable:"--foreground"},{token:"surface",variable:"--card"},{token:"surface",variable:"--popover"},{token:"foreground",variable:"--popover-foreground"},{token:"mutedForeground",variable:"--muted-foreground"},{token:"border",variable:"--border"},{token:"border",variable:"--input"},{token:"focusRing",variable:"--ring"},{token:"error",variable:"--destructive"},{token:"radius",variable:"--radius"}];function Da(e){return{"--popover":e.surface??"var(--color-neutral-800)","--popover-foreground":e.foreground??"var(--color-neutral-200)"}}function Sn(e){let t=To(e,{defaultTheme:"dark",presets:Ra,variables:Na,shadcnVariables:Aa});return{theme:t.theme,isCustomized:t.isCustomized,tokens:t.tokens,elements:t.elements,boundaryClassName:t.theme,boundaryStyle:t.boundaryStyle,dropdownStyle:Da(t.tokens)}}function qo(e,t){return No(e.elements,t)}import{jsx as Oa}from"react/jsx-runtime";var zo=La(Sn());function ct({appearance:e,children:t}){let n=Ua(()=>Sn(e),[e]);return Oa(zo.Provider,{value:n,children:t})}function kt(){return _a(zo)}function L(e){let t=kt();return qo(t,e)??{}}import{useAutoAnimate as Ms}from"@formkit/auto-animate/react";import ee from"react";import{useEffect as Ga,useState as Fa}from"react";import*as G from"@radix-ui/react-select";import{CheckIcon as Ma,ChevronDownIcon as Go,ChevronUpIcon as Ba}from"lucide-react";import{jsx as te,jsxs as En}from"react/jsx-runtime";function Fo({...e}){return te(G.Root,{"data-slot":"select",...e})}function Wo({...e}){return te(G.Value,{"data-slot":"select-value",...e})}var ja="border-input dark:bg-input/30 dark:hover:bg-input/50 bg-transparent";function Ho({className:e,size:t="default",theme:n="default",children:o,...r}){return En(G.Trigger,{"data-slot":"select-trigger","data-size":t,className:u("data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-fit items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n==="bare"?"":ja,e),...r,children:[o,te(G.Icon,{asChild:!0,children:te(Go,{className:"size-4 opacity-50"})})]})}function Ko({className:e,children:t,position:n="popper",align:o="center",...r}){return te(G.Portal,{children:En(G.Content,{"data-slot":"select-content",className:u("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:o,...r,children:[te(qa,{}),te(G.Viewport,{className:u("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),te(za,{})]})})}function Vo({className:e,children:t,...n}){return En(G.Item,{"data-slot":"select-item",className:u("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[te("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:te(G.ItemIndicator,{children:te(Ma,{className:"size-4"})})}),te(G.ItemText,{children:t})]})}function qa({className:e,...t}){return te(G.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:u("flex cursor-default items-center justify-center py-1",e),...t,children:te(Ba,{className:"size-4"})})}function za({className:e,...t}){return te(G.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:u("flex cursor-default items-center justify-center py-1",e),...t,children:te(Go,{className:"size-4"})})}import{jsx as De,jsxs as Gt}from"react/jsx-runtime";function Wa({id:e,open:t,disabled:n=!1,onToggle:o,onChange:r,selectedValue:a,countries:i}){let[l,c]=Fa(""),{isCustomized:p,boundaryClassName:s,boundaryStyle:y,dropdownStyle:v}=kt(),m=L("countryTrigger"),g=L("countryDropdown"),d=L("countrySearch"),I=L("countryOption"),R=z("searchCountry"),h=z("noCountriesFound");Ga(()=>{a==null&&i.length>0&&r(i[0].code)},[]);let b=i.filter(x=>x.name.toLowerCase().startsWith(l.toLowerCase())),A=i.find(x=>x.code===a);return Gt(Fo,{value:a,onValueChange:x=>{r(x),c("")},open:t,onOpenChange:x=>{x!==t&&o(),x||c("")},disabled:n,children:[De(Ho,{"data-bitsnap-checkout-slot":"countryTrigger",theme:"bare",className:u(n?"bg-neutral-100 dark:bg-neutral-800 dark:border-neutral-700":"","w-full rounded-md",m.className),style:m.style,children:De(Wo,{children:A&&Gt("span",{className:"truncate flex items-center",children:[De("img",{alt:a,src:`https://purecatamphetamine.github.io/country-flag-icons/3x2/${a}.svg`,className:"inline mr-2 h-4 rounded-sm"}),A.name]})})}),Gt(Ko,{"data-bitsnap-checkout":p?"dropdown":void 0,"data-bitsnap-checkout-slot":p?"countryDropdown":void 0,className:u(p?"bitsnap-react":"",s,"w-full max-h-80 max-w-[350px] z-[999999]",g.className),style:{...p?{...y,...v}:void 0,...g.style},position:"popper",children:[De("div",{"data-bitsnap-checkout-slot":"countrySearch",className:u("sticky top-0 z-10 p-1 border-b",d.className),style:d.style,children:De("input",{type:"search",name:"search",autoComplete:"off",className:"block w-full outline-none sm:text-body-regular bg-transparent rounded-md px-2 py-1.5",placeholder:R,"aria-label":R,value:l,onChange:x=>c(x.target.value),onClick:x=>x.stopPropagation(),onKeyDown:x=>x.stopPropagation()})}),De("div",{className:"max-h-64 overflow-y-auto",children:b.length===0?De("div",{className:"cursor-default select-none relative py-2 pl-3 pr-9 text-sm",children:h}):b.map(x=>Gt(Vo,{"data-bitsnap-checkout-slot":"countryOption",value:x.code,className:u("cursor-default select-none relative py-2 pl-3 pr-9 flex items-center transition",I.className),style:I.style,children:[De("img",{alt:x.code,src:`https://purecatamphetamine.github.io/country-flag-icons/3x2/${x.code}.svg`,className:"inline mr-2 h-4 rounded-sm"}),De("span",{className:"font-normal truncate",children:x.name})]},`${e}-${x.code}`))})]})]})}var $o=Wa;import{useEffect as Xa,useRef as Yo,useState as Jo}from"react";import{MinusIcon as Ya,PlusIcon as Za}from"lucide-react";import{Slot as hl}from"@radix-ui/react-slot";import{cva as Ha}from"class-variance-authority";import{jsx as Va}from"react/jsx-runtime";var Ka=Ha("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function Qo({className:e,orientation:t,...n}){return Va("div",{role:"group","data-slot":"button-group","data-orientation":t,className:u(Ka({orientation:t}),e),...n})}import{Fragment as $a,jsx as Ft,jsxs as Qa}from"react/jsx-runtime";function Xo({price:e,currency:t,pricing:n,quantity:o=1}){let r=z("lowestPrice30Days"),a=z("noPriceHistory"),i=n?.regularPrice??e,l=n?.effectivePrice??e,c=n?.discount?.status==="ACTIVE"&&l<i;return Ft("span",{children:c?Qa($a,{children:[Ft("span",{className:"mr-2 text-neutral-500 line-through",children:Ve(i*o,t)}),Ft("span",{className:"font-semibold text-red-700",children:Ve(l*o,t)}),Ft("span",{className:"mt-1 block text-xs text-neutral-600",children:n?.referencePrice.historyAvailable&&n.referencePrice.amount!=null?`${r} ${Ve(n.referencePrice.amount,t)}`:a})]}):Ve(l*o,t)})}function Wt(e){return Number.isFinite(e)?Math.min(99,Math.max(1,Math.trunc(e))):1}function Tn(e,t){let n=parseInt(e,10);return Number.isNaN(n)?t:Wt(n)}import{Fragment as ti,jsx as Z,jsxs as Ht}from"react/jsx-runtime";var Ja=({isNotAvailable:e,quantity:t,details:n,url:o,shouldUpdate:r})=>{let a=L("product"),i=L("productImage"),l=L("productName"),c=L("productPrice"),p=L("removeButton"),s=z("remove"),y=n.image_url??n.images?.[0],[v,m]=Jo(),g=y!=null&&y.length>0&&y!==v,d=n.baseName??n.name;return Ht("div",{"data-bitsnap-checkout-slot":"product","data-bitsnap-checkout-unavailable":e?"":void 0,className:u("flex items-center gap-3 mx-3",e?"outline outline-1 rounded-md m-1":"",a.className),style:a.style,children:[g&&Z(Zo,{url:o,tabIndex:-1,"aria-hidden":"true",className:"contents",children:Z("img",{"data-bitsnap-checkout-slot":"productImage",className:u("aspect-auto max-w-[30%] max-w-32 max-h-32 py-2 overflow-hidden",i.className),style:i.style,src:y,alt:"",onError:()=>m(y)})}),Ht("div",{className:"flex flex-col w-full",children:[Z("p",{"data-bitsnap-checkout-slot":"productName",className:u("font-medium",l.className),style:l.style,children:Z(Zo,{url:o,className:"text-inherit no-underline hover:underline",children:d})}),n.variantName!=null&&n.variantName.length>0&&Z("p",{className:"text-sm opacity-70",children:n.variantName}),Z("p",{"data-bitsnap-checkout-slot":"productPrice",className:u("text-sm",c.className),style:c.style,suppressHydrationWarning:!0,children:Z(Xo,{price:n.price,currency:n.currency,pricing:n.pricing,quantity:t})}),Ht("div",{className:"flex justify-between",children:[Z(ei,{className:"",quantity:t,shouldUpdate:r}),Z($,{"data-bitsnap-checkout-slot":"removeButton",type:"button",variant:"ghost",size:"sm",className:p.className,style:p.style,"aria-label":`${s}: ${n.name}`,onClick:()=>{Promise.resolve(r(0)).catch(()=>{})},children:s})]})]})]})},er=Ja,Zo=({url:e,children:t,...n})=>e==null?Z(ti,{children:t}):Z("a",{href:e,...n,children:t}),ei=({quantity:e,shouldUpdate:t,className:n})=>{let[o,r]=Jo(e.toString()),a=Yo(e),i=L("quantityControl"),l=L("quantityInput"),c=L("quantityButton"),p=z("quantity"),s=z("increaseQuantity"),y=z("decreaseQuantity"),v=Yo(e);v.current=e,Xa(()=>{a.current=e,r(e.toString())},[e]);function m(g){r(g.toString()),g!==a.current&&(a.current=g,Promise.resolve(t(g)).catch(()=>{a.current===g&&(a.current=v.current,r(v.current.toString()))}))}return Z("div",{"data-bitsnap-checkout-slot":"quantityControl",className:u("flex",n,i.className),style:i.style,children:Ht(Qo,{"aria-label":p,children:[Z($,{"data-bitsnap-checkout-slot":"quantityButton",type:"button",className:c.className,style:c.style,"aria-label":y,onClick:()=>m(Wt(a.current-1)),children:Z(Ya,{"aria-hidden":"true"})}),Z("input",{"data-bitsnap-checkout-slot":"quantityInput",className:u("w-8 bg-transparent text-center",l.className),style:l.style,value:o,"aria-label":p,inputMode:"numeric",pattern:"[0-9]*",onChange:g=>r(g.currentTarget.value),onBlur:g=>m(Tn(g.currentTarget.value,a.current)),onKeyDown:g=>{g.key==="Enter"&&m(Tn(g.currentTarget.value,a.current))},type:"text"}),Z($,{"data-bitsnap-checkout-slot":"quantityButton",type:"button",className:c.className,style:c.style,"aria-label":s,onClick:()=>m(Wt(a.current+1)),children:Z(Za,{"aria-hidden":"true"})})]})})};import{jsx as ni}from"react/jsx-runtime";function Nn({className:e,...t}){return ni("div",{"data-slot":"skeleton",className:"bg-neutral-700 animate-pulse rounded-md "+e,...t})}import tr from"apple-pay-button";function ke(){try{return ce()}catch{return}}import{useQuery as nr}from"@tanstack/react-query";import{jsx as Kt}from"react/jsx-runtime";var oi=tr.default??tr;function ri({style:e,buttonType:t,colorType:n,items:o,onClick:r}){let{checkIfApplePayIsAvailable:a,getApplePayPaymentRequest:i,completeApplePayPayment:l,setCountry:c,setCouponCodeIfPossible:p,setDeliveryMethod:s,setEmail:y,setPostalCode:v,clearCart:m,getApplePayPreview:g}=it(),d=xe(),I=z("paymentForCart"),{data:R}=nr({queryKey:["is-apple-pay-available"],queryFn:a}),h=o.map(S=>`${S.id}:${S.quantity}`).join(","),b=xt(),{data:A}=nr({queryKey:["apple-pay-preview",h,b.country??"",b.couponCode??"",b.selectedDeliveryMethod??"",b.postalCode??""],queryFn:()=>g({items:o.map(S=>({productID:S.id,quantity:S.quantity,metadata:S.metadata}))}),enabled:R===!0});if(R!=!0)return null;let x=A!=null&&!Q(A)?A:{countryCode:b.country||"PL",currencyCode:o[0]?.currency??"PLN",totalAmount:`${kn(o.reduce((S,T)=>S+T.price*T.quantity,0)/100,2)}`},E=o.map(S=>({productID:S.id,quantity:S.quantity,metadata:S.metadata}));async function D(){let S=!1,T=f=>{S||(S=!0,d.track("apple_pay_result",{outcome:f}))};d.track("apple_pay_clicked",{}),d.track("payment_method_selected",{gateway:"apple_pay",method:"apple_pay"}),Ae({event:"initiateCheckout",items:o.map(f=>({id:f.id,name:f.name,price:f.price,quantity:f.quantity,currency:x.currencyCode}))});let w=o.find(f=>f.isDeliverable===!0)!=null,C=new ApplePaySession(14,{countryCode:x.countryCode,merchantCapabilities:["supports3DS"],supportedNetworks:["visa","masterCard"],currencyCode:x.currencyCode,total:{amount:x.totalAmount,label:I,type:"pending"},lineItems:o.map(f=>({amount:`${kn(f.price*f.quantity/100,2)}`,label:f.name,type:"final"})),...w?{shippingMethods:[],supportsCouponCode:!0,requiredBillingContactFields:["name","email","postalAddress","phone"],requiredShippingContactFields:["name","email","postalAddress","phone"]}:{}});await r?.();let U=await i({expectedItems:E});if(Q(U)){console.error("Error creating ApplePaySession:",U.error),T("fail");return}C.oncancel=f=>{console.log("ApplePaySession cancelled",f),T("cancel")},C.onvalidatemerchant=async f=>{try{let k=await jt.get(ue).applePayValidateMerchant({validationUrl:f.validationURL,projectId:ce()});console.log("merchantSession",k.merchantSession),k.merchantSession.length>0?(console.log("completing merchant session"),C.completeMerchantValidation(JSON.parse(k.merchantSession))):C.abort()}catch{C.abort()}},C.onshippingmethodselected=async f=>{console.log("shipping method selected",f),d.track("delivery_method_selected",{method:f.shippingMethod.identifier}),await s(f.shippingMethod.identifier);let k=await i({expectedItems:E});if(console.log("apRequest",k),Q(k))throw C.abort(),new Error("Failed to get Apple Pay payment request");C.completeShippingMethodSelection({newTotal:k.total,newLineItems:k.lineItems,newShippingMethods:k.shippingMethods})},C.onshippingcontactselected=async f=>{try{f.shippingContact.countryCode!=null&&await c(f.shippingContact.countryCode),f.shippingContact.postalCode!=null&&await v(f.shippingContact.postalCode),f.shippingContact.phoneNumber!=null&&await y(f.shippingContact.emailAddress);let k=await i({expectedItems:E});if(Q(k))throw C.abort(),new Error("Failed to get Apple Pay payment request");console.log("apRequest",k),C.completeShippingContactSelection({newLineItems:k.lineItems,newTotal:k.total,newShippingMethods:k.shippingMethods})}catch(k){console.log("shipping contact selected error",k),C.abort()}},C.oncouponcodechanged=async f=>{try{console.log("coupon code changed",f);let k=await p(f.couponCode),X=await i({expectedItems:E});if(console.log("apRequest",X),Q(X))throw C.abort(),new Error("Failed to get Apple Pay payment request");C.completeCouponCodeChange({errors:Q(k)?[new ApplePayError("couponCodeInvalid")]:void 0,newTotal:X.total,newLineItems:X.lineItems,newShippingMethods:X.shippingMethods})}catch(k){console.log("coupon code changed error",k),C.abort()}},C.onpaymentauthorized=async f=>{d.track("payment_submitted",{gateway:"apple_pay",method:"apple_pay"});try{let k=await l({token:f.payment.token,billingContact:f.payment.billingContact,shippingContact:f.payment.shippingContact});if(Q(k)){console.log("apple pay error",k),T("fail"),C.completePayment({status:ApplePaySession.STATUS_FAILURE});return}k.redirectURL&&setTimeout(()=>{open(k.redirectURL,"_self")},2e3),T(k.isSuccess?"success":"fail"),C.completePayment({status:k.isSuccess?ApplePaySession.STATUS_SUCCESS:ApplePaySession.STATUS_FAILURE}),k.isSuccess&&m()}catch{T("fail"),C.completePayment({status:ApplePaySession.STATUS_FAILURE})}},C.begin()}return Kt(oi,{style:e,buttonStyle:n,type:t,onClick:D})}function ai(e){let t=me(ke(),e.analytics,"cart");return Kt(Pe,{value:t,children:Kt(st,{children:Kt(ri,{...e})})})}var Rn=ai;import ii from"@google-pay/button-react";import{useQuery as si,useMutation as li}from"@tanstack/react-query";import{Fragment as di,jsx as wt,jsxs as pi}from"react/jsx-runtime";function ci({items:e,style:t,buttonColor:n,buttonSizeMode:o,test:r}){let{getGooglePayConfiguration:a,completeGooglePayPayment:i,setCountry:l,setCouponCodeIfPossible:c,setDeliveryMethod:p,setEmail:s,setPostalCode:y,clearCart:v}=it(),m=xe(),{data:g}=si({queryKey:["get-google-pay-configuration",e.map(R=>R.id).join(",")],queryFn:()=>a({items:e.map(R=>({...R,id:void 0,productID:R.id}))})}),{mutateAsync:d,isPending:I}=li({mutationFn:i});return g==null||g.isAvailable!=!0?(console.log("google pay configuration is not available",g),null):pi(di,{children:[wt(ii,{buttonSizeMode:o,buttonColor:n,style:t,existingPaymentMethodRequired:!0,onClick:()=>m.track("payment_method_selected",{gateway:"google_pay",method:"google_pay"}),environment:r===!0?"TEST":"PRODUCTION",onPaymentDataChanged:async R=>{Ae({event:"initiateCheckout",items:e.map(b=>({id:b.id,name:b.name,price:b.price,quantity:b.quantity,currency:"PLN"}))}),console.log("payment data changed",R),R.shippingAddress?.postalCode!=null&&await y(R.shippingAddress?.postalCode),R.shippingAddress?.countryCode!=null&&await l(R.shippingAddress?.countryCode),R.shippingOptionData?.id!=null&&await p(R.shippingOptionData.id);let h=await a({items:[]});return console.log("PAYMENT DATA CHANGED CONFIG",h),h.isAvailable?{error:void 0,newShippingOptionParameters:h.config.shippingOptionParameters,newTransactionInfo:h.config.transactionInfo}:{error:void 0}},paymentRequest:g.config,onLoadPaymentData:async R=>{m.track("payment_submitted",{gateway:"google_pay",method:"google_pay"});try{let h=await d({paymentData:R});if(Q(h)){console.log("apple pay error",h);return}h.isSuccess&&v(),h.redirectURL&&open(h.redirectURL,"_self")}catch(h){console.warn("error completing google pay payment",h)}}}),I?wt(de,{}):null]})}function ui(e){let t=me(ke(),e.analytics,"cart");return wt(Pe,{value:t,children:wt(st,{children:wt(ci,{...e})})})}var An=ui;import{createElement as Ar,useCallback as mt,useEffect as Tt,useMemo as Dr,useRef as ft,useState as Gi}from"react";var mi="x-bitsnap-cart-token",or=new Set;function Dn(e,t,n){or.has(e)||(or.add(e),console.warn(t,n))}function fi(e,t,n){return`${e.replace(/\/+$/,"")}/api/integrations/${encodeURIComponent(t)}/public-commerce/express${n}`}async function It(e,t,n,o){let r=e.fetch??((a,i)=>globalThis.fetch(a,i));try{let a=await r(fi(e.host,e.projectID,t),{method:"POST",headers:{...yo,"Content-Type":"application/json",...o!=null?{[mi]:o}:{}},body:JSON.stringify(n),cache:"no-store",signal:e.signal}),i=await a.text().catch(()=>""),l;try{l=i.length>0?JSON.parse(i):void 0}catch{l=void 0}return{status:a.status,json:l,text:i}}catch(a){return{transportError:a}}}function we(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}function rr(e){return gi(e)?{ok:!1,code:"network",message:"aborted"}:{ok:!1,code:"network",message:"The server could not be reached."}}function gi(e){return typeof e=="object"&&e!=null&&e.name==="AbortError"}function ut(e){return e===404||e===405||e===501||e===502}function Ln(e,t){return typeof e=="string"&&e.length>0?e:t}async function ar(e,t){let n=await It(e,"/availability",t);if("transportError"in n){Dn(`availability:${e.host}:${e.projectID}`,"Bitsnap express availability is not reachable; express buttons stay hidden.",n.transportError);return}if(ut(n.status)||n.status!==200){Dn(`availability-status:${e.host}:${e.projectID}`,"Bitsnap express availability is not available on this backend; express buttons stay hidden.",n.status);return}let o=n.json;if(!we(o)||o.success!==!0||!we(o.providers)){Dn(`availability-shape:${e.host}:${e.projectID}`,"Bitsnap express availability returned an unknown shape; express buttons stay hidden.",void 0);return}return o}async function ir(e,t,n){let o=await It(e,"/cart",{...t,...n!=null?{cartId:n.cartId,expectedRevision:n.expectedRevision}:{}},n?.cartToken);if("transportError"in o)return{ok:!1,code:"internal",message:"The cart could not be saved."};let r=o.json;if(!we(r)||typeof r.success!="boolean")return{ok:!1,code:o.status===403?"cart-forbidden":"internal",message:"The cart endpoint returned an unknown answer."};if(r.success===!0){let a=r.snapshot;return a==null||typeof a.revision!="number"?{ok:!1,code:"internal",message:"The cart endpoint returned no snapshot."}:{ok:!0,...typeof r.cartToken=="string"?{cartToken:r.cartToken}:{},snapshot:a}}return{ok:!1,code:Ln(r.code,"internal"),message:typeof r.message=="string"?r.message:"The cart could not be saved.",...typeof r.currentRevision=="number"?{currentRevision:r.currentRevision}:{},...we(r.snapshot)?{snapshot:r.snapshot}:{},...Array.isArray(r.conflicts)?{conflicts:r.conflicts}:{}}}function yi(e){let t=Ln(e.code,"internal");return{code:t,message:Ln(e.message,t)}}async function sr(e,t,n){let o=await It(e,"/cart-snapshot",{cartId:t},n);if("transportError"in o)return rr(o.transportError);let r=o.json;return o.status===404?{ok:!1,code:"cart-not-found",message:"cart-not-found",status:404}:o.status===403?{ok:!1,code:"cart-forbidden",message:"cart-forbidden",status:403}:!we(r)||r.success!==!0||!we(r.snapshot)?{ok:!1,code:ut(o.status)?"not-implemented":"invalid-response",message:"The cart snapshot is not available.",status:o.status}:{ok:!0,value:r.snapshot}}async function lr(e,t,n){let r=await It(e,t==="inpostPay"?"/inpost/start":t==="revolutPay"?"/revolut/start":"/adyen/start",{cartId:n.cartId,...n.returnUrl!=null?{returnUrl:n.returnUrl}:{},...n.cancelUrl!=null?{cancelUrl:n.cancelUrl}:{},...n.embedOrigin!=null?{embedOrigin:n.embedOrigin}:{}},n.cartToken);if("transportError"in r)return rr(r.transportError);let a=r.json;if(!we(a)||typeof a.success!="boolean")return{ok:!1,code:ut(r.status)?"not-implemented":"invalid-response",message:"The provider start is not available.",status:r.status};if(a.success===!0)return typeof a.redirectUrl!="string"||typeof a.providerOrderId!="string"?{ok:!1,code:"invalid-response",message:"The provider start returned no redirect.",status:r.status}:{ok:!0,value:{ok:!0,provider:t,redirectUrl:a.redirectUrl,providerOrderId:a.providerOrderId,...we(a.publicConfig)?{publicConfig:a.publicConfig}:{},cartRevision:typeof a.cartRevision=="number"?a.cartRevision:0}};let i=a;return{ok:!1,code:ut(r.status)?"not-implemented":i.code,message:typeof i.message=="string"?i.message:"The provider start failed.",status:r.status}}function cr(e,t,n){return dr(e,"/revolut/status",t,n)}function ur(e,t,n){return dr(e,"/inpost/status",t,n)}async function dr(e,t,n,o){let r=await It(e,t,{cartId:n},o);if("transportError"in r)return{ok:!1,code:"network",message:"The status is not available."};let a=r.json;return r.status===401||r.status===403?{ok:!1,code:"cart-forbidden",message:"cart-forbidden"}:r.status===404?{ok:!1,code:"cart-not-found",message:"cart-not-found"}:!we(a)||typeof a.success!="boolean"?{ok:!1,code:ut(r.status)?"not-implemented":"provider-error",message:"The status is not available."}:a.success===!0?a.status==="pending"||a.status==="completed"||a.status==="failed"||a.status==="cancelled"?{ok:!0,status:a.status,...typeof a.orderId=="string"?{orderId:a.orderId}:{}}:{ok:!1,code:"provider-error",message:"Unknown status."}:{ok:!1,code:ut(r.status)?"not-implemented":"provider-error",message:we(a)?yi(a).message:"The status failed."}}var hi="bitsnap-express-cart";function pr(e,t=Date.now()){let n=e?.pending;if(n!=null)return t-n.ts<=864e5?n:void 0}function _n(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function Un(e,t){return`${hi}:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function mr(e){let t=e.storage??_n();if(t==null)return;let n=Un(e.host,e.projectID),o;try{let r=t.getItem(n);if(r==null)return;o=JSON.parse(r)}catch{Ie(e);return}if(!Vt(o)){Ie(e);return}if(o.projectID!==e.projectID||o.host!==e.host||typeof o.cartId!="string"||o.cartId.length===0||typeof o.cartToken!="string"||o.cartToken.length===0||typeof o.revision!="number"||o.environment!=="test"&&o.environment!=="production"){Ie(e);return}return{projectID:o.projectID,host:o.host,environment:o.environment,cartId:o.cartId,cartToken:o.cartToken,revision:o.revision,updatedAt:typeof o.updatedAt=="number"?o.updatedAt:0,...Array.isArray(o.syncedLines)?{syncedLines:o.syncedLines.filter(r=>Vt(r)&&typeof r.id=="string"&&typeof r.quantity=="number")}:{},...typeof o.inpostBindingApiKey=="string"?{inpostBindingApiKey:o.inpostBindingApiKey}:{},...vi(o.pending)?{pending:o.pending}:{}}}function Qe(e,t=_n()){if(t==null)return!1;try{return t.setItem(Un(e.host,e.projectID),JSON.stringify(e)),!0}catch{return!1}}function Ie(e){let t=e.storage??_n();if(t!=null)try{t.removeItem(Un(e.host,e.projectID))}catch{}}function Vt(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}function vi(e){return!Vt(e)||e.provider!=="inpostPay"&&e.provider!=="revolutPay"||typeof e.ts!="number"||!Array.isArray(e.lines)?!1:e.lines.every(t=>Vt(t)&&typeof t.id=="string"&&typeof t.quantity=="number")}var bi=3,$t=class{options;running=Promise.resolve();constructor(t){this.options=t}getRecord(){return mr(this.options)}getInpostBindingApiKey(){return this.getRecord()?.inpostBindingApiKey}previewUpload(t){return this.options.local.upload(t)}getPendingAttempt(){return this.getRecord()?.pending}ensure(t){return this.serialize(()=>this.ensureNow(t))}async ensureNow(t){let n=this.getRecord();n!=null&&t.environment!=null&&n.environment!==t.environment&&(Ie(this.options),n=void 0);let o,r=this.options.maxAttempts??bi;for(let a=0;a<r;a++){let i=this.options.local.upload(t.locale);if(i==null)return{ok:!1,code:"invalid-cart",message:"The cart is empty."};let l=this.options.local.signature(),c=await this.options.write(i,n!=null?{cartId:n.cartId,cartToken:n.cartToken,expectedRevision:n.revision}:void 0);if(c.ok){let p=c.cartToken??n?.cartToken;if(p==null)return{ok:!1,code:"internal",message:"The created cart has no access token."};let s=c.snapshot;if(n={projectID:this.options.projectID,host:this.options.host,environment:s.environment,cartId:s.cartId,cartToken:p,revision:s.revision,updatedAt:(this.options.now??Date.now)(),syncedLines:i.items.map(v=>({id:v.id,quantity:v.quantity})),...n?.inpostBindingApiKey!=null?{inpostBindingApiKey:n.inpostBindingApiKey}:{}},Qe(n,this.options.storage),this.options.local.signature()===l)return{ok:!0,value:{record:n,snapshot:s}};continue}switch(o=c,c.code){case"revision-conflict":{let p=c.snapshot?.revision??c.currentRevision;if(n==null||p==null)return c;let s=Pi({base:n.syncedLines,local:this.options.local.lines(),server:fr(c.snapshot?.lines)});if(!s.ok)return{...c,currentRevision:p,snapshot:c.snapshot,conflicts:s.conflicts};if(!Ci(s.lines,this.options.local.lines())){if(this.options.local.replaceLines==null)return{...c,currentRevision:p,snapshot:c.snapshot,conflicts:s.conflicts};this.options.local.replaceLines(s.lines)}n={...n,revision:p},c.snapshot?.environment!=null&&(n.environment=c.snapshot.environment),c.snapshot!=null&&(n.syncedLines=fr(c.snapshot.lines)),Qe(n,this.options.storage);continue}case"cart-locked":{Ie(this.options),n=void 0;continue}case"cart-not-found":case"cart-forbidden":{Ie(this.options),n=void 0;continue}case"invalid-request":case"product-not-available":case"currency-unsupported":return c;default:return c}}return o??{ok:!1,code:"internal",message:"The cart could not be saved."}}reconcileFromServer(){return this.serialize(async()=>{let t=this.getRecord();if(t==null)return{ok:!1,code:"cart-not-found",message:"There is no cart to read."};let n=qe(this.options.local.lines()),o=await this.options.read(t.cartId,t.cartToken);if(!o.ok)return(o.code==="cart-not-found"||o.code==="cart-forbidden")&&Ie(this.options),o;let r=o.value,a=qe(this.options.local.lines()),i=qe(t.syncedLines??[]),l=t.syncedLines!=null?i:n;this.options.local.adoptSnapshot(r);let c=xi(a,l);c.length>0&&this.options.local.appendLines(c);let p=this.getRecord();if(p!=null&&p.cartId===r.cartId&&Qe({...p,revision:r.revision,environment:r.environment,updatedAt:(this.options.now??Date.now)()},this.options.storage),c.length>0){let s=await this.ensureNow({locale:r.locale,environment:r.environment});if(!s.ok)return{ok:!1,code:s.code,message:s.message,...s.status!=null?{status:s.status}:{},...s.currentRevision!=null?{currentRevision:s.currentRevision}:{},...s.snapshot!=null?{snapshot:s.snapshot}:{},...s.conflicts!=null?{conflicts:s.conflicts}:{}}}return{ok:!0,value:r}})}async start(t,n){let o=await this.ensure({locale:n.locale,...n.environment!=null?{environment:n.environment}:{}});if(!o.ok)return o;let{record:r,snapshot:a}=o.value,i=await n.start({cartId:r.cartId,cartToken:r.cartToken,...n.returnUrl!=null?{returnUrl:n.returnUrl}:{},...n.cancelUrl!=null?{cancelUrl:n.cancelUrl}:{},...n.embedOrigin!=null?{embedOrigin:n.embedOrigin}:{}});if(!i.ok)return(i.code==="cart-locked"||i.code==="cart-not-found"||i.code==="cart-forbidden")&&Ie(this.options),i;let l=this.getRecord();return l!=null&&l.cartId===r.cartId&&Qe({...l,revision:Math.max(l.revision,i.value.cartRevision),updatedAt:(this.options.now??Date.now)(),...i.value.publicConfig?.basketBindingApiKey!=null?{inpostBindingApiKey:i.value.publicConfig.basketBindingApiKey}:{},pending:{provider:t,...i.value.providerOrderId.length>0?{providerOrderId:i.value.providerOrderId}:{},lines:a.lines.map(c=>({id:c.productId,quantity:c.quantity})),ts:(this.options.now??Date.now)()}},this.options.storage),{ok:!0,value:{start:i.value,snapshot:a}}}storeInpostBindingApiKey(t){let n=this.getRecord();n==null||t.length===0||Qe({...n,inpostBindingApiKey:t,updatedAt:(this.options.now??Date.now)()},this.options.storage)}completePurchase(t){let n=this.getRecord(),o=t??n?.pending?.lines??[];o.length>0&&this.options.local.removeLines(o),Ie(this.options)}keepCart(){}clearPending(){let t=this.getRecord();if(t==null||t.pending==null)return;let{pending:n,...o}=t;Qe(o,this.options.storage)}status(t){let n=this.getRecord();return n==null?Promise.resolve({ok:!1,code:"cart-not-found",message:"There is no cart to check."}):t(n.cartId,n.cartToken)}serialize(t){let n=this.running.then(t,t);return this.running=n.then(()=>{},()=>{}),n}};function qe(e){let t=new Map;for(let n of e)t.set(n.id,(t.get(n.id)??0)+n.quantity);return t}function fr(e){return(e??[]).map(t=>({id:t.productId,quantity:t.quantity}))}function Ci(e,t){let n=qe(e),o=qe(t);if(n.size!==o.size)return!1;for(let[r,a]of n)if(o.get(r)!==a)return!1;return!0}function Pi(e){if(e.base==null||e.server==null)return{ok:!1,lines:e.local,conflicts:[]};let t=qe(e.base),n=qe(e.local),o=qe(e.server),r=new Set([...t.keys(),...n.keys(),...o.keys()]),a=[],i=[];for(let l of r){let c=t.get(l)??0,p=n.get(l)??0,s=o.get(l)??0,y=p!==c,v=s!==c,m;y?(v&&(p===s||i.push({id:l,base:c,local:p,server:s})),m=p):m=s,m>0&&!i.some(g=>g.id===l)&&a.push({id:l,quantity:m})}return{ok:i.length===0,lines:a,conflicts:i}}function xi(e,t){let n=[];for(let[o,r]of e){let a=r-(t.get(o)??0);a>0&&n.push({id:o,quantity:a})}return n}var On=new Map,ki=5*60*1e3;function gr(e,t,n){let o=xt();return[e,t,n.items.map(r=>`${r.id}:${r.quantity}`).sort().join(","),(n.countries??[]).slice().sort().join(","),n.couponCode??"",n.deliveryMethod??"",o.postalCode??""].join("|")}function dt(e,t,n){let o=gr(e,t,n),r=On.get(o);if(r!=null){if(Date.now()-r.at>ki){On.delete(o);return}return r.quote}}function wi(e,t,n,o){On.set(gr(e,t,n),{quote:o,at:Date.now()})}function Xe(e,t){return t==null||t.delivery.length===0?e:{...e,delivery:e.delivery!=null&&e.delivery.length>0?e.delivery:t.delivery,...e.deliveryMethod==null&&t.deliveryMethod!=null?{deliveryMethod:t.deliveryMethod}:{}}}async function Ii(e){if(e.upload.items.length===0)return{delivery:[]};let t=xt();try{let n=await jt.get(e.host).getPreOrderDetails({projectId:e.projectID,items:e.upload.items.map(i=>({id:i.id,quantity:i.quantity})),...e.upload.countries?.[0]!=null?{countryCode:e.upload.countries[0]}:{},...e.upload.couponCode!=null?{couponCode:e.upload.couponCode}:{},...e.upload.deliveryMethod!=null?{selectedDeliveryMethod:e.upload.deliveryMethod}:t.selectedDeliveryMethod!=null?{selectedDeliveryMethod:t.selectedDeliveryMethod}:{},...t.postalCode!=null?{postCode:t.postalCode}:{}}),o=n.methods.map(i=>({name:i.id,...i.description!=null?{desc:i.description}:{},min:i.minDays??1,max:i.maxDays??14,price:i.amount/100})),r=n.selectedDeliveryMethod??o[0]?.name??void 0,a={delivery:o,...r!=null?{deliveryMethod:r}:{}};return wi(e.host,e.projectID,e.upload,a),a}catch(n){console.warn("cannot resolve the express delivery quote",n);return}}async function Qt(e){if(e.upload.delivery!=null&&e.upload.delivery.length>0)return{ok:!0,upload:e.upload,quote:{delivery:e.upload.delivery,...e.upload.deliveryMethod!=null?{deliveryMethod:e.upload.deliveryMethod}:{}}};let t=dt(e.host,e.projectID,e.upload);if(t!=null)return{ok:!0,upload:Xe(e.upload,t),quote:t};let n=await Ii(e);return n==null?{ok:!1,message:"The delivery quote for this cart is not available. Use the regular checkout."}:{ok:!0,upload:Xe(e.upload,n),quote:n}}function Mn(e){return{lines:()=>lt().map(t=>({id:t.productID,quantity:t.quantity})),signature:Uo,upload:t=>{let n=zt(t);if(n!=null)return Xe(n,dt(e.host,e.projectID,n))},adoptSnapshot:t=>{wn(t.lines.map(n=>({productId:n.productId,quantity:n.quantity})))},appendLines:Mo,removeLines:Oo,replaceLines:t=>{wn(t.map(n=>({productId:n.id,quantity:n.quantity})))}}}function Ye(e){let t=e.host??ue,n={projectID:e.projectID,host:t,...e.fetch!=null?{fetch:e.fetch}:{},...e.signal!=null?{signal:e.signal}:{}};return new $t({projectID:e.projectID,host:t,local:e.local??Mn({host:t,projectID:e.projectID}),...e.storage!=null?{storage:e.storage}:{},...e.now!=null?{now:e.now}:{},write:(o,r)=>ir(n,o,r),read:(o,r)=>sr(n,o,r)})}async function Xt(e,t,n=Ye(e)){let o=e.host??ue,r=n.previewUpload(e.locale);if(r!=null){let a=await Qt({host:o,projectID:e.projectID,upload:r});if(!a.ok)return{ok:!1,code:"invalid-cart",message:a.message}}return n.start(t,{locale:e.locale,...e.environment!=null?{environment:e.environment}:{},...e.returnUrl!=null?{returnUrl:e.returnUrl}:{},...e.cancelUrl!=null?{cancelUrl:e.cancelUrl}:{},...e.embedOrigin!=null?{embedOrigin:e.embedOrigin}:{},start:a=>lr({projectID:e.projectID,host:o,...e.fetch!=null?{fetch:e.fetch}:{},...e.signal!=null?{signal:e.signal}:{}},t,a)})}function yr(e,t){return vr(e,"revolutPay",t)}function hr(e,t){return vr(e,"inpostPay",t)}function vr(e,t,n){let o=e.host??ue;return(n??Ye(e)).status((a,i)=>(t==="inpostPay"?ur:cr)({projectID:e.projectID,host:o,...e.fetch!=null?{fetch:e.fetch}:{},...e.signal!=null?{signal:e.signal}:{}},a,i))}function br(){return typeof window>"u"?void 0:window}var jn="inpost-izi-button",qn="inpost-thank-you";function xr(e){return e!=null&&/^pl\b/i.test(e)?"pl":"en"}var Si="https://sandbox-inpostpay-widget-api.inpost.pl",Ei="https://inpostpay-widget-api.inpost.pl",Cr={test:"https://sandbox-inpostpay-widget-v2.inpost.pl/inpostpay.widget.v2.js",production:"https://inpostpay-widget-v2.inpost.pl/inpostpay.widget.v2.js"},Pr={test:Si,production:Ei};function Ti(e,t){return e==="test"||e==="production"?e:e==="prod"||e==="live"?"production":t??"production"}function Yt(e){return e.includes("sandbox")}function kr(e,t){if(e==null)return;let n=e.merchantClientId;if(n==null||n.length===0)return;let o=t??Ti(e.environment,void 0),r=e.widgetApiBaseUrl??e.apiBaseUrl,a=e.widgetScriptUrl,i=o==="test"?r!=null&&Yt(r)?r:Pr.test:r!=null&&!Yt(r)?r:Pr.production,l=o==="test"?a!=null&&Yt(a)?a:Cr.test:a!=null&&!Yt(a)?a:Cr.production;return{merchantClientId:n,environment:o,apiBaseUrl:i,scriptUrl:l,...e.basketBindingApiKey!=null&&e.basketBindingApiKey.length>0?{basketBindingApiKey:e.basketBindingApiKey}:{},...e.basketId!=null&&e.basketId.length>0?{basketId:e.basketId}:{}}}var Bn;function wr(){if(typeof window>"u")return Promise.reject(new Error("InPost Pay needs a browser."));let e=br()?.InPostPayWidget;return e!=null?Promise.resolve(e):(Bn??=import("@inpost-pay/widget").then(t=>{let n=t,o=typeof n.initialiseInpostPayWidget=="function"?n.initialiseInpostPayWidget:typeof n.default=="function"?n.default:typeof n.default?.initialiseInpostPayWidget=="function"?n.default.initialiseInpostPayWidget:void 0,r=br()?.InPostPayWidget;if(r!=null)return r;if(o!=null)return{init:o};throw new Error("The InPost Pay widget exposed no init function.")}).catch(t=>{throw Bn=void 0,t}),Bn)}function Ir(e){if(typeof window>"u")return;let t=window,n=t.__bitsnapInpostOwner,o=t.__INPOST_PAY_WIDGET__;if(o!=null){if(n!=null&&n.projectID===e.owner.projectID&&n.host===e.owner.host&&n.merchantClientId===e.owner.merchantClientId)return o.refresh(e.options),o;if(Ni()){e.warn?.("InPost Pay already runs for another project on this page; mount one InPost Pay button per page.");return}delete t.__INPOST_PAY_WIDGET__,delete t.__bitsnapInpostOwner}let r=e.namespace.init(e.options);return t.__INPOST_PAY_WIDGET__=r,t.__bitsnapInpostOwner=e.owner,r}function Ni(){return typeof document>"u"?!1:document.querySelector(`${jn}, ${qn}`)!=null}function Sr(e){return{binding_place:e.bindingPlace,...e.productId!=null?{"data-product-id":e.productId}:{},...e.variation!=null?{variation:e.variation}:{}}}import{useEffect as Ri,useMemo as Ec,useRef as Ai,useState as Di,useSyncExternalStore as Li}from"react";function pt(e){let t=Math.max(1,Math.trunc(e.quantity??1)),n={...e.country!=null?{country:e.country}:{},...e.couponCode!=null?{couponCode:e.couponCode}:{},productQuantity:t};if(e.items!=null&&e.items.length>0)return{...n,items:e.items.map(r=>({id:r.id,quantity:Math.max(1,Math.trunc(r.quantity))})),source:"items"};let o=lt().map(r=>({id:r.productID,quantity:r.quantity}));if(e.productId!=null&&e.productId.length>0){let r=o.some(a=>a.id===e.productId);return{...n,items:r?o:[...o,{id:e.productId,quantity:t}],source:"product",productId:e.productId}}return{...n,items:o,source:"cart"}}function Zt(e){let t=e.items.map(n=>`${n.id}:${n.quantity}`).sort().join(",");return[e.source,t,e.country??"",e.couponCode??"",e.productId??""].join("|")}function Jt(e,t,n){if(e.source==="cart")return Mn(n);let o={items:e.items.map(r=>({id:r.id,quantity:r.quantity})),...e.country!=null?{countries:[e.country]}:{},...e.couponCode!=null?{couponCode:e.couponCode}:{},locale:t};return{lines:()=>e.items,signature:()=>Zt(e),upload:()=>Xe(o,dt(n.host,n.projectID,o)),adoptSnapshot:()=>{},appendLines:()=>{},removeLines:()=>{}}}function St(){return Li(Bo,jo,()=>0)}function en(e){let t=Ai(e);t.current=e;let n=pt(e),o=Zt(n),r=St(),[a,i]=Di({loading:!1,provider:void 0,environment:void 0,failed:!1});return Ri(()=>{let l=t.current;if(l.enabled===!1||l.projectID==null||l.projectID.length===0||typeof window>"u"){i({loading:!1,provider:void 0,environment:void 0,failed:!1});return}let c=pt(l);if(c.items.length===0){i({loading:!1,provider:void 0,environment:void 0,failed:!1});return}let p=new AbortController,s=!0;return i(y=>({...y,loading:!0})),Ui({projectID:l.projectID,...l.host!=null?{host:l.host}:{},locale:l.locale,cart:c,...l.fetch!=null?{fetch:l.fetch}:{},signal:p.signal}).then(y=>{if(!s)return;let v=y?.providers?.[l.provider];i({loading:!1,provider:v,environment:y?.environment??v?.environment,failed:y==null})}).catch(()=>{s&&i({loading:!1,provider:void 0,environment:void 0,failed:!0})}),()=>{s=!1,p.abort()}},[o,r,e.projectID,e.host,e.provider,e.locale,e.enabled]),a}function tn(e){return e??ue}function _i(e,t,n){let o=e.source==="cart"?zt(t):e.items.length===0?void 0:{items:e.items.map(r=>({id:r.id,quantity:r.quantity})),...e.country!=null?{countries:[e.country]}:{},...e.couponCode!=null?{couponCode:e.couponCode}:{},locale:t};if(o!=null)return n?.host==null||n.projectID==null?o:Xe(o,dt(n.host,n.projectID,o))}async function Ui(e){let t=e.host??ue,n=_i(e.cart,e.locale);if(n==null)return;let o=await Qt({host:t,projectID:e.projectID,upload:n});if(!o.ok)return;let r=await ar({projectID:e.projectID,host:t,...e.fetch!=null?{fetch:e.fetch}:{},...e.signal!=null?{signal:e.signal}:{}},o.upload);if(r==null)return;if(o.quote.delivery.length===0)return r;let a=r.providers.revolutPay;return a==null||a.available!==!0?r:{...r,providers:{...r.providers,revolutPay:{...a,available:!1,reasons:[...a.reasons,"delivery-unsupported"]}}}}function Er(e){if(e==null)return;let t=e.publicKey??e.publicToken,n=e.mode;if(!(t==null||t.length===0)&&!(n!=="sandbox"&&n!=="prod"))return{publicKey:t,mode:n,...e.orderToken!=null&&e.orderToken.length>0?{orderToken:e.orderToken}:{}}}function Tr(e){let t=e.publicConfig?.orderToken;return t!=null&&t.length>0?t:e.providerOrderId}function Nr(e){return e!=null&&/^pl\b/i.test(e)?"pl":"en"}var Oi=6e4,Mi=2e3;function Bi(e){return new Promise(t=>setTimeout(t,e))}async function zn(e){let t=e.timeoutMs??Oi,n=e.intervalMs??Mi,o=e.sleep??Bi,r=(e.now??Date.now)(),a=Math.min(1e4,Math.max(1,Math.ceil(t/Math.max(1,n))+1)),i=0,l;for(;;){if(i+=1,e.signal?.aborted===!0)return l;try{l=await e.check()}catch{l=void 0}if(l?.ok===!0&&l.status!=="pending"||l?.ok===!1&&l.code==="not-implemented"||i>=a||(e.now??Date.now)()-r>=t)return l;await o(n)}}var Rr=zn;import{jsx as zi}from"react/jsx-runtime";var ji={pending:"expressPending",confirmed:"expressConfirmed",failed:"expressFailed",cancelled:"expressCancelled","load-failed":"expressLoadFailed","cart-unavailable":"expressCartUnavailable","cart-conflict":"expressCartConflict","price-changed":"expressPriceChanged","product-unavailable":"expressProductUnavailable"},qi=["failed","cancelled","load-failed","cart-unavailable","cart-conflict","price-changed","product-unavailable"];function Et({phase:e}){let t=at(),n=L("error");if(e==="idle")return null;let o=qi.includes(e);return zi("p",{role:o?"alert":"status","aria-live":o?"assertive":"polite","data-bitsnap-express-status":e,className:u("w-full px-2 text-center text-sm",o&&"opacity-90",n.className),style:n.style,children:t(ji[e])})}import{jsx as gt,jsxs as Hi}from"react/jsx-runtime";function Lr(e){return typeof e=="object"&&e!=null&&e.undeliverable===!0}function Gn(e){let{projectID:t}=e,n=tn(e.host),o=e.locale??Ne(),r=xe(),a=e.confirmation?.timeoutMs,i=e.confirmation?.intervalMs,l=e.confirmation?.sleep,c=e.confirmation?.now,p=St(),s=Dr(()=>pt({...e.items!=null?{items:e.items}:{},...e.productId!=null?{productId:e.productId}:{},...e.quantity!=null?{quantity:e.quantity}:{}}),[e.items,e.productId,e.quantity,p]),y=Zt(s),v=en({provider:"inpostPay",projectID:t,host:n,locale:o,...e.items!=null?{items:e.items}:{},...e.productId!=null?{productId:e.productId}:{},...e.quantity!=null?{quantity:e.quantity}:{},...e.fetch!=null?{fetch:e.fetch}:{}}),m=v.provider,g=m?.environment??v.environment,d=m?.available===!0?kr(m.publicConfig,g):void 0,I=d?.merchantClientId,R=d?.apiBaseUrl,h=Dr(()=>Ye({projectID:t,host:n,...s.source==="items"?{local:Jt(s,o,{host:n,projectID:t})}:{},...e.fetch!=null?{fetch:e.fetch}:{}}),[t,n,e.fetch,s,o]),[b,A]=Gi("idle"),x=ft(void 0),E=ft(void 0),D=ft(!0),S=ft(!1),T=ft(!1);Tt(()=>(D.current=!0,()=>{D.current=!1}),[]);let w=ft({cart:s,locale:o,environment:g,session:h,onOrderCreated:e.onOrderCreated,onBasketChanged:e.onBasketChanged});w.current={cart:s,locale:o,environment:g,session:h,onOrderCreated:e.onOrderCreated,onBasketChanged:e.onBasketChanged};let C=mt(async()=>{if(E.current!=null)return E.current;let M=Xt({projectID:t,host:n,locale:w.current.locale,...w.current.environment!=null?{environment:w.current.environment}:{},...typeof window<"u"?{returnUrl:window.location.href,cancelUrl:window.location.href,embedOrigin:window.location.origin}:{},...e.fetch!=null?{fetch:e.fetch}:{}},"inpostPay",w.current.session).then(O=>{if(!O.ok)throw A(O.code==="revision-conflict"?"cart-conflict":"cart-unavailable"),new Error(`inpost-start-${O.code}`);return r.track("payment_submitted",{gateway:"inpost_pay",method:"inpost_pay"}),O.value.start}).finally(()=>{E.current=void 0});return E.current=M,M},[t,n,r,e.fetch]),U=mt(async M=>{if(lt().some(_=>_.productID===M)||w.current.cart.source==="items")return;if(await xn.addProductToCart(M,w.current.cart.productQuantity)!=null)throw{undeliverable:!0}},[]),f=mt(async M=>{r.track("payment_method_selected",{gateway:"inpost_pay",method:"inpost_pay"});try{M!=null&&await U(M);let N=(await C()).publicConfig?.basketBindingApiKey;if(N==null||N.length===0)throw new Error("inpost-start-without-basket-key");return w.current.session.storeInpostBindingApiKey(N),A("idle"),N}catch(O){throw Lr(O)?(A("product-unavailable"),new Error("UNDELIVERABLE_PRODUCT")):(A(O instanceof Error&&O.message==="inpost-start-revision-conflict"?"cart-conflict":"cart-unavailable"),O instanceof Error?O:new Error("inpost-pay-failed"))}},[U,r,C]),k=mt(async M=>{let O=M??w.current.cart.productId;if(O!=null)try{if(await xn.addProductToCart(O,w.current.cart.productQuantity)!=null)throw{undeliverable:!0};await w.current.session.ensure({locale:w.current.locale,...w.current.environment!=null?{environment:w.current.environment}:{}})}catch(N){throw A("product-unavailable"),Lr(N)?new Error("UNDELIVERABLE_PRODUCT"):N instanceof Error?N:new Error("inpost-pay-failed")}},[]),X=mt(async()=>{if(!S.current){S.current=!0;try{let M=w.current.session,O=M.getPendingAttempt();if(O?.provider!=="inpostPay")return;D.current&&A("pending");let N=await zn({check:()=>hr({projectID:t,host:n,...e.fetch!=null?{fetch:e.fetch}:{}},M),timeoutMs:a??2e4,intervalMs:i??1500,...l!=null?{sleep:l}:{},...c!=null?{now:c}:{}});if(!D.current)return;let _=O.providerOrderId;if(N?.ok===!0&&N.status==="completed"){let W=await M.reconcileFromServer(),F=W.ok?W.value.lines.map(V=>({id:V.productId,quantity:V.quantity})):O.lines;F.length>0&&M.completePurchase(F),A("confirmed"),r.track("payment_returned",{gateway:"inpost_pay",method:"inpost_pay",outcome:"pending"}),T.current||(T.current=!0,w.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"completed"}));return}if(N?.ok===!0&&N.status==="failed"){M.clearPending(),A("failed"),T.current||(T.current=!0,w.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"failed"}));return}if(N?.ok===!0&&N.status==="cancelled"){M.clearPending(),A("cancelled"),T.current||(T.current=!0,w.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"cancelled"}));return}A("pending"),T.current||(T.current=!0,w.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"pending"}))}finally{S.current=!1}}},[i,c,l,a,n,r,t,e.fetch]),be=mt(async M=>{if(M==="basketProductChanged"){let O=await w.current.session.reconcileFromServer();return O.ok&&w.current.onBasketChanged?.(O.value),!0}return M==="orderCreated"&&X(),!0},[X]);if(Tt(()=>{m?.available===!0&&h.getPendingAttempt()?.provider==="inpostPay"&&X()},[m?.available,h,X]),Tt(()=>{if(m?.available!==!0||I==null||I.length===0||typeof window>"u")return;let M=!1;return wr().then(O=>{if(M)return;let N=Ir({namespace:O,owner:{projectID:t,host:n,merchantClientId:I},options:{merchantClientId:I,basketBindingApiKey:h.getInpostBindingApiKey(),unboundWidgetClicked:f,...s.source==="product"||e.productId!=null?{addToBasketClicked:k}:{},handleBasketEvent:be,...R!=null?{apiBaseUrl:R}:{},language:xr(o)}});if(N==null){A("cart-unavailable");return}x.current=N,N.rerender()}).catch(()=>{M||A("load-failed")}),()=>{M=!0,x.current=void 0}},[m?.available,I,R,o,t,n,h,f,k,be,s.source,e.productId]),Tt(()=>{x.current?.refresh({basketBindingApiKey:h.getInpostBindingApiKey()})},[y,h]),m?.available!==!0||I==null||I.length===0)return gt(Et,{phase:b==="idle"?"idle":b});let Me=e.bindingPlace??(e.productId!=null?"PRODUCT_CARD":"BASKET_SUMMARY");return Hi("div",{"data-bitsnap-express":"inpostPay","aria-busy":b==="pending"?!0:void 0,className:e.className,style:e.style,children:[Me==="THANK_YOU_PAGE"?Ar(qn,{...e.variation!=null?{variation:e.variation}:{}}):Ar(jn,Sr({bindingPlace:Me,...e.productId!=null?{productId:e.productId}:{},...e.variation!=null?{variation:e.variation}:{}})),gt(Et,{phase:b})]})}function Fi(e){let t=e.projectID??ke(),n=me(t,e.analytics,"cart");return Tt(()=>{e.projectID!=null&&$e(e.projectID)},[e.projectID]),gt(Pe,{value:n,children:gt(rt,{locale:e.locale,texts:e.texts,children:gt(ct,{appearance:e.appearance,children:t==null?null:gt(Gn,{...e,projectID:t})})})})}var Wi=Fi;import{useEffect as Vn,useMemo as Vi,useRef as on,useState as qr}from"react";var Ki={prod:"https://merchant.revolut.com/embed.js",sandbox:"https://sandbox-merchant.revolut.com/embed.js"},_r={prod:"revolut-checkout",sandbox:"revolut-checkout-sandbox"},Fn=new Map;function Ur(e,t={}){if(typeof window>"u")return Promise.reject(new Error("Revolut Checkout needs a browser."));let n=window.RevolutCheckout;if(n!=null)return Promise.resolve(n);let o=Fn.get(e);if(o!=null)return o;let r=t.document??document,a=t.timeoutMs??15e3,i=new Promise((l,c)=>{let p=!1,s=r.getElementById(_r[e]),y,v=()=>{y!=null&&clearTimeout(y),s?.removeEventListener("load",g),s?.removeEventListener("error",d)},m=I=>{p||(p=!0,v(),I())},g=()=>{m(()=>{let I=window.RevolutCheckout;I!=null?l(I):c(new Error("Revolut Checkout did not initialise."))})},d=()=>{m(()=>c(new Error("Revolut Checkout could not be loaded.")))};s==null?(s=r.createElement("script"),s.id=_r[e],s.src=Ki[e],s.async=!0,s.addEventListener("load",g),s.addEventListener("error",d),r.head.appendChild(s)):(s.addEventListener("load",g),s.addEventListener("error",d)),y=setTimeout(()=>{m(()=>c(new Error("Revolut Checkout timed out while loading.")))},a)});return Fn.set(e,i),i.catch(()=>Fn.delete(e)),i}function Or(e,t){return e.payments({publicToken:t.publicKey,mode:t.mode,locale:t.locale})}var Wn="bitsnap_express",Hn="bitsnap_express_cart",Kn="bitsnap_express_result",Mr="_rp_oid";function Br(e){let t;try{t=new URLSearchParams(e.startsWith("?")?e:`?${e}`)}catch{return{returned:!1}}let n=t.get(Wn),o=t.get(Mr)??void 0,r=t.get(Hn)??void 0,a=t.get(Kn),i=a==="success"||a==="failure"||a==="cancel"?a:void 0,l=n==="inpostPay"||n==="revolutPay";return{returned:l||o!=null,...l?{provider:n}:{},...r!=null?{cartId:r}:{},...o!=null?{orderToken:o}:{},...i!=null?{result:i}:{}}}function nn(e,t){let n=typeof window<"u"?window.location.href:"https://localhost/",o=new URL(e,n);return o.searchParams.set(Wn,t.provider),o.searchParams.set(Hn,t.cartId),o.searchParams.set(Kn,t.result),o.toString()}function jr(e){let t=typeof window<"u"?window.location.href:"https://localhost/",n=new URL(e,t);return n.searchParams.delete(Wn),n.searchParams.delete(Hn),n.searchParams.delete(Kn),n.searchParams.delete(Mr),n.pathname+n.search+n.hash}import{jsx as yt,jsxs as Xi}from"react/jsx-runtime";function $n(e){let{projectID:t}=e,n=tn(e.host),o=e.locale??Ne(),r=xe(),a=e.confirmation?.timeoutMs,i=e.confirmation?.intervalMs,l=e.confirmation?.sleep,c=e.confirmation?.now,p=JSON.stringify(e.buttonStyle??null),s=St(),y=Vi(()=>pt({...e.items!=null?{items:e.items}:{},...e.productId!=null?{productId:e.productId}:{},...e.quantity!=null?{quantity:e.quantity}:{},...e.country!=null?{country:e.country}:{},...e.couponCode!=null?{couponCode:e.couponCode}:{}}),[e.items,e.productId,e.quantity,e.country,e.couponCode,s]),v=[y.source,y.items.map(S=>`${S.id}:${S.quantity}`).sort().join(",")].join("|"),m=en({provider:"revolutPay",projectID:t,host:n,locale:o,...e.items!=null?{items:e.items}:{},...e.productId!=null?{productId:e.productId}:{},...e.quantity!=null?{quantity:e.quantity}:{},...e.country!=null?{country:e.country}:{},...e.couponCode!=null?{couponCode:e.couponCode}:{},...e.fetch!=null?{fetch:e.fetch}:{}}),g=m.provider?.available===!0?Er(m.provider.publicConfig):void 0,d=m.provider?.environment??m.environment,I=on(null),[R,h]=qr("idle"),[b,A]=qr(0),x=on(!0),E=on(void 0),D=on(void 0);return Vn(()=>(x.current=!0,()=>{x.current=!1}),[]),Vn(()=>{if(g==null||typeof window>"u"||I.current==null)return;let S=new AbortController,T=!1,w,C=Jt(y,o,{host:n,projectID:t}),U=Ye({projectID:t,host:n,local:C,...e.fetch!=null?{fetch:e.fetch}:{},signal:S.signal}),f=e.returnUrl??window.location.href,k=!1,X=!1,be=async N=>{if(!x.current||X)return;h("pending");let _=await Rr({check:()=>yr({projectID:t,host:n,...e.fetch!=null?{fetch:e.fetch}:{},signal:S.signal},N),signal:S.signal,...a!=null?{timeoutMs:a}:{},...i!=null?{intervalMs:i}:{},...l!=null?{sleep:l}:{},...c!=null?{now:c}:{}});if(!(T||!x.current)){if(_?.ok===!0&&_.status==="completed"){X=!0,N.completePurchase(),h("confirmed"),e.onPaymentResult?.({status:"completed",..._.orderId!=null?{orderId:_.orderId}:{}});return}if(_?.ok===!0&&_.status==="failed"){X=!0,N.clearPending(),h("failed"),e.onPaymentResult?.({status:"failed"});return}if(_?.ok===!0&&_.status==="cancelled"){X=!0,N.clearPending(),h("cancelled"),e.onPaymentResult?.({status:"cancelled"});return}h("pending"),e.onPaymentResult?.({status:"pending"})}},Me=N=>{k||(k=!0,be(N).finally(()=>{k=!1}))},M=N=>{if(N.type==="cancel"){r.track("payment_returned",{gateway:"revolut_pay",method:"revolut_pay",outcome:"cancel"}),U.clearPending(),h("cancelled"),e.onPaymentResult?.({status:"cancelled"});return}if(N.type==="error"){r.track("payment_returned",{gateway:"revolut_pay",method:"revolut_pay",outcome:"fail"}),U.clearPending();let _=D.current;D.current=void 0,h(_??"failed"),_==null&&e.onPaymentResult?.({status:"failed"});return}r.track("payment_returned",{gateway:"revolut_pay",method:"revolut_pay",outcome:"pending"}),Me(U)};return(async()=>{let N=await U.ensure({locale:o,...d!=null?{environment:d}:{}});if(T)return;if(!N.ok){h(N.code==="revision-conflict"?"cart-conflict":"cart-unavailable");return}let _=N.value.snapshot;E.current={cartId:_.cartId,currency:_.currency,totalMinor:_.totalMinor};let W=await Ur(g.mode);if(T)return;let F=await Or(W,{publicKey:g.publicKey,mode:g.mode,locale:Nr(o)});if(T){F.destroy?.();return}let{revolutPay:V}=F,We,mn=async()=>(We!=null||(We=(async()=>{let Y=await U.ensure({locale:o,...d!=null?{environment:d}:{}});if(!Y.ok)throw D.current=Y.code==="revision-conflict"?"cart-conflict":"cart-unavailable",new Error(`revolut-cart-${Y.code}`);if(!zr(Y.value.snapshot,E.current))throw E.current={cartId:Y.value.snapshot.cartId,currency:Y.value.snapshot.currency,totalMinor:Y.value.snapshot.totalMinor},D.current="price-changed",h("price-changed"),A(bt=>bt+1),new Error("revolut-amount-changed");let oe=await Xt({projectID:t,host:n,locale:o,...d!=null?{environment:d}:{},returnUrl:f,cancelUrl:e.cancelUrl??f,embedOrigin:window.location.origin,...e.fetch!=null?{fetch:e.fetch}:{}},"revolutPay",U);if(!oe.ok)throw D.current=oe.code==="revision-conflict"?"cart-conflict":"cart-unavailable",new Error(`revolut-start-${oe.code}`);if(!zr(oe.value.snapshot,E.current))throw E.current={cartId:oe.value.snapshot.cartId,currency:oe.value.snapshot.currency,totalMinor:oe.value.snapshot.totalMinor},D.current="price-changed",h("price-changed"),A(bt=>bt+1),new Error("revolut-amount-changed");return r.track("payment_submitted",{gateway:"revolut_pay",method:"revolut_pay"}),{publicId:Tr(oe.value.start)}})().finally(()=>{We=void 0})),We);V.mount(I.current,{currency:_.currency,totalAmount:_.totalMinor,createOrder:mn,mobileRedirectUrls:{success:nn(f,{provider:"revolutPay",cartId:_.cartId,result:"success"}),failure:nn(f,{provider:"revolutPay",cartId:_.cartId,result:"failure"}),cancel:nn(f,{provider:"revolutPay",cartId:_.cartId,result:"cancel"})},...e.buttonStyle!=null?{buttonStyle:e.buttonStyle}:{}}),V.on("click",()=>{r.track("payment_method_selected",{gateway:"revolut_pay",method:"revolut_pay"})}),V.on("payment",M),!T&&x.current&&h(Y=>Y==="price-changed"||Y==="cart-conflict"||Y==="confirmed"||Y==="failed"||Y==="cancelled"?Y:"idle"),w=()=>{try{V.destroy()}catch{}try{F.destroy?.()}catch{}};let Te=Br(window.location.search),gn=pr(U.getRecord())?.provider==="revolutPay"&&(Te.cartId==null||Te.cartId===_.cartId)||Te.returned&&Te.provider==="revolutPay";Te.returned&&window.history.replaceState({},"",jr(window.location.href)),gn&&await be(U)})().catch(()=>{!T&&x.current&&h("load-failed")}),()=>{T=!0,S.abort(),w?.()}},[g?.publicKey,g?.mode,d,o,v,t,n,e.fetch,e.returnUrl,e.cancelUrl,p,a,i,l,c,b]),Xi("div",{"data-bitsnap-express":"revolutPay","aria-busy":R==="pending"?!0:void 0,className:e.className,style:e.style,children:[yt("div",{ref:I}),yt(Et,{phase:R})]})}function zr(e,t){return t!=null&&e.cartId===t.cartId&&e.currency===t.currency&&e.totalMinor===t.totalMinor}function $i(e){let t=e.projectID??ke(),n=me(t,e.analytics,"cart");return Vn(()=>{e.projectID!=null&&$e(e.projectID)},[e.projectID]),yt(Pe,{value:n,children:yt(rt,{locale:e.locale,texts:e.texts,children:yt(ct,{appearance:e.appearance,children:t==null?null:yt($n,{...e,projectID:t})})})})}var Qi=$i;import{useReducer as Es,useRef as Ts,useEffect as Dt}from"react";import{useQuery as Ns}from"@tanstack/react-query";import{Settings as Rs}from"lucide-react";import{Fragment as Yi,jsx as Qn,jsxs as Zi}from"react/jsx-runtime";var J=ko.pl,j={title:null,description:null,managingDescription:"Zarz\u0105dzaj rodzajami powiadomie\u0144 i sposobem dostarczania.",formTitle:"Podaj Email aby zapisa\u0107 si\u0119\xA0do powiadomie\u0144",formEmailLabel:"Email",formPhoneLabel:"Numer telefonu",formPhoneOptional:"(opcjonalnie)",formEmailPlaceholder:"np. mail@gmail...",formPhonePlaceholder:"np. 663...",formSubmitButton:"Zapisz si\u0119",formSuccessMessage:"Zapisa\u0142e\u015B si\u0119 do powiadomie\u0144.",agreementText:Zi(Yi,{children:[Qn("span",{style:{color:"red"},children:"*"}),"Wyra\u017Cam zgod\u0119 na przetwarzanie moich danych w celach marketingowych zgodnie z"," ",Qn("a",{href:"/regulations/polityka-prywatnosci",target:"_blank",className:"cursor-alias font-bold hover:font-medium",children:"regulaminem"})," ",Qn("span",{className:"text-xs font-light",children:"(zgod\u0119 mo\u017Cna w ka\u017Cdej chwili wycofa\u0107)"})]}),qrCodeTitle:"lub zainstaluj aplikacj\u0119 mobiln\u0105",qrCodeSubtitle:"Aplikacja mobilna",qrCodeScanText:"zeskanuj kod QR",groupsNoSelectionWarning:"Je\u015Bli \u017Cadna z grup nie jest zaznaczona, nie otrzymasz \u017Cadnych powiadomie\u0144.",groupsSelectAllButton:"Zaznacz wszystkie",groupsUpdateButton:"Aktualizuj",groupsUpdateSuccess:"Zaktualizowano pomy\u015Blnie.",groupsTitle:"Zarz\u0105dzaj grupami z kt\xF3rych chcesz otrzymywa\u0107 powiadomienia",manageDataTitle:"Ustawienia powiadomie\u0144",manageDataDescription:"W jaki spos\xF3b chcesz otrzymywa\u0107 powiadomienia?",manageDataUnsubscribeButton:"Odsubskrybuj",manageDataUpdatedMessage:"Zaktualizowano",manageDataUnsubscribeDescription:"Wypisz mnie z wszystkich powiadomie\u0144 i grup.",loginEmailLabel:"Email",loginEmailPlaceholder:"Wprowad\u017A sw\xF3j email",loginSendCodeButton:"Wy\u015Blij kod weryfikacyjny",loginSendingButton:"Wysy\u0142anie...",loginCodeLabel:"Wprowad\u017A kod weryfikacyjny",loginCodeSentMessage:"Wys\u0142ali\u015Bmy kod weryfikacyjny na adres",loginChangeEmailButton:"Popraw email",loginResendCodeButton:"Wy\u015Blij kod ponownie",loginInvalidEmailError:"Wprowad\u017A prawid\u0142owy adres email",loginSlugRequiredError:"Wymagany jest identyfikator projektu",loginInvalidCodeError:"Nieprawid\u0142owy kod weryfikacyjny",loginVerificationFailedError:"Weryfikacja nie powiod\u0142a si\u0119. Sprawd\u017A sw\xF3j kod.",loginSendEmailError:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu weryfikacyjnego",loginVerifyCodeError:"Nie uda\u0142o si\u0119 zweryfikowa\u0107 kodu",loginResendEmailError:"Nie uda\u0142o si\u0119 ponownie wys\u0142a\u0107 kodu weryfikacyjnego",loginTitle:"Wpisz email aby zarz\u0105dza\u0107 powiadomieniami",loginDescription:"Dostaniesz kod weryfikacyjny na email.",loginIHaveCode:"Mam ju\u017C kod",loginVerifyButton:"Potwierd\u017A",loginResendInText:J.resendIn,loginResentMessage:J.resent,loginExpiredError:J.expired,loginTooManyAttemptsError:J.tooManyAttempts,loginRateLimitedError:J.rateLimited,loginNetworkError:J.network,loginSpamHint:J.spamHint,loginValidityHint:J.validity,loginVerifyingButton:J.verifying,loginStepEmailHint:J.stepEmail,loginStepCodeHint:J.stepCode,loginAlreadySentMessage:J.alreadySent,loginEmailNotFoundError:J.emailNotFound,loginDeliveryUnavailableError:J.deliveryUnavailable,loginResendNewCodeButton:J.resendNew,loginNoCodeButton:J.noCode,loginCodeIncompleteError:J.codeIncomplete};import{LogOutIcon as Ji}from"lucide-react";import{Fragment as Gr,jsx as Ze,jsxs as rn}from"react/jsx-runtime";function Fr({projectName:e,projectLogo:t,projectLogoDark:n,description:o,className:r,onLogout:a}){return rn(Gr,{children:[t!=null||e!=null&&rn("h2",{className:u("flex max-w-44 items-center gap-3 text-lg font-medium text-black sm:max-w-none md:text-xl lg:text-2xl xl:text-3xl dark:text-neutral-100",r?.headerTitle),children:[t!=null&&rn(Gr,{children:[Ze("img",{src:t,alt:"",className:u("h-12 w-auto dark:hidden",r?.headerLogo)}),Ze("img",{src:n??t,alt:"",className:u("hidden h-12 w-auto dark:inline",r?.headerLogo)})]}),Ze("span",{children:e})]}),rn("div",{className:"flex items-center gap-2",children:[o&&Ze("p",{className:u("mt-4 font-medium text-left",r?.headerDescription),children:o}),Ze("div",{className:"grow"}),a&&Ze($,{variant:"ghost",size:"icon-sm",onClick:a,children:Ze(Ji,{className:"h-5 w-5"})})]})]})}import*as an from"@radix-ui/react-switch";import{jsx as Wr}from"react/jsx-runtime";function ht({className:e,...t}){return Wr(an.Root,{"data-slot":"switch",className:u("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:Wr(an.Thumb,{"data-slot":"switch-thumb",className:u("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{useAutoAnimate as Qr}from"@formkit/auto-animate/react";import{CheckCircleIcon as ts,TriangleAlertIcon as ns}from"lucide-react";import*as Le from"@radix-ui/react-popover";import{jsx as sn}from"react/jsx-runtime";function Hr({...e}){return sn(Le.Root,{"data-slot":"popover",...e})}function Kr({...e}){return sn(Le.Trigger,{"data-slot":"popover-trigger",...e})}function Vr({className:e,align:t="center",sideOffset:n=4,...o}){return sn(Le.Portal,{children:sn(Le.Content,{"data-slot":"popover-content",align:t,sideOffset:n,className:u("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...o})})}import{ClockIcon as es}from"lucide-react";import{jsx as _e,jsxs as ze}from"react/jsx-runtime";function $r({regularity:e}){let t="";switch(e){case"rarely":t="rzadko";break;case"often":t="cz\u0119sto";break;case"very_often":t="codzienne";break}return ze(Hr,{children:[_e(Kr,{onClick:n=>{n.stopPropagation()},children:ze("button",{type:"button",className:"flex w-[30%] cursor-help flex-col items-center justify-center text-xs md:w-[25%] xl:w-[20%]",children:[_e(es,{size:12}),_e("span",{children:t})]})}),_e(Vr,{className:"w-80",children:ze("div",{className:"grid gap-4",children:[ze("div",{className:"space-y-2",children:[_e("h4",{className:"leading-none font-medium",children:"Co to oznacza?"}),ze("ul",{className:"list-inside list-disc text-sm",children:[ze("li",{children:[_e("span",{className:"font-semibold",children:"Rzadko"})," \u2013 powiadomienia b\u0119d\u0105 wysy\u0142ane maksymalnie kilka razy w miesi\u0105cu."]}),ze("li",{children:[_e("span",{className:"font-semibold",children:"Cz\u0119sto"})," \u2013 powiadomienia mog\u0119 by\u0107 wysy\u0142ane kilka razy w tygodniu."]}),ze("li",{children:[_e("span",{className:"font-semibold",children:"Codzienne"})," \u2013 powiadomienia b\u0119d\u0105 wysy\u0142ane nawet codziennie."]})]})]}),_e("div",{className:"grid gap-2"})]})})]})}import{Fragment as os,jsx as re,jsxs as Se}from"react/jsx-runtime";function ln({groups:e=[],isManaging:t,onToggle:n,onCheckAll:o,onUpdate:r,isUpdating:a,wasChanged:i,isUserGroupsUpdated:l,className:c,texts:p}){let[s]=Qr(),[y]=Qr(),v=e.filter(d=>d.isOn===!1).length>0,m=e.filter(d=>d.isOn===!1).length>0;if(e.length<=1&&t!=!0)return null;let g=Se("div",{ref:s,className:u("my-5 flex flex-col gap-3",c?.groupsList),children:[e.map(d=>Se("div",{id:d.id,role:"button",className:u(d.isOn?"bg-neutral-50 hover:bg-transparent shadow-sm border-transparent dark:bg-neutral-800":"border-neutral-200 hover:bg-neutral-50 dark:hover:border-neutral-800 shadow-sm dark:border-neutral-800","active:bg-beige-300 flex w-full cursor-pointer items-center gap-3 rounded-xl border px-3 py-2 transition active:dark:bg-neutral-900",c?.groupItem),onClick:I=>{I.target instanceof HTMLButtonElement||n(d.id)},children:[re(ht,{checked:d.isOn,className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-700",onCheckedChange:()=>{n(d.id)}}),Se("div",{className:"flex flex-col items-start justify-start",children:[re("p",{className:"font-medium text-sm",children:d.name}),d.description&&re("p",{className:"text-xs font-light",children:d.description})]}),re("div",{className:"grow"}),d.howOften&&re($r,{regularity:d.howOften})]},d.id)),Se("div",{className:"flex gap-2",children:[t===!0&&Se(os,{children:[Se("div",{ref:y,className:"flex flex-col items-start justify-start",children:[i&&Se($,{variant:"default",size:"sm",className:"relative",disabled:a,onClick:r,children:[p?.groupsUpdateButton??j.groupsUpdateButton,a&&re("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:re(de,{})})]}),l&&Se("p",{className:"mt-3 flex items-center gap-2 text-sm text-green-500",children:[re(ts,{color:"var(--color-green-500",size:16})," ",p?.groupsUpdateSuccess??j.groupsUpdateSuccess]})]}),re("div",{className:"grow"})]}),m&&re("div",{className:"flex justify-start",children:re($,{className:"cursor-pointer dark:bg-neutral-700",onClick:o,size:"sm",variant:"secondary",type:"button",children:p?.groupsSelectAllButton??j.groupsSelectAllButton})})]}),v&&Se("div",{className:"flex text-left gap-2 text-xs text-yellow-500",children:[re(ns,{color:"orange",size:16}),p?.groupsNoSelectionWarning??j.groupsNoSelectionWarning]})]});return t==!0?Se(et,{className:"mt-5 text-left",children:[re(tt,{children:re(nt,{children:p?.groupsTitle??j.groupsTitle})}),re(ot,{children:g})]}):g}import{jsx as Ge,jsxs as Nt}from"react/jsx-runtime";function Xr({showQRCode:e=!0,isManaging:t,className:n,texts:o}){let r=typeof window<"u",a=r?!!window.matchMedia?.("(prefers-color-scheme: dark)").matches:!1;function i(l){return l?window.location.href:""}return e?Nt(et,{className:u("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",n?.qrCodeSection),children:[Ge(tt,{children:Nt(nt,{className:u("mb-3 text-base font-medium lg:text-lg",n?.qrCodeTitle),children:[o?.qrCodeSubtitle??j.qrCodeSubtitle," "+(o?.qrCodeTitle??j.qrCodeTitle)]})}),Nt(ot,{className:"flex flex-col items-center gap-2",children:[Nt("div",{className:"mt-1.5 mb-3 flex items-center gap-x-2",children:[Ge("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",target:"_blank",className:"max-w-28 flex-1 basis-1/2 lg:max-w-36",children:Ge("img",{className:"h-auto w-full",src:ue+"/app-store-logo.png",alt:"Download on App Store"})}),Ge("a",{href:"https://play.google.com/store/apps/details?id=com.bitsnap.Bitsnap&pli=1",target:"_blank",className:"max-w-28 flex-1 basis-1/2 lg:max-w-36",children:Ge("img",{className:"h-auto w-full",src:ue+"/google-play-logo.png",alt:"Get in on Google Play"})})]}),r&&Ge("div",{className:"flex items-center justify-center",children:Nt("div",{className:u("flex min-w-[40%] flex-col items-center gap-2 rounded-xl bg-white p-2 dark:bg-neutral-900",n?.qrCodeContainer),children:[Ge("img",{className:"mt-3 w-[80%] p-1 pt-3",src:ue+`/api/qr-gen?url=${i(r)}&bgColor=${a?"171717":"F6F4F0"}&textColor=${a?"ffffff":"000000"}&margin=0`}),Ge("p",{className:"text-xs md:text-sm",children:o?.qrCodeScanText??j.qrCodeScanText})]})})]})]}):null}import{useState as Rt}from"react";import{isValidPhoneNumber as ls}from"react-phone-number-input";import{useAutoAnimate as rs}from"@formkit/auto-animate/react";import{Label as Yr}from"@radix-ui/react-label";import{CheckCircleIcon as as,CircleAlertIcon as is,TriangleAlertIcon as ss}from"lucide-react";import{useState as Xn}from"react";import{jsx as fe,jsxs as Ue}from"react/jsx-runtime";function Zr({submit:e,isLoading:t,errMsg:n,emailLack:o,warnMsg:r,isSubmited:a,agreementLack:i,showPhoneInput:l=!1,agreementText:c,className:p,texts:s}){let[y,v]=Xn(""),[m,g]=Xn(""),[d,I]=Xn(!1),[R]=rs();function h(b){b.preventDefault(),e(y,m,d)}return Ue("form",{ref:R,onSubmit:h,className:u("flex flex-col gap-3 text-left",p?.formContainer),children:[Ue("div",{className:"flex flex-col gap-1 text-left",children:[fe(Yr,{className:"text-sm",htmlFor:"bts-notifications-form-email",children:s?.formEmailLabel??j.formEmailLabel}),fe(Cn,{value:y,onChange:b=>{v(b.currentTarget.value)},id:"bts-notifications-form-email",className:u(o===!0?"border-red-400":""),type:"email",placeholder:s?.formEmailPlaceholder??j.formEmailPlaceholder})]}),l&&Ue("div",{className:"flex flex-col gap-1 text-left",children:[Ue(Yr,{className:"text-sm",htmlFor:"bts-notifications-form-phone",children:[s?.formPhoneLabel??j.formPhoneLabel," ",fe("span",{className:"text-neutral-500 dark:text-neutral-500",children:s?.formPhoneOptional??j.formPhoneOptional})]}),fe(Cn,{value:m,onChange:b=>{g(b.currentTarget.value)},id:"bts-notifications-form-phone",className:"",type:"tel",autoComplete:"tel",autoCorrect:"off",placeholder:s?.formPhonePlaceholder??j.formPhonePlaceholder})]}),Ue("div",{className:"flex items-start gap-x-1.5",children:[fe("input",{className:"cursor-pointer",id:"bts-notifications-form-marketing-consent",type:"checkbox",checked:d,onChange:()=>{I(!d)}}),fe("label",{htmlFor:"bts-notifications-form-marketing-consent",className:u("cursor-pointer text-xs leading-4 transition-colors md:text-sm md:leading-4",i===!0?"text-yellow-700":""),children:c})]}),n.length>0&&Ue("p",{className:"mb-3 flex items-center gap-1 text-sm text-red-400",children:[fe(ss,{color:"#ff6467",size:16})," ",n]}),r.length>0&&Ue("p",{className:"mb-3 flex items-center gap-1 text-sm text-amber-400",children:[fe(is,{color:"var(--color-amber-400)",size:16})," ",r]}),a==!1&&fe("div",{className:"flex justify-start",children:Ue($,{variant:"default",disabled:t,className:u(t?"cursor-not-allowed text-transparent":"","relative"),children:[s?.formSubmitButton??j.formSubmitButton,t&&fe("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:fe(de,{})})]})}),a&&Ue("div",{className:"flex items-center gap-3 text-sm text-green-400",children:[fe(as,{size:16})," ",s?.formSuccessMessage??j.formSuccessMessage]})]})}import{jsx as Yn,jsxs as us}from"react/jsx-runtime";var cs=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;function Jr({groups:e,onToggle:t,onCheckAll:n,slug:o,showPhoneInput:r=!1,agreementText:a,className:i,texts:l,isUpdating:c,wasChanged:p,onSuccess:s}){let[y,v]=Rt(""),[m,g]=Rt(""),[d,I]=Rt(!1),[R,h]=Rt(!1),[b,A]=Rt(!1),{mutateAsync:x,isPending:E}=Re(ye.notifications.createNotificationUser);function D(w){return w==null?!1:ls(w,"PL")}async function S(w,C,U){if(v(""),g(""),A(!1),I(!1),h(!1),!U){h(!0),v("Zgoda w tym przypadku jest wymagana.");return}if(cs.test(w)===!1){v("Email jest nieprawid\u0142owy."),A(!0);return}C.length>0&&D(C)===!1&&g("Numer telefonu mo\u017Ce by\u0107 nieprawid\u0142owy. Zapisali\u015Bmy go ale je\u015Bli jest nieprawid\u0142owy to wpisz jeszcze raz i kliknij przycisk.");try{let f=await x({slug:o,email:w,phone:C,groups:e.filter(k=>k.isOn==!0).map(k=>k.id),mobileNotificationEnabled:!0,emailNotificationEnabled:!0,smsNotificationEnabled:!0});if(f.result.case==="success"){I(!0),setTimeout(()=>{s?.(!1,f.userId,f.accessToken)},1e3);return}else{I(!0);let k=f.result.value;if(k!=null){if(k==32){s?.(!0,void 0,void 0);return}console.log(`Code error: ${vn[k]}`),v("Wyst\u0105pi\u0142 b\u0142\u0105d: "+vn[k]);return}return}}catch(f){v("Wyst\u0105pi\u0142 b\u0142\u0105d podczas zapisywania. Spr\xF3buj ponownie."),console.log(`Error: ${f}`)}}let T=l?.formTitle??j.formTitle;return us("div",{className:u("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",i?.formSection),children:[T.length>0&&Yn("h3",{className:u("mb-3 text-base font-medium lg:text-lg",i?.formTitle),children:T}),Yn(ln,{groups:e,isManaging:!1,onToggle:t??(()=>{}),onCheckAll:n??(()=>{}),isUpdating:c??!1,wasChanged:p??!1,isUserGroupsUpdated:!1,className:i,texts:l}),Yn(Zr,{errMsg:y,emailLack:b,warnMsg:m,submit:S,isLoading:E,isSubmited:d,agreementLack:R,showPhoneInput:r,agreementText:a??l?.agreementText??j.agreementText,className:i,texts:l})]})}import{useEffect as gs,useState as At}from"react";import{Label as Zn}from"@radix-ui/react-label";import{MessageCircleWarningIcon as ys}from"lucide-react";import{useDebouncedCallback as hs}from"use-debounce";import{TriangleAlertIcon as ds,XIcon as ps}from"lucide-react";import{createPortal as ms}from"react-dom";import{useEffect as ea,useState as fs}from"react";import{jsx as he,jsxs as vt}from"react/jsx-runtime";function ta({open:e,onOpenChange:t,onConfirm:n,isDeleting:o=!1}){let[r,a]=fs(!1);if(ea(()=>(a(!0),()=>a(!1)),[]),ea(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),!r||!e)return null;let i=c=>{c.target===c.currentTarget&&t(!1)},l=()=>{n()};return ms(he("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/50 p-4",onClick:i,children:vt("div",{className:u("relative w-full max-w-md rounded-2xl bg-white p-6 shadow-lg","dark:bg-neutral-800","animate-in fade-in-0 zoom-in-95 duration-200"),onClick:c=>c.stopPropagation(),children:[vt("button",{onClick:()=>t(!1),className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-neutral-950 focus:ring-offset-2 disabled:pointer-events-none dark:ring-offset-neutral-950 dark:focus:ring-neutral-300",disabled:o,children:[he(ps,{className:"h-4 w-4"}),he("span",{className:"sr-only",children:"Zamknij"})]}),vt("div",{className:"flex flex-col gap-4",children:[vt("div",{className:"flex items-start gap-3",children:[he("div",{className:"flex-shrink-0",children:he(ds,{className:"h-6 w-6 text-amber-500","aria-hidden":"true"})}),he("div",{className:"flex-1",children:he("h2",{className:"text-lg font-semibold text-black dark:text-neutral-100",children:"Czy na pewno chcesz si\u0119 wypisa\u0107?"})})]}),he("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Klikni\u0119cie tego przycisku spowoduje wypisanie z wszelkich powiadomie\u0144 i grup, kt\xF3re zapisa\u0142e\u015B."}),vt("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[he($,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:o,className:"sm:min-w-[100px]",children:"Anuluj"}),vt($,{type:"button",variant:"destructive",onClick:l,disabled:o,className:u(o&&"cursor-not-allowed text-transparent","relative sm:min-w-[100px]"),children:["Usu\u0144",o&&he("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:he("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"})})]})]})]})]})}),document.body)}import{useAutoAnimate as na}from"@formkit/auto-animate/react";import{Fragment as vs,jsx as H,jsxs as ve}from"react/jsx-runtime";function oa({accessToken:e,slug:t,userID:n,className:o,texts:r}){let[a]=na(),[i]=na(),{mutateAsync:l,isPending:c}=Re(ye.notifications.deleteNotificationUser),{mutateAsync:p,isPending:s}=Re(ye.notifications.updateNotificationUser),{data:y,isFetching:v}=qt(ye.notifications.getNotificationUserSettings,{userId:n,slug:t,accessToken:e}),[m,g]=At(!1),[d,I]=At(!1),[R,h]=At(!1),[b,A]=At(!1),[x,E]=At(!1),D=y?.result.case==="success"?y?.result?.value:void 0;function S(){E(!0)}async function T(){await l({accessToken:e,slug:t,userId:n}),E(!1)}async function w(){await p({accessToken:e,slug:t,notificationUserId:n,mobileNotificationEnabled:b,emailNotificationEnabled:m,smsNotificationEnabled:d}),h(!0),setTimeout(()=>{h(!1)},3e3)}let C=hs(f=>{w()},300);gs(()=>{let f=y?.result.case==="success"?y?.result?.value:void 0;g(f?.emailNotificationEnabled??!1),I(f?.smsNotificationEnabled??!1),A(f?.mobileNotificationEnabled??!1)},[y]);function U(f,k){f==="email"&&g(k),f==="phone"&&I(k),f==="push"&&A(k),C(!0)}return ve("div",{className:u("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",o?.manageDataSection),children:[H("div",{className:"flex justify-start",children:H("h3",{className:u("mb-3 text-base font-medium lg:text-lg",o?.manageDataTitle),children:r?.manageDataTitle??j.manageDataTitle})}),v?H(Eo,{className:"h-64 w-full"}):ve(et,{ref:i,className:u(s&&"relative"),children:[H(tt,{children:H(nt,{children:H("p",{className:"text-sm text-left",children:r?.manageDataDescription??j.manageDataDescription})})}),ve(ot,{ref:a,children:[H("div",{className:u(s&&"opacity-50 pointer-events-none","flex flex-col gap-2"),children:ve("div",{className:"flex flex-col items-start gap-5 gap-x-2",children:[D?.emailNotificationAvailable&&ve("div",{className:"flex items-center gap-3",children:[H(ht,{id:"email-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:m,onCheckedChange:()=>{U("email",!m)}}),H(Zn,{htmlFor:"email-enabled",className:"text-sm",children:"Email"})]}),D?.smsNotificationAvailable&&ve("div",{className:"flex items-center gap-3",children:[H(ht,{id:"sms-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:d,onCheckedChange:()=>{U("phone",!d)}}),H(Zn,{htmlFor:"sms-enabled",className:"text-sm",children:"SMS"})]}),D?.mobileNotificationAvailable&&ve(vs,{children:[ve("div",{className:"flex items-center gap-3",children:[H(ht,{id:"push-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:b,onCheckedChange:()=>{U("push",!b)}}),H(Zn,{htmlFor:"push-enabled",className:"text-sm",children:"Powiadomienia na telefon"})]}),D?.hasUserInstalledApp===!1&&ve("div",{className:"flex items-center gap-3",children:[H(ys,{color:"var(--color-amber-500)",size:26}),H("p",{className:"text-xs text-amber-500",children:"Wygl\u0105da na to, \u017Ce nie masz zainstalowanej aplikacji mobilnej. Zainstaluj i wyra\u017A zgod\u0119 na otrzymywanie powiadomie\u0144 na telefon."})]})]})]})}),ve("div",{className:"mt-5 flex flex-col gap-2 text-left",children:[H("hr",{}),R&&H("p",{className:"text-xs text-green-500",children:r?.manageDataUpdatedMessage??j.manageDataUpdatedMessage}),H("div",{className:"flex items-center gap-x-2",children:ve($,{size:"sm",variant:"link",className:u("pl-0 ml-0",c&&"cursor-not-allowed"),onClick:S,children:[r?.manageDataUnsubscribeButton??j.manageDataUnsubscribeButton,c&&H("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:H(de,{})})]})})]})]}),s&&H("div",{className:"bg-black/30 absolute inset-0 rounded-xl",children:H("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:H(de,{})})})]}),H(ta,{open:x,onOpenChange:E,onConfirm:T,isDeleting:c})]})}import{useAutoAnimate as ks}from"@formkit/auto-animate/react";import{ArrowLeft as ws}from"lucide-react";import{useMemo as pa,useRef as Is}from"react";import*as ae from"@radix-ui/react-dialog";import{XIcon as bs}from"lucide-react";import{jsx as Fe,jsxs as Jn}from"react/jsx-runtime";function ra({...e}){return Fe(ae.Root,{"data-slot":"dialog",...e})}function Cs({...e}){return Fe(ae.Portal,{"data-slot":"dialog-portal",...e})}function Ps({className:e,...t}){return Fe(ae.Overlay,{"data-slot":"dialog-overlay",className:u("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function aa({className:e,children:t,showCloseButton:n=!0,...o}){return Jn(Cs,{"data-slot":"dialog-portal",children:[Fe(Ps,{}),Jn(ae.Content,{"data-slot":"dialog-content",className:u("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...o,children:[t,n&&Jn(ae.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[Fe(bs,{}),Fe("span",{className:"sr-only",children:"Close"})]})]})]})}function ia({className:e,...t}){return Fe(ae.Title,{"data-slot":"dialog-title",className:u("text-lg leading-none font-semibold",e),...t})}function sa({className:e,...t}){return Fe(ae.Description,{"data-slot":"dialog-description",className:u("text-muted-foreground text-sm",e),...t})}import{Code as la,ConnectError as xs}from"@connectrpc/connect";function ua(e,t="pl"){let n=e.loginCodeSentMessage,o={emailLabel:e.loginEmailLabel,emailPlaceholder:e.loginEmailPlaceholder,sendCode:e.loginSendCodeButton,sending:e.loginSendingButton,invalidEmail:e.loginInvalidEmailError,codeSentTo:n!=null?`${n} {email}.`:void 0,changeEmail:e.loginChangeEmailButton,verify:e.loginVerifyButton,spamHint:e.loginSpamHint,validity:e.loginValidityHint,resend:e.loginResendCodeButton,resendIn:e.loginResendInText,resent:e.loginResentMessage,haveCodePrompt:"",haveCode:e.loginIHaveCode,wrongCode:e.loginInvalidCodeError,expired:e.loginExpiredError,tooManyAttempts:e.loginTooManyAttemptsError,rateLimited:e.loginRateLimitedError,network:e.loginNetworkError,generic:e.loginVerifyCodeError,deliveryFailed:e.loginSendEmailError,verifying:e.loginVerifyingButton,stepEmail:e.loginStepEmailHint,stepCode:e.loginStepCodeHint,alreadySent:e.loginAlreadySentMessage,emailNotFound:e.loginEmailNotFoundError,deliveryUnavailable:e.loginDeliveryUnavailableError,resendNew:e.loginResendNewCodeButton,noCode:e.loginNoCodeButton,codeIncomplete:e.loginCodeIncompleteError};return wo(t,o)}function ca(e){let t=xs.from(e),n=t.rawMessage||t.message;return t.code===la.ResourceExhausted?/too many attempts/i.test(n)?"tooManyAttempts":"rateLimited":/invalid code/i.test(n)?"wrongCode":/expired/i.test(n)?"expired":t.code===la.Unavailable?"unknown":bo(e)}function da(e,t,n){return{async send(o,{resend:r}){if(!t)return{ok:!1,kind:"unknown",message:n.loginSlugRequiredError};try{let a=await e({email:o,slug:t});return a.ok===!1?a.retryIn!=null&&a.retryIn>0?{ok:!1,kind:"rateLimited",retryIn:a.retryIn}:{ok:!1,kind:"deliveryFailed",message:r?n.loginResendEmailError:n.loginSendEmailError}:a.sent===!1?{ok:!1,kind:"alreadySent",retryIn:a.retryIn||void 0}:{ok:!0,retryIn:a.retryIn||void 0}}catch(a){let i=ca(a);return{ok:!1,kind:i,cause:a,message:i==="unknown"?r?n.loginResendEmailError:n.loginSendEmailError:void 0}}},async verify({email:o,code:r}){try{let a=await e({email:o,code:r,slug:t});return a.ok&&a.accessToken?{ok:!0,value:{userId:a.userId,accessToken:a.accessToken}}:{ok:!1,kind:"wrongCode",message:n.loginVerificationFailedError}}catch(a){return{ok:!1,kind:ca(a),cause:a}}}}}import{jsx as Oe,jsxs as ma}from"react/jsx-runtime";function Ss({slug:e,onSuccess:t,onError:n,texts:o,projectName:r,projectLogo:a,projectLogoDark:i,showLogo:l}){let[c]=ks(),{mutateAsync:p}=Re(ye.notifications.verifyUserEmail),s=pa(()=>ua(o),[o]),[y,v]=s.codeSentTo.split("{email}"),m=Is(n);m.current=n;let g=pa(()=>{let h=da(b=>p(b),e,o);return{...h,async verify(b){let A=await h.verify(b);return!A.ok&&A.kind==="wrongCode"&&m.current?.(A.cause instanceof Error?A.cause:new Error(A.message??"wrongCode")),A}}},[p,e,o]),d=Io({adapter:g,texts:s,storageKey:e?xo("notifications",e):void 0,onVerified:({userId:h,accessToken:b})=>t?.(h,b),onFailure:(h,b)=>n?.(b instanceof Error?b:new Error(h))}),I=d.step==="code",R=I&&!d.needsEmail?o.loginCodeLabel??"":o.loginTitle??"";return ma("div",{className:"flex h-full flex-col",children:[Oe(Po,{projectId:e,name:r,showLogo:l,logoUrl:a,logoDarkUrl:i,className:"text-foreground mb-3"}),ma("div",{ref:c,className:"mb-2 flex items-start gap-2",children:[I&&Oe($,{type:"button",variant:"ghost",size:"icon-sm",className:"-mt-2 -ml-2 size-11 shrink-0","aria-label":s.changeEmail,disabled:d.isBusy,onClick:d.changeEmail,children:Oe(ws,{className:"h-5 w-5","aria-hidden":!0})}),Oe(ia,{className:"text-lg leading-6 font-semibold",children:R})]}),Oe(sa,{className:I?"sr-only":"mb-4",children:I?`${y}${d.email}${v??""}`:o.loginDescription??""}),Oe(So,{login:d,texts:s})]})}function fa({slug:e,onSuccess:t,onError:n,className:o,isOpen:r,onClose:a,texts:i,projectName:l,projectLogo:c,projectLogoDark:p,showLogo:s}){return Oe(ra,{open:r,onOpenChange:a,children:Oe(aa,{className:"max-h-[100dvh] overflow-y-auto sm:max-w-[425px]",children:Oe(Ss,{slug:e,onSuccess:t,onError:n,texts:i,projectName:l,projectLogo:c,projectLogoDark:p,showLogo:s})})})}import{useAutoAnimate as As}from"@formkit/auto-animate/react";import{jsx as ne,jsxs as eo}from"react/jsx-runtime";function Ds(e,t){switch(t.type){case"SET_IS_LOGGED_IN":return{...e,isLoggedIn:t.value};case"SET_USER_ID":return{...e,userID:t.value};case"SET_LOADING":return{...e,isLoading:t.value};case"SET_PUBLIC_GROUPS":return{...e,groupsProvided:t.value,groups:t.value!=null&&t.value.length>0?e.groups.filter(n=>t.value?.find(o=>o.id===n.id)!=null):e.groups};case"SET_GROUPS":{let n=e.isLoggedIn==!1||e.groupsProvided!=null,o=t.value.map(r=>e.isLoggedIn==!0?r:{...r,isOn:e.groupsProvided?.find(a=>a.id===r.id)?.isOn??n});return{...e,groups:o}}case"TOGGLE_GROUP":{let n=e.groups.map(o=>o.id===t.groupID?{...o,isOn:!o.isOn}:o);return{...e,wasChanged:!0,groups:n}}case"CHECK_ALL_GROUPS":{let n=e.groups.map(o=>({...o,isOn:!0}));return{...e,groups:n,wasChanged:!0}}case"SET_WAS_CHANGED":return{...e,wasChanged:t.value};case"SET_IS_USER_GROUPS_UPDATED":return{...e,isUserGroupsUpdated:t.value};case"RESET_UPDATE_STATE":return{...e,wasChanged:!1,isUserGroupsUpdated:!0};case"SHOW_SETTINGS":return{...e,showSettings:!0};case"HIDE_SETTINGS":return{...e,showSettings:!1};default:return e}}function Ls({slug:e,userID:t,productID:n,projectID:o,analytics:r,projectName:a,projectLogo:i,projectLogoDark:l,showLoginLogo:c,groups:p,isManaging:s=!1,texts:y,showQRCode:v=!1,showPhoneInput:m=!1,hiddenGroupIds:g=[],className:d}){let[I]=As(),R=me(o??ke(),r),h=e??ce()??(typeof window<"u"?window.location.hostname:"");Co(h.trim(),c!==!1&&!i&&!l&&h.trim()!=="");let{mutateAsync:b,isPending:A}=Re(ye.notifications.updateUserGroups),{data:x,refetch:E}=Ns({queryKey:["notifications_accessToken"],queryFn:()=>{if(typeof window<"u")return{accessToken:localStorage.getItem("notifications_accessToken")??void 0,userID:localStorage.getItem("notifications_userID")??void 0}}}),{data:D,isPending:S,refetch:T}=qt(ye.notifications.getUserGroups,{slug:h,accessToken:x?.accessToken}),[w,C]=Es(Ds,{isLoading:S,isUserGroupsUpdated:!1,wasChanged:!1,groupsProvided:p,groups:[],showSettings:x!=null&&s==!0,isLoggedIn:x!=null,userID:void 0});Dt(()=>{C({type:"SET_LOADING",value:A||S})},[A,S]),Dt(()=>{C({type:"SET_IS_LOGGED_IN",value:x?.accessToken!=null}),C({type:"SET_USER_ID",value:x?.userID}),x?.accessToken!=null&&s==!0&&C({type:"SHOW_SETTINGS"})},[x,s]),Dt(()=>{if(D==null)return;let W=D.groups.map(F=>{let V="rarely";switch(F.howOften){case 0:V="rarely";break;case 1:V="often";break;case 2:V="veryOften";break}return{id:F.id,name:F.name,description:F.description,howOften:V,isOn:F.isOn??void 0}});C({type:"SET_GROUPS",value:W})},[D,S,p]);let U=Ts(null);Dt(()=>{let W=p?.map(F=>(F.id.startsWith("group_")||(F.id=`group_${F.id}`),F));C({type:"SET_PUBLIC_GROUPS",value:W})},[p]);let f={...j,...y};async function k(){await b({accessToken:x?.accessToken,slug:h,userId:t,groupIds:w.groups.filter(W=>W.isOn===!0).map(W=>W.id)}),C({type:"RESET_UPDATE_STATE"}),U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{C({type:"SET_IS_USER_GROUPS_UPDATED",value:!1})},2e3)}function X(W){C({type:"TOGGLE_GROUP",groupID:W})}function be(){C({type:"CHECK_ALL_GROUPS"})}function Me(){C({type:"SHOW_SETTINGS"})}function M(){C({type:"HIDE_SETTINGS"})}function O(){localStorage.removeItem("notifications_accessToken"),localStorage.removeItem("notifications_userID"),E(),C({type:"SET_USER_ID",value:void 0}),C({type:"SET_IS_LOGGED_IN",value:!1}),C({type:"HIDE_SETTINGS"})}async function N(W,F){typeof window<"u"&&(localStorage.setItem("notifications_accessToken",F),W!=null&&localStorage.setItem("notifications_userID",W)),C({type:"SET_USER_ID",value:W});try{await E(),T().then().catch().finally(()=>{s==!0&&C({type:"SHOW_SETTINGS"})})}catch(V){console.log(`Error: ${V}`)}}Dt(()=>()=>{U.current&&clearTimeout(U.current)},[]);let _=s==!0&&w.userID!=null&&x?.accessToken!=null;return eo("main",{className:u("bitsnap-react relative",d?.container),children:[f.title!=null&&ne("h1",{className:"text-2xl font-semibold text-black md:text-3xl lg:text-4xl xl:text-5xl dark:text-neutral-100",children:f.title}),!w.showSettings&&s&&ne($,{onClick:Me,variant:"outline",size:"icon",className:"absolute bottom-6 right-6 z-50 h-12 w-12 rounded-full shadow-lg hover:shadow-xl md:bottom-8 md:right-8","aria-label":"Settings",children:ne(Rs,{className:"h-5 w-5"})}),ne("div",{className:u("md:pt8 relative z-0 mt-6 overflow-hidden rounded-2xl bg-white px-3 pt-6 pb-3 md:px-5 md:pb-5 dark:bg-neutral-800",d?.header),children:w.showSettings?ne("div",{className:"space-y-6",children:w.isLoggedIn&&eo("div",{className:u("grid grid-cols-1 gap-3 lg:gap-6",_?"md:grid-cols-2":""),children:[eo("div",{className:d?.groupsContainer,children:[ne(Fr,{projectName:a,projectLogo:i,projectLogoDark:l,description:f.managingDescription,className:d,onLogout:O}),S&&ne("div",{className:"flex justify-center items-center py-8",children:ne(de,{})}),ne(ln,{groups:w.groups,hiddenGroupIds:g,isManaging:s,onToggle:X,onCheckAll:be,onUpdate:k,isUpdating:A,wasChanged:w.wasChanged,isUserGroupsUpdated:w.isUserGroupsUpdated,className:d,texts:f})]}),_&&ne(oa,{accessToken:x.accessToken??"",slug:h,userID:w.userID??"",className:d,texts:f}),v!=!1&&ne(Xr,{showQRCode:v,isManaging:!0,className:d,texts:f})]})}):ne("div",{className:u("grid grid-cols-1 gap-3 lg:gap-6"),children:ne(Jr,{slug:h,onToggle:W=>{C({type:"TOGGLE_GROUP",groupID:W})},onCheckAll:()=>{C({type:"CHECK_ALL_GROUPS"})},onSuccess:(W,F,V)=>{R.track("availability_signup",{},{product_id:n??null}),V!=null&&N(F,V),W&&C({type:"SHOW_SETTINGS"})},groups:w.groups,showPhoneInput:m,agreementText:f.agreementText,className:d,texts:f,wasChanged:w.wasChanged,isUpdating:A})})}),ne(fa,{isOpen:w.showSettings&&!w.isLoggedIn,slug:h,onSuccess:N,texts:f,onClose:M,projectName:a,projectLogo:i,projectLogoDark:l,showLogo:c})]})}function _s({slug:e,userID:t,productID:n,projectID:o,analytics:r,projectName:a,projectLogo:i,projectLogoDark:l,showLoginLogo:c,groups:p,isManaging:s,texts:y,showQRCode:v,showPhoneInput:m,hiddenGroupIds:g,className:d}){return ne(bn,{children:ne(Ls,{slug:e,userID:t,productID:n,projectID:o,analytics:r,projectName:a,projectLogo:i,projectLogoDark:l,showLoginLogo:c,groups:p,isManaging:s,texts:y,showQRCode:v,showPhoneInput:m,hiddenGroupIds:g,className:d})})}var Us=_s;import{useMutation as Lt,useQuery as _t,useQueryClient as Bs}from"@tanstack/react-query";import ga from"react";import{jsx as cn,jsxs as un}from"react/jsx-runtime";function ya({choice:e,selected:t,onChange:n,disabled:o}){let r=at(),a=L("paymentMethods"),i=L("paymentMethodOption"),l=ga.useId(),c=ga.useId(),p=e.manualAccountTypes.length===0||e.manualAccountTypes.includes("blik"),s={online:{title:r("paymentMethodOnline"),description:r("paymentMethodOnlineDescription")},manual:{title:r(Do(e.manualAccountTypes)),description:r("paymentMethodManualDescription"),note:p?r("paymentMethodManualBlikNote"):void 0},cod:{title:r("paymentMethodCod"),description:r("paymentMethodCodDescription")}};return un("fieldset",{"data-bitsnap-checkout-slot":"paymentMethods","aria-labelledby":c,className:u("mx-2 mt-4 mb-2 flex min-w-0 flex-col gap-2 border-0 p-0",a.className),style:a.style,disabled:o,children:[cn("legend",{id:c,className:"mb-1 px-1 text-sm font-medium",children:r("paymentMethodLegend")}),e.methods.map(y=>{let v=s[y],m=y===t,g=`${l}-${y}-description`;return un("label",{"data-bitsnap-checkout-slot":"paymentMethodOption","data-payment-method":y,"data-selected":m?"":void 0,className:u("flex cursor-pointer items-start gap-3 rounded-md border px-3 py-2.5 transition-colors",i.className),style:i.style,children:[cn("input",{type:"radio",name:l,value:y,checked:m,onChange:()=>n(y),"aria-describedby":g,className:"mt-0.5 size-4 shrink-0 cursor-pointer"}),un("span",{className:"flex min-w-0 flex-col gap-0.5",children:[cn("span",{className:"text-sm font-semibold leading-snug",children:v.title}),un("span",{id:g,"data-bitsnap-checkout-payment-method-description":"",className:"text-xs leading-snug",children:[v.description,m&&v.note!=null&&cn("span",{className:"mt-1 block font-medium",children:v.note})]})]})]},y)})]})}import{Fragment as qs,jsx as B,jsxs as ge}from"react/jsx-runtime";var js=({className:e,locale:t})=>{let n=it(),o=xe(),r=t??Ne(),a=L("productList"),i=L("summary"),l=L("totalLabel"),c=L("totalValue"),p=L("deliveryText"),s=L("summaryNote"),y=L("countryLabel"),v=L("paymentButtons"),m=L("checkoutButton"),g=L("emptyState"),d=L("error"),I=L("skeleton"),R=z("unavailableProducts"),h=at(),b=z("emptyCart"),A=z("total"),x=z("delivery"),E=z("chooseCountry"),D=z("nextStep"),S=z("loadFailed"),T=z("retry"),w=z("countryRequired"),C=z("extrasCalculatedNext"),U=ee.useId(),f=ee.useId(),{mutateAsync:k}=Lt({mutationFn:n.removeProductFromCart}),{mutateAsync:X}=Lt({mutationFn:n.updateQuantity}),{mutateAsync:be}=Lt({mutationFn:n.setCountry}),{mutateAsync:Me}=Lt({mutationFn:n.clearCart}),[M,O]=ee.useState(""),N=Ke(P=>P.notice);ee.useEffect(()=>()=>Ke.getState().setNotice(void 0),[]);let _=M.length>0?M:N??"",[W,F]=ee.useState([]),[V,We]=ee.useState(!1),{mutateAsync:mn,isPending:Te}=Lt({mutationFn:n.redirectToNextStep}),{data:fn}=_t({queryKey:["cart-available-countries"],queryFn:n.getAvailableCountries}),{data:gn}=_t({queryKey:["cart-one-click-payment"],queryFn:n.checkIfApplePayIsAvailable}),{data:Y,isLoading:oe,isError:bt,refetch:to}=_t({queryKey:["cart",r],queryFn:n.getProducts}),{data:He,refetch:no}=_t({queryKey:["cart-country"],queryFn:n.getCountry}),[Ca]=Ms(),q=Q(Y)?void 0:Y,Be=He!=null&&!Q(He)&&He!=""?He:void 0,oo=Bs(),Ot=q==null||q.length===0||Be==null?void 0:q.map(P=>`${P.productID}:${P.quantity}`).sort().join(","),ro={queryKey:["cart-payment-methods",ce(),r,Be,Ot],queryFn:async()=>n.getPaymentMethodChoice().catch(()=>null),staleTime:6e4,retry:!1},{data:ao,isPlaceholderData:Pa}=_t({...ro,enabled:Ot!=null,placeholderData:P=>P===void 0?void 0:Ao(P)}),Mt=Ot!=null?ao??null:null,[io,xa]=ee.useState(void 0),[so,lo]=ee.useState(!1),co=ee.useRef(null),uo=!oe&&(bt||Q(Y)),je=Q(fn)?[]:fn,Ct=q?.reduce((P,K)=>K.details==null?P:P+(K.details.pricing?.effectivePrice??K.details.price)*K.quantity,0)??0,Pt=q?.[0]?.details?.currency??"PLN",ka=q?.some(P=>P.details?.isDeliverable===!0)??!1,po=He!==void 0&&Be==null,mo=ee.useRef(!1);ee.useEffect(()=>{mo.current||je==null||je.length===0||He==null||Be!=null&&je.some(P=>P.code===Be)||(mo.current=!0,be(je[0].code).then(()=>no()).catch(()=>{}))},[je,He,Be]);let fo=ee.useRef(!1);ee.useEffect(()=>{fo.current||oe||(fo.current=!0,o.track("cart_opened",{item_count:q?.reduce((P,K)=>P+K.quantity,0)??0,value_minor:Ct,currency:Pt}))},[oe,o,q,Ct,Pt]);let yn=ee.useRef(new Map);ee.useEffect(()=>{yn.current.clear()},[q]);function wa(P,K){let se=q?.find(Ea=>Ea.id===P);if(se?.details==null)return;let le=K-(yn.current.get(P)??se.quantity);if(yn.current.set(P,K),le===0)return;let Ce=se.details.pricing?.effectivePrice??se.details.price,Bt=se.catalogProductID??se.productID;o.track(le>0?"add_to_cart":"remove_from_cart",{qty:Math.abs(le),value_minor:Math.round(Ce*Math.abs(le)),currency:se.details.currency},{product_id:Bt,variant_id:Bt!==se.productID?se.productID:null})}let go=ee.useRef(!1);async function Ia(P,K){if(K!=null){wa(P,Math.max(0,K));try{let se=K<=0?await k({id:P}):await X({id:P,quantity:K});if(Q(se))throw new Error(`cannot change the cart: ${se.error}`)}finally{await to().catch(()=>{})}}}async function Sa(){try{O(""),F([]),Ke.getState().setNotice(void 0);let P=Mt,K=P!=null?Pn(P,io):void 0;if(Ot!=null&&(ao===void 0||Pa)){lo(!0);try{P=await oo.fetchQuery(ro).catch(()=>null)}finally{lo(!1)}if(P==null)K=void 0;else if(K==null||!P.methods.includes(K)){window.setTimeout(()=>{co.current?.querySelector("input:checked")?.focus()},0);return}}if(q!=null){!go.current&&q.length>0&&(go.current=!0,o.track("checkout_started",{item_count:q.reduce((Ce,Bt)=>Ce+Bt.quantity,0),checkout_type:"cart",value_minor:Ct,currency:Pt}));try{Ae({event:"initiateCheckout",items:q?.map(Ce=>({id:Ce.productID,name:Ce.details?.name??"",price:Ce.details?.price??0,quantity:Ce.quantity,currency:Ce.details?.currency??"PLN"}))})}catch{}}let se=_o(),le=await mn(K!=null?{paymentMethod:K}:void 0);if(Q(le)){oo.invalidateQueries({queryKey:["cart-payment-methods"]}),le.error=="item-ids-not-found"?(O(R),"data"in le&&Array.isArray(le.data)&&F(le.data)):K==="cod"&&le.error=="gateway-not-configured"?O(h("paymentMethodCodUnavailable")):O(Ro(le,h));return}Lo(le,{cartProjectId:ce(),lines:se})||await Me(),window.location.href=le.url}catch(P){console.warn("checkout failed",P),O(h("checkoutFailed"))}}return ge("div",{className:`${e} flex flex-col`,ref:Ca,children:[oe&&ge("div",{className:"relative flex w-full justify-center flex-col gap-4",children:[B(Nn,{"data-bitsnap-checkout-slot":"skeleton",className:u("w-full h-32",I.className),style:I.style}),B(Nn,{"data-bitsnap-checkout-slot":"skeleton",className:u("w-full h-32",I.className),style:I.style})]}),uo&&ge("div",{className:"flex flex-col items-start gap-3 p-4",children:[B("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:u(d.className),style:d.style,children:S}),N!=null&&N.length>0&&B("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:u("text-sm",d.className),style:d.style,children:N}),B("button",{type:"button","data-bitsnap-checkout-slot":"checkoutButton",onClick:()=>{to().then().catch()},className:u("px-3 py-2 rounded-md transition font-bold",m.className),style:m.style,children:T})]}),!oe&&!uo&&(q==null||q.length==0)&&ge("div",{className:"flex flex-col gap-4 p-4",children:[B("p",{"data-bitsnap-checkout-slot":"emptyState",className:u(g.className),style:g.style,children:b}),N!=null&&N.length>0&&B("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:u("text-sm",d.className),style:d.style,children:N})]}),B("div",{"data-bitsnap-checkout-slot":"productList",className:u("max-h-[70vh] overflow-clip overflow-y-scroll",a.className),style:a.style,children:q!=null&&q.length>0&&B("ul",{className:"mt-5",children:q.map(P=>B(ee.Fragment,{children:P.details!=null&&ge("li",{className:"mb-3",children:[B(er,{isNotAvailable:W.includes(P.productID),quantity:P.quantity,details:P.details,url:P.url,shouldUpdate:K=>Ia(P.id,K)}),B("hr",{className:"h-1"})]})},P.id))})}),B("div",{className:"grow"}),Ct>0&&Pt!=null&&ge(qs,{children:[ge("div",{"data-bitsnap-checkout-slot":"summary",className:u("mx-3 flex flex-col",i.className),style:i.style,children:[ge("div",{className:"flex flex-row justify-between text-lg",children:[B("p",{"data-bitsnap-checkout-slot":"totalLabel",className:u("text-xl",l.className),style:l.style,children:A}),ge("div",{className:"flex flex-col items-end",children:[B("p",{"data-bitsnap-checkout-slot":"totalValue",className:u("font-medium",c.className),style:c.style,children:Ve(Ct,Pt)}),ka&&B("p",{"data-bitsnap-checkout-slot":"deliveryText",className:u("opacity-70 text-right text-base",p.className),style:p.style,children:x})]})]}),B("p",{"data-bitsnap-checkout-slot":"summaryNote",className:u("opacity-70 text-sm",s.className),style:s.style,children:C})]}),je&&je?.length>1&&ge("div",{children:[B("h4",{"data-bitsnap-checkout-slot":"countryLabel",className:u("ml-3 text-sm",y.className),style:y.style,children:E}),B($o,{id:U,open:V,onToggle:()=>{We(!V)},onChange:P=>{be(P).then(()=>{no().then().catch()})},selectedValue:Be??"",countries:je})]}),ge("div",{className:"mb-3 flex flex-col",children:[gn&&q!=null&&q.length>0&&B("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:u("w-full px-2",v.className),style:v.style,children:B(Rn,{colorType:"white",style:{width:"100%"},items:q?.map(P=>({name:P.details?.name??"",id:P.productID,price:P.details?.pricing?.effectivePrice??P.details?.price??0,currency:P.details?.currency,quantity:P.quantity,isDeliverable:P.details?.isDeliverable??!1,metadata:P.metadata}))})}),q!=null&&q.length>0&&B("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:u("w-full px-2",v.className),style:v.style,children:B(An,{buttonSizeMode:"fill",buttonColor:"white",style:{width:"100%"},items:q?.map(P=>({name:P.details?.name??"",id:P.productID,price:P.details?.pricing?.effectivePrice??P.details?.price??0,quantity:P.quantity,isDeliverable:P.details?.isDeliverable??!1,metadata:P.metadata}))})}),q!=null&&q.length>0&&ge("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:u("w-full px-2",v.className),style:v.style,children:[B(Gn,{projectID:ce()??"",locale:r}),B($n,{projectID:ce()??"",locale:r})]}),Mt!=null&&B("div",{ref:co,className:"contents",children:B(ya,{choice:Mt,selected:Pn(Mt,io),onChange:xa,disabled:Te})}),B("button",{"data-bitsnap-checkout-slot":"checkoutButton",onClick:Sa,disabled:oe||Te||so||Be==null,"aria-describedby":po?f:void 0,className:u("px-3 py-2 my-2 mx-2 rounded-md disabled:opacity-40 disabled:cursor-not-allowed transition font-bold",m.className),style:m.style,children:Te||so?B(de,{}):D}),po&&B("p",{id:f,className:"text-sm text-center opacity-70",children:w}),_.length>0&&B("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:u("text-sm text-center",d.className),style:d.style,children:_})]})]})]})},ha=js;import{jsx as pe,jsxs as dn}from"react/jsx-runtime";function Ks({isVisible:e,shouldHide:t,panelId:n,locale:o}){let[r]=zs(),[a,i]=Ws(null),l=Gs(b=>{r(b),i(b)},[r]),c=Fs(null),{boundaryClassName:p,boundaryStyle:s}=kt(),y=L("root"),v=L("overlay"),m=L("panel"),g=L("header"),d=L("title"),I=L("closeButton"),R=z("cart"),h=z("close");return pe("div",{ref:l,"data-bitsnap-checkout":"root","data-bitsnap-checkout-slot":"root",className:u("bitsnap-react",p,y.className),style:{zIndex:999999,...s,...y.style},children:a!=null&&pe(Ee.Root,{open:e,onOpenChange:b=>{b||t()},children:dn(Ee.Portal,{container:a,children:[pe(Ee.Overlay,{"data-bitsnap-checkout-slot":"overlay","aria-hidden":"true",className:u("fixed top-0 right-0 left-0 bottom-0 cursor-pointer z-10",v.className),style:v.style,onClick:t}),dn(Ee.Content,{id:n,"data-bitsnap-checkout-slot":"panel","aria-modal":"true","aria-describedby":void 0,onOpenAutoFocus:()=>{let b=document.activeElement;c.current=b instanceof HTMLElement?b:null},onCloseAutoFocus:b=>{b.preventDefault(),c.current?.focus(),c.current=null},className:u("fixed z-20 top-0 right-0 bottom-0 w-full md:w-[350px] xl:w-[420px] flex flex-col overflow-y-auto",m.className),style:m.style,onPointerDownOutside:b=>b.preventDefault(),children:[dn("div",{"data-bitsnap-checkout-slot":"header",className:u("mx-3 mt-7 flex justify-between items-center",g.className),style:g.style,children:[pe(Ee.Title,{asChild:!0,children:pe("h1",{"data-bitsnap-checkout-slot":"title",className:u("text-2xl font-medium",d.className),style:d.style,children:R})}),pe("button",{type:"button","data-bitsnap-checkout-slot":"closeButton",className:u("rounded-xl p-2 transition",I.className),style:I.style,"aria-label":h,onClick:t,children:dn("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-x","aria-hidden":"true",focusable:"false",children:[pe("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),pe("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),pe(ha,{className:"grow",locale:o})]})]})})})}var Vs=e=>typeof window>"u"?null:Hs(pe(ct,{appearance:e.appearance,children:pe(rt,{texts:e.texts,locale:e.locale,children:pe(st,{locale:e.locale,children:pe(Ks,{...e})})})}),document.body),va=Vs;import{Fragment as ba,jsx as Je,jsxs as pn}from"react/jsx-runtime";var Xs=ie.object({id:ie.string(),isSubscription:ie.boolean().default(!1),quantity:ie.number(),metadata:ie.record(ie.string(),ie.string().optional()).optional(),url:ie.string().optional()}),Ys={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0};function Zs({projectID:e,locale:t,children:n,onVisibleChange:o,className:r,numberOfProductsInCartOptions:a,appearance:i,texts:l,analytics:c}){let p=me(e,c,"cart");ho(p);let{isCartVisible:s,showCart:y,hideCart:v,numberOfProductsInCart:m}=Ke(),g=`bitsnap-cart-${$s()}`,d=E=>vo(E,t??Ne(),l),I=Qs(d);I.current=d;function R(E){Ke.getState().setNotice(I.current(E)),y()}function h(E){document.querySelectorAll("iframe").forEach(S=>{S.contentWindow?.postMessage(E,"*")})}Ut(()=>{o?.(s),s&&Ae({event:"viewCart"})},[s]),Ut(()=>{$e(e)},[e]),Ut(()=>{hn(t)},[t]),Ut(()=>{if(!("cart"in window)){let E=ce();if(E==null){console.warn("There is no project ID configured.");return}window.cart={buyProduct:async D=>{try{let S=ie.object({productID:ie.string(),email:ie.string().optional(),name:ie.string().optional(),country:ie.string().optional(),marketingAgreement:ie.boolean().optional(),locale:ie.string().optional()}).parse(D),T=In(E);try{let C=await T.getProducts();Q(C)==!1&&Ae({event:"initiateCheckout",items:C.map(U=>({id:U.productID,name:U.details?.name??"",price:U.details?.price??0,quantity:U.quantity,currency:U.details?.currency??"PLN"}))})}catch{}let w=await T.justRedirectToPayment(S);Q(w)==!1?window.location.href=w.url:R("redirectFailed")}catch(S){console.warn(S)}}}}},[]);async function b(E,D){let S=ce();if(S==null){console.warn("There is no project ID configured.");return}try{let T=Xs.parse(D);if(T.isSubscription){await A(S,T);return}await In(S).addProduct({productID:T.id,quantity:T.quantity,metadata:T.metadata,url:T.url}),h({id:E,type:"ADD_TO_CART",success:!0}),y()}catch(T){console.warn("cannot add item to cart",T)}}async function A(E,D){console.warn("subscriptions cannot be added to the cart yet",E,D.id),R("subscriptionUnsupported")}function x(){"__cart_is_listening"in window||(window.__cart_is_listening=!0,window.addEventListener("message",E=>{if(typeof E.data.id<"u"&&typeof E.data.type<"u"){let{id:D,type:S}=E.data;switch(S){case"ADD_TO_CART".toString():b(D,E.data.payload).then().catch();break;default:break}}}))}return Ut(()=>{if(x(),typeof window<"u")try{let E=new URLSearchParams(window.location.search),D=E.get("ref")??E.get("utm-source");typeof localStorage<"u"&&D&&D.length>0&&localStorage.setItem("bitsnap-ref",D)}catch{return}},[]),pn(ba,{children:[pn("button",{type:"button",onClick:()=>s?v():y(),"aria-label":n?void 0:m>0?`${d("openCart")}. ${d("cartItemsCount")}: ${m}`:d("openCart"),"aria-expanded":s,"aria-haspopup":"dialog","aria-controls":s?g:void 0,style:{position:"relative"},className:["bitsnap-react",r??"rounded-full hover:bg-neutral-300 transition p-1"].join(" "),children:[n?Je(ba,{children:n}):pn("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-shopping-cart","aria-hidden":"true",focusable:"false",children:[Je("circle",{cx:"8",cy:"21",r:"1"}),Je("circle",{cx:"19",cy:"21",r:"1"}),Je("path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"})]}),m>0&&pn("span",{style:Ys,children:[d("cartItemsCount"),": ",m]}),a?.isVisible!=!1&&m>0&&Je("div",{"aria-hidden":"true",style:{position:"absolute",bottom:-5,right:-5,background:"black",color:"white",borderRadius:"50%",width:"22px",height:"22px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",fontWeight:600,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.25)",...a?.style},children:m})]}),Je(Pe,{value:p,children:Je(va,{isVisible:s,locale:t,appearance:i,texts:l,panelId:g,shouldHide:()=>{v()}})})]})}var Os=Zs;export{Ta as a,Wi as b,Qi as c,Os as d,Rn as e,An as f,Us as g};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{A as at,B as kn,C as Ve,D as Ae,E as Lo,J as $e,K as ce,L as xt,M as _o,O as it,P as st,Q as lt,R as Uo,S as zt,T as wn,U as Oo,V as Mo,W as Bo,X as jo,Z as In,a as jt,b as et,c as tt,d as nt,e as ot,f as So,l as Q,n as Ro,o as Ao,p as Pn,q as Do,r as Ke,s as xn,y as rt,z}from"./chunk-ZMEWUEZJ.mjs";import{a as bo,b as Co,c as Po,e as de,f as xo,g as ko,h as wo,j as Io}from"./chunk-W4EUYPJ3.mjs";import{a as To,b as No}from"./chunk-KOVKUJAW.mjs";import{a as vn,e as ye,f as qt,g as Re,k as bn,l as $,m as Cn,p as Eo}from"./chunk-GMQYQTUM.mjs";import{a as u}from"./chunk-5R6AGO3Z.mjs";import{a as yo,e as ue}from"./chunk-4AU5SEHU.mjs";import{l as Pe,m as xe,n as me,q as ho}from"./chunk-EVV25IKM.mjs";import{c as vo,e as hn,f as Ne}from"./chunk-OFPRIENJ.mjs";import{useEffect as Ut,useId as $s,useRef as Qs}from"react";import ie from"zod";import{useAutoAnimate as zs}from"@formkit/auto-animate/react";import*as Ee from"@radix-ui/react-dialog";import{useCallback as Gs,useRef as Fs,useState as Ws}from"react";import{createPortal as Hs}from"react-dom";import{createContext as La,useContext as _a,useMemo as Ua}from"react";var Ta=["root","overlay","panel","header","title","closeButton","productList","product","productImage","productName","productPrice","quantityControl","quantityInput","quantityButton","removeButton","summary","totalLabel","totalValue","deliveryText","summaryNote","countryLabel","countryTrigger","countryDropdown","countrySearch","countryOption","paymentButtons","paymentMethods","paymentMethodOption","checkoutButton","emptyState","error","skeleton"],Na={fontFamily:"--bitsnap-checkout-font-family",fontSize:"--bitsnap-checkout-font-size",background:"--bitsnap-checkout-background",surface:"--bitsnap-checkout-surface",foreground:"--bitsnap-checkout-foreground",mutedForeground:"--bitsnap-checkout-muted-foreground",border:"--bitsnap-checkout-border",buttonBackground:"--bitsnap-checkout-button-background",buttonForeground:"--bitsnap-checkout-button-foreground",buttonHoverBackground:"--bitsnap-checkout-button-hover-background",hoverSurface:"--bitsnap-checkout-hover-surface",focusRing:"--bitsnap-checkout-focus-ring",error:"--bitsnap-checkout-error",overlay:"--bitsnap-checkout-overlay",radius:"--bitsnap-checkout-radius"},Ra={dark:{},light:{background:"#ffffff",surface:"#f9fafb",foreground:"#18181b",mutedForeground:"#71717a",border:"#e4e4e7",buttonBackground:"#18181b",buttonForeground:"#fafafa",buttonHoverBackground:"#000000",hoverSurface:"#e4e4e7",focusRing:"#71717a",error:"#dc2626",overlay:"rgb(0 0 0 / 0.35)"}},Aa=[{token:"background",variable:"--background"},{token:"foreground",variable:"--foreground"},{token:"surface",variable:"--card"},{token:"surface",variable:"--popover"},{token:"foreground",variable:"--popover-foreground"},{token:"mutedForeground",variable:"--muted-foreground"},{token:"border",variable:"--border"},{token:"border",variable:"--input"},{token:"focusRing",variable:"--ring"},{token:"error",variable:"--destructive"},{token:"radius",variable:"--radius"}];function Da(e){return{"--popover":e.surface??"var(--color-neutral-800)","--popover-foreground":e.foreground??"var(--color-neutral-200)"}}function Sn(e){let t=To(e,{defaultTheme:"dark",presets:Ra,variables:Na,shadcnVariables:Aa});return{theme:t.theme,isCustomized:t.isCustomized,tokens:t.tokens,elements:t.elements,boundaryClassName:t.theme,boundaryStyle:t.boundaryStyle,dropdownStyle:Da(t.tokens)}}function qo(e,t){return No(e.elements,t)}import{jsx as Oa}from"react/jsx-runtime";var zo=La(Sn());function ct({appearance:e,children:t}){let n=Ua(()=>Sn(e),[e]);return Oa(zo.Provider,{value:n,children:t})}function kt(){return _a(zo)}function L(e){let t=kt();return qo(t,e)??{}}import{useAutoAnimate as Ms}from"@formkit/auto-animate/react";import ee from"react";import{useEffect as Ga,useState as Fa}from"react";import*as G from"@radix-ui/react-select";import{CheckIcon as Ma,ChevronDownIcon as Go,ChevronUpIcon as Ba}from"lucide-react";import{jsx as te,jsxs as En}from"react/jsx-runtime";function Fo({...e}){return te(G.Root,{"data-slot":"select",...e})}function Wo({...e}){return te(G.Value,{"data-slot":"select-value",...e})}var ja="border-input dark:bg-input/30 dark:hover:bg-input/50 bg-transparent";function Ho({className:e,size:t="default",theme:n="default",children:o,...r}){return En(G.Trigger,{"data-slot":"select-trigger","data-size":t,className:u("data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-fit items-center justify-between gap-2 rounded-md border px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",n==="bare"?"":ja,e),...r,children:[o,te(G.Icon,{asChild:!0,children:te(Go,{className:"size-4 opacity-50"})})]})}function Ko({className:e,children:t,position:n="popper",align:o="center",...r}){return te(G.Portal,{children:En(G.Content,{"data-slot":"select-content",className:u("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:o,...r,children:[te(qa,{}),te(G.Viewport,{className:u("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),te(za,{})]})})}function Vo({className:e,children:t,...n}){return En(G.Item,{"data-slot":"select-item",className:u("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[te("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:te(G.ItemIndicator,{children:te(Ma,{className:"size-4"})})}),te(G.ItemText,{children:t})]})}function qa({className:e,...t}){return te(G.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:u("flex cursor-default items-center justify-center py-1",e),...t,children:te(Ba,{className:"size-4"})})}function za({className:e,...t}){return te(G.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:u("flex cursor-default items-center justify-center py-1",e),...t,children:te(Go,{className:"size-4"})})}import{jsx as De,jsxs as Gt}from"react/jsx-runtime";function Wa({id:e,open:t,disabled:n=!1,onToggle:o,onChange:r,selectedValue:a,countries:i}){let[l,c]=Fa(""),{isCustomized:p,boundaryClassName:s,boundaryStyle:y,dropdownStyle:v}=kt(),m=L("countryTrigger"),g=L("countryDropdown"),d=L("countrySearch"),I=L("countryOption"),R=z("searchCountry"),h=z("noCountriesFound");Ga(()=>{a==null&&i.length>0&&r(i[0].code)},[]);let b=i.filter(x=>x.name.toLowerCase().startsWith(l.toLowerCase())),A=i.find(x=>x.code===a);return Gt(Fo,{value:a,onValueChange:x=>{r(x),c("")},open:t,onOpenChange:x=>{x!==t&&o(),x||c("")},disabled:n,children:[De(Ho,{"data-bitsnap-checkout-slot":"countryTrigger",theme:"bare",className:u(n?"bg-neutral-100 dark:bg-neutral-800 dark:border-neutral-700":"","w-full rounded-md",m.className),style:m.style,children:De(Wo,{children:A&&Gt("span",{className:"truncate flex items-center",children:[De("img",{alt:a,src:`https://purecatamphetamine.github.io/country-flag-icons/3x2/${a}.svg`,className:"inline mr-2 h-4 rounded-sm"}),A.name]})})}),Gt(Ko,{"data-bitsnap-checkout":p?"dropdown":void 0,"data-bitsnap-checkout-slot":p?"countryDropdown":void 0,className:u(p?"bitsnap-react":"",s,"w-full max-h-80 max-w-[350px] z-[999999]",g.className),style:{...p?{...y,...v}:void 0,...g.style},position:"popper",children:[De("div",{"data-bitsnap-checkout-slot":"countrySearch",className:u("sticky top-0 z-10 p-1 border-b",d.className),style:d.style,children:De("input",{type:"search",name:"search",autoComplete:"off",className:"block w-full outline-none sm:text-body-regular bg-transparent rounded-md px-2 py-1.5",placeholder:R,"aria-label":R,value:l,onChange:x=>c(x.target.value),onClick:x=>x.stopPropagation(),onKeyDown:x=>x.stopPropagation()})}),De("div",{className:"max-h-64 overflow-y-auto",children:b.length===0?De("div",{className:"cursor-default select-none relative py-2 pl-3 pr-9 text-sm",children:h}):b.map(x=>Gt(Vo,{"data-bitsnap-checkout-slot":"countryOption",value:x.code,className:u("cursor-default select-none relative py-2 pl-3 pr-9 flex items-center transition",I.className),style:I.style,children:[De("img",{alt:x.code,src:`https://purecatamphetamine.github.io/country-flag-icons/3x2/${x.code}.svg`,className:"inline mr-2 h-4 rounded-sm"}),De("span",{className:"font-normal truncate",children:x.name})]},`${e}-${x.code}`))})]})]})}var $o=Wa;import{useEffect as Xa,useRef as Yo,useState as Jo}from"react";import{MinusIcon as Ya,PlusIcon as Za}from"lucide-react";import{Slot as hl}from"@radix-ui/react-slot";import{cva as Ha}from"class-variance-authority";import{jsx as Va}from"react/jsx-runtime";var Ka=Ha("flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}});function Qo({className:e,orientation:t,...n}){return Va("div",{role:"group","data-slot":"button-group","data-orientation":t,className:u(Ka({orientation:t}),e),...n})}import{Fragment as $a,jsx as Ft,jsxs as Qa}from"react/jsx-runtime";function Xo({price:e,currency:t,pricing:n,quantity:o=1}){let r=z("lowestPrice30Days"),a=z("noPriceHistory"),i=n?.regularPrice??e,l=n?.effectivePrice??e,c=n?.discount?.status==="ACTIVE"&&l<i;return Ft("span",{children:c?Qa($a,{children:[Ft("span",{className:"mr-2 text-neutral-500 line-through",children:Ve(i*o,t)}),Ft("span",{className:"font-semibold text-red-700",children:Ve(l*o,t)}),Ft("span",{className:"mt-1 block text-xs text-neutral-600",children:n?.referencePrice.historyAvailable&&n.referencePrice.amount!=null?`${r} ${Ve(n.referencePrice.amount,t)}`:a})]}):Ve(l*o,t)})}function Wt(e){return Number.isFinite(e)?Math.min(99,Math.max(1,Math.trunc(e))):1}function Tn(e,t){let n=parseInt(e,10);return Number.isNaN(n)?t:Wt(n)}import{Fragment as ti,jsx as Z,jsxs as Ht}from"react/jsx-runtime";var Ja=({isNotAvailable:e,quantity:t,details:n,url:o,shouldUpdate:r})=>{let a=L("product"),i=L("productImage"),l=L("productName"),c=L("productPrice"),p=L("removeButton"),s=z("remove"),y=n.image_url??n.images?.[0],[v,m]=Jo(),g=y!=null&&y.length>0&&y!==v,d=n.baseName??n.name;return Ht("div",{"data-bitsnap-checkout-slot":"product","data-bitsnap-checkout-unavailable":e?"":void 0,className:u("flex items-center gap-3 mx-3",e?"outline outline-1 rounded-md m-1":"",a.className),style:a.style,children:[g&&Z(Zo,{url:o,tabIndex:-1,"aria-hidden":"true",className:"contents",children:Z("img",{"data-bitsnap-checkout-slot":"productImage",className:u("aspect-auto max-w-[30%] max-w-32 max-h-32 py-2 overflow-hidden",i.className),style:i.style,src:y,alt:"",onError:()=>m(y)})}),Ht("div",{className:"flex flex-col w-full",children:[Z("p",{"data-bitsnap-checkout-slot":"productName",className:u("font-medium",l.className),style:l.style,children:Z(Zo,{url:o,className:"text-inherit no-underline hover:underline",children:d})}),n.variantName!=null&&n.variantName.length>0&&Z("p",{className:"text-sm opacity-70",children:n.variantName}),Z("p",{"data-bitsnap-checkout-slot":"productPrice",className:u("text-sm",c.className),style:c.style,suppressHydrationWarning:!0,children:Z(Xo,{price:n.price,currency:n.currency,pricing:n.pricing,quantity:t})}),Ht("div",{className:"flex justify-between",children:[Z(ei,{className:"",quantity:t,shouldUpdate:r}),Z($,{"data-bitsnap-checkout-slot":"removeButton",type:"button",variant:"ghost",size:"sm",className:p.className,style:p.style,"aria-label":`${s}: ${n.name}`,onClick:()=>{Promise.resolve(r(0)).catch(()=>{})},children:s})]})]})]})},er=Ja,Zo=({url:e,children:t,...n})=>e==null?Z(ti,{children:t}):Z("a",{href:e,...n,children:t}),ei=({quantity:e,shouldUpdate:t,className:n})=>{let[o,r]=Jo(e.toString()),a=Yo(e),i=L("quantityControl"),l=L("quantityInput"),c=L("quantityButton"),p=z("quantity"),s=z("increaseQuantity"),y=z("decreaseQuantity"),v=Yo(e);v.current=e,Xa(()=>{a.current=e,r(e.toString())},[e]);function m(g){r(g.toString()),g!==a.current&&(a.current=g,Promise.resolve(t(g)).catch(()=>{a.current===g&&(a.current=v.current,r(v.current.toString()))}))}return Z("div",{"data-bitsnap-checkout-slot":"quantityControl",className:u("flex",n,i.className),style:i.style,children:Ht(Qo,{"aria-label":p,children:[Z($,{"data-bitsnap-checkout-slot":"quantityButton",type:"button",className:c.className,style:c.style,"aria-label":y,onClick:()=>m(Wt(a.current-1)),children:Z(Ya,{"aria-hidden":"true"})}),Z("input",{"data-bitsnap-checkout-slot":"quantityInput",className:u("w-8 bg-transparent text-center",l.className),style:l.style,value:o,"aria-label":p,inputMode:"numeric",pattern:"[0-9]*",onChange:g=>r(g.currentTarget.value),onBlur:g=>m(Tn(g.currentTarget.value,a.current)),onKeyDown:g=>{g.key==="Enter"&&m(Tn(g.currentTarget.value,a.current))},type:"text"}),Z($,{"data-bitsnap-checkout-slot":"quantityButton",type:"button",className:c.className,style:c.style,"aria-label":s,onClick:()=>m(Wt(a.current+1)),children:Z(Za,{"aria-hidden":"true"})})]})})};import{jsx as ni}from"react/jsx-runtime";function Nn({className:e,...t}){return ni("div",{"data-slot":"skeleton",className:"bg-neutral-700 animate-pulse rounded-md "+e,...t})}import tr from"apple-pay-button";function ke(){try{return ce()}catch{return}}import{useQuery as nr}from"@tanstack/react-query";import{jsx as Kt}from"react/jsx-runtime";var oi=tr.default??tr;function ri({style:e,buttonType:t,colorType:n,items:o,onClick:r}){let{checkIfApplePayIsAvailable:a,getApplePayPaymentRequest:i,completeApplePayPayment:l,setCountry:c,setCouponCodeIfPossible:p,setDeliveryMethod:s,setEmail:y,setPostalCode:v,clearCart:m,getApplePayPreview:g}=it(),d=xe(),I=z("paymentForCart"),{data:R}=nr({queryKey:["is-apple-pay-available"],queryFn:a}),h=o.map(S=>`${S.id}:${S.quantity}`).join(","),b=xt(),{data:A}=nr({queryKey:["apple-pay-preview",h,b.country??"",b.couponCode??"",b.selectedDeliveryMethod??"",b.postalCode??""],queryFn:()=>g({items:o.map(S=>({productID:S.id,quantity:S.quantity,metadata:S.metadata}))}),enabled:R===!0});if(R!=!0)return null;let x=A!=null&&!Q(A)?A:{countryCode:b.country||"PL",currencyCode:o[0]?.currency??"PLN",totalAmount:`${kn(o.reduce((S,T)=>S+T.price*T.quantity,0)/100,2)}`},E=o.map(S=>({productID:S.id,quantity:S.quantity,metadata:S.metadata}));async function D(){let S=!1,T=f=>{S||(S=!0,d.track("apple_pay_result",{outcome:f}))};d.track("apple_pay_clicked",{}),d.track("payment_method_selected",{gateway:"apple_pay",method:"apple_pay"}),Ae({event:"initiateCheckout",items:o.map(f=>({id:f.id,name:f.name,price:f.price,quantity:f.quantity,currency:x.currencyCode}))});let w=o.find(f=>f.isDeliverable===!0)!=null,C=new ApplePaySession(14,{countryCode:x.countryCode,merchantCapabilities:["supports3DS"],supportedNetworks:["visa","masterCard"],currencyCode:x.currencyCode,total:{amount:x.totalAmount,label:I,type:"pending"},lineItems:o.map(f=>({amount:`${kn(f.price*f.quantity/100,2)}`,label:f.name,type:"final"})),...w?{shippingMethods:[],supportsCouponCode:!0,requiredBillingContactFields:["name","email","postalAddress","phone"],requiredShippingContactFields:["name","email","postalAddress","phone"]}:{}});await r?.();let U=await i({expectedItems:E});if(Q(U)){console.error("Error creating ApplePaySession:",U.error),T("fail");return}C.oncancel=f=>{console.log("ApplePaySession cancelled",f),T("cancel")},C.onvalidatemerchant=async f=>{try{let k=await jt.get(ue).applePayValidateMerchant({validationUrl:f.validationURL,projectId:ce()});console.log("merchantSession",k.merchantSession),k.merchantSession.length>0?(console.log("completing merchant session"),C.completeMerchantValidation(JSON.parse(k.merchantSession))):C.abort()}catch{C.abort()}},C.onshippingmethodselected=async f=>{console.log("shipping method selected",f),d.track("delivery_method_selected",{method:f.shippingMethod.identifier}),await s(f.shippingMethod.identifier);let k=await i({expectedItems:E});if(console.log("apRequest",k),Q(k))throw C.abort(),new Error("Failed to get Apple Pay payment request");C.completeShippingMethodSelection({newTotal:k.total,newLineItems:k.lineItems,newShippingMethods:k.shippingMethods})},C.onshippingcontactselected=async f=>{try{f.shippingContact.countryCode!=null&&await c(f.shippingContact.countryCode),f.shippingContact.postalCode!=null&&await v(f.shippingContact.postalCode),f.shippingContact.phoneNumber!=null&&await y(f.shippingContact.emailAddress);let k=await i({expectedItems:E});if(Q(k))throw C.abort(),new Error("Failed to get Apple Pay payment request");console.log("apRequest",k),C.completeShippingContactSelection({newLineItems:k.lineItems,newTotal:k.total,newShippingMethods:k.shippingMethods})}catch(k){console.log("shipping contact selected error",k),C.abort()}},C.oncouponcodechanged=async f=>{try{console.log("coupon code changed",f);let k=await p(f.couponCode),X=await i({expectedItems:E});if(console.log("apRequest",X),Q(X))throw C.abort(),new Error("Failed to get Apple Pay payment request");C.completeCouponCodeChange({errors:Q(k)?[new ApplePayError("couponCodeInvalid")]:void 0,newTotal:X.total,newLineItems:X.lineItems,newShippingMethods:X.shippingMethods})}catch(k){console.log("coupon code changed error",k),C.abort()}},C.onpaymentauthorized=async f=>{d.track("payment_submitted",{gateway:"apple_pay",method:"apple_pay"});try{let k=await l({token:f.payment.token,billingContact:f.payment.billingContact,shippingContact:f.payment.shippingContact});if(Q(k)){console.log("apple pay error",k),T("fail"),C.completePayment({status:ApplePaySession.STATUS_FAILURE});return}k.redirectURL&&setTimeout(()=>{open(k.redirectURL,"_self")},2e3),T(k.isSuccess?"success":"fail"),C.completePayment({status:k.isSuccess?ApplePaySession.STATUS_SUCCESS:ApplePaySession.STATUS_FAILURE}),k.isSuccess&&m()}catch{T("fail"),C.completePayment({status:ApplePaySession.STATUS_FAILURE})}},C.begin()}return Kt(oi,{style:e,buttonStyle:n,type:t,onClick:D})}function ai(e){let t=me(ke(),e.analytics,"cart");return Kt(Pe,{value:t,children:Kt(st,{children:Kt(ri,{...e})})})}var Rn=ai;import ii from"@google-pay/button-react";import{useQuery as si,useMutation as li}from"@tanstack/react-query";import{Fragment as di,jsx as wt,jsxs as pi}from"react/jsx-runtime";function ci({items:e,style:t,buttonColor:n,buttonSizeMode:o,test:r}){let{getGooglePayConfiguration:a,completeGooglePayPayment:i,setCountry:l,setCouponCodeIfPossible:c,setDeliveryMethod:p,setEmail:s,setPostalCode:y,clearCart:v}=it(),m=xe(),{data:g}=si({queryKey:["get-google-pay-configuration",e.map(R=>R.id).join(",")],queryFn:()=>a({items:e.map(R=>({...R,id:void 0,productID:R.id}))})}),{mutateAsync:d,isPending:I}=li({mutationFn:i});return g==null||g.isAvailable!=!0?(console.log("google pay configuration is not available",g),null):pi(di,{children:[wt(ii,{buttonSizeMode:o,buttonColor:n,style:t,existingPaymentMethodRequired:!0,onClick:()=>m.track("payment_method_selected",{gateway:"google_pay",method:"google_pay"}),environment:r===!0?"TEST":"PRODUCTION",onPaymentDataChanged:async R=>{Ae({event:"initiateCheckout",items:e.map(b=>({id:b.id,name:b.name,price:b.price,quantity:b.quantity,currency:"PLN"}))}),console.log("payment data changed",R),R.shippingAddress?.postalCode!=null&&await y(R.shippingAddress?.postalCode),R.shippingAddress?.countryCode!=null&&await l(R.shippingAddress?.countryCode),R.shippingOptionData?.id!=null&&await p(R.shippingOptionData.id);let h=await a({items:[]});return console.log("PAYMENT DATA CHANGED CONFIG",h),h.isAvailable?{error:void 0,newShippingOptionParameters:h.config.shippingOptionParameters,newTransactionInfo:h.config.transactionInfo}:{error:void 0}},paymentRequest:g.config,onLoadPaymentData:async R=>{m.track("payment_submitted",{gateway:"google_pay",method:"google_pay"});try{let h=await d({paymentData:R});if(Q(h)){console.log("apple pay error",h);return}h.isSuccess&&v(),h.redirectURL&&open(h.redirectURL,"_self")}catch(h){console.warn("error completing google pay payment",h)}}}),I?wt(de,{}):null]})}function ui(e){let t=me(ke(),e.analytics,"cart");return wt(Pe,{value:t,children:wt(st,{children:wt(ci,{...e})})})}var An=ui;import{createElement as Ar,useCallback as mt,useEffect as Tt,useMemo as Dr,useRef as ft,useState as Gi}from"react";var mi="x-bitsnap-cart-token",or=new Set;function Dn(e,t,n){or.has(e)||(or.add(e),console.warn(t,n))}function fi(e,t,n){return`${e.replace(/\/+$/,"")}/api/integrations/${encodeURIComponent(t)}/public-commerce/express${n}`}async function It(e,t,n,o){let r=e.fetch??((a,i)=>globalThis.fetch(a,i));try{let a=await r(fi(e.host,e.projectID,t),{method:"POST",headers:{...yo,"Content-Type":"application/json",...o!=null?{[mi]:o}:{}},body:JSON.stringify(n),cache:"no-store",signal:e.signal}),i=await a.text().catch(()=>""),l;try{l=i.length>0?JSON.parse(i):void 0}catch{l=void 0}return{status:a.status,json:l,text:i}}catch(a){return{transportError:a}}}function we(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}function rr(e){return gi(e)?{ok:!1,code:"network",message:"aborted"}:{ok:!1,code:"network",message:"The server could not be reached."}}function gi(e){return typeof e=="object"&&e!=null&&e.name==="AbortError"}function ut(e){return e===404||e===405||e===501||e===502}function Ln(e,t){return typeof e=="string"&&e.length>0?e:t}async function ar(e,t){let n=await It(e,"/availability",t);if("transportError"in n){Dn(`availability:${e.host}:${e.projectID}`,"Bitsnap express availability is not reachable; express buttons stay hidden.",n.transportError);return}if(ut(n.status)||n.status!==200){Dn(`availability-status:${e.host}:${e.projectID}`,"Bitsnap express availability is not available on this backend; express buttons stay hidden.",n.status);return}let o=n.json;if(!we(o)||o.success!==!0||!we(o.providers)){Dn(`availability-shape:${e.host}:${e.projectID}`,"Bitsnap express availability returned an unknown shape; express buttons stay hidden.",void 0);return}return o}async function ir(e,t,n){let o=await It(e,"/cart",{...t,...n!=null?{cartId:n.cartId,expectedRevision:n.expectedRevision}:{}},n?.cartToken);if("transportError"in o)return{ok:!1,code:"internal",message:"The cart could not be saved."};let r=o.json;if(!we(r)||typeof r.success!="boolean")return{ok:!1,code:o.status===403?"cart-forbidden":"internal",message:"The cart endpoint returned an unknown answer."};if(r.success===!0){let a=r.snapshot;return a==null||typeof a.revision!="number"?{ok:!1,code:"internal",message:"The cart endpoint returned no snapshot."}:{ok:!0,...typeof r.cartToken=="string"?{cartToken:r.cartToken}:{},snapshot:a}}return{ok:!1,code:Ln(r.code,"internal"),message:typeof r.message=="string"?r.message:"The cart could not be saved.",...typeof r.currentRevision=="number"?{currentRevision:r.currentRevision}:{},...we(r.snapshot)?{snapshot:r.snapshot}:{},...Array.isArray(r.conflicts)?{conflicts:r.conflicts}:{}}}function yi(e){let t=Ln(e.code,"internal");return{code:t,message:Ln(e.message,t)}}async function sr(e,t,n){let o=await It(e,"/cart-snapshot",{cartId:t},n);if("transportError"in o)return rr(o.transportError);let r=o.json;return o.status===404?{ok:!1,code:"cart-not-found",message:"cart-not-found",status:404}:o.status===403?{ok:!1,code:"cart-forbidden",message:"cart-forbidden",status:403}:!we(r)||r.success!==!0||!we(r.snapshot)?{ok:!1,code:ut(o.status)?"not-implemented":"invalid-response",message:"The cart snapshot is not available.",status:o.status}:{ok:!0,value:r.snapshot}}async function lr(e,t,n){let r=await It(e,t==="inpostPay"?"/inpost/start":t==="revolutPay"?"/revolut/start":"/adyen/start",{cartId:n.cartId,...n.returnUrl!=null?{returnUrl:n.returnUrl}:{},...n.cancelUrl!=null?{cancelUrl:n.cancelUrl}:{},...n.embedOrigin!=null?{embedOrigin:n.embedOrigin}:{}},n.cartToken);if("transportError"in r)return rr(r.transportError);let a=r.json;if(!we(a)||typeof a.success!="boolean")return{ok:!1,code:ut(r.status)?"not-implemented":"invalid-response",message:"The provider start is not available.",status:r.status};if(a.success===!0)return typeof a.redirectUrl!="string"||typeof a.providerOrderId!="string"?{ok:!1,code:"invalid-response",message:"The provider start returned no redirect.",status:r.status}:{ok:!0,value:{ok:!0,provider:t,redirectUrl:a.redirectUrl,providerOrderId:a.providerOrderId,...we(a.publicConfig)?{publicConfig:a.publicConfig}:{},cartRevision:typeof a.cartRevision=="number"?a.cartRevision:0}};let i=a;return{ok:!1,code:ut(r.status)?"not-implemented":i.code,message:typeof i.message=="string"?i.message:"The provider start failed.",status:r.status}}function cr(e,t,n){return dr(e,"/revolut/status",t,n)}function ur(e,t,n){return dr(e,"/inpost/status",t,n)}async function dr(e,t,n,o){let r=await It(e,t,{cartId:n},o);if("transportError"in r)return{ok:!1,code:"network",message:"The status is not available."};let a=r.json;return r.status===401||r.status===403?{ok:!1,code:"cart-forbidden",message:"cart-forbidden"}:r.status===404?{ok:!1,code:"cart-not-found",message:"cart-not-found"}:!we(a)||typeof a.success!="boolean"?{ok:!1,code:ut(r.status)?"not-implemented":"provider-error",message:"The status is not available."}:a.success===!0?a.status==="pending"||a.status==="completed"||a.status==="failed"||a.status==="cancelled"?{ok:!0,status:a.status,...typeof a.orderId=="string"?{orderId:a.orderId}:{}}:{ok:!1,code:"provider-error",message:"Unknown status."}:{ok:!1,code:ut(r.status)?"not-implemented":"provider-error",message:we(a)?yi(a).message:"The status failed."}}var hi="bitsnap-express-cart";function pr(e,t=Date.now()){let n=e?.pending;if(n!=null)return t-n.ts<=864e5?n:void 0}function _n(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function Un(e,t){return`${hi}:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function mr(e){let t=e.storage??_n();if(t==null)return;let n=Un(e.host,e.projectID),o;try{let r=t.getItem(n);if(r==null)return;o=JSON.parse(r)}catch{Ie(e);return}if(!Vt(o)){Ie(e);return}if(o.projectID!==e.projectID||o.host!==e.host||typeof o.cartId!="string"||o.cartId.length===0||typeof o.cartToken!="string"||o.cartToken.length===0||typeof o.revision!="number"||o.environment!=="test"&&o.environment!=="production"){Ie(e);return}return{projectID:o.projectID,host:o.host,environment:o.environment,cartId:o.cartId,cartToken:o.cartToken,revision:o.revision,updatedAt:typeof o.updatedAt=="number"?o.updatedAt:0,...Array.isArray(o.syncedLines)?{syncedLines:o.syncedLines.filter(r=>Vt(r)&&typeof r.id=="string"&&typeof r.quantity=="number")}:{},...typeof o.inpostBindingApiKey=="string"?{inpostBindingApiKey:o.inpostBindingApiKey}:{},...vi(o.pending)?{pending:o.pending}:{}}}function Qe(e,t=_n()){if(t==null)return!1;try{return t.setItem(Un(e.host,e.projectID),JSON.stringify(e)),!0}catch{return!1}}function Ie(e){let t=e.storage??_n();if(t!=null)try{t.removeItem(Un(e.host,e.projectID))}catch{}}function Vt(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}function vi(e){return!Vt(e)||e.provider!=="inpostPay"&&e.provider!=="revolutPay"||typeof e.ts!="number"||!Array.isArray(e.lines)?!1:e.lines.every(t=>Vt(t)&&typeof t.id=="string"&&typeof t.quantity=="number")}var bi=3,$t=class{options;running=Promise.resolve();constructor(t){this.options=t}getRecord(){return mr(this.options)}getInpostBindingApiKey(){return this.getRecord()?.inpostBindingApiKey}previewUpload(t){return this.options.local.upload(t)}getPendingAttempt(){return this.getRecord()?.pending}ensure(t){return this.serialize(()=>this.ensureNow(t))}async ensureNow(t){let n=this.getRecord();n!=null&&t.environment!=null&&n.environment!==t.environment&&(Ie(this.options),n=void 0);let o,r=this.options.maxAttempts??bi;for(let a=0;a<r;a++){let i=this.options.local.upload(t.locale);if(i==null)return{ok:!1,code:"invalid-cart",message:"The cart is empty."};let l=this.options.local.signature(),c=await this.options.write(i,n!=null?{cartId:n.cartId,cartToken:n.cartToken,expectedRevision:n.revision}:void 0);if(c.ok){let p=c.cartToken??n?.cartToken;if(p==null)return{ok:!1,code:"internal",message:"The created cart has no access token."};let s=c.snapshot;if(n={projectID:this.options.projectID,host:this.options.host,environment:s.environment,cartId:s.cartId,cartToken:p,revision:s.revision,updatedAt:(this.options.now??Date.now)(),syncedLines:i.items.map(v=>({id:v.id,quantity:v.quantity})),...n?.inpostBindingApiKey!=null?{inpostBindingApiKey:n.inpostBindingApiKey}:{}},Qe(n,this.options.storage),this.options.local.signature()===l)return{ok:!0,value:{record:n,snapshot:s}};continue}switch(o=c,c.code){case"revision-conflict":{let p=c.snapshot?.revision??c.currentRevision;if(n==null||p==null)return c;let s=Pi({base:n.syncedLines,local:this.options.local.lines(),server:fr(c.snapshot?.lines)});if(!s.ok)return{...c,currentRevision:p,snapshot:c.snapshot,conflicts:s.conflicts};if(!Ci(s.lines,this.options.local.lines())){if(this.options.local.replaceLines==null)return{...c,currentRevision:p,snapshot:c.snapshot,conflicts:s.conflicts};this.options.local.replaceLines(s.lines)}n={...n,revision:p},c.snapshot?.environment!=null&&(n.environment=c.snapshot.environment),c.snapshot!=null&&(n.syncedLines=fr(c.snapshot.lines)),Qe(n,this.options.storage);continue}case"cart-locked":{Ie(this.options),n=void 0;continue}case"cart-not-found":case"cart-forbidden":{Ie(this.options),n=void 0;continue}case"invalid-request":case"product-not-available":case"currency-unsupported":return c;default:return c}}return o??{ok:!1,code:"internal",message:"The cart could not be saved."}}reconcileFromServer(){return this.serialize(async()=>{let t=this.getRecord();if(t==null)return{ok:!1,code:"cart-not-found",message:"There is no cart to read."};let n=qe(this.options.local.lines()),o=await this.options.read(t.cartId,t.cartToken);if(!o.ok)return(o.code==="cart-not-found"||o.code==="cart-forbidden")&&Ie(this.options),o;let r=o.value,a=qe(this.options.local.lines()),i=qe(t.syncedLines??[]),l=t.syncedLines!=null?i:n;this.options.local.adoptSnapshot(r);let c=xi(a,l);c.length>0&&this.options.local.appendLines(c);let p=this.getRecord();if(p!=null&&p.cartId===r.cartId&&Qe({...p,revision:r.revision,environment:r.environment,updatedAt:(this.options.now??Date.now)()},this.options.storage),c.length>0){let s=await this.ensureNow({locale:r.locale,environment:r.environment});if(!s.ok)return{ok:!1,code:s.code,message:s.message,...s.status!=null?{status:s.status}:{},...s.currentRevision!=null?{currentRevision:s.currentRevision}:{},...s.snapshot!=null?{snapshot:s.snapshot}:{},...s.conflicts!=null?{conflicts:s.conflicts}:{}}}return{ok:!0,value:r}})}async start(t,n){let o=await this.ensure({locale:n.locale,...n.environment!=null?{environment:n.environment}:{}});if(!o.ok)return o;let{record:r,snapshot:a}=o.value,i=await n.start({cartId:r.cartId,cartToken:r.cartToken,...n.returnUrl!=null?{returnUrl:n.returnUrl}:{},...n.cancelUrl!=null?{cancelUrl:n.cancelUrl}:{},...n.embedOrigin!=null?{embedOrigin:n.embedOrigin}:{}});if(!i.ok)return(i.code==="cart-locked"||i.code==="cart-not-found"||i.code==="cart-forbidden")&&Ie(this.options),i;let l=this.getRecord();return l!=null&&l.cartId===r.cartId&&Qe({...l,revision:Math.max(l.revision,i.value.cartRevision),updatedAt:(this.options.now??Date.now)(),...i.value.publicConfig?.basketBindingApiKey!=null?{inpostBindingApiKey:i.value.publicConfig.basketBindingApiKey}:{},pending:{provider:t,...i.value.providerOrderId.length>0?{providerOrderId:i.value.providerOrderId}:{},lines:a.lines.map(c=>({id:c.productId,quantity:c.quantity})),ts:(this.options.now??Date.now)()}},this.options.storage),{ok:!0,value:{start:i.value,snapshot:a}}}storeInpostBindingApiKey(t){let n=this.getRecord();n==null||t.length===0||Qe({...n,inpostBindingApiKey:t,updatedAt:(this.options.now??Date.now)()},this.options.storage)}completePurchase(t){let n=this.getRecord(),o=t??n?.pending?.lines??[];o.length>0&&this.options.local.removeLines(o),Ie(this.options)}keepCart(){}clearPending(){let t=this.getRecord();if(t==null||t.pending==null)return;let{pending:n,...o}=t;Qe(o,this.options.storage)}status(t){let n=this.getRecord();return n==null?Promise.resolve({ok:!1,code:"cart-not-found",message:"There is no cart to check."}):t(n.cartId,n.cartToken)}serialize(t){let n=this.running.then(t,t);return this.running=n.then(()=>{},()=>{}),n}};function qe(e){let t=new Map;for(let n of e)t.set(n.id,(t.get(n.id)??0)+n.quantity);return t}function fr(e){return(e??[]).map(t=>({id:t.productId,quantity:t.quantity}))}function Ci(e,t){let n=qe(e),o=qe(t);if(n.size!==o.size)return!1;for(let[r,a]of n)if(o.get(r)!==a)return!1;return!0}function Pi(e){if(e.base==null||e.server==null)return{ok:!1,lines:e.local,conflicts:[]};let t=qe(e.base),n=qe(e.local),o=qe(e.server),r=new Set([...t.keys(),...n.keys(),...o.keys()]),a=[],i=[];for(let l of r){let c=t.get(l)??0,p=n.get(l)??0,s=o.get(l)??0,y=p!==c,v=s!==c,m;y?(v&&(p===s||i.push({id:l,base:c,local:p,server:s})),m=p):m=s,m>0&&!i.some(g=>g.id===l)&&a.push({id:l,quantity:m})}return{ok:i.length===0,lines:a,conflicts:i}}function xi(e,t){let n=[];for(let[o,r]of e){let a=r-(t.get(o)??0);a>0&&n.push({id:o,quantity:a})}return n}var On=new Map,ki=5*60*1e3;function gr(e,t,n){let o=xt();return[e,t,n.items.map(r=>`${r.id}:${r.quantity}`).sort().join(","),(n.countries??[]).slice().sort().join(","),n.couponCode??"",n.deliveryMethod??"",o.postalCode??""].join("|")}function dt(e,t,n){let o=gr(e,t,n),r=On.get(o);if(r!=null){if(Date.now()-r.at>ki){On.delete(o);return}return r.quote}}function wi(e,t,n,o){On.set(gr(e,t,n),{quote:o,at:Date.now()})}function Xe(e,t){return t==null||t.delivery.length===0?e:{...e,delivery:e.delivery!=null&&e.delivery.length>0?e.delivery:t.delivery,...e.deliveryMethod==null&&t.deliveryMethod!=null?{deliveryMethod:t.deliveryMethod}:{}}}async function Ii(e){if(e.upload.items.length===0)return{delivery:[]};let t=xt();try{let n=await jt.get(e.host).getPreOrderDetails({projectId:e.projectID,items:e.upload.items.map(i=>({id:i.id,quantity:i.quantity})),...e.upload.countries?.[0]!=null?{countryCode:e.upload.countries[0]}:{},...e.upload.couponCode!=null?{couponCode:e.upload.couponCode}:{},...e.upload.deliveryMethod!=null?{selectedDeliveryMethod:e.upload.deliveryMethod}:t.selectedDeliveryMethod!=null?{selectedDeliveryMethod:t.selectedDeliveryMethod}:{},...t.postalCode!=null?{postCode:t.postalCode}:{}}),o=n.methods.map(i=>({name:i.id,...i.description!=null?{desc:i.description}:{},min:i.minDays??1,max:i.maxDays??14,price:i.amount/100})),r=n.selectedDeliveryMethod??o[0]?.name??void 0,a={delivery:o,...r!=null?{deliveryMethod:r}:{}};return wi(e.host,e.projectID,e.upload,a),a}catch(n){console.warn("cannot resolve the express delivery quote",n);return}}async function Qt(e){if(e.upload.delivery!=null&&e.upload.delivery.length>0)return{ok:!0,upload:e.upload,quote:{delivery:e.upload.delivery,...e.upload.deliveryMethod!=null?{deliveryMethod:e.upload.deliveryMethod}:{}}};let t=dt(e.host,e.projectID,e.upload);if(t!=null)return{ok:!0,upload:Xe(e.upload,t),quote:t};let n=await Ii(e);return n==null?{ok:!1,message:"The delivery quote for this cart is not available. Use the regular checkout."}:{ok:!0,upload:Xe(e.upload,n),quote:n}}function Mn(e){return{lines:()=>lt().map(t=>({id:t.productID,quantity:t.quantity})),signature:Uo,upload:t=>{let n=zt(t);if(n!=null)return Xe(n,dt(e.host,e.projectID,n))},adoptSnapshot:t=>{wn(t.lines.map(n=>({productId:n.productId,quantity:n.quantity})))},appendLines:Mo,removeLines:Oo,replaceLines:t=>{wn(t.map(n=>({productId:n.id,quantity:n.quantity})))}}}function Ye(e){let t=e.host??ue,n={projectID:e.projectID,host:t,...e.fetch!=null?{fetch:e.fetch}:{},...e.signal!=null?{signal:e.signal}:{}};return new $t({projectID:e.projectID,host:t,local:e.local??Mn({host:t,projectID:e.projectID}),...e.storage!=null?{storage:e.storage}:{},...e.now!=null?{now:e.now}:{},write:(o,r)=>ir(n,o,r),read:(o,r)=>sr(n,o,r)})}async function Xt(e,t,n=Ye(e)){let o=e.host??ue,r=n.previewUpload(e.locale);if(r!=null){let a=await Qt({host:o,projectID:e.projectID,upload:r});if(!a.ok)return{ok:!1,code:"invalid-cart",message:a.message}}return n.start(t,{locale:e.locale,...e.environment!=null?{environment:e.environment}:{},...e.returnUrl!=null?{returnUrl:e.returnUrl}:{},...e.cancelUrl!=null?{cancelUrl:e.cancelUrl}:{},...e.embedOrigin!=null?{embedOrigin:e.embedOrigin}:{},start:a=>lr({projectID:e.projectID,host:o,...e.fetch!=null?{fetch:e.fetch}:{},...e.signal!=null?{signal:e.signal}:{}},t,a)})}function yr(e,t){return vr(e,"revolutPay",t)}function hr(e,t){return vr(e,"inpostPay",t)}function vr(e,t,n){let o=e.host??ue;return(n??Ye(e)).status((a,i)=>(t==="inpostPay"?ur:cr)({projectID:e.projectID,host:o,...e.fetch!=null?{fetch:e.fetch}:{},...e.signal!=null?{signal:e.signal}:{}},a,i))}function br(){return typeof window>"u"?void 0:window}var jn="inpost-izi-button",qn="inpost-thank-you";function xr(e){return e!=null&&/^pl\b/i.test(e)?"pl":"en"}var Si="https://sandbox-inpostpay-widget-api.inpost.pl",Ei="https://inpostpay-widget-api.inpost.pl",Cr={test:"https://sandbox-inpostpay-widget-v2.inpost.pl/inpostpay.widget.v2.js",production:"https://inpostpay-widget-v2.inpost.pl/inpostpay.widget.v2.js"},Pr={test:Si,production:Ei};function Ti(e,t){return e==="test"||e==="production"?e:e==="prod"||e==="live"?"production":t??"production"}function Yt(e){return e.includes("sandbox")}function kr(e,t){if(e==null)return;let n=e.merchantClientId;if(n==null||n.length===0)return;let o=t??Ti(e.environment,void 0),r=e.widgetApiBaseUrl??e.apiBaseUrl,a=e.widgetScriptUrl,i=o==="test"?r!=null&&Yt(r)?r:Pr.test:r!=null&&!Yt(r)?r:Pr.production,l=o==="test"?a!=null&&Yt(a)?a:Cr.test:a!=null&&!Yt(a)?a:Cr.production;return{merchantClientId:n,environment:o,apiBaseUrl:i,scriptUrl:l,...e.basketBindingApiKey!=null&&e.basketBindingApiKey.length>0?{basketBindingApiKey:e.basketBindingApiKey}:{},...e.basketId!=null&&e.basketId.length>0?{basketId:e.basketId}:{}}}var Bn;function wr(){if(typeof window>"u")return Promise.reject(new Error("InPost Pay needs a browser."));let e=br()?.InPostPayWidget;return e!=null?Promise.resolve(e):(Bn??=import("@inpost-pay/widget").then(t=>{let n=t,o=typeof n.initialiseInpostPayWidget=="function"?n.initialiseInpostPayWidget:typeof n.default=="function"?n.default:typeof n.default?.initialiseInpostPayWidget=="function"?n.default.initialiseInpostPayWidget:void 0,r=br()?.InPostPayWidget;if(r!=null)return r;if(o!=null)return{init:o};throw new Error("The InPost Pay widget exposed no init function.")}).catch(t=>{throw Bn=void 0,t}),Bn)}function Ir(e){if(typeof window>"u")return;let t=window,n=t.__bitsnapInpostOwner,o=t.__INPOST_PAY_WIDGET__;if(o!=null){if(n!=null&&n.projectID===e.owner.projectID&&n.host===e.owner.host&&n.merchantClientId===e.owner.merchantClientId)return o.refresh(e.options),o;if(Ni()){e.warn?.("InPost Pay already runs for another project on this page; mount one InPost Pay button per page.");return}delete t.__INPOST_PAY_WIDGET__,delete t.__bitsnapInpostOwner}let r=e.namespace.init(e.options);return t.__INPOST_PAY_WIDGET__=r,t.__bitsnapInpostOwner=e.owner,r}function Ni(){return typeof document>"u"?!1:document.querySelector(`${jn}, ${qn}`)!=null}function Sr(e){return{binding_place:e.bindingPlace,...e.productId!=null?{"data-product-id":e.productId}:{},...e.variation!=null?{variation:e.variation}:{}}}import{useEffect as Ri,useMemo as Ec,useRef as Ai,useState as Di,useSyncExternalStore as Li}from"react";function pt(e){let t=Math.max(1,Math.trunc(e.quantity??1)),n={...e.country!=null?{country:e.country}:{},...e.couponCode!=null?{couponCode:e.couponCode}:{},productQuantity:t};if(e.items!=null&&e.items.length>0)return{...n,items:e.items.map(r=>({id:r.id,quantity:Math.max(1,Math.trunc(r.quantity))})),source:"items"};let o=lt().map(r=>({id:r.productID,quantity:r.quantity}));if(e.productId!=null&&e.productId.length>0){let r=o.some(a=>a.id===e.productId);return{...n,items:r?o:[...o,{id:e.productId,quantity:t}],source:"product",productId:e.productId}}return{...n,items:o,source:"cart"}}function Zt(e){let t=e.items.map(n=>`${n.id}:${n.quantity}`).sort().join(",");return[e.source,t,e.country??"",e.couponCode??"",e.productId??""].join("|")}function Jt(e,t,n){if(e.source==="cart")return Mn(n);let o={items:e.items.map(r=>({id:r.id,quantity:r.quantity})),...e.country!=null?{countries:[e.country]}:{},...e.couponCode!=null?{couponCode:e.couponCode}:{},locale:t};return{lines:()=>e.items,signature:()=>Zt(e),upload:()=>Xe(o,dt(n.host,n.projectID,o)),adoptSnapshot:()=>{},appendLines:()=>{},removeLines:()=>{}}}function St(){return Li(Bo,jo,()=>0)}function en(e){let t=Ai(e);t.current=e;let n=pt(e),o=Zt(n),r=St(),[a,i]=Di({loading:!1,provider:void 0,environment:void 0,failed:!1});return Ri(()=>{let l=t.current;if(l.enabled===!1||l.projectID==null||l.projectID.length===0||typeof window>"u"){i({loading:!1,provider:void 0,environment:void 0,failed:!1});return}let c=pt(l);if(c.items.length===0){i({loading:!1,provider:void 0,environment:void 0,failed:!1});return}let p=new AbortController,s=!0;return i(y=>({...y,loading:!0})),Ui({projectID:l.projectID,...l.host!=null?{host:l.host}:{},locale:l.locale,cart:c,...l.fetch!=null?{fetch:l.fetch}:{},signal:p.signal}).then(y=>{if(!s)return;let v=y?.providers?.[l.provider];i({loading:!1,provider:v,environment:y?.environment??v?.environment,failed:y==null})}).catch(()=>{s&&i({loading:!1,provider:void 0,environment:void 0,failed:!0})}),()=>{s=!1,p.abort()}},[o,r,e.projectID,e.host,e.provider,e.locale,e.enabled]),a}function tn(e){return e??ue}function _i(e,t,n){let o=e.source==="cart"?zt(t):e.items.length===0?void 0:{items:e.items.map(r=>({id:r.id,quantity:r.quantity})),...e.country!=null?{countries:[e.country]}:{},...e.couponCode!=null?{couponCode:e.couponCode}:{},locale:t};if(o!=null)return n?.host==null||n.projectID==null?o:Xe(o,dt(n.host,n.projectID,o))}async function Ui(e){let t=e.host??ue,n=_i(e.cart,e.locale);if(n==null)return;let o=await Qt({host:t,projectID:e.projectID,upload:n});if(!o.ok)return;let r=await ar({projectID:e.projectID,host:t,...e.fetch!=null?{fetch:e.fetch}:{},...e.signal!=null?{signal:e.signal}:{}},o.upload);if(r==null)return;if(o.quote.delivery.length===0)return r;let a=r.providers.revolutPay;return a==null||a.available!==!0?r:{...r,providers:{...r.providers,revolutPay:{...a,available:!1,reasons:[...a.reasons,"delivery-unsupported"]}}}}function Er(e){if(e==null)return;let t=e.publicKey??e.publicToken,n=e.mode;if(!(t==null||t.length===0)&&!(n!=="sandbox"&&n!=="prod"))return{publicKey:t,mode:n,...e.orderToken!=null&&e.orderToken.length>0?{orderToken:e.orderToken}:{}}}function Tr(e){let t=e.publicConfig?.orderToken;return t!=null&&t.length>0?t:e.providerOrderId}function Nr(e){return e!=null&&/^pl\b/i.test(e)?"pl":"en"}var Oi=6e4,Mi=2e3;function Bi(e){return new Promise(t=>setTimeout(t,e))}async function zn(e){let t=e.timeoutMs??Oi,n=e.intervalMs??Mi,o=e.sleep??Bi,r=(e.now??Date.now)(),a=Math.min(1e4,Math.max(1,Math.ceil(t/Math.max(1,n))+1)),i=0,l;for(;;){if(i+=1,e.signal?.aborted===!0)return l;try{l=await e.check()}catch{l=void 0}if(l?.ok===!0&&l.status!=="pending"||l?.ok===!1&&l.code==="not-implemented"||i>=a||(e.now??Date.now)()-r>=t)return l;await o(n)}}var Rr=zn;import{jsx as zi}from"react/jsx-runtime";var ji={pending:"expressPending",confirmed:"expressConfirmed",failed:"expressFailed",cancelled:"expressCancelled","load-failed":"expressLoadFailed","cart-unavailable":"expressCartUnavailable","cart-conflict":"expressCartConflict","price-changed":"expressPriceChanged","product-unavailable":"expressProductUnavailable"},qi=["failed","cancelled","load-failed","cart-unavailable","cart-conflict","price-changed","product-unavailable"];function Et({phase:e}){let t=at(),n=L("error");if(e==="idle")return null;let o=qi.includes(e);return zi("p",{role:o?"alert":"status","aria-live":o?"assertive":"polite","data-bitsnap-express-status":e,className:u("w-full px-2 text-center text-sm",o&&"opacity-90",n.className),style:n.style,children:t(ji[e])})}import{jsx as gt,jsxs as Hi}from"react/jsx-runtime";function Lr(e){return typeof e=="object"&&e!=null&&e.undeliverable===!0}function Gn(e){let{projectID:t}=e,n=tn(e.host),o=e.locale??Ne(),r=xe(),a=e.confirmation?.timeoutMs,i=e.confirmation?.intervalMs,l=e.confirmation?.sleep,c=e.confirmation?.now,p=St(),s=Dr(()=>pt({...e.items!=null?{items:e.items}:{},...e.productId!=null?{productId:e.productId}:{},...e.quantity!=null?{quantity:e.quantity}:{}}),[e.items,e.productId,e.quantity,p]),y=Zt(s),v=en({provider:"inpostPay",projectID:t,host:n,locale:o,...e.items!=null?{items:e.items}:{},...e.productId!=null?{productId:e.productId}:{},...e.quantity!=null?{quantity:e.quantity}:{},...e.fetch!=null?{fetch:e.fetch}:{}}),m=v.provider,g=m?.environment??v.environment,d=m?.available===!0?kr(m.publicConfig,g):void 0,I=d?.merchantClientId,R=d?.apiBaseUrl,h=Dr(()=>Ye({projectID:t,host:n,...s.source==="items"?{local:Jt(s,o,{host:n,projectID:t})}:{},...e.fetch!=null?{fetch:e.fetch}:{}}),[t,n,e.fetch,s,o]),[b,A]=Gi("idle"),x=ft(void 0),E=ft(void 0),D=ft(!0),S=ft(!1),T=ft(!1);Tt(()=>(D.current=!0,()=>{D.current=!1}),[]);let w=ft({cart:s,locale:o,environment:g,session:h,onOrderCreated:e.onOrderCreated,onBasketChanged:e.onBasketChanged});w.current={cart:s,locale:o,environment:g,session:h,onOrderCreated:e.onOrderCreated,onBasketChanged:e.onBasketChanged};let C=mt(async()=>{if(E.current!=null)return E.current;let M=Xt({projectID:t,host:n,locale:w.current.locale,...w.current.environment!=null?{environment:w.current.environment}:{},...typeof window<"u"?{returnUrl:window.location.href,cancelUrl:window.location.href,embedOrigin:window.location.origin}:{},...e.fetch!=null?{fetch:e.fetch}:{}},"inpostPay",w.current.session).then(O=>{if(!O.ok)throw A(O.code==="revision-conflict"?"cart-conflict":"cart-unavailable"),new Error(`inpost-start-${O.code}`);return r.track("payment_submitted",{gateway:"inpost_pay",method:"inpost_pay"}),O.value.start}).finally(()=>{E.current=void 0});return E.current=M,M},[t,n,r,e.fetch]),U=mt(async M=>{if(lt().some(_=>_.productID===M)||w.current.cart.source==="items")return;if(await xn.addProductToCart(M,w.current.cart.productQuantity)!=null)throw{undeliverable:!0}},[]),f=mt(async M=>{r.track("payment_method_selected",{gateway:"inpost_pay",method:"inpost_pay"});try{M!=null&&await U(M);let N=(await C()).publicConfig?.basketBindingApiKey;if(N==null||N.length===0)throw new Error("inpost-start-without-basket-key");return w.current.session.storeInpostBindingApiKey(N),A("idle"),N}catch(O){throw Lr(O)?(A("product-unavailable"),new Error("UNDELIVERABLE_PRODUCT")):(A(O instanceof Error&&O.message==="inpost-start-revision-conflict"?"cart-conflict":"cart-unavailable"),O instanceof Error?O:new Error("inpost-pay-failed"))}},[U,r,C]),k=mt(async M=>{let O=M??w.current.cart.productId;if(O!=null)try{if(await xn.addProductToCart(O,w.current.cart.productQuantity)!=null)throw{undeliverable:!0};await w.current.session.ensure({locale:w.current.locale,...w.current.environment!=null?{environment:w.current.environment}:{}})}catch(N){throw A("product-unavailable"),Lr(N)?new Error("UNDELIVERABLE_PRODUCT"):N instanceof Error?N:new Error("inpost-pay-failed")}},[]),X=mt(async()=>{if(!S.current){S.current=!0;try{let M=w.current.session,O=M.getPendingAttempt();if(O?.provider!=="inpostPay")return;D.current&&A("pending");let N=await zn({check:()=>hr({projectID:t,host:n,...e.fetch!=null?{fetch:e.fetch}:{}},M),timeoutMs:a??2e4,intervalMs:i??1500,...l!=null?{sleep:l}:{},...c!=null?{now:c}:{}});if(!D.current)return;let _=O.providerOrderId;if(N?.ok===!0&&N.status==="completed"){let W=await M.reconcileFromServer(),F=W.ok?W.value.lines.map(V=>({id:V.productId,quantity:V.quantity})):O.lines;F.length>0&&M.completePurchase(F),A("confirmed"),r.track("payment_returned",{gateway:"inpost_pay",method:"inpost_pay",outcome:"pending"}),T.current||(T.current=!0,w.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"completed"}));return}if(N?.ok===!0&&N.status==="failed"){M.clearPending(),A("failed"),T.current||(T.current=!0,w.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"failed"}));return}if(N?.ok===!0&&N.status==="cancelled"){M.clearPending(),A("cancelled"),T.current||(T.current=!0,w.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"cancelled"}));return}A("pending"),T.current||(T.current=!0,w.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"pending"}))}finally{S.current=!1}}},[i,c,l,a,n,r,t,e.fetch]),be=mt(async M=>{if(M==="basketProductChanged"){let O=await w.current.session.reconcileFromServer();return O.ok&&w.current.onBasketChanged?.(O.value),!0}return M==="orderCreated"&&X(),!0},[X]);if(Tt(()=>{m?.available===!0&&h.getPendingAttempt()?.provider==="inpostPay"&&X()},[m?.available,h,X]),Tt(()=>{if(m?.available!==!0||I==null||I.length===0||typeof window>"u")return;let M=!1;return wr().then(O=>{if(M)return;let N=Ir({namespace:O,owner:{projectID:t,host:n,merchantClientId:I},options:{merchantClientId:I,basketBindingApiKey:h.getInpostBindingApiKey(),unboundWidgetClicked:f,...s.source==="product"||e.productId!=null?{addToBasketClicked:k}:{},handleBasketEvent:be,...R!=null?{apiBaseUrl:R}:{},language:xr(o)}});if(N==null){A("cart-unavailable");return}x.current=N,N.rerender()}).catch(()=>{M||A("load-failed")}),()=>{M=!0,x.current=void 0}},[m?.available,I,R,o,t,n,h,f,k,be,s.source,e.productId]),Tt(()=>{x.current?.refresh({basketBindingApiKey:h.getInpostBindingApiKey()})},[y,h]),m?.available!==!0||I==null||I.length===0)return gt(Et,{phase:b==="idle"?"idle":b});let Me=e.bindingPlace??(e.productId!=null?"PRODUCT_CARD":"BASKET_SUMMARY");return Hi("div",{"data-bitsnap-express":"inpostPay","aria-busy":b==="pending"?!0:void 0,className:e.className,style:e.style,children:[Me==="THANK_YOU_PAGE"?Ar(qn,{...e.variation!=null?{variation:e.variation}:{}}):Ar(jn,Sr({bindingPlace:Me,...e.productId!=null?{productId:e.productId}:{},...e.variation!=null?{variation:e.variation}:{}})),gt(Et,{phase:b})]})}function Fi(e){let t=e.projectID??ke(),n=me(t,e.analytics,"cart");return Tt(()=>{e.projectID!=null&&$e(e.projectID)},[e.projectID]),gt(Pe,{value:n,children:gt(rt,{locale:e.locale,texts:e.texts,children:gt(ct,{appearance:e.appearance,children:t==null?null:gt(Gn,{...e,projectID:t})})})})}var Wi=Fi;import{useEffect as Vn,useMemo as Vi,useRef as on,useState as qr}from"react";var Ki={prod:"https://merchant.revolut.com/embed.js",sandbox:"https://sandbox-merchant.revolut.com/embed.js"},_r={prod:"revolut-checkout",sandbox:"revolut-checkout-sandbox"},Fn=new Map;function Ur(e,t={}){if(typeof window>"u")return Promise.reject(new Error("Revolut Checkout needs a browser."));let n=window.RevolutCheckout;if(n!=null)return Promise.resolve(n);let o=Fn.get(e);if(o!=null)return o;let r=t.document??document,a=t.timeoutMs??15e3,i=new Promise((l,c)=>{let p=!1,s=r.getElementById(_r[e]),y,v=()=>{y!=null&&clearTimeout(y),s?.removeEventListener("load",g),s?.removeEventListener("error",d)},m=I=>{p||(p=!0,v(),I())},g=()=>{m(()=>{let I=window.RevolutCheckout;I!=null?l(I):c(new Error("Revolut Checkout did not initialise."))})},d=()=>{m(()=>c(new Error("Revolut Checkout could not be loaded.")))};s==null?(s=r.createElement("script"),s.id=_r[e],s.src=Ki[e],s.async=!0,s.addEventListener("load",g),s.addEventListener("error",d),r.head.appendChild(s)):(s.addEventListener("load",g),s.addEventListener("error",d)),y=setTimeout(()=>{m(()=>c(new Error("Revolut Checkout timed out while loading.")))},a)});return Fn.set(e,i),i.catch(()=>Fn.delete(e)),i}function Or(e,t){return e.payments({publicToken:t.publicKey,mode:t.mode,locale:t.locale})}var Wn="bitsnap_express",Hn="bitsnap_express_cart",Kn="bitsnap_express_result",Mr="_rp_oid";function Br(e){let t;try{t=new URLSearchParams(e.startsWith("?")?e:`?${e}`)}catch{return{returned:!1}}let n=t.get(Wn),o=t.get(Mr)??void 0,r=t.get(Hn)??void 0,a=t.get(Kn),i=a==="success"||a==="failure"||a==="cancel"?a:void 0,l=n==="inpostPay"||n==="revolutPay";return{returned:l||o!=null,...l?{provider:n}:{},...r!=null?{cartId:r}:{},...o!=null?{orderToken:o}:{},...i!=null?{result:i}:{}}}function nn(e,t){let n=typeof window<"u"?window.location.href:"https://localhost/",o=new URL(e,n);return o.searchParams.set(Wn,t.provider),o.searchParams.set(Hn,t.cartId),o.searchParams.set(Kn,t.result),o.toString()}function jr(e){let t=typeof window<"u"?window.location.href:"https://localhost/",n=new URL(e,t);return n.searchParams.delete(Wn),n.searchParams.delete(Hn),n.searchParams.delete(Kn),n.searchParams.delete(Mr),n.pathname+n.search+n.hash}import{jsx as yt,jsxs as Xi}from"react/jsx-runtime";function $n(e){let{projectID:t}=e,n=tn(e.host),o=e.locale??Ne(),r=xe(),a=e.confirmation?.timeoutMs,i=e.confirmation?.intervalMs,l=e.confirmation?.sleep,c=e.confirmation?.now,p=JSON.stringify(e.buttonStyle??null),s=St(),y=Vi(()=>pt({...e.items!=null?{items:e.items}:{},...e.productId!=null?{productId:e.productId}:{},...e.quantity!=null?{quantity:e.quantity}:{},...e.country!=null?{country:e.country}:{},...e.couponCode!=null?{couponCode:e.couponCode}:{}}),[e.items,e.productId,e.quantity,e.country,e.couponCode,s]),v=[y.source,y.items.map(S=>`${S.id}:${S.quantity}`).sort().join(",")].join("|"),m=en({provider:"revolutPay",projectID:t,host:n,locale:o,...e.items!=null?{items:e.items}:{},...e.productId!=null?{productId:e.productId}:{},...e.quantity!=null?{quantity:e.quantity}:{},...e.country!=null?{country:e.country}:{},...e.couponCode!=null?{couponCode:e.couponCode}:{},...e.fetch!=null?{fetch:e.fetch}:{}}),g=m.provider?.available===!0?Er(m.provider.publicConfig):void 0,d=m.provider?.environment??m.environment,I=on(null),[R,h]=qr("idle"),[b,A]=qr(0),x=on(!0),E=on(void 0),D=on(void 0);return Vn(()=>(x.current=!0,()=>{x.current=!1}),[]),Vn(()=>{if(g==null||typeof window>"u"||I.current==null)return;let S=new AbortController,T=!1,w,C=Jt(y,o,{host:n,projectID:t}),U=Ye({projectID:t,host:n,local:C,...e.fetch!=null?{fetch:e.fetch}:{},signal:S.signal}),f=e.returnUrl??window.location.href,k=!1,X=!1,be=async N=>{if(!x.current||X)return;h("pending");let _=await Rr({check:()=>yr({projectID:t,host:n,...e.fetch!=null?{fetch:e.fetch}:{},signal:S.signal},N),signal:S.signal,...a!=null?{timeoutMs:a}:{},...i!=null?{intervalMs:i}:{},...l!=null?{sleep:l}:{},...c!=null?{now:c}:{}});if(!(T||!x.current)){if(_?.ok===!0&&_.status==="completed"){X=!0,N.completePurchase(),h("confirmed"),e.onPaymentResult?.({status:"completed",..._.orderId!=null?{orderId:_.orderId}:{}});return}if(_?.ok===!0&&_.status==="failed"){X=!0,N.clearPending(),h("failed"),e.onPaymentResult?.({status:"failed"});return}if(_?.ok===!0&&_.status==="cancelled"){X=!0,N.clearPending(),h("cancelled"),e.onPaymentResult?.({status:"cancelled"});return}h("pending"),e.onPaymentResult?.({status:"pending"})}},Me=N=>{k||(k=!0,be(N).finally(()=>{k=!1}))},M=N=>{if(N.type==="cancel"){r.track("payment_returned",{gateway:"revolut_pay",method:"revolut_pay",outcome:"cancel"}),U.clearPending(),h("cancelled"),e.onPaymentResult?.({status:"cancelled"});return}if(N.type==="error"){r.track("payment_returned",{gateway:"revolut_pay",method:"revolut_pay",outcome:"fail"}),U.clearPending();let _=D.current;D.current=void 0,h(_??"failed"),_==null&&e.onPaymentResult?.({status:"failed"});return}r.track("payment_returned",{gateway:"revolut_pay",method:"revolut_pay",outcome:"pending"}),Me(U)};return(async()=>{let N=await U.ensure({locale:o,...d!=null?{environment:d}:{}});if(T)return;if(!N.ok){h(N.code==="revision-conflict"?"cart-conflict":"cart-unavailable");return}let _=N.value.snapshot;E.current={cartId:_.cartId,currency:_.currency,totalMinor:_.totalMinor};let W=await Ur(g.mode);if(T)return;let F=await Or(W,{publicKey:g.publicKey,mode:g.mode,locale:Nr(o)});if(T){F.destroy?.();return}let{revolutPay:V}=F,We,mn=async()=>(We!=null||(We=(async()=>{let Y=await U.ensure({locale:o,...d!=null?{environment:d}:{}});if(!Y.ok)throw D.current=Y.code==="revision-conflict"?"cart-conflict":"cart-unavailable",new Error(`revolut-cart-${Y.code}`);if(!zr(Y.value.snapshot,E.current))throw E.current={cartId:Y.value.snapshot.cartId,currency:Y.value.snapshot.currency,totalMinor:Y.value.snapshot.totalMinor},D.current="price-changed",h("price-changed"),A(bt=>bt+1),new Error("revolut-amount-changed");let oe=await Xt({projectID:t,host:n,locale:o,...d!=null?{environment:d}:{},returnUrl:f,cancelUrl:e.cancelUrl??f,embedOrigin:window.location.origin,...e.fetch!=null?{fetch:e.fetch}:{}},"revolutPay",U);if(!oe.ok)throw D.current=oe.code==="revision-conflict"?"cart-conflict":"cart-unavailable",new Error(`revolut-start-${oe.code}`);if(!zr(oe.value.snapshot,E.current))throw E.current={cartId:oe.value.snapshot.cartId,currency:oe.value.snapshot.currency,totalMinor:oe.value.snapshot.totalMinor},D.current="price-changed",h("price-changed"),A(bt=>bt+1),new Error("revolut-amount-changed");return r.track("payment_submitted",{gateway:"revolut_pay",method:"revolut_pay"}),{publicId:Tr(oe.value.start)}})().finally(()=>{We=void 0})),We);V.mount(I.current,{currency:_.currency,totalAmount:_.totalMinor,createOrder:mn,mobileRedirectUrls:{success:nn(f,{provider:"revolutPay",cartId:_.cartId,result:"success"}),failure:nn(f,{provider:"revolutPay",cartId:_.cartId,result:"failure"}),cancel:nn(f,{provider:"revolutPay",cartId:_.cartId,result:"cancel"})},...e.buttonStyle!=null?{buttonStyle:e.buttonStyle}:{}}),V.on("click",()=>{r.track("payment_method_selected",{gateway:"revolut_pay",method:"revolut_pay"})}),V.on("payment",M),!T&&x.current&&h(Y=>Y==="price-changed"||Y==="cart-conflict"||Y==="confirmed"||Y==="failed"||Y==="cancelled"?Y:"idle"),w=()=>{try{V.destroy()}catch{}try{F.destroy?.()}catch{}};let Te=Br(window.location.search),gn=pr(U.getRecord())?.provider==="revolutPay"&&(Te.cartId==null||Te.cartId===_.cartId)||Te.returned&&Te.provider==="revolutPay";Te.returned&&window.history.replaceState({},"",jr(window.location.href)),gn&&await be(U)})().catch(()=>{!T&&x.current&&h("load-failed")}),()=>{T=!0,S.abort(),w?.()}},[g?.publicKey,g?.mode,d,o,v,t,n,e.fetch,e.returnUrl,e.cancelUrl,p,a,i,l,c,b]),Xi("div",{"data-bitsnap-express":"revolutPay","aria-busy":R==="pending"?!0:void 0,className:e.className,style:e.style,children:[yt("div",{ref:I}),yt(Et,{phase:R})]})}function zr(e,t){return t!=null&&e.cartId===t.cartId&&e.currency===t.currency&&e.totalMinor===t.totalMinor}function $i(e){let t=e.projectID??ke(),n=me(t,e.analytics,"cart");return Vn(()=>{e.projectID!=null&&$e(e.projectID)},[e.projectID]),yt(Pe,{value:n,children:yt(rt,{locale:e.locale,texts:e.texts,children:yt(ct,{appearance:e.appearance,children:t==null?null:yt($n,{...e,projectID:t})})})})}var Qi=$i;import{useReducer as Es,useRef as Ts,useEffect as Dt}from"react";import{useQuery as Ns}from"@tanstack/react-query";import{Settings as Rs}from"lucide-react";import{Fragment as Yi,jsx as Qn,jsxs as Zi}from"react/jsx-runtime";var J=ko.pl,j={title:null,description:null,managingDescription:"Zarz\u0105dzaj rodzajami powiadomie\u0144 i sposobem dostarczania.",formTitle:"Podaj Email aby zapisa\u0107 si\u0119\xA0do powiadomie\u0144",formEmailLabel:"Email",formPhoneLabel:"Numer telefonu",formPhoneOptional:"(opcjonalnie)",formEmailPlaceholder:"np. mail@gmail...",formPhonePlaceholder:"np. 663...",formSubmitButton:"Zapisz si\u0119",formSuccessMessage:"Zapisa\u0142e\u015B si\u0119 do powiadomie\u0144.",agreementText:Zi(Yi,{children:[Qn("span",{style:{color:"red"},children:"*"}),"Wyra\u017Cam zgod\u0119 na przetwarzanie moich danych w celach marketingowych zgodnie z"," ",Qn("a",{href:"/regulations/polityka-prywatnosci",target:"_blank",className:"cursor-alias font-bold hover:font-medium",children:"regulaminem"})," ",Qn("span",{className:"text-xs font-light",children:"(zgod\u0119 mo\u017Cna w ka\u017Cdej chwili wycofa\u0107)"})]}),qrCodeTitle:"lub zainstaluj aplikacj\u0119 mobiln\u0105",qrCodeSubtitle:"Aplikacja mobilna",qrCodeScanText:"zeskanuj kod QR",groupsNoSelectionWarning:"Je\u015Bli \u017Cadna z grup nie jest zaznaczona, nie otrzymasz \u017Cadnych powiadomie\u0144.",groupsSelectAllButton:"Zaznacz wszystkie",groupsUpdateButton:"Aktualizuj",groupsUpdateSuccess:"Zaktualizowano pomy\u015Blnie.",groupsTitle:"Zarz\u0105dzaj grupami z kt\xF3rych chcesz otrzymywa\u0107 powiadomienia",manageDataTitle:"Ustawienia powiadomie\u0144",manageDataDescription:"W jaki spos\xF3b chcesz otrzymywa\u0107 powiadomienia?",manageDataUnsubscribeButton:"Odsubskrybuj",manageDataUpdatedMessage:"Zaktualizowano",manageDataUnsubscribeDescription:"Wypisz mnie z wszystkich powiadomie\u0144 i grup.",loginEmailLabel:"Email",loginEmailPlaceholder:"Wprowad\u017A sw\xF3j email",loginSendCodeButton:"Wy\u015Blij kod weryfikacyjny",loginSendingButton:"Wysy\u0142anie...",loginCodeLabel:"Wprowad\u017A kod weryfikacyjny",loginCodeSentMessage:"Wys\u0142ali\u015Bmy kod weryfikacyjny na adres",loginChangeEmailButton:"Popraw email",loginResendCodeButton:"Wy\u015Blij kod ponownie",loginInvalidEmailError:"Wprowad\u017A prawid\u0142owy adres email",loginSlugRequiredError:"Wymagany jest identyfikator projektu",loginInvalidCodeError:"Nieprawid\u0142owy kod weryfikacyjny",loginVerificationFailedError:"Weryfikacja nie powiod\u0142a si\u0119. Sprawd\u017A sw\xF3j kod.",loginSendEmailError:"Nie uda\u0142o si\u0119 wys\u0142a\u0107 kodu weryfikacyjnego",loginVerifyCodeError:"Nie uda\u0142o si\u0119 zweryfikowa\u0107 kodu",loginResendEmailError:"Nie uda\u0142o si\u0119 ponownie wys\u0142a\u0107 kodu weryfikacyjnego",loginTitle:"Wpisz email aby zarz\u0105dza\u0107 powiadomieniami",loginDescription:"Dostaniesz kod weryfikacyjny na email.",loginIHaveCode:"Mam ju\u017C kod",loginVerifyButton:"Potwierd\u017A",loginResendInText:J.resendIn,loginResentMessage:J.resent,loginExpiredError:J.expired,loginTooManyAttemptsError:J.tooManyAttempts,loginRateLimitedError:J.rateLimited,loginNetworkError:J.network,loginSpamHint:J.spamHint,loginValidityHint:J.validity,loginVerifyingButton:J.verifying,loginStepEmailHint:J.stepEmail,loginStepCodeHint:J.stepCode,loginAlreadySentMessage:J.alreadySent,loginEmailNotFoundError:J.emailNotFound,loginDeliveryUnavailableError:J.deliveryUnavailable,loginResendNewCodeButton:J.resendNew,loginNoCodeButton:J.noCode,loginCodeIncompleteError:J.codeIncomplete};import{LogOutIcon as Ji}from"lucide-react";import{Fragment as Gr,jsx as Ze,jsxs as rn}from"react/jsx-runtime";function Fr({projectName:e,projectLogo:t,projectLogoDark:n,description:o,className:r,onLogout:a}){return rn(Gr,{children:[t!=null||e!=null&&rn("h2",{className:u("flex max-w-44 items-center gap-3 text-lg font-medium text-black sm:max-w-none md:text-xl lg:text-2xl xl:text-3xl dark:text-neutral-100",r?.headerTitle),children:[t!=null&&rn(Gr,{children:[Ze("img",{src:t,alt:"",className:u("h-12 w-auto dark:hidden",r?.headerLogo)}),Ze("img",{src:n??t,alt:"",className:u("hidden h-12 w-auto dark:inline",r?.headerLogo)})]}),Ze("span",{children:e})]}),rn("div",{className:"flex items-center gap-2",children:[o&&Ze("p",{className:u("mt-4 font-medium text-left",r?.headerDescription),children:o}),Ze("div",{className:"grow"}),a&&Ze($,{variant:"ghost",size:"icon-sm",onClick:a,children:Ze(Ji,{className:"h-5 w-5"})})]})]})}import*as an from"@radix-ui/react-switch";import{jsx as Wr}from"react/jsx-runtime";function ht({className:e,...t}){return Wr(an.Root,{"data-slot":"switch",className:u("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:Wr(an.Thumb,{"data-slot":"switch-thumb",className:u("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{useAutoAnimate as Qr}from"@formkit/auto-animate/react";import{CheckCircleIcon as ts,TriangleAlertIcon as ns}from"lucide-react";import*as Le from"@radix-ui/react-popover";import{jsx as sn}from"react/jsx-runtime";function Hr({...e}){return sn(Le.Root,{"data-slot":"popover",...e})}function Kr({...e}){return sn(Le.Trigger,{"data-slot":"popover-trigger",...e})}function Vr({className:e,align:t="center",sideOffset:n=4,...o}){return sn(Le.Portal,{children:sn(Le.Content,{"data-slot":"popover-content",align:t,sideOffset:n,className:u("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...o})})}import{ClockIcon as es}from"lucide-react";import{jsx as _e,jsxs as ze}from"react/jsx-runtime";function $r({regularity:e}){let t="";switch(e){case"rarely":t="rzadko";break;case"often":t="cz\u0119sto";break;case"very_often":t="codzienne";break}return ze(Hr,{children:[_e(Kr,{onClick:n=>{n.stopPropagation()},children:ze("button",{type:"button",className:"flex w-[30%] cursor-help flex-col items-center justify-center text-xs md:w-[25%] xl:w-[20%]",children:[_e(es,{size:12}),_e("span",{children:t})]})}),_e(Vr,{className:"w-80",children:ze("div",{className:"grid gap-4",children:[ze("div",{className:"space-y-2",children:[_e("h4",{className:"leading-none font-medium",children:"Co to oznacza?"}),ze("ul",{className:"list-inside list-disc text-sm",children:[ze("li",{children:[_e("span",{className:"font-semibold",children:"Rzadko"})," \u2013 powiadomienia b\u0119d\u0105 wysy\u0142ane maksymalnie kilka razy w miesi\u0105cu."]}),ze("li",{children:[_e("span",{className:"font-semibold",children:"Cz\u0119sto"})," \u2013 powiadomienia mog\u0119 by\u0107 wysy\u0142ane kilka razy w tygodniu."]}),ze("li",{children:[_e("span",{className:"font-semibold",children:"Codzienne"})," \u2013 powiadomienia b\u0119d\u0105 wysy\u0142ane nawet codziennie."]})]})]}),_e("div",{className:"grid gap-2"})]})})]})}import{Fragment as os,jsx as re,jsxs as Se}from"react/jsx-runtime";function ln({groups:e=[],isManaging:t,onToggle:n,onCheckAll:o,onUpdate:r,isUpdating:a,wasChanged:i,isUserGroupsUpdated:l,className:c,texts:p}){let[s]=Qr(),[y]=Qr(),v=e.filter(d=>d.isOn===!1).length>0,m=e.filter(d=>d.isOn===!1).length>0;if(e.length<=1&&t!=!0)return null;let g=Se("div",{ref:s,className:u("my-5 flex flex-col gap-3",c?.groupsList),children:[e.map(d=>Se("div",{id:d.id,role:"button",className:u(d.isOn?"bg-neutral-50 hover:bg-transparent shadow-sm border-transparent dark:bg-neutral-800":"border-neutral-200 hover:bg-neutral-50 dark:hover:border-neutral-800 shadow-sm dark:border-neutral-800","active:bg-beige-300 flex w-full cursor-pointer items-center gap-3 rounded-xl border px-3 py-2 transition active:dark:bg-neutral-900",c?.groupItem),onClick:I=>{I.target instanceof HTMLButtonElement||n(d.id)},children:[re(ht,{checked:d.isOn,className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-700",onCheckedChange:()=>{n(d.id)}}),Se("div",{className:"flex flex-col items-start justify-start",children:[re("p",{className:"font-medium text-sm",children:d.name}),d.description&&re("p",{className:"text-xs font-light",children:d.description})]}),re("div",{className:"grow"}),d.howOften&&re($r,{regularity:d.howOften})]},d.id)),Se("div",{className:"flex gap-2",children:[t===!0&&Se(os,{children:[Se("div",{ref:y,className:"flex flex-col items-start justify-start",children:[i&&Se($,{variant:"default",size:"sm",className:"relative",disabled:a,onClick:r,children:[p?.groupsUpdateButton??j.groupsUpdateButton,a&&re("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:re(de,{})})]}),l&&Se("p",{className:"mt-3 flex items-center gap-2 text-sm text-green-500",children:[re(ts,{color:"var(--color-green-500",size:16})," ",p?.groupsUpdateSuccess??j.groupsUpdateSuccess]})]}),re("div",{className:"grow"})]}),m&&re("div",{className:"flex justify-start",children:re($,{className:"cursor-pointer dark:bg-neutral-700",onClick:o,size:"sm",variant:"secondary",type:"button",children:p?.groupsSelectAllButton??j.groupsSelectAllButton})})]}),v&&Se("div",{className:"flex text-left gap-2 text-xs text-yellow-500",children:[re(ns,{color:"orange",size:16}),p?.groupsNoSelectionWarning??j.groupsNoSelectionWarning]})]});return t==!0?Se(et,{className:"mt-5 text-left",children:[re(tt,{children:re(nt,{children:p?.groupsTitle??j.groupsTitle})}),re(ot,{children:g})]}):g}import{jsx as Ge,jsxs as Nt}from"react/jsx-runtime";function Xr({showQRCode:e=!0,isManaging:t,className:n,texts:o}){let r=typeof window<"u",a=r?!!window.matchMedia?.("(prefers-color-scheme: dark)").matches:!1;function i(l){return l?window.location.href:""}return e?Nt(et,{className:u("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",n?.qrCodeSection),children:[Ge(tt,{children:Nt(nt,{className:u("mb-3 text-base font-medium lg:text-lg",n?.qrCodeTitle),children:[o?.qrCodeSubtitle??j.qrCodeSubtitle," "+(o?.qrCodeTitle??j.qrCodeTitle)]})}),Nt(ot,{className:"flex flex-col items-center gap-2",children:[Nt("div",{className:"mt-1.5 mb-3 flex items-center gap-x-2",children:[Ge("a",{href:"https://apps.apple.com/us/app/bitsnap/id6741902807",target:"_blank",className:"max-w-28 flex-1 basis-1/2 lg:max-w-36",children:Ge("img",{className:"h-auto w-full",src:ue+"/app-store-logo.png",alt:"Download on App Store"})}),Ge("a",{href:"https://play.google.com/store/apps/details?id=com.bitsnap.Bitsnap&pli=1",target:"_blank",className:"max-w-28 flex-1 basis-1/2 lg:max-w-36",children:Ge("img",{className:"h-auto w-full",src:ue+"/google-play-logo.png",alt:"Get in on Google Play"})})]}),r&&Ge("div",{className:"flex items-center justify-center",children:Nt("div",{className:u("flex min-w-[40%] flex-col items-center gap-2 rounded-xl bg-white p-2 dark:bg-neutral-900",n?.qrCodeContainer),children:[Ge("img",{className:"mt-3 w-[80%] p-1 pt-3",src:ue+`/api/qr-gen?url=${i(r)}&bgColor=${a?"171717":"F6F4F0"}&textColor=${a?"ffffff":"000000"}&margin=0`}),Ge("p",{className:"text-xs md:text-sm",children:o?.qrCodeScanText??j.qrCodeScanText})]})})]})]}):null}import{useState as Rt}from"react";import{isValidPhoneNumber as ls}from"react-phone-number-input";import{useAutoAnimate as rs}from"@formkit/auto-animate/react";import{Label as Yr}from"@radix-ui/react-label";import{CheckCircleIcon as as,CircleAlertIcon as is,TriangleAlertIcon as ss}from"lucide-react";import{useState as Xn}from"react";import{jsx as fe,jsxs as Ue}from"react/jsx-runtime";function Zr({submit:e,isLoading:t,errMsg:n,emailLack:o,warnMsg:r,isSubmited:a,agreementLack:i,showPhoneInput:l=!1,agreementText:c,className:p,texts:s}){let[y,v]=Xn(""),[m,g]=Xn(""),[d,I]=Xn(!1),[R]=rs();function h(b){b.preventDefault(),e(y,m,d)}return Ue("form",{ref:R,onSubmit:h,className:u("flex flex-col gap-3 text-left",p?.formContainer),children:[Ue("div",{className:"flex flex-col gap-1 text-left",children:[fe(Yr,{className:"text-sm",htmlFor:"bts-notifications-form-email",children:s?.formEmailLabel??j.formEmailLabel}),fe(Cn,{value:y,onChange:b=>{v(b.currentTarget.value)},id:"bts-notifications-form-email",className:u(o===!0?"border-red-400":""),type:"email",placeholder:s?.formEmailPlaceholder??j.formEmailPlaceholder})]}),l&&Ue("div",{className:"flex flex-col gap-1 text-left",children:[Ue(Yr,{className:"text-sm",htmlFor:"bts-notifications-form-phone",children:[s?.formPhoneLabel??j.formPhoneLabel," ",fe("span",{className:"text-neutral-500 dark:text-neutral-500",children:s?.formPhoneOptional??j.formPhoneOptional})]}),fe(Cn,{value:m,onChange:b=>{g(b.currentTarget.value)},id:"bts-notifications-form-phone",className:"",type:"tel",autoComplete:"tel",autoCorrect:"off",placeholder:s?.formPhonePlaceholder??j.formPhonePlaceholder})]}),Ue("div",{className:"flex items-start gap-x-1.5",children:[fe("input",{className:"cursor-pointer",id:"bts-notifications-form-marketing-consent",type:"checkbox",checked:d,onChange:()=>{I(!d)}}),fe("label",{htmlFor:"bts-notifications-form-marketing-consent",className:u("cursor-pointer text-xs leading-4 transition-colors md:text-sm md:leading-4",i===!0?"text-yellow-700":""),children:c})]}),n.length>0&&Ue("p",{className:"mb-3 flex items-center gap-1 text-sm text-red-400",children:[fe(ss,{color:"#ff6467",size:16})," ",n]}),r.length>0&&Ue("p",{className:"mb-3 flex items-center gap-1 text-sm text-amber-400",children:[fe(is,{color:"var(--color-amber-400)",size:16})," ",r]}),a==!1&&fe("div",{className:"flex justify-start",children:Ue($,{variant:"default",disabled:t,className:u(t?"cursor-not-allowed text-transparent":"","relative"),children:[s?.formSubmitButton??j.formSubmitButton,t&&fe("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:fe(de,{})})]})}),a&&Ue("div",{className:"flex items-center gap-3 text-sm text-green-400",children:[fe(as,{size:16})," ",s?.formSuccessMessage??j.formSuccessMessage]})]})}import{jsx as Yn,jsxs as us}from"react/jsx-runtime";var cs=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;function Jr({groups:e,onToggle:t,onCheckAll:n,slug:o,showPhoneInput:r=!1,agreementText:a,className:i,texts:l,isUpdating:c,wasChanged:p,onSuccess:s}){let[y,v]=Rt(""),[m,g]=Rt(""),[d,I]=Rt(!1),[R,h]=Rt(!1),[b,A]=Rt(!1),{mutateAsync:x,isPending:E}=Re(ye.notifications.createNotificationUser);function D(w){return w==null?!1:ls(w,"PL")}async function S(w,C,U){if(v(""),g(""),A(!1),I(!1),h(!1),!U){h(!0),v("Zgoda w tym przypadku jest wymagana.");return}if(cs.test(w)===!1){v("Email jest nieprawid\u0142owy."),A(!0);return}C.length>0&&D(C)===!1&&g("Numer telefonu mo\u017Ce by\u0107 nieprawid\u0142owy. Zapisali\u015Bmy go ale je\u015Bli jest nieprawid\u0142owy to wpisz jeszcze raz i kliknij przycisk.");try{let f=await x({slug:o,email:w,phone:C,groups:e.filter(k=>k.isOn==!0).map(k=>k.id),mobileNotificationEnabled:!0,emailNotificationEnabled:!0,smsNotificationEnabled:!0});if(f.result.case==="success"){I(!0),setTimeout(()=>{s?.(!1,f.userId,f.accessToken)},1e3);return}else{I(!0);let k=f.result.value;if(k!=null){if(k==32){s?.(!0,void 0,void 0);return}console.log(`Code error: ${vn[k]}`),v("Wyst\u0105pi\u0142 b\u0142\u0105d: "+vn[k]);return}return}}catch(f){v("Wyst\u0105pi\u0142 b\u0142\u0105d podczas zapisywania. Spr\xF3buj ponownie."),console.log(`Error: ${f}`)}}let T=l?.formTitle??j.formTitle;return us("div",{className:u("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",i?.formSection),children:[T.length>0&&Yn("h3",{className:u("mb-3 text-base font-medium lg:text-lg",i?.formTitle),children:T}),Yn(ln,{groups:e,isManaging:!1,onToggle:t??(()=>{}),onCheckAll:n??(()=>{}),isUpdating:c??!1,wasChanged:p??!1,isUserGroupsUpdated:!1,className:i,texts:l}),Yn(Zr,{errMsg:y,emailLack:b,warnMsg:m,submit:S,isLoading:E,isSubmited:d,agreementLack:R,showPhoneInput:r,agreementText:a??l?.agreementText??j.agreementText,className:i,texts:l})]})}import{useEffect as gs,useState as At}from"react";import{Label as Zn}from"@radix-ui/react-label";import{MessageCircleWarningIcon as ys}from"lucide-react";import{useDebouncedCallback as hs}from"use-debounce";import{TriangleAlertIcon as ds,XIcon as ps}from"lucide-react";import{createPortal as ms}from"react-dom";import{useEffect as ea,useState as fs}from"react";import{jsx as he,jsxs as vt}from"react/jsx-runtime";function ta({open:e,onOpenChange:t,onConfirm:n,isDeleting:o=!1}){let[r,a]=fs(!1);if(ea(()=>(a(!0),()=>a(!1)),[]),ea(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),!r||!e)return null;let i=c=>{c.target===c.currentTarget&&t(!1)},l=()=>{n()};return ms(he("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/50 p-4",onClick:i,children:vt("div",{className:u("relative w-full max-w-md rounded-2xl bg-white p-6 shadow-lg","dark:bg-neutral-800","animate-in fade-in-0 zoom-in-95 duration-200"),onClick:c=>c.stopPropagation(),children:[vt("button",{onClick:()=>t(!1),className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-neutral-950 focus:ring-offset-2 disabled:pointer-events-none dark:ring-offset-neutral-950 dark:focus:ring-neutral-300",disabled:o,children:[he(ps,{className:"h-4 w-4"}),he("span",{className:"sr-only",children:"Zamknij"})]}),vt("div",{className:"flex flex-col gap-4",children:[vt("div",{className:"flex items-start gap-3",children:[he("div",{className:"flex-shrink-0",children:he(ds,{className:"h-6 w-6 text-amber-500","aria-hidden":"true"})}),he("div",{className:"flex-1",children:he("h2",{className:"text-lg font-semibold text-black dark:text-neutral-100",children:"Czy na pewno chcesz si\u0119 wypisa\u0107?"})})]}),he("p",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Klikni\u0119cie tego przycisku spowoduje wypisanie z wszelkich powiadomie\u0144 i grup, kt\xF3re zapisa\u0142e\u015B."}),vt("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[he($,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:o,className:"sm:min-w-[100px]",children:"Anuluj"}),vt($,{type:"button",variant:"destructive",onClick:l,disabled:o,className:u(o&&"cursor-not-allowed text-transparent","relative sm:min-w-[100px]"),children:["Usu\u0144",o&&he("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:he("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"})})]})]})]})]})}),document.body)}import{useAutoAnimate as na}from"@formkit/auto-animate/react";import{Fragment as vs,jsx as H,jsxs as ve}from"react/jsx-runtime";function oa({accessToken:e,slug:t,userID:n,className:o,texts:r}){let[a]=na(),[i]=na(),{mutateAsync:l,isPending:c}=Re(ye.notifications.deleteNotificationUser),{mutateAsync:p,isPending:s}=Re(ye.notifications.updateNotificationUser),{data:y,isFetching:v}=qt(ye.notifications.getNotificationUserSettings,{userId:n,slug:t,accessToken:e}),[m,g]=At(!1),[d,I]=At(!1),[R,h]=At(!1),[b,A]=At(!1),[x,E]=At(!1),D=y?.result.case==="success"?y?.result?.value:void 0;function S(){E(!0)}async function T(){await l({accessToken:e,slug:t,userId:n}),E(!1)}async function w(){await p({accessToken:e,slug:t,notificationUserId:n,mobileNotificationEnabled:b,emailNotificationEnabled:m,smsNotificationEnabled:d}),h(!0),setTimeout(()=>{h(!1)},3e3)}let C=hs(f=>{w()},300);gs(()=>{let f=y?.result.case==="success"?y?.result?.value:void 0;g(f?.emailNotificationEnabled??!1),I(f?.smsNotificationEnabled??!1),A(f?.mobileNotificationEnabled??!1)},[y]);function U(f,k){f==="email"&&g(k),f==="phone"&&I(k),f==="push"&&A(k),C(!0)}return ve("div",{className:u("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",o?.manageDataSection),children:[H("div",{className:"flex justify-start",children:H("h3",{className:u("mb-3 text-base font-medium lg:text-lg",o?.manageDataTitle),children:r?.manageDataTitle??j.manageDataTitle})}),v?H(Eo,{className:"h-64 w-full"}):ve(et,{ref:i,className:u(s&&"relative"),children:[H(tt,{children:H(nt,{children:H("p",{className:"text-sm text-left",children:r?.manageDataDescription??j.manageDataDescription})})}),ve(ot,{ref:a,children:[H("div",{className:u(s&&"opacity-50 pointer-events-none","flex flex-col gap-2"),children:ve("div",{className:"flex flex-col items-start gap-5 gap-x-2",children:[D?.emailNotificationAvailable&&ve("div",{className:"flex items-center gap-3",children:[H(ht,{id:"email-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:m,onCheckedChange:()=>{U("email",!m)}}),H(Zn,{htmlFor:"email-enabled",className:"text-sm",children:"Email"})]}),D?.smsNotificationAvailable&&ve("div",{className:"flex items-center gap-3",children:[H(ht,{id:"sms-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:d,onCheckedChange:()=>{U("phone",!d)}}),H(Zn,{htmlFor:"sms-enabled",className:"text-sm",children:"SMS"})]}),D?.mobileNotificationAvailable&&ve(vs,{children:[ve("div",{className:"flex items-center gap-3",children:[H(ht,{id:"push-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:b,onCheckedChange:()=>{U("push",!b)}}),H(Zn,{htmlFor:"push-enabled",className:"text-sm",children:"Powiadomienia na telefon"})]}),D?.hasUserInstalledApp===!1&&ve("div",{className:"flex items-center gap-3",children:[H(ys,{color:"var(--color-amber-500)",size:26}),H("p",{className:"text-xs text-amber-500",children:"Wygl\u0105da na to, \u017Ce nie masz zainstalowanej aplikacji mobilnej. Zainstaluj i wyra\u017A zgod\u0119 na otrzymywanie powiadomie\u0144 na telefon."})]})]})]})}),ve("div",{className:"mt-5 flex flex-col gap-2 text-left",children:[H("hr",{}),R&&H("p",{className:"text-xs text-green-500",children:r?.manageDataUpdatedMessage??j.manageDataUpdatedMessage}),H("div",{className:"flex items-center gap-x-2",children:ve($,{size:"sm",variant:"link",className:u("pl-0 ml-0",c&&"cursor-not-allowed"),onClick:S,children:[r?.manageDataUnsubscribeButton??j.manageDataUnsubscribeButton,c&&H("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:H(de,{})})]})})]})]}),s&&H("div",{className:"bg-black/30 absolute inset-0 rounded-xl",children:H("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:H(de,{})})})]}),H(ta,{open:x,onOpenChange:E,onConfirm:T,isDeleting:c})]})}import{useAutoAnimate as ks}from"@formkit/auto-animate/react";import{ArrowLeft as ws}from"lucide-react";import{useMemo as pa,useRef as Is}from"react";import*as ae from"@radix-ui/react-dialog";import{XIcon as bs}from"lucide-react";import{jsx as Fe,jsxs as Jn}from"react/jsx-runtime";function ra({...e}){return Fe(ae.Root,{"data-slot":"dialog",...e})}function Cs({...e}){return Fe(ae.Portal,{"data-slot":"dialog-portal",...e})}function Ps({className:e,...t}){return Fe(ae.Overlay,{"data-slot":"dialog-overlay",className:u("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function aa({className:e,children:t,showCloseButton:n=!0,...o}){return Jn(Cs,{"data-slot":"dialog-portal",children:[Fe(Ps,{}),Jn(ae.Content,{"data-slot":"dialog-content",className:u("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...o,children:[t,n&&Jn(ae.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[Fe(bs,{}),Fe("span",{className:"sr-only",children:"Close"})]})]})]})}function ia({className:e,...t}){return Fe(ae.Title,{"data-slot":"dialog-title",className:u("text-lg leading-none font-semibold",e),...t})}function sa({className:e,...t}){return Fe(ae.Description,{"data-slot":"dialog-description",className:u("text-muted-foreground text-sm",e),...t})}import{Code as la,ConnectError as xs}from"@connectrpc/connect";function ua(e,t="pl"){let n=e.loginCodeSentMessage,o={emailLabel:e.loginEmailLabel,emailPlaceholder:e.loginEmailPlaceholder,sendCode:e.loginSendCodeButton,sending:e.loginSendingButton,invalidEmail:e.loginInvalidEmailError,codeSentTo:n!=null?`${n} {email}.`:void 0,changeEmail:e.loginChangeEmailButton,verify:e.loginVerifyButton,spamHint:e.loginSpamHint,validity:e.loginValidityHint,resend:e.loginResendCodeButton,resendIn:e.loginResendInText,resent:e.loginResentMessage,haveCodePrompt:"",haveCode:e.loginIHaveCode,wrongCode:e.loginInvalidCodeError,expired:e.loginExpiredError,tooManyAttempts:e.loginTooManyAttemptsError,rateLimited:e.loginRateLimitedError,network:e.loginNetworkError,generic:e.loginVerifyCodeError,deliveryFailed:e.loginSendEmailError,verifying:e.loginVerifyingButton,stepEmail:e.loginStepEmailHint,stepCode:e.loginStepCodeHint,alreadySent:e.loginAlreadySentMessage,emailNotFound:e.loginEmailNotFoundError,deliveryUnavailable:e.loginDeliveryUnavailableError,resendNew:e.loginResendNewCodeButton,noCode:e.loginNoCodeButton,codeIncomplete:e.loginCodeIncompleteError};return wo(t,o)}function ca(e){let t=xs.from(e),n=t.rawMessage||t.message;return t.code===la.ResourceExhausted?/too many attempts/i.test(n)?"tooManyAttempts":"rateLimited":/invalid code/i.test(n)?"wrongCode":/expired/i.test(n)?"expired":t.code===la.Unavailable?"unknown":bo(e)}function da(e,t,n){return{async send(o,{resend:r}){if(!t)return{ok:!1,kind:"unknown",message:n.loginSlugRequiredError};try{let a=await e({email:o,slug:t});return a.ok===!1?a.retryIn!=null&&a.retryIn>0?{ok:!1,kind:"rateLimited",retryIn:a.retryIn}:{ok:!1,kind:"deliveryFailed",message:r?n.loginResendEmailError:n.loginSendEmailError}:a.sent===!1?{ok:!1,kind:"alreadySent",retryIn:a.retryIn||void 0}:{ok:!0,retryIn:a.retryIn||void 0}}catch(a){let i=ca(a);return{ok:!1,kind:i,cause:a,message:i==="unknown"?r?n.loginResendEmailError:n.loginSendEmailError:void 0}}},async verify({email:o,code:r}){try{let a=await e({email:o,code:r,slug:t});return a.ok&&a.accessToken?{ok:!0,value:{userId:a.userId,accessToken:a.accessToken}}:{ok:!1,kind:"wrongCode",message:n.loginVerificationFailedError}}catch(a){return{ok:!1,kind:ca(a),cause:a}}}}}import{jsx as Oe,jsxs as ma}from"react/jsx-runtime";function Ss({slug:e,onSuccess:t,onError:n,texts:o,projectName:r,projectLogo:a,projectLogoDark:i,showLogo:l}){let[c]=ks(),{mutateAsync:p}=Re(ye.notifications.verifyUserEmail),s=pa(()=>ua(o),[o]),[y,v]=s.codeSentTo.split("{email}"),m=Is(n);m.current=n;let g=pa(()=>{let h=da(b=>p(b),e,o);return{...h,async verify(b){let A=await h.verify(b);return!A.ok&&A.kind==="wrongCode"&&m.current?.(A.cause instanceof Error?A.cause:new Error(A.message??"wrongCode")),A}}},[p,e,o]),d=Io({adapter:g,texts:s,storageKey:e?xo("notifications",e):void 0,onVerified:({userId:h,accessToken:b})=>t?.(h,b),onFailure:(h,b)=>n?.(b instanceof Error?b:new Error(h))}),I=d.step==="code",R=I&&!d.needsEmail?o.loginCodeLabel??"":o.loginTitle??"";return ma("div",{className:"flex h-full flex-col",children:[Oe(Po,{projectId:e,name:r,showLogo:l,logoUrl:a,logoDarkUrl:i,className:"text-foreground mb-3"}),ma("div",{ref:c,className:"mb-2 flex items-start gap-2",children:[I&&Oe($,{type:"button",variant:"ghost",size:"icon-sm",className:"-mt-2 -ml-2 size-11 shrink-0","aria-label":s.changeEmail,disabled:d.isBusy,onClick:d.changeEmail,children:Oe(ws,{className:"h-5 w-5","aria-hidden":!0})}),Oe(ia,{className:"text-lg leading-6 font-semibold",children:R})]}),Oe(sa,{className:I?"sr-only":"mb-4",children:I?`${y}${d.email}${v??""}`:o.loginDescription??""}),Oe(So,{login:d,texts:s})]})}function fa({slug:e,onSuccess:t,onError:n,className:o,isOpen:r,onClose:a,texts:i,projectName:l,projectLogo:c,projectLogoDark:p,showLogo:s}){return Oe(ra,{open:r,onOpenChange:a,children:Oe(aa,{className:"max-h-[100dvh] overflow-y-auto sm:max-w-[425px]",children:Oe(Ss,{slug:e,onSuccess:t,onError:n,texts:i,projectName:l,projectLogo:c,projectLogoDark:p,showLogo:s})})})}import{useAutoAnimate as As}from"@formkit/auto-animate/react";import{jsx as ne,jsxs as eo}from"react/jsx-runtime";function Ds(e,t){switch(t.type){case"SET_IS_LOGGED_IN":return{...e,isLoggedIn:t.value};case"SET_USER_ID":return{...e,userID:t.value};case"SET_LOADING":return{...e,isLoading:t.value};case"SET_PUBLIC_GROUPS":return{...e,groupsProvided:t.value,groups:t.value!=null&&t.value.length>0?e.groups.filter(n=>t.value?.find(o=>o.id===n.id)!=null):e.groups};case"SET_GROUPS":{let n=e.isLoggedIn==!1||e.groupsProvided!=null,o=t.value.map(r=>e.isLoggedIn==!0?r:{...r,isOn:e.groupsProvided?.find(a=>a.id===r.id)?.isOn??n});return{...e,groups:o}}case"TOGGLE_GROUP":{let n=e.groups.map(o=>o.id===t.groupID?{...o,isOn:!o.isOn}:o);return{...e,wasChanged:!0,groups:n}}case"CHECK_ALL_GROUPS":{let n=e.groups.map(o=>({...o,isOn:!0}));return{...e,groups:n,wasChanged:!0}}case"SET_WAS_CHANGED":return{...e,wasChanged:t.value};case"SET_IS_USER_GROUPS_UPDATED":return{...e,isUserGroupsUpdated:t.value};case"RESET_UPDATE_STATE":return{...e,wasChanged:!1,isUserGroupsUpdated:!0};case"SHOW_SETTINGS":return{...e,showSettings:!0};case"HIDE_SETTINGS":return{...e,showSettings:!1};default:return e}}function Ls({slug:e,userID:t,productID:n,projectID:o,analytics:r,projectName:a,projectLogo:i,projectLogoDark:l,showLoginLogo:c,groups:p,isManaging:s=!1,texts:y,showQRCode:v=!1,showPhoneInput:m=!1,hiddenGroupIds:g=[],className:d}){let[I]=As(),R=me(o??ke(),r),h=e??ce()??(typeof window<"u"?window.location.hostname:"");Co(h.trim(),c!==!1&&!i&&!l&&h.trim()!=="");let{mutateAsync:b,isPending:A}=Re(ye.notifications.updateUserGroups),{data:x,refetch:E}=Ns({queryKey:["notifications_accessToken"],queryFn:()=>{if(typeof window<"u")return{accessToken:localStorage.getItem("notifications_accessToken")??void 0,userID:localStorage.getItem("notifications_userID")??void 0}}}),{data:D,isPending:S,refetch:T}=qt(ye.notifications.getUserGroups,{slug:h,accessToken:x?.accessToken}),[w,C]=Es(Ds,{isLoading:S,isUserGroupsUpdated:!1,wasChanged:!1,groupsProvided:p,groups:[],showSettings:x!=null&&s==!0,isLoggedIn:x!=null,userID:void 0});Dt(()=>{C({type:"SET_LOADING",value:A||S})},[A,S]),Dt(()=>{C({type:"SET_IS_LOGGED_IN",value:x?.accessToken!=null}),C({type:"SET_USER_ID",value:x?.userID}),x?.accessToken!=null&&s==!0&&C({type:"SHOW_SETTINGS"})},[x,s]),Dt(()=>{if(D==null)return;let W=D.groups.map(F=>{let V="rarely";switch(F.howOften){case 0:V="rarely";break;case 1:V="often";break;case 2:V="veryOften";break}return{id:F.id,name:F.name,description:F.description,howOften:V,isOn:F.isOn??void 0}});C({type:"SET_GROUPS",value:W})},[D,S,p]);let U=Ts(null);Dt(()=>{let W=p?.map(F=>(F.id.startsWith("group_")||(F.id=`group_${F.id}`),F));C({type:"SET_PUBLIC_GROUPS",value:W})},[p]);let f={...j,...y};async function k(){await b({accessToken:x?.accessToken,slug:h,userId:t,groupIds:w.groups.filter(W=>W.isOn===!0).map(W=>W.id)}),C({type:"RESET_UPDATE_STATE"}),U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{C({type:"SET_IS_USER_GROUPS_UPDATED",value:!1})},2e3)}function X(W){C({type:"TOGGLE_GROUP",groupID:W})}function be(){C({type:"CHECK_ALL_GROUPS"})}function Me(){C({type:"SHOW_SETTINGS"})}function M(){C({type:"HIDE_SETTINGS"})}function O(){localStorage.removeItem("notifications_accessToken"),localStorage.removeItem("notifications_userID"),E(),C({type:"SET_USER_ID",value:void 0}),C({type:"SET_IS_LOGGED_IN",value:!1}),C({type:"HIDE_SETTINGS"})}async function N(W,F){typeof window<"u"&&(localStorage.setItem("notifications_accessToken",F),W!=null&&localStorage.setItem("notifications_userID",W)),C({type:"SET_USER_ID",value:W});try{await E(),T().then().catch().finally(()=>{s==!0&&C({type:"SHOW_SETTINGS"})})}catch(V){console.log(`Error: ${V}`)}}Dt(()=>()=>{U.current&&clearTimeout(U.current)},[]);let _=s==!0&&w.userID!=null&&x?.accessToken!=null;return eo("main",{className:u("bitsnap-react relative",d?.container),children:[f.title!=null&&ne("h1",{className:"text-2xl font-semibold text-black md:text-3xl lg:text-4xl xl:text-5xl dark:text-neutral-100",children:f.title}),!w.showSettings&&s&&ne($,{onClick:Me,variant:"outline",size:"icon",className:"absolute bottom-6 right-6 z-50 h-12 w-12 rounded-full shadow-lg hover:shadow-xl md:bottom-8 md:right-8","aria-label":"Settings",children:ne(Rs,{className:"h-5 w-5"})}),ne("div",{className:u("md:pt8 relative z-0 mt-6 overflow-hidden rounded-2xl bg-white px-3 pt-6 pb-3 md:px-5 md:pb-5 dark:bg-neutral-800",d?.header),children:w.showSettings?ne("div",{className:"space-y-6",children:w.isLoggedIn&&eo("div",{className:u("grid grid-cols-1 gap-3 lg:gap-6",_?"md:grid-cols-2":""),children:[eo("div",{className:d?.groupsContainer,children:[ne(Fr,{projectName:a,projectLogo:i,projectLogoDark:l,description:f.managingDescription,className:d,onLogout:O}),S&&ne("div",{className:"flex justify-center items-center py-8",children:ne(de,{})}),ne(ln,{groups:w.groups,hiddenGroupIds:g,isManaging:s,onToggle:X,onCheckAll:be,onUpdate:k,isUpdating:A,wasChanged:w.wasChanged,isUserGroupsUpdated:w.isUserGroupsUpdated,className:d,texts:f})]}),_&&ne(oa,{accessToken:x.accessToken??"",slug:h,userID:w.userID??"",className:d,texts:f}),v!=!1&&ne(Xr,{showQRCode:v,isManaging:!0,className:d,texts:f})]})}):ne("div",{className:u("grid grid-cols-1 gap-3 lg:gap-6"),children:ne(Jr,{slug:h,onToggle:W=>{C({type:"TOGGLE_GROUP",groupID:W})},onCheckAll:()=>{C({type:"CHECK_ALL_GROUPS"})},onSuccess:(W,F,V)=>{R.track("availability_signup",{},{product_id:n??null}),V!=null&&N(F,V),W&&C({type:"SHOW_SETTINGS"})},groups:w.groups,showPhoneInput:m,agreementText:f.agreementText,className:d,texts:f,wasChanged:w.wasChanged,isUpdating:A})})}),ne(fa,{isOpen:w.showSettings&&!w.isLoggedIn,slug:h,onSuccess:N,texts:f,onClose:M,projectName:a,projectLogo:i,projectLogoDark:l,showLogo:c})]})}function _s({slug:e,userID:t,productID:n,projectID:o,analytics:r,projectName:a,projectLogo:i,projectLogoDark:l,showLoginLogo:c,groups:p,isManaging:s,texts:y,showQRCode:v,showPhoneInput:m,hiddenGroupIds:g,className:d}){return ne(bn,{children:ne(Ls,{slug:e,userID:t,productID:n,projectID:o,analytics:r,projectName:a,projectLogo:i,projectLogoDark:l,showLoginLogo:c,groups:p,isManaging:s,texts:y,showQRCode:v,showPhoneInput:m,hiddenGroupIds:g,className:d})})}var Us=_s;import{useMutation as Lt,useQuery as _t,useQueryClient as Bs}from"@tanstack/react-query";import ga from"react";import{jsx as cn,jsxs as un}from"react/jsx-runtime";function ya({choice:e,selected:t,onChange:n,disabled:o}){let r=at(),a=L("paymentMethods"),i=L("paymentMethodOption"),l=ga.useId(),c=ga.useId(),p=e.manualAccountTypes.length===0||e.manualAccountTypes.includes("blik"),s={online:{title:r("paymentMethodOnline"),description:r("paymentMethodOnlineDescription")},manual:{title:r(Do(e.manualAccountTypes)),description:r("paymentMethodManualDescription"),note:p?r("paymentMethodManualBlikNote"):void 0},cod:{title:r("paymentMethodCod"),description:r("paymentMethodCodDescription")}};return un("fieldset",{"data-bitsnap-checkout-slot":"paymentMethods","aria-labelledby":c,className:u("mx-2 mt-4 mb-2 flex min-w-0 flex-col gap-2 border-0 p-0",a.className),style:a.style,disabled:o,children:[cn("legend",{id:c,className:"mb-1 px-1 text-sm font-medium",children:r("paymentMethodLegend")}),e.methods.map(y=>{let v=s[y],m=y===t,g=`${l}-${y}-description`;return un("label",{"data-bitsnap-checkout-slot":"paymentMethodOption","data-payment-method":y,"data-selected":m?"":void 0,className:u("flex cursor-pointer items-start gap-3 rounded-md border px-3 py-2.5 transition-colors",i.className),style:i.style,children:[cn("input",{type:"radio",name:l,value:y,checked:m,onChange:()=>n(y),"aria-describedby":g,className:"mt-0.5 size-4 shrink-0 cursor-pointer"}),un("span",{className:"flex min-w-0 flex-col gap-0.5",children:[cn("span",{className:"text-sm font-semibold leading-snug",children:v.title}),un("span",{id:g,"data-bitsnap-checkout-payment-method-description":"",className:"text-xs leading-snug",children:[v.description,m&&v.note!=null&&cn("span",{className:"mt-1 block font-medium",children:v.note})]})]})]},y)})]})}import{Fragment as qs,jsx as B,jsxs as ge}from"react/jsx-runtime";var js=({className:e,locale:t})=>{let n=it(),o=xe(),r=t??Ne(),a=L("productList"),i=L("summary"),l=L("totalLabel"),c=L("totalValue"),p=L("deliveryText"),s=L("summaryNote"),y=L("countryLabel"),v=L("paymentButtons"),m=L("checkoutButton"),g=L("emptyState"),d=L("error"),I=L("skeleton"),R=z("unavailableProducts"),h=at(),b=z("emptyCart"),A=z("total"),x=z("delivery"),E=z("chooseCountry"),D=z("nextStep"),S=z("loadFailed"),T=z("retry"),w=z("countryRequired"),C=z("extrasCalculatedNext"),U=ee.useId(),f=ee.useId(),{mutateAsync:k}=Lt({mutationFn:n.removeProductFromCart}),{mutateAsync:X}=Lt({mutationFn:n.updateQuantity}),{mutateAsync:be}=Lt({mutationFn:n.setCountry}),{mutateAsync:Me}=Lt({mutationFn:n.clearCart}),[M,O]=ee.useState(""),N=Ke(P=>P.notice);ee.useEffect(()=>()=>Ke.getState().setNotice(void 0),[]);let _=M.length>0?M:N??"",[W,F]=ee.useState([]),[V,We]=ee.useState(!1),{mutateAsync:mn,isPending:Te}=Lt({mutationFn:n.redirectToNextStep}),{data:fn}=_t({queryKey:["cart-available-countries"],queryFn:n.getAvailableCountries}),{data:gn}=_t({queryKey:["cart-one-click-payment"],queryFn:n.checkIfApplePayIsAvailable}),{data:Y,isLoading:oe,isError:bt,refetch:to}=_t({queryKey:["cart",r],queryFn:n.getProducts}),{data:He,refetch:no}=_t({queryKey:["cart-country"],queryFn:n.getCountry}),[Ca]=Ms(),q=Q(Y)?void 0:Y,Be=He!=null&&!Q(He)&&He!=""?He:void 0,oo=Bs(),Ot=q==null||q.length===0||Be==null?void 0:q.map(P=>`${P.productID}:${P.quantity}`).sort().join(","),ro={queryKey:["cart-payment-methods",ce(),r,Be,Ot],queryFn:async()=>n.getPaymentMethodChoice().catch(()=>null),staleTime:6e4,retry:!1},{data:ao,isPlaceholderData:Pa}=_t({...ro,enabled:Ot!=null,placeholderData:P=>P===void 0?void 0:Ao(P)}),Mt=Ot!=null?ao??null:null,[io,xa]=ee.useState(void 0),[so,lo]=ee.useState(!1),co=ee.useRef(null),uo=!oe&&(bt||Q(Y)),je=Q(fn)?[]:fn,Ct=q?.reduce((P,K)=>K.details==null?P:P+(K.details.pricing?.effectivePrice??K.details.price)*K.quantity,0)??0,Pt=q?.[0]?.details?.currency??"PLN",ka=q?.some(P=>P.details?.isDeliverable===!0)??!1,po=He!==void 0&&Be==null,mo=ee.useRef(!1);ee.useEffect(()=>{mo.current||je==null||je.length===0||He==null||Be!=null&&je.some(P=>P.code===Be)||(mo.current=!0,be(je[0].code).then(()=>no()).catch(()=>{}))},[je,He,Be]);let fo=ee.useRef(!1);ee.useEffect(()=>{fo.current||oe||(fo.current=!0,o.track("cart_opened",{item_count:q?.reduce((P,K)=>P+K.quantity,0)??0,value_minor:Ct,currency:Pt}))},[oe,o,q,Ct,Pt]);let yn=ee.useRef(new Map);ee.useEffect(()=>{yn.current.clear()},[q]);function wa(P,K){let se=q?.find(Ea=>Ea.id===P);if(se?.details==null)return;let le=K-(yn.current.get(P)??se.quantity);if(yn.current.set(P,K),le===0)return;let Ce=se.details.pricing?.effectivePrice??se.details.price,Bt=se.catalogProductID??se.productID;o.track(le>0?"add_to_cart":"remove_from_cart",{qty:Math.abs(le),value_minor:Math.round(Ce*Math.abs(le)),currency:se.details.currency},{product_id:Bt,variant_id:Bt!==se.productID?se.productID:null})}let go=ee.useRef(!1);async function Ia(P,K){if(K!=null){wa(P,Math.max(0,K));try{let se=K<=0?await k({id:P}):await X({id:P,quantity:K});if(Q(se))throw new Error(`cannot change the cart: ${se.error}`)}finally{await to().catch(()=>{})}}}async function Sa(){try{O(""),F([]),Ke.getState().setNotice(void 0);let P=Mt,K=P!=null?Pn(P,io):void 0;if(Ot!=null&&(ao===void 0||Pa)){lo(!0);try{P=await oo.fetchQuery(ro).catch(()=>null)}finally{lo(!1)}if(P==null)K=void 0;else if(K==null||!P.methods.includes(K)){window.setTimeout(()=>{co.current?.querySelector("input:checked")?.focus()},0);return}}if(q!=null){!go.current&&q.length>0&&(go.current=!0,o.track("checkout_started",{item_count:q.reduce((Ce,Bt)=>Ce+Bt.quantity,0),checkout_type:"cart",value_minor:Ct,currency:Pt}));try{Ae({event:"initiateCheckout",items:q?.map(Ce=>({id:Ce.productID,name:Ce.details?.name??"",price:Ce.details?.price??0,quantity:Ce.quantity,currency:Ce.details?.currency??"PLN"}))})}catch{}}let se=_o(),le=await mn(K!=null?{paymentMethod:K}:void 0);if(Q(le)){oo.invalidateQueries({queryKey:["cart-payment-methods"]}),le.error=="item-ids-not-found"?(O(R),"data"in le&&Array.isArray(le.data)&&F(le.data)):K==="cod"&&le.error=="gateway-not-configured"?O(h("paymentMethodCodUnavailable")):O(Ro(le,h));return}Lo(le,{cartProjectId:ce(),lines:se})||await Me(),window.location.href=le.url}catch(P){console.warn("checkout failed",P),O(h("checkoutFailed"))}}return ge("div",{className:`${e} flex flex-col`,ref:Ca,children:[oe&&ge("div",{className:"relative flex w-full justify-center flex-col gap-4",children:[B(Nn,{"data-bitsnap-checkout-slot":"skeleton",className:u("w-full h-32",I.className),style:I.style}),B(Nn,{"data-bitsnap-checkout-slot":"skeleton",className:u("w-full h-32",I.className),style:I.style})]}),uo&&ge("div",{className:"flex flex-col items-start gap-3 p-4",children:[B("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:u(d.className),style:d.style,children:S}),N!=null&&N.length>0&&B("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:u("text-sm",d.className),style:d.style,children:N}),B("button",{type:"button","data-bitsnap-checkout-slot":"checkoutButton",onClick:()=>{to().then().catch()},className:u("px-3 py-2 rounded-md transition font-bold",m.className),style:m.style,children:T})]}),!oe&&!uo&&(q==null||q.length==0)&&ge("div",{className:"flex flex-col gap-4 p-4",children:[B("p",{"data-bitsnap-checkout-slot":"emptyState",className:u(g.className),style:g.style,children:b}),N!=null&&N.length>0&&B("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:u("text-sm",d.className),style:d.style,children:N})]}),B("div",{"data-bitsnap-checkout-slot":"productList",className:u("max-h-[70vh] overflow-clip overflow-y-scroll",a.className),style:a.style,children:q!=null&&q.length>0&&B("ul",{className:"mt-5",children:q.map(P=>B(ee.Fragment,{children:P.details!=null&&ge("li",{className:"mb-3",children:[B(er,{isNotAvailable:W.includes(P.productID),quantity:P.quantity,details:P.details,url:P.url,shouldUpdate:K=>Ia(P.id,K)}),B("hr",{className:"h-1"})]})},P.id))})}),B("div",{className:"grow"}),Ct>0&&Pt!=null&&ge(qs,{children:[ge("div",{"data-bitsnap-checkout-slot":"summary",className:u("mx-3 flex flex-col",i.className),style:i.style,children:[ge("div",{className:"flex flex-row justify-between text-lg",children:[B("p",{"data-bitsnap-checkout-slot":"totalLabel",className:u("text-xl",l.className),style:l.style,children:A}),ge("div",{className:"flex flex-col items-end",children:[B("p",{"data-bitsnap-checkout-slot":"totalValue",className:u("font-medium",c.className),style:c.style,children:Ve(Ct,Pt)}),ka&&B("p",{"data-bitsnap-checkout-slot":"deliveryText",className:u("opacity-70 text-right text-base",p.className),style:p.style,children:x})]})]}),B("p",{"data-bitsnap-checkout-slot":"summaryNote",className:u("opacity-70 text-sm",s.className),style:s.style,children:C})]}),je&&je?.length>1&&ge("div",{children:[B("h4",{"data-bitsnap-checkout-slot":"countryLabel",className:u("ml-3 text-sm",y.className),style:y.style,children:E}),B($o,{id:U,open:V,onToggle:()=>{We(!V)},onChange:P=>{be(P).then(()=>{no().then().catch()})},selectedValue:Be??"",countries:je})]}),ge("div",{className:"mb-3 flex flex-col",children:[gn&&q!=null&&q.length>0&&B("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:u("w-full px-2",v.className),style:v.style,children:B(Rn,{colorType:"white",style:{width:"100%"},items:q?.map(P=>({name:P.details?.name??"",id:P.productID,price:P.details?.pricing?.effectivePrice??P.details?.price??0,currency:P.details?.currency,quantity:P.quantity,isDeliverable:P.details?.isDeliverable??!1,metadata:P.metadata}))})}),q!=null&&q.length>0&&B("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:u("w-full px-2",v.className),style:v.style,children:B(An,{buttonSizeMode:"fill",buttonColor:"white",style:{width:"100%"},items:q?.map(P=>({name:P.details?.name??"",id:P.productID,price:P.details?.pricing?.effectivePrice??P.details?.price??0,quantity:P.quantity,isDeliverable:P.details?.isDeliverable??!1,metadata:P.metadata}))})}),q!=null&&q.length>0&&ge("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:u("w-full px-2",v.className),style:v.style,children:[B(Gn,{projectID:ce()??"",locale:r}),B($n,{projectID:ce()??"",locale:r})]}),Mt!=null&&B("div",{ref:co,className:"contents",children:B(ya,{choice:Mt,selected:Pn(Mt,io),onChange:xa,disabled:Te})}),B("button",{"data-bitsnap-checkout-slot":"checkoutButton",onClick:Sa,disabled:oe||Te||so||Be==null,"aria-describedby":po?f:void 0,className:u("px-3 py-2 my-2 mx-2 rounded-md disabled:opacity-40 disabled:cursor-not-allowed transition font-bold",m.className),style:m.style,children:Te||so?B(de,{}):D}),po&&B("p",{id:f,className:"text-sm text-center opacity-70",children:w}),_.length>0&&B("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:u("text-sm text-center",d.className),style:d.style,children:_})]})]})]})},ha=js;import{jsx as pe,jsxs as dn}from"react/jsx-runtime";function Ks({isVisible:e,shouldHide:t,panelId:n,locale:o}){let[r]=zs(),[a,i]=Ws(null),l=Gs(b=>{r(b),i(b)},[r]),c=Fs(null),{boundaryClassName:p,boundaryStyle:s}=kt(),y=L("root"),v=L("overlay"),m=L("panel"),g=L("header"),d=L("title"),I=L("closeButton"),R=z("cart"),h=z("close");return pe("div",{ref:l,"data-bitsnap-checkout":"root","data-bitsnap-checkout-slot":"root",className:u("bitsnap-react",p,y.className),style:{zIndex:999999,...s,...y.style},children:a!=null&&pe(Ee.Root,{open:e,onOpenChange:b=>{b||t()},children:dn(Ee.Portal,{container:a,children:[pe(Ee.Overlay,{"data-bitsnap-checkout-slot":"overlay","aria-hidden":"true",className:u("fixed top-0 right-0 left-0 bottom-0 cursor-pointer z-10",v.className),style:v.style,onClick:t}),dn(Ee.Content,{id:n,"data-bitsnap-checkout-slot":"panel","aria-modal":"true","aria-describedby":void 0,onOpenAutoFocus:()=>{let b=document.activeElement;c.current=b instanceof HTMLElement?b:null},onCloseAutoFocus:b=>{b.preventDefault(),c.current?.focus(),c.current=null},className:u("fixed z-20 top-0 right-0 bottom-0 w-full md:w-[350px] xl:w-[420px] flex flex-col overflow-y-auto",m.className),style:m.style,onPointerDownOutside:b=>b.preventDefault(),children:[dn("div",{"data-bitsnap-checkout-slot":"header",className:u("mx-3 mt-7 flex justify-between items-center",g.className),style:g.style,children:[pe(Ee.Title,{asChild:!0,children:pe("h1",{"data-bitsnap-checkout-slot":"title",className:u("text-2xl font-medium",d.className),style:d.style,children:R})}),pe("button",{type:"button","data-bitsnap-checkout-slot":"closeButton",className:u("rounded-xl p-2 transition",I.className),style:I.style,"aria-label":h,onClick:t,children:dn("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-x","aria-hidden":"true",focusable:"false",children:[pe("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),pe("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),pe(ha,{className:"grow",locale:o})]})]})})})}var Vs=e=>typeof window>"u"?null:Hs(pe(ct,{appearance:e.appearance,children:pe(rt,{texts:e.texts,locale:e.locale,children:pe(st,{locale:e.locale,children:pe(Ks,{...e})})})}),document.body),va=Vs;import{Fragment as ba,jsx as Je,jsxs as pn}from"react/jsx-runtime";var Xs=ie.object({id:ie.string(),isSubscription:ie.boolean().default(!1),quantity:ie.number(),metadata:ie.record(ie.string(),ie.string().optional()).optional(),url:ie.string().optional()}),Ys={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0};function Zs({projectID:e,locale:t,children:n,onVisibleChange:o,className:r,numberOfProductsInCartOptions:a,appearance:i,texts:l,analytics:c}){let p=me(e,c,"cart");ho(p);let{isCartVisible:s,showCart:y,hideCart:v,numberOfProductsInCart:m}=Ke(),g=`bitsnap-cart-${$s()}`,d=E=>vo(E,t??Ne(),l),I=Qs(d);I.current=d;function R(E){Ke.getState().setNotice(I.current(E)),y()}function h(E){document.querySelectorAll("iframe").forEach(S=>{S.contentWindow?.postMessage(E,"*")})}Ut(()=>{o?.(s),s&&Ae({event:"viewCart"})},[s]),Ut(()=>{$e(e)},[e]),Ut(()=>{hn(t)},[t]),Ut(()=>{if(!("cart"in window)){let E=ce();if(E==null){console.warn("There is no project ID configured.");return}window.cart={buyProduct:async D=>{try{let S=ie.object({productID:ie.string(),email:ie.string().optional(),name:ie.string().optional(),country:ie.string().optional(),marketingAgreement:ie.boolean().optional(),locale:ie.string().optional()}).parse(D),T=In(E);try{let C=await T.getProducts();Q(C)==!1&&Ae({event:"initiateCheckout",items:C.map(U=>({id:U.productID,name:U.details?.name??"",price:U.details?.price??0,quantity:U.quantity,currency:U.details?.currency??"PLN"}))})}catch{}let w=await T.justRedirectToPayment(S);Q(w)==!1?window.location.href=w.url:R("redirectFailed")}catch(S){console.warn(S)}}}}},[]);async function b(E,D){let S=ce();if(S==null){console.warn("There is no project ID configured.");return}try{let T=Xs.parse(D);if(T.isSubscription){await A(S,T);return}await In(S).addProduct({productID:T.id,quantity:T.quantity,metadata:T.metadata,url:T.url}),h({id:E,type:"ADD_TO_CART",success:!0}),y()}catch(T){console.warn("cannot add item to cart",T)}}async function A(E,D){console.warn("subscriptions cannot be added to the cart yet",E,D.id),R("subscriptionUnsupported")}function x(){"__cart_is_listening"in window||(window.__cart_is_listening=!0,window.addEventListener("message",E=>{if(typeof E.data.id<"u"&&typeof E.data.type<"u"){let{id:D,type:S}=E.data;switch(S){case"ADD_TO_CART".toString():b(D,E.data.payload).then().catch();break;default:break}}}))}return Ut(()=>{if(x(),typeof window<"u")try{let E=new URLSearchParams(window.location.search),D=E.get("ref")??E.get("utm-source");typeof localStorage<"u"&&D&&D.length>0&&localStorage.setItem("bitsnap-ref",D)}catch{return}},[]),pn(ba,{children:[pn("button",{type:"button",onClick:()=>s?v():y(),"aria-label":n?void 0:m>0?`${d("openCart")}. ${d("cartItemsCount")}: ${m}`:d("openCart"),"aria-expanded":s,"aria-haspopup":"dialog","aria-controls":s?g:void 0,style:{position:"relative"},className:["bitsnap-react",r??"rounded-full hover:bg-neutral-300 transition p-1"].join(" "),children:[n?Je(ba,{children:n}):pn("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-shopping-cart","aria-hidden":"true",focusable:"false",children:[Je("circle",{cx:"8",cy:"21",r:"1"}),Je("circle",{cx:"19",cy:"21",r:"1"}),Je("path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"})]}),m>0&&pn("span",{style:Ys,children:[d("cartItemsCount"),": ",m]}),a?.isVisible!=!1&&m>0&&Je("div",{"aria-hidden":"true",style:{position:"absolute",bottom:-5,right:-5,background:"black",color:"white",borderRadius:"50%",width:"22px",height:"22px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",fontWeight:600,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.25)",...a?.style},children:m})]}),Je(Pe,{value:p,children:Je(va,{isVisible:s,locale:t,appearance:i,texts:l,panelId:g,shouldHide:()=>{v()}})})]})}var Os=Zs;export{Ta as a,Wi as b,Qi as c,Os as d,Rn as e,An as f,Us as g};
|
|
2
|
+
//# sourceMappingURL=chunk-JRSQ2IGQ.mjs.map
|