@blotoutio/providers-blotout-wallet-sdk 0.44.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -1,38 +1,5 @@
1
1
  'use strict';
2
2
 
3
- /**
4
- * Returns whether A contains the entirety of B (A superset of B)
5
- *
6
- * A ⊇ B
7
- */
8
- const isSuperset = (a, b) => {
9
- for (const item of b) {
10
- if (!a.has(item)) {
11
- return false;
12
- }
13
- }
14
- return true;
15
- };
16
- /**
17
- * Returns whether A is entirely contained within B (A subset of B)
18
- *
19
- * A ⊆ B
20
- */
21
- const isSubset = (a, b) => {
22
- for (const item of a) {
23
- if (!b.has(item)) {
24
- return false;
25
- }
26
- }
27
- return true;
28
- };
29
- /**
30
- * Returns true when the two ets contain the same set of elements
31
- *
32
- * A = B
33
- */
34
- const areEquivalent = (a, b) => a.size == b.size && isSuperset(a, b) && isSubset(a, b);
35
-
36
3
  const expand = (str) => str.split(',').flatMap((entry) => {
37
4
  if (!entry.includes('-')) {
38
5
  return entry;
@@ -68,1079 +35,53 @@ new Set([
68
35
  ]);
69
36
 
70
37
  const packageName = 'blotoutWallet';
71
- const customAttributes = {
72
- '--bw-primary': { type: 'color', defaultValue: '#f25c2b' },
73
- '--bw-secondary': { type: 'color', defaultValue: '#172a41' },
74
- '--bw-button': { type: 'color', defaultValue: '#da2e3a' },
75
- '--bw-foreground': { type: 'color', defaultValue: 'white' },
76
- '--bw-input-border': { type: 'color', defaultValue: '#dbe2eb' },
77
- '--bw-input-foreground': { type: 'color', defaultValue: '#172a41' },
78
- '--bw-input-background': { type: 'color', defaultValue: 'white' },
79
- '--bw-backdrop': { type: 'color', defaultValue: '#00000077' },
80
- '--bw-z-index': { type: 'number', defaultValue: '9999' },
81
- };
38
+ const cartTokenCookie = 'cart';
39
+ const cartCurrencyCookie = 'cart_currency';
82
40
 
83
- const canLog = () => {
84
- try {
85
- return localStorage.getItem('edgeTagDebug') === '1';
86
- }
87
- catch {
88
- return false;
89
- }
90
- };
91
- const logger = {
92
- log: (...args) => {
93
- if (canLog()) {
94
- console.log(...args);
95
- }
96
- },
97
- error: (...args) => {
98
- if (canLog()) {
99
- console.error(...args);
100
- }
101
- },
102
- info: (...args) => {
103
- if (canLog()) {
104
- console.info(...args);
105
- }
106
- },
107
- trace: (...args) => {
108
- if (canLog()) {
109
- console.trace(...args);
110
- }
111
- },
112
- table: (...args) => {
113
- if (canLog()) {
114
- console.table(...args);
115
- }
116
- },
117
- dir: (...args) => {
118
- if (canLog()) {
119
- console.dir(...args);
120
- }
121
- },
122
- };
41
+ const init = () => { };
123
42
 
124
- // eslint-disable-next-line @nx/enforce-module-boundaries
125
- class APIError extends Error {
126
- constructor(...args) {
127
- super(...args);
128
- }
129
- }
130
- const getItemKey = (item) => `${item.productId}-${item.variantId}`;
131
- const postMessageKey = 'blotoutWallet';
132
- class WalletAPI {
133
- constructor({ baseUrl, userId, enabled }) {
134
- this.listeners = new Set();
135
- this._cart = { cartId: null, items: [], email: false };
136
- this.onWindowMessage = (event) => {
137
- var _a;
138
- if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.name) == postMessageKey) {
139
- this.cart = event.data.cart;
140
- }
141
- };
142
- this.baseUrl = baseUrl;
143
- this.userId = userId;
144
- this.enabled = enabled;
145
- logger.info(`[Blotout Wallet] User is ${enabled ? 'enabled' : 'disabled'}`);
146
- window.addEventListener('message', this.onWindowMessage);
147
- }
148
- getHeaders(json = false) {
149
- const headers = new Headers({
150
- EdgeTagUserId: this.userId,
151
- });
152
- if (json) {
153
- headers.set('Content-type', 'application/json; charset=utf-8');
154
- }
155
- return headers;
156
- }
157
- getUrl(path) {
158
- return `${this.baseUrl}/providers/blotoutWallet${path}`;
159
- }
160
- notify() {
161
- var _a;
162
- for (const listener of this.listeners) {
163
- try {
164
- listener(this.cart);
165
- }
166
- catch (err) {
167
- console.error(err);
168
- }
169
- }
170
- (_a = window.top) === null || _a === void 0 ? void 0 : _a.postMessage({ name: postMessageKey, cart: this.cart }, '*');
171
- }
172
- get cart() {
173
- return this._cart;
174
- }
175
- set cart(value) {
176
- if (this.isCartUpdated(value)) {
177
- this._cart = value;
178
- this.notify();
179
- }
180
- }
181
- isCartUpdated(value) {
182
- if (value.cartId != this.cart.cartId ||
183
- value.email != this.cart.email ||
184
- value.items.length != this.cart.items.length) {
185
- return true;
186
- }
187
- const newItemsMap = new Map(value.items.map((item) => [item.itemId, item]));
188
- const newItemsKeys = new Set(newItemsMap.keys());
189
- const currenItemsMap = new Map(this.cart.items.map((item) => [item.itemId, item]));
190
- const currentItemsKeys = new Set(currenItemsMap.keys());
191
- if (!areEquivalent(newItemsKeys, currentItemsKeys)) {
192
- return true;
193
- }
194
- for (const [key, newItem] of newItemsMap) {
195
- const currentItem = currenItemsMap.get(key);
196
- if (newItem.amount != currentItem.amount ||
197
- newItem.value != currentItem.value ||
198
- newItem.name != currentItem.name ||
199
- newItem.productId != currentItem.productId ||
200
- newItem.variantId != currentItem.variantId) {
201
- return true;
202
- }
43
+ const getCookieValue = (key) => {
44
+ try {
45
+ if (!document || !document.cookie) {
46
+ return '';
203
47
  }
204
- return false;
205
- }
206
- get segmentEnabled() {
207
- return this.enabled;
208
- }
209
- subscribe(listener) {
210
- this.listeners.add(listener);
211
- return () => {
212
- this.listeners.delete(listener);
213
- };
214
- }
215
- getCart() {
216
- return fetch(this.getUrl('/cart'), {
217
- method: 'GET',
218
- headers: this.getHeaders(),
219
- }).then(async (response) => {
220
- if (!response.ok) {
221
- throw new APIError(`Could not fetch cart contents`, {
222
- cause: response,
223
- });
48
+ const name = `${key}=`;
49
+ const decodedCookie = decodeURIComponent(document.cookie);
50
+ const ca = decodedCookie.split(';');
51
+ for (let i = 0; i < ca.length; i++) {
52
+ let c = ca[i];
53
+ while (c.charAt(0) === ' ') {
54
+ c = c.substring(1);
224
55
  }
225
- return (this.cart = await response.json());
226
- });
227
- }
228
- addItems(items) {
229
- return fetch(this.getUrl('/items'), {
230
- method: 'POST',
231
- headers: this.getHeaders(true),
232
- body: JSON.stringify(items),
233
- }).then(async (response) => {
234
- if (!response.ok) {
235
- throw new APIError(`Could not add items`, { cause: response });
236
- }
237
- return (this.cart = await response.json());
238
- });
239
- }
240
- removeItems(items) {
241
- const cartLookup = new Map(this._cart.items.map((item) => [getItemKey(item), item]));
242
- const itemLookup = new Map(items.map((item) => [getItemKey(item), item]));
243
- const updatedCartItems = [];
244
- for (const [itemKey, walletItem] of cartLookup.entries()) {
245
- const itemToRemove = itemLookup.get(itemKey);
246
- if (itemToRemove) {
247
- // if the removed amount is equal or greater, we simply don't push the
248
- // wallet item into the updated cart contents
249
- if (walletItem.amount > itemToRemove.amount) {
250
- walletItem.amount -= itemToRemove.amount;
251
- updatedCartItems.push(walletItem);
252
- }
253
- }
254
- else {
255
- updatedCartItems.push(walletItem);
56
+ if (c.indexOf(name) === 0) {
57
+ return c.substring(name.length, c.length);
256
58
  }
257
59
  }
258
- return this.setItems(updatedCartItems);
259
- }
260
- setItems(items) {
261
- return fetch(this.getUrl('/items'), {
262
- method: 'PUT',
263
- headers: this.getHeaders(true),
264
- body: JSON.stringify(items),
265
- }).then(async (response) => {
266
- if (!response.ok) {
267
- throw new APIError(`Could not set items`, { cause: response });
268
- }
269
- return (this.cart = await response.json());
270
- });
60
+ return '';
271
61
  }
272
- updateItem(item) {
273
- return fetch(this.getUrl(`/items/${item.itemId}`), {
274
- method: 'PUT',
275
- headers: this.getHeaders(true),
276
- body: JSON.stringify({
277
- name: item.name,
278
- productId: item.productId,
279
- amount: item.amount,
280
- value: item.value,
281
- }),
282
- }).then(async (response) => {
283
- if (!response.ok) {
284
- throw new APIError(`Could not update item`, { cause: response });
285
- }
286
- return (this.cart = await response.json());
287
- });
288
- }
289
- removeItem(itemId) {
290
- return fetch(this.getUrl(`/items/${itemId}`), {
291
- method: 'DELETE',
292
- headers: this.getHeaders(),
293
- }).then(async (response) => {
294
- if (!response.ok) {
295
- throw new APIError(`Could not remove item`, { cause: response });
296
- }
297
- return (this.cart = await response.json());
298
- });
299
- }
300
- saveEmail(email) {
301
- return fetch(this.getUrl('/cart/email'), {
302
- method: 'POST',
303
- body: JSON.stringify({ email }),
304
- headers: this.getHeaders(true),
305
- }).then((response) => {
306
- if (!response.ok) {
307
- throw new APIError('Could not save email', { cause: response });
308
- }
309
- this.cart.email = true;
310
- this.notify();
311
- });
312
- }
313
- restore() {
314
- return fetch(this.getUrl('/cart/restore'), {
315
- method: 'POST',
316
- headers: this.getHeaders(),
317
- }).then((response) => {
318
- if (!response.ok) {
319
- throw new APIError('Could not mark cart as restored', {
320
- cause: response,
321
- });
322
- }
323
- });
62
+ catch {
63
+ return '';
324
64
  }
325
- }
65
+ };
326
66
 
327
67
  var _a;
328
68
  const registryKey = Symbol.for('blotout-wallet');
329
69
  (_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
330
70
 
331
- /******************************************************************************
332
- Copyright (c) Microsoft Corporation.
333
-
334
- Permission to use, copy, modify, and/or distribute this software for any
335
- purpose with or without fee is hereby granted.
336
-
337
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
338
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
339
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
340
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
341
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
342
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
343
- PERFORMANCE OF THIS SOFTWARE.
344
- ***************************************************************************** */
345
- /* global Reflect, Promise, SuppressedError, Symbol */
346
-
347
-
348
- function __decorate(decorators, target, key, desc) {
349
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
350
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
351
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
352
- return c > 3 && r && Object.defineProperty(target, key, r), r;
353
- }
354
-
355
- function __metadata(metadataKey, metadataValue) {
356
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
357
- }
358
-
359
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
360
- var e = new Error(message);
361
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
362
- };
363
-
364
- /**
365
- * @license
366
- * Copyright 2019 Google LLC
367
- * SPDX-License-Identifier: BSD-3-Clause
368
- */
369
- const t$3=globalThis,e$6=t$3.ShadowRoot&&(void 0===t$3.ShadyCSS||t$3.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$4=new WeakMap;let n$4 = class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$6&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$4.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$4.set(s,t));}return t}toString(){return this.cssText}};const r$5=t=>new n$4("string"==typeof t?t:t+"",void 0,s$2),i$4=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$4(o,t,s$2)},S$1=(s,o)=>{if(e$6)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$3.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$6?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$5(e)})(t):t;
370
-
371
- /**
372
- * @license
373
- * Copyright 2017 Google LLC
374
- * SPDX-License-Identifier: BSD-3-Clause
375
- */const{is:i$3,defineProperty:e$5,getOwnPropertyDescriptor:r$4,getOwnPropertyNames:h$1,getOwnPropertySymbols:o$3,getPrototypeOf:n$3}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$3(t,s),y$1={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let b$1 = class b extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=y$1){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,s);void 0!==r&&e$5(this.prototype,t,r);}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r$4(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get(){return e?.call(this)},set(s){const r=e?.call(this);h.call(this,s),this.requestUpdate(t,r,i);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y$1}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$3(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...h$1(t),...o$3(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return !1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$EC(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==r?this.removeAttribute(e):this.setAttribute(e,r),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e,this[e]=r.fromAttribute(s,t.type),this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??f$1)(this[t],s))return;this.P(t,s,i);}!1===this.isUpdatePending&&(this._$ES=this._$ET());}P(t,s,i){this._$AL.has(t)||this._$AL.set(t,s),!0===i.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t);}async _$ET(){this.isUpdatePending=!0;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t)!0!==i.wrapped||this._$AL.has(s)||void 0===this[s]||this.P(s,this[s],i);}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EU();}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t);}_$EU(){this._$AL=new Map,this.isUpdatePending=!1;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return !0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU();}updated(t){}firstUpdated(t){}};b$1.elementStyles=[],b$1.shadowRootOptions={mode:"open"},b$1[d$1("elementProperties")]=new Map,b$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:b$1}),(a$1.reactiveElementVersions??=[]).push("2.0.4");
376
-
377
- /**
378
- * @license
379
- * Copyright 2017 Google LLC
380
- * SPDX-License-Identifier: BSD-3-Clause
381
- */
382
- const t$2=globalThis,i$2=t$2.trustedTypes,s$1=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$4="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$2="?"+h,n$2=`<${o$2}>`,r$3=document,l=()=>r$3.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),b=y(2),w=Symbol.for("lit-noChange"),T=Symbol.for("lit-nothing"),A=new WeakMap,E=r$3.createTreeWalker(r$3,129);function C(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$1?s$1.createHTML(i):i}const P=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n$2:d>=0?(o.push(a),s.slice(0,d)+e$4+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [C(t,l+(t[s]||"<?>")+(2===i?"</svg>":"")),o]};class V{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=P(t,s);if(this.el=V.createElement(f,n),E.currentNode=this.el.content,2===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=E.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$4)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?k:"?"===e[1]?H:"@"===e[1]?I:R}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$2?i$2.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),E.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$2)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r$3.createElement("template");return s.innerHTML=t,s}}function N(t,i,s=t,e){if(i===w)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=N(t,h._$AS(t,i.values),h,e)),i}class S{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r$3).importNode(i,!0);E.currentNode=e;let h=E.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new M(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new L(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=E.nextNode(),o++);}return E.currentNode=r$3,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class M{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=T,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=N(this,t,i),c(t)?t===T||null==t||""===t?(this._$AH!==T&&this._$AR(),this._$AH=T):t!==this._$AH&&t!==w&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}S(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t));}_(t){this._$AH!==T&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$3.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=V.createElement(C(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new S(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new V(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new M(this.S(l()),this.S(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class R{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=T,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=T;}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=N(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==w,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=N(this,e[s+n],i,n),r===w&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===T?t=T:t!==T&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===T?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class k extends R{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===T?void 0:t;}}class H extends R{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==T);}}class I extends R{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=N(this,t,i,0)??T)===w)return;const s=this._$AH,e=t===T&&s!==T||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==T&&(s===T||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class L{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){N(this,t);}}const Z=t$2.litHtmlPolyfillSupport;Z?.(V,M),(t$2.litHtmlVersions??=[]).push("3.1.3");const j=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new M(i.insertBefore(l(),t),t,void 0,s??{});}return h._$AI(t),h};
383
-
384
- /**
385
- * @license
386
- * Copyright 2017 Google LLC
387
- * SPDX-License-Identifier: BSD-3-Clause
388
- */class s extends b$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=j(i,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return w}}s._$litElement$=!0,s[("finalized")]=!0,globalThis.litElementHydrateSupport?.({LitElement:s});const r$2=globalThis.litElementPolyfillSupport;r$2?.({LitElement:s});(globalThis.litElementVersions??=[]).push("4.0.5");
389
-
390
- /**
391
- * @license
392
- * Copyright 2017 Google LLC
393
- * SPDX-License-Identifier: BSD-3-Clause
394
- */
395
- const t$1=t=>(e,o)=>{void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
396
-
397
- /**
398
- * @license
399
- * Copyright 2017 Google LLC
400
- * SPDX-License-Identifier: BSD-3-Clause
401
- */const o$1={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1},r$1=(t=o$1,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.P(o,void 0,t),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n$1(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,r?{...t,wrapped:!0}:t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
402
-
403
- /**
404
- * @license
405
- * Copyright 2017 Google LLC
406
- * SPDX-License-Identifier: BSD-3-Clause
407
- */function r(r){return n$1({...r,state:!0,attribute:!1})}
408
-
409
- /**
410
- * @license
411
- * Copyright 2017 Google LLC
412
- * SPDX-License-Identifier: BSD-3-Clause
413
- */
414
- const e$3=(e,t,c)=>(c.configurable=!0,c.enumerable=!0,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
415
-
416
- /**
417
- * @license
418
- * Copyright 2017 Google LLC
419
- * SPDX-License-Identifier: BSD-3-Clause
420
- */function e$2(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;if(r){const{get:e,set:r}="object"==typeof s?n:i??(()=>{const t=Symbol();return {get(){return this[t]},set(e){this[t]=e;}}})();return e$3(n,s,{get(){let t=e.call(this);return void 0===t&&(t=o(this),(null!==t||this.hasUpdated)&&r.call(this,t)),t}})}return e$3(n,s,{get(){return o(this)}})}}
421
-
422
- /**
423
- * @license
424
- * Copyright 2017 Google LLC
425
- * SPDX-License-Identifier: BSD-3-Clause
426
- */
427
- const t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e$1=t=>(...e)=>({_$litDirective$:t,values:e});let i$1 = class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};
428
-
429
- /**
430
- * @license
431
- * Copyright 2018 Google LLC
432
- * SPDX-License-Identifier: BSD-3-Clause
433
- */const e=e$1(class extends i$1{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter((s=>t[s])).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return w}});
434
-
435
- /**
436
- * @license
437
- * Copyright 2018 Google LLC
438
- * SPDX-License-Identifier: BSD-3-Clause
439
- */const n="important",i=" !"+n,o=e$1(class extends i$1{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"style"!==t$1.name||t$1.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce(((e,r)=>{const s=t[r];return null==s?e:e+`${r=r.includes("-")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`}),"")}update(e,[r]){const{style:s}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(r)),this.render(r);for(const t of this.ft)null==r[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in r){const e=r[t];if(null!=e){this.ft.add(t);const r="string"==typeof e&&e.endsWith(i);t.includes("-")||r?s.setProperty(t,r?e.slice(0,-11):e,r?n:""):s[t]=e;}}return w}});
440
-
441
- const bounce = 'linear(0, 0.004, 0.016, 0.035, 0.063, 0.098, 0.141 13.6%, 0.25, 0.391, 0.563, 0.765, 1, 0.891 40.9%, 0.848, 0.813, 0.785, 0.766, 0.754, 0.75, 0.754, 0.766, 0.785, 0.813, 0.848, 0.891 68.2%, 1 72.7%, 0.973, 0.953, 0.941, 0.938, 0.941, 0.953, 0.973, 1, 0.988, 0.984, 0.988, 1)';
442
- const spring = 'linear(0, 0.009, 0.035 2.1%, 0.141, 0.281 6.7%, 0.723 12.9%, 0.938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%, 0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1.004 83.8%, 1)';
443
-
444
- const cssVars = i$4 `
445
- :host {
446
- --primary: var(
447
- --bw-primary,
448
- ${r$5(customAttributes['--bw-primary'].defaultValue)}
449
- );
450
- --secondary: var(
451
- --bw-secondary,
452
- ${r$5(customAttributes['--bw-secondary'].defaultValue)}
453
- );
454
- --button: var(
455
- --bw-button,
456
- ${r$5(customAttributes['--bw-button'].defaultValue)}
457
- );
458
- --foreground: var(
459
- --bw-foreground,
460
- ${r$5(customAttributes['--bw-foreground'].defaultValue)}
461
- );
462
- --input-border: var(
463
- --bw-input-border,
464
- ${r$5(customAttributes['--bw-input-border'].defaultValue)}
465
- );
466
- --input-foreground: var(
467
- --bw-input-foreground,
468
- ${r$5(customAttributes['--bw-input-foreground'].defaultValue)}
469
- );
470
- --input-background: var(
471
- --bw-input-background,
472
- ${r$5(customAttributes['--bw-input-background'].defaultValue)}
473
- );
474
- --backdrop: var(
475
- --bw-backdrop,
476
- ${r$5(customAttributes['--bw-backdrop'].defaultValue)}
477
- );
478
- --z-index: var(
479
- --bw-z-index,
480
- ${r$5(customAttributes['--bw-z-index'].defaultValue)}
481
- );
482
-
483
- --spring-easing: ${r$5(spring)};
484
-
485
- --bounce-easing: ${r$5(bounce)};
486
- }
487
- `;
488
-
489
- const wallet = (attrs) => b `<svg
490
- width="32"
491
- height="22"
492
- viewBox="0 0 32 22"
493
- fill="none"
494
- xmlns="http://www.w3.org/2000/svg"
495
- class=${attrs === null || attrs === void 0 ? void 0 : attrs.class}
496
- style=${attrs === null || attrs === void 0 ? void 0 : attrs.style}
497
- >
498
- <g>
499
- <path
500
- fill-rule="evenodd"
501
- clip-rule="evenodd"
502
- d="M29.2312 0H2.7688C1.24278 0 0 1.24278 0 2.7688V18.7688C0 20.2959 1.24278 21.5376 2.7688 21.5376H29.2301C30.7572 21.5376 31.9989 20.2948 31.9989 18.7688V14.7691H22.1525C21.6431 14.7691 21.2296 14.3555 21.2296 13.8461V7.69254C21.2296 7.18315 21.6431 6.7696 22.1525 6.7696H31.9989V2.7688C31.9989 1.2417 30.7561 0 29.2301 0H29.2312ZM8.92347 18.1582C7.76038 18.1582 6.69206 17.7532 5.85098 17.0769V17.554C5.85098 17.7037 5.85098 17.778 5.8219 17.8351C5.79606 17.8857 5.75513 17.9266 5.70559 17.9514C5.64852 17.9805 5.57421 17.9805 5.42451 17.9805H4.43266C4.28404 17.9805 4.20866 17.9805 4.15158 17.9514C4.10096 17.9256 4.06112 17.8846 4.03527 17.8351C4.00619 17.778 4.00619 17.7037 4.00619 17.554V4.02558C4.00619 3.87588 4.00619 3.80158 4.03527 3.7445C4.06112 3.69388 4.10204 3.65296 4.15158 3.62819C4.20866 3.59911 4.28296 3.59911 4.43266 3.59911H5.42451C5.57313 3.59911 5.64852 3.59911 5.70559 3.62819C5.75621 3.65404 5.79606 3.69496 5.8219 3.7445C5.85098 3.80158 5.85098 3.87696 5.85098 4.02558V9.37686C6.69314 8.70055 7.76146 8.29562 8.92347 8.29562C11.6384 8.29562 13.8397 10.5033 13.8397 13.2269C13.8397 15.9505 11.6384 18.1582 8.92347 18.1582Z"
503
- fill="currentColor"
504
- />
505
- <path
506
- d="M8.92308 16.3091C10.62 16.3091 11.9956 14.9292 11.9956 13.227C11.9956 11.5247 10.62 10.1448 8.92308 10.1448C7.22619 10.1448 5.85059 11.5247 5.85059 13.227C5.85059 14.9292 7.22619 16.3091 8.92308 16.3091Z"
507
- fill="currentColor"
508
- />
509
- <path
510
- fill-rule="evenodd"
511
- clip-rule="evenodd"
512
- d="M23.0771 12.9232H32.0006V8.61548H23.0771V12.9232ZM24.615 9.84641H25.8459C26.3553 9.84641 26.7689 10.26 26.7689 10.7693C26.7689 11.2787 26.3553 11.6923 25.8459 11.6923H24.615C24.1056 11.6923 23.6921 11.2787 23.6921 10.7693C23.6921 10.26 24.1056 9.84641 24.615 9.84641Z"
513
- fill="currentColor"
514
- />
515
- </g>
516
- </svg>`;
517
- const blotout = (attrs) => b `<svg
518
- width="26"
519
- height="36"
520
- viewBox="0 0 26 36"
521
- fill="none"
522
- xmlns="http://www.w3.org/2000/svg"
523
- class=${attrs === null || attrs === void 0 ? void 0 : attrs.class}
524
- style=${attrs === null || attrs === void 0 ? void 0 : attrs.style}
525
- >
526
- <path
527
- fill-rule="evenodd"
528
- clip-rule="evenodd"
529
- d="M0.830995 0.42104C0.75879 0.56208 0.758789 0.746712 0.758789 1.11598V34.5089C0.758789 34.8782 0.75879 35.0628 0.830995 35.2038C0.894508 35.3279 0.995851 35.4288 1.1205 35.4921C1.26221 35.5638 1.44772 35.5638 1.81874 35.5638H4.28515C4.65617 35.5638 4.84167 35.5638 4.98338 35.4921C5.10803 35.4288 5.20938 35.3279 5.27289 35.2038C5.3451 35.0628 5.3451 34.8782 5.3451 34.5089V33.3303C7.4389 35.0007 10.0967 36 12.9889 36C19.7435 36 25.2191 30.5502 25.2191 23.8275C25.2191 17.1049 19.7435 11.6552 12.9889 11.6552C10.0967 11.6552 7.4389 12.6544 5.3451 14.3249V1.11598C5.3451 0.746712 5.3451 0.56208 5.27289 0.42104C5.20938 0.296978 5.10803 0.196112 4.98338 0.132899C4.84167 0.0610352 4.65617 0.0610352 4.28515 0.0610352H1.81874C1.44772 0.0610352 1.26221 0.0610352 1.1205 0.132899C0.995851 0.196112 0.894508 0.296978 0.830995 0.42104ZM5.3451 23.8275C5.3451 28.0292 8.76736 31.4353 12.9889 31.4353C17.2105 31.4353 20.6328 28.0292 20.6328 23.8275C20.6328 19.626 17.2105 16.2198 12.9889 16.2198C8.76736 16.2198 5.3451 19.626 5.3451 23.8275Z"
530
- fill="currentColor"
531
- />
532
- </svg>`;
533
- const wink = (attrs) => b `<svg
534
- width="18"
535
- height="18"
536
- viewBox="0 0 18 18"
537
- fill="none"
538
- xmlns="http://www.w3.org/2000/svg"
539
- class=${attrs === null || attrs === void 0 ? void 0 : attrs.class}
540
- style=${attrs === null || attrs === void 0 ? void 0 : attrs.style}
541
- >
542
- <g>
543
- <path
544
- d="M9.5 1.125C7.94248 1.125 6.41992 1.58686 5.12489 2.45218C3.82985 3.31749 2.82049 4.5474 2.22445 5.98637C1.62841 7.42534 1.47246 9.00874 1.77632 10.5363C2.08018 12.0639 2.8302 13.4671 3.93154 14.5685C5.03288 15.6698 6.43607 16.4198 7.96367 16.7237C9.49127 17.0275 11.0747 16.8716 12.5136 16.2756C13.9526 15.6795 15.1825 14.6702 16.0478 13.3751C16.9131 12.0801 17.375 10.5575 17.375 9C17.375 6.91142 16.5453 4.90838 15.0685 3.43153C13.5916 1.95469 11.5886 1.125 9.5 1.125ZM9.5 15.75C8.16498 15.75 6.85994 15.3541 5.7499 14.6124C4.63987 13.8707 3.77471 12.8165 3.26382 11.5831C2.75293 10.3497 2.61925 8.99251 2.8797 7.68314C3.14015 6.37377 3.78303 5.17103 4.72703 4.22703C5.67104 3.28302 6.87377 2.64015 8.18314 2.3797C9.49252 2.11925 10.8497 2.25292 12.0831 2.76381C13.3165 3.2747 14.3707 4.13987 15.1124 5.2499C15.8541 6.35993 16.25 7.66498 16.25 9C16.25 10.7902 15.5388 12.5071 14.273 13.773C13.0071 15.0388 11.2902 15.75 9.5 15.75Z"
545
- fill="currentColor"
546
- />
547
- <path
548
- d="M12.0313 6.1875C11.7531 6.1875 11.4812 6.26997 11.25 6.4245C11.0187 6.57902 10.8385 6.79864 10.732 7.0556C10.6256 7.31256 10.5978 7.59531 10.652 7.8681C10.7063 8.14088 10.8402 8.39145 11.0369 8.58812C11.2335 8.78479 11.4841 8.91872 11.7569 8.97298C12.0297 9.02724 12.3124 8.99939 12.5694 8.89296C12.8264 8.78652 13.046 8.60628 13.2005 8.37502C13.355 8.14376 13.4375 7.87188 13.4375 7.59375C13.4375 7.22079 13.2893 6.8631 13.0256 6.59938C12.7619 6.33566 12.4042 6.1875 12.0313 6.1875Z"
549
- fill="currentColor"
550
- />
551
- <path d="M8.375 7.3125H5V8.4375H8.375V7.3125Z" fill="white" />
552
- <path
553
- d="M9.49961 13.5001C10.2761 13.4988 11.039 13.2966 11.7142 12.9132C12.3893 12.5298 12.9538 11.9782 13.3527 11.312L12.3909 10.7495C12.0907 11.248 11.6667 11.6604 11.1601 11.9467C10.6535 12.233 10.0815 12.3834 9.49961 12.3834C8.91771 12.3834 8.3457 12.233 7.83911 11.9467C7.33251 11.6604 6.90854 11.248 6.60836 10.7495L5.64648 11.312C6.04539 11.9782 6.60987 12.5298 7.28506 12.9132C7.96024 13.2966 8.72315 13.4988 9.49961 13.5001Z"
554
- fill="currentColor"
555
- />
556
- </g>
557
- </svg> `;
558
- const cross = (attrs) => b `<svg
559
- width="32"
560
- height="32"
561
- viewBox="0 0 32 32"
562
- fill="none"
563
- xmlns="http://www.w3.org/2000/svg"
564
- class=${attrs === null || attrs === void 0 ? void 0 : attrs.class}
565
- style=${attrs === null || attrs === void 0 ? void 0 : attrs.style}
566
- >
567
- <g>
568
- <path
569
- d="M17.4141 16L24 9.4141L22.5859 8L16 14.5859L9.4143 8L8 9.4141L14.5859 16L8 22.5859L9.4143 24L16 17.4141L22.5859 24L24 22.5859L17.4141 16Z"
570
- fill="currentColor"
571
- />
572
- </g>
573
- </svg> `;
574
-
575
- const fadeInDialog = (element) => {
576
- const dialogAnimation = element.animate([
577
- { transform: 'translateY(-20px)', opacity: 0 },
578
- { transform: 'translateY(0)', opacity: 1 },
579
- ], { duration: 600, easing: spring, composite: 'add' });
580
- const backdropAnimation = element.animate([{ opacity: 0 }, { opacity: 1 }], {
581
- duration: 300,
582
- easing: 'ease-out',
583
- pseudoElement: '::backdrop',
584
- fill: 'forwards',
585
- });
586
- return Promise.all([dialogAnimation.finished, backdropAnimation.finished]);
587
- };
588
- const fadeOutToBottom = (element) => {
589
- const dialogAnimation = element.animate([
590
- { transform: 'translateY(0)', opacity: 1 },
591
- { transform: 'translateY(20px)', opacity: 0 },
592
- ], { duration: 600, easing: spring });
593
- const backdropAnimation = element.animate([{ opacity: 1 }, { opacity: 0 }], {
594
- duration: 300,
595
- easing: 'ease-out',
596
- pseudoElement: '::backdrop',
597
- fill: 'forwards',
598
- });
599
- return Promise.all([dialogAnimation.finished, backdropAnimation.finished]);
600
- };
601
- const springInFromLeft = (element, offset = '100%') => element.animate([{ transform: `translateX(-${offset})` }, { transform: 'translateX(0)' }], { duration: 600, easing: bounce, composite: 'add' }).finished;
602
- const springInFromRight = (element, offset = '100%') => element.animate([{ transform: `translateX(${offset})` }, { transform: 'translateX(0)' }], { duration: 600, easing: bounce, composite: 'add' }).finished;
603
- const springInFromTop = (element, offset = '100%') => element.animate([{ transform: `translateY(-${offset})` }, { transform: 'translateY(0)' }], { duration: 600, easing: bounce, composite: 'add' }).finished;
604
- const springInFromBottom = (element, offset = '100%') => element.animate([{ transform: `translateY(${offset})` }, { transform: 'translateY(0)' }], { duration: 600, easing: bounce, composite: 'add' }).finished;
605
- const springOutToLeft = (element, offset = '100%') => element.animate([{ transform: 'translateX(0)' }, { transform: `translateX(-${offset})` }], { duration: 600, easing: bounce, composite: 'add' }).finished;
606
- const springOutToRight = (element, offset = '100%') => element.animate([{ transform: 'translateX(0)' }, { transform: `translateX(${offset})` }], { duration: 600, easing: bounce, composite: 'add' }).finished;
607
- const springOutToTop = (element, offset = '100%') => element.animate([{ transform: 'translateY(0)' }, { transform: `translateY(-${offset})` }], { duration: 600, easing: bounce, composite: 'add' }).finished;
608
- const springOutToBottom = (element, offset = '100%') => element.animate([{ transform: 'translateY(0)' }, { transform: `translateY(${offset})` }], { duration: 600, easing: bounce, composite: 'add' }).finished;
609
-
610
- const validPositions = new Set([
611
- 'bottom',
612
- 'bottom-left',
613
- 'bottom-right',
614
- 'left',
615
- 'right',
616
- 'top',
617
- 'top-left',
618
- 'top-right',
619
- ]);
620
- const wait = (timeout) => new Promise((res) => setTimeout(res, timeout));
621
- let BlotoutWallet = class BlotoutWallet extends s {
622
- constructor() {
623
- super(...arguments);
624
- this.buttonVisible = false;
625
- this.bannerVisible = false;
626
- this.hasItemsInWallet = false;
627
- this.hasEmail = false;
628
- this.onWalletUpdated = (walletContent) => {
629
- logger.log('[Blotout Wallet] Cart updated', walletContent);
630
- this.hasItemsInWallet = walletContent.items.length > 0;
631
- this.hasEmail = walletContent.email;
632
- if (this.isSegmentEnabled && (this.hasItemsInWallet || !this.hasEmail)) {
633
- this.showButton();
634
- }
635
- else if (!this.hasItemsInWallet && this.hasEmail) {
636
- this.hideButton();
637
- }
638
- };
639
- this.onSubmit = (ev) => {
640
- var _a;
641
- ev.preventDefault();
642
- ev.stopPropagation();
643
- const modalAnimation = this.hideModal();
644
- const email = (_a = this.email) === null || _a === void 0 ? void 0 : _a.value.trim();
645
- if (email) {
646
- this.walletApi.saveEmail(email)
647
- .then(() => {
648
- this.email.value = '';
649
- this.hasEmail = true;
650
- this.dispatchEvent(new CustomEvent('blotout-wallet-email-saved', { bubbles: true }));
651
- })
652
- .catch((err) => logger.error(err));
653
- }
654
- if (this.hasItemsInWallet) {
655
- this.storeApi.addItems(this.walletApi.cart.items)
656
- .then(() => this.walletApi.restore())
657
- .then(() => {
658
- this.dispatchEvent(new CustomEvent('blotout-wallet-restored', { bubbles: true }));
659
- return modalAnimation.then(() => this.showRestorationBanner());
660
- })
661
- .then(() => wait(1000))
662
- .then(() => (window.location.href = `${window.Shopify.routes.root}cart`))
663
- .catch((err) => logger.error(err));
664
- }
665
- };
666
- this.showRestorationBanner = async () => {
667
- if (this.bannerVisible) {
668
- return;
669
- }
670
- this.bannerVisible = true;
671
- await new Promise(requestAnimationFrame);
672
- await springInFromBottom(this.banner, '120%');
673
- };
674
- this.hideRestorationBanner = async () => {
675
- if (!this.bannerVisible) {
676
- return;
677
- }
678
- await springOutToBottom(this.banner, '120%');
679
- this.bannerVisible = false;
680
- };
681
- }
682
- get storeApi() {
683
- var _a;
684
- return (_a = window[registryKey]) === null || _a === void 0 ? void 0 : _a.storeAPI;
685
- }
686
- get walletApi() {
687
- var _a;
688
- return (_a = window[registryKey]) === null || _a === void 0 ? void 0 : _a.walletAPI;
689
- }
690
- get isSegmentEnabled() {
691
- var _a;
692
- return (_a = this.walletApi) === null || _a === void 0 ? void 0 : _a.segmentEnabled;
693
- }
694
- get _position() {
695
- return validPositions.has(this.position) ? this.position : 'bottom-left';
696
- }
697
- connectedCallback() {
698
- var _a;
699
- super.connectedCallback();
700
- this.unsubscribe = (_a = this.walletApi) === null || _a === void 0 ? void 0 : _a.subscribe(this.onWalletUpdated);
701
- this.syncItems().then(() => {
702
- this.dispatchEvent(new CustomEvent('blotout-wallet-loaded', { bubbles: true }));
703
- });
704
- }
705
- disconnectedCallback() {
706
- var _a;
707
- super.disconnectedCallback();
708
- (_a = this.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
709
- this.unsubscribe = undefined;
710
- }
711
- async syncItems() {
712
- if (!this.walletApi) {
713
- logger.error('The required APIs are not available');
714
- return false;
715
- }
716
- const savedCart = await this.walletApi.getCart();
717
- this.hasEmail = savedCart.email;
718
- return savedCart.items.length > 0;
719
- }
720
- async showButton() {
721
- if (this.buttonVisible) {
722
- return;
723
- }
724
- this.buttonVisible = true;
725
- await new Promise(requestAnimationFrame).then(() => {
726
- switch (this.position) {
727
- case 'top-left':
728
- case 'left':
729
- case 'bottom-left': {
730
- return springInFromLeft(this.button);
731
- }
732
- case 'top-right':
733
- case 'right':
734
- case 'bottom-right': {
735
- return springInFromRight(this.button);
736
- }
737
- case 'bottom': {
738
- return springInFromBottom(this.button);
739
- }
740
- case 'top': {
741
- return springInFromTop(this.button);
742
- }
743
- default: {
744
- return springInFromLeft(this.button);
745
- }
746
- }
747
- });
748
- this.dispatchEvent(new CustomEvent('blotout-wallet-shown', { bubbles: true }));
749
- }
750
- async hideButton() {
751
- if (!this.buttonVisible) {
752
- return;
753
- }
754
- switch (this.position) {
755
- case 'top-left':
756
- case 'left':
757
- case 'bottom-left': {
758
- await springOutToLeft(this.button);
759
- break;
760
- }
761
- case 'top-right':
762
- case 'right':
763
- case 'bottom-right': {
764
- await springOutToRight(this.button);
765
- break;
766
- }
767
- case 'bottom': {
768
- await springOutToBottom(this.button);
769
- break;
770
- }
771
- case 'top': {
772
- await springOutToTop(this.button);
773
- break;
774
- }
775
- default: {
776
- await springOutToLeft(this.button);
777
- }
778
- }
779
- this.buttonVisible = false;
780
- this.dispatchEvent(new CustomEvent('blotout-wallet-hidden', { bubbles: true }));
781
- }
782
- async showModal() {
783
- this.dialog.showModal();
784
- await new Promise(requestAnimationFrame);
785
- await fadeInDialog(this.dialog);
786
- }
787
- async hideModal() {
788
- await fadeOutToBottom(this.dialog);
789
- this.dialog.close();
790
- }
791
- render() {
792
- return x `
793
- <button
794
- class="${e({
795
- cta: true,
796
- [this._position]: true,
797
- hidden: !this.buttonVisible,
798
- })}"
799
- @click=${this.showModal}
800
- >
801
- ${wallet({ class: 'icon' })}
802
- </button>
803
-
804
- <dialog>
805
- <button class="dismiss" @click=${this.hideModal}>${cross()}</button>
806
- ${blotout({ class: 'logo' })}
807
- <form method="dialog" @submit=${this.onSubmit}>
808
- ${this.hasItemsInWallet
809
- ? x `<p>
810
- Hey! Your <strong>cart has expired!</strong><br />But we've got
811
- you covered. ${wink({ style: 'vertical-align:middle' })}
812
- </p>`
813
- : x `<p>
814
- Carts expire in 7 days.<br />But we can save your carts for life
815
- ${wink({ style: 'vertical-align:middle' })}
816
- </p>`}
817
-
818
- <p>
819
- <input
820
- type="email"
821
- name="email"
822
- placeholder="Enter your email ID"
823
- ?required=${!this.hasEmail}
824
- style=${o({
825
- display: this.hasEmail ? 'none' : 'block',
826
- })}
827
- />
828
- </p>
829
- <p>
830
- <button class="restore" type="submit">
831
- ${this.hasItemsInWallet ? 'Restore Cart' : 'Save Cart'}
832
- </button>
833
- </p>
834
- </form>
835
- </dialog>
836
-
837
- <div
838
- class="banner"
839
- style=${o({ display: this.bannerVisible ? '' : 'none' })}
840
- >
841
- ${blotout({
842
- class: 'logo',
843
- style: 'height: 18px',
844
- })}
845
- <div>Cart restored!</div>
846
- </div>
847
- `;
848
- }
849
- };
850
- BlotoutWallet.styles = [
851
- cssVars,
852
- i$4 `
853
- * {
854
- box-sizing: border-box;
855
- font-family: inherit;
856
- font-size: 16px;
857
- line-height: 24px;
858
- }
859
-
860
- strong {
861
- font-weight: bold;
862
- }
863
-
864
- button {
865
- cursor: pointer;
866
- }
867
-
868
- .cta {
869
- position: fixed;
870
- z-index: var(--z-index);
871
- background: var(--button);
872
- color: var(--foreground);
873
- padding: 8px;
874
- border: none;
875
- }
876
-
877
- .top-left {
878
- border-radius: 0 4px 4px 0;
879
- left: 0;
880
- top: 4px;
881
- }
882
-
883
- .top {
884
- border-radius: 0 0 4px 4px;
885
- left: 50%;
886
- top: 0;
887
- transform: translateX(-50%);
888
- }
889
-
890
- .top-right {
891
- border-radius: 4px 0 0 4px;
892
- right: 0;
893
- top: 4px;
894
- }
895
-
896
- .left {
897
- border-radius: 0 4px 4px 0;
898
- left: 0;
899
- top: 50%;
900
- transform: translateY(-50%);
901
- }
902
-
903
- .right {
904
- border-radius: 4px 0 0 4px;
905
- right: 0;
906
- top: 50%;
907
- transform: translateY(-50%);
908
- }
909
-
910
- .bottom-left {
911
- border-radius: 0 4px 4px 0;
912
- left: 0;
913
- bottom: 4px;
914
- }
915
-
916
- .bottom {
917
- border-radius: 4px 4px 0 0;
918
- left: 50%;
919
- bottom: 0;
920
- transform: translateX(-50%);
921
- }
922
-
923
- .bottom-right {
924
- border-radius: 4px 0 0 4px;
925
- right: 0;
926
- bottom: 4px;
927
- }
928
-
929
- .hidden {
930
- display: none;
931
- }
932
-
933
- .icon {
934
- display: block;
935
- }
936
-
937
- .logo {
938
- color: var(--primary);
939
- }
940
-
941
- dialog {
942
- width: 430px;
943
- max-width: 100vw;
944
- background: var(--secondary);
945
- color: var(--foreground);
946
- border: 0 solid transparent;
947
- border-top: 4px solid var(--primary);
948
- border-radius: 20px;
949
- padding: 24px;
950
- text-align: center;
951
- }
952
-
953
- dialog::backdrop {
954
- background: var(--backdrop);
955
- backdrop-filter: blur(4px);
956
- }
957
-
958
- .dismiss {
959
- position: absolute;
960
- right: 20px;
961
- top: 20px;
962
- padding: 0;
963
- border: 0;
964
- border: 0;
965
- background: transparent;
966
- color: var(--foreground);
967
- cursor: pointer;
968
- }
969
-
970
- .dismiss > svg {
971
- display: block;
972
- width: 32px;
973
- height: 32px;
974
- }
975
-
976
- input[name='email'] {
977
- box-sizing: border-box;
978
- width: 100%;
979
- border: 1px solid var(--input-border);
980
- color: var(--input-foreground);
981
- background: var(--input-background);
982
- padding: 10px 16px;
983
- border-radius: 5px;
984
- }
985
-
986
- input[name='email']::placeholder {
987
- color: var(--input-foreground);
988
- }
989
-
990
- .restore {
991
- width: 100%;
992
- border: none;
993
- color: var(--foreground);
994
- background: var(--primary);
995
- border-radius: 5px;
996
- padding: 10px 16px;
997
- }
998
-
999
- .banner {
1000
- position: fixed;
1001
- z-index: var(--z-index);
1002
- bottom: 8px;
1003
- left: 50%;
1004
- padding: 12px 32px;
1005
- border-radius: 32px;
1006
- transform: translateX(-50%);
1007
- color: var(--foreground);
1008
- background: var(--secondary);
1009
- border: none;
1010
- border-bottom: 3px solid var(--primary);
1011
- display: flex;
1012
- gap: 8px;
1013
- align-items: center;
1014
- pointer-events: none;
1015
- }
1016
- `,
1017
- ];
1018
- __decorate([
1019
- n$1({ type: String }),
1020
- __metadata("design:type", Object)
1021
- ], BlotoutWallet.prototype, "position", void 0);
1022
- __decorate([
1023
- e$2('dialog'),
1024
- __metadata("design:type", HTMLDialogElement)
1025
- ], BlotoutWallet.prototype, "dialog", void 0);
1026
- __decorate([
1027
- e$2('button.cta'),
1028
- __metadata("design:type", HTMLButtonElement)
1029
- ], BlotoutWallet.prototype, "button", void 0);
1030
- __decorate([
1031
- e$2('input[name=email]'),
1032
- __metadata("design:type", HTMLInputElement)
1033
- ], BlotoutWallet.prototype, "email", void 0);
1034
- __decorate([
1035
- e$2('.banner'),
1036
- __metadata("design:type", HTMLDivElement)
1037
- ], BlotoutWallet.prototype, "banner", void 0);
1038
- __decorate([
1039
- r(),
1040
- __metadata("design:type", Boolean)
1041
- ], BlotoutWallet.prototype, "buttonVisible", void 0);
1042
- __decorate([
1043
- r(),
1044
- __metadata("design:type", Boolean)
1045
- ], BlotoutWallet.prototype, "bannerVisible", void 0);
1046
- __decorate([
1047
- r(),
1048
- __metadata("design:type", Boolean)
1049
- ], BlotoutWallet.prototype, "hasItemsInWallet", void 0);
1050
- __decorate([
1051
- r(),
1052
- __metadata("design:type", Boolean)
1053
- ], BlotoutWallet.prototype, "hasEmail", void 0);
1054
- BlotoutWallet = __decorate([
1055
- t$1('blotout-wallet')
1056
- ], BlotoutWallet);
1057
-
1058
- const init = (params) => {
1059
- var _a, _b, _c;
1060
- if (
1061
- // if loaded in non-browser SDKs
1062
- !window ||
1063
- !document) {
1064
- return;
1065
- }
1066
- let walletAPI = window[registryKey].walletAPI;
1067
- if (!window[registryKey].walletAPI) {
1068
- walletAPI = window[registryKey].walletAPI = new WalletAPI({
1069
- baseUrl: params.baseUrl,
1070
- userId: params.userId,
1071
- enabled: !!((_a = params.manifest.variables) === null || _a === void 0 ? void 0 : _a['enabled']),
1072
- });
1073
- }
1074
- let store = window[registryKey].storeAPI;
1075
- if (!store) {
1076
- store = window[registryKey].storeAPI =
1077
- (_c = (_b = window[registryKey]).storeAPIFactory) === null || _c === void 0 ? void 0 : _c.call(_b);
1078
- if (!store) {
1079
- throw new Error('Implementation for store API missing!');
1080
- }
1081
- }
1082
- const initComponent = () => {
1083
- var _a, _b;
1084
- const element = (window[registryKey].wallet =
1085
- document.createElement('blotout-wallet'));
1086
- const theme = (_a = params.manifest.variables) === null || _a === void 0 ? void 0 : _a['theme'];
1087
- if (theme) {
1088
- element.style.cssText = Object.entries(theme)
1089
- .map(([name, value]) => `${name}:${value}`)
1090
- .join(';');
1091
- }
1092
- const position = (_b = params.manifest.variables) === null || _b === void 0 ? void 0 : _b['position'];
1093
- if (position) {
1094
- element.setAttribute('position', position);
1095
- }
1096
- document.body.append(element);
1097
- };
1098
- if (window.top === window && !window[registryKey].wallet) {
1099
- if (params.isNewUser) {
1100
- // sync items from cart to wallet if a new user is detected
1101
- store
1102
- .getCart()
1103
- .then((cartContent) => walletAPI.addItems(cartContent).catch(logger.error))
1104
- .then(() => initComponent())
1105
- .catch((err) => logger.error(err));
1106
- }
1107
- else {
1108
- initComponent();
1109
- }
1110
- }
1111
- };
1112
-
1113
- const transformItems = (data) => {
1114
- var _a;
1115
- return (_a = data.contents) === null || _a === void 0 ? void 0 : _a.map((item) => ({
1116
- productId: item.id,
1117
- variantId: item.variantId || null,
1118
- name: item.title || item.description || '',
1119
- amount: parseInt(item.quantity.toString()),
1120
- value: parseFloat(item.item_price.toString()),
1121
- }));
1122
- };
1123
- const tag = (params) => {
1124
- var _a;
1125
- if (!((_a = window === null || window === void 0 ? void 0 : window[registryKey]) === null || _a === void 0 ? void 0 : _a.walletAPI)) {
1126
- logger.error(`[Blotout Wallet] No wallet API available`);
71
+ // eslint-disable-next-line @nx/enforce-module-boundaries
72
+ const tag = () => {
73
+ if (!window) {
1127
74
  return;
1128
75
  }
1129
- const wallet = window[registryKey].walletAPI;
1130
- switch (params.eventName) {
1131
- case 'AddToCart': {
1132
- const items = transformItems(params.data);
1133
- if (items === null || items === void 0 ? void 0 : items.length) {
1134
- wallet.addItems(items).catch(logger.error);
1135
- }
1136
- return;
76
+ const platform = window[registryKey].platform;
77
+ switch (platform) {
78
+ case 'SHOPIFY': {
79
+ const cartToken = getCookieValue(cartTokenCookie);
80
+ const cartCurrency = getCookieValue(cartCurrencyCookie);
81
+ return { platform, cartToken, cartCurrency };
1137
82
  }
1138
- case 'RemoveFromCart': {
1139
- const items = transformItems(params.data);
1140
- if (items === null || items === void 0 ? void 0 : items.length) {
1141
- wallet.removeItems(items).catch(logger.error);
1142
- }
1143
- return;
83
+ default: {
84
+ return {};
1144
85
  }
1145
86
  }
1146
87
  };