ui.shipaid.com 0.0.6 → 0.0.7
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/README.md +78 -0
- package/dist/ui.shipaid.com.es.js +168 -20
- package/dist/ui.shipaid.com.iife.js +162 -15
- package/dist/ui.shipaid.com.umd.js +162 -15
- package/package.json +2 -5
- package/types/shipaid.ts +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# ShipAid Shopify Widget
|
|
2
|
+
|
|
3
|
+
This is the repository for the ShipAid Shopify (and possibly others in future) widget. It uses the [Lit](https://lit.dev/) web components library, so it is recommended to become familiar with it before contributing to this repository.
|
|
4
|
+
|
|
5
|
+
Using Lit provides a framework that allows us to build a reactive UI, using JSX-like syntax - no need to use JQuery etc. And it can easily be installed in a page by using the custom web component name:
|
|
6
|
+
```html
|
|
7
|
+
<shipaid-widget>Fallback Content</shipaid-widget>
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
This widget provides an interface where a user can choose to add or remove ShipAid protection - this is actually a product in their store that can be added to cart. When the component is loaded, we immediately run a request to fetch the ShipAid protection product details from our API, as well as the customers current cart from the [Shopify AJAX API](https://shopify.dev/api/ajax/reference/cart).
|
|
13
|
+
Once we have this data, we can check whether the customer currently has the ShipAid product in their cart, and show either the add/remove product buttons based on this.
|
|
14
|
+
|
|
15
|
+
We also emit various [custom events](https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events#adding_custom_data_%E2%80%93_customevent) when we add or remove the ShipAid product from the cart, so other developers can listen to these events, and update AJAX carts.
|
|
16
|
+
|
|
17
|
+
### Events
|
|
18
|
+
|
|
19
|
+
This is a list of the events emitted by the widget:
|
|
20
|
+
|
|
21
|
+
| Event | Description | Payload |
|
|
22
|
+
|-------|-------------|---------|
|
|
23
|
+
| `shipaid-loaded` | Dispatched when the widget has finished fetching data from the API, and has successfully rendered. | Contains the data from the ShipAid API: [`ShipAidStore`](/types/shipaid.ts) |
|
|
24
|
+
| `shipaid-protection-status` | Dispatched a user either adds or removes the protection product from their cart. | `{ protection: boolean, cart: ShopifyCart, lineItem: ShopifyCartItem }` |
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Contributing
|
|
28
|
+
|
|
29
|
+
### Requirements
|
|
30
|
+
|
|
31
|
+
- Node v16+
|
|
32
|
+
- PNPM
|
|
33
|
+
- Development Shopify store (with the ShipAid app installed)
|
|
34
|
+
- ShipAid API development/staging instance
|
|
35
|
+
|
|
36
|
+
### Development
|
|
37
|
+
|
|
38
|
+
Make sure to copy `.env.example` to `.env.local`, and add the ShipAid API endpoint:
|
|
39
|
+
|
|
40
|
+
```env
|
|
41
|
+
# Can be either the URL of a local dev instance, or the Nhost staging URL
|
|
42
|
+
VITE_APP_SHIPAID_API=http://localhost:1337/v1/graphql
|
|
43
|
+
```
|
|
44
|
+
You will need to make sure your development store has the ShipAid app installed, so the store and its protection product is added to the DB.
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
pnpm install
|
|
48
|
+
pnpm run develop
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Once the project is running, add the below to your development Shopify store `theme.liquid`:
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<!-- Dev -->
|
|
55
|
+
<script src="http://localhost:3000/src/shipaid-widget.ts"type="module" ></script>
|
|
56
|
+
<!-- Prod -->
|
|
57
|
+
<script src="https://unpkg.com/ui.shipaid.com?module" type="module"></script>
|
|
58
|
+
```
|
|
59
|
+
And add the widget element in your cart (likely `/sections/main-cart-items.liquid`):
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<shipaid-widget>
|
|
63
|
+
<p>Loading ShipAid Protection</p>
|
|
64
|
+
</shipaid-widget>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Build
|
|
68
|
+
|
|
69
|
+
Create an `.env.production` file, and add the URL to the ShipAid production API.
|
|
70
|
+
|
|
71
|
+
Once the project has been built, you can publish the project to NPM, and users can add the script to their store using a package CDN (I.e. [Unpkg](https://unpkg.com/)).
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
pnpm install
|
|
75
|
+
pnpm run lint
|
|
76
|
+
pnpm run build
|
|
77
|
+
pnpm publish
|
|
78
|
+
```
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
1
|
+
var mt=Object.defineProperty,vt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var $t=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable;var Y=(o,t,e)=>t in o?mt(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,C=(o,t)=>{for(var e in t||(t={}))$t.call(t,e)&&Y(o,e,t[e]);if(K)for(var e of K(t))yt.call(t,e)&&Y(o,e,t[e]);return o},P=(o,t)=>vt(o,_t(t));/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2017 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const
|
|
5
|
+
*/const gt=o=>t=>typeof t=="function"?((e,i)=>(window.customElements.define(e,i),i))(o,t):((e,i)=>{const{kind:s,elements:r}=i;return{kind:s,elements:r,finisher(n){window.customElements.define(e,n)}}})(o,t);/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const
|
|
9
|
+
*/const wt=(o,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?P(C({},t),{finisher(e){e.createProperty(t.key,o)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(e){e.createProperty(t.key,o)}};function At(o){return(t,e)=>e!==void 0?((i,s,r)=>{s.constructor.createProperty(r,i)})(o,t,e):wt(o,t)}/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/function
|
|
13
|
+
*/function $(o){return At(P(C({},o),{state:!0}))}/**
|
|
14
14
|
* @license
|
|
15
15
|
* Copyright 2021 Google LLC
|
|
16
16
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -18,24 +18,24 @@ var vt=Object.defineProperty,mt=Object.defineProperties;var _t=Object.getOwnProp
|
|
|
18
18
|
* @license
|
|
19
19
|
* Copyright 2019 Google LLC
|
|
20
20
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
21
|
-
*/const
|
|
21
|
+
*/const L=window.ShadowRoot&&(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,j=Symbol(),Z=new Map;class G{constructor(t,e){if(this._$cssResult$=!0,e!==j)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=Z.get(this.cssText);return L&&t===void 0&&(Z.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const bt=o=>new G(typeof o=="string"?o:o+"",j),Et=(o,...t)=>{const e=o.length===1?o[0]:t.reduce((i,s,r)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+o[r+1],o[0]);return new G(e,j)},St=(o,t)=>{L?o.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):t.forEach(e=>{const i=document.createElement("style"),s=window.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,o.appendChild(i)})},Q=L?o=>o:o=>o instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return bt(e)})(o):o;/**
|
|
22
22
|
* @license
|
|
23
23
|
* Copyright 2017 Google LLC
|
|
24
24
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
25
|
-
*/var
|
|
25
|
+
*/var B;const X=window.trustedTypes,xt=X?X.emptyScript:"",tt=window.reactiveElementPolyfillSupport,V={toAttribute(o,t){switch(t){case Boolean:o=o?xt:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,t){let e=o;switch(t){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},et=(o,t)=>t!==o&&(t==t||o==o),q={attribute:!0,type:String,converter:V,reflect:!1,hasChanged:et};class w extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;(e=this.l)!==null&&e!==void 0||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach((e,i)=>{const s=this._$Eh(i,e);s!==void 0&&(this._$Eu.set(s,i),t.push(s))}),t}static createProperty(t,e=q){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const r=this[t];this[e]=s,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||q}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const e=this.properties,i=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const s of i)this.createProperty(s,e[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(Q(s))}else t!==void 0&&e.push(Q(t));return e}static _$Eh(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$Em(),this.requestUpdate(),(t=this.constructor.l)===null||t===void 0||t.forEach(e=>e(this))}addController(t){var e,i;((e=this._$Eg)!==null&&e!==void 0?e:this._$Eg=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((i=t.hostConnected)===null||i===void 0||i.call(t))}removeController(t){var e;(e=this._$Eg)===null||e===void 0||e.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.set(e,this[e]),delete this[e])})}createRenderRoot(){var t;const e=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return St(e,this.constructor.elementStyles),e}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$Eg)===null||t===void 0||t.forEach(e=>{var i;return(i=e.hostConnected)===null||i===void 0?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$Eg)===null||t===void 0||t.forEach(e=>{var i;return(i=e.hostDisconnected)===null||i===void 0?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ES(t,e,i=q){var s,r;const n=this.constructor._$Eh(t,i);if(n!==void 0&&i.reflect===!0){const h=((r=(s=i.converter)===null||s===void 0?void 0:s.toAttribute)!==null&&r!==void 0?r:V.toAttribute)(e,i.type);this._$Ei=t,h==null?this.removeAttribute(n):this.setAttribute(n,h),this._$Ei=null}}_$AK(t,e){var i,s,r;const n=this.constructor,h=n._$Eu.get(t);if(h!==void 0&&this._$Ei!==h){const a=n.getPropertyOptions(h),p=a.converter,u=(r=(s=(i=p)===null||i===void 0?void 0:i.fromAttribute)!==null&&s!==void 0?s:typeof p=="function"?p:null)!==null&&r!==void 0?r:V.fromAttribute;this._$Ei=h,this[h]=u(e,a.type),this._$Ei=null}}requestUpdate(t,e,i){let s=!0;t!==void 0&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||et)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Ei!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach((s,r)=>this[r]=s),this._$Et=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),(t=this._$Eg)===null||t===void 0||t.forEach(s=>{var r;return(r=s.hostUpdate)===null||r===void 0?void 0:r.call(s)}),this.update(i)):this._$EU()}catch(s){throw e=!1,this._$EU(),s}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;(e=this._$Eg)===null||e===void 0||e.forEach(i=>{var s;return(s=i.hostUpdated)===null||s===void 0?void 0:s.call(i)}),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._$Ep}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((e,i)=>this._$ES(i,this[i],e)),this._$EC=void 0),this._$EU()}updated(t){}firstUpdated(t){}}w.finalized=!0,w.elementProperties=new Map,w.elementStyles=[],w.shadowRootOptions={mode:"open"},tt==null||tt({ReactiveElement:w}),((B=globalThis.reactiveElementVersions)!==null&&B!==void 0?B:globalThis.reactiveElementVersions=[]).push("1.3.0");/**
|
|
26
26
|
* @license
|
|
27
27
|
* Copyright 2017 Google LLC
|
|
28
28
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
29
|
-
*/var
|
|
29
|
+
*/var F;const A=globalThis.trustedTypes,it=A?A.createPolicy("lit-html",{createHTML:o=>o}):void 0,y=`lit$${(Math.random()+"").slice(9)}$`,ot="?"+y,Ct=`<${ot}>`,b=document,T=(o="")=>b.createComment(o),U=o=>o===null||typeof o!="object"&&typeof o!="function",st=Array.isArray,Pt=o=>{var t;return st(o)||typeof((t=o)===null||t===void 0?void 0:t[Symbol.iterator])=="function"},N=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,rt=/-->/g,nt=/>/g,g=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,at=/'/g,pt=/"/g,ht=/^(?:script|style|textarea|title)$/i,Tt=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),z=Tt(1),E=Symbol.for("lit-noChange"),c=Symbol.for("lit-nothing"),dt=new WeakMap,Ut=(o,t,e)=>{var i,s;const r=(i=e==null?void 0:e.renderBefore)!==null&&i!==void 0?i:t;let n=r._$litPart$;if(n===void 0){const h=(s=e==null?void 0:e.renderBefore)!==null&&s!==void 0?s:null;r._$litPart$=n=new H(t.insertBefore(T(),h),h,void 0,e!=null?e:{})}return n._$AI(o),n},S=b.createTreeWalker(b,129,null,!1),Nt=(o,t)=>{const e=o.length-1,i=[];let s,r=t===2?"<svg>":"",n=N;for(let a=0;a<e;a++){const p=o[a];let u,d,l=-1,m=0;for(;m<p.length&&(n.lastIndex=m,d=n.exec(p),d!==null);)m=n.lastIndex,n===N?d[1]==="!--"?n=rt:d[1]!==void 0?n=nt:d[2]!==void 0?(ht.test(d[2])&&(s=RegExp("</"+d[2],"g")),n=g):d[3]!==void 0&&(n=g):n===g?d[0]===">"?(n=s!=null?s:N,l=-1):d[1]===void 0?l=-2:(l=n.lastIndex-d[2].length,u=d[1],n=d[3]===void 0?g:d[3]==='"'?pt:at):n===pt||n===at?n=g:n===rt||n===nt?n=N:(n=g,s=void 0);const O=n===g&&o[a+1].startsWith("/>")?" ":"";r+=n===N?p+Ct:l>=0?(i.push(u),p.slice(0,l)+"$lit$"+p.slice(l)+y+O):p+y+(l===-2?(i.push(void 0),a):O)}const h=r+(o[e]||"<?>")+(t===2?"</svg>":"");if(!Array.isArray(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return[it!==void 0?it.createHTML(h):h,i]};class I{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,n=0;const h=t.length-1,a=this.parts,[p,u]=Nt(t,e);if(this.el=I.createElement(p,i),S.currentNode=this.el.content,e===2){const d=this.el.content,l=d.firstChild;l.remove(),d.append(...l.childNodes)}for(;(s=S.nextNode())!==null&&a.length<h;){if(s.nodeType===1){if(s.hasAttributes()){const d=[];for(const l of s.getAttributeNames())if(l.endsWith("$lit$")||l.startsWith(y)){const m=u[n++];if(d.push(l),m!==void 0){const O=s.getAttribute(m.toLowerCase()+"$lit$").split(y),M=/([.?@])?(.*)/.exec(m);a.push({type:1,index:r,name:M[2],strings:O,ctor:M[1]==="."?It:M[1]==="?"?Ot:M[1]==="@"?Mt:R})}else a.push({type:6,index:r})}for(const l of d)s.removeAttribute(l)}if(ht.test(s.tagName)){const d=s.textContent.split(y),l=d.length-1;if(l>0){s.textContent=A?A.emptyScript:"";for(let m=0;m<l;m++)s.append(d[m],T()),S.nextNode(),a.push({type:2,index:++r});s.append(d[l],T())}}}else if(s.nodeType===8)if(s.data===ot)a.push({type:2,index:r});else{let d=-1;for(;(d=s.data.indexOf(y,d+1))!==-1;)a.push({type:7,index:r}),d+=y.length-1}r++}}static createElement(t,e){const i=b.createElement("template");return i.innerHTML=t,i}}function x(o,t,e=o,i){var s,r,n,h;if(t===E)return t;let a=i!==void 0?(s=e._$Cl)===null||s===void 0?void 0:s[i]:e._$Cu;const p=U(t)?void 0:t._$litDirective$;return(a==null?void 0:a.constructor)!==p&&((r=a==null?void 0:a._$AO)===null||r===void 0||r.call(a,!1),p===void 0?a=void 0:(a=new p(o),a._$AT(o,e,i)),i!==void 0?((n=(h=e)._$Cl)!==null&&n!==void 0?n:h._$Cl=[])[i]=a:e._$Cu=a),a!==void 0&&(t=x(o,a._$AS(o,t.values),a,i)),t}class kt{constructor(t,e){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var e;const{el:{content:i},parts:s}=this._$AD,r=((e=t==null?void 0:t.creationScope)!==null&&e!==void 0?e:b).importNode(i,!0);S.currentNode=r;let n=S.nextNode(),h=0,a=0,p=s[0];for(;p!==void 0;){if(h===p.index){let u;p.type===2?u=new H(n,n.nextSibling,this,t):p.type===1?u=new p.ctor(n,p.name,p.strings,this,t):p.type===6&&(u=new zt(n,this,t)),this.v.push(u),p=s[++a]}h!==(p==null?void 0:p.index)&&(n=S.nextNode(),h++)}return r}m(t){let e=0;for(const i of this.v)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class H{constructor(t,e,i,s){var r;this.type=2,this._$AH=c,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cg=(r=s==null?void 0:s.isConnected)===null||r===void 0||r}get _$AU(){var t,e;return(e=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&e!==void 0?e:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=x(this,t,e),U(t)?t===c||t==null||t===""?(this._$AH!==c&&this._$AR(),this._$AH=c):t!==this._$AH&&t!==E&&this.$(t):t._$litType$!==void 0?this.T(t):t.nodeType!==void 0?this.k(t):Pt(t)?this.S(t):this.$(t)}A(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==c&&U(this._$AH)?this._$AA.nextSibling.data=t:this.k(b.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:s}=t,r=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=I.createElement(s.h,this.options)),s);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===r)this._$AH.m(i);else{const n=new kt(r,this),h=n.p(this.options);n.m(i),this.k(h),this._$AH=n}}_$AC(t){let e=dt.get(t.strings);return e===void 0&&dt.set(t.strings,e=new I(t)),e}S(t){st(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new H(this.A(T()),this.A(T()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cg=t,(e=this._$AP)===null||e===void 0||e.call(this,t))}}class R{constructor(t,e,i,s,r){this.type=1,this._$AH=c,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=c}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const r=this.strings;let n=!1;if(r===void 0)t=x(this,t,e,0),n=!U(t)||t!==this._$AH&&t!==E,n&&(this._$AH=t);else{const h=t;let a,p;for(t=r[0],a=0;a<r.length-1;a++)p=x(this,h[i+a],e,a),p===E&&(p=this._$AH[a]),n||(n=!U(p)||p!==this._$AH[a]),p===c?t=c:t!==c&&(t+=(p!=null?p:"")+r[a+1]),this._$AH[a]=p}n&&!s&&this.C(t)}C(t){t===c?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t!=null?t:"")}}class It extends R{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===c?void 0:t}}const Ht=A?A.emptyScript:"";class Ot extends R{constructor(){super(...arguments),this.type=4}C(t){t&&t!==c?this.element.setAttribute(this.name,Ht):this.element.removeAttribute(this.name)}}class Mt extends R{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){var i;if((t=(i=x(this,t,e,0))!==null&&i!==void 0?i:c)===E)return;const s=this._$AH,r=t===c&&s!==c||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==c&&(s===c||r);r&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;typeof this._$AH=="function"?this._$AH.call((i=(e=this.options)===null||e===void 0?void 0:e.host)!==null&&i!==void 0?i:this.element,t):this._$AH.handleEvent(t)}}class zt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){x(this,t)}}const lt=window.litHtmlPolyfillSupport;lt==null||lt(I,H),((F=globalThis.litHtmlVersions)!==null&&F!==void 0?F:globalThis.litHtmlVersions=[]).push("2.2.0");/**
|
|
30
30
|
* @license
|
|
31
31
|
* Copyright 2017 Google LLC
|
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
-
*/var W,J;class
|
|
33
|
+
*/var W,J;class k extends w{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return(t=(e=this.renderOptions).renderBefore)!==null&&t!==void 0||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=Ut(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Dt)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Dt)===null||t===void 0||t.setConnected(!1)}render(){return E}}k.finalized=!0,k._$litElement$=!0,(W=globalThis.litElementHydrateSupport)===null||W===void 0||W.call(globalThis,{LitElement:k});const ct=globalThis.litElementPolyfillSupport;ct==null||ct({LitElement:k}),((J=globalThis.litElementVersions)!==null&&J!==void 0?J:globalThis.litElementVersions=[]).push("3.2.0");function Rt(o){if(!o.dispatchEvent||!o.requestUpdate)throw new Error("Element missing required functions (dispatchEvent/requestUpdate)");return o}const v="__registered_effects";function Dt(o){const t=o;if(t[v])return t;const e=Rt(o),i=e.updated;return t[v]={index:0,count:0,effects:[]},e.updated=s=>(t[v].index=0,i(s)),t}function Lt(o,t){const e=Dt(o),{index:i,count:s}=e[v];return i===s?(e[v].index++,e[v].count++,e[v].effects.push(t),t):(e[v].index++,e[v].effects[i])}function ut(o,t,e){const i=Lt(o,{on:t,observe:["__initial__dirty"]});i.observe.some((s,r)=>e[r]!==s)&&i.on(),i.observe=e}const jt=(o,t)=>ut(o,t,[]);/**
|
|
34
34
|
* @license
|
|
35
35
|
* Copyright 2021 Google LLC
|
|
36
36
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
37
|
-
*/function
|
|
38
|
-
|
|
37
|
+
*/function Bt(o,t,e){return o?t():e==null?void 0:e()}var Vt=Et`
|
|
38
|
+
:host {
|
|
39
39
|
--shipaid-primary: #002bd6;
|
|
40
40
|
--shipaid-secondary: #0076ff;
|
|
41
41
|
--shipaid-text: #000000;
|
|
@@ -48,7 +48,122 @@ var vt=Object.defineProperty,mt=Object.defineProperties;var _t=Object.getOwnProp
|
|
|
48
48
|
--shipaid-font-lg: 18px;
|
|
49
49
|
--shipaid-font-regular: 400;
|
|
50
50
|
--shipaid-font-heavy: 700;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
* {
|
|
54
|
+
font-family: var(--shipaid-font);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Popups */
|
|
58
|
+
|
|
59
|
+
.shipaid-popup {
|
|
60
|
+
position: fixed;
|
|
61
|
+
top: 0;
|
|
62
|
+
bottom: 0;
|
|
63
|
+
left: 0;
|
|
64
|
+
right: 0;
|
|
65
|
+
margin: auto;
|
|
66
|
+
max-width: 500px;
|
|
67
|
+
max-height: 100vh;
|
|
68
|
+
height: fit-content;
|
|
69
|
+
border: var(--shipaid-light-grey) 1px solid;
|
|
70
|
+
background-color: #fff;
|
|
71
|
+
z-index: 10000;
|
|
72
|
+
overflow: auto;
|
|
73
|
+
visibility: hidden;
|
|
74
|
+
opacity: 0;
|
|
75
|
+
transition: all 250ms ease-in-out;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.shipaid-popup.active {
|
|
79
|
+
visibility: visible;
|
|
80
|
+
opacity: 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@media (max-width: 600px) {
|
|
84
|
+
.shipaid-popup {
|
|
85
|
+
width: 100vw;
|
|
86
|
+
height: 100vh;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.shipaid-popup .popup {
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
gap: 1rem;
|
|
94
|
+
padding: 5rem;
|
|
95
|
+
height: fit-content;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@media (max-width: 600px) {
|
|
99
|
+
.shipaid-popup .popup {
|
|
100
|
+
padding: 3rem;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.popup .popup-close {
|
|
105
|
+
width: fit-content;
|
|
106
|
+
margin-left: auto;
|
|
107
|
+
background-color: transparent;
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
border: none;
|
|
110
|
+
font-family: var(--shipaid-font);
|
|
111
|
+
font-weight: var(--shipaid-font-heavy);
|
|
112
|
+
text-transform: uppercase;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.popup .popup-title {
|
|
116
|
+
font-size: clamp(1.8rem, 2vw + 1rem, 2.8rem);;
|
|
117
|
+
letter-spacing: 1px;
|
|
118
|
+
}
|
|
51
119
|
|
|
120
|
+
.popup p {
|
|
121
|
+
font-size: clamp(1.125rem, 1vw + 1rem, 1.6rem);
|
|
122
|
+
margin: 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.popup .popup-disclaimer {
|
|
126
|
+
font-size: 10px;
|
|
127
|
+
color: var(--shipaid-text-muted);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.popup .popup-footer {
|
|
131
|
+
display: flex;
|
|
132
|
+
flex-direction: row;
|
|
133
|
+
justify-content: space-between;
|
|
134
|
+
align-items: flex-start;
|
|
135
|
+
margin-top: 2rem;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@media (max-width: 600px) {
|
|
139
|
+
.popup .popup-footer {
|
|
140
|
+
flex-direction: column;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.popup .popup-footer .footer-links {
|
|
145
|
+
display: flex;
|
|
146
|
+
flex-direction: row;
|
|
147
|
+
gap: 2rem;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.popup .popup-footer .footer-links a {
|
|
151
|
+
font-family: var(--shipaid-font);
|
|
152
|
+
font-size: var(--shipaid-font-sm);
|
|
153
|
+
color: var(--shipaid-text-muted);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.popup .popup-footer .footer-date p {
|
|
157
|
+
font-family: var(--shipaid-font);
|
|
158
|
+
font-weight: var(--shipaid-font-heavy);
|
|
159
|
+
font-size: var(--shipaid-font-sm);
|
|
160
|
+
color: var(--shipaid-text);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
/* Widget */
|
|
165
|
+
|
|
166
|
+
.shipaid-prompt {
|
|
52
167
|
width: 400px;
|
|
53
168
|
font-family: var(--shipaid-font);
|
|
54
169
|
font-size: var(--shipaid-font-base);
|
|
@@ -58,6 +173,13 @@ var vt=Object.defineProperty,mt=Object.defineProperties;var _t=Object.getOwnProp
|
|
|
58
173
|
gap: 1rem;
|
|
59
174
|
margin: 2rem 0 2rem auto;
|
|
60
175
|
}
|
|
176
|
+
|
|
177
|
+
@media (max-width: 600px) {
|
|
178
|
+
.shipaid-prompt {
|
|
179
|
+
width: 100%;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
61
183
|
.shipaid-prompt p, .shipaid-prompt a {
|
|
62
184
|
margin: 0;
|
|
63
185
|
line-height: 1;
|
|
@@ -113,6 +235,9 @@ var vt=Object.defineProperty,mt=Object.defineProperties;var _t=Object.getOwnProp
|
|
|
113
235
|
cursor: pointer;
|
|
114
236
|
text-decoration: underline;
|
|
115
237
|
font-size: var(--shipaid-font-sm);
|
|
238
|
+
background-color: transparent;
|
|
239
|
+
cursor: pointer;
|
|
240
|
+
border: none;
|
|
116
241
|
}
|
|
117
242
|
.shipaid-prompt .prompt-footer .prompt-footer-badge {
|
|
118
243
|
background-color: var(--shipaid-light-grey);
|
|
@@ -133,7 +258,27 @@ var vt=Object.defineProperty,mt=Object.defineProperties;var _t=Object.getOwnProp
|
|
|
133
258
|
color: var(--shipaid-text-grey);
|
|
134
259
|
font-weight: var(--shipaid-font-heavy);
|
|
135
260
|
}
|
|
136
|
-
`,qt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor
|
|
261
|
+
`,qt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,_=(o,t,e,i)=>{for(var s=i>1?void 0:i?Ft(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&qt(t,e,s),s},Wt=(o=>(o.LOADED="shipaid-loaded",o.STATUS_UPDATE="shipaid-protection-status",o))(Wt||{});const ft=async(o,t)=>{try{const e=await fetch(o,t);if(!e.ok)throw new Error(await e.text());return await e.json()}catch(e){throw console.error(e),new Error("Failed to complete fetch request.")}};let f=class extends k{constructor(){super(...arguments);var o;this._storeDomain=(o=window.Shopify)==null?void 0:o.shop,this._hasFinishedSetup=!1,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>ft(t),post:(t,e)=>ft(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var e,i;jt(this,async()=>{var a,p;console.log("add fonts to head");const s=document.createElement("link");s.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),s.setAttribute("rel","stylesheet"),document.head.appendChild(s);const[r,n]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=r,this._cart=n;const h=(p=(a=n.items)==null?void 0:a.some(u=>u.variant_id===r.productVariantNumericId))!=null?p:!1;this._hasProtectionInCart=h,this._hasFinishedSetup=!0,this._dispatchEvent("shipaid-loaded",r)}),ut(this,()=>{var n,h,a,p;if(!((n=this._cart)!=null&&n.items))return;const s=(a=(h=this._cart)==null?void 0:h.items)==null?void 0:a.findIndex(u=>{var d;return u.variant_id===((d=this._store)==null?void 0:d.productVariantNumericId)}),r=(p=this._cart)==null?void 0:p.items[s];this._hasProtectionInCart=!!r,r&&(this._protectionProduct=P(C({},r),{index:s,position:s+1}))},[this._store,this._cart]);const o=z`
|
|
262
|
+
<div class=${`shipaid-popup ${this._popup==="learn-more"&&"active"}`}>
|
|
263
|
+
<div class="popup">
|
|
264
|
+
<button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
|
|
265
|
+
<p class="popup-title">Instant Package Protection</p>
|
|
266
|
+
<p>We empower your favorite brands to protect their packages, because every order is precious!</p>
|
|
267
|
+
<p class="popup-title">Shop Care-Free With ShipAid</p>
|
|
268
|
+
<p>Brands and shipment carriers cannot always guarantee your order will arrive at your doorstep safely. Things happen! We allow the brand you are purchasing from to protect your order in the chance of an issue in transit. If you encounter an issue, simply reach out to the brand and they will handle your claim as soon as possible</p>
|
|
269
|
+
<p class="popup-disclaimer">By purchasing this protection, you are agreeing to our Terms Of Service and Privacy Policy. You are not obligated to purchase this protection. This protection is NOT insurance. Purchasing this protection does not guarantee you will be reimbursed for any product or shipping costs. The claim process and decision for compensation is strictly decided by the brand you a purchasing from.</p>
|
|
270
|
+
<div class="popup-footer">
|
|
271
|
+
<div class="footer-links">
|
|
272
|
+
<a>Terms of Service</a>
|
|
273
|
+
<a>Privacy Policy</a>
|
|
274
|
+
</div>
|
|
275
|
+
<div class="footer-date">
|
|
276
|
+
<p>ShipAid © ${new Date().getFullYear()}</p>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
`,t=z`
|
|
137
282
|
<div class="shipaid-prompt">
|
|
138
283
|
<p class="prompt-title">${this._hasProtectionInCart?"Active":"Inactive"}</p>
|
|
139
284
|
<div class="prompt-product">
|
|
@@ -145,14 +290,14 @@ var vt=Object.defineProperty,mt=Object.defineProperties;var _t=Object.getOwnProp
|
|
|
145
290
|
<p class="prompt-product-details-description">Resolve shipping issues care-free</p>
|
|
146
291
|
</div>
|
|
147
292
|
<div class="prompt-product-actions">
|
|
148
|
-
<p class="prompt-product-actions-price">${
|
|
293
|
+
<p class="prompt-product-actions-price">${this._currencyFormat((i=(e=this._store)==null?void 0:e.productPrice)!=null?i:0)}</p>
|
|
149
294
|
<button class="prompt-product-actions-button" @click=${this._updateProtection} ?disabled=${this._state.loading}>
|
|
150
295
|
${this._state.loading?"Loading...":this._hasProtectionInCart?"Remove":"+ Add"}
|
|
151
296
|
</button>
|
|
152
297
|
</div>
|
|
153
298
|
</div>
|
|
154
299
|
<div class="prompt-footer">
|
|
155
|
-
<
|
|
300
|
+
<button class="prompt-footer-about" @click=${()=>{this._popup="learn-more"}}>Learn More</button>
|
|
156
301
|
<a class="prompt-footer-badge" href="/">
|
|
157
302
|
<span>Powered by</span>
|
|
158
303
|
<span class="ship">Ship</span>
|
|
@@ -160,14 +305,17 @@ var vt=Object.defineProperty,mt=Object.defineProperties;var _t=Object.getOwnProp
|
|
|
160
305
|
</a>
|
|
161
306
|
</div>
|
|
162
307
|
</div>
|
|
163
|
-
`;return
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
308
|
+
`;return z`
|
|
309
|
+
<div class="shipaid">
|
|
310
|
+
${Bt(this._hasFinishedSetup&&this._store,()=>[o,t],()=>z`<p>Loading...</p>`)}
|
|
311
|
+
</div>
|
|
312
|
+
`}_currencyFormat(o){var t,e,i,s,r;return new Intl.NumberFormat((e=(t=window.Shopify)==null?void 0:t.locale)!=null?e:void 0,{currency:((i=this._store)==null?void 0:i.currency)||((r=(s=window.Shopify)==null?void 0:s.currency)==null?void 0:r.active)||"USD",style:"currency"}).format(o)}_dispatchEvent(o,t={}){this.dispatchEvent(new CustomEvent(o,{bubbles:!0,composed:!0,detail:t}))}_setState(o,t){this._state={loading:o==="loading",success:o==="success",error:o==="error"?t||!0:!1}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{const o=this._storeDomain||window.location.hostname;if(!o)throw new Error("Missing store domain - cannot continue.");const t={domain:o},e=`query StoreByDomain($domain: String!) {
|
|
313
|
+
store: store_properties(args: { store: $domain }) {
|
|
314
|
+
currency
|
|
168
315
|
productId
|
|
316
|
+
productPrice
|
|
169
317
|
productVariantId
|
|
170
318
|
productVariantNumericId
|
|
171
|
-
|
|
319
|
+
store
|
|
172
320
|
}
|
|
173
|
-
}`,{data:
|
|
321
|
+
}`,{data:i}=await this._fetch.post("http://localhost:1337/v1/graphql",{query:e,variables:t});if(!i.store)throw new Error(`Could not find a store for ${o}`);if(!i.store.productVariantNumericId)throw new Error("Missing variant ID for ShipAid product.");return i.store}catch(o){throw console.error(o),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(o){throw console.error(o),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async addProtection(){var o,t;try{if(!((o=this._store)!=null&&o.productVariantNumericId))throw new Error("Store has not been loaded.");if(!((t=this._cart)!=null&&t.items))throw new Error("Cart has not been loaded.");this._setState("loading");const e={id:this._store.productVariantNumericId,quantity:1},i=await this._fetch.post("/cart/add.js",e),s=P(C({},this._cart),{items:[i,...this._cart.items]});this._cart=s,this._setState("success"),this._dispatchEvent("shipaid-protection-status",{protection:!0,cart:s,lineItem:i})}catch(e){console.error(e),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){var o;try{if(!((o=this._store)!=null&&o.productVariantNumericId))throw new Error("Store has not been loaded.");if(!this._protectionProduct)throw new Error("Protection product not found.");this._setState("loading");const t={id:this._protectionProduct.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);this._dispatchEvent("shipaid-protection-status",{protection:!1,cart:e,lineItem:this._protectionProduct}),this._cart=e,this._setState("success")}catch(t){console.error(t),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}};f.styles=Vt,_([$()],f.prototype,"_storeDomain",2),_([$()],f.prototype,"_store",2),_([$()],f.prototype,"_cart",2),_([$()],f.prototype,"_hasFinishedSetup",2),_([$()],f.prototype,"_hasProtectionInCart",2),_([$()],f.prototype,"_protectionProduct",2),_([$()],f.prototype,"_state",2),_([$()],f.prototype,"_popup",2),f=_([gt("shipaid-widget")],f);export{f as ShipAidWidget};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
1
|
+
var jt=Object.defineProperty,Bt=Object.defineProperties,Vt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,vt=(t,e,i)=>e in t?jt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,H=(t,e)=>{for(var i in e||(e={}))qt.call(e,i)&&vt(t,i,e[i]);if(mt)for(var i of mt(e))Ft.call(e,i)&&vt(t,i,e[i]);return t},M=(t,e)=>Bt(t,Vt(e)),ShipAidWidget=function(t){"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/const e=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?M(
|
|
6
|
+
*/const e=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?M(H({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
@@ -14,36 +14,36 @@ var Vt=Object.defineProperty,Bt=Object.defineProperties,qt=Object.getOwnProperty
|
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
function i(t){return function(t){return(i,
|
|
17
|
+
function i(t){return function(t){return(i,o)=>{return void 0!==o?(r=t,s=o,void i.constructor.createProperty(s,r)):e(t,i);var r,s}}(M(H({},t),{state:!0}))}
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2021 Google LLC
|
|
21
21
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
-
*/var
|
|
22
|
+
*/var o;null===(o=window.HTMLSlotElement)||void 0===o||o.prototype.assignedElements;
|
|
23
23
|
/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2019 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
27
|
*/
|
|
28
|
-
const r=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,
|
|
28
|
+
const r=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),n=new Map;class a{constructor(t,e){if(this._$cssResult$=!0,e!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=n.get(this.cssText);return r&&void 0===t&&(n.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const p=r?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",s))(e)})(t):t
|
|
29
29
|
/**
|
|
30
30
|
* @license
|
|
31
31
|
* Copyright 2017 Google LLC
|
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
-
*/;var
|
|
33
|
+
*/;var l;const d=window.trustedTypes,h=d?d.emptyScript:"",c=window.reactiveElementPolyfillSupport,u={toAttribute(t,e){switch(e){case Boolean:t=t?h:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){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{i=null}}return i}},f=(t,e)=>e!==t&&(e==e||t==t),v={attribute:!0,type:String,converter:u,reflect:!1,hasChanged:f};class m extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;null!==(e=this.l)&&void 0!==e||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const o=this._$Eh(i,e);void 0!==o&&(this._$Eu.set(o,i),t.push(o))})),t}static createProperty(t,e=v){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,i,e);void 0!==o&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(o){const r=this[t];this[e]=o,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||v}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(p(t))}else void 0!==t&&e.push(p(t));return e}static _$Eh(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$Eg)&&void 0!==e?e:this._$Eg=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$Eg)||void 0===e||e.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{r?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),o=window.litNonce;void 0!==o&&i.setAttribute("nonce",o),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ES(t,e,i=v){var o,r;const s=this.constructor._$Eh(t,i);if(void 0!==s&&!0===i.reflect){const n=(null!==(r=null===(o=i.converter)||void 0===o?void 0:o.toAttribute)&&void 0!==r?r:u.toAttribute)(e,i.type);this._$Ei=t,null==n?this.removeAttribute(s):this.setAttribute(s,n),this._$Ei=null}}_$AK(t,e){var i,o,r;const s=this.constructor,n=s._$Eu.get(t);if(void 0!==n&&this._$Ei!==n){const t=s.getPropertyOptions(n),a=t.converter,p=null!==(r=null!==(o=null===(i=a)||void 0===i?void 0:i.fromAttribute)&&void 0!==o?o:"function"==typeof a?a:null)&&void 0!==r?r:u.fromAttribute;this._$Ei=n,this[n]=p(e,t.type),this._$Ei=null}}requestUpdate(t,e,i){let o=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||f)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Ei!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):o=!1),!this.isUpdatePending&&o&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,e)=>this[e]=t)),this._$Et=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$EU()}catch(o){throw e=!1,this._$EU(),o}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$Eg)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),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._$Ep}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$ES(e,this[e],t))),this._$EC=void 0),this._$EU()}updated(t){}firstUpdated(t){}}
|
|
34
34
|
/**
|
|
35
35
|
* @license
|
|
36
36
|
* Copyright 2017 Google LLC
|
|
37
37
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
38
|
*/
|
|
39
|
-
var _;m.finalized=!0,m.elementProperties=new Map,m.elementStyles=[],m.shadowRootOptions={mode:"open"},null==
|
|
39
|
+
var _;m.finalized=!0,m.elementProperties=new Map,m.elementStyles=[],m.shadowRootOptions={mode:"open"},null==c||c({ReactiveElement:m}),(null!==(l=globalThis.reactiveElementVersions)&&void 0!==l?l:globalThis.reactiveElementVersions=[]).push("1.3.0");const g=globalThis.trustedTypes,y=g?g.createPolicy("lit-html",{createHTML:t=>t}):void 0,$=`lit$${(Math.random()+"").slice(9)}$`,A="?"+$,w=`<${A}>`,b=document,S=(t="")=>b.createComment(t),E=t=>null===t||"object"!=typeof t&&"function"!=typeof t,x=Array.isArray,P=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,C=/-->/g,T=/>/g,U=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,O=/'/g,k=/"/g,N=/^(?:script|style|textarea|title)$/i,I=(L=1,(t,...e)=>({_$litType$:L,strings:t,values:e})),z=Symbol.for("lit-noChange"),R=Symbol.for("lit-nothing"),j=new WeakMap,D=b.createTreeWalker(b,129,null,!1);var L;class W{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[p,l]=((t,e)=>{const i=t.length-1,o=[];let r,s=2===e?"<svg>":"",n=P;for(let p=0;p<i;p++){const e=t[p];let i,a,l=-1,d=0;for(;d<e.length&&(n.lastIndex=d,a=n.exec(e),null!==a);)d=n.lastIndex,n===P?"!--"===a[1]?n=C:void 0!==a[1]?n=T:void 0!==a[2]?(N.test(a[2])&&(r=RegExp("</"+a[2],"g")),n=U):void 0!==a[3]&&(n=U):n===U?">"===a[0]?(n=null!=r?r:P,l=-1):void 0===a[1]?l=-2:(l=n.lastIndex-a[2].length,i=a[1],n=void 0===a[3]?U:'"'===a[3]?k:O):n===k||n===O?n=U:n===C||n===T?n=P:(n=U,r=void 0);const h=n===U&&t[p+1].startsWith("/>")?" ":"";s+=n===P?e+w:l>=0?(o.push(i),e.slice(0,l)+"$lit$"+e.slice(l)+$+h):e+$+(-2===l?(o.push(void 0),p):h)}const a=s+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==y?y.createHTML(a):a,o]})(t,e);if(this.el=W.createElement(p,i),D.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=D.nextNode())&&a.length<n;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith($)){const i=l[s++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+"$lit$").split($),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?J:"?"===e[1]?Y:"@"===e[1]?Z:F})}else a.push({type:6,index:r})}for(const e of t)o.removeAttribute(e)}if(N.test(o.tagName)){const t=o.textContent.split($),e=t.length-1;if(e>0){o.textContent=g?g.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],S()),D.nextNode(),a.push({type:2,index:++r});o.append(t[e],S())}}}else if(8===o.nodeType)if(o.data===A)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf($,t+1));)a.push({type:7,index:r}),t+=$.length-1}r++}}static createElement(t,e){const i=b.createElement("template");return i.innerHTML=t,i}}function B(t,e,i=t,o){var r,s,n,a;if(e===z)return e;let p=void 0!==o?null===(r=i._$Cl)||void 0===r?void 0:r[o]:i._$Cu;const l=E(e)?void 0:e._$litDirective$;return(null==p?void 0:p.constructor)!==l&&(null===(s=null==p?void 0:p._$AO)||void 0===s||s.call(p,!1),void 0===l?p=void 0:(p=new l(t),p._$AT(t,i,o)),void 0!==o?(null!==(n=(a=i)._$Cl)&&void 0!==n?n:a._$Cl=[])[o]=p:i._$Cu=p),void 0!==p&&(e=B(t,p._$AS(t,e.values),p,o)),e}class V{constructor(t,e){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var e;const{el:{content:i},parts:o}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:b).importNode(i,!0);D.currentNode=r;let s=D.nextNode(),n=0,a=0,p=o[0];for(;void 0!==p;){if(n===p.index){let e;2===p.type?e=new q(s,s.nextSibling,this,t):1===p.type?e=new p.ctor(s,p.name,p.strings,this,t):6===p.type&&(e=new G(s,this,t)),this.v.push(e),p=o[++a]}n!==(null==p?void 0:p.index)&&(s=D.nextNode(),n++)}return r}m(t){let e=0;for(const i of this.v)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class q{constructor(t,e,i,o){var r;this.type=2,this._$AH=R,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cg=null===(r=null==o?void 0:o.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=B(this,t,e),E(t)?t===R||null==t||""===t?(this._$AH!==R&&this._$AR(),this._$AH=R):t!==this._$AH&&t!==z&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.k(t):(t=>{var e;return x(t)||"function"==typeof(null===(e=t)||void 0===e?void 0:e[Symbol.iterator])})(t)?this.S(t):this.$(t)}A(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==R&&E(this._$AH)?this._$AA.nextSibling.data=t:this.k(b.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:o}=t,r="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=W.createElement(o.h,this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.m(i);else{const t=new V(r,this),e=t.p(this.options);t.m(i),this.k(e),this._$AH=t}}_$AC(t){let e=j.get(t.strings);return void 0===e&&j.set(t.strings,e=new W(t)),e}S(t){x(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const r of t)o===e.length?e.push(i=new q(this.A(S()),this.A(S()),this,this.options)):i=e[o],i._$AI(r),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cg=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class F{constructor(t,e,i,o,r){this.type=1,this._$AH=R,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=R}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const r=this.strings;let s=!1;if(void 0===r)t=B(this,t,e,0),s=!E(t)||t!==this._$AH&&t!==z,s&&(this._$AH=t);else{const o=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=B(this,o[i+n],e,n),a===z&&(a=this._$AH[n]),s||(s=!E(a)||a!==this._$AH[n]),a===R?t=R:t!==R&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}s&&!o&&this.C(t)}C(t){t===R?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class J extends F{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===R?void 0:t}}const K=g?g.emptyScript:"";class Y extends F{constructor(){super(...arguments),this.type=4}C(t){t&&t!==R?this.element.setAttribute(this.name,K):this.element.removeAttribute(this.name)}}class Z extends F{constructor(t,e,i,o,r){super(t,e,i,o,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=B(this,t,e,0))&&void 0!==i?i:R)===z)return;const o=this._$AH,r=t===R&&o!==R||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,s=t!==R&&(o===R||r);r&&this.element.removeEventListener(this.name,this,o),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class G{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){B(this,t)}}const Q=window.litHtmlPolyfillSupport;
|
|
40
40
|
/**
|
|
41
41
|
* @license
|
|
42
42
|
* Copyright 2017 Google LLC
|
|
43
43
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
44
|
*/
|
|
45
|
-
var
|
|
46
|
-
|
|
45
|
+
var X,tt;null==Q||Q(W,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:globalThis.litHtmlVersions=[]).push("2.2.0");class et extends m{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=((t,e,i)=>{var o,r;const s=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let n=s._$litPart$;if(void 0===n){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=n=new q(e.insertBefore(S(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return z}}et.finalized=!0,et._$litElement$=!0,null===(X=globalThis.litElementHydrateSupport)||void 0===X||X.call(globalThis,{LitElement:et});const it=globalThis.litElementPolyfillSupport;null==it||it({LitElement:et}),(null!==(tt=globalThis.litElementVersions)&&void 0!==tt?tt:globalThis.litElementVersions=[]).push("3.2.0");const ot="__registered_effects";function rt(t){const e=t;if(e[ot])return e;const i=function(t){if(!t.dispatchEvent||!t.requestUpdate)throw new Error("Element missing required functions (dispatchEvent/requestUpdate)");return t}(t),o=i.updated;return e[ot]={index:0,count:0,effects:[]},i.updated=t=>(e[ot].index=0,o(t)),e}function st(t,e,i){const o=function(t,e){const i=rt(t),{index:o,count:r}=i[ot];return o===r?(i[ot].index++,i[ot].count++,i[ot].effects.push(e),e):(i[ot].index++,i[ot].effects[o])}(t,{on:e,observe:["__initial__dirty"]});o.observe.some(((t,e)=>i[e]!==t))&&o.on(),o.observe=i}var nt=((t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,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.")})(i)+t[o+1]),t[0]);return new a(i,s)})`
|
|
46
|
+
:host {
|
|
47
47
|
--shipaid-primary: #002bd6;
|
|
48
48
|
--shipaid-secondary: #0076ff;
|
|
49
49
|
--shipaid-text: #000000;
|
|
@@ -56,7 +56,122 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
56
56
|
--shipaid-font-lg: 18px;
|
|
57
57
|
--shipaid-font-regular: 400;
|
|
58
58
|
--shipaid-font-heavy: 700;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
* {
|
|
62
|
+
font-family: var(--shipaid-font);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Popups */
|
|
66
|
+
|
|
67
|
+
.shipaid-popup {
|
|
68
|
+
position: fixed;
|
|
69
|
+
top: 0;
|
|
70
|
+
bottom: 0;
|
|
71
|
+
left: 0;
|
|
72
|
+
right: 0;
|
|
73
|
+
margin: auto;
|
|
74
|
+
max-width: 500px;
|
|
75
|
+
max-height: 100vh;
|
|
76
|
+
height: fit-content;
|
|
77
|
+
border: var(--shipaid-light-grey) 1px solid;
|
|
78
|
+
background-color: #fff;
|
|
79
|
+
z-index: 10000;
|
|
80
|
+
overflow: auto;
|
|
81
|
+
visibility: hidden;
|
|
82
|
+
opacity: 0;
|
|
83
|
+
transition: all 250ms ease-in-out;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.shipaid-popup.active {
|
|
87
|
+
visibility: visible;
|
|
88
|
+
opacity: 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@media (max-width: 600px) {
|
|
92
|
+
.shipaid-popup {
|
|
93
|
+
width: 100vw;
|
|
94
|
+
height: 100vh;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.shipaid-popup .popup {
|
|
99
|
+
display: inline-flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
gap: 1rem;
|
|
102
|
+
padding: 5rem;
|
|
103
|
+
height: fit-content;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@media (max-width: 600px) {
|
|
107
|
+
.shipaid-popup .popup {
|
|
108
|
+
padding: 3rem;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
59
111
|
|
|
112
|
+
.popup .popup-close {
|
|
113
|
+
width: fit-content;
|
|
114
|
+
margin-left: auto;
|
|
115
|
+
background-color: transparent;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
border: none;
|
|
118
|
+
font-family: var(--shipaid-font);
|
|
119
|
+
font-weight: var(--shipaid-font-heavy);
|
|
120
|
+
text-transform: uppercase;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.popup .popup-title {
|
|
124
|
+
font-size: clamp(1.8rem, 2vw + 1rem, 2.8rem);;
|
|
125
|
+
letter-spacing: 1px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.popup p {
|
|
129
|
+
font-size: clamp(1.125rem, 1vw + 1rem, 1.6rem);
|
|
130
|
+
margin: 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.popup .popup-disclaimer {
|
|
134
|
+
font-size: 10px;
|
|
135
|
+
color: var(--shipaid-text-muted);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.popup .popup-footer {
|
|
139
|
+
display: flex;
|
|
140
|
+
flex-direction: row;
|
|
141
|
+
justify-content: space-between;
|
|
142
|
+
align-items: flex-start;
|
|
143
|
+
margin-top: 2rem;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@media (max-width: 600px) {
|
|
147
|
+
.popup .popup-footer {
|
|
148
|
+
flex-direction: column;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.popup .popup-footer .footer-links {
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-direction: row;
|
|
155
|
+
gap: 2rem;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.popup .popup-footer .footer-links a {
|
|
159
|
+
font-family: var(--shipaid-font);
|
|
160
|
+
font-size: var(--shipaid-font-sm);
|
|
161
|
+
color: var(--shipaid-text-muted);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.popup .popup-footer .footer-date p {
|
|
165
|
+
font-family: var(--shipaid-font);
|
|
166
|
+
font-weight: var(--shipaid-font-heavy);
|
|
167
|
+
font-size: var(--shipaid-font-sm);
|
|
168
|
+
color: var(--shipaid-text);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
/* Widget */
|
|
173
|
+
|
|
174
|
+
.shipaid-prompt {
|
|
60
175
|
width: 400px;
|
|
61
176
|
font-family: var(--shipaid-font);
|
|
62
177
|
font-size: var(--shipaid-font-base);
|
|
@@ -66,6 +181,13 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
66
181
|
gap: 1rem;
|
|
67
182
|
margin: 2rem 0 2rem auto;
|
|
68
183
|
}
|
|
184
|
+
|
|
185
|
+
@media (max-width: 600px) {
|
|
186
|
+
.shipaid-prompt {
|
|
187
|
+
width: 100%;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
69
191
|
.shipaid-prompt p, .shipaid-prompt a {
|
|
70
192
|
margin: 0;
|
|
71
193
|
line-height: 1;
|
|
@@ -121,6 +243,9 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
121
243
|
cursor: pointer;
|
|
122
244
|
text-decoration: underline;
|
|
123
245
|
font-size: var(--shipaid-font-sm);
|
|
246
|
+
background-color: transparent;
|
|
247
|
+
cursor: pointer;
|
|
248
|
+
border: none;
|
|
124
249
|
}
|
|
125
250
|
.shipaid-prompt .prompt-footer .prompt-footer-badge {
|
|
126
251
|
background-color: var(--shipaid-light-grey);
|
|
@@ -141,12 +266,32 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
141
266
|
color: var(--shipaid-text-grey);
|
|
142
267
|
font-weight: var(--shipaid-font-heavy);
|
|
143
268
|
}
|
|
144
|
-
`,at=Object.defineProperty,
|
|
269
|
+
`,at=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,lt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?pt(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&at(e,i,s),s},dt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(dt||{});const ht=async(t,e)=>{try{const i=await fetch(t,e);if(!i.ok)throw new Error(await i.text());return await i.json()}catch(i){throw console.error(i),new Error("Failed to complete fetch request.")}};return t.ShipAidWidget=class extends et{constructor(){var t;super(...arguments),this._storeDomain=null==(t=window.Shopify)?void 0:t.shop,this._hasFinishedSetup=!1,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>ht(t),post:(t,e)=>ht(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t,e;((t,e)=>{st(t,e,[]);
|
|
145
270
|
/**
|
|
146
271
|
* @license
|
|
147
272
|
* Copyright 2021 Google LLC
|
|
148
273
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
149
|
-
*/})(this,(async()=>{var t,e;const
|
|
274
|
+
*/})(this,(async()=>{var t,e;console.log("add fonts to head");const i=document.createElement("link");i.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),i.setAttribute("rel","stylesheet"),document.head.appendChild(i);const[o,r]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=o,this._cart=r;const s=null!=(e=null==(t=r.items)?void 0:t.some((t=>t.variant_id===o.productVariantNumericId)))&&e;this._hasProtectionInCart=s,this._hasFinishedSetup=!0,this._dispatchEvent("shipaid-loaded",o)})),st(this,(()=>{var t,e,i,o;if(null==(t=this._cart)||!t.items)return;const r=null==(i=null==(e=this._cart)?void 0:e.items)?void 0:i.findIndex((t=>{var e;return t.variant_id===(null==(e=this._store)?void 0:e.productVariantNumericId)})),s=null==(o=this._cart)?void 0:o.items[r];this._hasProtectionInCart=!!s,s&&(this._protectionProduct=M(H({},s),{index:r,position:r+1}))}),[this._store,this._cart]);const i=I`
|
|
275
|
+
<div class=${`shipaid-popup ${"learn-more"===this._popup&&"active"}`}>
|
|
276
|
+
<div class="popup">
|
|
277
|
+
<button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
|
|
278
|
+
<p class="popup-title">Instant Package Protection</p>
|
|
279
|
+
<p>We empower your favorite brands to protect their packages, because every order is precious!</p>
|
|
280
|
+
<p class="popup-title">Shop Care-Free With ShipAid</p>
|
|
281
|
+
<p>Brands and shipment carriers cannot always guarantee your order will arrive at your doorstep safely. Things happen! We allow the brand you are purchasing from to protect your order in the chance of an issue in transit. If you encounter an issue, simply reach out to the brand and they will handle your claim as soon as possible</p>
|
|
282
|
+
<p class="popup-disclaimer">By purchasing this protection, you are agreeing to our Terms Of Service and Privacy Policy. You are not obligated to purchase this protection. This protection is NOT insurance. Purchasing this protection does not guarantee you will be reimbursed for any product or shipping costs. The claim process and decision for compensation is strictly decided by the brand you a purchasing from.</p>
|
|
283
|
+
<div class="popup-footer">
|
|
284
|
+
<div class="footer-links">
|
|
285
|
+
<a>Terms of Service</a>
|
|
286
|
+
<a>Privacy Policy</a>
|
|
287
|
+
</div>
|
|
288
|
+
<div class="footer-date">
|
|
289
|
+
<p>ShipAid © ${(new Date).getFullYear()}</p>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
`,o=I`
|
|
150
295
|
<div class="shipaid-prompt">
|
|
151
296
|
<p class="prompt-title">${this._hasProtectionInCart?"Active":"Inactive"}</p>
|
|
152
297
|
<div class="prompt-product">
|
|
@@ -158,14 +303,14 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
158
303
|
<p class="prompt-product-details-description">Resolve shipping issues care-free</p>
|
|
159
304
|
</div>
|
|
160
305
|
<div class="prompt-product-actions">
|
|
161
|
-
<p class="prompt-product-actions-price">${
|
|
306
|
+
<p class="prompt-product-actions-price">${this._currencyFormat(null!=(e=null==(t=this._store)?void 0:t.productPrice)?e:0)}</p>
|
|
162
307
|
<button class="prompt-product-actions-button" @click=${this._updateProtection} ?disabled=${this._state.loading}>
|
|
163
308
|
${this._state.loading?"Loading...":this._hasProtectionInCart?"Remove":"+ Add"}
|
|
164
309
|
</button>
|
|
165
310
|
</div>
|
|
166
311
|
</div>
|
|
167
312
|
<div class="prompt-footer">
|
|
168
|
-
<
|
|
313
|
+
<button class="prompt-footer-about" @click=${()=>{this._popup="learn-more"}}>Learn More</button>
|
|
169
314
|
<a class="prompt-footer-badge" href="/">
|
|
170
315
|
<span>Powered by</span>
|
|
171
316
|
<span class="ship">Ship</span>
|
|
@@ -174,5 +319,7 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
174
319
|
</div>
|
|
175
320
|
</div>
|
|
176
321
|
`;return I`
|
|
177
|
-
|
|
178
|
-
|
|
322
|
+
<div class="shipaid">
|
|
323
|
+
${function(t,e,i){return t?e():null==i?void 0:i()}(this._hasFinishedSetup&&this._store,(()=>[i,o]),(()=>I`<p>Loading...</p>`))}
|
|
324
|
+
</div>
|
|
325
|
+
`}_currencyFormat(t){var e,i,o,r,s;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:(null==(o=this._store)?void 0:o.currency)||(null==(s=null==(r=window.Shopify)?void 0:r.currency)?void 0:s.active)||"USD",style:"currency"}).format(t)}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}_setState(t,e){this._state={loading:"loading"===t,success:"success"===t,error:"error"===t&&(e||!0)}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{const t=this._storeDomain||window.location.hostname;if(!t)throw new Error("Missing store domain - cannot continue.");const e={domain:t},i="query StoreByDomain($domain: String!) {\n store: store_properties(args: { store: $domain }) {\n currency\n productId\n productPrice\n productVariantId\n productVariantNumericId\n store\n }\n }",{data:o}=await this._fetch.post("http://localhost:1337/v1/graphql",{query:i,variables:e});if(!o.store)throw new Error(`Could not find a store for ${t}`);if(!o.store.productVariantNumericId)throw new Error("Missing variant ID for ShipAid product.");return o.store}catch(L){throw console.error(L),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(L){throw console.error(L),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async addProtection(){var t,e;try{if(null==(t=this._store)||!t.productVariantNumericId)throw new Error("Store has not been loaded.");if(null==(e=this._cart)||!e.items)throw new Error("Cart has not been loaded.");this._setState("loading");const i={id:this._store.productVariantNumericId,quantity:1},o=await this._fetch.post("/cart/add.js",i),r=M(H({},this._cart),{items:[o,...this._cart.items]});this._cart=r,this._setState("success"),this._dispatchEvent("shipaid-protection-status",{protection:!0,cart:r,lineItem:o})}catch(i){console.error(i),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){var t;try{if(null==(t=this._store)||!t.productVariantNumericId)throw new Error("Store has not been loaded.");if(!this._protectionProduct)throw new Error("Protection product not found.");this._setState("loading");const e={id:this._protectionProduct.key,quantity:0},i=await this._fetch.post("/cart/change.js",e);this._dispatchEvent("shipaid-protection-status",{protection:!1,cart:i,lineItem:this._protectionProduct}),this._cart=i,this._setState("success")}catch(e){console.error(e),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}},t.ShipAidWidget.styles=nt,lt([i()],t.ShipAidWidget.prototype,"_storeDomain",2),lt([i()],t.ShipAidWidget.prototype,"_store",2),lt([i()],t.ShipAidWidget.prototype,"_cart",2),lt([i()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),lt([i()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),lt([i()],t.ShipAidWidget.prototype,"_protectionProduct",2),lt([i()],t.ShipAidWidget.prototype,"_state",2),lt([i()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=lt([(t=>e=>{return"function"==typeof e?(i=t,o=e,window.customElements.define(i,o),o):((t,e)=>{const{kind:i,elements:o}=e;return{kind:i,elements:o,finisher(e){window.customElements.define(t,e)}}})(t,e);var i,o})("shipaid-widget")],t.ShipAidWidget),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),t}({});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
1
|
+
var jt=Object.defineProperty,Bt=Object.defineProperties,Vt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,vt=(t,e,i)=>e in t?jt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,H=(t,e)=>{for(var i in e||(e={}))qt.call(e,i)&&vt(t,i,e[i]);if(mt)for(var i of mt(e))Ft.call(e,i)&&vt(t,i,e[i]);return t},M=(t,e)=>Bt(t,Vt(e));!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShipAidWidget={})}(this,(function(t){"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
5
5
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/const e=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?M(
|
|
6
|
+
*/const e=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?M(H({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2017 Google LLC
|
|
@@ -14,36 +14,36 @@ var Vt=Object.defineProperty,Bt=Object.defineProperties,qt=Object.getOwnProperty
|
|
|
14
14
|
* Copyright 2017 Google LLC
|
|
15
15
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
16
|
*/
|
|
17
|
-
function i(t){return function(t){return(i,
|
|
17
|
+
function i(t){return function(t){return(i,o)=>{return void 0!==o?(r=t,s=o,void i.constructor.createProperty(s,r)):e(t,i);var r,s}}(M(H({},t),{state:!0}))}
|
|
18
18
|
/**
|
|
19
19
|
* @license
|
|
20
20
|
* Copyright 2021 Google LLC
|
|
21
21
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
|
-
*/var
|
|
22
|
+
*/var o;null===(o=window.HTMLSlotElement)||void 0===o||o.prototype.assignedElements;
|
|
23
23
|
/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2019 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
27
|
*/
|
|
28
|
-
const r=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,
|
|
28
|
+
const r=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),n=new Map;class a{constructor(t,e){if(this._$cssResult$=!0,e!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=n.get(this.cssText);return r&&void 0===t&&(n.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const p=r?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new a("string"==typeof t?t:t+"",s))(e)})(t):t
|
|
29
29
|
/**
|
|
30
30
|
* @license
|
|
31
31
|
* Copyright 2017 Google LLC
|
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
-
*/;var
|
|
33
|
+
*/;var d;const l=window.trustedTypes,h=l?l.emptyScript:"",c=window.reactiveElementPolyfillSupport,u={toAttribute(t,e){switch(e){case Boolean:t=t?h:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){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{i=null}}return i}},f=(t,e)=>e!==t&&(e==e||t==t),v={attribute:!0,type:String,converter:u,reflect:!1,hasChanged:f};class m extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;null!==(e=this.l)&&void 0!==e||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const o=this._$Eh(i,e);void 0!==o&&(this._$Eu.set(o,i),t.push(o))})),t}static createProperty(t,e=v){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,i,e);void 0!==o&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(o){const r=this[t];this[e]=o,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||v}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(p(t))}else void 0!==t&&e.push(p(t));return e}static _$Eh(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$Eg)&&void 0!==e?e:this._$Eg=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$Eg)||void 0===e||e.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{r?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),o=window.litNonce;void 0!==o&&i.setAttribute("nonce",o),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ES(t,e,i=v){var o,r;const s=this.constructor._$Eh(t,i);if(void 0!==s&&!0===i.reflect){const n=(null!==(r=null===(o=i.converter)||void 0===o?void 0:o.toAttribute)&&void 0!==r?r:u.toAttribute)(e,i.type);this._$Ei=t,null==n?this.removeAttribute(s):this.setAttribute(s,n),this._$Ei=null}}_$AK(t,e){var i,o,r;const s=this.constructor,n=s._$Eu.get(t);if(void 0!==n&&this._$Ei!==n){const t=s.getPropertyOptions(n),a=t.converter,p=null!==(r=null!==(o=null===(i=a)||void 0===i?void 0:i.fromAttribute)&&void 0!==o?o:"function"==typeof a?a:null)&&void 0!==r?r:u.fromAttribute;this._$Ei=n,this[n]=p(e,t.type),this._$Ei=null}}requestUpdate(t,e,i){let o=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||f)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Ei!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):o=!1),!this.isUpdatePending&&o&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,e)=>this[e]=t)),this._$Et=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$EU()}catch(o){throw e=!1,this._$EU(),o}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$Eg)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),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._$Ep}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$ES(e,this[e],t))),this._$EC=void 0),this._$EU()}updated(t){}firstUpdated(t){}}
|
|
34
34
|
/**
|
|
35
35
|
* @license
|
|
36
36
|
* Copyright 2017 Google LLC
|
|
37
37
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
38
38
|
*/
|
|
39
|
-
var _;m.finalized=!0,m.elementProperties=new Map,m.elementStyles=[],m.shadowRootOptions={mode:"open"},null==c||c({ReactiveElement:m}),(null!==(
|
|
39
|
+
var _;m.finalized=!0,m.elementProperties=new Map,m.elementStyles=[],m.shadowRootOptions={mode:"open"},null==c||c({ReactiveElement:m}),(null!==(d=globalThis.reactiveElementVersions)&&void 0!==d?d:globalThis.reactiveElementVersions=[]).push("1.3.0");const g=globalThis.trustedTypes,y=g?g.createPolicy("lit-html",{createHTML:t=>t}):void 0,$=`lit$${(Math.random()+"").slice(9)}$`,A="?"+$,b=`<${A}>`,w=document,S=(t="")=>w.createComment(t),E=t=>null===t||"object"!=typeof t&&"function"!=typeof t,x=Array.isArray,P=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,C=/-->/g,T=/>/g,U=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,O=/'/g,k=/"/g,N=/^(?:script|style|textarea|title)$/i,I=(L=1,(t,...e)=>({_$litType$:L,strings:t,values:e})),z=Symbol.for("lit-noChange"),R=Symbol.for("lit-nothing"),j=new WeakMap,D=w.createTreeWalker(w,129,null,!1);var L;class W{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[p,d]=((t,e)=>{const i=t.length-1,o=[];let r,s=2===e?"<svg>":"",n=P;for(let p=0;p<i;p++){const e=t[p];let i,a,d=-1,l=0;for(;l<e.length&&(n.lastIndex=l,a=n.exec(e),null!==a);)l=n.lastIndex,n===P?"!--"===a[1]?n=C:void 0!==a[1]?n=T:void 0!==a[2]?(N.test(a[2])&&(r=RegExp("</"+a[2],"g")),n=U):void 0!==a[3]&&(n=U):n===U?">"===a[0]?(n=null!=r?r:P,d=-1):void 0===a[1]?d=-2:(d=n.lastIndex-a[2].length,i=a[1],n=void 0===a[3]?U:'"'===a[3]?k:O):n===k||n===O?n=U:n===C||n===T?n=P:(n=U,r=void 0);const h=n===U&&t[p+1].startsWith("/>")?" ":"";s+=n===P?e+b:d>=0?(o.push(i),e.slice(0,d)+"$lit$"+e.slice(d)+$+h):e+$+(-2===d?(o.push(void 0),p):h)}const a=s+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==y?y.createHTML(a):a,o]})(t,e);if(this.el=W.createElement(p,i),D.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=D.nextNode())&&a.length<n;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith($)){const i=d[s++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+"$lit$").split($),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?J:"?"===e[1]?Y:"@"===e[1]?Z:F})}else a.push({type:6,index:r})}for(const e of t)o.removeAttribute(e)}if(N.test(o.tagName)){const t=o.textContent.split($),e=t.length-1;if(e>0){o.textContent=g?g.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],S()),D.nextNode(),a.push({type:2,index:++r});o.append(t[e],S())}}}else if(8===o.nodeType)if(o.data===A)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf($,t+1));)a.push({type:7,index:r}),t+=$.length-1}r++}}static createElement(t,e){const i=w.createElement("template");return i.innerHTML=t,i}}function B(t,e,i=t,o){var r,s,n,a;if(e===z)return e;let p=void 0!==o?null===(r=i._$Cl)||void 0===r?void 0:r[o]:i._$Cu;const d=E(e)?void 0:e._$litDirective$;return(null==p?void 0:p.constructor)!==d&&(null===(s=null==p?void 0:p._$AO)||void 0===s||s.call(p,!1),void 0===d?p=void 0:(p=new d(t),p._$AT(t,i,o)),void 0!==o?(null!==(n=(a=i)._$Cl)&&void 0!==n?n:a._$Cl=[])[o]=p:i._$Cu=p),void 0!==p&&(e=B(t,p._$AS(t,e.values),p,o)),e}class V{constructor(t,e){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var e;const{el:{content:i},parts:o}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:w).importNode(i,!0);D.currentNode=r;let s=D.nextNode(),n=0,a=0,p=o[0];for(;void 0!==p;){if(n===p.index){let e;2===p.type?e=new q(s,s.nextSibling,this,t):1===p.type?e=new p.ctor(s,p.name,p.strings,this,t):6===p.type&&(e=new G(s,this,t)),this.v.push(e),p=o[++a]}n!==(null==p?void 0:p.index)&&(s=D.nextNode(),n++)}return r}m(t){let e=0;for(const i of this.v)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class q{constructor(t,e,i,o){var r;this.type=2,this._$AH=R,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cg=null===(r=null==o?void 0:o.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=B(this,t,e),E(t)?t===R||null==t||""===t?(this._$AH!==R&&this._$AR(),this._$AH=R):t!==this._$AH&&t!==z&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.k(t):(t=>{var e;return x(t)||"function"==typeof(null===(e=t)||void 0===e?void 0:e[Symbol.iterator])})(t)?this.S(t):this.$(t)}A(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==R&&E(this._$AH)?this._$AA.nextSibling.data=t:this.k(w.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:o}=t,r="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=W.createElement(o.h,this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.m(i);else{const t=new V(r,this),e=t.p(this.options);t.m(i),this.k(e),this._$AH=t}}_$AC(t){let e=j.get(t.strings);return void 0===e&&j.set(t.strings,e=new W(t)),e}S(t){x(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const r of t)o===e.length?e.push(i=new q(this.A(S()),this.A(S()),this,this.options)):i=e[o],i._$AI(r),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cg=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class F{constructor(t,e,i,o,r){this.type=1,this._$AH=R,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=R}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const r=this.strings;let s=!1;if(void 0===r)t=B(this,t,e,0),s=!E(t)||t!==this._$AH&&t!==z,s&&(this._$AH=t);else{const o=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=B(this,o[i+n],e,n),a===z&&(a=this._$AH[n]),s||(s=!E(a)||a!==this._$AH[n]),a===R?t=R:t!==R&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}s&&!o&&this.C(t)}C(t){t===R?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class J extends F{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===R?void 0:t}}const K=g?g.emptyScript:"";class Y extends F{constructor(){super(...arguments),this.type=4}C(t){t&&t!==R?this.element.setAttribute(this.name,K):this.element.removeAttribute(this.name)}}class Z extends F{constructor(t,e,i,o,r){super(t,e,i,o,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=B(this,t,e,0))&&void 0!==i?i:R)===z)return;const o=this._$AH,r=t===R&&o!==R||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,s=t!==R&&(o===R||r);r&&this.element.removeEventListener(this.name,this,o),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class G{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){B(this,t)}}const Q=window.litHtmlPolyfillSupport;
|
|
40
40
|
/**
|
|
41
41
|
* @license
|
|
42
42
|
* Copyright 2017 Google LLC
|
|
43
43
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
44
|
*/
|
|
45
|
-
var
|
|
46
|
-
|
|
45
|
+
var X,tt;null==Q||Q(W,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:globalThis.litHtmlVersions=[]).push("2.2.0");class et extends m{constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=((t,e,i)=>{var o,r;const s=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let n=s._$litPart$;if(void 0===n){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=n=new q(e.insertBefore(S(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return z}}et.finalized=!0,et._$litElement$=!0,null===(X=globalThis.litElementHydrateSupport)||void 0===X||X.call(globalThis,{LitElement:et});const it=globalThis.litElementPolyfillSupport;null==it||it({LitElement:et}),(null!==(tt=globalThis.litElementVersions)&&void 0!==tt?tt:globalThis.litElementVersions=[]).push("3.2.0");const ot="__registered_effects";function rt(t){const e=t;if(e[ot])return e;const i=function(t){if(!t.dispatchEvent||!t.requestUpdate)throw new Error("Element missing required functions (dispatchEvent/requestUpdate)");return t}(t),o=i.updated;return e[ot]={index:0,count:0,effects:[]},i.updated=t=>(e[ot].index=0,o(t)),e}function st(t,e,i){const o=function(t,e){const i=rt(t),{index:o,count:r}=i[ot];return o===r?(i[ot].index++,i[ot].count++,i[ot].effects.push(e),e):(i[ot].index++,i[ot].effects[o])}(t,{on:e,observe:["__initial__dirty"]});o.observe.some(((t,e)=>i[e]!==t))&&o.on(),o.observe=i}var nt=((t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,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.")})(i)+t[o+1]),t[0]);return new a(i,s)})`
|
|
46
|
+
:host {
|
|
47
47
|
--shipaid-primary: #002bd6;
|
|
48
48
|
--shipaid-secondary: #0076ff;
|
|
49
49
|
--shipaid-text: #000000;
|
|
@@ -56,7 +56,122 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
56
56
|
--shipaid-font-lg: 18px;
|
|
57
57
|
--shipaid-font-regular: 400;
|
|
58
58
|
--shipaid-font-heavy: 700;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
* {
|
|
62
|
+
font-family: var(--shipaid-font);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Popups */
|
|
66
|
+
|
|
67
|
+
.shipaid-popup {
|
|
68
|
+
position: fixed;
|
|
69
|
+
top: 0;
|
|
70
|
+
bottom: 0;
|
|
71
|
+
left: 0;
|
|
72
|
+
right: 0;
|
|
73
|
+
margin: auto;
|
|
74
|
+
max-width: 500px;
|
|
75
|
+
max-height: 100vh;
|
|
76
|
+
height: fit-content;
|
|
77
|
+
border: var(--shipaid-light-grey) 1px solid;
|
|
78
|
+
background-color: #fff;
|
|
79
|
+
z-index: 10000;
|
|
80
|
+
overflow: auto;
|
|
81
|
+
visibility: hidden;
|
|
82
|
+
opacity: 0;
|
|
83
|
+
transition: all 250ms ease-in-out;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.shipaid-popup.active {
|
|
87
|
+
visibility: visible;
|
|
88
|
+
opacity: 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@media (max-width: 600px) {
|
|
92
|
+
.shipaid-popup {
|
|
93
|
+
width: 100vw;
|
|
94
|
+
height: 100vh;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.shipaid-popup .popup {
|
|
99
|
+
display: inline-flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
gap: 1rem;
|
|
102
|
+
padding: 5rem;
|
|
103
|
+
height: fit-content;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@media (max-width: 600px) {
|
|
107
|
+
.shipaid-popup .popup {
|
|
108
|
+
padding: 3rem;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
59
111
|
|
|
112
|
+
.popup .popup-close {
|
|
113
|
+
width: fit-content;
|
|
114
|
+
margin-left: auto;
|
|
115
|
+
background-color: transparent;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
border: none;
|
|
118
|
+
font-family: var(--shipaid-font);
|
|
119
|
+
font-weight: var(--shipaid-font-heavy);
|
|
120
|
+
text-transform: uppercase;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.popup .popup-title {
|
|
124
|
+
font-size: clamp(1.8rem, 2vw + 1rem, 2.8rem);;
|
|
125
|
+
letter-spacing: 1px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.popup p {
|
|
129
|
+
font-size: clamp(1.125rem, 1vw + 1rem, 1.6rem);
|
|
130
|
+
margin: 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.popup .popup-disclaimer {
|
|
134
|
+
font-size: 10px;
|
|
135
|
+
color: var(--shipaid-text-muted);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.popup .popup-footer {
|
|
139
|
+
display: flex;
|
|
140
|
+
flex-direction: row;
|
|
141
|
+
justify-content: space-between;
|
|
142
|
+
align-items: flex-start;
|
|
143
|
+
margin-top: 2rem;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@media (max-width: 600px) {
|
|
147
|
+
.popup .popup-footer {
|
|
148
|
+
flex-direction: column;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.popup .popup-footer .footer-links {
|
|
153
|
+
display: flex;
|
|
154
|
+
flex-direction: row;
|
|
155
|
+
gap: 2rem;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.popup .popup-footer .footer-links a {
|
|
159
|
+
font-family: var(--shipaid-font);
|
|
160
|
+
font-size: var(--shipaid-font-sm);
|
|
161
|
+
color: var(--shipaid-text-muted);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.popup .popup-footer .footer-date p {
|
|
165
|
+
font-family: var(--shipaid-font);
|
|
166
|
+
font-weight: var(--shipaid-font-heavy);
|
|
167
|
+
font-size: var(--shipaid-font-sm);
|
|
168
|
+
color: var(--shipaid-text);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
/* Widget */
|
|
173
|
+
|
|
174
|
+
.shipaid-prompt {
|
|
60
175
|
width: 400px;
|
|
61
176
|
font-family: var(--shipaid-font);
|
|
62
177
|
font-size: var(--shipaid-font-base);
|
|
@@ -66,6 +181,13 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
66
181
|
gap: 1rem;
|
|
67
182
|
margin: 2rem 0 2rem auto;
|
|
68
183
|
}
|
|
184
|
+
|
|
185
|
+
@media (max-width: 600px) {
|
|
186
|
+
.shipaid-prompt {
|
|
187
|
+
width: 100%;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
69
191
|
.shipaid-prompt p, .shipaid-prompt a {
|
|
70
192
|
margin: 0;
|
|
71
193
|
line-height: 1;
|
|
@@ -121,6 +243,9 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
121
243
|
cursor: pointer;
|
|
122
244
|
text-decoration: underline;
|
|
123
245
|
font-size: var(--shipaid-font-sm);
|
|
246
|
+
background-color: transparent;
|
|
247
|
+
cursor: pointer;
|
|
248
|
+
border: none;
|
|
124
249
|
}
|
|
125
250
|
.shipaid-prompt .prompt-footer .prompt-footer-badge {
|
|
126
251
|
background-color: var(--shipaid-light-grey);
|
|
@@ -141,12 +266,32 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
141
266
|
color: var(--shipaid-text-grey);
|
|
142
267
|
font-weight: var(--shipaid-font-heavy);
|
|
143
268
|
}
|
|
144
|
-
`,at=Object.defineProperty,
|
|
269
|
+
`,at=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,dt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?pt(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&at(e,i,s),s},lt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(lt||{});const ht=async(t,e)=>{try{const i=await fetch(t,e);if(!i.ok)throw new Error(await i.text());return await i.json()}catch(i){throw console.error(i),new Error("Failed to complete fetch request.")}};t.ShipAidWidget=class extends et{constructor(){var t;super(...arguments),this._storeDomain=null==(t=window.Shopify)?void 0:t.shop,this._hasFinishedSetup=!1,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>ht(t),post:(t,e)=>ht(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t,e;((t,e)=>{st(t,e,[]);
|
|
145
270
|
/**
|
|
146
271
|
* @license
|
|
147
272
|
* Copyright 2021 Google LLC
|
|
148
273
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
149
|
-
*/})(this,(async()=>{var t,e;const
|
|
274
|
+
*/})(this,(async()=>{var t,e;console.log("add fonts to head");const i=document.createElement("link");i.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),i.setAttribute("rel","stylesheet"),document.head.appendChild(i);const[o,r]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=o,this._cart=r;const s=null!=(e=null==(t=r.items)?void 0:t.some((t=>t.variant_id===o.productVariantNumericId)))&&e;this._hasProtectionInCart=s,this._hasFinishedSetup=!0,this._dispatchEvent("shipaid-loaded",o)})),st(this,(()=>{var t,e,i,o;if(null==(t=this._cart)||!t.items)return;const r=null==(i=null==(e=this._cart)?void 0:e.items)?void 0:i.findIndex((t=>{var e;return t.variant_id===(null==(e=this._store)?void 0:e.productVariantNumericId)})),s=null==(o=this._cart)?void 0:o.items[r];this._hasProtectionInCart=!!s,s&&(this._protectionProduct=M(H({},s),{index:r,position:r+1}))}),[this._store,this._cart]);const i=I`
|
|
275
|
+
<div class=${`shipaid-popup ${"learn-more"===this._popup&&"active"}`}>
|
|
276
|
+
<div class="popup">
|
|
277
|
+
<button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
|
|
278
|
+
<p class="popup-title">Instant Package Protection</p>
|
|
279
|
+
<p>We empower your favorite brands to protect their packages, because every order is precious!</p>
|
|
280
|
+
<p class="popup-title">Shop Care-Free With ShipAid</p>
|
|
281
|
+
<p>Brands and shipment carriers cannot always guarantee your order will arrive at your doorstep safely. Things happen! We allow the brand you are purchasing from to protect your order in the chance of an issue in transit. If you encounter an issue, simply reach out to the brand and they will handle your claim as soon as possible</p>
|
|
282
|
+
<p class="popup-disclaimer">By purchasing this protection, you are agreeing to our Terms Of Service and Privacy Policy. You are not obligated to purchase this protection. This protection is NOT insurance. Purchasing this protection does not guarantee you will be reimbursed for any product or shipping costs. The claim process and decision for compensation is strictly decided by the brand you a purchasing from.</p>
|
|
283
|
+
<div class="popup-footer">
|
|
284
|
+
<div class="footer-links">
|
|
285
|
+
<a>Terms of Service</a>
|
|
286
|
+
<a>Privacy Policy</a>
|
|
287
|
+
</div>
|
|
288
|
+
<div class="footer-date">
|
|
289
|
+
<p>ShipAid © ${(new Date).getFullYear()}</p>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
`,o=I`
|
|
150
295
|
<div class="shipaid-prompt">
|
|
151
296
|
<p class="prompt-title">${this._hasProtectionInCart?"Active":"Inactive"}</p>
|
|
152
297
|
<div class="prompt-product">
|
|
@@ -158,14 +303,14 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
158
303
|
<p class="prompt-product-details-description">Resolve shipping issues care-free</p>
|
|
159
304
|
</div>
|
|
160
305
|
<div class="prompt-product-actions">
|
|
161
|
-
<p class="prompt-product-actions-price">${
|
|
306
|
+
<p class="prompt-product-actions-price">${this._currencyFormat(null!=(e=null==(t=this._store)?void 0:t.productPrice)?e:0)}</p>
|
|
162
307
|
<button class="prompt-product-actions-button" @click=${this._updateProtection} ?disabled=${this._state.loading}>
|
|
163
308
|
${this._state.loading?"Loading...":this._hasProtectionInCart?"Remove":"+ Add"}
|
|
164
309
|
</button>
|
|
165
310
|
</div>
|
|
166
311
|
</div>
|
|
167
312
|
<div class="prompt-footer">
|
|
168
|
-
<
|
|
313
|
+
<button class="prompt-footer-about" @click=${()=>{this._popup="learn-more"}}>Learn More</button>
|
|
169
314
|
<a class="prompt-footer-badge" href="/">
|
|
170
315
|
<span>Powered by</span>
|
|
171
316
|
<span class="ship">Ship</span>
|
|
@@ -174,5 +319,7 @@ var Y,tt;null==X||X(V,q),(null!==(_=globalThis.litHtmlVersions)&&void 0!==_?_:gl
|
|
|
174
319
|
</div>
|
|
175
320
|
</div>
|
|
176
321
|
`;return I`
|
|
177
|
-
|
|
178
|
-
|
|
322
|
+
<div class="shipaid">
|
|
323
|
+
${function(t,e,i){return t?e():null==i?void 0:i()}(this._hasFinishedSetup&&this._store,(()=>[i,o]),(()=>I`<p>Loading...</p>`))}
|
|
324
|
+
</div>
|
|
325
|
+
`}_currencyFormat(t){var e,i,o,r,s;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:(null==(o=this._store)?void 0:o.currency)||(null==(s=null==(r=window.Shopify)?void 0:r.currency)?void 0:s.active)||"USD",style:"currency"}).format(t)}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}_setState(t,e){this._state={loading:"loading"===t,success:"success"===t,error:"error"===t&&(e||!0)}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{const t=this._storeDomain||window.location.hostname;if(!t)throw new Error("Missing store domain - cannot continue.");const e={domain:t},i="query StoreByDomain($domain: String!) {\n store: store_properties(args: { store: $domain }) {\n currency\n productId\n productPrice\n productVariantId\n productVariantNumericId\n store\n }\n }",{data:o}=await this._fetch.post("http://localhost:1337/v1/graphql",{query:i,variables:e});if(!o.store)throw new Error(`Could not find a store for ${t}`);if(!o.store.productVariantNumericId)throw new Error("Missing variant ID for ShipAid product.");return o.store}catch(L){throw console.error(L),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(L){throw console.error(L),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async addProtection(){var t,e;try{if(null==(t=this._store)||!t.productVariantNumericId)throw new Error("Store has not been loaded.");if(null==(e=this._cart)||!e.items)throw new Error("Cart has not been loaded.");this._setState("loading");const i={id:this._store.productVariantNumericId,quantity:1},o=await this._fetch.post("/cart/add.js",i),r=M(H({},this._cart),{items:[o,...this._cart.items]});this._cart=r,this._setState("success"),this._dispatchEvent("shipaid-protection-status",{protection:!0,cart:r,lineItem:o})}catch(i){console.error(i),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){var t;try{if(null==(t=this._store)||!t.productVariantNumericId)throw new Error("Store has not been loaded.");if(!this._protectionProduct)throw new Error("Protection product not found.");this._setState("loading");const e={id:this._protectionProduct.key,quantity:0},i=await this._fetch.post("/cart/change.js",e);this._dispatchEvent("shipaid-protection-status",{protection:!1,cart:i,lineItem:this._protectionProduct}),this._cart=i,this._setState("success")}catch(e){console.error(e),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}},t.ShipAidWidget.styles=nt,dt([i()],t.ShipAidWidget.prototype,"_storeDomain",2),dt([i()],t.ShipAidWidget.prototype,"_store",2),dt([i()],t.ShipAidWidget.prototype,"_cart",2),dt([i()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),dt([i()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),dt([i()],t.ShipAidWidget.prototype,"_protectionProduct",2),dt([i()],t.ShipAidWidget.prototype,"_state",2),dt([i()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=dt([(t=>e=>{return"function"==typeof e?(i=t,o=e,window.customElements.define(i,o),o):((t,e)=>{const{kind:i,elements:o}=e;return{kind:i,elements:o,finisher(e){window.customElements.define(t,e)}}})(t,e);var i,o})("shipaid-widget")],t.ShipAidWidget),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ui.shipaid.com",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"main": "dist/ui.shipaid.com.umd.js",
|
|
6
6
|
"unpkg": "dist/ui.shipaid.com.iife.js",
|
|
7
7
|
"module": "dist/ui.shipaid.com.es.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@lit-labs/task": "^1.1.1",
|
|
23
|
-
"lit": "^2.2.
|
|
23
|
+
"lit": "^2.2.1",
|
|
24
24
|
"lit-element-effect": "^1.0.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -34,9 +34,6 @@
|
|
|
34
34
|
"eslint-plugin-lit-a11y": "^2.2.0",
|
|
35
35
|
"eslint-plugin-node": "^11.1.0",
|
|
36
36
|
"eslint-plugin-promise": "^5.2.0",
|
|
37
|
-
"rollup-plugin-postcss": "^4.0.2",
|
|
38
|
-
"rollup-plugin-postcss-lit": "^2.0.0",
|
|
39
|
-
"sass": "^1.49.9",
|
|
40
37
|
"typescript": "^4.6.2",
|
|
41
38
|
"vite": "^2.8.6"
|
|
42
39
|
}
|