bitsnap-react 1.11.1 → 1.12.1

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 (93) hide show
  1. package/README.md +37 -7
  2. package/dist/CartProvider-WPJWECBS.mjs +2 -0
  3. package/dist/CartProvider-YPZ3HD7W.js +2 -0
  4. package/dist/CartProvider-YPZ3HD7W.js.map +1 -0
  5. package/dist/analytics.js +1 -1
  6. package/dist/analytics.js.map +1 -1
  7. package/dist/analytics.mjs +1 -1
  8. package/dist/catalog.js +1 -1
  9. package/dist/catalog.js.map +1 -1
  10. package/dist/catalog.mjs +1 -1
  11. package/dist/chunk-3ITTSNWG.js +2 -0
  12. package/dist/chunk-3ITTSNWG.js.map +1 -0
  13. package/dist/chunk-4BV5IUZH.js +2 -0
  14. package/dist/chunk-4BV5IUZH.js.map +1 -0
  15. package/dist/{chunk-UFIOJGJZ.js → chunk-4ZFIL5S7.js} +2 -2
  16. package/dist/chunk-4ZFIL5S7.js.map +1 -0
  17. package/dist/{chunk-JUDR4EZA.mjs → chunk-DRAKVCD7.mjs} +2 -2
  18. package/dist/{chunk-HWQNT6XU.mjs → chunk-G3VVAVG7.mjs} +2 -2
  19. package/dist/chunk-GJNFDUJN.mjs +4 -0
  20. package/dist/chunk-GJNFDUJN.mjs.map +1 -0
  21. package/dist/{chunk-ETGHIHWR.mjs → chunk-HBPSSGYN.mjs} +2 -2
  22. package/dist/{chunk-WGJTXDIS.js → chunk-HDLCLZOK.js} +2 -2
  23. package/dist/chunk-HDLCLZOK.js.map +1 -0
  24. package/dist/{chunk-3IVLQILF.js → chunk-I6BRDRPB.js} +2 -2
  25. package/dist/chunk-I6BRDRPB.js.map +1 -0
  26. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  27. package/dist/chunk-KOYBZORL.js.map +1 -1
  28. package/dist/{chunk-VPBFEAFQ.js → chunk-MZSLLGFS.js} +2 -2
  29. package/dist/chunk-MZSLLGFS.js.map +1 -0
  30. package/dist/{chunk-UCL4Y7L3.js → chunk-STVEBT6M.js} +2 -2
  31. package/dist/chunk-STVEBT6M.js.map +1 -0
  32. package/dist/{chunk-IJLHU2MA.mjs → chunk-T2YSOHJM.mjs} +2 -2
  33. package/dist/{chunk-IJLHU2MA.mjs.map → chunk-T2YSOHJM.mjs.map} +1 -1
  34. package/dist/chunk-T3PAOMHI.mjs +2 -0
  35. package/dist/chunk-T3PAOMHI.mjs.map +1 -0
  36. package/dist/chunk-VDLJW4JJ.mjs +2 -0
  37. package/dist/chunk-VDLJW4JJ.mjs.map +1 -0
  38. package/dist/{chunk-DWRBPP32.mjs → chunk-VF62KDNS.mjs} +2 -2
  39. package/dist/chunk-VRL3IF5J.js +4 -0
  40. package/dist/chunk-VRL3IF5J.js.map +1 -0
  41. package/dist/chunk-XIHGWNTS.js.map +1 -1
  42. package/dist/consent.js.map +1 -1
  43. package/dist/course.js +1 -1
  44. package/dist/course.js.map +1 -1
  45. package/dist/course.mjs +1 -1
  46. package/dist/embed/analytics.js +1 -1
  47. package/dist/errors.js.map +1 -1
  48. package/dist/index.css +1 -1
  49. package/dist/index.css.map +1 -1
  50. package/dist/index.d.mts +97 -2
  51. package/dist/index.d.ts +97 -2
  52. package/dist/index.js +1 -1
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +1 -1
  55. package/dist/index.mjs.map +1 -1
  56. package/dist/internal.js.map +1 -1
  57. package/dist/methods-FVDH6Y57.mjs +2 -0
  58. package/dist/methods-ISVX5JQ7.js +2 -0
  59. package/dist/methods-ISVX5JQ7.js.map +1 -0
  60. package/dist/models.js.map +1 -1
  61. package/dist/returns.js +1 -1
  62. package/dist/returns.js.map +1 -1
  63. package/dist/returns.mjs +1 -1
  64. package/package.json +2 -2
  65. package/dist/CartProvider-QY2DMNCC.js +0 -2
  66. package/dist/CartProvider-QY2DMNCC.js.map +0 -1
  67. package/dist/CartProvider-XMHPQRWC.mjs +0 -2
  68. package/dist/chunk-2PK36NGB.mjs +0 -4
  69. package/dist/chunk-2PK36NGB.mjs.map +0 -1
  70. package/dist/chunk-2X32DDUM.mjs +0 -2
  71. package/dist/chunk-2X32DDUM.mjs.map +0 -1
  72. package/dist/chunk-3IVLQILF.js.map +0 -1
  73. package/dist/chunk-FBTYZHXM.js +0 -4
  74. package/dist/chunk-FBTYZHXM.js.map +0 -1
  75. package/dist/chunk-G2UOTVS5.mjs +0 -2
  76. package/dist/chunk-G2UOTVS5.mjs.map +0 -1
  77. package/dist/chunk-Q25D7OAO.js +0 -2
  78. package/dist/chunk-Q25D7OAO.js.map +0 -1
  79. package/dist/chunk-UCL4Y7L3.js.map +0 -1
  80. package/dist/chunk-UFIOJGJZ.js.map +0 -1
  81. package/dist/chunk-VPBFEAFQ.js.map +0 -1
  82. package/dist/chunk-WGJTXDIS.js.map +0 -1
  83. package/dist/chunk-YBGAYEJQ.js +0 -2
  84. package/dist/chunk-YBGAYEJQ.js.map +0 -1
  85. package/dist/methods-ALO22YWQ.mjs +0 -2
  86. package/dist/methods-ZBX4BTDE.js +0 -2
  87. package/dist/methods-ZBX4BTDE.js.map +0 -1
  88. /package/dist/{CartProvider-XMHPQRWC.mjs.map → CartProvider-WPJWECBS.mjs.map} +0 -0
  89. /package/dist/{chunk-JUDR4EZA.mjs.map → chunk-DRAKVCD7.mjs.map} +0 -0
  90. /package/dist/{chunk-HWQNT6XU.mjs.map → chunk-G3VVAVG7.mjs.map} +0 -0
  91. /package/dist/{chunk-ETGHIHWR.mjs.map → chunk-HBPSSGYN.mjs.map} +0 -0
  92. /package/dist/{chunk-DWRBPP32.mjs.map → chunk-VF62KDNS.mjs.map} +0 -0
  93. /package/dist/{methods-ALO22YWQ.mjs.map → methods-FVDH6Y57.mjs.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{o as p}from"./chunk-DWRBPP32.mjs";import{l as g,n as d}from"./chunk-IJLHU2MA.mjs";var t={projectID:void 0,loginURL:"/panel/login",theme:void 0,host:void 0,allowedReturnOrigins:[]},u=[];function w(e){t={...t,...e}}function s(){return t}function P(e){t.projectID=e}function v(e){t.theme=e}function C(e){t.loginURL=e}function R(e){t.host=e}function x(e){u=e,t={...t,allowedReturnOrigins:e}}function y(){return u}import{createContext as c,useContext as m}from"react";import{jsx as r}from"react/jsx-runtime";var f=c(s()),b=({children:e,analytics:n})=>{let o=s(),i=d(o.projectID,n,"panel");return r(p,{children:r(f.Provider,{value:{...o},children:r(g,{value:i,children:r("div",{className:"bitsnap-react",children:e})})})})},L=()=>m(f);var l=(e,n)=>`bitsnap-panel-session:${encodeURIComponent(n??"https://bitsnap.pl")}:${encodeURIComponent(e)}`,a=(e,n)=>`bitsnap-panel-email:${encodeURIComponent(n??"https://bitsnap.pl")}:${encodeURIComponent(e)}`;function $(e,n){return typeof window>"u"||!e?void 0:window.localStorage.getItem(l(e,n))??void 0}function G(e,n,o,i){typeof window>"u"||!e||(window.localStorage.setItem(l(e,i),n),window.localStorage.setItem(a(e,i),o))}function k(e,n){return typeof window>"u"||!e?null:window.localStorage.getItem(a(e,n))}function E(e,n){typeof window>"u"||!e||(window.localStorage.removeItem(l(e,n)),window.localStorage.removeItem(a(e,n)))}export{w as a,s as b,P as c,v as d,C as e,R as f,x as g,y as h,b as i,L as j,$ as k,G as l,k as m,E as n};
2
- //# sourceMappingURL=chunk-ETGHIHWR.mjs.map
1
+ import{o as p}from"./chunk-VF62KDNS.mjs";import{l as g,n as d}from"./chunk-T2YSOHJM.mjs";var t={projectID:void 0,loginURL:"/panel/login",theme:void 0,host:void 0,allowedReturnOrigins:[]},u=[];function w(e){t={...t,...e}}function s(){return t}function P(e){t.projectID=e}function v(e){t.theme=e}function C(e){t.loginURL=e}function R(e){t.host=e}function x(e){u=e,t={...t,allowedReturnOrigins:e}}function y(){return u}import{createContext as c,useContext as m}from"react";import{jsx as r}from"react/jsx-runtime";var f=c(s()),b=({children:e,analytics:n})=>{let o=s(),i=d(o.projectID,n,"panel");return r(p,{children:r(f.Provider,{value:{...o},children:r(g,{value:i,children:r("div",{className:"bitsnap-react",children:e})})})})},L=()=>m(f);var l=(e,n)=>`bitsnap-panel-session:${encodeURIComponent(n??"https://bitsnap.pl")}:${encodeURIComponent(e)}`,a=(e,n)=>`bitsnap-panel-email:${encodeURIComponent(n??"https://bitsnap.pl")}:${encodeURIComponent(e)}`;function $(e,n){return typeof window>"u"||!e?void 0:window.localStorage.getItem(l(e,n))??void 0}function G(e,n,o,i){typeof window>"u"||!e||(window.localStorage.setItem(l(e,i),n),window.localStorage.setItem(a(e,i),o))}function k(e,n){return typeof window>"u"||!e?null:window.localStorage.getItem(a(e,n))}function E(e,n){typeof window>"u"||!e||(window.localStorage.removeItem(l(e,n)),window.localStorage.removeItem(a(e,n)))}export{w as a,s as b,P as c,v as d,C as e,R as f,x as g,y as h,b as i,L as j,$ as k,G as l,k as m,E as n};
2
+ //# sourceMappingURL=chunk-HBPSSGYN.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkXIHGWNTSjs = require('./chunk-XIHGWNTS.js');var Oe=Symbol.for("bitsnap.pageViews");function ye(e){let t=e;return t[Oe]??={path:null,starters:new Set,watching:!1}}function De(e,t){let n=()=>{try{t()}catch (e2){}};for(let o of["pushState","replaceState"]){let a=e.history[o];e.history[o]=function(...i){let c=a.apply(this,i);return n(),c}}e.addEventListener("popstate",n)}function A(e,t=window){try{let n=ye(t),o=()=>e();n.watching||(n.watching=!0,De(t,()=>{let i=t.location.pathname;i===n.path||n.starters.size===0||(n.path=i,_optionalChain([n, 'access', _2 => _2.starters, 'access', _3 => _3.values, 'call', _4 => _4(), 'access', _5 => _5.next, 'call', _6 => _6(), 'access', _7 => _7.value, 'optionalCall', _8 => _8()]))})),n.starters.add(o);let a=t.location.pathname;return a!==n.path&&(n.path=a,o()),()=>void n.starters.delete(o)}catch (e3){return()=>{}}}function ge(e=window){let t=ye(e);t.path=null,t.starters.clear()}var ve="1.11.1";function I(e){let t=new Uint8Array(e),n=typeof crypto<"u"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")n.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);return t}var me="X-Bitsnap-Visitor",$e=390*24*60*60,Me=/^[A-Za-z0-9_-]{22}$/;function R(e){return e.BitsnapConsent}function je(e,t){for(let n of e.cookie.split(";")){let o=n.indexOf("=");if(o!==-1&&n.slice(0,o).trim()===t)return n.slice(o+1).trim()}return null}function He(e){let t=e.toLowerCase();return t==="bitsnap.pl"||t.endsWith(".bitsnap.pl")}function F(e,t){try{let n=R(e);if(!n)return!1;if(n.scope==="project")return n.projectKey===t;let o=He(e.location.hostname);return n.scope==="global"?!o:!1}catch (e4){return!1}}function J(e,t){try{return _optionalChain([R, 'call', _9 => _9(e), 'optionalAccess', _10 => _10.get, 'call', _11 => _11(), 'optionalAccess', _12 => _12.c, 'access', _13 => _13.analytics])===!0&&F(e,t)}catch (e5){return!1}}function he(){let e="";return I(16).forEach(t=>e+=String.fromCharCode(t)),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ee(e,t){try{return je(e,_chunkXIHGWNTSjs.f.call(void 0, t))}catch (e6){return null}}function B(e,t){let n=Ee(e,t);return n!==null&&Me.test(n)?n:null}function ke(e,t,n){try{let o=e.document,a=`${_chunkXIHGWNTSjs.f.call(void 0, t)}=${n}; Max-Age=${$e}; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");for(let i of _chunkXIHGWNTSjs.n.call(void 0, e.location.hostname).reverse())if(o.cookie=`${a}; Domain=${i}`,B(o,t)===n)return;o.cookie=a}catch (e7){}}function be(e,t){try{let n=e.document;if(Ee(n,t)===null)return;let o=`${_chunkXIHGWNTSjs.f.call(void 0, t)}=; Max-Age=0; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");n.cookie=o;for(let a of _chunkXIHGWNTSjs.n.call(void 0, e.location.hostname))n.cookie=`${o}; Domain=${a}`}catch (e8){}}function N(e,t){try{let n=e.navigator;return _optionalChain([n, 'optionalAccess', _14 => _14.globalPrivacyControl])===!0||_optionalChain([n, 'optionalAccess', _15 => _15.webdriver])===!0?null:J(e,t)?B(e.document,t):null}catch (e9){return null}}var Ue="https://collect.bitsnap.pl",Ke=5e3,Ge=20,Te=32*1024,ze=60*1024,xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _e(e){return typeof TextEncoder=="function"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}var y={track(){},page(){},clientId:()=>null,flush(){},setEnabled(){},onEvent:()=>()=>{},configure(){},destroy(){}};function Ye(e=Date.now()){let t=I(16),n=e;for(let a=5;a>=0;a--)t[a]=n%256,n=Math.floor(n/256);t[6]=t[6]&15|112,t[8]=t[8]&63|128;let o=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Fe(){return Array.from(I(16),e=>Ce[e%Ce.length]).join("")}function Je(e,t,n=!1){let o=_e(JSON.stringify({k:e,events:[]})),a=[],i=[],c=o,s=()=>{i.length>0&&a.push({body:JSON.stringify({k:e,events:i}),bytes:c,count:i.length}),i=[],c=o};for(let u of t){let l=_e(JSON.stringify(u));o+l>Te||((i.length>=_chunkXIHGWNTSjs.a.maxBatchEvents||c+l+(i.length>0?1:0)>Te)&&s(),c+=l+(i.length>0?1:0),i.push(u))}if(s(),n){let u=0,l=a.length;for(;l>0&&u+a[l-1].bytes<=ze;)u+=a[l-1].bytes,l--;a=a.slice(l)}return a}function Xe(e){try{return typeof window>"u"||typeof document>"u"?y:qe(e,window)}catch (e10){return y}}function qe(e,t){let n=_chunkXIHGWNTSjs.b.call(void 0, _nullishCoalesce(e.projectKey, () => (""))),o=!!e.debug,a=(...r)=>{o&&console.warn("[bitsnap analytics]",...r)};if(!n)return a("invalid projectKey, tracking is off"),y;let i=n,c=r=>`${(r||Ue).replace(/\/+$/,"")}/e`,s=c(e.endpoint),u=_nullishCoalesce(e.source, () => ("sdk_react")),l=_nullishCoalesce(e.channel, () => ("embed")),b=`bitsnap-react@${ve}`,M=Fe(),T=_chunkXIHGWNTSjs.d.call(void 0, t.location.href),j=_nullishCoalesce(e.env, () => ("live"));if(!e.env)try{new URLSearchParams(t.location.search).has("test")&&(j="test")}catch (e11){}let Le=_chunkXIHGWNTSjs.e.call(void 0, document.referrer),H=e.enabled!==!1,ee=null,Re=0,p=[],h=null,C=new Set;e.onEvent&&C.add(e.onEvent);let E=[],g,m=!0;function W(){let r=R(t);!r||r===g||(g=r,m=!r.ready,_optionalChain([r, 'access', _16 => _16.ready, 'optionalAccess', _17 => _17.then, 'call', _18 => _18(()=>{g===r&&(m=!0,re())},()=>{g===r&&(m=!0)})]))}function te(){W();try{if(!g)return!1;let r=g.get();return!!g.denied&&g.denied("analytics")||!!r&&r.c.analytics===!1}catch (e12){return!1}}function ne(r){C.forEach(f=>{try{f(r)}catch (e13){}})}function U(r){try{if(W(),!g||!F(t,i))return;J(t,i)?P()&&B(t.document,i)===null&&ke(t,i,he()):r&&be(t,i)}catch (e14){}}function re(){if(U(!0),te())p=[],E=[],w();else{if(m&&E.length>0){let r=E;E=[],r.forEach(ne)}p.length>0&&x()}}function P(){if(!H)return!1;let r=t.navigator;return r&&(r.globalPrivacyControl===!0||r.webdriver===!0)?!1:!te()}function w(){h!==null&&clearTimeout(h),h=null}function Be(){h===null&&(h=setTimeout(()=>{h=null,x()},Ke),_optionalChain([h, 'access', _19 => _19.unref, 'optionalCall', _20 => _20()]))}function Ne(r){try{if(typeof fetch=="function"){fetch(s,{method:"POST",body:r,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{});return}}catch (e15){}try{let f=t.navigator;f&&typeof f.sendBeacon=="function"&&f.sendBeacon(s,new Blob([r],{type:"text/plain"}))}catch (e16){}}function x(r=!1){try{if(w(),p.length===0)return;if(!P()){p=[];return}if(!m)return;U(m);let f=N(t,i),d=f?p.map(k=>({...k,client_id:f})):p;p=[],Je(i,d,r).forEach(k=>Ne(k.body))}catch (e17){}}function oe(r,f,d){if(!P())return;let k=_chunkXIHGWNTSjs.g.call(void 0, r,f);if(!k.ok){a("dropped",r,k.reason);return}let se=_chunkXIHGWNTSjs.d.call(void 0, t.location.href),K={event_id:_optionalChain([d, 'optionalAccess', _21 => _21.event_id])&&xe.test(d.event_id)?d.event_id:Ye(),event:r,ts:Date.now(),schema_version:1,env:j,source:u,channel:l,sdk:b,page_id:M,page_type:_optionalChain([d, 'optionalAccess', _22 => _22.page_type])!==void 0?d.page_type:ee,host:_nullishCoalesce(_optionalChain([se, 'optionalAccess', _23 => _23.host]), () => (null)),path:_optionalChain([d, 'optionalAccess', _24 => _24.path])?_chunkXIHGWNTSjs.c.call(void 0, d.path.split(/[?#]/)[0]):_nullishCoalesce(_optionalChain([se, 'optionalAccess', _25 => _25.path]), () => (null)),referrer_host:Le,utm_source:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _26 => _26.utm_source]), () => (null)),utm_medium:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _27 => _27.utm_medium]), () => (null)),utm_campaign:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _28 => _28.utm_campaign]), () => (null)),utm_content:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _29 => _29.utm_content]), () => (null)),utm_term:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _30 => _30.utm_term]), () => (null)),ref_code:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _31 => _31.ref_code]), () => (null)),product_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _32 => _32.product_id]), () => (null)),variant_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _33 => _33.variant_id]), () => (null)),order_ref:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _34 => _34.order_ref]), () => (null)),props:k.props};_optionalChain([d, 'optionalAccess', _35 => _35.event_id])&&!xe.test(d.event_id)&&a("ignored invalid event_id",r),u==="dashboard"&&e.visitorId&&(K.visitor_id=e.visitorId);let ce=_chunkXIHGWNTSjs.h.call(void 0, K);if(!ce.ok){a("dropped",r,ce.reason);return}let G=K;m?ne(G):E.push(G),p.push(G),p.length>=Ge?x():Be()}let ie=()=>x(!0),ae=()=>{document.visibilityState==="hidden"&&x(!0)},S=()=>re();return t.addEventListener("pagehide",ie),document.addEventListener("visibilitychange",ae),t.addEventListener("bitsnap:consent",S),t.addEventListener("bitsnap:consent:ready",S),W(),U(m),{track(r,f,d){try{oe(r,f,d)}catch (e18){}},page(r,f){try{r!==void 0&&(ee=r),oe("page_view",{landing:Re++===0},f)}catch (e19){}},clientId(r){try{return r!==void 0&&_chunkXIHGWNTSjs.b.call(void 0, r)!==i?null:P()?N(t,i):null}catch (e20){return null}},flush:()=>x(),setEnabled(r){H=!!r,H||(p=[],E=[],w())},configure(r){try{(r.env==="live"||r.env==="test")&&(j=r.env),typeof r.endpoint=="string"&&r.endpoint&&(s=c(r.endpoint))}catch (e21){}},onEvent(r){return C.add(r),()=>void C.delete(r)},destroy(){p=[],E=[],w(),C.clear(),t.removeEventListener("pagehide",ie),document.removeEventListener("visibilitychange",ae),t.removeEventListener("bitsnap:consent",S),t.removeEventListener("bitsnap:consent:ready",S)}}}var v,O=null;function D(e){if(!v){let t=Xe(e);return t===y||(v=t,O=_chunkXIHGWNTSjs.b.call(void 0, _nullishCoalesce(e.projectKey, () => ("")))),t}try{let t=_chunkXIHGWNTSjs.b.call(void 0, _nullishCoalesce(e.projectKey, () => ("")));t!==O&&e.debug&&console.warn("[bitsnap analytics]","tracker already started for another projectKey, ignoring",e.projectKey),t===O&&((e.env||e.endpoint)&&v.configure({env:e.env,endpoint:e.endpoint}),e.enabled!=null&&v.setEnabled(e.enabled))}catch (e22){}return v}function Ae(){return v}function xt(){typeof window<"u"&&ge(window),_optionalChain([v, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]),v=void 0,O=null}function _t(e){try{if(typeof window>"u")return{};let t=v,n=null;if(t)n=t.clientId(e);else{let o=e?_chunkXIHGWNTSjs.b.call(void 0, e):null;n=o?N(window,o):null}return n?{[me]:n}:{}}catch (e23){return{}}}var _react = require('react');var nt={track:y.track,page:y.page},Pe=_react.createContext.call(void 0, nt);function St({projectKey:e,env:t,enabled:n,endpoint:o,onEvent:a,autoPageViews:i,children:c}){let s=_react.useMemo.call(void 0, ()=>D({projectKey:e,env:t,endpoint:o,enabled:n}),[e,t,o]),u=_react.useRef.call(void 0, a);u.current=a,_chunkXIHGWNTSjs.p.call(void 0, ()=>{s.setEnabled(n!==!1)},[s,n]),_chunkXIHGWNTSjs.p.call(void 0, ()=>{if(!(i===!1||n===!1||s===y))return A(()=>s.page(null))},[s,i,n]),_chunkXIHGWNTSjs.p.call(void 0, ()=>s.onEvent(b=>_optionalChain([u, 'access', _38 => _38.current, 'optionalCall', _39 => _39(b)])),[s]);let l=_react.useMemo.call(void 0, ()=>({track:s.track.bind(s),page:s.page.bind(s)}),[s]);return _react.createElement.call(void 0, Pe.Provider,{value:l},c)}function we(){return _react.useContext.call(void 0, Pe)}var $={track(){}},X=null;function lt(e){let t=Symbol("bitsnap-instrument");function n(){if(typeof window>"u")return null;let{projectKey:i,analytics:c,provided:s}=e();return c===!1?null:s||(i?D({projectKey:i,source:"sdk_react",channel:"embed",env:typeof c=="object"?c.env:void 0}):null)}let o={track(i,c,s){try{let u=n();if(!u)return;let{analytics:l,pageType:b}=e(),M=b&&_optionalChain([s, 'optionalAccess', _40 => _40.page_type])===void 0?{...s,page_type:b}:s;X=typeof l=="object"&&l.onEvent?t:null,u.track(i,c,M)}catch (e24){}finally{X=null}}};function a(){try{if(!n())return()=>{};let i=Ae();if(!i)return()=>{};let c=e().provided?()=>{}:A(()=>i.page(_nullishCoalesce(e().pageType, () => (null)))),s=i.onEvent(u=>{if(X===t)try{let{analytics:l}=e();typeof l=="object"&&_optionalChain([l, 'access', _41 => _41.onEvent, 'optionalCall', _42 => _42(u)])}catch (e25){}});return()=>{c(),s()}}catch (e26){return()=>{}}}return{instrument:o,attach:a}}var Z=_react.createContext.call(void 0, null);function Nt({value:e,children:t}){return _react.createElement.call(void 0, Z.Provider,{value:e},t)}function Ot(){return _nullishCoalesce(_react.useContext.call(void 0, Z), () => ($))}function Dt(e,t,n){let o=_react.useContext.call(void 0, Z),a=we(),i=a.track===y.track?null:a,c=_react.useRef.call(void 0, {projectKey:e,analytics:t,pageType:n,provided:i});c.current={projectKey:e,analytics:t,pageType:n,provided:i};let s=_react.useMemo.call(void 0, ()=>lt(()=>c.current),[]),u=t===void 0&&o!==null,l=typeof t=="object"&&!!t.onEvent;return _react.useLayoutEffect.call(void 0, ()=>{if(!u)return s.attach()},[s,u,l,e]),u?o:s.instrument}var Q=$;function Se(e){Q=_nullishCoalesce(e, () => ($))}var q=0;function $t(){return q>0?$:Q}async function Mt(e){q++;try{return await e()}finally{q--}}function jt(e){_react.useEffect.call(void 0, ()=>(Se(e),()=>{Q===e&&Se(null)}),[e])}function Ht(e){let t=Number.isFinite(e)?Math.max(0,Math.min(100,e)):0;return t>=100?"100":t>=75?"75-99":t>=50?"50-74":t>=25?"25-49":"0-24"}function Wt(e,t){let n=[];for(let o of[25,50,75,100])e>=o&&!t.has(o)&&(t.add(o),n.push(o));return n}exports.a = ve; exports.b = A; exports.c = Ue; exports.d = Xe; exports.e = D; exports.f = Ae; exports.g = xt; exports.h = _t; exports.i = St; exports.j = we; exports.k = $; exports.l = Nt; exports.m = Ot; exports.n = Dt; exports.o = $t; exports.p = Mt; exports.q = jt; exports.r = Ht; exports.s = Wt;
2
- //# sourceMappingURL=chunk-WGJTXDIS.js.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkXIHGWNTSjs = require('./chunk-XIHGWNTS.js');var Oe=Symbol.for("bitsnap.pageViews");function ye(e){let t=e;return t[Oe]??={path:null,starters:new Set,watching:!1}}function De(e,t){let n=()=>{try{t()}catch (e2){}};for(let o of["pushState","replaceState"]){let a=e.history[o];e.history[o]=function(...i){let c=a.apply(this,i);return n(),c}}e.addEventListener("popstate",n)}function A(e,t=window){try{let n=ye(t),o=()=>e();n.watching||(n.watching=!0,De(t,()=>{let i=t.location.pathname;i===n.path||n.starters.size===0||(n.path=i,_optionalChain([n, 'access', _2 => _2.starters, 'access', _3 => _3.values, 'call', _4 => _4(), 'access', _5 => _5.next, 'call', _6 => _6(), 'access', _7 => _7.value, 'optionalCall', _8 => _8()]))})),n.starters.add(o);let a=t.location.pathname;return a!==n.path&&(n.path=a,o()),()=>void n.starters.delete(o)}catch (e3){return()=>{}}}function ge(e=window){let t=ye(e);t.path=null,t.starters.clear()}var ve="1.12.1";function I(e){let t=new Uint8Array(e),n=typeof crypto<"u"?crypto:void 0;if(n&&typeof n.getRandomValues=="function")n.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);return t}var me="X-Bitsnap-Visitor",$e=390*24*60*60,Me=/^[A-Za-z0-9_-]{22}$/;function R(e){return e.BitsnapConsent}function je(e,t){for(let n of e.cookie.split(";")){let o=n.indexOf("=");if(o!==-1&&n.slice(0,o).trim()===t)return n.slice(o+1).trim()}return null}function He(e){let t=e.toLowerCase();return t==="bitsnap.pl"||t.endsWith(".bitsnap.pl")}function F(e,t){try{let n=R(e);if(!n)return!1;if(n.scope==="project")return n.projectKey===t;let o=He(e.location.hostname);return n.scope==="global"?!o:!1}catch (e4){return!1}}function J(e,t){try{return _optionalChain([R, 'call', _9 => _9(e), 'optionalAccess', _10 => _10.get, 'call', _11 => _11(), 'optionalAccess', _12 => _12.c, 'access', _13 => _13.analytics])===!0&&F(e,t)}catch (e5){return!1}}function he(){let e="";return I(16).forEach(t=>e+=String.fromCharCode(t)),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ee(e,t){try{return je(e,_chunkXIHGWNTSjs.f.call(void 0, t))}catch (e6){return null}}function B(e,t){let n=Ee(e,t);return n!==null&&Me.test(n)?n:null}function ke(e,t,n){try{let o=e.document,a=`${_chunkXIHGWNTSjs.f.call(void 0, t)}=${n}; Max-Age=${$e}; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");for(let i of _chunkXIHGWNTSjs.n.call(void 0, e.location.hostname).reverse())if(o.cookie=`${a}; Domain=${i}`,B(o,t)===n)return;o.cookie=a}catch (e7){}}function be(e,t){try{let n=e.document;if(Ee(n,t)===null)return;let o=`${_chunkXIHGWNTSjs.f.call(void 0, t)}=; Max-Age=0; Path=/; SameSite=Lax`+(e.location.protocol==="https:"?"; Secure":"");n.cookie=o;for(let a of _chunkXIHGWNTSjs.n.call(void 0, e.location.hostname))n.cookie=`${o}; Domain=${a}`}catch (e8){}}function N(e,t){try{let n=e.navigator;return _optionalChain([n, 'optionalAccess', _14 => _14.globalPrivacyControl])===!0||_optionalChain([n, 'optionalAccess', _15 => _15.webdriver])===!0?null:J(e,t)?B(e.document,t):null}catch (e9){return null}}var Ue="https://collect.bitsnap.pl",Ke=5e3,Ge=20,Te=32*1024,ze=60*1024,xe=/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function _e(e){return typeof TextEncoder=="function"?new TextEncoder().encode(e).length:unescape(encodeURIComponent(e)).length}var y={track(){},page(){},clientId:()=>null,flush(){},setEnabled(){},onEvent:()=>()=>{},configure(){},destroy(){}};function Ye(e=Date.now()){let t=I(16),n=e;for(let a=5;a>=0;a--)t[a]=n%256,n=Math.floor(n/256);t[6]=t[6]&15|112,t[8]=t[8]&63|128;let o=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";function Fe(){return Array.from(I(16),e=>Ce[e%Ce.length]).join("")}function Je(e,t,n=!1){let o=_e(JSON.stringify({k:e,events:[]})),a=[],i=[],c=o,s=()=>{i.length>0&&a.push({body:JSON.stringify({k:e,events:i}),bytes:c,count:i.length}),i=[],c=o};for(let u of t){let l=_e(JSON.stringify(u));o+l>Te||((i.length>=_chunkXIHGWNTSjs.a.maxBatchEvents||c+l+(i.length>0?1:0)>Te)&&s(),c+=l+(i.length>0?1:0),i.push(u))}if(s(),n){let u=0,l=a.length;for(;l>0&&u+a[l-1].bytes<=ze;)u+=a[l-1].bytes,l--;a=a.slice(l)}return a}function Xe(e){try{return typeof window>"u"||typeof document>"u"?y:qe(e,window)}catch (e10){return y}}function qe(e,t){let n=_chunkXIHGWNTSjs.b.call(void 0, _nullishCoalesce(e.projectKey, () => (""))),o=!!e.debug,a=(...r)=>{o&&console.warn("[bitsnap analytics]",...r)};if(!n)return a("invalid projectKey, tracking is off"),y;let i=n,c=r=>`${(r||Ue).replace(/\/+$/,"")}/e`,s=c(e.endpoint),u=_nullishCoalesce(e.source, () => ("sdk_react")),l=_nullishCoalesce(e.channel, () => ("embed")),b=`bitsnap-react@${ve}`,M=Fe(),T=_chunkXIHGWNTSjs.d.call(void 0, t.location.href),j=_nullishCoalesce(e.env, () => ("live"));if(!e.env)try{new URLSearchParams(t.location.search).has("test")&&(j="test")}catch (e11){}let Le=_chunkXIHGWNTSjs.e.call(void 0, document.referrer),H=e.enabled!==!1,ee=null,Re=0,p=[],h=null,C=new Set;e.onEvent&&C.add(e.onEvent);let E=[],g,m=!0;function W(){let r=R(t);!r||r===g||(g=r,m=!r.ready,_optionalChain([r, 'access', _16 => _16.ready, 'optionalAccess', _17 => _17.then, 'call', _18 => _18(()=>{g===r&&(m=!0,re())},()=>{g===r&&(m=!0)})]))}function te(){W();try{if(!g)return!1;let r=g.get();return!!g.denied&&g.denied("analytics")||!!r&&r.c.analytics===!1}catch (e12){return!1}}function ne(r){C.forEach(f=>{try{f(r)}catch (e13){}})}function U(r){try{if(W(),!g||!F(t,i))return;J(t,i)?P()&&B(t.document,i)===null&&ke(t,i,he()):r&&be(t,i)}catch (e14){}}function re(){if(U(!0),te())p=[],E=[],w();else{if(m&&E.length>0){let r=E;E=[],r.forEach(ne)}p.length>0&&x()}}function P(){if(!H)return!1;let r=t.navigator;return r&&(r.globalPrivacyControl===!0||r.webdriver===!0)?!1:!te()}function w(){h!==null&&clearTimeout(h),h=null}function Be(){h===null&&(h=setTimeout(()=>{h=null,x()},Ke),_optionalChain([h, 'access', _19 => _19.unref, 'optionalCall', _20 => _20()]))}function Ne(r){try{if(typeof fetch=="function"){fetch(s,{method:"POST",body:r,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{});return}}catch (e15){}try{let f=t.navigator;f&&typeof f.sendBeacon=="function"&&f.sendBeacon(s,new Blob([r],{type:"text/plain"}))}catch (e16){}}function x(r=!1){try{if(w(),p.length===0)return;if(!P()){p=[];return}if(!m)return;U(m);let f=N(t,i),d=f?p.map(k=>({...k,client_id:f})):p;p=[],Je(i,d,r).forEach(k=>Ne(k.body))}catch (e17){}}function oe(r,f,d){if(!P())return;let k=_chunkXIHGWNTSjs.g.call(void 0, r,f);if(!k.ok){a("dropped",r,k.reason);return}let se=_chunkXIHGWNTSjs.d.call(void 0, t.location.href),K={event_id:_optionalChain([d, 'optionalAccess', _21 => _21.event_id])&&xe.test(d.event_id)?d.event_id:Ye(),event:r,ts:Date.now(),schema_version:1,env:j,source:u,channel:l,sdk:b,page_id:M,page_type:_optionalChain([d, 'optionalAccess', _22 => _22.page_type])!==void 0?d.page_type:ee,host:_nullishCoalesce(_optionalChain([se, 'optionalAccess', _23 => _23.host]), () => (null)),path:_optionalChain([d, 'optionalAccess', _24 => _24.path])?_chunkXIHGWNTSjs.c.call(void 0, d.path.split(/[?#]/)[0]):_nullishCoalesce(_optionalChain([se, 'optionalAccess', _25 => _25.path]), () => (null)),referrer_host:Le,utm_source:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _26 => _26.utm_source]), () => (null)),utm_medium:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _27 => _27.utm_medium]), () => (null)),utm_campaign:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _28 => _28.utm_campaign]), () => (null)),utm_content:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _29 => _29.utm_content]), () => (null)),utm_term:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _30 => _30.utm_term]), () => (null)),ref_code:_nullishCoalesce(_optionalChain([T, 'optionalAccess', _31 => _31.ref_code]), () => (null)),product_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _32 => _32.product_id]), () => (null)),variant_id:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _33 => _33.variant_id]), () => (null)),order_ref:_nullishCoalesce(_optionalChain([d, 'optionalAccess', _34 => _34.order_ref]), () => (null)),props:k.props};_optionalChain([d, 'optionalAccess', _35 => _35.event_id])&&!xe.test(d.event_id)&&a("ignored invalid event_id",r),u==="dashboard"&&e.visitorId&&(K.visitor_id=e.visitorId);let ce=_chunkXIHGWNTSjs.h.call(void 0, K);if(!ce.ok){a("dropped",r,ce.reason);return}let G=K;m?ne(G):E.push(G),p.push(G),p.length>=Ge?x():Be()}let ie=()=>x(!0),ae=()=>{document.visibilityState==="hidden"&&x(!0)},S=()=>re();return t.addEventListener("pagehide",ie),document.addEventListener("visibilitychange",ae),t.addEventListener("bitsnap:consent",S),t.addEventListener("bitsnap:consent:ready",S),W(),U(m),{track(r,f,d){try{oe(r,f,d)}catch (e18){}},page(r,f){try{r!==void 0&&(ee=r),oe("page_view",{landing:Re++===0},f)}catch (e19){}},clientId(r){try{return r!==void 0&&_chunkXIHGWNTSjs.b.call(void 0, r)!==i?null:P()?N(t,i):null}catch (e20){return null}},flush:()=>x(),setEnabled(r){H=!!r,H||(p=[],E=[],w())},configure(r){try{(r.env==="live"||r.env==="test")&&(j=r.env),typeof r.endpoint=="string"&&r.endpoint&&(s=c(r.endpoint))}catch (e21){}},onEvent(r){return C.add(r),()=>void C.delete(r)},destroy(){p=[],E=[],w(),C.clear(),t.removeEventListener("pagehide",ie),document.removeEventListener("visibilitychange",ae),t.removeEventListener("bitsnap:consent",S),t.removeEventListener("bitsnap:consent:ready",S)}}}var v,O=null;function D(e){if(!v){let t=Xe(e);return t===y||(v=t,O=_chunkXIHGWNTSjs.b.call(void 0, _nullishCoalesce(e.projectKey, () => ("")))),t}try{let t=_chunkXIHGWNTSjs.b.call(void 0, _nullishCoalesce(e.projectKey, () => ("")));t!==O&&e.debug&&console.warn("[bitsnap analytics]","tracker already started for another projectKey, ignoring",e.projectKey),t===O&&((e.env||e.endpoint)&&v.configure({env:e.env,endpoint:e.endpoint}),e.enabled!=null&&v.setEnabled(e.enabled))}catch (e22){}return v}function Ae(){return v}function xt(){typeof window<"u"&&ge(window),_optionalChain([v, 'optionalAccess', _36 => _36.destroy, 'call', _37 => _37()]),v=void 0,O=null}function _t(e){try{if(typeof window>"u")return{};let t=v,n=null;if(t)n=t.clientId(e);else{let o=e?_chunkXIHGWNTSjs.b.call(void 0, e):null;n=o?N(window,o):null}return n?{[me]:n}:{}}catch (e23){return{}}}var _react = require('react');var nt={track:y.track,page:y.page},Pe=_react.createContext.call(void 0, nt);function St({projectKey:e,env:t,enabled:n,endpoint:o,onEvent:a,autoPageViews:i,children:c}){let s=_react.useMemo.call(void 0, ()=>D({projectKey:e,env:t,endpoint:o,enabled:n}),[e,t,o]),u=_react.useRef.call(void 0, a);u.current=a,_chunkXIHGWNTSjs.p.call(void 0, ()=>{s.setEnabled(n!==!1)},[s,n]),_chunkXIHGWNTSjs.p.call(void 0, ()=>{if(!(i===!1||n===!1||s===y))return A(()=>s.page(null))},[s,i,n]),_chunkXIHGWNTSjs.p.call(void 0, ()=>s.onEvent(b=>_optionalChain([u, 'access', _38 => _38.current, 'optionalCall', _39 => _39(b)])),[s]);let l=_react.useMemo.call(void 0, ()=>({track:s.track.bind(s),page:s.page.bind(s)}),[s]);return _react.createElement.call(void 0, Pe.Provider,{value:l},c)}function we(){return _react.useContext.call(void 0, Pe)}var $={track(){}},X=null;function lt(e){let t=Symbol("bitsnap-instrument");function n(){if(typeof window>"u")return null;let{projectKey:i,analytics:c,provided:s}=e();return c===!1?null:s||(i?D({projectKey:i,source:"sdk_react",channel:"embed",env:typeof c=="object"?c.env:void 0}):null)}let o={track(i,c,s){try{let u=n();if(!u)return;let{analytics:l,pageType:b}=e(),M=b&&_optionalChain([s, 'optionalAccess', _40 => _40.page_type])===void 0?{...s,page_type:b}:s;X=typeof l=="object"&&l.onEvent?t:null,u.track(i,c,M)}catch (e24){}finally{X=null}}};function a(){try{if(!n())return()=>{};let i=Ae();if(!i)return()=>{};let c=e().provided?()=>{}:A(()=>i.page(_nullishCoalesce(e().pageType, () => (null)))),s=i.onEvent(u=>{if(X===t)try{let{analytics:l}=e();typeof l=="object"&&_optionalChain([l, 'access', _41 => _41.onEvent, 'optionalCall', _42 => _42(u)])}catch (e25){}});return()=>{c(),s()}}catch (e26){return()=>{}}}return{instrument:o,attach:a}}var Z=_react.createContext.call(void 0, null);function Nt({value:e,children:t}){return _react.createElement.call(void 0, Z.Provider,{value:e},t)}function Ot(){return _nullishCoalesce(_react.useContext.call(void 0, Z), () => ($))}function Dt(e,t,n){let o=_react.useContext.call(void 0, Z),a=we(),i=a.track===y.track?null:a,c=_react.useRef.call(void 0, {projectKey:e,analytics:t,pageType:n,provided:i});c.current={projectKey:e,analytics:t,pageType:n,provided:i};let s=_react.useMemo.call(void 0, ()=>lt(()=>c.current),[]),u=t===void 0&&o!==null,l=typeof t=="object"&&!!t.onEvent;return _react.useLayoutEffect.call(void 0, ()=>{if(!u)return s.attach()},[s,u,l,e]),u?o:s.instrument}var Q=$;function Se(e){Q=_nullishCoalesce(e, () => ($))}var q=0;function $t(){return q>0?$:Q}async function Mt(e){q++;try{return await e()}finally{q--}}function jt(e){_react.useEffect.call(void 0, ()=>(Se(e),()=>{Q===e&&Se(null)}),[e])}function Ht(e){let t=Number.isFinite(e)?Math.max(0,Math.min(100,e)):0;return t>=100?"100":t>=75?"75-99":t>=50?"50-74":t>=25?"25-49":"0-24"}function Wt(e,t){let n=[];for(let o of[25,50,75,100])e>=o&&!t.has(o)&&(t.add(o),n.push(o));return n}exports.a = ve; exports.b = A; exports.c = Ue; exports.d = Xe; exports.e = D; exports.f = Ae; exports.g = xt; exports.h = _t; exports.i = St; exports.j = we; exports.k = $; exports.l = Nt; exports.m = Ot; exports.n = Dt; exports.o = $t; exports.p = Mt; exports.q = jt; exports.r = Ht; exports.s = Wt;
2
+ //# sourceMappingURL=chunk-HDLCLZOK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-HDLCLZOK.js","../src/analytics/pageviews.ts","../src/version.ts","../src/analytics/random.ts","../src/analytics/visitor.ts"],"names":["REGISTRY","registry","win","holder","watchNavigation","onChange","check","name","original","args","result","startAutoPageViews","send","reg","starter","path","resetAutoPageViews","SDK_VERSION","randomBytes","n","bytes","c","i","VISITOR_HEADER","MAX_AGE_SECONDS","VISITOR_ID_RE","consentApi","readCookie","doc","part","index","isBitsnapHost","hostname","host","consentBelongsTo","projectKey","api","onBitsnap","analyticsGranted","newVisitorId","binary","byte","rawVisitorCookie","clientIdCookieName","readVisitorCookie","value","writeVisitorCookie","id","base"],"mappings":"AAAA,uuBAA2G,ICYrGA,EAAAA,CAAW,MAAA,CAAO,GAAA,CAAI,mBAAmB,CAAA,CAE/C,SAASC,EAAAA,CAASC,CAAAA,CAAuB,CACvC,IAAMC,CAAAA,CAASD,CAAAA,CACf,OAAQC,CAAAA,CAAOH,EAAQ,CAAA,GAAM,CAAE,IAAA,CAAM,IAAA,CAAM,QAAA,CAAU,IAAI,GAAA,CAAO,QAAA,CAAU,CAAA,CAAM,CAClF,CAGA,SAASI,EAAAA,CAAgBF,CAAAA,CAAaG,CAAAA,CAAsB,CAC1D,IAAMC,CAAAA,CAAQ,CAAA,CAAA,EAAM,CAClB,GAAI,CACFD,CAAAA,CAAS,CACX,CAAA,UAAQ,CAAC,CACX,CAAA,CACA,GAAA,CAAA,IAAWE,EAAAA,EAAQ,CAAC,WAAA,CAAa,cAAc,CAAA,CAAY,CACzD,IAAMC,CAAAA,CAAWN,CAAAA,CAAI,OAAA,CAAQK,CAAI,CAAA,CACjCL,CAAAA,CAAI,OAAA,CAAQK,CAAI,CAAA,CAAI,QAAA,CAAA,GAA4BE,CAAAA,CAAwC,CACtF,IAAMC,CAAAA,CAASF,CAAAA,CAAS,KAAA,CAAM,IAAA,CAAMC,CAAI,CAAA,CACxC,OAAAH,CAAAA,CAAM,CAAA,CACCI,CACT,CACF,CACAR,CAAAA,CAAI,gBAAA,CAAiB,UAAA,CAAYI,CAAK,CACxC,CAQO,SAASK,CAAAA,CAAmBC,CAAAA,CAAkBV,CAAAA,CAAc,MAAA,CAAoB,CAC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/E,CAGA,SAASE,EAAAA,CAAiBd,CAAAA,CAAeO,CAAAA,CAAmC,CAC1E,GAAI,CACF,OAAOR,EAAAA,CAAWC,CAAAA,CAAKe,gCAAAA,CAA6B,CAAC,CACvD,CAAA,UAAQ,CACN,OAAO,IACT,CACF,CAGO,SAASC,CAAAA,CAAkBhB,CAAAA,CAAeO,CAAAA,CAAmC,CAClF,IAAMU,CAAAA,CAAQH,EAAAA,CAAiBd,CAAAA,CAAKO,CAAU,CAAA,CAC9C,OAAOU,CAAAA,GAAU,IAAA,EAAQpB,EAAAA,CAAc,IAAA,CAAKoB,CAAK,CAAA,CAAIA,CAAAA,CAAQ,IAC/D,CAOO,SAASC,EAAAA,CAAmB5C,CAAAA,CAAaiC,CAAAA,CAAoBY,CAAAA,CAAkB,CACpF,GAAI,CACF,IAAMnB,CAAAA,CAAM1B,CAAAA,CAAI,QAAA,CACV8C,CAAAA,CACJ,CAAA,EAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-HDLCLZOK.js","sourcesContent":[null,"/**\n * Page-wide state of the automatic page views. It lives on `window`, so the\n * npm package, a second copy of it and the `analytics.js` script agree on who\n * reports a path and the history is patched once.\n */\ntype Registry = {\n /** Last path some starter reported. */\n path: string | null;\n starters: Set<() => void>;\n watching: boolean;\n};\n\nconst REGISTRY = Symbol.for(\"bitsnap.pageViews\");\n\nfunction registry(win: Window): Registry {\n const holder = win as unknown as Record<symbol, Registry | undefined>;\n return (holder[REGISTRY] ??= { path: null, starters: new Set(), watching: false });\n}\n\n/** Calls `onChange` when the path changes through `history.pushState`/`replaceState` or Back/Forward. */\nfunction watchNavigation(win: Window, onChange: () => void) {\n const check = () => {\n try {\n onChange();\n } catch {}\n };\n for (const name of [\"pushState\", \"replaceState\"] as const) {\n const original = win.history[name];\n win.history[name] = function (this: History, ...args: Parameters<History[typeof name]>) {\n const result = original.apply(this, args);\n check();\n return result;\n };\n }\n win.addEventListener(\"popstate\", check);\n}\n\n/**\n * Calls `send` for the current path and again on every path change, unless\n * another starter on the page already reported that path: the page gets one\n * `page_view` per path change however many providers, components and embeds\n * start it. Returns the function that stops this starter.\n */\nexport function startAutoPageViews(send: () => void, win: Window = window): () => void {\n try {\n const reg = registry(win);\n const starter = () => send();\n if (!reg.watching) {\n reg.watching = true;\n watchNavigation(win, () => {\n const path = win.location.pathname;\n // Nobody listening: leave the path unreported so the next starter sends it.\n if (path === reg.path || reg.starters.size === 0) return;\n reg.path = path;\n reg.starters.values().next().value?.();\n });\n }\n reg.starters.add(starter);\n const path = win.location.pathname;\n if (path !== reg.path) {\n reg.path = path;\n starter();\n }\n return () => void reg.starters.delete(starter);\n } catch {\n return () => {};\n }\n}\n\n/** Forgets the reported path and the starters (tests, hot reload). The history patch stays. */\nexport function resetAutoPageViews(win: Window = window) {\n const reg = registry(win);\n reg.path = null;\n reg.starters.clear();\n}\n","// Generated by scripts/write-version.mjs from package.json. Do not edit.\nexport const SDK_VERSION = \"1.12.1\";\n","export function randomBytes(n: number): Uint8Array {\n const bytes = new Uint8Array(n);\n const c = typeof crypto !== \"undefined\" ? crypto : undefined;\n if (c && typeof c.getRandomValues === \"function\") c.getRandomValues(bytes);\n else for (let i = 0; i < n; i++) bytes[i] = Math.floor(Math.random() * 256);\n return bytes;\n}\n","import { domainCandidates } from \"../consent/core/cookie\";\nimport { clientIdCookieName } from \"./contract\";\nimport { randomBytes } from \"./random\";\n\n/** The part of `window.BitsnapConsent` (`bitsnap-react/consent`) the tracker reads. */\nexport type ConsentLike = {\n /** Absent on a consent script older than 1.9.0, which never counts as the project's banner. */\n scope?: \"global\" | \"project\";\n projectKey?: string | null;\n get(): { c: { analytics?: boolean } } | null;\n /** Also true for a refusal made on an older banner version, which `get()` no longer returns. */\n denied?(category: \"analytics\"): boolean;\n ready?: Promise<unknown>;\n};\n\n/** Sent to the Bitsnap server on the requests that create a checkout or payment link. */\nexport const VISITOR_HEADER = \"X-Bitsnap-Visitor\";\n// 390 days, under the 13 months CNIL allows. Set once, never extended.\nconst MAX_AGE_SECONDS = 390 * 24 * 60 * 60;\nconst VISITOR_ID_RE = /^[A-Za-z0-9_-]{22}$/;\n\nexport function consentApi(win: Window): ConsentLike | undefined {\n return (win as unknown as { BitsnapConsent?: ConsentLike }).BitsnapConsent;\n}\n\nfunction readCookie(doc: Document, name: string): string | null {\n for (const part of doc.cookie.split(\";\")) {\n const index = part.indexOf(\"=\");\n if (index !== -1 && part.slice(0, index).trim() === name) return part.slice(index + 1).trim();\n }\n return null;\n}\n\n/** bitsnap.pl and its subdomains: many merchants share them, and the site-wide choice is bitsnap's own. */\nfunction isBitsnapHost(hostname: string): boolean {\n const host = hostname.toLowerCase();\n return host === \"bitsnap.pl\" || host.endsWith(\".bitsnap.pl\");\n}\n\n/**\n * Whether the page's consent banner speaks for `projectKey`: a project-scope banner of that\n * key, or a site-scope banner on a merchant's own site. On bitsnap.pl a site-scope choice is\n * bitsnap's own, so only a project-scope one counts.\n */\nexport function consentBelongsTo(win: Window, projectKey: string): boolean {\n try {\n const api = consentApi(win);\n if (!api) return false;\n if (api.scope === \"project\") return api.projectKey === projectKey;\n const onBitsnap = isBitsnapHost(win.location.hostname);\n if (api.scope === \"global\") return !onBitsnap;\n // A consent script from before the scope info: it cannot be told apart from another project's banner.\n return false;\n } catch {\n return false;\n }\n}\n\n/** `true` only while a banner that speaks for `projectKey` holds a valid choice that grants `analytics`. */\nexport function analyticsGranted(win: Window, projectKey: string): boolean {\n try {\n return consentApi(win)?.get()?.c.analytics === true && consentBelongsTo(win, projectKey);\n } catch {\n return false;\n }\n}\n\n/** 16 random bytes as 22 base64url characters. */\nexport function newVisitorId(): string {\n let binary = \"\";\n randomBytes(16).forEach((byte) => (binary += String.fromCharCode(byte)));\n return btoa(binary).replace(/\\+/g, \"-\").replace(/\\//g, \"_\").replace(/=+$/, \"\");\n}\n\n/** Value of the `bs_vid_<projectKey>` cookie, whatever it holds; `null` when it is absent. */\nfunction rawVisitorCookie(doc: Document, projectKey: string): string | null {\n try {\n return readCookie(doc, clientIdCookieName(projectKey));\n } catch {\n return null;\n }\n}\n\n/** The project's client id from its first-party cookie (`bs_vid_<projectKey>`), or `null` if absent or malformed. */\nexport function readVisitorCookie(doc: Document, projectKey: string): string | null {\n const value = rawVisitorCookie(doc, projectKey);\n return value !== null && VISITOR_ID_RE.test(value) ? value : null;\n}\n\n/**\n * Sets the cookie on the widest registrable domain the browser accepts\n * (shortest suffix with two labels first, so `shop.example.co.uk` skips the\n * refused `co.uk`), host-only where no domain sticks (localhost, IP hosts).\n */\nexport function writeVisitorCookie(win: Window, projectKey: string, id: string): void {\n try {\n const doc = win.document;\n const base =\n `${clientIdCookieName(projectKey)}=${id}; Max-Age=${MAX_AGE_SECONDS}; Path=/; SameSite=Lax` +\n (win.location.protocol === \"https:\" ? \"; Secure\" : \"\");\n for (const domain of domainCandidates(win.location.hostname).reverse()) {\n doc.cookie = `${base}; Domain=${domain}`;\n if (readVisitorCookie(doc, projectKey) === id) return;\n }\n doc.cookie = base;\n } catch {\n // cookies blocked (sandboxed frame)\n }\n}\n\n/** Expires the cookie on the host and on every parent domain it may have been set on. */\nexport function deleteVisitorCookie(win: Window, projectKey: string): void {\n try {\n const doc = win.document;\n // Present under any value: a malformed one must go too.\n if (rawVisitorCookie(doc, projectKey) === null) return;\n const base =\n `${clientIdCookieName(projectKey)}=; Max-Age=0; Path=/; SameSite=Lax` +\n (win.location.protocol === \"https:\" ? \"; Secure\" : \"\");\n doc.cookie = base;\n for (const domain of domainCandidates(win.location.hostname)) doc.cookie = `${base}; Domain=${domain}`;\n } catch {\n // best effort\n }\n}\n\n/**\n * The project's client id to send, or `null`: analytics consent is granted,\n * Global Privacy Control is off, the browser is not automated and the cookie exists.\n */\nexport function readVisitorId(win: Window, projectKey: string): string | null {\n try {\n const nav = win.navigator as { globalPrivacyControl?: boolean; webdriver?: boolean } | undefined;\n if (nav?.globalPrivacyControl === true || nav?.webdriver === true) return null;\n return analyticsGranted(win, projectKey) ? readVisitorCookie(win.document, projectKey) : null;\n } catch {\n return null;\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkUFIOJGJZjs = require('./chunk-UFIOJGJZ.js');var _chunkWGJTXDISjs = require('./chunk-WGJTXDIS.js');var t={projectID:void 0,loginURL:"/panel/login",theme:void 0,host:void 0,allowedReturnOrigins:[]},u=[];function w(e){t={...t,...e}}function s(){return t}function P(e){t.projectID=e}function v(e){t.theme=e}function C(e){t.loginURL=e}function R(e){t.host=e}function x(e){u=e,t={...t,allowedReturnOrigins:e}}function y(){return u}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var f=_react.createContext.call(void 0, s()),b= exports.i =({children:e,analytics:n})=>{let o=s(),i=_chunkWGJTXDISjs.n.call(void 0, o.projectID,n,"panel");return _jsxruntime.jsx.call(void 0, _chunkUFIOJGJZjs.o,{children:_jsxruntime.jsx.call(void 0, f.Provider,{value:{...o},children:_jsxruntime.jsx.call(void 0, _chunkWGJTXDISjs.l,{value:i,children:_jsxruntime.jsx.call(void 0, "div",{className:"bitsnap-react",children:e})})})})},L= exports.j =()=>_react.useContext.call(void 0, f);var l=(e,n)=>`bitsnap-panel-session:${encodeURIComponent(_nullishCoalesce(n, () => ("https://bitsnap.pl")))}:${encodeURIComponent(e)}`,a=(e,n)=>`bitsnap-panel-email:${encodeURIComponent(_nullishCoalesce(n, () => ("https://bitsnap.pl")))}:${encodeURIComponent(e)}`;function $(e,n){return typeof window>"u"||!e?void 0:_nullishCoalesce(window.localStorage.getItem(l(e,n)), () => (void 0))}function G(e,n,o,i){typeof window>"u"||!e||(window.localStorage.setItem(l(e,i),n),window.localStorage.setItem(a(e,i),o))}function k(e,n){return typeof window>"u"||!e?null:window.localStorage.getItem(a(e,n))}function E(e,n){typeof window>"u"||!e||(window.localStorage.removeItem(l(e,n)),window.localStorage.removeItem(a(e,n)))}exports.a = w; exports.b = s; exports.c = P; exports.d = v; exports.e = C; exports.f = R; exports.g = x; exports.h = y; exports.i = b; exports.j = L; exports.k = $; exports.l = G; exports.m = k; exports.n = E;
2
- //# sourceMappingURL=chunk-3IVLQILF.js.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunk4ZFIL5S7js = require('./chunk-4ZFIL5S7.js');var _chunkHDLCLZOKjs = require('./chunk-HDLCLZOK.js');var t={projectID:void 0,loginURL:"/panel/login",theme:void 0,host:void 0,allowedReturnOrigins:[]},u=[];function w(e){t={...t,...e}}function s(){return t}function P(e){t.projectID=e}function v(e){t.theme=e}function C(e){t.loginURL=e}function R(e){t.host=e}function x(e){u=e,t={...t,allowedReturnOrigins:e}}function y(){return u}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var f=_react.createContext.call(void 0, s()),b= exports.i =({children:e,analytics:n})=>{let o=s(),i=_chunkHDLCLZOKjs.n.call(void 0, o.projectID,n,"panel");return _jsxruntime.jsx.call(void 0, _chunk4ZFIL5S7js.o,{children:_jsxruntime.jsx.call(void 0, f.Provider,{value:{...o},children:_jsxruntime.jsx.call(void 0, _chunkHDLCLZOKjs.l,{value:i,children:_jsxruntime.jsx.call(void 0, "div",{className:"bitsnap-react",children:e})})})})},L= exports.j =()=>_react.useContext.call(void 0, f);var l=(e,n)=>`bitsnap-panel-session:${encodeURIComponent(_nullishCoalesce(n, () => ("https://bitsnap.pl")))}:${encodeURIComponent(e)}`,a=(e,n)=>`bitsnap-panel-email:${encodeURIComponent(_nullishCoalesce(n, () => ("https://bitsnap.pl")))}:${encodeURIComponent(e)}`;function $(e,n){return typeof window>"u"||!e?void 0:_nullishCoalesce(window.localStorage.getItem(l(e,n)), () => (void 0))}function G(e,n,o,i){typeof window>"u"||!e||(window.localStorage.setItem(l(e,i),n),window.localStorage.setItem(a(e,i),o))}function k(e,n){return typeof window>"u"||!e?null:window.localStorage.getItem(a(e,n))}function E(e,n){typeof window>"u"||!e||(window.localStorage.removeItem(l(e,n)),window.localStorage.removeItem(a(e,n)))}exports.a = w; exports.b = s; exports.c = P; exports.d = v; exports.e = C; exports.f = R; exports.g = x; exports.h = y; exports.i = b; exports.j = L; exports.k = $; exports.l = G; exports.m = k; exports.n = E;
2
+ //# sourceMappingURL=chunk-I6BRDRPB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-I6BRDRPB.js","../src/panel/config.ts","../src/panel/PanelProvider.tsx","../src/panel/session-storage.ts"],"names":["config","allowedReturnOrigins","setPanelConfig","newConfig","getPanelConfig","setProjectID","projectID","setTheme","theme","setLoginURL","loginURL","setHost","host","setAllowedReturnOrigins","origins","getAllowedReturnOrigins","PanelContext","createContext","PanelProvider","children","analytics","instrument","useInstrument","jsx","RpcProvider","InstrumentProvider","usePanelConfig","useContext","panelSessionKey"],"mappings":"AAAA,mOAAuC,sDAA+C,ICElFA,CAAAA,CAAsB,CACxB,SAAA,CAAW,KAAA,CAAA,CACX,QAAA,CAAU,cAAA,CACV,KAAA,CAAO,KAAA,CAAA,CACP,IAAA,CAAM,KAAA,CAAA,CACN,oBAAA,CAAsB,CAAC,CACzB,CAAA,CAEIC,CAAAA,CAAiC,CAAC,CAAA,CAU/B,SAASC,CAAAA,CAAeC,CAAAA,CAAuC,CACpEH,CAAAA,CAAS,CAAE,GAAGA,CAAAA,CAAQ,GAAGG,CAAU,CACrC,CAEO,SAASC,CAAAA,CAAAA,CAA8B,CAC5C,OAAOJ,CACT,CAEO,SAASK,CAAAA,CAAaC,CAAAA,CAAyB,CACpDN,CAAAA,CAAO,SAAA,CAAYM,CACrB,CAEO,SAASC,CAAAA,CAASC,CAAAA,CAA6B,CACpDR,CAAAA,CAAO,KAAA,CAAQQ,CACjB,CAEO,SAASC,CAAAA,CAAYC,CAAAA,CAAwB,CAClDV,CAAAA,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/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-I6BRDRPB.js","sourcesContent":[null,"import type { GetThemeOutput } from \"./types\";\n\nlet config: PanelConfig = {\n projectID: undefined,\n loginURL: \"/panel/login\",\n theme: undefined,\n host: undefined,\n allowedReturnOrigins: [],\n};\n\nlet allowedReturnOrigins: string[] = [];\n\nexport interface PanelConfig {\n projectID?: string;\n loginURL?: string;\n theme?: GetThemeOutput;\n host?: string;\n allowedReturnOrigins: string[];\n}\n\nexport function setPanelConfig(newConfig: Partial<PanelConfig>): void {\n config = { ...config, ...newConfig };\n}\n\nexport function getPanelConfig(): PanelConfig {\n return config;\n}\n\nexport function setProjectID(projectID: string): void {\n config.projectID = projectID;\n}\n\nexport function setTheme(theme: GetThemeOutput): void {\n config.theme = theme;\n}\n\nexport function setLoginURL(loginURL: string): void {\n config.loginURL = loginURL;\n}\n\nexport function setHost(host: string): void {\n config.host = host;\n}\n\nexport function setAllowedReturnOrigins(origins: string[]): void {\n allowedReturnOrigins = origins;\n config = { ...config, allowedReturnOrigins: origins };\n}\n\nexport function getAllowedReturnOrigins(): string[] {\n return allowedReturnOrigins;\n}\n","import { createContext, useContext } from \"react\";\nimport {\n InstrumentProvider,\n useInstrument,\n type AnalyticsOption,\n} from \"../analytics/instrument\";\nimport { RpcProvider } from \"../rpc-provider\";\nimport { getPanelConfig, type PanelConfig } from \"./config\";\n\nconst PanelContext = createContext<PanelConfig>(getPanelConfig());\n\nexport const PanelProvider: React.FC<{\n children: React.ReactNode;\n /**\n * Usage statistics for your Bitsnap dashboard (panel logins, orders viewed,\n * downloads, course progress). On by default; `false` turns it off. An\n * object lets you forward every event: `{ onEvent }`. Nothing is stored on\n * the visitor's device.\n */\n analytics?: AnalyticsOption;\n}> = ({ children, analytics }) => {\n const config = getPanelConfig();\n const instrument = useInstrument(config.projectID, analytics, \"panel\");\n return (\n <RpcProvider>\n <PanelContext.Provider value={{ ...config }}>\n <InstrumentProvider value={instrument}>\n <div className=\"bitsnap-react\">{children}</div>\n </InstrumentProvider>\n </PanelContext.Provider>\n </RpcProvider>\n );\n};\n\nexport const usePanelConfig = () => useContext(PanelContext);\n","const panelSessionKey = (projectID: string, host?: string) =>\n `bitsnap-panel-session:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nconst panelEmailKey = (projectID: string, host?: string) =>\n `bitsnap-panel-email:${encodeURIComponent(host ?? \"https://bitsnap.pl\")}:${encodeURIComponent(projectID)}`;\n\nexport function getPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return undefined;\n const token = window.localStorage.getItem(panelSessionKey(projectID, host));\n return token ?? undefined;\n}\n\nexport function savePanelSession(projectID: string | undefined, token: string, email: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.setItem(panelSessionKey(projectID, host), token);\n window.localStorage.setItem(panelEmailKey(projectID, host), email);\n}\n\nexport function getPanelEmail(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return null;\n return window.localStorage.getItem(panelEmailKey(projectID, host));\n}\n\nexport function clearPanelSession(projectID?: string, host?: string) {\n if (typeof window === \"undefined\" || !projectID) return;\n window.localStorage.removeItem(panelSessionKey(projectID, host));\n window.localStorage.removeItem(panelEmailKey(projectID, host));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-JSDGZ4NY.js"],"names":[],"mappings":"AAAA,6EAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,6BAAqB","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-JSDGZ4NY.js"}
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-JSDGZ4NY.js"],"names":[],"mappings":"AAAA,6EAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,6BAAqB","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-JSDGZ4NY.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/appearance-core.ts"],"names":["omitUndefined","tokens","result","key","value","hasAnyElement","elements","element","resolveBoundaryStyle","variables","shadcnVariables","style","token","variable","resolveAppearanceCore","appearance","config","theme","getSlotAppearance","slot"],"mappings":"AA8DO,0rBAASA,CAAAA,CACdC,CAAAA,CACgC,CAChC,IAAMC,CAAAA,CAAkC,CAAC,CAAA,CAEzC,GAAA,CAAA,GAAW,CAACC,CAAAA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,CAAK,CAAA,CACvB,mBAAGF,CAAAA,6BAAY,QACjB,CAAC,CAAA,CAEKT,CAAAA,kCAAWS,CAAAA,6BAAY,UAAA,SAAY,CAAC,GAAA,CAE1C,MAAO,CACL,KAAA,CAAAE,CAAAA,CACA,YAAA,iBACEF,CAAAA,6BAAY,OAAA,EAAS,IAAA,EACrB,MAAA,CAAO,IAAA,CAAKd,CAAM,CAAA,CAAE,MAAA,CAAS,CAAA,EAC7BI,CAAAA,CAAcC,CAAQ,CAAA,CACxB,MAAA,CAAAL,CAAAA,CACA,QAAA,CAAAK,CAAAA,CACA,aAAA,CAAeE,CAAAA,CACbP,CAAAA,CACAe,CAAAA,CAAO,SAAA,CACPA,CAAAA,CAAO,eACT,CACF,CACF,CAGO,SAASE,CAAAA,CACdZ,CAAAA,CACAa,CAAAA,CAC4B,CAC5B,OAAOb,CAAAA,CAASa,CAAI,CACtB,CAAA,6BAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-KOYBZORL.js","sourcesContent":["import type { CSSProperties } from \"react\";\n\n/**\n * Generic building blocks shared by the appearance modules (checkout, and\n * later returns). Each module supplies its own token to CSS variable map, theme\n * presets and shadcn mapping, and keeps its own public types. Everything here\n * is pure so it can be tested without a DOM.\n */\n\n/** Caller overrides for a single slot. */\nexport type SlotAppearance = {\n /** Merged after the built-in classes with `cn`, so Tailwind conflicts resolve. */\n className?: string;\n /** Merged after the built-in inline styles. */\n style?: CSSProperties;\n};\n\n/** Typed partial map of slot name to its overrides. */\nexport type AppearanceElements<Slot extends string> = Partial<\n Record<Slot, SlotAppearance>\n>;\n\n/** CSS custom property used for each token. */\nexport type TokenVariables<Token extends string> = Readonly<\n Record<Token, string>\n>;\n\n/**\n * Remaps a token onto a shadcn theme variable (`--background`, `--ring`, ...)\n * so shared UI primitives follow the module's tokens. Only written when the\n * token is in effect.\n */\nexport type ShadcnVariableMapping<Token extends string> = readonly {\n token: Token;\n variable: string;\n}[];\n\nexport type AppearanceCoreConfig<Token extends string, Theme extends string> = {\n /** Theme used when the caller does not select one. */\n defaultTheme: Theme;\n /** Partial token sets applied underneath the caller tokens. */\n presets: Record<Theme, Partial<Record<Token, string>>>;\n variables: TokenVariables<Token>;\n shadcnVariables: ShadcnVariableMapping<Token>;\n};\n\nexport type ResolvedAppearanceCore<\n Token extends string,\n Theme extends string,\n Slot extends string,\n> = {\n theme: Theme;\n /** `true` as soon as the caller passed a theme, a token or a slot override. */\n isCustomized: boolean;\n /** Tokens that are in effect. Empty entries were dropped. */\n tokens: Partial<Record<Token, string>>;\n elements: AppearanceElements<Slot>;\n /** Inline custom properties for the theme boundary. */\n boundaryStyle: CSSProperties;\n};\n\n/** Drops `undefined`/`null` tokens so unset values keep the stylesheet default. */\nexport function omitUndefined<Token extends string>(\n tokens: Partial<Record<Token, string>>,\n): Partial<Record<Token, string>> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(tokens)) {\n if (value != null) {\n result[key] = value;\n }\n }\n\n return result as Partial<Record<Token, string>>;\n}\n\nexport function hasAnyElement<Slot extends string>(\n elements: AppearanceElements<Slot>,\n): boolean {\n return Object.values<SlotAppearance | undefined>(elements).some(\n (element) =>\n element != null && (element.className != null || element.style != null),\n );\n}\n\n/**\n * Token to CSS variable resolution, followed by the shadcn remapping. Only\n * tokens that are in effect produce a variable.\n */\nexport function resolveBoundaryStyle<Token extends string>(\n tokens: Partial<Record<Token, string>>,\n variables: TokenVariables<Token>,\n shadcnVariables: ShadcnVariableMapping<Token>,\n): CSSProperties {\n const style: Record<string, string> = {};\n\n for (const [token, variable] of Object.entries<string>(variables)) {\n const value = tokens[token as Token];\n if (value != null) {\n style[variable] = value;\n }\n }\n\n for (const { token, variable } of shadcnVariables) {\n const value = tokens[token];\n if (value != null) {\n style[variable] = value;\n }\n }\n\n return style as CSSProperties;\n}\n\n/**\n * Resolves theme, tokens, slot overrides and the boundary style. The resolver\n * never invents values: a token is only present when the caller provided it or\n * selected a theme preset that carries it.\n */\nexport function resolveAppearanceCore<\n Token extends string,\n Theme extends string,\n Slot extends string,\n>(\n appearance:\n | {\n theme?: Theme;\n tokens?: Partial<Record<Token, string>>;\n elements?: AppearanceElements<Slot>;\n }\n | undefined,\n config: AppearanceCoreConfig<Token, Theme>,\n): ResolvedAppearanceCore<Token, Theme, Slot> {\n const theme: Theme = appearance?.theme ?? config.defaultTheme;\n\n const tokens = omitUndefined<Token>({\n ...config.presets[theme],\n ...appearance?.tokens,\n });\n\n const elements = appearance?.elements ?? {};\n\n return {\n theme,\n isCustomized:\n appearance?.theme != null ||\n Object.keys(tokens).length > 0 ||\n hasAnyElement(elements),\n tokens,\n elements,\n boundaryStyle: resolveBoundaryStyle(\n tokens,\n config.variables,\n config.shadcnVariables,\n ),\n };\n}\n\n/** Caller overrides for a slot, if any were provided. */\nexport function getSlotAppearance<Slot extends string>(\n elements: AppearanceElements<Slot>,\n slot: Slot,\n): SlotAppearance | undefined {\n return elements[slot];\n}\n"]}
1
+ {"version":3,"sources":["../src/lib/appearance-core.ts"],"names":["omitUndefined","tokens","result","key","value","hasAnyElement","elements","element","resolveBoundaryStyle","variables","shadcnVariables","style","token","variable","resolveAppearanceCore","appearance","config","theme","getSlotAppearance","slot"],"mappings":"AA8DO,0rBAASA,CAAAA,CACdC,CAAAA,CACgC,CAChC,IAAMC,CAAAA,CAAkC,CAAC,CAAA,CAEzC,GAAA,CAAA,GAAW,CAACC,CAAAA,CAAKC,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQH,CAAM,CAAA,CAC1CG,CAAAA,EAAS,IAAA,EAAA,CACXF,CAAAA,CAAOC,CAAG,CAAA,CAAIC,CAAAA,CAAAA,CAIlB,OAAOF,CACT,CAEO,SAASG,CAAAA,CACdC,CAAAA,CACS,CACT,OAAO,MAAA,CAAO,MAAA,CAAmCA,CAAQ,CAAA,CAAE,IAAA,CACxDC,CAAAA,EACCA,CAAAA,EAAW,IAAA,EAAA,CAASA,CAAAA,CAAQ,SAAA,EAAa,I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,CAAAK,CAAAA,CACA,aAAA,CAAeE,CAAAA,CACbP,CAAAA,CACAe,CAAAA,CAAO,SAAA,CACPA,CAAAA,CAAO,eACT,CACF,CACF,CAGO,SAASE,CAAAA,CACdZ,CAAAA,CACAa,CAAAA,CAC4B,CAC5B,OAAOb,CAAAA,CAASa,CAAI,CACtB,CAAA,6BAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-KOYBZORL.js","sourcesContent":["import type { CSSProperties } from \"react\";\n\n/**\n * Generic building blocks shared by the appearance modules (checkout, and\n * later returns). Each module supplies its own token to CSS variable map, theme\n * presets and shadcn mapping, and keeps its own public types. Everything here\n * is pure so it can be tested without a DOM.\n */\n\n/** Caller overrides for a single slot. */\nexport type SlotAppearance = {\n /** Merged after the built-in classes with `cn`, so Tailwind conflicts resolve. */\n className?: string;\n /** Merged after the built-in inline styles. */\n style?: CSSProperties;\n};\n\n/** Typed partial map of slot name to its overrides. */\nexport type AppearanceElements<Slot extends string> = Partial<\n Record<Slot, SlotAppearance>\n>;\n\n/** CSS custom property used for each token. */\nexport type TokenVariables<Token extends string> = Readonly<\n Record<Token, string>\n>;\n\n/**\n * Remaps a token onto a shadcn theme variable (`--background`, `--ring`, ...)\n * so shared UI primitives follow the module's tokens. Only written when the\n * token is in effect.\n */\nexport type ShadcnVariableMapping<Token extends string> = readonly {\n token: Token;\n variable: string;\n}[];\n\nexport type AppearanceCoreConfig<Token extends string, Theme extends string> = {\n /** Theme used when the caller does not select one. */\n defaultTheme: Theme;\n /** Partial token sets applied underneath the caller tokens. */\n presets: Record<Theme, Partial<Record<Token, string>>>;\n variables: TokenVariables<Token>;\n shadcnVariables: ShadcnVariableMapping<Token>;\n};\n\nexport type ResolvedAppearanceCore<\n Token extends string,\n Theme extends string,\n Slot extends string,\n> = {\n theme: Theme;\n /** `true` as soon as the caller passed a theme, a token or a slot override. */\n isCustomized: boolean;\n /** Tokens that are in effect. Empty entries were dropped. */\n tokens: Partial<Record<Token, string>>;\n elements: AppearanceElements<Slot>;\n /** Inline custom properties for the theme boundary. */\n boundaryStyle: CSSProperties;\n};\n\n/** Drops `undefined`/`null` tokens so unset values keep the stylesheet default. */\nexport function omitUndefined<Token extends string>(\n tokens: Partial<Record<Token, string>>,\n): Partial<Record<Token, string>> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(tokens)) {\n if (value != null) {\n result[key] = value;\n }\n }\n\n return result as Partial<Record<Token, string>>;\n}\n\nexport function hasAnyElement<Slot extends string>(\n elements: AppearanceElements<Slot>,\n): boolean {\n return Object.values<SlotAppearance | undefined>(elements).some(\n (element) =>\n element != null && (element.className != null || element.style != null),\n );\n}\n\n/**\n * Token to CSS variable resolution, followed by the shadcn remapping. Only\n * tokens that are in effect produce a variable.\n */\nexport function resolveBoundaryStyle<Token extends string>(\n tokens: Partial<Record<Token, string>>,\n variables: TokenVariables<Token>,\n shadcnVariables: ShadcnVariableMapping<Token>,\n): CSSProperties {\n const style: Record<string, string> = {};\n\n for (const [token, variable] of Object.entries<string>(variables)) {\n const value = tokens[token as Token];\n if (value != null) {\n style[variable] = value;\n }\n }\n\n for (const { token, variable } of shadcnVariables) {\n const value = tokens[token];\n if (value != null) {\n style[variable] = value;\n }\n }\n\n return style as CSSProperties;\n}\n\n/**\n * Resolves theme, tokens, slot overrides and the boundary style. The resolver\n * never invents values: a token is only present when the caller provided it or\n * selected a theme preset that carries it.\n */\nexport function resolveAppearanceCore<\n Token extends string,\n Theme extends string,\n Slot extends string,\n>(\n appearance:\n | {\n theme?: Theme;\n tokens?: Partial<Record<Token, string>>;\n elements?: AppearanceElements<Slot>;\n }\n | undefined,\n config: AppearanceCoreConfig<Token, Theme>,\n): ResolvedAppearanceCore<Token, Theme, Slot> {\n const theme: Theme = appearance?.theme ?? config.defaultTheme;\n\n const tokens = omitUndefined<Token>({\n ...config.presets[theme],\n ...appearance?.tokens,\n });\n\n const elements = appearance?.elements ?? {};\n\n return {\n theme,\n isCustomized:\n appearance?.theme != null ||\n Object.keys(tokens).length > 0 ||\n hasAnyElement(elements),\n tokens,\n elements,\n boundaryStyle: resolveBoundaryStyle(\n tokens,\n config.variables,\n config.shadcnVariables,\n ),\n };\n}\n\n/** Caller overrides for a slot, if any were provided. */\nexport function getSlotAppearance<Slot extends string>(\n elements: AppearanceElements<Slot>,\n slot: Slot,\n): SlotAppearance | undefined {\n return elements[slot];\n}\n"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkUCL4Y7L3js = require('./chunk-UCL4Y7L3.js');var _chunkQ25D7OAOjs = require('./chunk-Q25D7OAO.js');var B=["orders","order","confirmation","result","myReturns","myReturn"];function P(e){return B.includes(e)}function f(e){return e?{name:"orders"}:{name:"email"}}function C(e,n){switch(n.type){case"SESSION_EXPIRED":return P(e.name)?{name:"email"}:e;case"CODE_SENT":return e.name==="email"?{name:"code"}:e;case"AUTHENTICATED":return e.name==="email"||e.name==="code"?{name:"orders"}:e;case"SELECT_ORDER":return e.name==="orders"?{name:"order",orderId:n.orderId}:e;case"REVIEW":return e.name==="order"?{name:"confirmation",orderId:e.orderId,items:n.items,note:n.note}:e;case"SUBMITTED":return e.name==="confirmation"?{name:"result",returnId:n.returnId}:e;case"OPEN_MY_RETURNS":return e.name==="orders"||e.name==="result"?{name:"myReturns"}:e;case"SELECT_RETURN":return e.name==="myReturns"?{name:"myReturn",returnId:n.returnId}:e;case"CONTINUE":return e.name==="result"?{name:"orders"}:e;case"BACK":switch(e.name){case"code":return{name:"email"};case"order":case"myReturns":return{name:"orders"};case"confirmation":return{name:"order",orderId:e.orderId,items:e.items,note:e.note};case"myReturn":return{name:"myReturns"};default:return e}}}var x={email:1,code:2,orders:3,order:4,confirmation:5,result:6},_=6;function O(e){return x[e]}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function g({current:e}){let n=_chunkUCL4Y7L3js.i.call(void 0, ),r=_chunkUCL4Y7L3js.f.call(void 0, "stepIndicator");return _jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"stepIndicator",className:_chunkQ25D7OAOjs.d.call(void 0, "text-xs",r.className),style:r.style,children:n("stepIndicator",{current:e,total:_})})}function b({panelToken:e}){let{status:n}=_chunkUCL4Y7L3js.j.call(void 0, "BitsnapReturns"),[r,t]=_react.useReducer.call(void 0, C,f(!1));if(_react.useEffect.call(void 0, ()=>{n==="authenticated"?t({type:"AUTHENTICATED"}):n==="anonymous"&&t({type:"SESSION_EXPIRED"})},[n]),n==="exchanging"||n==="hydrating"&&e)return _jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.s,{});let s=O(r.name);return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-4",children:[s!=null&&_jsxruntime.jsx.call(void 0, g,{current:s}),r.name==="email"&&_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.t,{onSubmitted:()=>t({type:"CODE_SENT"})}),r.name==="code"&&_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.u,{onVerified:()=>t({type:"AUTHENTICATED"}),onBack:()=>t({type:"BACK"})}),r.name==="orders"&&_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.v,{showLogout:!e,onSelectOrder:u=>t({type:"SELECT_ORDER",orderId:u}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="order"&&_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.w,{orderId:r.orderId,initialItems:r.items,initialNote:r.note,onBack:()=>t({type:"BACK"}),onContinue:({items:u,note:U})=>t({type:"REVIEW",items:u,note:U})}),r.name==="confirmation"&&_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.x,{orderId:r.orderId,items:r.items,note:r.note,onBack:()=>t({type:"BACK"}),onSubmitted:u=>t({type:"SUBMITTED",returnId:u})}),r.name==="result"&&_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.y,{returnId:r.returnId,onContinue:()=>t({type:"CONTINUE"}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="myReturns"&&_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.z,{onSelectReturn:u=>t({type:"SELECT_RETURN",returnId:u}),onBack:()=>t({type:"BACK"})}),r.name==="myReturn"&&_jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.A,{returnId:r.returnId,onBack:()=>t({type:"BACK"})})]})}function q(e){return _jsxruntime.jsx.call(void 0, _chunkUCL4Y7L3js.k,{...e,children:_jsxruntime.jsx.call(void 0, b,{panelToken:e.panelAccessToken!=null&&e.panelAccessToken!==""})})}exports.a = q;
2
- //# sourceMappingURL=chunk-VPBFEAFQ.js.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSTVEBT6Mjs = require('./chunk-STVEBT6M.js');var _chunk4BV5IUZHjs = require('./chunk-4BV5IUZH.js');var B=["orders","order","confirmation","result","myReturns","myReturn"];function P(e){return B.includes(e)}function f(e){return e?{name:"orders"}:{name:"email"}}function C(e,n){switch(n.type){case"SESSION_EXPIRED":return P(e.name)?{name:"email"}:e;case"CODE_SENT":return e.name==="email"?{name:"code"}:e;case"AUTHENTICATED":return e.name==="email"||e.name==="code"?{name:"orders"}:e;case"SELECT_ORDER":return e.name==="orders"?{name:"order",orderId:n.orderId}:e;case"REVIEW":return e.name==="order"?{name:"confirmation",orderId:e.orderId,items:n.items,note:n.note}:e;case"SUBMITTED":return e.name==="confirmation"?{name:"result",returnId:n.returnId}:e;case"OPEN_MY_RETURNS":return e.name==="orders"||e.name==="result"?{name:"myReturns"}:e;case"SELECT_RETURN":return e.name==="myReturns"?{name:"myReturn",returnId:n.returnId}:e;case"CONTINUE":return e.name==="result"?{name:"orders"}:e;case"BACK":switch(e.name){case"code":return{name:"email"};case"order":case"myReturns":return{name:"orders"};case"confirmation":return{name:"order",orderId:e.orderId,items:e.items,note:e.note};case"myReturn":return{name:"myReturns"};default:return e}}}var x={email:1,code:2,orders:3,order:4,confirmation:5,result:6},_=6;function O(e){return x[e]}var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function g({current:e}){let n=_chunkSTVEBT6Mjs.i.call(void 0, ),r=_chunkSTVEBT6Mjs.f.call(void 0, "stepIndicator");return _jsxruntime.jsx.call(void 0, "p",{"data-bitsnap-returns-slot":"stepIndicator",className:_chunk4BV5IUZHjs.d.call(void 0, "text-xs",r.className),style:r.style,children:n("stepIndicator",{current:e,total:_})})}function b({panelToken:e}){let{status:n}=_chunkSTVEBT6Mjs.j.call(void 0, "BitsnapReturns"),[r,t]=_react.useReducer.call(void 0, C,f(!1));if(_react.useEffect.call(void 0, ()=>{n==="authenticated"?t({type:"AUTHENTICATED"}):n==="anonymous"&&t({type:"SESSION_EXPIRED"})},[n]),n==="exchanging"||n==="hydrating"&&e)return _jsxruntime.jsx.call(void 0, _chunkSTVEBT6Mjs.s,{});let s=O(r.name);return _jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col gap-4",children:[s!=null&&_jsxruntime.jsx.call(void 0, g,{current:s}),r.name==="email"&&_jsxruntime.jsx.call(void 0, _chunkSTVEBT6Mjs.t,{onSubmitted:()=>t({type:"CODE_SENT"})}),r.name==="code"&&_jsxruntime.jsx.call(void 0, _chunkSTVEBT6Mjs.u,{onVerified:()=>t({type:"AUTHENTICATED"}),onBack:()=>t({type:"BACK"})}),r.name==="orders"&&_jsxruntime.jsx.call(void 0, _chunkSTVEBT6Mjs.v,{showLogout:!e,onSelectOrder:u=>t({type:"SELECT_ORDER",orderId:u}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="order"&&_jsxruntime.jsx.call(void 0, _chunkSTVEBT6Mjs.w,{orderId:r.orderId,initialItems:r.items,initialNote:r.note,onBack:()=>t({type:"BACK"}),onContinue:({items:u,note:U})=>t({type:"REVIEW",items:u,note:U})}),r.name==="confirmation"&&_jsxruntime.jsx.call(void 0, _chunkSTVEBT6Mjs.x,{orderId:r.orderId,items:r.items,note:r.note,onBack:()=>t({type:"BACK"}),onSubmitted:u=>t({type:"SUBMITTED",returnId:u})}),r.name==="result"&&_jsxruntime.jsx.call(void 0, _chunkSTVEBT6Mjs.y,{returnId:r.returnId,onContinue:()=>t({type:"CONTINUE"}),onOpenMyReturns:()=>t({type:"OPEN_MY_RETURNS"})}),r.name==="myReturns"&&_jsxruntime.jsx.call(void 0, _chunkSTVEBT6Mjs.z,{onSelectReturn:u=>t({type:"SELECT_RETURN",returnId:u}),onBack:()=>t({type:"BACK"})}),r.name==="myReturn"&&_jsxruntime.jsx.call(void 0, _chunkSTVEBT6Mjs.A,{returnId:r.returnId,onBack:()=>t({type:"BACK"})})]})}function q(e){return _jsxruntime.jsx.call(void 0, _chunkSTVEBT6Mjs.k,{...e,children:_jsxruntime.jsx.call(void 0, b,{panelToken:e.panelAccessToken!=null&&e.panelAccessToken!==""})})}exports.a = q;
2
+ //# sourceMappingURL=chunk-MZSLLGFS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-MZSLLGFS.js","../src/components/returns/state-machine.ts","../src/components/returns/BitsnapReturns.tsx"],"names":["STEPS_WITH_SESSION","stepRequiresSession","step","initialReturnsStep","hasSession","reduceReturnsStep","event","STEP_NUMBERS","RETURNS_STEP_COUNT","returnsStepNumber","StepIndicator","current","text","useReturnsText","slot","useReturnsSlot","jsx","cn","ReturnsRouter","panelToken","status","useReturnsContext","dispatch","useReducer","useEffect","SkeletonRows","stepNumber","jsxs","ReturnsEmailStep","ReturnsCodeStep","ReturnsOrderList","orderId","ReturnsOrderDetail","items","note","ReturnsConfirmation","returnId","ReturnsResult","ReturnsMyReturnsList","ReturnsMyReturnDetail","BitsnapReturns","props","ReturnsProvider"],"mappings":"AAAA,+HAAsH,sDAAwC,IC8CxJA,CAAAA,CAAiD,CACrD,QAAA,CACA,OAAA,CACA,cAAA,CACA,QAAA,CACA,WAAA,CACA,UACF,CAAA,CAGO,SAASC,CAAAA,CAAoBC,CAAAA,CAAgC,CA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AC0B,CAAA,CAAiB,GAAGD,CAAAA,CACnB,QAAA,CAAAzB,6BAAAA,CAACE,CAAA,CAAc,UAAA,CAAYuB,CAAAA,CAAM,gBAAA,EAAoB,IAAA,EAAQA,CAAAA,CAAM,gBAAA,GAAqB,EAAA,CAAI,CAAA,CAC9F,CAEJ,CAAA,cAAA","file":"/home/emems/.t3/worktrees/bitsnap-react/cart-payment-method/dist/chunk-MZSLLGFS.js","sourcesContent":[null,"/** One line chosen for return. */\nexport type SelectedReturnLine = {\n lineId: string;\n quantity: number;\n};\n\n/** Where the default flow of `BitsnapReturns` currently is. */\nexport type ReturnsStep =\n | { name: \"email\" }\n | { name: \"code\" }\n | { name: \"orders\" }\n | {\n name: \"order\";\n orderId: string;\n /** Selection to restore when coming back from the confirmation. */\n items?: SelectedReturnLine[];\n note?: string;\n }\n | {\n name: \"confirmation\";\n orderId: string;\n items: SelectedReturnLine[];\n note: string;\n }\n | { name: \"result\"; returnId: string }\n | { name: \"myReturns\" }\n | { name: \"myReturn\"; returnId: string };\n\nexport type ReturnsStepName = ReturnsStep[\"name\"];\n\nexport type ReturnsStepEvent =\n /** A verification code was requested. */\n | { type: \"CODE_SENT\" }\n /** The session became valid: code verified, stored session or panel token. */\n | { type: \"AUTHENTICATED\" }\n /** The session was dropped by the backend, expiry or logout. */\n | { type: \"SESSION_EXPIRED\" }\n | { type: \"SELECT_ORDER\"; orderId: string }\n | { type: \"REVIEW\"; items: SelectedReturnLine[]; note: string }\n | { type: \"SUBMITTED\"; returnId: string }\n | { type: \"OPEN_MY_RETURNS\" }\n | { type: \"SELECT_RETURN\"; returnId: string }\n | { type: \"BACK\" }\n /** Leave the result screen for the order list. */\n | { type: \"CONTINUE\" };\n\nconst STEPS_WITH_SESSION: readonly ReturnsStepName[] = [\n \"orders\",\n \"order\",\n \"confirmation\",\n \"result\",\n \"myReturns\",\n \"myReturn\",\n];\n\n/** Steps that cannot be shown without a returns session. */\nexport function stepRequiresSession(step: ReturnsStepName): boolean {\n return STEPS_WITH_SESSION.includes(step);\n}\n\n/** Starts at the orders when a session exists, otherwise at the email. */\nexport function initialReturnsStep(hasSession: boolean): ReturnsStep {\n return hasSession ? { name: \"orders\" } : { name: \"email\" };\n}\n\n/**\n * Pure transition function of the default flow. Events that do not apply to\n * the current step leave it unchanged.\n */\nexport function reduceReturnsStep(\n step: ReturnsStep,\n event: ReturnsStepEvent,\n): ReturnsStep {\n switch (event.type) {\n case \"SESSION_EXPIRED\":\n // Email and code do not need a session; keep a pending verification.\n return stepRequiresSession(step.name) ? { name: \"email\" } : step;\n case \"CODE_SENT\":\n return step.name === \"email\" ? { name: \"code\" } : step;\n case \"AUTHENTICATED\":\n return step.name === \"email\" || step.name === \"code\"\n ? { name: \"orders\" }\n : step;\n case \"SELECT_ORDER\":\n return step.name === \"orders\"\n ? { name: \"order\", orderId: event.orderId }\n : step;\n case \"REVIEW\":\n return step.name === \"order\"\n ? {\n name: \"confirmation\",\n orderId: step.orderId,\n items: event.items,\n note: event.note,\n }\n : step;\n case \"SUBMITTED\":\n return step.name === \"confirmation\"\n ? { name: \"result\", returnId: event.returnId }\n : step;\n case \"OPEN_MY_RETURNS\":\n return step.name === \"orders\" || step.name === \"result\"\n ? { name: \"myReturns\" }\n : step;\n case \"SELECT_RETURN\":\n return step.name === \"myReturns\"\n ? { name: \"myReturn\", returnId: event.returnId }\n : step;\n case \"CONTINUE\":\n return step.name === \"result\" ? { name: \"orders\" } : step;\n case \"BACK\":\n switch (step.name) {\n case \"code\":\n return { name: \"email\" };\n case \"order\":\n case \"myReturns\":\n return { name: \"orders\" };\n case \"confirmation\":\n return {\n name: \"order\",\n orderId: step.orderId,\n items: step.items,\n note: step.note,\n };\n case \"myReturn\":\n return { name: \"myReturns\" };\n default:\n return step;\n }\n }\n}\n\nconst STEP_NUMBERS: Partial<Record<ReturnsStepName, number>> = {\n email: 1,\n code: 2,\n orders: 3,\n order: 4,\n confirmation: 5,\n result: 6,\n};\n\nexport const RETURNS_STEP_COUNT = 6;\n\n/** Position of a step in the return flow, `undefined` for the \"my returns\" views. */\nexport function returnsStepNumber(step: ReturnsStepName): number | undefined {\n return STEP_NUMBERS[step];\n}\n","import { useEffect, useReducer } from \"react\";\nimport { cn } from \"@/src/lib/utils\";\nimport { useReturnsSlot } from \"./appearance.context\";\nimport { ReturnsCodeStep, ReturnsEmailStep } from \"./AuthSteps\";\nimport { SkeletonRows } from \"./internal\";\nimport { ReturnsMyReturnDetail, ReturnsMyReturnsList } from \"./MyReturns\";\nimport {\n ReturnsConfirmation,\n ReturnsOrderDetail,\n ReturnsOrderList,\n ReturnsResult,\n} from \"./OrderSteps\";\nimport {\n ReturnsProvider,\n useReturnsContext,\n type ReturnsProviderProps,\n} from \"./ReturnsProvider\";\nimport {\n initialReturnsStep,\n reduceReturnsStep,\n RETURNS_STEP_COUNT,\n returnsStepNumber,\n} from \"./state-machine\";\nimport { useReturnsText } from \"./texts.context\";\n\nexport type BitsnapReturnsProps = Omit<ReturnsProviderProps, \"children\">;\n\nfunction StepIndicator({ current }: { current: number }) {\n const text = useReturnsText();\n const slot = useReturnsSlot(\"stepIndicator\");\n\n return (\n <p\n data-bitsnap-returns-slot=\"stepIndicator\"\n className={cn(\"text-xs\", slot.className)}\n style={slot.style}\n >\n {text(\"stepIndicator\", { current, total: RETURNS_STEP_COUNT })}\n </p>\n );\n}\n\n/** Default step router. All transitions come from the pure state machine. */\nfunction ReturnsRouter({ panelToken }: { panelToken: boolean }) {\n const { status } = useReturnsContext(\"BitsnapReturns\");\n const [step, dispatch] = useReducer(\n reduceReturnsStep,\n initialReturnsStep(false),\n );\n\n // A valid session (verified code, stored session, exchanged panel token)\n // moves on to the orders; a dropped one returns to the start.\n useEffect(() => {\n if (status === \"authenticated\") {\n dispatch({ type: \"AUTHENTICATED\" });\n } else if (status === \"anonymous\") {\n dispatch({ type: \"SESSION_EXPIRED\" });\n }\n }, [status]);\n\n // Without a panel token the server render and the first client render show\n // the email step; a stored session switches to the orders after hydration.\n if (status === \"exchanging\" || (status === \"hydrating\" && panelToken)) {\n return <SkeletonRows />;\n }\n\n const stepNumber = returnsStepNumber(step.name);\n\n return (\n <div className=\"flex flex-col gap-4\">\n {stepNumber != null && <StepIndicator current={stepNumber} />}\n {step.name === \"email\" && (\n <ReturnsEmailStep onSubmitted={() => dispatch({ type: \"CODE_SENT\" })} />\n )}\n {step.name === \"code\" && (\n <ReturnsCodeStep\n onVerified={() => dispatch({ type: \"AUTHENTICATED\" })}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"orders\" && (\n <ReturnsOrderList\n showLogout={!panelToken}\n onSelectOrder={(orderId) =>\n dispatch({ type: \"SELECT_ORDER\", orderId })\n }\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"order\" && (\n <ReturnsOrderDetail\n orderId={step.orderId}\n initialItems={step.items}\n initialNote={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onContinue={({ items, note }) =>\n dispatch({ type: \"REVIEW\", items, note })\n }\n />\n )}\n {step.name === \"confirmation\" && (\n <ReturnsConfirmation\n orderId={step.orderId}\n items={step.items}\n note={step.note}\n onBack={() => dispatch({ type: \"BACK\" })}\n onSubmitted={(returnId) =>\n dispatch({ type: \"SUBMITTED\", returnId })\n }\n />\n )}\n {step.name === \"result\" && (\n <ReturnsResult\n returnId={step.returnId}\n onContinue={() => dispatch({ type: \"CONTINUE\" })}\n onOpenMyReturns={() => dispatch({ type: \"OPEN_MY_RETURNS\" })}\n />\n )}\n {step.name === \"myReturns\" && (\n <ReturnsMyReturnsList\n onSelectReturn={(returnId) =>\n dispatch({ type: \"SELECT_RETURN\", returnId })\n }\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n {step.name === \"myReturn\" && (\n <ReturnsMyReturnDetail\n returnId={step.returnId}\n onBack={() => dispatch({ type: \"BACK\" })}\n />\n )}\n </div>\n );\n}\n\n/**\n * Customer return flow: email, code, orders, line selection, confirmation and\n * result, plus the list of earlier returns. It is `ReturnsProvider` with the\n * default step router; compose your own page from the step components to\n * change the layout.\n *\n * ```tsx\n * <BitsnapReturns projectID=\"…\" appearance={brand} texts={{ emailStepTitle: \"Return a product\" }} />\n * ```\n */\nexport function BitsnapReturns(props: BitsnapReturnsProps) {\n return (\n <ReturnsProvider {...props}>\n <ReturnsRouter panelToken={props.panelAccessToken != null && props.panelAccessToken !== \"\"} />\n </ReturnsProvider>\n );\n}\n"]}