bitsnap-react 1.10.0 → 1.11.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 (90) hide show
  1. package/README.md +57 -1
  2. package/dist/CartProvider-ONIOELW5.mjs +2 -0
  3. package/dist/CartProvider-Q3CIVK5K.js +2 -0
  4. package/dist/CartProvider-Q3CIVK5K.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-7RGH57QG.js +2 -0
  12. package/dist/chunk-7RGH57QG.js.map +1 -0
  13. package/dist/{chunk-AJNULBC3.js → chunk-ASNUY3EU.js} +2 -2
  14. package/dist/chunk-ASNUY3EU.js.map +1 -0
  15. package/dist/{chunk-T2OUOO4X.mjs → chunk-C5Q7DGCD.mjs} +2 -2
  16. package/dist/{chunk-YXFJG4MF.mjs → chunk-C5RMHUOG.mjs} +2 -2
  17. package/dist/{chunk-DPKT6ITB.js → chunk-CUQ2PNCJ.js} +3 -3
  18. package/dist/chunk-CUQ2PNCJ.js.map +1 -0
  19. package/dist/{chunk-F46RJVWC.js → chunk-ELGNOAH4.js} +2 -2
  20. package/dist/chunk-ELGNOAH4.js.map +1 -0
  21. package/dist/chunk-EZWH6BB2.mjs +2 -0
  22. package/dist/chunk-EZWH6BB2.mjs.map +1 -0
  23. package/dist/{chunk-6D3OORMK.mjs → chunk-GPNALARZ.mjs} +2 -2
  24. package/dist/{chunk-B32ACCW2.js → chunk-GT3OH55Y.js} +2 -2
  25. package/dist/chunk-GT3OH55Y.js.map +1 -0
  26. package/dist/{chunk-DDY7IBMG.mjs → chunk-H3YP2QPV.mjs} +2 -2
  27. package/dist/{chunk-JXCHRSPW.mjs → chunk-HG4YOJWE.mjs} +3 -3
  28. package/dist/chunk-HG4YOJWE.mjs.map +1 -0
  29. package/dist/chunk-JSDGZ4NY.js.map +1 -1
  30. package/dist/chunk-KOYBZORL.js.map +1 -1
  31. package/dist/{chunk-3Z6VNXBP.js → chunk-PUYK4YHE.js} +2 -2
  32. package/dist/chunk-PUYK4YHE.js.map +1 -0
  33. package/dist/{chunk-RLEC25JI.mjs → chunk-T57337WD.mjs} +2 -2
  34. package/dist/{chunk-RLEC25JI.mjs.map → chunk-T57337WD.mjs.map} +1 -1
  35. package/dist/{chunk-F6GQLKA6.js → chunk-VQQBBSK2.js} +2 -2
  36. package/dist/chunk-VQQBBSK2.js.map +1 -0
  37. package/dist/chunk-XIHGWNTS.js.map +1 -1
  38. package/dist/{chunk-ZPTHK4OX.mjs → chunk-XQ43IC4M.mjs} +2 -2
  39. package/dist/{chunk-RVILRUW3.js → chunk-YFETPEI6.js} +2 -2
  40. package/dist/chunk-YFETPEI6.js.map +1 -0
  41. package/dist/consent.js +29 -15
  42. package/dist/consent.js.map +1 -1
  43. package/dist/consent.mjs +29 -15
  44. package/dist/consent.mjs.map +1 -1
  45. package/dist/course.js +1 -1
  46. package/dist/course.js.map +1 -1
  47. package/dist/course.mjs +1 -1
  48. package/dist/embed/analytics.js +1 -1
  49. package/dist/embed/consent.js +27 -13
  50. package/dist/errors.js.map +1 -1
  51. package/dist/index.d.mts +37 -5
  52. package/dist/index.d.ts +37 -5
  53. package/dist/index.js +1 -1
  54. package/dist/index.js.map +1 -1
  55. package/dist/index.mjs +1 -1
  56. package/dist/index.mjs.map +1 -1
  57. package/dist/internal.js.map +1 -1
  58. package/dist/methods-C5HWYPPN.mjs +2 -0
  59. package/dist/methods-CHNMFVFV.js +2 -0
  60. package/dist/methods-CHNMFVFV.js.map +1 -0
  61. package/dist/models.js.map +1 -1
  62. package/dist/returns.js +1 -1
  63. package/dist/returns.js.map +1 -1
  64. package/dist/returns.mjs +1 -1
  65. package/package.json +2 -2
  66. package/dist/CartProvider-HXLGQ4EX.mjs +0 -2
  67. package/dist/CartProvider-OHHYOMSG.js +0 -2
  68. package/dist/CartProvider-OHHYOMSG.js.map +0 -1
  69. package/dist/chunk-3Z6VNXBP.js.map +0 -1
  70. package/dist/chunk-43IIYJ6J.mjs +0 -2
  71. package/dist/chunk-43IIYJ6J.mjs.map +0 -1
  72. package/dist/chunk-AJNULBC3.js.map +0 -1
  73. package/dist/chunk-B32ACCW2.js.map +0 -1
  74. package/dist/chunk-DPKT6ITB.js.map +0 -1
  75. package/dist/chunk-F46RJVWC.js.map +0 -1
  76. package/dist/chunk-F6GQLKA6.js.map +0 -1
  77. package/dist/chunk-JXCHRSPW.mjs.map +0 -1
  78. package/dist/chunk-RVILRUW3.js.map +0 -1
  79. package/dist/chunk-VIII45AC.js +0 -2
  80. package/dist/chunk-VIII45AC.js.map +0 -1
  81. package/dist/methods-A5KGZBAM.js +0 -2
  82. package/dist/methods-A5KGZBAM.js.map +0 -1
  83. package/dist/methods-AOHKV7IN.mjs +0 -2
  84. /package/dist/{CartProvider-HXLGQ4EX.mjs.map → CartProvider-ONIOELW5.mjs.map} +0 -0
  85. /package/dist/{chunk-T2OUOO4X.mjs.map → chunk-C5Q7DGCD.mjs.map} +0 -0
  86. /package/dist/{chunk-YXFJG4MF.mjs.map → chunk-C5RMHUOG.mjs.map} +0 -0
  87. /package/dist/{chunk-6D3OORMK.mjs.map → chunk-GPNALARZ.mjs.map} +0 -0
  88. /package/dist/{chunk-DDY7IBMG.mjs.map → chunk-H3YP2QPV.mjs.map} +0 -0
  89. /package/dist/{chunk-ZPTHK4OX.mjs.map → chunk-XQ43IC4M.mjs.map} +0 -0
  90. /package/dist/{methods-AOHKV7IN.mjs.map → methods-C5HWYPPN.mjs.map} +0 -0
package/README.md CHANGED
@@ -353,7 +353,22 @@ copy per language, pass a different object.
353
353
  ```
354
354
 
355
355
  Checkout keys (`CheckoutTexts`): `cart`, `emptyCart`, `total`, `delivery`,
356
- `chooseCountry`, `nextStep`, `unavailableProducts`.
356
+ `chooseCountry`, `nextStep`, `unavailableProducts`, `checkoutFailed`,
357
+ `noPaymentGateway`, `gatewayNotConfigured`, `shippingNotConfigured`,
358
+ `mixedRecurring`, `currencyUnsupported`, `priceChanged`.
359
+
360
+ When "Next step" fails, the cart shows the text of the backend error code
361
+ (`noPaymentGateway`, `gatewayNotConfigured`, `shippingNotConfigured`,
362
+ `mixedRecurring`, `currencyUnsupported`, `priceChanged`; `unavailableProducts`
363
+ for `product-not-found`). Server errors (5xx, `internal`) and `invalid-request`
364
+ show `checkoutFailed`. For any other 4xx code the cart shows the message sent
365
+ by the server, else `checkoutFailed`. It never shows the bare code, and never
366
+ a message that is HTML, multi-line, longer than 200 characters or a stack
367
+ trace.
368
+
369
+ These keys were added in 1.11.0. If you type your own language
370
+ objects, use `Partial<CheckoutTexts>` (the `texts` prop already accepts it) so
371
+ that they keep compiling when new keys appear.
357
372
 
358
373
  Returns keys (`ReturnsTexts`) cover each step (`emailStepTitle`,
359
374
  `codeStepDescription`, `ordersEmpty`, `confirmationSubmit`, `successTitle`,
@@ -763,6 +778,40 @@ async function handleCheckout() {
763
778
  }
764
779
  ```
765
780
 
781
+ On success `createCheckout` returns `{ status: "ok", redirectURL }`. A failed
782
+ response no longer throws and no longer yields an undefined `redirectURL`: it
783
+ returns an `Err` with `status: "error"` instead (`result.ERR === true`), typed
784
+ as `CreateCheckoutResult`. Check `result.status === "ok"` before reading
785
+ `redirectURL`. `result.error` is the backend code (`invalid-request`,
786
+ `product-not-available`, `product-not-found`, `no-payment-gateway`,
787
+ `gateway-not-configured`, `shipping-not-configured`, `mixed-recurring`,
788
+ `currency-unsupported`, `price-changed`, `internal`). New backends send
789
+ `internal` for their own failures; `internal-error` is what the library uses
790
+ when an older backend sent no code. `result.data` is a `BuyErrorData`
791
+ (`{ message?, itemIds? }`), except for `item-ids-not-found`
792
+ (`ITEM_IDS_NOT_FOUND`), where it is the array of ids; both are exported.
793
+ `message` is the reason sent by the server, when it was usable. `result.type`
794
+ is `internal` for 5xx and `badInput` for 4xx.
795
+
796
+ ```tsx
797
+ import { ITEM_IDS_NOT_FOUND, type BuyErrorData } from "bitsnap-react";
798
+
799
+ if (result.status === "error") {
800
+ if (result.error === ITEM_IDS_NOT_FOUND) {
801
+ const ids = result.data as string[];
802
+ } else {
803
+ const { message } = (result.data ?? {}) as BuyErrorData;
804
+ }
805
+ }
806
+ ```
807
+
808
+ `createPaymentURL` returns the same errors: the backend code in `error`,
809
+ `type: "badInput"` for 4xx (`"internal"` for 5xx) and `data: { message }`.
810
+ When the backend lists unavailable products (`itemIds`) under
811
+ `product-not-available` or `product-not-found` (or sends no code), the error is
812
+ `item-ids-not-found` and `data` is the array of ids. With any other code the
813
+ code is kept and the ids are in `data.itemIds`.
814
+
766
815
  6. Webhook Handler:
767
816
 
768
817
  ```tsx
@@ -1194,6 +1243,13 @@ The cookie only follows a banner that speaks for the project: a project-scope ba
1194
1243
 
1195
1244
  Declare the cookie in your banner's cookie list (category `analytics`, purpose "shop statistics: recognising returning visitors", lifetime 13 months): add `{ name: "Bitsnap statistics", category: "analytics", cookies: ["bs_vid_<projectKey>"] }` to `services` in the banner config, with your exact bare project key, which also lets the banner delete it on withdrawal from pages that run no tracker. Do not use a `bs_vid_*` prefix: the banner deletes every cookie that matches it, which on a site shared by several merchants (bitsnap.pl) would wipe other projects' ids too.
1196
1245
 
1246
+ ### Release notes (1.11.0)
1247
+
1248
+ - **The cart shows why it cannot continue to payment.** When `/buy` fails, the cart shows a localized text for the backend code (no payment gateway, delivery not configured, changed price, mixed subscription cart, unsupported currency), else the server's reason, else `checkoutFailed`. It never shows a bare code such as `internal-error`. Older bitsnap.pl responses are read too.
1249
+ - **`createCheckout` returns an error instead of a broken success.** A failed response returns an `Err` with `status: "error"` (typed `CreateCheckoutResult`) instead of `{ status: "ok", redirectURL: undefined }` or a thrown error. Check `result.status === "ok"` before reading `redirectURL`.
1250
+ - **`createPaymentURL` errors carry the backend code** in `error` (`badInput` for 4xx, `internal` for 5xx) and `data: { message }`, instead of always `internal-error`.
1251
+ - **New checkout text keys** (`checkoutFailed`, `noPaymentGateway`, `gatewayNotConfigured`, `shippingNotConfigured`, `mixedRecurring`, `currencyUnsupported`, `priceChanged`). Type your language objects as `Partial<CheckoutTexts>`.
1252
+
1197
1253
  ### Release notes (1.10.0)
1198
1254
 
1199
1255
  - **Requires bitsnap.pl with `X-Bitsnap-Visitor` support.** The cart's `/buy` and `/api/payment/link/auto` requests now send that header while analytics is granted, and a server whose CORS preflight does not allow it makes those checkouts fail in the browser. Deploy bitsnap.pl first, then publish and install this version.
@@ -0,0 +1,2 @@
1
+ import{D as c,E as d,F as e,G as f,H as g,I as h,J as i}from"./chunk-HG4YOJWE.mjs";import"./chunk-H3YP2QPV.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-C5RMHUOG.mjs";import"./chunk-C5Q7DGCD.mjs";import{l as a,m as b}from"./chunk-EZWH6BB2.mjs";import"./chunk-T57337WD.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{c as MARKETING_AGREEMENT_ID,d as bitsnapProjectID,h as default,i as getCheckoutMethods,b as getLocale,f as getProjectID,a as setLocale,e as setProjectID,g as useCartProvider};
2
+ //# sourceMappingURL=CartProvider-ONIOELW5.mjs.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCUQ2PNCJjs = require('./chunk-CUQ2PNCJ.js');require('./chunk-YFETPEI6.js');require('./chunk-KOYBZORL.js');require('./chunk-VQQBBSK2.js');require('./chunk-ASNUY3EU.js');var _chunk7RGH57QGjs = require('./chunk-7RGH57QG.js');require('./chunk-GT3OH55Y.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.MARKETING_AGREEMENT_ID = _chunkCUQ2PNCJjs.D; exports.bitsnapProjectID = _chunkCUQ2PNCJjs.E; exports.default = _chunkCUQ2PNCJjs.I; exports.getCheckoutMethods = _chunkCUQ2PNCJjs.J; exports.getLocale = _chunk7RGH57QGjs.m; exports.getProjectID = _chunkCUQ2PNCJjs.G; exports.setLocale = _chunk7RGH57QGjs.l; exports.setProjectID = _chunkCUQ2PNCJjs.F; exports.useCartProvider = _chunkCUQ2PNCJjs.H;
2
+ //# sourceMappingURL=CartProvider-Q3CIVK5K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-Q3CIVK5K.js"],"names":[],"mappings":"AAAA,+HAAiF,+BAA4B,+BAA4B,+BAA4B,+BAA4B,sDAA+C,+BAA4B,+BAA4B,+BAA4B,8YAAsL","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/CartProvider-Q3CIVK5K.js"}
package/dist/analytics.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkB32ACCW2js = require('./chunk-B32ACCW2.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.BitsnapAnalyticsProvider = _chunkB32ACCW2js.i; exports.DEFAULT_ENDPOINT = _chunkB32ACCW2js.c; exports.InstrumentProvider = _chunkB32ACCW2js.l; exports.createTracker = _chunkB32ACCW2js.d; exports.getTracker = _chunkB32ACCW2js.f; exports.initTracker = _chunkB32ACCW2js.e; exports.noopInstrument = _chunkB32ACCW2js.k; exports.resetTracker = _chunkB32ACCW2js.g; exports.scoreBucket = _chunkB32ACCW2js.r; exports.startAutoPageViews = _chunkB32ACCW2js.b; exports.useAnalytics = _chunkB32ACCW2js.j; exports.useInstrument = _chunkB32ACCW2js.n; exports.useInstrumentContext = _chunkB32ACCW2js.m;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGT3OH55Yjs = require('./chunk-GT3OH55Y.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.BitsnapAnalyticsProvider = _chunkGT3OH55Yjs.i; exports.DEFAULT_ENDPOINT = _chunkGT3OH55Yjs.c; exports.InstrumentProvider = _chunkGT3OH55Yjs.l; exports.createTracker = _chunkGT3OH55Yjs.d; exports.getTracker = _chunkGT3OH55Yjs.f; exports.initTracker = _chunkGT3OH55Yjs.e; exports.noopInstrument = _chunkGT3OH55Yjs.k; exports.resetTracker = _chunkGT3OH55Yjs.g; exports.scoreBucket = _chunkGT3OH55Yjs.r; exports.startAutoPageViews = _chunkGT3OH55Yjs.b; exports.useAnalytics = _chunkGT3OH55Yjs.j; exports.useInstrument = _chunkGT3OH55Yjs.n; exports.useInstrumentContext = _chunkGT3OH55Yjs.m;
2
2
  //# sourceMappingURL=analytics.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/visitor-cookie/dist/analytics.js"],"names":[],"mappings":"AAAA,+HAAsH,+BAA4B,+BAA4B,klBAAsR","file":"/home/emems/.t3/worktrees/bitsnap-react/visitor-cookie/dist/analytics.js"}
1
+ {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/analytics.js"],"names":[],"mappings":"AAAA,+HAAsH,+BAA4B,+BAA4B,klBAAsR","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/analytics.js"}
@@ -1,2 +1,2 @@
1
- import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-RLEC25JI.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{s as BitsnapAnalyticsProvider,t as DEFAULT_ENDPOINT,i as InstrumentProvider,r as createTracker,o as getTracker,n as initTracker,c as noopInstrument,a as resetTracker,v as scoreBucket,e as startAutoPageViews,p as useAnalytics,u as useInstrument,m as useInstrumentContext};
1
+ import{b as e,c as t,d as r,e as n,f as o,g as a,i as s,j as p,k as c,l as i,m,n as u,r as v}from"./chunk-T57337WD.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{s as BitsnapAnalyticsProvider,t as DEFAULT_ENDPOINT,i as InstrumentProvider,r as createTracker,o as getTracker,n as initTracker,c as noopInstrument,a as resetTracker,v as scoreBucket,e as startAutoPageViews,p as useAnalytics,u as useInstrument,m as useInstrumentContext};
2
2
  //# sourceMappingURL=analytics.mjs.map
package/dist/catalog.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3Z6VNXBPjs = require('./chunk-3Z6VNXBP.js');require('./chunk-KOYBZORL.js');require('./chunk-VIII45AC.js');require('./chunk-B32ACCW2.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.PRODUCT_LIST_SLOT_NAMES = _chunk3Z6VNXBPjs.a; exports.ProductList = _chunk3Z6VNXBPjs.d; exports.formatProductPrice = _chunk3Z6VNXBPjs.b; exports.useProducts = _chunk3Z6VNXBPjs.c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPUYK4YHEjs = require('./chunk-PUYK4YHE.js');require('./chunk-KOYBZORL.js');require('./chunk-7RGH57QG.js');require('./chunk-GT3OH55Y.js');require('./chunk-XIHGWNTS.js');require('./chunk-JSDGZ4NY.js');exports.PRODUCT_LIST_SLOT_NAMES = _chunkPUYK4YHEjs.a; exports.ProductList = _chunkPUYK4YHEjs.d; exports.formatProductPrice = _chunkPUYK4YHEjs.b; exports.useProducts = _chunkPUYK4YHEjs.c;
2
2
  //# sourceMappingURL=catalog.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/emems/.t3/worktrees/bitsnap-react/visitor-cookie/dist/catalog.js"],"names":[],"mappings":"AAAA,+HAA4D,+BAA4B,+BAA4B,+BAA4B,+BAA4B,+BAA4B,0LAA+F","file":"/home/emems/.t3/worktrees/bitsnap-react/visitor-cookie/dist/catalog.js"}
1
+ {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/catalog.js"],"names":[],"mappings":"AAAA,+HAA4D,+BAA4B,+BAA4B,+BAA4B,+BAA4B,+BAA4B,0LAA+F","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/catalog.js"}
package/dist/catalog.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a as o,b as r,c as e,d as f}from"./chunk-6D3OORMK.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-43IIYJ6J.mjs";import"./chunk-RLEC25JI.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{o as PRODUCT_LIST_SLOT_NAMES,f as ProductList,r as formatProductPrice,e as useProducts};
1
+ import{a as o,b as r,c as e,d as f}from"./chunk-GPNALARZ.mjs";import"./chunk-KOVKUJAW.mjs";import"./chunk-EZWH6BB2.mjs";import"./chunk-T57337WD.mjs";import"./chunk-ADYVTMGH.mjs";import"./chunk-U6FLIRIV.mjs";export{o as PRODUCT_LIST_SLOT_NAMES,f as ProductList,r as formatProductPrice,e as useProducts};
2
2
  //# sourceMappingURL=catalog.mjs.map
@@ -0,0 +1,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 _chunkGT3OH55Yjs = require('./chunk-GT3OH55Y.js');var l="X-Bitsnap-Client",s=`bitsnap-react@${_chunkGT3OH55Yjs.a}`,g="bs_client",w= exports.a ={[l]:s},K= exports.b =e=>t=>(t.header.set(l,s),e(t));function z(e){let t=e.indexOf("#"),n=t===-1?e:e.slice(0,t),a=t===-1?"":e.slice(t),r=n.includes("?")?/[?&]$/.test(n)?"":"&":"?";return`${n}${r}${g}=${encodeURIComponent(s)}${a}`}var d="https://bitsnap.pl",T= exports.f =d;function j(e){console.log("setCustomHost",e),T= exports.f =e}function x(e,t){return t.toLowerCase().startsWith("en")?e.en:e.pl}function f(e,t){let n={...e};if(t!=null)for(let[a,r]of Object.entries(t))r!=null&&(n[a]=r);return n}function u(e,t,n){return f(x(e,t),n)}function y(e,t){return _nullishCoalesce(e[t], () => (t))}var h={en:{cart:"Cart",emptyCart:"Your cart is empty.",total:"Total:",delivery:"+ delivery",chooseCountry:"Choose a country",nextStep:"Next step",unavailableProducts:"Not all products are available.",checkoutFailed:"Something went wrong. Please try again later.",noPaymentGateway:"This shop doesn't accept online payments yet. Try again later or contact the seller.",gatewayNotConfigured:"Payments in this shop are not set up correctly. Try again later or contact the seller.",shippingNotConfigured:"Delivery in this shop is not configured yet. Try again later or contact the seller.",mixedRecurring:"Subscriptions and one-time products cannot be paid for together. Pay for them in separate orders.",currencyUnsupported:"The shop doesn't accept payments in this currency. Contact the seller.",priceChanged:"The product price has changed. Refresh the page to see the current price."},pl:{cart:"Koszyk",emptyCart:"Brak produkt\xF3w w koszyku.",total:"Suma:",delivery:"+ dostawa",chooseCountry:"Wybierz kraj",nextStep:"Nast\u0119pny krok",unavailableProducts:"Nie wszystkie produkty s\u0105 dost\u0119pne w magazynie.",checkoutFailed:"Co\u015B posz\u0142o nie tak. Spr\xF3buj ponownie p\xF3\u017Aniej.",noPaymentGateway:"Ten sklep nie przyjmuje jeszcze p\u0142atno\u015Bci online. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",gatewayNotConfigured:"P\u0142atno\u015Bci w tym sklepie nie s\u0105 poprawnie skonfigurowane. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",shippingNotConfigured:"Dostawa w tym sklepie nie jest jeszcze skonfigurowana. Spr\xF3buj ponownie p\xF3\u017Aniej lub skontaktuj si\u0119 ze sprzedawc\u0105.",mixedRecurring:"Subskrypcji i produkt\xF3w jednorazowych nie mo\u017Cna op\u0142aci\u0107 razem. Op\u0142a\u0107 je w osobnych zam\xF3wieniach.",currencyUnsupported:"Sklep nie przyjmuje p\u0142atno\u015Bci w tej walucie. Skontaktuj si\u0119 ze sprzedawc\u0105.",priceChanged:"Cena produktu si\u0119 zmieni\u0142a. Od\u015Bwie\u017C stron\u0119, aby zobaczy\u0107 aktualn\u0105 cen\u0119."}};function m(e,t){return u(h,e,t)}function R(e,t,n){return y(m(t,n),e)}var i="pl-PL",c="bitsnap-locale",o;function N(e){let t=_optionalChain([e, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()]);o=t?t.toLowerCase()==="en"?"en-US":t.toLowerCase()==="pl"?i:t:void 0,typeof localStorage<"u"&&(o==null?localStorage.removeItem(c):localStorage.setItem(c,o))}function _(){return _nullishCoalesce(o, () => ((typeof localStorage<"u"?_nullishCoalesce(localStorage.getItem(c), () => (i)):i)))}var _clsx = require('clsx');var _tailwindmerge = require('tailwind-merge');function U(...e){return _tailwindmerge.twMerge.call(void 0, _clsx.clsx.call(void 0, e))}exports.a = w; exports.b = K; exports.c = z; exports.d = U; exports.e = d; exports.f = T; exports.g = j; exports.h = x; exports.i = u; exports.j = R; exports.k = i; exports.l = N; exports.m = _;
2
+ //# sourceMappingURL=chunk-7RGH57QG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-7RGH57QG.js","../src/lib/client-header.ts"],"names":["CLIENT_HEADER_NAME","CLIENT_HEADER_VALUE","SDK_VERSION"],"mappings":"AAAA,uuBAAuC,ICG1BA,CAAAA,CAAqB,kBAAA,CACrBC,CAAAA,CAAsB,CAAA,cAAA,EAAiBC,kBAAW,CAAA,CAAA","file":"/home/emems/web/bitsnap/bitsnap/bitsnap-react/dist/chunk-7RGH57QG.js","sourcesContent":[null,"import type { Interceptor } from \"@connectrpc/connect\";\nimport { SDK_VERSION } from \"../version\";\n\nexport const CLIENT_HEADER_NAME = \"X-Bitsnap-Client\";\nexport const CLIENT_HEADER_VALUE = `bitsnap-react@${SDK_VERSION}`;\n\nexport const CLIENT_QUERY_PARAM = \"bs_client\";\n\n/**\n * Spread into the `headers` of a fetch that already triggers a CORS preflight\n * (JSON POST, Connect RPC). Never use it on a simple cross-origin GET: the\n * custom header would force a preflight that older servers and merchant\n * proxies do not allow. Use `withClientParam` there.\n */\nexport const clientHeaders: Record<string, string> = {\n [CLIENT_HEADER_NAME]: CLIENT_HEADER_VALUE,\n};\n\n/** Connect interceptor adding the client header to every RPC. */\nexport const clientHeaderInterceptor: Interceptor = (next) => (req) => {\n req.header.set(CLIENT_HEADER_NAME, CLIENT_HEADER_VALUE);\n return next(req);\n};\n\n/** Adds `bs_client=<pkg>@<ver>` to a URL, for simple GETs that must stay preflight-free. */\nexport function withClientParam(url: string): string {\n const hash = url.indexOf(\"#\");\n const base = hash === -1 ? url : url.slice(0, hash);\n const fragment = hash === -1 ? \"\" : url.slice(hash);\n const separator = base.includes(\"?\") ? (/[?&]$/.test(base) ? \"\" : \"&\") : \"?\";\n return `${base}${separator}${CLIENT_QUERY_PARAM}=${encodeURIComponent(CLIENT_HEADER_VALUE)}${fragment}`;\n}\n"]}