bitsnap-react 1.18.1 → 1.19.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.
Files changed (146) hide show
  1. package/AGENTS.md +21 -0
  2. package/README.md +45 -0
  3. package/dist/BitsnapCart-E72W5RRZ.mjs +2 -0
  4. package/dist/BitsnapCart-LHJ6KOTV.css +2 -0
  5. package/dist/BitsnapCart-LHJ6KOTV.css.map +1 -0
  6. package/dist/BitsnapCart-Q2HER6GU.js +2 -0
  7. package/dist/BitsnapCart-Q2HER6GU.js.map +1 -0
  8. package/dist/CartProvider-677CE2FI.js +2 -0
  9. package/dist/CartProvider-677CE2FI.js.map +1 -0
  10. package/dist/CartProvider-YPDOFSYC.mjs +2 -0
  11. package/dist/PanelModelFiles-EKQRLF46.js.map +1 -1
  12. package/dist/analytics.js +1 -1
  13. package/dist/analytics.js.map +1 -1
  14. package/dist/analytics.mjs +1 -1
  15. package/dist/catalog.js +1 -1
  16. package/dist/catalog.js.map +1 -1
  17. package/dist/catalog.mjs +1 -1
  18. package/dist/chat.css +2 -0
  19. package/dist/chat.css.map +1 -0
  20. package/dist/chat.d.mts +172 -0
  21. package/dist/chat.d.ts +172 -0
  22. package/dist/chat.js +2 -0
  23. package/dist/chat.js.map +1 -0
  24. package/dist/chat.mjs +2 -0
  25. package/dist/chat.mjs.map +1 -0
  26. package/dist/chunk-2FD2QP4Y.js +2 -0
  27. package/dist/chunk-2FD2QP4Y.js.map +1 -0
  28. package/dist/chunk-5JRUPLXY.mjs +2 -0
  29. package/dist/chunk-5JRUPLXY.mjs.map +1 -0
  30. package/dist/chunk-5M6M7FAR.mjs +2 -0
  31. package/dist/chunk-5M6M7FAR.mjs.map +1 -0
  32. package/dist/chunk-6Q3VGPSF.js.map +1 -1
  33. package/dist/chunk-AAC576BC.mjs +5 -0
  34. package/dist/chunk-AAC576BC.mjs.map +1 -0
  35. package/dist/{chunk-ZKT4N553.mjs → chunk-AB37DWOK.mjs} +2 -2
  36. package/dist/{chunk-AHISXVEE.js → chunk-BUYTK7KM.js} +2 -2
  37. package/dist/chunk-BUYTK7KM.js.map +1 -0
  38. package/dist/{chunk-G4SEOVLD.js → chunk-D2ASWUXM.js} +2 -2
  39. package/dist/chunk-D2ASWUXM.js.map +1 -0
  40. package/dist/chunk-DDIEFKNP.mjs +2 -0
  41. package/dist/{chunk-ZM5T4TQW.mjs.map → chunk-DDIEFKNP.mjs.map} +1 -1
  42. package/dist/{chunk-N3B25GTY.js → chunk-DOJICJCQ.js} +2 -2
  43. package/dist/chunk-DOJICJCQ.js.map +1 -0
  44. package/dist/chunk-EMR4YXNY.mjs +2 -0
  45. package/dist/chunk-EMR4YXNY.mjs.map +1 -0
  46. package/dist/{chunk-DR7WYI37.js → chunk-GJOGATP6.js} +2 -2
  47. package/dist/chunk-GJOGATP6.js.map +1 -0
  48. package/dist/chunk-GQ5OKU74.js +2 -0
  49. package/dist/chunk-GQ5OKU74.js.map +1 -0
  50. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  51. package/dist/chunk-KHQEDQYF.js +5 -0
  52. package/dist/chunk-KHQEDQYF.js.map +1 -0
  53. package/dist/chunk-KOYBZORL.js.map +1 -1
  54. package/dist/chunk-LGPNJ5XE.js +2 -0
  55. package/dist/chunk-LGPNJ5XE.js.map +1 -0
  56. package/dist/chunk-MDAFPGPA.js +2 -0
  57. package/dist/chunk-MDAFPGPA.js.map +1 -0
  58. package/dist/{chunk-UTUPPMLK.mjs → chunk-MMLBQHBM.mjs} +2 -2
  59. package/dist/chunk-MWWEPEU2.js +2 -0
  60. package/dist/chunk-MWWEPEU2.js.map +1 -0
  61. package/dist/{chunk-62WDFH7K.mjs → chunk-N523LFAM.mjs} +2 -2
  62. package/dist/chunk-NWXZ45TV.js +2 -0
  63. package/dist/chunk-NWXZ45TV.js.map +1 -0
  64. package/dist/chunk-OR566YJI.mjs +2 -0
  65. package/dist/chunk-OR566YJI.mjs.map +1 -0
  66. package/dist/chunk-Q337IQNA.js.map +1 -1
  67. package/dist/chunk-SCEWYZUZ.mjs +2 -0
  68. package/dist/chunk-SCEWYZUZ.mjs.map +1 -0
  69. package/dist/{chunk-GKJURMDO.mjs → chunk-SSSF64M7.mjs} +2 -2
  70. package/dist/{chunk-GKJURMDO.mjs.map → chunk-SSSF64M7.mjs.map} +1 -1
  71. package/dist/chunk-W3RGQYPD.js.map +1 -1
  72. package/dist/chunk-WG54EHST.mjs +2 -0
  73. package/dist/chunk-WG54EHST.mjs.map +1 -0
  74. package/dist/chunk-XEXPQFKN.mjs +2 -0
  75. package/dist/chunk-XEXPQFKN.mjs.map +1 -0
  76. package/dist/chunk-YV2C276H.js +2 -0
  77. package/dist/chunk-YV2C276H.js.map +1 -0
  78. package/dist/consent.js.map +1 -1
  79. package/dist/course.d.mts +2 -14
  80. package/dist/course.d.ts +2 -14
  81. package/dist/course.js +1 -1
  82. package/dist/course.js.map +1 -1
  83. package/dist/course.mjs +1 -1
  84. package/dist/course.mjs.map +1 -1
  85. package/dist/embed/analytics.js +1 -1
  86. package/dist/errors.js.map +1 -1
  87. package/dist/index.css +1 -1
  88. package/dist/index.css.map +1 -1
  89. package/dist/index.d.mts +17 -3
  90. package/dist/index.d.ts +17 -3
  91. package/dist/index.js +1 -1
  92. package/dist/index.js.map +1 -1
  93. package/dist/index.mjs +1 -1
  94. package/dist/index.mjs.map +1 -1
  95. package/dist/internal.js.map +1 -1
  96. package/dist/methods-64D5DD6K.js +2 -0
  97. package/dist/methods-64D5DD6K.js.map +1 -0
  98. package/dist/methods-NQA3DFLE.mjs +2 -0
  99. package/dist/methods-NQA3DFLE.mjs.map +1 -0
  100. package/dist/model-files-client-P4PORZJ6.js.map +1 -1
  101. package/dist/models.js.map +1 -1
  102. package/dist/returns.js +1 -1
  103. package/dist/returns.js.map +1 -1
  104. package/dist/returns.mjs +1 -1
  105. package/dist/texts-9kfgClsA.d.mts +14 -0
  106. package/dist/texts-9kfgClsA.d.ts +14 -0
  107. package/dist/{types-D6LsoycW.d.mts → types-B-sjyZQs.d.mts} +7 -1
  108. package/dist/{types-ClFCVzk_.d.ts → types-iRe6ix2y.d.ts} +7 -1
  109. package/dist/viewer3d.js.map +1 -1
  110. package/dist/viewer3d.mjs +1 -1
  111. package/dist/viewer3d.mjs.map +1 -1
  112. package/dist/widgets-BT2LN2Nq.d.mts +547 -0
  113. package/dist/widgets-BVOSj9fU.d.ts +547 -0
  114. package/package.json +16 -2
  115. package/dist/CartProvider-CC6YIZVS.js +0 -2
  116. package/dist/CartProvider-CC6YIZVS.js.map +0 -1
  117. package/dist/CartProvider-ZL65WZN6.mjs +0 -2
  118. package/dist/chunk-2XSLIZ27.js +0 -2
  119. package/dist/chunk-2XSLIZ27.js.map +0 -1
  120. package/dist/chunk-5OCGXVLC.js +0 -2
  121. package/dist/chunk-5OCGXVLC.js.map +0 -1
  122. package/dist/chunk-5YN752OV.mjs +0 -2
  123. package/dist/chunk-5YN752OV.mjs.map +0 -1
  124. package/dist/chunk-7BG22YBF.js +0 -5
  125. package/dist/chunk-7BG22YBF.js.map +0 -1
  126. package/dist/chunk-AHISXVEE.js.map +0 -1
  127. package/dist/chunk-DR7WYI37.js.map +0 -1
  128. package/dist/chunk-EOFJAQPT.js +0 -2
  129. package/dist/chunk-EOFJAQPT.js.map +0 -1
  130. package/dist/chunk-G4SEOVLD.js.map +0 -1
  131. package/dist/chunk-IGQZP4YR.mjs +0 -2
  132. package/dist/chunk-IGQZP4YR.mjs.map +0 -1
  133. package/dist/chunk-N3B25GTY.js.map +0 -1
  134. package/dist/chunk-VWA3ZCNI.mjs +0 -2
  135. package/dist/chunk-VWA3ZCNI.mjs.map +0 -1
  136. package/dist/chunk-YGE2223J.mjs +0 -5
  137. package/dist/chunk-YGE2223J.mjs.map +0 -1
  138. package/dist/chunk-ZM5T4TQW.mjs +0 -2
  139. package/dist/methods-7DWKFCPK.js +0 -2
  140. package/dist/methods-7DWKFCPK.js.map +0 -1
  141. package/dist/methods-DQTADIN4.mjs +0 -2
  142. /package/dist/{CartProvider-ZL65WZN6.mjs.map → BitsnapCart-E72W5RRZ.mjs.map} +0 -0
  143. /package/dist/{methods-DQTADIN4.mjs.map → CartProvider-YPDOFSYC.mjs.map} +0 -0
  144. /package/dist/{chunk-ZKT4N553.mjs.map → chunk-AB37DWOK.mjs.map} +0 -0
  145. /package/dist/{chunk-UTUPPMLK.mjs.map → chunk-MMLBQHBM.mjs.map} +0 -0
  146. /package/dist/{chunk-62WDFH7K.mjs.map → chunk-N523LFAM.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{A as Fc,B as Wc,C as Hc,D as ne,E as q,F as oe,G as Ar,J as $t,K as lt,L as ke,M as Dr,O as ie,P as se,Q as ce,R as Lr,S as qe,T as Ca,U as _r,V as Ur,W as zr,X as Or,Y as Pa,a as Be,b as te,c as ee,d as ae,e as re,f as Pr,g as jo,h as qo,i as Go,j as Fo,k as Wo,l as ui,m as mi,n as wa,o as Kt,p as At,q as Q,r as bi,s as Tr,t as Nr,u as xa,v as Rr,w as Vt,x as ka,y as qc,z as Gc}from"./chunk-YGE2223J.mjs";import{a as gi}from"./chunk-UTUPPMLK.mjs";import{A as ai,B as ri,D as ni,E as oi,F as ii,G as si,H as ci,I as li,J as di,K as pi,a as hr,b as vr,c as yr,e as pt,f as wr,g as xr,h as kr,j as Cr,l as Ho,m as Ko,n as Vo,o as $o,r as Qo,u as Xo,v as Yo,w as Zo,x as Jo,y as ti,z as ei}from"./chunk-ZKT4N553.mjs";import{a as Kc,b as $c,c as Qc}from"./chunk-ZM5T4TQW.mjs";import{f as Vc}from"./chunk-IGQZP4YR.mjs";import{a as Ir,b as Er}from"./chunk-KOVKUJAW.mjs";import{a as Mo,b as Bo}from"./chunk-5YN752OV.mjs";import{a as Ro,b as Ao,c as Do,d as Lo,e as _o,f as Uo,g as zo,h as Oo}from"./chunk-CUPG4B5W.mjs";import{g as ha,i as No,k as ft,l as je,m as Rt,p as va,q as $,r as ya,u as Sr}from"./chunk-VWA3ZCNI.mjs";import{a as d}from"./chunk-5R6AGO3Z.mjs";import{a as br,e as dt,f as To}from"./chunk-62WDFH7K.mjs";import{l as xt,m as kt,n as mt,q as gr}from"./chunk-GKJURMDO.mjs";import{c as fr,e as fa,f as Nt}from"./chunk-OFPRIENJ.mjs";import"./chunk-MDCP5JNP.mjs";import"./chunk-U6FLIRIV.mjs";import Mr from"apple-pay-button";function Ct(){try{return lt()}catch{return}}import{useQuery as Br}from"@tanstack/react-query";import{jsx as Ge}from"react/jsx-runtime";var fi=Mr.default??Mr;function hi({style:t,buttonType:e,colorType:a,items:r,onClick:n}){let{checkIfApplePayIsAvailable:o,getApplePayPaymentRequest:i,completeApplePayPayment:c,setCountry:l,setCouponCodeIfPossible:u,setDeliveryMethod:s,setEmail:f,setPostalCode:v,clearCart:m,getApplePayPreview:g}=ie(),p=kt(),S=q("paymentForCart"),{data:R}=Br({queryKey:["is-apple-pay-available"],queryFn:o}),h=r.map(I=>`${I.id}:${I.quantity}`).join(","),y=ke(),{data:A}=Br({queryKey:["apple-pay-preview",h,y.country??"",y.couponCode??"",y.selectedDeliveryMethod??"",y.postalCode??""],queryFn:()=>g({items:r.map(I=>({productID:I.id,quantity:I.quantity,metadata:I.metadata}))}),enabled:R===!0});if(R!=!0)return null;let k=A!=null&&!Q(A)?A:{countryCode:y.country||"PL",currencyCode:r[0]?.currency??"PLN",totalAmount:`${wa(r.reduce((I,T)=>I+T.price*T.quantity,0)/100,2)}`},E=r.map(I=>({productID:I.id,quantity:I.quantity,metadata:I.metadata}));async function D(){let I=!1,T=b=>{I||(I=!0,p.track("apple_pay_result",{outcome:b}))};p.track("apple_pay_clicked",{}),p.track("payment_method_selected",{gateway:"apple_pay",method:"apple_pay"}),At({event:"initiateCheckout",items:r.map(b=>({id:b.id,name:b.name,price:b.price,quantity:b.quantity,currency:k.currencyCode}))});let P=r.find(b=>b.isDeliverable===!0)!=null,w=new ApplePaySession(14,{countryCode:k.countryCode,merchantCapabilities:["supports3DS"],supportedNetworks:["visa","masterCard"],currencyCode:k.currencyCode,total:{amount:k.totalAmount,label:S,type:"pending"},lineItems:r.map(b=>({amount:`${wa(b.price*b.quantity/100,2)}`,label:b.name,type:"final"})),...P?{shippingMethods:[],supportsCouponCode:!0,requiredBillingContactFields:["name","email","postalAddress","phone"],requiredShippingContactFields:["name","email","postalAddress","phone"]}:{}});await n?.();let U=await i({expectedItems:E});if(Q(U)){console.error("Error creating ApplePaySession:",U.error),T("fail");return}w.oncancel=b=>{console.log("ApplePaySession cancelled",b),T("cancel")},w.onvalidatemerchant=async b=>{try{let C=await Be.get(dt).applePayValidateMerchant({validationUrl:b.validationURL,projectId:lt()});console.log("merchantSession",C.merchantSession),C.merchantSession.length>0?(console.log("completing merchant session"),w.completeMerchantValidation(JSON.parse(C.merchantSession))):w.abort()}catch{w.abort()}},w.onshippingmethodselected=async b=>{console.log("shipping method selected",b),p.track("delivery_method_selected",{method:b.shippingMethod.identifier}),await s(b.shippingMethod.identifier);let C=await i({expectedItems:E});if(console.log("apRequest",C),Q(C))throw w.abort(),new Error("Failed to get Apple Pay payment request");w.completeShippingMethodSelection({newTotal:C.total,newLineItems:C.lineItems,newShippingMethods:C.shippingMethods})},w.onshippingcontactselected=async b=>{try{b.shippingContact.countryCode!=null&&await l(b.shippingContact.countryCode),b.shippingContact.postalCode!=null&&await v(b.shippingContact.postalCode),b.shippingContact.phoneNumber!=null&&await f(b.shippingContact.emailAddress);let C=await i({expectedItems:E});if(Q(C))throw w.abort(),new Error("Failed to get Apple Pay payment request");console.log("apRequest",C),w.completeShippingContactSelection({newLineItems:C.lineItems,newTotal:C.total,newShippingMethods:C.shippingMethods})}catch(C){console.log("shipping contact selected error",C),w.abort()}},w.oncouponcodechanged=async b=>{try{console.log("coupon code changed",b);let C=await u(b.couponCode),X=await i({expectedItems:E});if(console.log("apRequest",X),Q(X))throw w.abort(),new Error("Failed to get Apple Pay payment request");w.completeCouponCodeChange({errors:Q(C)?[new ApplePayError("couponCodeInvalid")]:void 0,newTotal:X.total,newLineItems:X.lineItems,newShippingMethods:X.shippingMethods})}catch(C){console.log("coupon code changed error",C),w.abort()}},w.onpaymentauthorized=async b=>{p.track("payment_submitted",{gateway:"apple_pay",method:"apple_pay"});try{let C=await c({token:b.payment.token,billingContact:b.payment.billingContact,shippingContact:b.payment.shippingContact});if(Q(C)){console.log("apple pay error",C),T("fail"),w.completePayment({status:ApplePaySession.STATUS_FAILURE});return}C.redirectURL&&setTimeout(()=>{open(C.redirectURL,"_self")},2e3),T(C.isSuccess?"success":"fail"),w.completePayment({status:C.isSuccess?ApplePaySession.STATUS_SUCCESS:ApplePaySession.STATUS_FAILURE}),C.isSuccess&&m()}catch{T("fail"),w.completePayment({status:ApplePaySession.STATUS_FAILURE})}},w.begin()}return Ge(fi,{style:t,buttonStyle:a,type:e,onClick:D})}function vi(t){let e=mt(Ct(),t.analytics,"cart");return Ge(xt,{value:e,children:Ge(se,{children:Ge(hi,{...t})})})}var Sa=vi;import{useEffect as Re,useId as Fs,useRef as Ws}from"react";import nt from"zod";import{useAutoAnimate as zs}from"@formkit/auto-animate/react";import*as It from"@radix-ui/react-dialog";import{useCallback as Os,useRef as Ms,useState as Bs}from"react";import{createPortal as js}from"react-dom";import{createContext as Pi,useContext as Si,useMemo as Ii}from"react";var yi=["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"],wi={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"},xi={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)"}},ki=[{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 Ci(t){return{"--popover":t.surface??"var(--color-neutral-800)","--popover-foreground":t.foreground??"var(--color-neutral-200)"}}function Ia(t){let e=Ir(t,{defaultTheme:"dark",presets:xi,variables:wi,shadcnVariables:ki});return{theme:e.theme,isCustomized:e.isCustomized,tokens:e.tokens,elements:e.elements,boundaryClassName:e.theme,boundaryStyle:e.boundaryStyle,dropdownStyle:Ci(e.tokens)}}function jr(t,e){return Er(t.elements,e)}import{jsx as Ei}from"react/jsx-runtime";var qr=Pi(Ia());function le({appearance:t,children:e}){let a=Ii(()=>Ia(t),[t]);return Ei(qr.Provider,{value:a,children:e})}function Ce(){return Si(qr)}function L(t){let e=Ce();return jr(e,t)??{}}import{useAutoAnimate as Ds}from"@formkit/auto-animate/react";import J from"react";import{useEffect as Li,useState as _i}from"react";import*as G from"@radix-ui/react-select";import{CheckIcon as Ti,ChevronDownIcon as Gr,ChevronUpIcon as Ni}from"lucide-react";import{jsx as et,jsxs as Ea}from"react/jsx-runtime";function Fr({...t}){return et(G.Root,{"data-slot":"select",...t})}function Wr({...t}){return et(G.Value,{"data-slot":"select-value",...t})}var Ri="border-input dark:bg-input/30 dark:hover:bg-input/50 bg-transparent";function Hr({className:t,size:e="default",theme:a="default",children:r,...n}){return Ea(G.Trigger,{"data-slot":"select-trigger","data-size":e,className:d("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",a==="bare"?"":Ri,t),...n,children:[r,et(G.Icon,{asChild:!0,children:et(Gr,{className:"size-4 opacity-50"})})]})}function Kr({className:t,children:e,position:a="popper",align:r="center",...n}){return et(G.Portal,{children:Ea(G.Content,{"data-slot":"select-content",className:d("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",a==="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",t),position:a,align:r,...n,children:[et(Ai,{}),et(G.Viewport,{className:d("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),et(Di,{})]})})}function Vr({className:t,children:e,...a}){return Ea(G.Item,{"data-slot":"select-item",className:d("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",t),...a,children:[et("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:et(G.ItemIndicator,{children:et(Ti,{className:"size-4"})})}),et(G.ItemText,{children:e})]})}function Ai({className:t,...e}){return et(G.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:d("flex cursor-default items-center justify-center py-1",t),...e,children:et(Ni,{className:"size-4"})})}function Di({className:t,...e}){return et(G.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:d("flex cursor-default items-center justify-center py-1",t),...e,children:et(Gr,{className:"size-4"})})}import{jsx as Dt,jsxs as Fe}from"react/jsx-runtime";function Ui({id:t,open:e,disabled:a=!1,onToggle:r,onChange:n,selectedValue:o,countries:i}){let[c,l]=_i(""),{isCustomized:u,boundaryClassName:s,boundaryStyle:f,dropdownStyle:v}=Ce(),m=L("countryTrigger"),g=L("countryDropdown"),p=L("countrySearch"),S=L("countryOption"),R=q("searchCountry"),h=q("noCountriesFound");Li(()=>{o==null&&i.length>0&&n(i[0].code)},[]);let y=i.filter(k=>k.name.toLowerCase().startsWith(c.toLowerCase())),A=i.find(k=>k.code===o);return Fe(Fr,{value:o,onValueChange:k=>{n(k),l("")},open:e,onOpenChange:k=>{k!==e&&r(),k||l("")},disabled:a,children:[Dt(Hr,{"data-bitsnap-checkout-slot":"countryTrigger",theme:"bare",className:d(a?"bg-neutral-100 dark:bg-neutral-800 dark:border-neutral-700":"","w-full rounded-md",m.className),style:m.style,children:Dt(Wr,{children:A&&Fe("span",{className:"truncate flex items-center",children:[Dt("img",{alt:o,src:`https://purecatamphetamine.github.io/country-flag-icons/3x2/${o}.svg`,className:"inline mr-2 h-4 rounded-sm"}),A.name]})})}),Fe(Kr,{"data-bitsnap-checkout":u?"dropdown":void 0,"data-bitsnap-checkout-slot":u?"countryDropdown":void 0,className:d(u?"bitsnap-react":"",s,"w-full max-h-80 max-w-[350px] z-[999999]",g.className),style:{...u?{...f,...v}:void 0,...g.style},position:"popper",children:[Dt("div",{"data-bitsnap-checkout-slot":"countrySearch",className:d("sticky top-0 z-10 p-1 border-b",p.className),style:p.style,children:Dt("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:c,onChange:k=>l(k.target.value),onClick:k=>k.stopPropagation(),onKeyDown:k=>k.stopPropagation()})}),Dt("div",{className:"max-h-64 overflow-y-auto",children:y.length===0?Dt("div",{className:"cursor-default select-none relative py-2 pl-3 pr-9 text-sm",children:h}):y.map(k=>Fe(Vr,{"data-bitsnap-checkout-slot":"countryOption",value:k.code,className:d("cursor-default select-none relative py-2 pl-3 pr-9 flex items-center transition",S.className),style:S.style,children:[Dt("img",{alt:k.code,src:`https://purecatamphetamine.github.io/country-flag-icons/3x2/${k.code}.svg`,className:"inline mr-2 h-4 rounded-sm"}),Dt("span",{className:"font-normal truncate",children:k.name})]},`${t}-${k.code}`))})]})]})}var $r=Ui;import{useEffect as qi,useRef as Yr,useState as Jr}from"react";import{MinusIcon as Gi,PlusIcon as Fi}from"lucide-react";import{Slot as Ol}from"@radix-ui/react-slot";import{cva as zi}from"class-variance-authority";import{jsx as Mi}from"react/jsx-runtime";var Oi=zi("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 Qr({className:t,orientation:e,...a}){return Mi("div",{role:"group","data-slot":"button-group","data-orientation":e,className:d(Oi({orientation:e}),t),...a})}import{Fragment as Bi,jsx as We,jsxs as ji}from"react/jsx-runtime";function Xr({price:t,currency:e,pricing:a,quantity:r=1}){let n=q("lowestPrice30Days"),o=q("noPriceHistory"),i=a?.regularPrice??t,c=a?.effectivePrice??t,l=a?.discount?.status==="ACTIVE"&&c<i;return We("span",{children:l?ji(Bi,{children:[We("span",{className:"mr-2 text-neutral-500 line-through",children:Kt(i*r,e)}),We("span",{className:"font-semibold text-red-700",children:Kt(c*r,e)}),We("span",{className:"mt-1 block text-xs text-neutral-600",children:a?.referencePrice.historyAvailable&&a.referencePrice.amount!=null?`${n} ${Kt(a.referencePrice.amount,e)}`:o})]}):Kt(c*r,e)})}function He(t){return Number.isFinite(t)?Math.min(99,Math.max(1,Math.trunc(t))):1}function Ta(t,e){let a=parseInt(t,10);return Number.isNaN(a)?e:He(a)}import{Fragment as Ki,jsx as Z,jsxs as Ke}from"react/jsx-runtime";var Wi=({isNotAvailable:t,quantity:e,details:a,url:r,shouldUpdate:n})=>{let o=L("product"),i=L("productImage"),c=L("productName"),l=L("productPrice"),u=L("removeButton"),s=q("remove"),f=a.image_url??a.images?.[0],[v,m]=Jr(),g=f!=null&&f.length>0&&f!==v,p=a.baseName??a.name;return Ke("div",{"data-bitsnap-checkout-slot":"product","data-bitsnap-checkout-unavailable":t?"":void 0,className:d("flex items-center gap-3 mx-3",t?"outline outline-1 rounded-md m-1":"",o.className),style:o.style,children:[g&&Z(Zr,{url:r,tabIndex:-1,"aria-hidden":"true",className:"contents",children:Z("img",{"data-bitsnap-checkout-slot":"productImage",className:d("aspect-auto max-w-[30%] max-w-32 max-h-32 py-2 overflow-hidden",i.className),style:i.style,src:f,alt:"",onError:()=>m(f)})}),Ke("div",{className:"flex flex-col w-full",children:[Z("p",{"data-bitsnap-checkout-slot":"productName",className:d("font-medium",c.className),style:c.style,children:Z(Zr,{url:r,className:"text-inherit no-underline hover:underline",children:p})}),a.variantName!=null&&a.variantName.length>0&&Z("p",{className:"text-sm opacity-70",children:a.variantName}),Z("p",{"data-bitsnap-checkout-slot":"productPrice",className:d("text-sm",l.className),style:l.style,suppressHydrationWarning:!0,children:Z(Xr,{price:a.price,currency:a.currency,pricing:a.pricing,quantity:e})}),Ke("div",{className:"flex justify-between",children:[Z(Hi,{className:"",quantity:e,shouldUpdate:n}),Z($,{"data-bitsnap-checkout-slot":"removeButton",type:"button",variant:"ghost",size:"sm",className:u.className,style:u.style,"aria-label":`${s}: ${a.name}`,onClick:()=>{Promise.resolve(n(0)).catch(()=>{})},children:s})]})]})]})},tn=Wi,Zr=({url:t,children:e,...a})=>t==null?Z(Ki,{children:e}):Z("a",{href:t,...a,children:e}),Hi=({quantity:t,shouldUpdate:e,className:a})=>{let[r,n]=Jr(t.toString()),o=Yr(t),i=L("quantityControl"),c=L("quantityInput"),l=L("quantityButton"),u=q("quantity"),s=q("increaseQuantity"),f=q("decreaseQuantity"),v=Yr(t);v.current=t,qi(()=>{o.current=t,n(t.toString())},[t]);function m(g){n(g.toString()),g!==o.current&&(o.current=g,Promise.resolve(e(g)).catch(()=>{o.current===g&&(o.current=v.current,n(v.current.toString()))}))}return Z("div",{"data-bitsnap-checkout-slot":"quantityControl",className:d("flex",a,i.className),style:i.style,children:Ke(Qr,{"aria-label":u,children:[Z($,{"data-bitsnap-checkout-slot":"quantityButton",type:"button",className:l.className,style:l.style,"aria-label":f,onClick:()=>m(He(o.current-1)),children:Z(Gi,{"aria-hidden":"true"})}),Z("input",{"data-bitsnap-checkout-slot":"quantityInput",className:d("w-8 bg-transparent text-center",c.className),style:c.style,value:r,"aria-label":u,inputMode:"numeric",pattern:"[0-9]*",onChange:g=>n(g.currentTarget.value),onBlur:g=>m(Ta(g.currentTarget.value,o.current)),onKeyDown:g=>{g.key==="Enter"&&m(Ta(g.currentTarget.value,o.current))},type:"text"}),Z($,{"data-bitsnap-checkout-slot":"quantityButton",type:"button",className:l.className,style:l.style,"aria-label":s,onClick:()=>m(He(o.current+1)),children:Z(Fi,{"aria-hidden":"true"})})]})})};import{jsx as Vi}from"react/jsx-runtime";function Na({className:t,...e}){return Vi("div",{"data-slot":"skeleton",className:"bg-neutral-700 animate-pulse rounded-md "+t,...e})}import{useMutation as Te,useQuery as Ne,useQueryClient as Ls}from"@tanstack/react-query";import en from"react";import{jsx as Ve,jsxs as $e}from"react/jsx-runtime";function an({choice:t,selected:e,onChange:a,disabled:r}){let n=oe(),o=L("paymentMethods"),i=L("paymentMethodOption"),c=en.useId(),l=en.useId(),u=t.manualAccountTypes.length===0||t.manualAccountTypes.includes("blik"),s={online:{title:n("paymentMethodOnline"),description:n("paymentMethodOnlineDescription")},manual:{title:n(Rr(t.manualAccountTypes)),description:n("paymentMethodManualDescription"),note:u?n("paymentMethodManualBlikNote"):void 0},cod:{title:n("paymentMethodCod"),description:n("paymentMethodCodDescription")}};return $e("fieldset",{"data-bitsnap-checkout-slot":"paymentMethods","aria-labelledby":l,className:d("mx-2 mt-4 mb-2 flex min-w-0 flex-col gap-2 border-0 p-0",o.className),style:o.style,disabled:r,children:[Ve("legend",{id:l,className:"mb-1 px-1 text-sm font-medium",children:n("paymentMethodLegend")}),t.methods.map(f=>{let v=s[f],m=f===e,g=`${c}-${f}-description`;return $e("label",{"data-bitsnap-checkout-slot":"paymentMethodOption","data-payment-method":f,"data-selected":m?"":void 0,className:d("flex cursor-pointer items-start gap-3 rounded-md border px-3 py-2.5 transition-colors",i.className),style:i.style,children:[Ve("input",{type:"radio",name:c,value:f,checked:m,onChange:()=>a(f),"aria-describedby":g,className:"mt-0.5 size-4 shrink-0 cursor-pointer"}),$e("span",{className:"flex min-w-0 flex-col gap-0.5",children:[Ve("span",{className:"text-sm font-semibold leading-snug",children:v.title}),$e("span",{id:g,"data-bitsnap-checkout-payment-method-description":"",className:"text-xs leading-snug",children:[v.description,m&&v.note!=null&&Ve("span",{className:"mt-1 block font-medium",children:v.note})]})]})]},f)})]})}import{createElement as Dn,useCallback as me,useEffect as Ee,useMemo as Ln,useRef as be,useState as Cs}from"react";var $i="x-bitsnap-cart-token",rn=new Set;function Ra(t,e,a){rn.has(t)||(rn.add(t),console.warn(e,a))}function Qi(t,e,a){return`${t.replace(/\/+$/,"")}/api/integrations/${encodeURIComponent(e)}/public-commerce/express${a}`}async function Pe(t,e,a,r){let n=t.fetch??((o,i)=>globalThis.fetch(o,i));try{let o=await n(Qi(t.host,t.projectID,e),{method:"POST",headers:{...br,"Content-Type":"application/json",...r!=null?{[$i]:r}:{}},body:JSON.stringify(a),cache:"no-store",signal:t.signal}),i=await o.text().catch(()=>""),c;try{c=i.length>0?JSON.parse(i):void 0}catch{c=void 0}return{status:o.status,json:c,text:i}}catch(o){return{transportError:o}}}function Pt(t){return typeof t=="object"&&t!=null&&!Array.isArray(t)}function nn(t){return Xi(t)?{ok:!1,code:"network",message:"aborted"}:{ok:!1,code:"network",message:"The server could not be reached."}}function Xi(t){return typeof t=="object"&&t!=null&&t.name==="AbortError"}function de(t){return t===404||t===405||t===501||t===502}function Aa(t,e){return typeof t=="string"&&t.length>0?t:e}async function on(t,e){let a=await Pe(t,"/availability",e);if("transportError"in a){Ra(`availability:${t.host}:${t.projectID}`,"Bitsnap express availability is not reachable; express buttons stay hidden.",a.transportError);return}if(de(a.status)||a.status!==200){Ra(`availability-status:${t.host}:${t.projectID}`,"Bitsnap express availability is not available on this backend; express buttons stay hidden.",a.status);return}let r=a.json;if(!Pt(r)||r.success!==!0||!Pt(r.providers)){Ra(`availability-shape:${t.host}:${t.projectID}`,"Bitsnap express availability returned an unknown shape; express buttons stay hidden.",void 0);return}return r}async function sn(t,e,a){let r=await Pe(t,"/cart",{...e,...a!=null?{cartId:a.cartId,expectedRevision:a.expectedRevision}:{}},a?.cartToken);if("transportError"in r)return{ok:!1,code:"internal",message:"The cart could not be saved."};let n=r.json;if(!Pt(n)||typeof n.success!="boolean")return{ok:!1,code:r.status===403?"cart-forbidden":"internal",message:"The cart endpoint returned an unknown answer."};if(n.success===!0){let o=n.snapshot;return o==null||typeof o.revision!="number"?{ok:!1,code:"internal",message:"The cart endpoint returned no snapshot."}:{ok:!0,...typeof n.cartToken=="string"?{cartToken:n.cartToken}:{},snapshot:o}}return{ok:!1,code:Aa(n.code,"internal"),message:typeof n.message=="string"?n.message:"The cart could not be saved.",...typeof n.currentRevision=="number"?{currentRevision:n.currentRevision}:{},...Pt(n.snapshot)?{snapshot:n.snapshot}:{},...Array.isArray(n.conflicts)?{conflicts:n.conflicts}:{}}}function Yi(t){let e=Aa(t.code,"internal");return{code:e,message:Aa(t.message,e)}}async function cn(t,e,a){let r=await Pe(t,"/cart-snapshot",{cartId:e},a);if("transportError"in r)return nn(r.transportError);let n=r.json;return r.status===404?{ok:!1,code:"cart-not-found",message:"cart-not-found",status:404}:r.status===403?{ok:!1,code:"cart-forbidden",message:"cart-forbidden",status:403}:!Pt(n)||n.success!==!0||!Pt(n.snapshot)?{ok:!1,code:de(r.status)?"not-implemented":"invalid-response",message:"The cart snapshot is not available.",status:r.status}:{ok:!0,value:n.snapshot}}async function ln(t,e,a){let n=await Pe(t,e==="inpostPay"?"/inpost/start":e==="revolutPay"?"/revolut/start":"/adyen/start",{cartId:a.cartId,...a.returnUrl!=null?{returnUrl:a.returnUrl}:{},...a.cancelUrl!=null?{cancelUrl:a.cancelUrl}:{},...a.embedOrigin!=null?{embedOrigin:a.embedOrigin}:{}},a.cartToken);if("transportError"in n)return nn(n.transportError);let o=n.json;if(!Pt(o)||typeof o.success!="boolean")return{ok:!1,code:de(n.status)?"not-implemented":"invalid-response",message:"The provider start is not available.",status:n.status};if(o.success===!0)return typeof o.redirectUrl!="string"||typeof o.providerOrderId!="string"?{ok:!1,code:"invalid-response",message:"The provider start returned no redirect.",status:n.status}:{ok:!0,value:{ok:!0,provider:e,redirectUrl:o.redirectUrl,providerOrderId:o.providerOrderId,...Pt(o.publicConfig)?{publicConfig:o.publicConfig}:{},cartRevision:typeof o.cartRevision=="number"?o.cartRevision:0}};let i=o;return{ok:!1,code:de(n.status)?"not-implemented":i.code,message:typeof i.message=="string"?i.message:"The provider start failed.",status:n.status}}function dn(t,e,a){return un(t,"/revolut/status",e,a)}function pn(t,e,a){return un(t,"/inpost/status",e,a)}async function un(t,e,a,r){let n=await Pe(t,e,{cartId:a},r);if("transportError"in n)return{ok:!1,code:"network",message:"The status is not available."};let o=n.json;return n.status===401||n.status===403?{ok:!1,code:"cart-forbidden",message:"cart-forbidden"}:n.status===404?{ok:!1,code:"cart-not-found",message:"cart-not-found"}:!Pt(o)||typeof o.success!="boolean"?{ok:!1,code:de(n.status)?"not-implemented":"provider-error",message:"The status is not available."}:o.success===!0?o.status==="pending"||o.status==="completed"||o.status==="failed"||o.status==="cancelled"?{ok:!0,status:o.status,...typeof o.orderId=="string"?{orderId:o.orderId}:{}}:{ok:!1,code:"provider-error",message:"Unknown status."}:{ok:!1,code:de(n.status)?"not-implemented":"provider-error",message:Pt(o)?Yi(o).message:"The status failed."}}var Zi="bitsnap-express-cart";function mn(t,e=Date.now()){let a=t?.pending;if(a!=null)return e-a.ts<=864e5?a:void 0}function Da(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function La(t,e){return`${Zi}:${encodeURIComponent(t)}:${encodeURIComponent(e)}`}function bn(t){let e=t.storage??Da();if(e==null)return;let a=La(t.host,t.projectID),r;try{let n=e.getItem(a);if(n==null)return;r=JSON.parse(n)}catch{St(t);return}if(!Qe(r)){St(t);return}if(r.projectID!==t.projectID||r.host!==t.host||typeof r.cartId!="string"||r.cartId.length===0||typeof r.cartToken!="string"||r.cartToken.length===0||typeof r.revision!="number"||r.environment!=="test"&&r.environment!=="production"){St(t);return}return{projectID:r.projectID,host:r.host,environment:r.environment,cartId:r.cartId,cartToken:r.cartToken,revision:r.revision,updatedAt:typeof r.updatedAt=="number"?r.updatedAt:0,...Array.isArray(r.syncedLines)?{syncedLines:r.syncedLines.filter(n=>Qe(n)&&typeof n.id=="string"&&typeof n.quantity=="number")}:{},...typeof r.inpostBindingApiKey=="string"?{inpostBindingApiKey:r.inpostBindingApiKey}:{},...Ji(r.pending)?{pending:r.pending}:{}}}function Qt(t,e=Da()){if(e==null)return!1;try{return e.setItem(La(t.host,t.projectID),JSON.stringify(t)),!0}catch{return!1}}function St(t){let e=t.storage??Da();if(e!=null)try{e.removeItem(La(t.host,t.projectID))}catch{}}function Qe(t){return typeof t=="object"&&t!=null&&!Array.isArray(t)}function Ji(t){return!Qe(t)||t.provider!=="inpostPay"&&t.provider!=="revolutPay"||typeof t.ts!="number"||!Array.isArray(t.lines)?!1:t.lines.every(e=>Qe(e)&&typeof e.id=="string"&&typeof e.quantity=="number")}var ts=3,Xe=class{options;running=Promise.resolve();constructor(e){this.options=e}getRecord(){return bn(this.options)}getInpostBindingApiKey(){return this.getRecord()?.inpostBindingApiKey}previewUpload(e){return this.options.local.upload(e)}getPendingAttempt(){return this.getRecord()?.pending}ensure(e){return this.serialize(()=>this.ensureNow(e))}async ensureNow(e){let a=this.getRecord();a!=null&&e.environment!=null&&a.environment!==e.environment&&(St(this.options),a=void 0);let r,n=this.options.maxAttempts??ts;for(let o=0;o<n;o++){let i=this.options.local.upload(e.locale);if(i==null)return{ok:!1,code:"invalid-cart",message:"The cart is empty."};let c=this.options.local.signature(),l=await this.options.write(i,a!=null?{cartId:a.cartId,cartToken:a.cartToken,expectedRevision:a.revision}:void 0);if(l.ok){let u=l.cartToken??a?.cartToken;if(u==null)return{ok:!1,code:"internal",message:"The created cart has no access token."};let s=l.snapshot;if(a={projectID:this.options.projectID,host:this.options.host,environment:s.environment,cartId:s.cartId,cartToken:u,revision:s.revision,updatedAt:(this.options.now??Date.now)(),syncedLines:i.items.map(v=>({id:v.id,quantity:v.quantity})),...a?.inpostBindingApiKey!=null?{inpostBindingApiKey:a.inpostBindingApiKey}:{}},Qt(a,this.options.storage),this.options.local.signature()===c)return{ok:!0,value:{record:a,snapshot:s}};continue}switch(r=l,l.code){case"revision-conflict":{let u=l.snapshot?.revision??l.currentRevision;if(a==null||u==null)return l;let s=as({base:a.syncedLines,local:this.options.local.lines(),server:gn(l.snapshot?.lines)});if(!s.ok)return{...l,currentRevision:u,snapshot:l.snapshot,conflicts:s.conflicts};if(!es(s.lines,this.options.local.lines())){if(this.options.local.replaceLines==null)return{...l,currentRevision:u,snapshot:l.snapshot,conflicts:s.conflicts};this.options.local.replaceLines(s.lines)}a={...a,revision:u},l.snapshot?.environment!=null&&(a.environment=l.snapshot.environment),l.snapshot!=null&&(a.syncedLines=gn(l.snapshot.lines)),Qt(a,this.options.storage);continue}case"cart-locked":{St(this.options),a=void 0;continue}case"cart-not-found":case"cart-forbidden":{St(this.options),a=void 0;continue}case"invalid-request":case"product-not-available":case"currency-unsupported":return l;default:return l}}return r??{ok:!1,code:"internal",message:"The cart could not be saved."}}reconcileFromServer(){return this.serialize(async()=>{let e=this.getRecord();if(e==null)return{ok:!1,code:"cart-not-found",message:"There is no cart to read."};let a=jt(this.options.local.lines()),r=await this.options.read(e.cartId,e.cartToken);if(!r.ok)return(r.code==="cart-not-found"||r.code==="cart-forbidden")&&St(this.options),r;let n=r.value,o=jt(this.options.local.lines()),i=jt(e.syncedLines??[]),c=e.syncedLines!=null?i:a;this.options.local.adoptSnapshot(n);let l=rs(o,c);l.length>0&&this.options.local.appendLines(l);let u=this.getRecord();if(u!=null&&u.cartId===n.cartId&&Qt({...u,revision:n.revision,environment:n.environment,updatedAt:(this.options.now??Date.now)()},this.options.storage),l.length>0){let s=await this.ensureNow({locale:n.locale,environment:n.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:n}})}async start(e,a){let r=await this.ensure({locale:a.locale,...a.environment!=null?{environment:a.environment}:{}});if(!r.ok)return r;let{record:n,snapshot:o}=r.value,i=await a.start({cartId:n.cartId,cartToken:n.cartToken,...a.returnUrl!=null?{returnUrl:a.returnUrl}:{},...a.cancelUrl!=null?{cancelUrl:a.cancelUrl}:{},...a.embedOrigin!=null?{embedOrigin:a.embedOrigin}:{}});if(!i.ok)return(i.code==="cart-locked"||i.code==="cart-not-found"||i.code==="cart-forbidden")&&St(this.options),i;let c=this.getRecord();return c!=null&&c.cartId===n.cartId&&Qt({...c,revision:Math.max(c.revision,i.value.cartRevision),updatedAt:(this.options.now??Date.now)(),...i.value.publicConfig?.basketBindingApiKey!=null?{inpostBindingApiKey:i.value.publicConfig.basketBindingApiKey}:{},pending:{provider:e,...i.value.providerOrderId.length>0?{providerOrderId:i.value.providerOrderId}:{},lines:o.lines.map(l=>({id:l.productId,quantity:l.quantity})),ts:(this.options.now??Date.now)()}},this.options.storage),{ok:!0,value:{start:i.value,snapshot:o}}}storeInpostBindingApiKey(e){let a=this.getRecord();a==null||e.length===0||Qt({...a,inpostBindingApiKey:e,updatedAt:(this.options.now??Date.now)()},this.options.storage)}completePurchase(e){let a=this.getRecord(),r=e??a?.pending?.lines??[];r.length>0&&this.options.local.removeLines(r),St(this.options)}keepCart(){}clearPending(){let e=this.getRecord();if(e==null||e.pending==null)return;let{pending:a,...r}=e;Qt(r,this.options.storage)}status(e){let a=this.getRecord();return a==null?Promise.resolve({ok:!1,code:"cart-not-found",message:"There is no cart to check."}):e(a.cartId,a.cartToken)}serialize(e){let a=this.running.then(e,e);return this.running=a.then(()=>{},()=>{}),a}};function jt(t){let e=new Map;for(let a of t)e.set(a.id,(e.get(a.id)??0)+a.quantity);return e}function gn(t){return(t??[]).map(e=>({id:e.productId,quantity:e.quantity}))}function es(t,e){let a=jt(t),r=jt(e);if(a.size!==r.size)return!1;for(let[n,o]of a)if(r.get(n)!==o)return!1;return!0}function as(t){if(t.base==null||t.server==null)return{ok:!1,lines:t.local,conflicts:[]};let e=jt(t.base),a=jt(t.local),r=jt(t.server),n=new Set([...e.keys(),...a.keys(),...r.keys()]),o=[],i=[];for(let c of n){let l=e.get(c)??0,u=a.get(c)??0,s=r.get(c)??0,f=u!==l,v=s!==l,m;f?(v&&(u===s||i.push({id:c,base:l,local:u,server:s})),m=u):m=s,m>0&&!i.some(g=>g.id===c)&&o.push({id:c,quantity:m})}return{ok:i.length===0,lines:o,conflicts:i}}function rs(t,e){let a=[];for(let[r,n]of t){let o=n-(e.get(r)??0);o>0&&a.push({id:r,quantity:o})}return a}var _a=new Map,ns=5*60*1e3;function fn(t,e,a){let r=ke();return[t,e,a.items.map(n=>`${n.id}:${n.quantity}`).sort().join(","),(a.countries??[]).slice().sort().join(","),a.couponCode??"",a.deliveryMethod??"",r.postalCode??""].join("|")}function pe(t,e,a){let r=fn(t,e,a),n=_a.get(r);if(n!=null){if(Date.now()-n.at>ns){_a.delete(r);return}return n.quote}}function os(t,e,a,r){_a.set(fn(t,e,a),{quote:r,at:Date.now()})}function Xt(t,e){return e==null||e.delivery.length===0?t:{...t,delivery:t.delivery!=null&&t.delivery.length>0?t.delivery:e.delivery,...t.deliveryMethod==null&&e.deliveryMethod!=null?{deliveryMethod:e.deliveryMethod}:{}}}async function is(t){if(t.upload.items.length===0)return{delivery:[]};let e=ke();try{let a=await Be.get(t.host).getPreOrderDetails({projectId:t.projectID,items:t.upload.items.map(i=>({id:i.id,quantity:i.quantity})),...t.upload.countries?.[0]!=null?{countryCode:t.upload.countries[0]}:{},...t.upload.couponCode!=null?{couponCode:t.upload.couponCode}:{},...t.upload.deliveryMethod!=null?{selectedDeliveryMethod:t.upload.deliveryMethod}:e.selectedDeliveryMethod!=null?{selectedDeliveryMethod:e.selectedDeliveryMethod}:{},...e.postalCode!=null?{postCode:e.postalCode}:{}}),r=a.methods.map(i=>({name:i.id,...i.description!=null?{desc:i.description}:{},min:i.minDays??1,max:i.maxDays??14,price:i.amount/100})),n=a.selectedDeliveryMethod??r[0]?.name??void 0,o={delivery:r,...n!=null?{deliveryMethod:n}:{}};return os(t.host,t.projectID,t.upload,o),o}catch(a){console.warn("cannot resolve the express delivery quote",a);return}}async function Ye(t){if(t.upload.delivery!=null&&t.upload.delivery.length>0)return{ok:!0,upload:t.upload,quote:{delivery:t.upload.delivery,...t.upload.deliveryMethod!=null?{deliveryMethod:t.upload.deliveryMethod}:{}}};let e=pe(t.host,t.projectID,t.upload);if(e!=null)return{ok:!0,upload:Xt(t.upload,e),quote:e};let a=await is(t);return a==null?{ok:!1,message:"The delivery quote for this cart is not available. Use the regular checkout."}:{ok:!0,upload:Xt(t.upload,a),quote:a}}function Ua(t){return{lines:()=>ce().map(e=>({id:e.productID,quantity:e.quantity})),signature:Lr,upload:e=>{let a=qe(e);if(a!=null)return Xt(a,pe(t.host,t.projectID,a))},adoptSnapshot:e=>{Ca(e.lines.map(a=>({productId:a.productId,quantity:a.quantity})))},appendLines:Ur,removeLines:_r,replaceLines:e=>{Ca(e.map(a=>({productId:a.id,quantity:a.quantity})))}}}function Yt(t){let e=t.host??dt,a={projectID:t.projectID,host:e,...t.fetch!=null?{fetch:t.fetch}:{},...t.signal!=null?{signal:t.signal}:{}};return new Xe({projectID:t.projectID,host:e,local:t.local??Ua({host:e,projectID:t.projectID}),...t.storage!=null?{storage:t.storage}:{},...t.now!=null?{now:t.now}:{},write:(r,n)=>sn(a,r,n),read:(r,n)=>cn(a,r,n)})}async function Ze(t,e,a=Yt(t)){let r=t.host??dt,n=a.previewUpload(t.locale);if(n!=null){let o=await Ye({host:r,projectID:t.projectID,upload:n});if(!o.ok)return{ok:!1,code:"invalid-cart",message:o.message}}return a.start(e,{locale:t.locale,...t.environment!=null?{environment:t.environment}:{},...t.returnUrl!=null?{returnUrl:t.returnUrl}:{},...t.cancelUrl!=null?{cancelUrl:t.cancelUrl}:{},...t.embedOrigin!=null?{embedOrigin:t.embedOrigin}:{},start:o=>ln({projectID:t.projectID,host:r,...t.fetch!=null?{fetch:t.fetch}:{},...t.signal!=null?{signal:t.signal}:{}},e,o)})}function hn(t,e){return yn(t,"revolutPay",e)}function vn(t,e){return yn(t,"inpostPay",e)}function yn(t,e,a){let r=t.host??dt;return(a??Yt(t)).status((o,i)=>(e==="inpostPay"?pn:dn)({projectID:t.projectID,host:r,...t.fetch!=null?{fetch:t.fetch}:{},...t.signal!=null?{signal:t.signal}:{}},o,i))}function wn(){return typeof window>"u"?void 0:window}var Oa="inpost-izi-button",Ma="inpost-thank-you";function Cn(t){return t!=null&&/^pl\b/i.test(t)?"pl":"en"}var ss="https://sandbox-inpostpay-widget-api.inpost.pl",cs="https://inpostpay-widget-api.inpost.pl",xn={test:"https://sandbox-inpostpay-widget-v2.inpost.pl/inpostpay.widget.v2.js",production:"https://inpostpay-widget-v2.inpost.pl/inpostpay.widget.v2.js"},kn={test:ss,production:cs};function ls(t,e){return t==="test"||t==="production"?t:t==="prod"||t==="live"?"production":e??"production"}function Je(t){return t.includes("sandbox")}function Pn(t,e){if(t==null)return;let a=t.merchantClientId;if(a==null||a.length===0)return;let r=e??ls(t.environment,void 0),n=t.widgetApiBaseUrl??t.apiBaseUrl,o=t.widgetScriptUrl,i=r==="test"?n!=null&&Je(n)?n:kn.test:n!=null&&!Je(n)?n:kn.production,c=r==="test"?o!=null&&Je(o)?o:xn.test:o!=null&&!Je(o)?o:xn.production;return{merchantClientId:a,environment:r,apiBaseUrl:i,scriptUrl:c,...t.basketBindingApiKey!=null&&t.basketBindingApiKey.length>0?{basketBindingApiKey:t.basketBindingApiKey}:{},...t.basketId!=null&&t.basketId.length>0?{basketId:t.basketId}:{}}}var za;function Sn(){if(typeof window>"u")return Promise.reject(new Error("InPost Pay needs a browser."));let t=wn()?.InPostPayWidget;return t!=null?Promise.resolve(t):(za??=import("@inpost-pay/widget").then(e=>{let a=e,r=typeof a.initialiseInpostPayWidget=="function"?a.initialiseInpostPayWidget:typeof a.default=="function"?a.default:typeof a.default?.initialiseInpostPayWidget=="function"?a.default.initialiseInpostPayWidget:void 0,n=wn()?.InPostPayWidget;if(n!=null)return n;if(r!=null)return{init:r};throw new Error("The InPost Pay widget exposed no init function.")}).catch(e=>{throw za=void 0,e}),za)}function In(t){if(typeof window>"u")return;let e=window,a=e.__bitsnapInpostOwner,r=e.__INPOST_PAY_WIDGET__;if(r!=null){if(a!=null&&a.projectID===t.owner.projectID&&a.host===t.owner.host&&a.merchantClientId===t.owner.merchantClientId)return r.refresh(t.options),r;if(ds()){t.warn?.("InPost Pay already runs for another project on this page; mount one InPost Pay button per page.");return}delete e.__INPOST_PAY_WIDGET__,delete e.__bitsnapInpostOwner}let n=t.namespace.init(t.options);return e.__INPOST_PAY_WIDGET__=n,e.__bitsnapInpostOwner=t.owner,n}function ds(){return typeof document>"u"?!1:document.querySelector(`${Oa}, ${Ma}`)!=null}function En(t){return{binding_place:t.bindingPlace,...t.productId!=null?{"data-product-id":t.productId}:{},...t.variation!=null?{variation:t.variation}:{}}}import{useEffect as ps,useMemo as Nd,useRef as us,useState as ms,useSyncExternalStore as bs}from"react";function ue(t){let e=Math.max(1,Math.trunc(t.quantity??1)),a={...t.country!=null?{country:t.country}:{},...t.couponCode!=null?{couponCode:t.couponCode}:{},productQuantity:e};if(t.items!=null&&t.items.length>0)return{...a,items:t.items.map(n=>({id:n.id,quantity:Math.max(1,Math.trunc(n.quantity))})),source:"items"};let r=ce().map(n=>({id:n.productID,quantity:n.quantity}));if(t.productId!=null&&t.productId.length>0){let n=r.some(o=>o.id===t.productId);return{...a,items:n?r:[...r,{id:t.productId,quantity:e}],source:"product",productId:t.productId}}return{...a,items:r,source:"cart"}}function ta(t){let e=t.items.map(a=>`${a.id}:${a.quantity}`).sort().join(",");return[t.source,e,t.country??"",t.couponCode??"",t.productId??""].join("|")}function ea(t,e,a){if(t.source==="cart")return Ua(a);let r={items:t.items.map(n=>({id:n.id,quantity:n.quantity})),...t.country!=null?{countries:[t.country]}:{},...t.couponCode!=null?{couponCode:t.couponCode}:{},locale:e};return{lines:()=>t.items,signature:()=>ta(t),upload:()=>Xt(r,pe(a.host,a.projectID,r)),adoptSnapshot:()=>{},appendLines:()=>{},removeLines:()=>{}}}function Se(){return bs(zr,Or,()=>0)}function aa(t){let e=us(t);e.current=t;let a=ue(t),r=ta(a),n=Se(),[o,i]=ms({loading:!1,provider:void 0,environment:void 0,failed:!1});return ps(()=>{let c=e.current;if(c.enabled===!1||c.projectID==null||c.projectID.length===0||typeof window>"u"){i({loading:!1,provider:void 0,environment:void 0,failed:!1});return}let l=ue(c);if(l.items.length===0){i({loading:!1,provider:void 0,environment:void 0,failed:!1});return}let u=new AbortController,s=!0;return i(f=>({...f,loading:!0})),fs({projectID:c.projectID,...c.host!=null?{host:c.host}:{},locale:c.locale,cart:l,...c.fetch!=null?{fetch:c.fetch}:{},signal:u.signal}).then(f=>{if(!s)return;let v=f?.providers?.[c.provider];i({loading:!1,provider:v,environment:f?.environment??v?.environment,failed:f==null})}).catch(()=>{s&&i({loading:!1,provider:void 0,environment:void 0,failed:!0})}),()=>{s=!1,u.abort()}},[r,n,t.projectID,t.host,t.provider,t.locale,t.enabled]),o}function ra(t){return t??dt}function gs(t,e,a){let r=t.source==="cart"?qe(e):t.items.length===0?void 0:{items:t.items.map(n=>({id:n.id,quantity:n.quantity})),...t.country!=null?{countries:[t.country]}:{},...t.couponCode!=null?{couponCode:t.couponCode}:{},locale:e};if(r!=null)return a?.host==null||a.projectID==null?r:Xt(r,pe(a.host,a.projectID,r))}async function fs(t){let e=t.host??dt,a=gs(t.cart,t.locale);if(a==null)return;let r=await Ye({host:e,projectID:t.projectID,upload:a});if(!r.ok)return;let n=await on({projectID:t.projectID,host:e,...t.fetch!=null?{fetch:t.fetch}:{},...t.signal!=null?{signal:t.signal}:{}},r.upload);if(n==null)return;if(r.quote.delivery.length===0)return n;let o=n.providers.revolutPay;return o==null||o.available!==!0?n:{...n,providers:{...n.providers,revolutPay:{...o,available:!1,reasons:[...o.reasons,"delivery-unsupported"]}}}}function Tn(t){if(t==null)return;let e=t.publicKey??t.publicToken,a=t.mode;if(!(e==null||e.length===0)&&!(a!=="sandbox"&&a!=="prod"))return{publicKey:e,mode:a,...t.orderToken!=null&&t.orderToken.length>0?{orderToken:t.orderToken}:{}}}function Nn(t){let e=t.publicConfig?.orderToken;return e!=null&&e.length>0?e:t.providerOrderId}function Rn(t){return t!=null&&/^pl\b/i.test(t)?"pl":"en"}var hs=6e4,vs=2e3;function ys(t){return new Promise(e=>setTimeout(e,t))}async function Ba(t){let e=t.timeoutMs??hs,a=t.intervalMs??vs,r=t.sleep??ys,n=(t.now??Date.now)(),o=Math.min(1e4,Math.max(1,Math.ceil(e/Math.max(1,a))+1)),i=0,c;for(;;){if(i+=1,t.signal?.aborted===!0)return c;try{c=await t.check()}catch{c=void 0}if(c?.ok===!0&&c.status!=="pending"||c?.ok===!1&&c.code==="not-implemented"||i>=o||(t.now??Date.now)()-n>=e)return c;await r(a)}}var An=Ba;import{jsx as ks}from"react/jsx-runtime";var ws={pending:"expressPending",confirmed:"expressConfirmed",failed:"expressFailed",cancelled:"expressCancelled","load-failed":"expressLoadFailed","cart-unavailable":"expressCartUnavailable","cart-conflict":"expressCartConflict","price-changed":"expressPriceChanged","product-unavailable":"expressProductUnavailable"},xs=["failed","cancelled","load-failed","cart-unavailable","cart-conflict","price-changed","product-unavailable"];function Ie({phase:t}){let e=oe(),a=L("error");if(t==="idle")return null;let r=xs.includes(t);return ks("p",{role:r?"alert":"status","aria-live":r?"assertive":"polite","data-bitsnap-express-status":t,className:d("w-full px-2 text-center text-sm",r&&"opacity-90",a.className),style:a.style,children:e(ws[t])})}import{jsx as ge,jsxs as Is}from"react/jsx-runtime";function _n(t){return typeof t=="object"&&t!=null&&t.undeliverable===!0}function ja(t){let{projectID:e}=t,a=ra(t.host),r=t.locale??Nt(),n=kt(),o=t.confirmation?.timeoutMs,i=t.confirmation?.intervalMs,c=t.confirmation?.sleep,l=t.confirmation?.now,u=Se(),s=Ln(()=>ue({...t.items!=null?{items:t.items}:{},...t.productId!=null?{productId:t.productId}:{},...t.quantity!=null?{quantity:t.quantity}:{}}),[t.items,t.productId,t.quantity,u]),f=ta(s),v=aa({provider:"inpostPay",projectID:e,host:a,locale:r,...t.items!=null?{items:t.items}:{},...t.productId!=null?{productId:t.productId}:{},...t.quantity!=null?{quantity:t.quantity}:{},...t.fetch!=null?{fetch:t.fetch}:{}}),m=v.provider,g=m?.environment??v.environment,p=m?.available===!0?Pn(m.publicConfig,g):void 0,S=p?.merchantClientId,R=p?.apiBaseUrl,h=Ln(()=>Yt({projectID:e,host:a,...s.source==="items"?{local:ea(s,r,{host:a,projectID:e})}:{},...t.fetch!=null?{fetch:t.fetch}:{}}),[e,a,t.fetch,s,r]),[y,A]=Cs("idle"),k=be(void 0),E=be(void 0),D=be(!0),I=be(!1),T=be(!1);Ee(()=>(D.current=!0,()=>{D.current=!1}),[]);let P=be({cart:s,locale:r,environment:g,session:h,onOrderCreated:t.onOrderCreated,onBasketChanged:t.onBasketChanged});P.current={cart:s,locale:r,environment:g,session:h,onOrderCreated:t.onOrderCreated,onBasketChanged:t.onBasketChanged};let w=me(async()=>{if(E.current!=null)return E.current;let O=Ze({projectID:e,host:a,locale:P.current.locale,...P.current.environment!=null?{environment:P.current.environment}:{},...typeof window<"u"?{returnUrl:window.location.href,cancelUrl:window.location.href,embedOrigin:window.location.origin}:{},...t.fetch!=null?{fetch:t.fetch}:{}},"inpostPay",P.current.session).then(z=>{if(!z.ok)throw A(z.code==="revision-conflict"?"cart-conflict":"cart-unavailable"),new Error(`inpost-start-${z.code}`);return n.track("payment_submitted",{gateway:"inpost_pay",method:"inpost_pay"}),z.value.start}).finally(()=>{E.current=void 0});return E.current=O,O},[e,a,n,t.fetch]),U=me(async O=>{if(ce().some(_=>_.productID===O)||P.current.cart.source==="items")return;if(await ka.addProductToCart(O,P.current.cart.productQuantity)!=null)throw{undeliverable:!0}},[]),b=me(async O=>{n.track("payment_method_selected",{gateway:"inpost_pay",method:"inpost_pay"});try{O!=null&&await U(O);let N=(await w()).publicConfig?.basketBindingApiKey;if(N==null||N.length===0)throw new Error("inpost-start-without-basket-key");return P.current.session.storeInpostBindingApiKey(N),A("idle"),N}catch(z){throw _n(z)?(A("product-unavailable"),new Error("UNDELIVERABLE_PRODUCT")):(A(z instanceof Error&&z.message==="inpost-start-revision-conflict"?"cart-conflict":"cart-unavailable"),z instanceof Error?z:new Error("inpost-pay-failed"))}},[U,n,w]),C=me(async O=>{let z=O??P.current.cart.productId;if(z!=null)try{if(await ka.addProductToCart(z,P.current.cart.productQuantity)!=null)throw{undeliverable:!0};await P.current.session.ensure({locale:P.current.locale,...P.current.environment!=null?{environment:P.current.environment}:{}})}catch(N){throw A("product-unavailable"),_n(N)?new Error("UNDELIVERABLE_PRODUCT"):N instanceof Error?N:new Error("inpost-pay-failed")}},[]),X=me(async()=>{if(!I.current){I.current=!0;try{let O=P.current.session,z=O.getPendingAttempt();if(z?.provider!=="inpostPay")return;D.current&&A("pending");let N=await Ba({check:()=>vn({projectID:e,host:a,...t.fetch!=null?{fetch:t.fetch}:{}},O),timeoutMs:o??2e4,intervalMs:i??1500,...c!=null?{sleep:c}:{},...l!=null?{now:l}:{}});if(!D.current)return;let _=z.providerOrderId;if(N?.ok===!0&&N.status==="completed"){let W=await O.reconcileFromServer(),F=W.ok?W.value.lines.map(V=>({id:V.productId,quantity:V.quantity})):z.lines;F.length>0&&O.completePurchase(F),A("confirmed"),n.track("payment_returned",{gateway:"inpost_pay",method:"inpost_pay",outcome:"pending"}),T.current||(T.current=!0,P.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"completed"}));return}if(N?.ok===!0&&N.status==="failed"){O.clearPending(),A("failed"),T.current||(T.current=!0,P.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"failed"}));return}if(N?.ok===!0&&N.status==="cancelled"){O.clearPending(),A("cancelled"),T.current||(T.current=!0,P.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"cancelled"}));return}A("pending"),T.current||(T.current=!0,P.current.onOrderCreated?.({..._!=null?{providerOrderId:_}:{},status:"pending"}))}finally{I.current=!1}}},[i,l,c,o,a,n,e,t.fetch]),yt=me(async O=>{if(O==="basketProductChanged"){let z=await P.current.session.reconcileFromServer();return z.ok&&P.current.onBasketChanged?.(z.value),!0}return O==="orderCreated"&&X(),!0},[X]);if(Ee(()=>{m?.available===!0&&h.getPendingAttempt()?.provider==="inpostPay"&&X()},[m?.available,h,X]),Ee(()=>{if(m?.available!==!0||S==null||S.length===0||typeof window>"u")return;let O=!1;return Sn().then(z=>{if(O)return;let N=In({namespace:z,owner:{projectID:e,host:a,merchantClientId:S},options:{merchantClientId:S,basketBindingApiKey:h.getInpostBindingApiKey(),unboundWidgetClicked:b,...s.source==="product"||t.productId!=null?{addToBasketClicked:C}:{},handleBasketEvent:yt,...R!=null?{apiBaseUrl:R}:{},language:Cn(r)}});if(N==null){A("cart-unavailable");return}k.current=N,N.rerender()}).catch(()=>{O||A("load-failed")}),()=>{O=!0,k.current=void 0}},[m?.available,S,R,r,e,a,h,b,C,yt,s.source,t.productId]),Ee(()=>{k.current?.refresh({basketBindingApiKey:h.getInpostBindingApiKey()})},[f,h]),m?.available!==!0||S==null||S.length===0)return ge(Ie,{phase:y==="idle"?"idle":y});let Ot=t.bindingPlace??(t.productId!=null?"PRODUCT_CARD":"BASKET_SUMMARY");return Is("div",{"data-bitsnap-express":"inpostPay","aria-busy":y==="pending"?!0:void 0,className:t.className,style:t.style,children:[Ot==="THANK_YOU_PAGE"?Dn(Ma,{...t.variation!=null?{variation:t.variation}:{}}):Dn(Oa,En({bindingPlace:Ot,...t.productId!=null?{productId:t.productId}:{},...t.variation!=null?{variation:t.variation}:{}})),ge(Ie,{phase:y})]})}function Ps(t){let e=t.projectID??Ct(),a=mt(e,t.analytics,"cart");return Ee(()=>{t.projectID!=null&&$t(t.projectID)},[t.projectID]),ge(xt,{value:a,children:ge(ne,{locale:t.locale,texts:t.texts,children:ge(le,{appearance:t.appearance,children:e==null?null:ge(ja,{...t,projectID:e})})})})}var Ss=Ps;import{useEffect as Ha,useMemo as Ts,useRef as oa,useState as qn}from"react";var Es={prod:"https://merchant.revolut.com/embed.js",sandbox:"https://sandbox-merchant.revolut.com/embed.js"},Un={prod:"revolut-checkout",sandbox:"revolut-checkout-sandbox"},qa=new Map;function zn(t,e={}){if(typeof window>"u")return Promise.reject(new Error("Revolut Checkout needs a browser."));let a=window.RevolutCheckout;if(a!=null)return Promise.resolve(a);let r=qa.get(t);if(r!=null)return r;let n=e.document??document,o=e.timeoutMs??15e3,i=new Promise((c,l)=>{let u=!1,s=n.getElementById(Un[t]),f,v=()=>{f!=null&&clearTimeout(f),s?.removeEventListener("load",g),s?.removeEventListener("error",p)},m=S=>{u||(u=!0,v(),S())},g=()=>{m(()=>{let S=window.RevolutCheckout;S!=null?c(S):l(new Error("Revolut Checkout did not initialise."))})},p=()=>{m(()=>l(new Error("Revolut Checkout could not be loaded.")))};s==null?(s=n.createElement("script"),s.id=Un[t],s.src=Es[t],s.async=!0,s.addEventListener("load",g),s.addEventListener("error",p),n.head.appendChild(s)):(s.addEventListener("load",g),s.addEventListener("error",p)),f=setTimeout(()=>{m(()=>l(new Error("Revolut Checkout timed out while loading.")))},o)});return qa.set(t,i),i.catch(()=>qa.delete(t)),i}function On(t,e){return t.payments({publicToken:e.publicKey,mode:e.mode,locale:e.locale})}var Ga="bitsnap_express",Fa="bitsnap_express_cart",Wa="bitsnap_express_result",Mn="_rp_oid";function Bn(t){let e;try{e=new URLSearchParams(t.startsWith("?")?t:`?${t}`)}catch{return{returned:!1}}let a=e.get(Ga),r=e.get(Mn)??void 0,n=e.get(Fa)??void 0,o=e.get(Wa),i=o==="success"||o==="failure"||o==="cancel"?o:void 0,c=a==="inpostPay"||a==="revolutPay";return{returned:c||r!=null,...c?{provider:a}:{},...n!=null?{cartId:n}:{},...r!=null?{orderToken:r}:{},...i!=null?{result:i}:{}}}function na(t,e){let a=typeof window<"u"?window.location.href:"https://localhost/",r=new URL(t,a);return r.searchParams.set(Ga,e.provider),r.searchParams.set(Fa,e.cartId),r.searchParams.set(Wa,e.result),r.toString()}function jn(t){let e=typeof window<"u"?window.location.href:"https://localhost/",a=new URL(t,e);return a.searchParams.delete(Ga),a.searchParams.delete(Fa),a.searchParams.delete(Wa),a.searchParams.delete(Mn),a.pathname+a.search+a.hash}import{jsx as fe,jsxs as As}from"react/jsx-runtime";function Ka(t){let{projectID:e}=t,a=ra(t.host),r=t.locale??Nt(),n=kt(),o=t.confirmation?.timeoutMs,i=t.confirmation?.intervalMs,c=t.confirmation?.sleep,l=t.confirmation?.now,u=JSON.stringify(t.buttonStyle??null),s=Se(),f=Ts(()=>ue({...t.items!=null?{items:t.items}:{},...t.productId!=null?{productId:t.productId}:{},...t.quantity!=null?{quantity:t.quantity}:{},...t.country!=null?{country:t.country}:{},...t.couponCode!=null?{couponCode:t.couponCode}:{}}),[t.items,t.productId,t.quantity,t.country,t.couponCode,s]),v=[f.source,f.items.map(I=>`${I.id}:${I.quantity}`).sort().join(",")].join("|"),m=aa({provider:"revolutPay",projectID:e,host:a,locale:r,...t.items!=null?{items:t.items}:{},...t.productId!=null?{productId:t.productId}:{},...t.quantity!=null?{quantity:t.quantity}:{},...t.country!=null?{country:t.country}:{},...t.couponCode!=null?{couponCode:t.couponCode}:{},...t.fetch!=null?{fetch:t.fetch}:{}}),g=m.provider?.available===!0?Tn(m.provider.publicConfig):void 0,p=m.provider?.environment??m.environment,S=oa(null),[R,h]=qn("idle"),[y,A]=qn(0),k=oa(!0),E=oa(void 0),D=oa(void 0);return Ha(()=>(k.current=!0,()=>{k.current=!1}),[]),Ha(()=>{if(g==null||typeof window>"u"||S.current==null)return;let I=new AbortController,T=!1,P,w=ea(f,r,{host:a,projectID:e}),U=Yt({projectID:e,host:a,local:w,...t.fetch!=null?{fetch:t.fetch}:{},signal:I.signal}),b=t.returnUrl??window.location.href,C=!1,X=!1,yt=async N=>{if(!k.current||X)return;h("pending");let _=await An({check:()=>hn({projectID:e,host:a,...t.fetch!=null?{fetch:t.fetch}:{},signal:I.signal},N),signal:I.signal,...o!=null?{timeoutMs:o}:{},...i!=null?{intervalMs:i}:{},...c!=null?{sleep:c}:{},...l!=null?{now:l}:{}});if(!(T||!k.current)){if(_?.ok===!0&&_.status==="completed"){X=!0,N.completePurchase(),h("confirmed"),t.onPaymentResult?.({status:"completed",..._.orderId!=null?{orderId:_.orderId}:{}});return}if(_?.ok===!0&&_.status==="failed"){X=!0,N.clearPending(),h("failed"),t.onPaymentResult?.({status:"failed"});return}if(_?.ok===!0&&_.status==="cancelled"){X=!0,N.clearPending(),h("cancelled"),t.onPaymentResult?.({status:"cancelled"});return}h("pending"),t.onPaymentResult?.({status:"pending"})}},Ot=N=>{C||(C=!0,yt(N).finally(()=>{C=!1}))},O=N=>{if(N.type==="cancel"){n.track("payment_returned",{gateway:"revolut_pay",method:"revolut_pay",outcome:"cancel"}),U.clearPending(),h("cancelled"),t.onPaymentResult?.({status:"cancelled"});return}if(N.type==="error"){n.track("payment_returned",{gateway:"revolut_pay",method:"revolut_pay",outcome:"fail"}),U.clearPending();let _=D.current;D.current=void 0,h(_??"failed"),_==null&&t.onPaymentResult?.({status:"failed"});return}n.track("payment_returned",{gateway:"revolut_pay",method:"revolut_pay",outcome:"pending"}),Ot(U)};return(async()=>{let N=await U.ensure({locale:r,...p!=null?{environment:p}:{}});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 zn(g.mode);if(T)return;let F=await On(W,{publicKey:g.publicKey,mode:g.mode,locale:Rn(r)});if(T){F.destroy?.();return}let{revolutPay:V}=F,Wt,ua=async()=>(Wt!=null||(Wt=(async()=>{let Y=await U.ensure({locale:r,...p!=null?{environment:p}:{}});if(!Y.ok)throw D.current=Y.code==="revision-conflict"?"cart-conflict":"cart-unavailable",new Error(`revolut-cart-${Y.code}`);if(!Gn(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(ye=>ye+1),new Error("revolut-amount-changed");let rt=await Ze({projectID:e,host:a,locale:r,...p!=null?{environment:p}:{},returnUrl:b,cancelUrl:t.cancelUrl??b,embedOrigin:window.location.origin,...t.fetch!=null?{fetch:t.fetch}:{}},"revolutPay",U);if(!rt.ok)throw D.current=rt.code==="revision-conflict"?"cart-conflict":"cart-unavailable",new Error(`revolut-start-${rt.code}`);if(!Gn(rt.value.snapshot,E.current))throw E.current={cartId:rt.value.snapshot.cartId,currency:rt.value.snapshot.currency,totalMinor:rt.value.snapshot.totalMinor},D.current="price-changed",h("price-changed"),A(ye=>ye+1),new Error("revolut-amount-changed");return n.track("payment_submitted",{gateway:"revolut_pay",method:"revolut_pay"}),{publicId:Nn(rt.value.start)}})().finally(()=>{Wt=void 0})),Wt);V.mount(S.current,{currency:_.currency,totalAmount:_.totalMinor,createOrder:ua,mobileRedirectUrls:{success:na(b,{provider:"revolutPay",cartId:_.cartId,result:"success"}),failure:na(b,{provider:"revolutPay",cartId:_.cartId,result:"failure"}),cancel:na(b,{provider:"revolutPay",cartId:_.cartId,result:"cancel"})},...t.buttonStyle!=null?{buttonStyle:t.buttonStyle}:{}}),V.on("click",()=>{n.track("payment_method_selected",{gateway:"revolut_pay",method:"revolut_pay"})}),V.on("payment",O),!T&&k.current&&h(Y=>Y==="price-changed"||Y==="cart-conflict"||Y==="confirmed"||Y==="failed"||Y==="cancelled"?Y:"idle"),P=()=>{try{V.destroy()}catch{}try{F.destroy?.()}catch{}};let Tt=Bn(window.location.search),ba=mn(U.getRecord())?.provider==="revolutPay"&&(Tt.cartId==null||Tt.cartId===_.cartId)||Tt.returned&&Tt.provider==="revolutPay";Tt.returned&&window.history.replaceState({},"",jn(window.location.href)),ba&&await yt(U)})().catch(()=>{!T&&k.current&&h("load-failed")}),()=>{T=!0,I.abort(),P?.()}},[g?.publicKey,g?.mode,p,r,v,e,a,t.fetch,t.returnUrl,t.cancelUrl,u,o,i,c,l,y]),As("div",{"data-bitsnap-express":"revolutPay","aria-busy":R==="pending"?!0:void 0,className:t.className,style:t.style,children:[fe("div",{ref:S}),fe(Ie,{phase:R})]})}function Gn(t,e){return e!=null&&t.cartId===e.cartId&&t.currency===e.currency&&t.totalMinor===e.totalMinor}function Ns(t){let e=t.projectID??Ct(),a=mt(e,t.analytics,"cart");return Ha(()=>{t.projectID!=null&&$t(t.projectID)},[t.projectID]),fe(xt,{value:a,children:fe(ne,{locale:t.locale,texts:t.texts,children:fe(le,{appearance:t.appearance,children:e==null?null:fe(Ka,{...t,projectID:e})})})})}var Rs=Ns;import{Fragment as Us,jsx as M,jsxs as bt}from"react/jsx-runtime";var _s=({className:t,locale:e})=>{let a=ie(),r=kt(),n=e??Nt(),o=L("productList"),i=L("summary"),c=L("totalLabel"),l=L("totalValue"),u=L("deliveryText"),s=L("summaryNote"),f=L("countryLabel"),v=L("paymentButtons"),m=L("checkoutButton"),g=L("emptyState"),p=L("error"),S=L("skeleton"),R=q("unavailableProducts"),h=oe(),y=q("emptyCart"),A=q("total"),k=q("delivery"),E=q("chooseCountry"),D=q("nextStep"),I=q("loadFailed"),T=q("retry"),P=q("countryRequired"),w=q("extrasCalculatedNext"),U=J.useId(),b=J.useId(),{mutateAsync:C}=Te({mutationFn:a.removeProductFromCart}),{mutateAsync:X}=Te({mutationFn:a.updateQuantity}),{mutateAsync:yt}=Te({mutationFn:a.setCountry}),{mutateAsync:Ot}=Te({mutationFn:a.clearCart}),[O,z]=J.useState(""),N=Vt(x=>x.notice);J.useEffect(()=>()=>Vt.getState().setNotice(void 0),[]);let _=O.length>0?O:N??"",[W,F]=J.useState([]),[V,Wt]=J.useState(!1),{mutateAsync:ua,isPending:Tt}=Te({mutationFn:a.redirectToNextStep}),{data:ma}=Ne({queryKey:["cart-available-countries"],queryFn:a.getAvailableCountries}),{data:ba}=Ne({queryKey:["cart-one-click-payment"],queryFn:a.checkIfApplePayIsAvailable}),{data:Y,isLoading:rt,isError:ye,refetch:tr}=Ne({queryKey:["cart",n],queryFn:a.getProducts}),{data:Ht,refetch:er}=Ne({queryKey:["cart-country"],queryFn:a.getCountry}),[wo]=Ds(),j=Q(Y)?void 0:Y,Mt=Ht!=null&&!Q(Ht)&&Ht!=""?Ht:void 0,ar=Ls(),ze=j==null||j.length===0||Mt==null?void 0:j.map(x=>`${x.productID}:${x.quantity}`).sort().join(","),rr={queryKey:["cart-payment-methods",lt(),n,Mt,ze],queryFn:async()=>a.getPaymentMethodChoice().catch(()=>null),staleTime:6e4,retry:!1},{data:nr,isPlaceholderData:xo}=Ne({...rr,enabled:ze!=null,placeholderData:x=>x===void 0?void 0:Nr(x)}),Oe=ze!=null?nr??null:null,[or,ko]=J.useState(void 0),[ir,sr]=J.useState(!1),cr=J.useRef(null),lr=!rt&&(ye||Q(Y)),Bt=Q(ma)?[]:ma,we=j?.reduce((x,K)=>K.details==null?x:x+(K.details.pricing?.effectivePrice??K.details.price)*K.quantity,0)??0,xe=j?.[0]?.details?.currency??"PLN",Co=j?.some(x=>x.details?.isDeliverable===!0)??!1,dr=Ht!==void 0&&Mt==null,pr=J.useRef(!1);J.useEffect(()=>{pr.current||Bt==null||Bt.length===0||Ht==null||Mt!=null&&Bt.some(x=>x.code===Mt)||(pr.current=!0,yt(Bt[0].code).then(()=>er()).catch(()=>{}))},[Bt,Ht,Mt]);let ur=J.useRef(!1);J.useEffect(()=>{ur.current||rt||(ur.current=!0,r.track("cart_opened",{item_count:j?.reduce((x,K)=>x+K.quantity,0)??0,value_minor:we,currency:xe}))},[rt,r,j,we,xe]);let ga=J.useRef(new Map);J.useEffect(()=>{ga.current.clear()},[j]);function Po(x,K){let st=j?.find(Eo=>Eo.id===x);if(st?.details==null)return;let ct=K-(ga.current.get(x)??st.quantity);if(ga.current.set(x,K),ct===0)return;let wt=st.details.pricing?.effectivePrice??st.details.price,Me=st.catalogProductID??st.productID;r.track(ct>0?"add_to_cart":"remove_from_cart",{qty:Math.abs(ct),value_minor:Math.round(wt*Math.abs(ct)),currency:st.details.currency},{product_id:Me,variant_id:Me!==st.productID?st.productID:null})}let mr=J.useRef(!1);async function So(x,K){if(K!=null){Po(x,Math.max(0,K));try{let st=K<=0?await C({id:x}):await X({id:x,quantity:K});if(Q(st))throw new Error(`cannot change the cart: ${st.error}`)}finally{await tr().catch(()=>{})}}}async function Io(){try{z(""),F([]),Vt.getState().setNotice(void 0);let x=Oe,K=x!=null?xa(x,or):void 0;if(ze!=null&&(nr===void 0||xo)){sr(!0);try{x=await ar.fetchQuery(rr).catch(()=>null)}finally{sr(!1)}if(x==null)K=void 0;else if(K==null||!x.methods.includes(K)){window.setTimeout(()=>{cr.current?.querySelector("input:checked")?.focus()},0);return}}if(j!=null){!mr.current&&j.length>0&&(mr.current=!0,r.track("checkout_started",{item_count:j.reduce((wt,Me)=>wt+Me.quantity,0),checkout_type:"cart",value_minor:we,currency:xe}));try{At({event:"initiateCheckout",items:j?.map(wt=>({id:wt.productID,name:wt.details?.name??"",price:wt.details?.price??0,quantity:wt.quantity,currency:wt.details?.currency??"PLN"}))})}catch{}}let st=Dr(),ct=await ua(K!=null?{paymentMethod:K}:void 0);if(Q(ct)){ar.invalidateQueries({queryKey:["cart-payment-methods"]}),ct.error=="item-ids-not-found"?(z(R),"data"in ct&&Array.isArray(ct.data)&&F(ct.data)):K==="cod"&&ct.error=="gateway-not-configured"?z(h("paymentMethodCodUnavailable")):z(Tr(ct,h));return}Ar(ct,{cartProjectId:lt(),lines:st})||await Ot(),window.location.href=ct.url}catch(x){console.warn("checkout failed",x),z(h("checkoutFailed"))}}return bt("div",{className:`${t} flex flex-col`,ref:wo,children:[rt&&bt("div",{className:"relative flex w-full justify-center flex-col gap-4",children:[M(Na,{"data-bitsnap-checkout-slot":"skeleton",className:d("w-full h-32",S.className),style:S.style}),M(Na,{"data-bitsnap-checkout-slot":"skeleton",className:d("w-full h-32",S.className),style:S.style})]}),lr&&bt("div",{className:"flex flex-col items-start gap-3 p-4",children:[M("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:d(p.className),style:p.style,children:I}),N!=null&&N.length>0&&M("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:d("text-sm",p.className),style:p.style,children:N}),M("button",{type:"button","data-bitsnap-checkout-slot":"checkoutButton",onClick:()=>{tr().then().catch()},className:d("px-3 py-2 rounded-md transition font-bold",m.className),style:m.style,children:T})]}),!rt&&!lr&&(j==null||j.length==0)&&bt("div",{className:"flex flex-col gap-4 p-4",children:[M("p",{"data-bitsnap-checkout-slot":"emptyState",className:d(g.className),style:g.style,children:y}),N!=null&&N.length>0&&M("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:d("text-sm",p.className),style:p.style,children:N})]}),M("div",{"data-bitsnap-checkout-slot":"productList",className:d("max-h-[70vh] overflow-clip overflow-y-scroll",o.className),style:o.style,children:j!=null&&j.length>0&&M("ul",{className:"mt-5",children:j.map(x=>M(J.Fragment,{children:x.details!=null&&bt("li",{className:"mb-3",children:[M(tn,{isNotAvailable:W.includes(x.productID),quantity:x.quantity,details:x.details,url:x.url,shouldUpdate:K=>So(x.id,K)}),M("hr",{className:"h-1"})]})},x.id))})}),M("div",{className:"grow"}),we>0&&xe!=null&&bt(Us,{children:[bt("div",{"data-bitsnap-checkout-slot":"summary",className:d("mx-3 flex flex-col",i.className),style:i.style,children:[bt("div",{className:"flex flex-row justify-between text-lg",children:[M("p",{"data-bitsnap-checkout-slot":"totalLabel",className:d("text-xl",c.className),style:c.style,children:A}),bt("div",{className:"flex flex-col items-end",children:[M("p",{"data-bitsnap-checkout-slot":"totalValue",className:d("font-medium",l.className),style:l.style,children:Kt(we,xe)}),Co&&M("p",{"data-bitsnap-checkout-slot":"deliveryText",className:d("opacity-70 text-right text-base",u.className),style:u.style,children:k})]})]}),M("p",{"data-bitsnap-checkout-slot":"summaryNote",className:d("opacity-70 text-sm",s.className),style:s.style,children:w})]}),Bt&&Bt?.length>1&&bt("div",{children:[M("h4",{"data-bitsnap-checkout-slot":"countryLabel",className:d("ml-3 text-sm",f.className),style:f.style,children:E}),M($r,{id:U,open:V,onToggle:()=>{Wt(!V)},onChange:x=>{yt(x).then(()=>{er().then().catch()})},selectedValue:Mt??"",countries:Bt})]}),bt("div",{className:"mb-3 flex flex-col",children:[ba&&j!=null&&j.length>0&&M("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:d("w-full px-2",v.className),style:v.style,children:M(Sa,{colorType:"white",style:{width:"100%"},items:j?.map(x=>({name:x.details?.name??"",id:x.productID,price:x.details?.pricing?.effectivePrice??x.details?.price??0,currency:x.details?.currency,quantity:x.quantity,isDeliverable:x.details?.isDeliverable??!1,metadata:x.metadata}))})}),j!=null&&j.length>0&&M("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:d("w-full px-2",v.className),style:v.style,children:M(Va,{buttonSizeMode:"fill",buttonColor:"white",style:{width:"100%"},items:j?.map(x=>({name:x.details?.name??"",id:x.productID,price:x.details?.pricing?.effectivePrice??x.details?.price??0,quantity:x.quantity,isDeliverable:x.details?.isDeliverable??!1,metadata:x.metadata}))})}),j!=null&&j.length>0&&bt("div",{"data-bitsnap-checkout-slot":"paymentButtons",className:d("w-full px-2",v.className),style:v.style,children:[M(ja,{projectID:lt()??"",locale:n}),M(Ka,{projectID:lt()??"",locale:n})]}),Oe!=null&&M("div",{ref:cr,className:"contents",children:M(an,{choice:Oe,selected:xa(Oe,or),onChange:ko,disabled:Tt})}),M("button",{"data-bitsnap-checkout-slot":"checkoutButton",onClick:Io,disabled:rt||Tt||ir||Mt==null,"aria-describedby":dr?b:void 0,className:d("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:Tt||ir?M(pt,{}):D}),dr&&M("p",{id:b,className:"text-sm text-center opacity-70",children:P}),_.length>0&&M("p",{role:"alert","data-bitsnap-checkout-slot":"error",className:d("text-sm text-center",p.className),style:p.style,children:_})]})]})]})},Fn=_s;import{jsx as ut,jsxs as ia}from"react/jsx-runtime";function qs({isVisible:t,shouldHide:e,panelId:a,locale:r}){let[n]=zs(),[o,i]=Bs(null),c=Os(y=>{n(y),i(y)},[n]),l=Ms(null),{boundaryClassName:u,boundaryStyle:s}=Ce(),f=L("root"),v=L("overlay"),m=L("panel"),g=L("header"),p=L("title"),S=L("closeButton"),R=q("cart"),h=q("close");return ut("div",{ref:c,"data-bitsnap-checkout":"root","data-bitsnap-checkout-slot":"root",className:d("bitsnap-react",u,f.className),style:{zIndex:999999,...s,...f.style},children:o!=null&&ut(It.Root,{open:t,onOpenChange:y=>{y||e()},children:ia(It.Portal,{container:o,children:[ut(It.Overlay,{"data-bitsnap-checkout-slot":"overlay","aria-hidden":"true",className:d("fixed top-0 right-0 left-0 bottom-0 cursor-pointer z-10",v.className),style:v.style,onClick:e}),ia(It.Content,{id:a,"data-bitsnap-checkout-slot":"panel","aria-modal":"true","aria-describedby":void 0,onOpenAutoFocus:()=>{let y=document.activeElement;l.current=y instanceof HTMLElement?y:null},onCloseAutoFocus:y=>{y.preventDefault(),l.current?.focus(),l.current=null},className:d("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:y=>y.preventDefault(),children:[ia("div",{"data-bitsnap-checkout-slot":"header",className:d("mx-3 mt-7 flex justify-between items-center",g.className),style:g.style,children:[ut(It.Title,{asChild:!0,children:ut("h1",{"data-bitsnap-checkout-slot":"title",className:d("text-2xl font-medium",p.className),style:p.style,children:R})}),ut("button",{type:"button","data-bitsnap-checkout-slot":"closeButton",className:d("rounded-xl p-2 transition",S.className),style:S.style,"aria-label":h,onClick:e,children:ia("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:[ut("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ut("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),ut(Fn,{className:"grow",locale:r})]})]})})})}var Gs=t=>typeof window>"u"?null:js(ut(le,{appearance:t.appearance,children:ut(ne,{texts:t.texts,locale:t.locale,children:ut(se,{locale:t.locale,children:ut(qs,{...t})})})}),document.body),Wn=Gs;import{Fragment as Hn,jsx as Zt,jsxs as sa}from"react/jsx-runtime";var Hs=nt.object({id:nt.string(),isSubscription:nt.boolean().default(!1),quantity:nt.number(),metadata:nt.record(nt.string(),nt.string().optional()).optional(),url:nt.string().optional()}),Ks={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0};function Vs({projectID:t,locale:e,children:a,onVisibleChange:r,className:n,numberOfProductsInCartOptions:o,appearance:i,texts:c,analytics:l}){let u=mt(t,l,"cart");gr(u);let{isCartVisible:s,showCart:f,hideCart:v,numberOfProductsInCart:m}=Vt(),g=`bitsnap-cart-${Fs()}`,p=E=>fr(E,e??Nt(),c),S=Ws(p);S.current=p;function R(E){Vt.getState().setNotice(S.current(E)),f()}function h(E){document.querySelectorAll("iframe").forEach(I=>{I.contentWindow?.postMessage(E,"*")})}Re(()=>{r?.(s),s&&At({event:"viewCart"})},[s]),Re(()=>{$t(t)},[t]),Re(()=>{fa(e)},[e]),Re(()=>{if(!("cart"in window)){let E=lt();if(E==null){console.warn("There is no project ID configured.");return}window.cart={buyProduct:async D=>{try{let I=nt.object({productID:nt.string(),email:nt.string().optional(),name:nt.string().optional(),country:nt.string().optional(),marketingAgreement:nt.boolean().optional(),locale:nt.string().optional()}).parse(D),T=Pa(E);try{let w=await T.getProducts();Q(w)==!1&&At({event:"initiateCheckout",items:w.map(U=>({id:U.productID,name:U.details?.name??"",price:U.details?.price??0,quantity:U.quantity,currency:U.details?.currency??"PLN"}))})}catch{}let P=await T.justRedirectToPayment(I);Q(P)==!1?window.location.href=P.url:R("redirectFailed")}catch(I){console.warn(I)}}}}},[]);async function y(E,D){let I=lt();if(I==null){console.warn("There is no project ID configured.");return}try{let T=Hs.parse(D);if(T.isSubscription){await A(I,T);return}await Pa(I).addProduct({productID:T.id,quantity:T.quantity,metadata:T.metadata,url:T.url}),h({id:E,type:"ADD_TO_CART",success:!0}),f()}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 k(){"__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:I}=E.data;switch(I){case"ADD_TO_CART".toString():y(D,E.data.payload).then().catch();break;default:break}}}))}return Re(()=>{if(k(),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}},[]),sa(Hn,{children:[sa("button",{type:"button",onClick:()=>s?v():f(),"aria-label":a?void 0:m>0?`${p("openCart")}. ${p("cartItemsCount")}: ${m}`:p("openCart"),"aria-expanded":s,"aria-haspopup":"dialog","aria-controls":s?g:void 0,style:{position:"relative"},className:["bitsnap-react",n??"rounded-full hover:bg-neutral-300 transition p-1"].join(" "),children:[a?Zt(Hn,{children:a}):sa("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:[Zt("circle",{cx:"8",cy:"21",r:"1"}),Zt("circle",{cx:"19",cy:"21",r:"1"}),Zt("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&&sa("span",{style:Ks,children:[p("cartItemsCount"),": ",m]}),o?.isVisible!=!1&&m>0&&Zt("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)",...o?.style},children:m})]}),Zt(xt,{value:u,children:Zt(Wn,{isVisible:s,locale:e,appearance:i,texts:c,panelId:g,shouldHide:()=>{v()}})})]})}var $s=Vs;import Qs from"@google-pay/button-react";import{useQuery as Xs,useMutation as Ys}from"@tanstack/react-query";import{Fragment as tc,jsx as Ae,jsxs as ec}from"react/jsx-runtime";function Zs({items:t,style:e,buttonColor:a,buttonSizeMode:r,test:n}){let{getGooglePayConfiguration:o,completeGooglePayPayment:i,setCountry:c,setCouponCodeIfPossible:l,setDeliveryMethod:u,setEmail:s,setPostalCode:f,clearCart:v}=ie(),m=kt(),{data:g}=Xs({queryKey:["get-google-pay-configuration",t.map(R=>R.id).join(",")],queryFn:()=>o({items:t.map(R=>({...R,id:void 0,productID:R.id}))})}),{mutateAsync:p,isPending:S}=Ys({mutationFn:i});return g==null||g.isAvailable!=!0?(console.log("google pay configuration is not available",g),null):ec(tc,{children:[Ae(Qs,{buttonSizeMode:r,buttonColor:a,style:e,existingPaymentMethodRequired:!0,onClick:()=>m.track("payment_method_selected",{gateway:"google_pay",method:"google_pay"}),environment:n===!0?"TEST":"PRODUCTION",onPaymentDataChanged:async R=>{At({event:"initiateCheckout",items:t.map(y=>({id:y.id,name:y.name,price:y.price,quantity:y.quantity,currency:"PLN"}))}),console.log("payment data changed",R),R.shippingAddress?.postalCode!=null&&await f(R.shippingAddress?.postalCode),R.shippingAddress?.countryCode!=null&&await c(R.shippingAddress?.countryCode),R.shippingOptionData?.id!=null&&await u(R.shippingOptionData.id);let h=await o({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 p({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)}}}),S?Ae(pt,{}):null]})}function Js(t){let e=mt(Ct(),t.analytics,"cart");return Ae(xt,{value:e,children:Ae(se,{children:Ae(Zs,{...t})})})}var Va=Js;import{useReducer as Dc,useRef as Lc,useEffect as Ue}from"react";import{useQuery as _c}from"@tanstack/react-query";import{Settings as Uc}from"lucide-react";import{Fragment as ac,jsx as $a,jsxs as rc}from"react/jsx-runtime";var tt=xr.pl,B={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:rc(ac,{children:[$a("span",{style:{color:"red"},children:"*"}),"Wyra\u017Cam zgod\u0119 na przetwarzanie moich danych w celach marketingowych zgodnie z"," ",$a("a",{href:"/regulations/polityka-prywatnosci",target:"_blank",className:"cursor-alias font-bold hover:font-medium",children:"regulaminem"})," ",$a("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:tt.resendIn,loginResentMessage:tt.resent,loginExpiredError:tt.expired,loginTooManyAttemptsError:tt.tooManyAttempts,loginRateLimitedError:tt.rateLimited,loginNetworkError:tt.network,loginSpamHint:tt.spamHint,loginValidityHint:tt.validity,loginVerifyingButton:tt.verifying,loginStepEmailHint:tt.stepEmail,loginStepCodeHint:tt.stepCode,loginAlreadySentMessage:tt.alreadySent,loginEmailNotFoundError:tt.emailNotFound,loginDeliveryUnavailableError:tt.deliveryUnavailable,loginResendNewCodeButton:tt.resendNew,loginNoCodeButton:tt.noCode,loginCodeIncompleteError:tt.codeIncomplete};import{LogOutIcon as nc}from"lucide-react";import{Fragment as Kn,jsx as Jt,jsxs as ca}from"react/jsx-runtime";function Vn({projectName:t,projectLogo:e,projectLogoDark:a,description:r,className:n,onLogout:o}){return ca(Kn,{children:[e!=null||t!=null&&ca("h2",{className:d("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",n?.headerTitle),children:[e!=null&&ca(Kn,{children:[Jt("img",{src:e,alt:"",className:d("h-12 w-auto dark:hidden",n?.headerLogo)}),Jt("img",{src:a??e,alt:"",className:d("hidden h-12 w-auto dark:inline",n?.headerLogo)})]}),Jt("span",{children:t})]}),ca("div",{className:"flex items-center gap-2",children:[r&&Jt("p",{className:d("mt-4 font-medium text-left",n?.headerDescription),children:r}),Jt("div",{className:"grow"}),o&&Jt($,{variant:"ghost",size:"icon-sm",onClick:o,children:Jt(nc,{className:"h-5 w-5"})})]})]})}import*as la from"@radix-ui/react-switch";import{jsx as $n}from"react/jsx-runtime";function he({className:t,...e}){return $n(la.Root,{"data-slot":"switch",className:d("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",t),...e,children:$n(la.Thumb,{"data-slot":"switch-thumb",className:d("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 Jn}from"@formkit/auto-animate/react";import{CheckCircleIcon as ic,TriangleAlertIcon as sc}from"lucide-react";import*as Lt from"@radix-ui/react-popover";import{jsx as da}from"react/jsx-runtime";function Qn({...t}){return da(Lt.Root,{"data-slot":"popover",...t})}function Xn({...t}){return da(Lt.Trigger,{"data-slot":"popover-trigger",...t})}function Yn({className:t,align:e="center",sideOffset:a=4,...r}){return da(Lt.Portal,{children:da(Lt.Content,{"data-slot":"popover-content",align:e,sideOffset:a,className:d("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",t),...r})})}import{ClockIcon as oc}from"lucide-react";import{jsx as _t,jsxs as qt}from"react/jsx-runtime";function Zn({regularity:t}){let e="";switch(t){case"rarely":e="rzadko";break;case"often":e="cz\u0119sto";break;case"very_often":e="codzienne";break}return qt(Qn,{children:[_t(Xn,{onClick:a=>{a.stopPropagation()},children:qt("button",{type:"button",className:"flex w-[30%] cursor-help flex-col items-center justify-center text-xs md:w-[25%] xl:w-[20%]",children:[_t(oc,{size:12}),_t("span",{children:e})]})}),_t(Yn,{className:"w-80",children:qt("div",{className:"grid gap-4",children:[qt("div",{className:"space-y-2",children:[_t("h4",{className:"leading-none font-medium",children:"Co to oznacza?"}),qt("ul",{className:"list-inside list-disc text-sm",children:[qt("li",{children:[_t("span",{className:"font-semibold",children:"Rzadko"})," \u2013 powiadomienia b\u0119d\u0105 wysy\u0142ane maksymalnie kilka razy w miesi\u0105cu."]}),qt("li",{children:[_t("span",{className:"font-semibold",children:"Cz\u0119sto"})," \u2013 powiadomienia mog\u0119 by\u0107 wysy\u0142ane kilka razy w tygodniu."]}),qt("li",{children:[_t("span",{className:"font-semibold",children:"Codzienne"})," \u2013 powiadomienia b\u0119d\u0105 wysy\u0142ane nawet codziennie."]})]})]}),_t("div",{className:"grid gap-2"})]})})]})}import{Fragment as cc,jsx as ot,jsxs as Et}from"react/jsx-runtime";function pa({groups:t=[],isManaging:e,onToggle:a,onCheckAll:r,onUpdate:n,isUpdating:o,wasChanged:i,isUserGroupsUpdated:c,className:l,texts:u}){let[s]=Jn(),[f]=Jn(),v=t.filter(p=>p.isOn===!1).length>0,m=t.filter(p=>p.isOn===!1).length>0;if(t.length<=1&&e!=!0)return null;let g=Et("div",{ref:s,className:d("my-5 flex flex-col gap-3",l?.groupsList),children:[t.map(p=>Et("div",{id:p.id,role:"button",className:d(p.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",l?.groupItem),onClick:S=>{S.target instanceof HTMLButtonElement||a(p.id)},children:[ot(he,{checked:p.isOn,className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-700",onCheckedChange:()=>{a(p.id)}}),Et("div",{className:"flex flex-col items-start justify-start",children:[ot("p",{className:"font-medium text-sm",children:p.name}),p.description&&ot("p",{className:"text-xs font-light",children:p.description})]}),ot("div",{className:"grow"}),p.howOften&&ot(Zn,{regularity:p.howOften})]},p.id)),Et("div",{className:"flex gap-2",children:[e===!0&&Et(cc,{children:[Et("div",{ref:f,className:"flex flex-col items-start justify-start",children:[i&&Et($,{variant:"default",size:"sm",className:"relative",disabled:o,onClick:n,children:[u?.groupsUpdateButton??B.groupsUpdateButton,o&&ot("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:ot(pt,{})})]}),c&&Et("p",{className:"mt-3 flex items-center gap-2 text-sm text-green-500",children:[ot(ic,{color:"var(--color-green-500",size:16})," ",u?.groupsUpdateSuccess??B.groupsUpdateSuccess]})]}),ot("div",{className:"grow"})]}),m&&ot("div",{className:"flex justify-start",children:ot($,{className:"cursor-pointer dark:bg-neutral-700",onClick:r,size:"sm",variant:"secondary",type:"button",children:u?.groupsSelectAllButton??B.groupsSelectAllButton})})]}),v&&Et("div",{className:"flex text-left gap-2 text-xs text-yellow-500",children:[ot(sc,{color:"orange",size:16}),u?.groupsNoSelectionWarning??B.groupsNoSelectionWarning]})]});return e==!0?Et(te,{className:"mt-5 text-left",children:[ot(ee,{children:ot(ae,{children:u?.groupsTitle??B.groupsTitle})}),ot(re,{children:g})]}):g}import{jsx as Gt,jsxs as De}from"react/jsx-runtime";function to({showQRCode:t=!0,isManaging:e,className:a,texts:r}){let n=typeof window<"u",o=n?!!window.matchMedia?.("(prefers-color-scheme: dark)").matches:!1;function i(c){return c?window.location.href:""}return t?De(te,{className:d("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",a?.qrCodeSection),children:[Gt(ee,{children:De(ae,{className:d("mb-3 text-base font-medium lg:text-lg",a?.qrCodeTitle),children:[r?.qrCodeSubtitle??B.qrCodeSubtitle," "+(r?.qrCodeTitle??B.qrCodeTitle)]})}),De(re,{className:"flex flex-col items-center gap-2",children:[De("div",{className:"mt-1.5 mb-3 flex items-center gap-x-2",children:[Gt("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:Gt("img",{className:"h-auto w-full",src:dt+"/app-store-logo.png",alt:"Download on App Store"})}),Gt("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:Gt("img",{className:"h-auto w-full",src:dt+"/google-play-logo.png",alt:"Get in on Google Play"})})]}),n&&Gt("div",{className:"flex items-center justify-center",children:De("div",{className:d("flex min-w-[40%] flex-col items-center gap-2 rounded-xl bg-white p-2 dark:bg-neutral-900",a?.qrCodeContainer),children:[Gt("img",{className:"mt-3 w-[80%] p-1 pt-3",src:dt+`/api/qr-gen?url=${i(n)}&bgColor=${o?"171717":"F6F4F0"}&textColor=${o?"ffffff":"000000"}&margin=0`}),Gt("p",{className:"text-xs md:text-sm",children:r?.qrCodeScanText??B.qrCodeScanText})]})})]})]}):null}import{useState as Le}from"react";import{isValidPhoneNumber as mc}from"react-phone-number-input";import{useAutoAnimate as lc}from"@formkit/auto-animate/react";import{Label as eo}from"@radix-ui/react-label";import{CheckCircleIcon as dc,CircleAlertIcon as pc,TriangleAlertIcon as uc}from"lucide-react";import{useState as Qa}from"react";import{jsx as gt,jsxs as Ut}from"react/jsx-runtime";function ao({submit:t,isLoading:e,errMsg:a,emailLack:r,warnMsg:n,isSubmited:o,agreementLack:i,showPhoneInput:c=!1,agreementText:l,className:u,texts:s}){let[f,v]=Qa(""),[m,g]=Qa(""),[p,S]=Qa(!1),[R]=lc();function h(y){y.preventDefault(),t(f,m,p)}return Ut("form",{ref:R,onSubmit:h,className:d("flex flex-col gap-3 text-left",u?.formContainer),children:[Ut("div",{className:"flex flex-col gap-1 text-left",children:[gt(eo,{className:"text-sm",htmlFor:"bts-notifications-form-email",children:s?.formEmailLabel??B.formEmailLabel}),gt(ya,{value:f,onChange:y=>{v(y.currentTarget.value)},id:"bts-notifications-form-email",className:d(r===!0?"border-red-400":""),type:"email",placeholder:s?.formEmailPlaceholder??B.formEmailPlaceholder})]}),c&&Ut("div",{className:"flex flex-col gap-1 text-left",children:[Ut(eo,{className:"text-sm",htmlFor:"bts-notifications-form-phone",children:[s?.formPhoneLabel??B.formPhoneLabel," ",gt("span",{className:"text-neutral-500 dark:text-neutral-500",children:s?.formPhoneOptional??B.formPhoneOptional})]}),gt(ya,{value:m,onChange:y=>{g(y.currentTarget.value)},id:"bts-notifications-form-phone",className:"",type:"tel",autoComplete:"tel",autoCorrect:"off",placeholder:s?.formPhonePlaceholder??B.formPhonePlaceholder})]}),Ut("div",{className:"flex items-start gap-x-1.5",children:[gt("input",{className:"cursor-pointer",id:"bts-notifications-form-marketing-consent",type:"checkbox",checked:p,onChange:()=>{S(!p)}}),gt("label",{htmlFor:"bts-notifications-form-marketing-consent",className:d("cursor-pointer text-xs leading-4 transition-colors md:text-sm md:leading-4",i===!0?"text-yellow-700":""),children:l})]}),a.length>0&&Ut("p",{className:"mb-3 flex items-center gap-1 text-sm text-red-400",children:[gt(uc,{color:"#ff6467",size:16})," ",a]}),n.length>0&&Ut("p",{className:"mb-3 flex items-center gap-1 text-sm text-amber-400",children:[gt(pc,{color:"var(--color-amber-400)",size:16})," ",n]}),o==!1&&gt("div",{className:"flex justify-start",children:Ut($,{variant:"default",disabled:e,className:d(e?"cursor-not-allowed text-transparent":"","relative"),children:[s?.formSubmitButton??B.formSubmitButton,e&&gt("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:gt(pt,{})})]})}),o&&Ut("div",{className:"flex items-center gap-3 text-sm text-green-400",children:[gt(dc,{size:16})," ",s?.formSuccessMessage??B.formSuccessMessage]})]})}import{jsx as Xa,jsxs as gc}from"react/jsx-runtime";var bc=/^(([^<>()\[\]\\.,;:\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 ro({groups:t,onToggle:e,onCheckAll:a,slug:r,showPhoneInput:n=!1,agreementText:o,className:i,texts:c,isUpdating:l,wasChanged:u,onSuccess:s}){let[f,v]=Le(""),[m,g]=Le(""),[p,S]=Le(!1),[R,h]=Le(!1),[y,A]=Le(!1),{mutateAsync:k,isPending:E}=Rt(ft.notifications.createNotificationUser);function D(P){return P==null?!1:mc(P,"PL")}async function I(P,w,U){if(v(""),g(""),A(!1),S(!1),h(!1),!U){h(!0),v("Zgoda w tym przypadku jest wymagana.");return}if(bc.test(P)===!1){v("Email jest nieprawid\u0142owy."),A(!0);return}w.length>0&&D(w)===!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 b=await k({slug:r,email:P,phone:w,groups:t.filter(C=>C.isOn==!0).map(C=>C.id),mobileNotificationEnabled:!0,emailNotificationEnabled:!0,smsNotificationEnabled:!0});if(b.result.case==="success"){S(!0),setTimeout(()=>{s?.(!1,b.userId,b.accessToken)},1e3);return}else{S(!0);let C=b.result.value;if(C!=null){if(C==32){s?.(!0,void 0,void 0);return}console.log(`Code error: ${ha[C]}`),v("Wyst\u0105pi\u0142 b\u0142\u0105d: "+ha[C]);return}return}}catch(b){v("Wyst\u0105pi\u0142 b\u0142\u0105d podczas zapisywania. Spr\xF3buj ponownie."),console.log(`Error: ${b}`)}}let T=c?.formTitle??B.formTitle;return gc("div",{className:d("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",i?.formSection),children:[T.length>0&&Xa("h3",{className:d("mb-3 text-base font-medium lg:text-lg",i?.formTitle),children:T}),Xa(pa,{groups:t,isManaging:!1,onToggle:e??(()=>{}),onCheckAll:a??(()=>{}),isUpdating:l??!1,wasChanged:u??!1,isUserGroupsUpdated:!1,className:i,texts:c}),Xa(ao,{errMsg:f,emailLack:y,warnMsg:m,submit:I,isLoading:E,isSubmited:p,agreementLack:R,showPhoneInput:n,agreementText:o??c?.agreementText??B.agreementText,className:i,texts:c})]})}import{useEffect as wc,useState as _e}from"react";import{Label as Ya}from"@radix-ui/react-label";import{MessageCircleWarningIcon as xc}from"lucide-react";import{useDebouncedCallback as kc}from"use-debounce";import{TriangleAlertIcon as fc,XIcon as hc}from"lucide-react";import{createPortal as vc}from"react-dom";import{useEffect as no,useState as yc}from"react";import{jsx as ht,jsxs as ve}from"react/jsx-runtime";function oo({open:t,onOpenChange:e,onConfirm:a,isDeleting:r=!1}){let[n,o]=yc(!1);if(no(()=>(o(!0),()=>o(!1)),[]),no(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),!n||!t)return null;let i=l=>{l.target===l.currentTarget&&e(!1)},c=()=>{a()};return vc(ht("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/50 p-4",onClick:i,children:ve("div",{className:d("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:l=>l.stopPropagation(),children:[ve("button",{onClick:()=>e(!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:r,children:[ht(hc,{className:"h-4 w-4"}),ht("span",{className:"sr-only",children:"Zamknij"})]}),ve("div",{className:"flex flex-col gap-4",children:[ve("div",{className:"flex items-start gap-3",children:[ht("div",{className:"flex-shrink-0",children:ht(fc,{className:"h-6 w-6 text-amber-500","aria-hidden":"true"})}),ht("div",{className:"flex-1",children:ht("h2",{className:"text-lg font-semibold text-black dark:text-neutral-100",children:"Czy na pewno chcesz si\u0119 wypisa\u0107?"})})]}),ht("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."}),ve("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[ht($,{type:"button",variant:"ghost",onClick:()=>e(!1),disabled:r,className:"sm:min-w-[100px]",children:"Anuluj"}),ve($,{type:"button",variant:"destructive",onClick:c,disabled:r,className:d(r&&"cursor-not-allowed text-transparent","relative sm:min-w-[100px]"),children:["Usu\u0144",r&&ht("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:ht("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"})})]})]})]})]})}),document.body)}import{useAutoAnimate as io}from"@formkit/auto-animate/react";import{Fragment as Cc,jsx as H,jsxs as vt}from"react/jsx-runtime";function so({accessToken:t,slug:e,userID:a,className:r,texts:n}){let[o]=io(),[i]=io(),{mutateAsync:c,isPending:l}=Rt(ft.notifications.deleteNotificationUser),{mutateAsync:u,isPending:s}=Rt(ft.notifications.updateNotificationUser),{data:f,isFetching:v}=je(ft.notifications.getNotificationUserSettings,{userId:a,slug:e,accessToken:t}),[m,g]=_e(!1),[p,S]=_e(!1),[R,h]=_e(!1),[y,A]=_e(!1),[k,E]=_e(!1),D=f?.result.case==="success"?f?.result?.value:void 0;function I(){E(!0)}async function T(){await c({accessToken:t,slug:e,userId:a}),E(!1)}async function P(){await u({accessToken:t,slug:e,notificationUserId:a,mobileNotificationEnabled:y,emailNotificationEnabled:m,smsNotificationEnabled:p}),h(!0),setTimeout(()=>{h(!1)},3e3)}let w=kc(b=>{P()},300);wc(()=>{let b=f?.result.case==="success"?f?.result?.value:void 0;g(b?.emailNotificationEnabled??!1),S(b?.smsNotificationEnabled??!1),A(b?.mobileNotificationEnabled??!1)},[f]);function U(b,C){b==="email"&&g(C),b==="phone"&&S(C),b==="push"&&A(C),w(!0)}return vt("div",{className:d("bg-beige-100 rounded-xl p-4 dark:bg-neutral-700",r?.manageDataSection),children:[H("div",{className:"flex justify-start",children:H("h3",{className:d("mb-3 text-base font-medium lg:text-lg",r?.manageDataTitle),children:n?.manageDataTitle??B.manageDataTitle})}),v?H(Sr,{className:"h-64 w-full"}):vt(te,{ref:i,className:d(s&&"relative"),children:[H(ee,{children:H(ae,{children:H("p",{className:"text-sm text-left",children:n?.manageDataDescription??B.manageDataDescription})})}),vt(re,{ref:o,children:[H("div",{className:d(s&&"opacity-50 pointer-events-none","flex flex-col gap-2"),children:vt("div",{className:"flex flex-col items-start gap-5 gap-x-2",children:[D?.emailNotificationAvailable&&vt("div",{className:"flex items-center gap-3",children:[H(he,{id:"email-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:m,onCheckedChange:()=>{U("email",!m)}}),H(Ya,{htmlFor:"email-enabled",className:"text-sm",children:"Email"})]}),D?.smsNotificationAvailable&&vt("div",{className:"flex items-center gap-3",children:[H(he,{id:"sms-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:p,onCheckedChange:()=>{U("phone",!p)}}),H(Ya,{htmlFor:"sms-enabled",className:"text-sm",children:"SMS"})]}),D?.mobileNotificationAvailable&&vt(Cc,{children:[vt("div",{className:"flex items-center gap-3",children:[H(he,{id:"push-enabled",className:"data-[state=checked]:bg-blue-500 dark:data-[state=unchecked]:bg-neutral-600",checked:y,onCheckedChange:()=>{U("push",!y)}}),H(Ya,{htmlFor:"push-enabled",className:"text-sm",children:"Powiadomienia na telefon"})]}),D?.hasUserInstalledApp===!1&&vt("div",{className:"flex items-center gap-3",children:[H(xc,{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."})]})]})]})}),vt("div",{className:"mt-5 flex flex-col gap-2 text-left",children:[H("hr",{}),R&&H("p",{className:"text-xs text-green-500",children:n?.manageDataUpdatedMessage??B.manageDataUpdatedMessage}),H("div",{className:"flex items-center gap-x-2",children:vt($,{size:"sm",variant:"link",className:d("pl-0 ml-0",l&&"cursor-not-allowed"),onClick:I,children:[n?.manageDataUnsubscribeButton??B.manageDataUnsubscribeButton,l&&H("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2",children:H(pt,{})})]})})]})]}),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(pt,{})})})]}),H(oo,{open:k,onOpenChange:E,onConfirm:T,isDeleting:l})]})}import{useAutoAnimate as Tc}from"@formkit/auto-animate/react";import{ArrowLeft as Nc}from"lucide-react";import{useMemo as ho,useRef as Rc}from"react";import*as it from"@radix-ui/react-dialog";import{XIcon as Pc}from"lucide-react";import{jsx as Ft,jsxs as Za}from"react/jsx-runtime";function co({...t}){return Ft(it.Root,{"data-slot":"dialog",...t})}function Sc({...t}){return Ft(it.Portal,{"data-slot":"dialog-portal",...t})}function Ic({className:t,...e}){return Ft(it.Overlay,{"data-slot":"dialog-overlay",className:d("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",t),...e})}function lo({className:t,children:e,showCloseButton:a=!0,...r}){return Za(Sc,{"data-slot":"dialog-portal",children:[Ft(Ic,{}),Za(it.Content,{"data-slot":"dialog-content",className:d("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",t),...r,children:[e,a&&Za(it.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:[Ft(Pc,{}),Ft("span",{className:"sr-only",children:"Close"})]})]})]})}function po({className:t,...e}){return Ft(it.Title,{"data-slot":"dialog-title",className:d("text-lg leading-none font-semibold",t),...e})}function uo({className:t,...e}){return Ft(it.Description,{"data-slot":"dialog-description",className:d("text-muted-foreground text-sm",t),...e})}import{Code as mo,ConnectError as Ec}from"@connectrpc/connect";function go(t,e="pl"){let a=t.loginCodeSentMessage,r={emailLabel:t.loginEmailLabel,emailPlaceholder:t.loginEmailPlaceholder,sendCode:t.loginSendCodeButton,sending:t.loginSendingButton,invalidEmail:t.loginInvalidEmailError,codeSentTo:a!=null?`${a} {email}.`:void 0,changeEmail:t.loginChangeEmailButton,verify:t.loginVerifyButton,spamHint:t.loginSpamHint,validity:t.loginValidityHint,resend:t.loginResendCodeButton,resendIn:t.loginResendInText,resent:t.loginResentMessage,haveCodePrompt:"",haveCode:t.loginIHaveCode,wrongCode:t.loginInvalidCodeError,expired:t.loginExpiredError,tooManyAttempts:t.loginTooManyAttemptsError,rateLimited:t.loginRateLimitedError,network:t.loginNetworkError,generic:t.loginVerifyCodeError,deliveryFailed:t.loginSendEmailError,verifying:t.loginVerifyingButton,stepEmail:t.loginStepEmailHint,stepCode:t.loginStepCodeHint,alreadySent:t.loginAlreadySentMessage,emailNotFound:t.loginEmailNotFoundError,deliveryUnavailable:t.loginDeliveryUnavailableError,resendNew:t.loginResendNewCodeButton,noCode:t.loginNoCodeButton,codeIncomplete:t.loginCodeIncompleteError};return kr(e,r)}function bo(t){let e=Ec.from(t),a=e.rawMessage||e.message;return e.code===mo.ResourceExhausted?/too many attempts/i.test(a)?"tooManyAttempts":"rateLimited":/invalid code/i.test(a)?"wrongCode":/expired/i.test(a)?"expired":e.code===mo.Unavailable?"unknown":hr(t)}function fo(t,e,a){return{async send(r,{resend:n}){if(!e)return{ok:!1,kind:"unknown",message:a.loginSlugRequiredError};try{let o=await t({email:r,slug:e});return o.ok===!1?o.retryIn!=null&&o.retryIn>0?{ok:!1,kind:"rateLimited",retryIn:o.retryIn}:{ok:!1,kind:"deliveryFailed",message:n?a.loginResendEmailError:a.loginSendEmailError}:o.sent===!1?{ok:!1,kind:"alreadySent",retryIn:o.retryIn||void 0}:{ok:!0,retryIn:o.retryIn||void 0}}catch(o){let i=bo(o);return{ok:!1,kind:i,cause:o,message:i==="unknown"?n?a.loginResendEmailError:a.loginSendEmailError:void 0}}},async verify({email:r,code:n}){try{let o=await t({email:r,code:n,slug:e});return o.ok&&o.accessToken?{ok:!0,value:{userId:o.userId,accessToken:o.accessToken}}:{ok:!1,kind:"wrongCode",message:a.loginVerificationFailedError}}catch(o){return{ok:!1,kind:bo(o),cause:o}}}}}import{jsx as zt,jsxs as vo}from"react/jsx-runtime";function Ac({slug:t,onSuccess:e,onError:a,texts:r,projectName:n,projectLogo:o,projectLogoDark:i,showLogo:c}){let[l]=Tc(),{mutateAsync:u}=Rt(ft.notifications.verifyUserEmail),s=ho(()=>go(r),[r]),[f,v]=s.codeSentTo.split("{email}"),m=Rc(a);m.current=a;let g=ho(()=>{let h=fo(y=>u(y),t,r);return{...h,async verify(y){let A=await h.verify(y);return!A.ok&&A.kind==="wrongCode"&&m.current?.(A.cause instanceof Error?A.cause:new Error(A.message??"wrongCode")),A}}},[u,t,r]),p=Cr({adapter:g,texts:s,storageKey:t?wr("notifications",t):void 0,onVerified:({userId:h,accessToken:y})=>e?.(h,y),onFailure:(h,y)=>a?.(y instanceof Error?y:new Error(h))}),S=p.step==="code",R=S&&!p.needsEmail?r.loginCodeLabel??"":r.loginTitle??"";return vo("div",{className:"flex h-full flex-col",children:[zt(yr,{projectId:t,name:n,showLogo:c,logoUrl:o,logoDarkUrl:i,className:"text-foreground mb-3"}),vo("div",{ref:l,className:"mb-2 flex items-start gap-2",children:[S&&zt($,{type:"button",variant:"ghost",size:"icon-sm",className:"-mt-2 -ml-2 size-11 shrink-0","aria-label":s.changeEmail,disabled:p.isBusy,onClick:p.changeEmail,children:zt(Nc,{className:"h-5 w-5","aria-hidden":!0})}),zt(po,{className:"text-lg leading-6 font-semibold",children:R})]}),zt(uo,{className:S?"sr-only":"mb-4",children:S?`${f}${p.email}${v??""}`:r.loginDescription??""}),zt(Pr,{login:p,texts:s})]})}function yo({slug:t,onSuccess:e,onError:a,className:r,isOpen:n,onClose:o,texts:i,projectName:c,projectLogo:l,projectLogoDark:u,showLogo:s}){return zt(co,{open:n,onOpenChange:o,children:zt(lo,{className:"max-h-[100dvh] overflow-y-auto sm:max-w-[425px]",children:zt(Ac,{slug:t,onSuccess:e,onError:a,texts:i,projectName:c,projectLogo:l,projectLogoDark:u,showLogo:s})})})}import{useAutoAnimate as zc}from"@formkit/auto-animate/react";import{jsx as at,jsxs as Ja}from"react/jsx-runtime";function Oc(t,e){switch(e.type){case"SET_IS_LOGGED_IN":return{...t,isLoggedIn:e.value};case"SET_USER_ID":return{...t,userID:e.value};case"SET_LOADING":return{...t,isLoading:e.value};case"SET_PUBLIC_GROUPS":return{...t,groupsProvided:e.value,groups:e.value!=null&&e.value.length>0?t.groups.filter(a=>e.value?.find(r=>r.id===a.id)!=null):t.groups};case"SET_GROUPS":{let a=t.isLoggedIn==!1||t.groupsProvided!=null,r=e.value.map(n=>t.isLoggedIn==!0?n:{...n,isOn:t.groupsProvided?.find(o=>o.id===n.id)?.isOn??a});return{...t,groups:r}}case"TOGGLE_GROUP":{let a=t.groups.map(r=>r.id===e.groupID?{...r,isOn:!r.isOn}:r);return{...t,wasChanged:!0,groups:a}}case"CHECK_ALL_GROUPS":{let a=t.groups.map(r=>({...r,isOn:!0}));return{...t,groups:a,wasChanged:!0}}case"SET_WAS_CHANGED":return{...t,wasChanged:e.value};case"SET_IS_USER_GROUPS_UPDATED":return{...t,isUserGroupsUpdated:e.value};case"RESET_UPDATE_STATE":return{...t,wasChanged:!1,isUserGroupsUpdated:!0};case"SHOW_SETTINGS":return{...t,showSettings:!0};case"HIDE_SETTINGS":return{...t,showSettings:!1};default:return t}}function Mc({slug:t,userID:e,productID:a,projectID:r,analytics:n,projectName:o,projectLogo:i,projectLogoDark:c,showLoginLogo:l,groups:u,isManaging:s=!1,texts:f,showQRCode:v=!1,showPhoneInput:m=!1,hiddenGroupIds:g=[],className:p}){let[S]=zc(),R=mt(r??Ct(),n),h=t??lt()??(typeof window<"u"?window.location.hostname:"");vr(h.trim(),l!==!1&&!i&&!c&&h.trim()!=="");let{mutateAsync:y,isPending:A}=Rt(ft.notifications.updateUserGroups),{data:k,refetch:E}=_c({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:I,refetch:T}=je(ft.notifications.getUserGroups,{slug:h,accessToken:k?.accessToken}),[P,w]=Dc(Oc,{isLoading:I,isUserGroupsUpdated:!1,wasChanged:!1,groupsProvided:u,groups:[],showSettings:k!=null&&s==!0,isLoggedIn:k!=null,userID:void 0});Ue(()=>{w({type:"SET_LOADING",value:A||I})},[A,I]),Ue(()=>{w({type:"SET_IS_LOGGED_IN",value:k?.accessToken!=null}),w({type:"SET_USER_ID",value:k?.userID}),k?.accessToken!=null&&s==!0&&w({type:"SHOW_SETTINGS"})},[k,s]),Ue(()=>{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}});w({type:"SET_GROUPS",value:W})},[D,I,u]);let U=Lc(null);Ue(()=>{let W=u?.map(F=>(F.id.startsWith("group_")||(F.id=`group_${F.id}`),F));w({type:"SET_PUBLIC_GROUPS",value:W})},[u]);let b={...B,...f};async function C(){await y({accessToken:k?.accessToken,slug:h,userId:e,groupIds:P.groups.filter(W=>W.isOn===!0).map(W=>W.id)}),w({type:"RESET_UPDATE_STATE"}),U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{w({type:"SET_IS_USER_GROUPS_UPDATED",value:!1})},2e3)}function X(W){w({type:"TOGGLE_GROUP",groupID:W})}function yt(){w({type:"CHECK_ALL_GROUPS"})}function Ot(){w({type:"SHOW_SETTINGS"})}function O(){w({type:"HIDE_SETTINGS"})}function z(){localStorage.removeItem("notifications_accessToken"),localStorage.removeItem("notifications_userID"),E(),w({type:"SET_USER_ID",value:void 0}),w({type:"SET_IS_LOGGED_IN",value:!1}),w({type:"HIDE_SETTINGS"})}async function N(W,F){typeof window<"u"&&(localStorage.setItem("notifications_accessToken",F),W!=null&&localStorage.setItem("notifications_userID",W)),w({type:"SET_USER_ID",value:W});try{await E(),T().then().catch().finally(()=>{s==!0&&w({type:"SHOW_SETTINGS"})})}catch(V){console.log(`Error: ${V}`)}}Ue(()=>()=>{U.current&&clearTimeout(U.current)},[]);let _=s==!0&&P.userID!=null&&k?.accessToken!=null;return Ja("main",{className:d("bitsnap-react relative",p?.container),children:[b.title!=null&&at("h1",{className:"text-2xl font-semibold text-black md:text-3xl lg:text-4xl xl:text-5xl dark:text-neutral-100",children:b.title}),!P.showSettings&&s&&at($,{onClick:Ot,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:at(Uc,{className:"h-5 w-5"})}),at("div",{className:d("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",p?.header),children:P.showSettings?at("div",{className:"space-y-6",children:P.isLoggedIn&&Ja("div",{className:d("grid grid-cols-1 gap-3 lg:gap-6",_?"md:grid-cols-2":""),children:[Ja("div",{className:p?.groupsContainer,children:[at(Vn,{projectName:o,projectLogo:i,projectLogoDark:c,description:b.managingDescription,className:p,onLogout:z}),I&&at("div",{className:"flex justify-center items-center py-8",children:at(pt,{})}),at(pa,{groups:P.groups,hiddenGroupIds:g,isManaging:s,onToggle:X,onCheckAll:yt,onUpdate:C,isUpdating:A,wasChanged:P.wasChanged,isUserGroupsUpdated:P.isUserGroupsUpdated,className:p,texts:b})]}),_&&at(so,{accessToken:k.accessToken??"",slug:h,userID:P.userID??"",className:p,texts:b}),v!=!1&&at(to,{showQRCode:v,isManaging:!0,className:p,texts:b})]})}):at("div",{className:d("grid grid-cols-1 gap-3 lg:gap-6"),children:at(ro,{slug:h,onToggle:W=>{w({type:"TOGGLE_GROUP",groupID:W})},onCheckAll:()=>{w({type:"CHECK_ALL_GROUPS"})},onSuccess:(W,F,V)=>{R.track("availability_signup",{},{product_id:a??null}),V!=null&&N(F,V),W&&w({type:"SHOW_SETTINGS"})},groups:P.groups,showPhoneInput:m,agreementText:b.agreementText,className:p,texts:b,wasChanged:P.wasChanged,isUpdating:A})})}),at(yo,{isOpen:P.showSettings&&!P.isLoggedIn,slug:h,onSuccess:N,texts:b,onClose:O,projectName:o,projectLogo:i,projectLogoDark:c,showLogo:l})]})}function Bc({slug:t,userID:e,productID:a,projectID:r,analytics:n,projectName:o,projectLogo:i,projectLogoDark:c,showLoginLogo:l,groups:u,isManaging:s,texts:f,showQRCode:v,showPhoneInput:m,hiddenGroupIds:g,className:p}){return at(va,{children:at(Mc,{slug:t,userID:e,productID:a,projectID:r,analytics:n,projectName:o,projectLogo:i,projectLogoDark:c,showLoginLogo:l,groups:u,isManaging:s,texts:f,showQRCode:v,showPhoneInput:m,hiddenGroupIds:g,className:p})})}var jc=Bc;export{Sa as ApplePayButton,ka as Bitsnap,$s as BitsnapCheckout,gi as BitsnapReturns,Yo as BitsnapReturnsProvider,yi as CHECKOUT_SLOT_NAMES,No as Environment,Va as GooglePayButton,bi as ITEM_IDS_NOT_FOUND,Ss as InPostPayButton,jc as NotificationsComponent,Kc as PRODUCT_LIST_SLOT_NAMES,mi as Panel,Wo as PanelLogin,Mo as PanelProvider,Qc as ProductList,ui as PublicOrderPage,Ho as RETURNS_SLOT_NAMES,Ko as ReturnsAppearanceProvider,oi as ReturnsCodeStep,ci as ReturnsConfirmation,ni as ReturnsEmailStep,pi as ReturnsMyReturnDetail,di as ReturnsMyReturnsList,si as ReturnsOrderDetail,ii as ReturnsOrderList,Xo as ReturnsProvider,li as ReturnsResult,Rs as RevolutPayButton,Fo as buildAccessTokenRedirect,Fc as createCheckout,Gc as createPaymentURL,Vc as formatProductPrice,Oo as getAllowedReturnOrigins,Nt as getLocale,Ao as getPanelConfig,qc as getPaymentMethodChoice,Wc as getReferenceIfPossible,jo as getReturnURLFromSearch,Hc as injectReferenceToRequestIfNeeded,qo as persistReturnURL,Go as readPersistedReturnURL,zo as setAllowedReturnOrigins,To as setCustomHost,Uo as setHost,fa as setLocale,_o as setLoginURL,Ro as setPanelConfig,Do as setPanelProjectID,$t as setProjectID,Lo as setTheme,ei as useCreateReturn,ri as useMyReturn,ai as useMyReturns,Bo as usePanelConfig,$c as useProducts,Jo as useReturnOrders,Zo as useReturnSession,ti as useReturnableOrder,Vo as useReturnsAppearance,$o as useReturnsSlot,Qo as useReturnsText};
1
+ import{a as ra,b as ea,c as ia,d as na,e as la,f as ga,g as va}from"./chunk-5M6M7FAR.mjs";import{F as oa,G as ca,J as sa,g as z,h as j,i as C,j as _,k as S,m as Q,s as V,t as X,u as Z,v as $,w as aa,x as ta}from"./chunk-AAC576BC.mjs";import{a as ha}from"./chunk-MMLBQHBM.mjs";import{A as q,B as A,D as R,E as F,F as W,G as Y,H as G,I as H,J,K,l as B,m as E,n as T,o as M,r as I,u as P,v as L,w as O,x as U,y as N,z as D}from"./chunk-AB37DWOK.mjs";import{a as pa,b as ba,c as ua}from"./chunk-DDIEFKNP.mjs";import{a as da}from"./chunk-EMR4YXNY.mjs";import"./chunk-KOVKUJAW.mjs";import{a as k,b as y}from"./chunk-5JRUPLXY.mjs";import{c as b}from"./chunk-SCEWYZUZ.mjs";import"./chunk-OR566YJI.mjs";import"./chunk-XEXPQFKN.mjs";import{a as u,b as h,c as g,d as v,e as m,f as w,g as f,h as x}from"./chunk-CUPG4B5W.mjs";import"./chunk-WG54EHST.mjs";import"./chunk-5R6AGO3Z.mjs";import{f as d}from"./chunk-N523LFAM.mjs";import"./chunk-SSSF64M7.mjs";import"./chunk-MDCP5JNP.mjs";import{e as l,f as p}from"./chunk-OFPRIENJ.mjs";import"./chunk-U6FLIRIV.mjs";import{lazy as r,Suspense as e}from"react";import{jsx as a}from"react/jsx-runtime";var n=r(()=>import("./chat.mjs").then(t=>({default:t.ChatThread}))),o=r(()=>import("./chat.mjs").then(t=>({default:t.Channel})));function i(){return a("div",{className:"bitsnap-react h-full",children:a("div",{role:"status","aria-busy":"true",className:"h-full min-h-[28rem] w-full rounded-xl border border-neutral-200 bg-white motion-safe:animate-pulse dark:border-neutral-800 dark:bg-neutral-900"})})}function c(t){return a(e,{fallback:a(i,{}),children:a(n,{...t})})}function s(t){return a(e,{fallback:a(i,{}),children:a(o,{...t})})}export{la as ApplePayButton,V as Bitsnap,na as BitsnapCheckout,ha as BitsnapReturns,L as BitsnapReturnsProvider,ra as CHECKOUT_SLOT_NAMES,s as Channel,c as ChatThread,b as Environment,ga as GooglePayButton,Q as ITEM_IDS_NOT_FOUND,ea as InPostPayButton,va as NotificationsComponent,pa as PRODUCT_LIST_SLOT_NAMES,ca as Panel,S as PanelLogin,k as PanelProvider,ua as ProductList,oa as PublicOrderPage,B as RETURNS_SLOT_NAMES,E as ReturnsAppearanceProvider,F as ReturnsCodeStep,G as ReturnsConfirmation,R as ReturnsEmailStep,K as ReturnsMyReturnDetail,J as ReturnsMyReturnsList,Y as ReturnsOrderDetail,W as ReturnsOrderList,P as ReturnsProvider,H as ReturnsResult,ia as RevolutPayButton,_ as buildAccessTokenRedirect,$ as createCheckout,Z as createPaymentURL,da as formatProductPrice,x as getAllowedReturnOrigins,p as getLocale,h as getPanelConfig,X as getPaymentMethodChoice,aa as getReferenceIfPossible,z as getReturnURLFromSearch,ta as injectReferenceToRequestIfNeeded,j as persistReturnURL,C as readPersistedReturnURL,f as setAllowedReturnOrigins,d as setCustomHost,w as setHost,l as setLocale,m as setLoginURL,u as setPanelConfig,g as setPanelProjectID,sa as setProjectID,v as setTheme,D as useCreateReturn,A as useMyReturn,q as useMyReturns,y as usePanelConfig,ba as useProducts,U as useReturnOrders,O as useReturnSession,N as useReturnableOrder,T as useReturnsAppearance,M as useReturnsSlot,I as useReturnsText};
2
2
  //# sourceMappingURL=index.mjs.map