@zonos/elements 1.3.174 → 1.3.176
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/dist/cjs/CheckoutConfig-f1442a60.js +35 -0
- package/dist/cjs/{cart-93ed3002.js → cart-e648a65f.js} +11 -5
- package/dist/cjs/index.cjs.js +67 -12
- package/dist/cjs/{paypal-8b49ef07.js → paypal-2390cfb2.js} +1 -1
- package/dist/cjs/zonos-address_7.cjs.entry.js +1 -1
- package/dist/cjs/zonos-cart-items_13.cjs.entry.js +2 -2
- package/dist/cjs/zonos-checkout.cjs.entry.js +57 -4
- package/dist/cjs/zonos-controller.cjs.entry.js +8 -1
- package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-empty-state-payment_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +1 -1
- package/dist/cjs/zonos-hello.cjs.entry.js +4 -4
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/collection/components/utils/api/getShippingZones.js +8 -3
- package/dist/collection/components/utils/api/getZonosSettings.js +7 -0
- package/dist/collection/components/utils/api/trackConversionEvent.js +5 -2
- package/dist/collection/components/utils/hello/getProductsOnPage.js +4 -4
- package/dist/collection/scripts/_getCartInfoById.js +29 -0
- package/dist/collection/scripts/_zonosBase.js +8 -5
- package/dist/collection/scripts/cart/_setupCartDataWithSettings.js +28 -0
- package/dist/collection/types/generated/graphql.internal.types.js +3 -0
- package/dist/esm/CheckoutConfig-5479d192.js +31 -0
- package/dist/esm/{cart-54d84646.js → cart-dc171e7f.js} +12 -6
- package/dist/esm/index.js +68 -13
- package/dist/esm/{paypal-17a320c8.js → paypal-1beec534.js} +1 -1
- package/dist/esm/zonos-address_7.entry.js +1 -1
- package/dist/esm/zonos-cart-items_13.entry.js +2 -2
- package/dist/esm/zonos-checkout.entry.js +56 -3
- package/dist/esm/zonos-controller.entry.js +8 -1
- package/dist/esm/zonos-country-flag.entry.js +1 -1
- package/dist/esm/zonos-country-select_4.entry.js +1 -1
- package/dist/esm/zonos-empty-state-payment_4.entry.js +2 -2
- package/dist/esm/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm/zonos-hello.entry.js +4 -4
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/CheckoutConfig-5479d192.js +1 -0
- package/dist/esm-es5/cart-dc171e7f.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{paypal-17a320c8.js → paypal-1beec534.js} +1 -1
- package/dist/esm-es5/zonos-address_7.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-empty-state-payment_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/scripts/index.d.ts +199 -0
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/scripts/_getCartInfoById.d.ts +7 -0
- package/dist/types/scripts/_zonosBase.d.ts +11 -1
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +166 -0
- package/dist/types/types/checkout/api/NormalizedTempCart.d.ts +20 -1
- package/dist/types/types/generated/graphql.internal.types.d.ts +155 -0
- package/dist/types/types/generated/graphql.internal.types.ts +159 -0
- package/dist/types/types/utils/ZonosSettings.d.ts +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-007a4d24.entry.js +1 -0
- package/dist/zonos-elements/{p-9f8b820e.system.entry.js → p-08fa3875.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3d169241.system.entry.js → p-0a6aa4cf.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d9779ea7.entry.js → p-0ef83bec.entry.js} +1 -1
- package/dist/zonos-elements/{p-ed8a8a44.entry.js → p-117eb67d.entry.js} +1 -1
- package/dist/zonos-elements/{p-28dcd7bb.entry.js → p-24d4f2ec.entry.js} +1 -1
- package/dist/zonos-elements/{p-d22c15be.entry.js → p-30ff0a71.entry.js} +1 -1
- package/dist/zonos-elements/p-35bfc9d1.system.entry.js +1 -0
- package/dist/zonos-elements/p-40e5359c.system.js +1 -0
- package/dist/zonos-elements/p-46f6e5e9.system.js +1 -1
- package/dist/zonos-elements/p-5372fed8.system.js +1 -0
- package/dist/zonos-elements/{p-c67f6666.system.entry.js → p-60ab9c4c.system.entry.js} +1 -1
- package/dist/zonos-elements/p-655bc743.system.entry.js +1 -0
- package/dist/zonos-elements/{p-6612e6f9.system.entry.js → p-6ef7451f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e11eecbf.system.entry.js → p-7dd0d6b4.system.entry.js} +1 -1
- package/dist/zonos-elements/p-80dd3fb6.entry.js +1 -0
- package/dist/zonos-elements/p-8ee34712.system.js +1 -0
- package/dist/zonos-elements/{p-d98fa14c.system.entry.js → p-a334b6d8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1b6d0895.system.entry.js → p-a7d2a768.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-78a95cee.entry.js → p-aa651c8f.entry.js} +1 -1
- package/dist/zonos-elements/{p-8e436df2.system.entry.js → p-bdf93de1.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-f80f24a0.js → p-d53968eb.js} +2 -2
- package/dist/zonos-elements/p-e3f9a12b.js +1 -0
- package/dist/zonos-elements/{p-0ee9b22a.entry.js → p-e9f8edbb.entry.js} +1 -1
- package/dist/zonos-elements/{p-8964d8f8.system.js → p-ef7d14a3.system.js} +1 -1
- package/dist/zonos-elements/p-f4d9f007.entry.js +1 -0
- package/dist/zonos-elements/{p-4c6dfe2e.entry.js → p-f4eaf289.entry.js} +1 -1
- package/dist/zonos-elements/p-fe253cc1.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/CheckoutConfig-fb59baa3.js +0 -90
- package/dist/esm/CheckoutConfig-63b3ed06.js +0 -86
- package/dist/esm-es5/CheckoutConfig-63b3ed06.js +0 -1
- package/dist/esm-es5/cart-54d84646.js +0 -1
- package/dist/zonos-elements/p-19ac0f84.system.entry.js +0 -1
- package/dist/zonos-elements/p-416ac901.entry.js +0 -1
- package/dist/zonos-elements/p-4a87a92c.entry.js +0 -1
- package/dist/zonos-elements/p-75b771cf.js +0 -1
- package/dist/zonos-elements/p-84dd312c.system.js +0 -1
- package/dist/zonos-elements/p-869bbedc.js +0 -1
- package/dist/zonos-elements/p-a1d54022.system.js +0 -1
- package/dist/zonos-elements/p-b86b82eb.entry.js +0 -1
- package/dist/zonos-elements/p-d74ab632.system.entry.js +0 -1
- package/dist/zonos-elements/p-e0d3aeae.system.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function r(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,i){function s(o){try{l(n.next(o))}catch(o){i(o)}}function a(o){try{l(n["throw"](o))}catch(o){i(o)}}function l(o){o.done?t(o.value):r(o.value).then(s,a)}l((n=n.apply(o,e||[])).next())}))};var __generator=this&&this.__generator||function(o,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,r,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(o){return function(e){return l([o,e])}}function l(a){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(t=0)),t)try{if(n=1,r&&(i=a[0]&2?r["return"]:a[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;if(r=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;r=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=e.call(o,t)}catch(o){a=[6,o];r=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host}from"./index-d82f06f2.js";import{_ as _root,e as _baseGetTag,i as isObjectLike_1,f as isObject_1,z as zonosStore,g as getZonosStoreTheme,m as mergeConfig}from"./zonosStore-d3c5a0a5.js";import{l as localizationStore,G as isValidSelector,r as translate,u as getZCountryUrlParam,I as setZCountryUrlParam,J as currencyDisplay,K as currencyConvertAndFormat,L as currencyConvert,E as currencyFormat}from"./cart-54d84646.js";import{c as classes}from"./classes-0d95c529.js";import{h as handleFetch,b as logError,l as log}from"./handleFetch-621e45bc.js";import{g as getHasMoreSpaceOnRight}from"./getHasMoreSpaceOnRight-70eb913a.js";import"./isDarkColor-446fccb7.js";import"./getBorderRadius-ada3ccad.js";var root=_root;var now$1=function(){return root.Date.now()};var now_1=now$1;var reWhitespace=/\s/;function trimmedEndIndex$1(o){var e=o.length;while(e--&&reWhitespace.test(o.charAt(e))){}return e}var _trimmedEndIndex=trimmedEndIndex$1;var trimmedEndIndex=_trimmedEndIndex;var reTrimStart=/^\s+/;function baseTrim$1(o){return o?o.slice(0,trimmedEndIndex(o)+1).replace(reTrimStart,""):o}var _baseTrim=baseTrim$1;var baseGetTag=_baseGetTag,isObjectLike=isObjectLike_1;var symbolTag="[object Symbol]";function isSymbol$1(o){return typeof o=="symbol"||isObjectLike(o)&&baseGetTag(o)==symbolTag}var isSymbol_1=isSymbol$1;var baseTrim=_baseTrim,isObject$1=isObject_1,isSymbol=isSymbol_1;var NAN=0/0;var reIsBadHex=/^[-+]0x[0-9a-f]+$/i;var reIsBinary=/^0b[01]+$/i;var reIsOctal=/^0o[0-7]+$/i;var freeParseInt=parseInt;function toNumber$1(o){if(typeof o=="number"){return o}if(isSymbol(o)){return NAN}if(isObject$1(o)){var e=typeof o.valueOf=="function"?o.valueOf():o;o=isObject$1(e)?e+"":e}if(typeof o!="string"){return o===0?o:+o}o=baseTrim(o);var t=reIsBinary.test(o);return t||reIsOctal.test(o)?freeParseInt(o.slice(2),t?2:8):reIsBadHex.test(o)?NAN:+o}var toNumber_1=toNumber$1;var isObject=isObject_1,now=now_1,toNumber=toNumber_1;var FUNC_ERROR_TEXT="Expected a function";var nativeMax=Math.max,nativeMin=Math.min;function debounce(o,e,t){var n,r,i,s,a,l,h=0,d=false,c=false,u=true;if(typeof o!="function"){throw new TypeError(FUNC_ERROR_TEXT)}e=toNumber(e)||0;if(isObject(t)){d=!!t.leading;c="maxWait"in t;i=c?nativeMax(toNumber(t.maxWait)||0,e):i;u="trailing"in t?!!t.trailing:u}function f(e){var t=n,i=r;n=r=undefined;h=e;s=o.apply(i,t);return s}function m(o){h=o;a=setTimeout(w,e);return d?f(o):s}function g(o){var t=o-l,n=o-h,r=e-t;return c?nativeMin(r,i-n):r}function v(o){var t=o-l,n=o-h;return l===undefined||t>=e||t<0||c&&n>=i}function w(){var o=now();if(v(o)){return z(o)}a=setTimeout(w,g(o))}function z(o){a=undefined;if(u&&n){return f(o)}n=r=undefined;return s}function p(){if(a!==undefined){clearTimeout(a)}h=0;n=l=r=a=undefined}function b(){return a===undefined?s:z(now())}function x(){var o=now(),t=v(o);n=arguments;r=this;l=o;if(t){if(a===undefined){return m(l)}if(c){clearTimeout(a);a=setTimeout(w,e);return f(l)}}if(a===undefined){a=setTimeout(w,e)}return s}x.cancel=p;x.flush=b;return x}var debounce_1=debounce;var checkItemRestrictions=function(o){return __awaiter(void 0,[o],void 0,(function(o){var e,t,n,r,i;var s=o.items,a=o.shipFrom,l=o.shipTo;return __generator(this,(function(o){switch(o.label){case 0:t={items:s,shipFrom:a,shipTo:l};return[4,handleFetch("/api/zonos-elements/check-item-restrictions",{body:t,method:"POST"})];case 1:n=o.sent(),r=n.errors,i=n.json;if(r.length||!i){logError("Error fetching item restrictions: ".concat((e=r.find(Boolean))===null||e===void 0?void 0:e.message));return[2,[]]}return[2,i.filter(Boolean)]}}))}))};var detectItemRestrictions=function(o){return __awaiter(void 0,void 0,void 0,(function(){var e,t,n,r;return __generator(this,(function(i){switch(i.label){case 0:if(!o.length){return[2,[]]}e=localizationStore.selectedCountryCode;if(!e){logError("Hello could not check item restrictions - No country code selected");return[2,[]]}t=o.map((function(o){return{description:o.description,name:o.title}}));return[4,checkItemRestrictions({items:t,shipFrom:"AD",shipTo:e})];case 1:n=i.sent();r=n.map((function(o){var e;var n=((e=t.filter((function(e){return e.description===o.itemDescription})).find(Boolean))===null||e===void 0?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:n})}));return[2,r]}}))}))};var matchUrlPattern=function(o){var e=o===null||o===void 0?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)};var getCurrentHelloLocalePage=function(){var o=zonosStore.helloSettings,e=o.cartUrlPattern,t=o.homepageUrlPattern,n=o.productDetailUrlPattern,r=o.productListUrlPattern;if(matchUrlPattern(e)){return"cart"}if(matchUrlPattern(n)){return"productDetail"}if(matchUrlPattern(r)){return"productList"}if(matchUrlPattern(t)){return"home"}return""};var getProductsOnPage=function(){var o,e;var t=zonosStore.helloSettings,n=t.productAddToCartElementSelector,r=t.productDescriptionElementSelector,i=t.productTitleElementSelector,s=t.restrictionBehavior;if(!i||!r){logError("Hello could not check item restrictions - must provide title and description selectors.")}var a=i&&isValidSelector(i)&&document.querySelectorAll(i)||[];var l=r&&isValidSelector(r)&&document.querySelectorAll(r)||[];if(a.length!==l.length){logError("Hello could not check item restrictions - Title and description selectors do not match");return[]}var h=s==="RESTRICT_AND_BLOCK";var d=h&&n&&isValidSelector(n)&&document.querySelectorAll(n)||[];if(h&&d.length!==l.length){logError('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match')}var c=[];for(var u=0;u<a.length;u++){var f=a[u];var m=l[u];var g=d[u];if(f&&m){var v={cartButtonNode:g||null,description:((o=m.textContent)===null||o===void 0?void 0:o.trim())||"",title:((e=f.textContent)===null||e===void 0?void 0:e.trim())||""};c.push(v)}}return c};var zonosHelloCss=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:inline-block}:host .zonos--hello-wrapper{position:relative}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper-mobile-override{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media (max-width: 768px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}}:host .zonos--hello-widget{-webkit-transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);padding:6px;border-radius:30px;background:var(--zonos-elements-page-background);font-size:var(--zonos-elements-font-size-s);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;position:relative;z-index:1000}:host .zonos--hello-widget>.zonos--hello-message{-ms-flex-order:0;order:0;max-width:0;height:100%;white-space:nowrap;-webkit-transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);overflow:hidden;color:var(--zonos-elements-text-color);position:absolute;background:var(--zonos-elements-page-background);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top-left-radius:30px;border-bottom-left-radius:30px;left:0;-webkit-transform:translateX(calc(-100% + 16px));transform:translateX(calc(-100% + 16px));width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border-top:var(--zonos-elements-border);border-bottom:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-has-restrictions{background:var(--zonos-elements-red-100);border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-has-restrictions>.zonos--hello-message{background:var(--zonos-elements-red-100);color:var(--zonos-elements-red-800);font-weight:500}:host .zonos--hello-widget.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-show-peek-message{max-width:100vw;width:100%}:host .zonos--hello-widget.zonos--hello-show-peek-message>.zonos--hello-message{max-width:100vw;padding:0 6px;padding-right:16px;border:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-show-peek-message:not(.zonos--hello-widget-animate-from-left)>.zonos--hello-message{border-right:none}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{border-left:0}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:16px;padding-right:6px;border-left:none}:host .zonos--hello-widget.zonos--hello-widget-animate-from-left>.zonos--hello-message{-ms-flex-order:1;order:1;-webkit-transform:translateX(calc(100% - 16px));transform:translateX(calc(100% - 16px));right:0;left:auto;border-top-right-radius:30px;border-bottom-right-radius:30px}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper .zonos--hello-country-flag{height:18px;width:18px;position:relative;overflow:hidden;border-radius:30px;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}:host .zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}";var ZonosHelloStyle0=zonosHelloCss;var PEEK_MESSAGE_CLOSE_DELAY_MS=3e3;var ZonosHello=function(){function o(o){var e=this;registerInstance(this,o);this.getHelloPeekMessage=function(o){var t=zonosStore.currentHelloPage==="productDetail"||zonosStore.currentHelloPage==="productList";if(t&&e.allRestrictedItems.length){var n=translate("click to learn more");var r=zonosStore.currentHelloPage==="productDetail"?translate("Restricted item"):translate("Restricted items found");return"".concat(r," - ").concat(n)}switch(zonosStore.currentHelloPage){case"cart":return translate("Prepay duties and taxes at checkout");case"productList":case"productDetail":return translate("See duty and tax thresholds");default:return translate("Welcome to [storeName]",{storeName:o})}};this.enableShowPeekMessage=function(){if(e.peekMessage){e.showPeekMessage=true}};this.getNewItemRestrictions=function(o){return __awaiter(e,void 0,void 0,(function(){var e,t;return __generator(this,(function(n){switch(n.label){case 0:e=zonosStore.currentHelloPage==="productDetail"||zonosStore.currentHelloPage==="productList";if(!e||zonosStore.helloSettings.restrictionBehavior==="DISABLED"){return[2,[]]}return[4,detectItemRestrictions(o)];case 1:t=n.sent();return[2,t]}}))}))};this.triggerShowPeekMessage=function(){e.peekMessage=e.getHelloPeekMessage(zonosStore.organizationName);var o=zonosStore.helloSettings,t=o.peekMessageBehavior,n=o.peekMessageDelay;var r=n*1e3;if(t==="ENABLED"){setTimeout((function(){e.enableShowPeekMessage();var o=e.allRestrictedItems.some((function(o){return e.productsOnPage.some((function(e){return e.description===o.itemDescription}))}));if(!o){setTimeout((function(){e.showPeekMessage=false}),PEEK_MESSAGE_CLOSE_DELAY_MS)}}),r)}};this.disableAddToCartButtons=function(){if(e.productsOnPage.length){e.productsOnPage.forEach((function(o){var t,n;var r=e.allRestrictedItems.some((function(e){return e.itemDescription===o.description}));if(r){(t=o.cartButtonNode)===null||t===void 0?void 0:t.setAttribute("disabled","disabled")}else{(n=o.cartButtonNode)===null||n===void 0?void 0:n.removeAttribute("disabled")}}))}};this.handleItemRestrictions=function(){return __awaiter(e,void 0,void 0,(function(){var o,e;var t,n;var r=this;return __generator(this,(function(i){switch(i.label){case 0:this.productsOnPage=getProductsOnPage();o=this.productsOnPage.filter((function(o){return!r.allFoundProducts.some((function(e){return e.title===o.title}))}));return[4,this.getNewItemRestrictions(o)];case 1:e=i.sent();(t=this.allRestrictedItems).push.apply(t,e);(n=this.allFoundProducts).push.apply(n,o);this.disableAddToCartButtons();return[2]}}))}))};this.reloadHelloData=function(){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(o){switch(o.label){case 0:return[4,this.handleItemRestrictions()];case 1:o.sent();this.triggerShowPeekMessage();return[2]}}))}))};this.handleProductCountChange=debounce_1((function(){var o=zonosStore.helloSettings.productTitleElementSelector;if(o){var t=getProductsOnPage();if(e.allFoundProducts.length!==t.length&&window.location.href===e.initialUrl){if(!e.allFoundProducts.length){return}void e.reloadHelloData()}}}),1e3);this.watchProductCountChange=function(){var o=new MutationObserver(e.handleProductCountChange);o.observe(document.body,{childList:true,subtree:true})};this.watchPriceChange=function(){var o=new MutationObserver((function(){return void e.displayCurrency()}));o.observe(document.body,{attributes:true,childList:true,subtree:true})};this.updateHelloOnPageChange=function(){e.watchProductCountChange();setInterval((function(){if(window.location.href!==e.initialUrl){var o=e.initialUrl&&new URL(e.initialUrl);var t=o&&getZCountryUrlParam(o.searchParams);if(t!==localizationStore.selectedCountryCode){e.allFoundProducts=[];e.allRestrictedItems=[];e.productsOnPage=[]}e.initialUrl=window.location.href;zonosStore.currentHelloPage=getCurrentHelloLocalePage();var n=new URL(window.location.href);var r=getZCountryUrlParam(n.searchParams);if(!r){setZCountryUrlParam(localizationStore.selectedCountryCode);return}void e.reloadHelloData()}}),1e3)};this.changeShowDialog=function(o){e.showDialog=o};this.shouldAnimateLeftDesktop=function(){var o=e.helloRef&&getComputedStyle(e.helloRef).position;if(e.helloRef&&o==="relative"){var t=getHasMoreSpaceOnRight(e.helloRef);return t}};this.shouldRenderHello=function(o){if(o===void 0){o=true}if(!localizationStore.localizationLoaded){return false}var e=zonosStore.helloSettings.showForCountries;if(o){if(!localizationStore.isShippableCountry){log("Hello: not shippable country - Show for countries: ".concat(e))}}if(e==="ONLY_SHIPPABLE"){return localizationStore.isShippableCountry}if(e==="ALL"){return true}return e===null||e===void 0?void 0:e.includes(localizationStore.selectedCountryCode||"")};this.mobileLocationOverride=undefined;this.animateFromLeftOverride=undefined;this.appearanceSettingsOverride=undefined;this.showPeekMessage=false;this.zonosStoreHelloSettings=zonosStore.helloSettings;this.showDialog=false;this.peekMessage="";this.initialUrl="";this.allRestrictedItems=[];this.allFoundProducts=[];this.productsOnPage=[];this.isHelloWidgetRendered=false;this.isMobile=false}o.prototype.getCountryList=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){return[2,localizationStore.helloCountryList]}))}))};o.prototype.componentWillLoad=function(){var o=this;var e=setInterval((function(){return __awaiter(o,void 0,void 0,(function(){return __generator(this,(function(o){if(!this.helloRef){return[2]}if(zonosStore.loadedConfig){this.helloRef.setAttribute("data-zonos-hello-loaded","");this.updateHelloOnPageChange();this.watchPriceChange();this.handleAppearanceSettingsOverrideChange();clearInterval(e)}return[2]}))}))}),100)};o.prototype.displayCurrency=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){if(zonosStore.helloSettings.currencyBehavior==="DISABLED"){return[2]}if(!localizationStore.exchangeRate){log("Could not display currency. Exchange rate and format data is not available.","warn");return[2]}currencyDisplay();return[2]}))}))};o.prototype.convertAndFormat=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,currencyConvertAndFormat(o)]}))}))};o.prototype.convert=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,currencyConvert(o)]}))}))};o.prototype.format=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,currencyFormat({amount:o})]}))}))};o.prototype.openHelloDialog=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.changeShowDialog(o);return[2]}))}))};o.prototype.handleResize=function(){this.isMobile=window.innerWidth<=768};o.prototype.handleHelloWidgetInitializedState=function(o){var e=o.countryCode,t=o.currencyCode;var n,r;if(this.isHelloWidgetRendered){return}if(localizationStore.selectedCountryCode&&typeof zonosStore.helloSettings.onInitSuccess==="function"){this.isHelloWidgetRendered=true;void((r=(n=zonosStore.helloSettings).onInitSuccess)===null||r===void 0?void 0:r.call(n,{countryCode:e,currencyCode:t}))}};o.prototype.getHelloLocation=function(){var o=this.mobileLocationOverride||zonosStore.helloSettings.mobileLocation;var e=zonosStore.helloSettings.desktopLocation;var t=this.isMobile;switch(true){case t:{var n=this.animateFromLeftOverride||(o===null||o===void 0?void 0:o.includes("LEFT"));var r=o===null||o===void 0?void 0:o.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:r,shouldFloat:!!o}}default:case!t:{var i=!zonosStore.helloSettings.anchorElementSelector&&!!e;var n=this.animateFromLeftOverride||(e===null||e===void 0?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop();var r=e===null||e===void 0?void 0:e.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:r,shouldFloat:i}}}};o.prototype.handleAppearanceSettingsOverrideChange=function(){var o;if((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme){this.appearanceSettingsOverride.theme=getZonosStoreTheme(this.appearanceSettingsOverride.theme)}};o.prototype.componentDidLoad=function(){this.isMobile=window.innerWidth<=768};o.prototype.render=function(){var o=this;var e,t;var n=(e=zonosStore.helloSettings.excludedUrlPatterns)===null||e===void 0?void 0:e.some((function(o){return o&&new RegExp(o).test(window.location.href)}));if(n){log("Hello is excluded on this url","warn");return null}var r=localizationStore.selectedCountryCode,i=localizationStore.targetCurrency;var s=this.getHelloLocation(),a=s.isOnLeft,l=s.isOnTop,d=s.shouldFloat;var c=mergeConfig(zonosStore.appearance,this.appearanceSettingsOverride||null);var u=c.theme;var f=(t=this.allRestrictedItems)===null||t===void 0?void 0:t.filter((function(e){return o.productsOnPage.some((function(o){return o.description===e.itemDescription}))}));this.peekMessage=this.getHelloPeekMessage(zonosStore.organizationName);var m=this.shouldRenderHello()&&!!r;if(m&&!this.isHelloWidgetRendered){this.handleHelloWidgetInitializedState({countryCode:r,currencyCode:i})}return h(Host,{class:"zonos--hello zonos--elements","data-theme":u},m&&h("div",{class:classes(["zonos--hello-wrapper",d&&"zonos--hello-widget-float"])},h("button",{class:classes(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",a&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",l&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",d&&"zonos--hello-widget-float"]),onClick:function(){void o.changeShowDialog(!o.showDialog)},onMouseEnter:function(){return o.enableShowPeekMessage()},onMouseLeave:function(){return o.showPeekMessage=false},ref:function(e){return e&&(o.helloRef=e)}},h("zonos-text",{class:"zonos--hello-message"},this.peekMessage),r&&h("div",{class:"zonos--hello-country-flag-wrapper"},h("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:r}))),h("div",{class:classes(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",d&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},h("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:c,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:f,setIsOpen:this.changeShowDialog}))))};Object.defineProperty(o,"watchers",{get:function(){return{appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}},enumerable:false,configurable:true});return o}();ZonosHello.style=ZonosHelloStyle0;export{ZonosHello as zonos_hello};
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(o,e,t,n){function r(o){return o instanceof t?o:new t((function(e){e(o)}))}return new(t||(t=Promise))((function(t,i){function s(o){try{l(n.next(o))}catch(o){i(o)}}function a(o){try{l(n["throw"](o))}catch(o){i(o)}}function l(o){o.done?t(o.value):r(o.value).then(s,a)}l((n=n.apply(o,e||[])).next())}))};var __generator=this&&this.__generator||function(o,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,r,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(o){return function(e){return l([o,e])}}function l(a){if(n)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(t=0)),t)try{if(n=1,r&&(i=a[0]&2?r["return"]:a[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;if(r=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:t.label++;return{value:a[1],done:false};case 5:t.label++;r=a[1];a=[0];continue;case 7:a=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1];i=a;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(a);break}if(i[2])t.ops.pop();t.trys.pop();continue}a=e.call(o,t)}catch(o){a=[6,o];r=0}finally{n=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{r as registerInstance,h,H as Host}from"./index-d82f06f2.js";import{_ as _root,e as _baseGetTag,i as isObjectLike_1,f as isObject_1,z as zonosStore,g as getZonosStoreTheme,m as mergeConfig}from"./zonosStore-d3c5a0a5.js";import{l as localizationStore,G as isValidSelector,r as translate,u as getZCountryUrlParam,I as setZCountryUrlParam,J as currencyDisplay,K as currencyConvertAndFormat,L as currencyConvert,E as currencyFormat}from"./cart-dc171e7f.js";import{c as classes}from"./classes-0d95c529.js";import{h as handleFetch,b as logError,l as log}from"./handleFetch-621e45bc.js";import{g as getHasMoreSpaceOnRight}from"./getHasMoreSpaceOnRight-70eb913a.js";import"./isDarkColor-446fccb7.js";import"./getBorderRadius-ada3ccad.js";var root=_root;var now$1=function(){return root.Date.now()};var now_1=now$1;var reWhitespace=/\s/;function trimmedEndIndex$1(o){var e=o.length;while(e--&&reWhitespace.test(o.charAt(e))){}return e}var _trimmedEndIndex=trimmedEndIndex$1;var trimmedEndIndex=_trimmedEndIndex;var reTrimStart=/^\s+/;function baseTrim$1(o){return o?o.slice(0,trimmedEndIndex(o)+1).replace(reTrimStart,""):o}var _baseTrim=baseTrim$1;var baseGetTag=_baseGetTag,isObjectLike=isObjectLike_1;var symbolTag="[object Symbol]";function isSymbol$1(o){return typeof o=="symbol"||isObjectLike(o)&&baseGetTag(o)==symbolTag}var isSymbol_1=isSymbol$1;var baseTrim=_baseTrim,isObject$1=isObject_1,isSymbol=isSymbol_1;var NAN=0/0;var reIsBadHex=/^[-+]0x[0-9a-f]+$/i;var reIsBinary=/^0b[01]+$/i;var reIsOctal=/^0o[0-7]+$/i;var freeParseInt=parseInt;function toNumber$1(o){if(typeof o=="number"){return o}if(isSymbol(o)){return NAN}if(isObject$1(o)){var e=typeof o.valueOf=="function"?o.valueOf():o;o=isObject$1(e)?e+"":e}if(typeof o!="string"){return o===0?o:+o}o=baseTrim(o);var t=reIsBinary.test(o);return t||reIsOctal.test(o)?freeParseInt(o.slice(2),t?2:8):reIsBadHex.test(o)?NAN:+o}var toNumber_1=toNumber$1;var isObject=isObject_1,now=now_1,toNumber=toNumber_1;var FUNC_ERROR_TEXT="Expected a function";var nativeMax=Math.max,nativeMin=Math.min;function debounce(o,e,t){var n,r,i,s,a,l,h=0,d=false,c=false,u=true;if(typeof o!="function"){throw new TypeError(FUNC_ERROR_TEXT)}e=toNumber(e)||0;if(isObject(t)){d=!!t.leading;c="maxWait"in t;i=c?nativeMax(toNumber(t.maxWait)||0,e):i;u="trailing"in t?!!t.trailing:u}function f(e){var t=n,i=r;n=r=undefined;h=e;s=o.apply(i,t);return s}function m(o){h=o;a=setTimeout(w,e);return d?f(o):s}function g(o){var t=o-l,n=o-h,r=e-t;return c?nativeMin(r,i-n):r}function v(o){var t=o-l,n=o-h;return l===undefined||t>=e||t<0||c&&n>=i}function w(){var o=now();if(v(o)){return z(o)}a=setTimeout(w,g(o))}function z(o){a=undefined;if(u&&n){return f(o)}n=r=undefined;return s}function p(){if(a!==undefined){clearTimeout(a)}h=0;n=l=r=a=undefined}function b(){return a===undefined?s:z(now())}function x(){var o=now(),t=v(o);n=arguments;r=this;l=o;if(t){if(a===undefined){return m(l)}if(c){clearTimeout(a);a=setTimeout(w,e);return f(l)}}if(a===undefined){a=setTimeout(w,e)}return s}x.cancel=p;x.flush=b;return x}var debounce_1=debounce;var checkItemRestrictions=function(o){return __awaiter(void 0,[o],void 0,(function(o){var e,t,n,r,i;var s=o.items,a=o.shipFrom,l=o.shipTo;return __generator(this,(function(o){switch(o.label){case 0:t={items:s,shipFrom:a,shipTo:l};return[4,handleFetch("/api/zonos-elements/check-item-restrictions",{body:t,method:"POST"})];case 1:n=o.sent(),r=n.errors,i=n.json;if(r.length||!i){logError("Error fetching item restrictions: ".concat((e=r.find(Boolean))===null||e===void 0?void 0:e.message));return[2,[]]}return[2,i.filter(Boolean)]}}))}))};var detectItemRestrictions=function(o){return __awaiter(void 0,void 0,void 0,(function(){var e,t,n,r;return __generator(this,(function(i){switch(i.label){case 0:if(!o.length){return[2,[]]}e=localizationStore.selectedCountryCode;if(!e){logError("Hello could not check item restrictions - No country code selected");return[2,[]]}t=o.map((function(o){return{description:o.description,name:o.title}}));return[4,checkItemRestrictions({items:t,shipFrom:"AD",shipTo:e})];case 1:n=i.sent();r=n.map((function(o){var e;var n=((e=t.filter((function(e){return e.description===o.itemDescription})).find(Boolean))===null||e===void 0?void 0:e.name)||"";return Object.assign(Object.assign({},o),{name:n})}));return[2,r]}}))}))};var matchUrlPattern=function(o){var e=o===null||o===void 0?void 0:o.replace("www.","").replace("https://","");return e&&new RegExp(e).test(window.location.href)};var getCurrentHelloLocalePage=function(){var o=zonosStore.helloSettings,e=o.cartUrlPattern,t=o.homepageUrlPattern,n=o.productDetailUrlPattern,r=o.productListUrlPattern;if(matchUrlPattern(e)){return"cart"}if(matchUrlPattern(n)){return"productDetail"}if(matchUrlPattern(r)){return"productList"}if(matchUrlPattern(t)){return"home"}return""};var getProductsOnPage=function(){var o,e;var t=zonosStore.helloSettings,n=t.productAddToCartElementSelector,r=t.productDescriptionElementSelector,i=t.productTitleElementSelector,s=t.restrictionBehavior;if(!i||!r){log("Hello could not check item restrictions - must provide title and description selectors.")}var a=i&&isValidSelector(i)&&document.querySelectorAll(i)||[];var l=r&&isValidSelector(r)&&document.querySelectorAll(r)||[];if(a.length!==l.length){log("Hello could not check item restrictions - Title and description selectors do not match");return[]}var h=s==="RESTRICT_AND_BLOCK";var d=h&&n&&isValidSelector(n)&&document.querySelectorAll(n)||[];if(h&&d.length!==l.length){log('Hello could not disable "Add to cart" buttons - Title and add to cart selectors do not match')}var c=[];for(var u=0;u<a.length;u++){var f=a[u];var m=l[u];var g=d[u];if(f&&m){var v={cartButtonNode:g||null,description:((o=m.textContent)===null||o===void 0?void 0:o.trim())||"",title:((e=f.textContent)===null||e===void 0?void 0:e.trim())||""};c.push(v)}}return c};var zonosHelloCss=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host{display:inline-block}:host .zonos--hello-wrapper{position:relative}:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper-mobile-override{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}@media (max-width: 768px){:host .zonos--hello-wrapper .zonos--hello-dialog-wrapper{position:fixed;bottom:0;left:0;width:100vw;z-index:1001;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content}}:host .zonos--hello-widget{-webkit-transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);padding:6px;border-radius:30px;background:var(--zonos-elements-page-background);font-size:var(--zonos-elements-font-size-s);border:var(--zonos-elements-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;cursor:pointer;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;position:relative;z-index:1000}:host .zonos--hello-widget>.zonos--hello-message{-ms-flex-order:0;order:0;max-width:0;height:100%;white-space:nowrap;-webkit-transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);transition:border 0.3s ease-in, all 0.7s cubic-bezier(0.31, -0.02, 0.06, 1.53);overflow:hidden;color:var(--zonos-elements-text-color);position:absolute;background:var(--zonos-elements-page-background);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-top-left-radius:30px;border-bottom-left-radius:30px;left:0;-webkit-transform:translateX(calc(-100% + 16px));transform:translateX(calc(-100% + 16px));width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border-top:var(--zonos-elements-border);border-bottom:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-has-restrictions{background:var(--zonos-elements-red-100);border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-has-restrictions>.zonos--hello-message{background:var(--zonos-elements-red-100);color:var(--zonos-elements-red-800);font-weight:500}:host .zonos--hello-widget.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:1px solid var(--zonos-elements-red-200)}:host .zonos--hello-widget.zonos--hello-show-peek-message{max-width:100vw;width:100%}:host .zonos--hello-widget.zonos--hello-show-peek-message>.zonos--hello-message{max-width:100vw;padding:0 6px;padding-right:16px;border:var(--zonos-elements-border)}:host .zonos--hello-widget.zonos--hello-show-peek-message:not(.zonos--hello-widget-animate-from-left)>.zonos--hello-message{border-right:none}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{border-left:0}:host .zonos--hello-widget.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:16px;padding-right:6px;border-left:none}:host .zonos--hello-widget.zonos--hello-widget-animate-from-left>.zonos--hello-message{-ms-flex-order:1;order:1;-webkit-transform:translateX(calc(100% - 16px));transform:translateX(calc(100% - 16px));right:0;left:auto;border-top-right-radius:30px;border-bottom-right-radius:30px}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}:host .zonos--hello-widget .zonos--hello-country-flag-wrapper .zonos--hello-country-flag{height:18px;width:18px;position:relative;overflow:hidden;border-radius:30px;-webkit-box-shadow:var(--zonos-elements-v3-shadow-medium);box-shadow:var(--zonos-elements-v3-shadow-medium);z-index:10;justify-self:center}:host .zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float{position:fixed;bottom:72px;right:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-left{left:32px;right:auto}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-top{bottom:auto;top:32px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-has-restrictions.zonos--hello-show-peek-message>.zonos--hello-message{border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float>.zonos--hello-message{position:relative;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;border-radius:30px;height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;top:0;bottom:0;left:0;-webkit-transform:translateX(0);transform:translateX(0);width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;border:none}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-widget-animate-from-left>.zonos--hello-message{-webkit-transform:translateX(0);transform:translateX(0)}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message.zonos--hello-widget-animate-from-left>.zonos--hello-message{padding-left:8px;padding-right:4px}:host .zonos--hello-mobile-override.zonos--hello-widget.zonos--hello-widget-float.zonos--hello-show-peek-message>.zonos--hello-message{padding:0 var(--zonos-elements-radius-4);padding-right:6px;border:none}";var ZonosHelloStyle0=zonosHelloCss;var PEEK_MESSAGE_CLOSE_DELAY_MS=3e3;var ZonosHello=function(){function o(o){var e=this;registerInstance(this,o);this.getHelloPeekMessage=function(o){var t=zonosStore.currentHelloPage==="productDetail"||zonosStore.currentHelloPage==="productList";if(t&&e.allRestrictedItems.length){var n=translate("click to learn more");var r=zonosStore.currentHelloPage==="productDetail"?translate("Restricted item"):translate("Restricted items found");return"".concat(r," - ").concat(n)}switch(zonosStore.currentHelloPage){case"cart":return translate("Prepay duties and taxes at checkout");case"productList":case"productDetail":return translate("See duty and tax thresholds");default:return translate("Welcome to [storeName]",{storeName:o})}};this.enableShowPeekMessage=function(){if(e.peekMessage){e.showPeekMessage=true}};this.getNewItemRestrictions=function(o){return __awaiter(e,void 0,void 0,(function(){var e,t;return __generator(this,(function(n){switch(n.label){case 0:e=zonosStore.currentHelloPage==="productDetail"||zonosStore.currentHelloPage==="productList";if(!e||zonosStore.helloSettings.restrictionBehavior==="DISABLED"){return[2,[]]}return[4,detectItemRestrictions(o)];case 1:t=n.sent();return[2,t]}}))}))};this.triggerShowPeekMessage=function(){e.peekMessage=e.getHelloPeekMessage(zonosStore.organizationName);var o=zonosStore.helloSettings,t=o.peekMessageBehavior,n=o.peekMessageDelay;var r=n*1e3;if(t==="ENABLED"){setTimeout((function(){e.enableShowPeekMessage();var o=e.allRestrictedItems.some((function(o){return e.productsOnPage.some((function(e){return e.description===o.itemDescription}))}));if(!o){setTimeout((function(){e.showPeekMessage=false}),PEEK_MESSAGE_CLOSE_DELAY_MS)}}),r)}};this.disableAddToCartButtons=function(){if(e.productsOnPage.length){e.productsOnPage.forEach((function(o){var t,n;var r=e.allRestrictedItems.some((function(e){return e.itemDescription===o.description}));if(r){(t=o.cartButtonNode)===null||t===void 0?void 0:t.setAttribute("disabled","disabled")}else{(n=o.cartButtonNode)===null||n===void 0?void 0:n.removeAttribute("disabled")}}))}};this.handleItemRestrictions=function(){return __awaiter(e,void 0,void 0,(function(){var o,e;var t,n;var r=this;return __generator(this,(function(i){switch(i.label){case 0:this.productsOnPage=getProductsOnPage();o=this.productsOnPage.filter((function(o){return!r.allFoundProducts.some((function(e){return e.title===o.title}))}));return[4,this.getNewItemRestrictions(o)];case 1:e=i.sent();(t=this.allRestrictedItems).push.apply(t,e);(n=this.allFoundProducts).push.apply(n,o);this.disableAddToCartButtons();return[2]}}))}))};this.reloadHelloData=function(){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(o){switch(o.label){case 0:return[4,this.handleItemRestrictions()];case 1:o.sent();this.triggerShowPeekMessage();return[2]}}))}))};this.handleProductCountChange=debounce_1((function(){var o=zonosStore.helloSettings.productTitleElementSelector;if(o){var t=getProductsOnPage();if(e.allFoundProducts.length!==t.length&&window.location.href===e.initialUrl){if(!e.allFoundProducts.length){return}void e.reloadHelloData()}}}),1e3);this.watchProductCountChange=function(){var o=new MutationObserver(e.handleProductCountChange);o.observe(document.body,{childList:true,subtree:true})};this.watchPriceChange=function(){var o=new MutationObserver((function(){return void e.displayCurrency()}));o.observe(document.body,{attributes:true,childList:true,subtree:true})};this.updateHelloOnPageChange=function(){e.watchProductCountChange();setInterval((function(){if(window.location.href!==e.initialUrl){var o=e.initialUrl&&new URL(e.initialUrl);var t=o&&getZCountryUrlParam(o.searchParams);if(t!==localizationStore.selectedCountryCode){e.allFoundProducts=[];e.allRestrictedItems=[];e.productsOnPage=[]}e.initialUrl=window.location.href;zonosStore.currentHelloPage=getCurrentHelloLocalePage();var n=new URL(window.location.href);var r=getZCountryUrlParam(n.searchParams);if(!r){setZCountryUrlParam(localizationStore.selectedCountryCode);return}void e.reloadHelloData()}}),1e3)};this.changeShowDialog=function(o){e.showDialog=o};this.shouldAnimateLeftDesktop=function(){var o=e.helloRef&&getComputedStyle(e.helloRef).position;if(e.helloRef&&o==="relative"){var t=getHasMoreSpaceOnRight(e.helloRef);return t}};this.shouldRenderHello=function(o){if(o===void 0){o=true}if(!localizationStore.localizationLoaded){return false}var e=zonosStore.helloSettings.showForCountries;if(o){if(!localizationStore.isShippableCountry){log("Hello: not shippable country - Show for countries: ".concat(e))}}if(e==="ONLY_SHIPPABLE"){return localizationStore.isShippableCountry}if(e==="ALL"){return true}return e===null||e===void 0?void 0:e.includes(localizationStore.selectedCountryCode||"")};this.mobileLocationOverride=undefined;this.animateFromLeftOverride=undefined;this.appearanceSettingsOverride=undefined;this.showPeekMessage=false;this.zonosStoreHelloSettings=zonosStore.helloSettings;this.showDialog=false;this.peekMessage="";this.initialUrl="";this.allRestrictedItems=[];this.allFoundProducts=[];this.productsOnPage=[];this.isHelloWidgetRendered=false;this.isMobile=false}o.prototype.getCountryList=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){return[2,localizationStore.helloCountryList]}))}))};o.prototype.componentWillLoad=function(){var o=this;var e=setInterval((function(){return __awaiter(o,void 0,void 0,(function(){return __generator(this,(function(o){if(!this.helloRef){return[2]}if(zonosStore.loadedConfig){this.helloRef.setAttribute("data-zonos-hello-loaded","");this.updateHelloOnPageChange();this.watchPriceChange();this.handleAppearanceSettingsOverrideChange();clearInterval(e)}return[2]}))}))}),100)};o.prototype.displayCurrency=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(o){if(zonosStore.helloSettings.currencyBehavior==="DISABLED"){return[2]}if(!localizationStore.exchangeRate){log("Could not display currency. Exchange rate and format data is not available.","warn");return[2]}currencyDisplay();return[2]}))}))};o.prototype.convertAndFormat=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,currencyConvertAndFormat(o)]}))}))};o.prototype.convert=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,currencyConvert(o)]}))}))};o.prototype.format=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,currencyFormat({amount:o})]}))}))};o.prototype.openHelloDialog=function(o){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.changeShowDialog(o);return[2]}))}))};o.prototype.handleResize=function(){this.isMobile=window.innerWidth<=768};o.prototype.handleHelloWidgetInitializedState=function(o){var e=o.countryCode,t=o.currencyCode;var n,r;if(this.isHelloWidgetRendered){return}if(localizationStore.selectedCountryCode&&typeof zonosStore.helloSettings.onInitSuccess==="function"){this.isHelloWidgetRendered=true;void((r=(n=zonosStore.helloSettings).onInitSuccess)===null||r===void 0?void 0:r.call(n,{countryCode:e,currencyCode:t}))}};o.prototype.getHelloLocation=function(){var o=this.mobileLocationOverride||zonosStore.helloSettings.mobileLocation;var e=zonosStore.helloSettings.desktopLocation;var t=this.isMobile;switch(true){case t:{var n=this.animateFromLeftOverride||(o===null||o===void 0?void 0:o.includes("LEFT"));var r=o===null||o===void 0?void 0:o.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:r,shouldFloat:!!o}}default:case!t:{var i=!zonosStore.helloSettings.anchorElementSelector&&!!e;var n=this.animateFromLeftOverride||(e===null||e===void 0?void 0:e.includes("LEFT"))||this.shouldAnimateLeftDesktop();var r=e===null||e===void 0?void 0:e.includes("TOP");return{isMobileWindow:t,isOnLeft:n,isOnTop:r,shouldFloat:i}}}};o.prototype.handleAppearanceSettingsOverrideChange=function(){var o;if((o=this.appearanceSettingsOverride)===null||o===void 0?void 0:o.theme){this.appearanceSettingsOverride.theme=getZonosStoreTheme(this.appearanceSettingsOverride.theme)}};o.prototype.componentDidLoad=function(){this.isMobile=window.innerWidth<=768};o.prototype.render=function(){var o=this;var e,t;var n=(e=zonosStore.helloSettings.excludedUrlPatterns)===null||e===void 0?void 0:e.some((function(o){return o&&new RegExp(o).test(window.location.href)}));if(n){log("Hello is excluded on this url","warn");return null}var r=localizationStore.selectedCountryCode,i=localizationStore.targetCurrency;var s=this.getHelloLocation(),a=s.isOnLeft,l=s.isOnTop,d=s.shouldFloat;var c=mergeConfig(zonosStore.appearance,this.appearanceSettingsOverride||null);var u=c.theme;var f=(t=this.allRestrictedItems)===null||t===void 0?void 0:t.filter((function(e){return o.productsOnPage.some((function(o){return o.description===e.itemDescription}))}));this.peekMessage=this.getHelloPeekMessage(zonosStore.organizationName);var m=this.shouldRenderHello()&&!!r;if(m&&!this.isHelloWidgetRendered){this.handleHelloWidgetInitializedState({countryCode:r,currencyCode:i})}return h(Host,{class:"zonos--hello zonos--elements","data-theme":u},m&&h("div",{class:classes(["zonos--hello-wrapper",d&&"zonos--hello-widget-float"])},h("button",{class:classes(["zonos--hello-widget",this.showPeekMessage&&"zonos--hello-show-peek-message",this.mobileLocationOverride&&"zonos--hello-mobile-override",a&&"zonos--hello-widget-left zonos--hello-widget-animate-from-left",l&&"zonos--hello-widget-top",!!this.allRestrictedItems.length&&"zonos--hello-has-restrictions",d&&"zonos--hello-widget-float"]),onClick:function(){void o.changeShowDialog(!o.showDialog)},onMouseEnter:function(){return o.enableShowPeekMessage()},onMouseLeave:function(){return o.showPeekMessage=false},ref:function(e){return e&&(o.helloRef=e)}},h("zonos-text",{class:"zonos--hello-message"},this.peekMessage),r&&h("div",{class:"zonos--hello-country-flag-wrapper"},h("zonos-country-flag",{class:"zonos--hello-country-flag",countryCode:r}))),h("div",{class:classes(["zonos--hello-dialog-wrapper",this.mobileLocationOverride&&"zonos--hello-dialog-wrapper-mobile-override",d&&"zonos--hello-widget-float"]),style:{height:this.showDialog?"fit-content":"0px"}},h("zonos-hello-dialog",{animateFromLeftOverride:this.animateFromLeftOverride,appearanceSettings:c,isOpen:this.showDialog,mobileLocationOverride:this.mobileLocationOverride,restrictedItems:f,setIsOpen:this.changeShowDialog}))))};Object.defineProperty(o,"watchers",{get:function(){return{appearanceSettingsOverride:["handleAppearanceSettingsOverrideChange"]}},enumerable:false,configurable:true});return o}();ZonosHello.style=ZonosHelloStyle0;export{ZonosHello as zonos_hello};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as registerInstance,h,H as Host}from"./index-d82f06f2.js";import{W as localizationStoreUpdateSelectedLocale,r as translate,l as localizationStore}from"./cart-
|
|
1
|
+
import{r as registerInstance,h,H as Host}from"./index-d82f06f2.js";import{W as localizationStoreUpdateSelectedLocale,r as translate,l as localizationStore}from"./cart-dc171e7f.js";import{d as zonosStoreFontFamily}from"./zonosStore-d3c5a0a5.js";import{l as languages}from"./ILanguage-cd6acb72.js";import"./handleFetch-621e45bc.js";import"./isDarkColor-446fccb7.js";import"./getBorderRadius-ada3ccad.js";var GreenCheckDuotoneIcon='<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M7.99996 2.6665C5.05444 2.6665 2.66663 5.05432 2.66663 7.99984C2.66663 10.9454 5.05444 13.3332 7.99996 13.3332C10.9455 13.3332 13.3333 10.9454 13.3333 7.99984C13.3333 5.05432 10.9455 2.6665 7.99996 2.6665Z" fill="#AFF8C3"/>\n<path fill-rule="evenodd" clip-rule="evenodd" d="M10.1403 6.10535C10.3582 6.27488 10.3975 6.58902 10.228 6.80699L8.01055 9.65797C7.76436 9.97449 7.29646 10.0036 7.01291 9.72008L5.81307 8.52024C5.61781 8.32498 5.61781 8.0084 5.81307 7.81314C6.00833 7.61787 6.32492 7.61787 6.52018 7.81314L7.45301 8.74597L9.43862 6.19305C9.60815 5.97508 9.92229 5.93581 10.1403 6.10535Z" fill="#246627"/>\n</svg>\n';var zonosLanguageSelectCss=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--language-select{width:100%}:host .zonos--language-select .zonos--language-select-content{display:grid;grid-template-columns:repeat(3, minmax(-webkit-max-content, 1fr));grid-template-columns:repeat(3, minmax(max-content, 1fr));padding:16px;padding-top:0px}:host .zonos--language-select .zonos--language-select-content .zonos--language-select-button{display:-ms-flexbox;display:flex;padding:8px;gap:4px;-ms-flex-align:center;align-items:center;border-radius:var(--zonos-elements-radius-4);cursor:pointer;width:100%;border:none;background:none}:host .zonos--language-select .zonos--language-select-content .zonos--language-select-button:hover{background:var(--zonos-elements-gray-100)}@media (max-width: 400px){:host .zonos--language-select .zonos--language-select-content{grid-template-columns:1fr 1fr}}";var ZonosLanguageSelectStyle0=zonosLanguageSelectCss;var ZonosLanguageSelect=function(){function e(e){var o=this;registerInstance(this,e);this.languageSelected=function(e){void localizationStoreUpdateSelectedLocale(e);o.handleOnClose()};this.handleOnClose=function(){}}e.prototype.render=function(){var e=this;var o=localizationStore.selectedLocale;return h(Host,{key:"cc711dba7371852eab6e20994389ae3b95bb3be7",class:"zonos--elements",style:{"--zonos--font-family":zonosStoreFontFamily()}},h("div",{key:"47135e2b7363a3179139a7b8e23cb22435ce3299",class:"zonos--language-select"},h("zonos-select-dialog-header",{key:"3bf830e585fa6478f560c57dfa978721af47ad19",handleOnClose:function(){return e.handleOnClose()},label:translate("Select a language")}),h("div",{key:"f693b231755087ec849f5a759b2dc43e2695b24f",class:"zonos--language-select-content"},languages.map((function(t){return h("button",{class:"zonos--language-select-button",onClick:function(){return e.languageSelected(t.code)}},h("zonos-text",{textColor:"gray-800"},t.translatedLabel),t.code===o&&h("zonos-icon",{content:GreenCheckDuotoneIcon,size:16}))})))))};return e}();ZonosLanguageSelect.style=ZonosLanguageSelectStyle0;var RemoveIcon='<svg xmlns="https://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"><path fill="#C5C6CA" fill-rule="evenodd" d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Z" clip-rule="evenodd"/><path fill="#4D505A" fill-rule="evenodd" d="M8.293 8.293a1 1 0 0 1 1.414 0L12 10.586l2.293-2.293a1 1 0 1 1 1.414 1.414L13.414 12l2.293 2.293a1 1 0 0 1-1.414 1.414L12 13.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L10.586 12 8.293 9.707a1 1 0 0 1 0-1.414Z" clip-rule="evenodd"/></svg>';var zonosSelectDialogHeaderCss=":host{font-family:var(--zonos--font-family, Inter), Inter;display:block;white-space:normal}:host *{font-family:var(--zonos--font-family, Inter), Inter}:host img{max-width:100%}:host dl,:host dd,:host h1,:host h2,:host h3,:host h4,:host h5,:host h6,:host hr,:host figure,:host p,:host pre{margin:0}:host{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}:host .zonos--select-dialog-header-wrapper{position:-webkit-sticky;position:sticky;top:0;background:var(--zonos-elements-surface-color);padding:16px}:host .zonos--select-dialog-header-wrapper .zonos--select-dialog-header{position:relative;-ms-flex-pack:justify;justify-content:space-between;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}";var ZonosSelectDialogHeaderStyle0=zonosSelectDialogHeaderCss;var ZonosSelectDialogHeader=function(){function e(e){registerInstance(this,e);this.handleOnClose=function(){};this.label=""}e.prototype.render=function(){var e=this;return h(Host,{key:"15035421483b079dde47eeb3ddcb4dcc6edffae4",class:"zonos--elements",style:{"--zonos--font-family":zonosStoreFontFamily()}},h("zonos-v-stack",{key:"bf1bbdb1bb8a62841616893d8e9005002772adc4",class:"zonos--select-dialog-header-wrapper",spacing:8},h("div",{key:"a2593795816ceb851489c386231a1b90e6dd6261",class:"zonos--select-dialog-header"},h("zonos-text",{key:"e91d4a54ac0deb073c30272c5e9626168fea52b7",type:"boldLabel"},this.label),h("zonos-button",{key:"e8fdf75686b33e9958f64925ddf95fb5c89d74bb",class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close select dialog",content:RemoveIcon,size:20}),noBackground:true,onClick:function(){return e.handleOnClose()}})),h("slot",{key:"ede6d09a4f6900419bf16df0ca8a2b79882bf266"})))};return e}();ZonosSelectDialogHeader.style=ZonosSelectDialogHeaderStyle0;export{ZonosLanguageSelect as zonos_language_select,ZonosSelectDialogHeader as zonos_select_dialog_header};
|
package/dist/scripts/index.d.ts
CHANGED
|
@@ -87,6 +87,11 @@ declare const adjustmentSource: {
|
|
|
87
87
|
readonly PromoCode: "PROMO_CODE";
|
|
88
88
|
};
|
|
89
89
|
type AdjustmentSource = (typeof adjustmentSource)[keyof typeof adjustmentSource];
|
|
90
|
+
declare const allowedCharacterSets: {
|
|
91
|
+
readonly All: "ALL";
|
|
92
|
+
readonly Latin: "LATIN";
|
|
93
|
+
};
|
|
94
|
+
type AllowedCharacterSets = (typeof allowedCharacterSets)[keyof typeof allowedCharacterSets];
|
|
90
95
|
declare const allowedSettlementCurrencies: {
|
|
91
96
|
readonly Local: "LOCAL";
|
|
92
97
|
readonly LocalAndUsd: "LOCAL_AND_USD";
|
|
@@ -600,6 +605,11 @@ declare const helloCurrencyBehavior: {
|
|
|
600
605
|
readonly Enabled: "ENABLED";
|
|
601
606
|
};
|
|
602
607
|
type HelloCurrencyBehavior = (typeof helloCurrencyBehavior)[keyof typeof helloCurrencyBehavior];
|
|
608
|
+
declare const helloEstimateBehavior: {
|
|
609
|
+
readonly Disabled: "DISABLED";
|
|
610
|
+
readonly Enabled: "ENABLED";
|
|
611
|
+
};
|
|
612
|
+
type HelloEstimateBehavior = (typeof helloEstimateBehavior)[keyof typeof helloEstimateBehavior];
|
|
603
613
|
declare const helloMobileLocation: {
|
|
604
614
|
readonly BottomLeft: "BOTTOM_LEFT";
|
|
605
615
|
readonly BottomRight: "BOTTOM_RIGHT";
|
|
@@ -889,6 +899,157 @@ type CheckItemRestrictionsMutation = {
|
|
|
889
899
|
} | null>;
|
|
890
900
|
};
|
|
891
901
|
};
|
|
902
|
+
type CartCheckoutWorkflowQuery = {
|
|
903
|
+
cartCheckoutWorkflow: {
|
|
904
|
+
appearanceSettings: {
|
|
905
|
+
colorPrimary: string;
|
|
906
|
+
colorSecondary: string;
|
|
907
|
+
createdAt: string;
|
|
908
|
+
createdBy: string;
|
|
909
|
+
fontFamily: string;
|
|
910
|
+
id: string;
|
|
911
|
+
logoUrl: string;
|
|
912
|
+
mode: Mode;
|
|
913
|
+
organization: string;
|
|
914
|
+
style: ElementsUiStyle;
|
|
915
|
+
theme: ElementsUiTheme;
|
|
916
|
+
updatedAt: string;
|
|
917
|
+
updatedBy: string;
|
|
918
|
+
zonosAttribution: ZonosAttribution | null;
|
|
919
|
+
};
|
|
920
|
+
cart: {
|
|
921
|
+
adjustments: Array<{
|
|
922
|
+
amount: number;
|
|
923
|
+
currencyCode: CurrencyCode;
|
|
924
|
+
description: string | null;
|
|
925
|
+
productId: string | null;
|
|
926
|
+
sku: string | null;
|
|
927
|
+
type: CartAdjustmentType;
|
|
928
|
+
}>;
|
|
929
|
+
createdAt: string;
|
|
930
|
+
id: string;
|
|
931
|
+
items: Array<{
|
|
932
|
+
amount: number;
|
|
933
|
+
attributes: Array<{
|
|
934
|
+
key: string | null;
|
|
935
|
+
value: string | null;
|
|
936
|
+
} | null> | null;
|
|
937
|
+
countryOfOrigin: CountryCode | null;
|
|
938
|
+
currencyCode: CurrencyCode;
|
|
939
|
+
description: string | null;
|
|
940
|
+
id: string;
|
|
941
|
+
imageUrl: string | null;
|
|
942
|
+
itemType: ItemType | null;
|
|
943
|
+
measurements: Array<{
|
|
944
|
+
type: ItemMeasurementType;
|
|
945
|
+
unitOfMeasure: ItemUnitOfMeasure;
|
|
946
|
+
value: number;
|
|
947
|
+
} | null> | null;
|
|
948
|
+
name: string | null;
|
|
949
|
+
productId: string;
|
|
950
|
+
quantity: number;
|
|
951
|
+
sku: string | null;
|
|
952
|
+
}>;
|
|
953
|
+
metadata: Array<{
|
|
954
|
+
key: string;
|
|
955
|
+
value: string;
|
|
956
|
+
}>;
|
|
957
|
+
organization: {
|
|
958
|
+
id: string;
|
|
959
|
+
name: string;
|
|
960
|
+
references: {
|
|
961
|
+
storeId: number | null;
|
|
962
|
+
} | null;
|
|
963
|
+
} | null;
|
|
964
|
+
};
|
|
965
|
+
checkoutSettings: {
|
|
966
|
+
allowedCharacterSets: AllowedCharacterSets;
|
|
967
|
+
allowedSettlementCurrencies: AllowedSettlementCurrencies;
|
|
968
|
+
successRedirectUrl: string;
|
|
969
|
+
captureDelay: number;
|
|
970
|
+
createdAt: string;
|
|
971
|
+
createdBy: string;
|
|
972
|
+
customHTML: string;
|
|
973
|
+
defaultCartExpiration: number;
|
|
974
|
+
disabledCountries: Array<CountryCode> | null;
|
|
975
|
+
externalPaymentMethods: Array<{
|
|
976
|
+
status: ExternalPaymentMethodStatus;
|
|
977
|
+
type: ExternalPaymentMethodType;
|
|
978
|
+
}> | null;
|
|
979
|
+
externalServiceTokens: Array<{
|
|
980
|
+
token: string;
|
|
981
|
+
type: ExternalServiceTokenType;
|
|
982
|
+
}>;
|
|
983
|
+
id: string;
|
|
984
|
+
mode: Mode;
|
|
985
|
+
orderNotifications: {
|
|
986
|
+
abandonedCart: {
|
|
987
|
+
delay: number;
|
|
988
|
+
discountPercent: number;
|
|
989
|
+
status: {
|
|
990
|
+
active: NotificationActiveStatus;
|
|
991
|
+
sendCopiesTo: Array<string>;
|
|
992
|
+
};
|
|
993
|
+
};
|
|
994
|
+
orderCancelled: {
|
|
995
|
+
active: NotificationActiveStatus;
|
|
996
|
+
sendCopiesTo: Array<string>;
|
|
997
|
+
};
|
|
998
|
+
orderShipped: {
|
|
999
|
+
active: NotificationActiveStatus;
|
|
1000
|
+
sendCopiesTo: Array<string>;
|
|
1001
|
+
};
|
|
1002
|
+
};
|
|
1003
|
+
organization: string;
|
|
1004
|
+
placeOrderButtonSelector: string | null;
|
|
1005
|
+
subscriptionStatus: CheckoutSubscriptionStatus;
|
|
1006
|
+
successBehavior: CheckoutSuccessBehavior;
|
|
1007
|
+
analyticsProviders: Array<{
|
|
1008
|
+
status: AnalyticsProviderStatus;
|
|
1009
|
+
type: AnalyticsProviderType;
|
|
1010
|
+
}>;
|
|
1011
|
+
updatedAt: string;
|
|
1012
|
+
updatedBy: string;
|
|
1013
|
+
visibilityStatus: CheckoutVisibilityStatus;
|
|
1014
|
+
};
|
|
1015
|
+
credentialTokenId: string;
|
|
1016
|
+
helloSettings: {
|
|
1017
|
+
allowedDomains: Array<string>;
|
|
1018
|
+
anchorElementSelector: string;
|
|
1019
|
+
cartUrlPattern: string | null;
|
|
1020
|
+
createdAt: string;
|
|
1021
|
+
createdBy: string;
|
|
1022
|
+
currencyBehavior: HelloCurrencyBehavior;
|
|
1023
|
+
currencyElementSelector: string;
|
|
1024
|
+
dutyTaxEstimationBehavior: HelloEstimateBehavior;
|
|
1025
|
+
excludedUrlPatterns: Array<string>;
|
|
1026
|
+
homepageUrlPattern: string | null;
|
|
1027
|
+
id: string;
|
|
1028
|
+
mobileLocation: HelloMobileLocation;
|
|
1029
|
+
mode: Mode;
|
|
1030
|
+
organization: string;
|
|
1031
|
+
peekMessageBehavior: HelloPeekMessageBehavior;
|
|
1032
|
+
peekMessageDelay: number;
|
|
1033
|
+
productAddToCartElementSelector: string | null;
|
|
1034
|
+
productDetailUrlPattern: string | null;
|
|
1035
|
+
productListUrlPattern: string | null;
|
|
1036
|
+
productDescriptionElementSelector: string | null;
|
|
1037
|
+
productPriceElementSelector: string | null;
|
|
1038
|
+
productTitleElementSelector: string | null;
|
|
1039
|
+
restrictionBehavior: HelloRestrictionBehavior;
|
|
1040
|
+
updatedAt: string;
|
|
1041
|
+
updatedBy: string;
|
|
1042
|
+
};
|
|
1043
|
+
onlineStoreSettings: {
|
|
1044
|
+
allowedDomains: Array<string>;
|
|
1045
|
+
url: string;
|
|
1046
|
+
};
|
|
1047
|
+
organizationId: string;
|
|
1048
|
+
shippingZones: Array<{
|
|
1049
|
+
countryCodes: Array<CountryCode> | null;
|
|
1050
|
+
} | null> | null;
|
|
1051
|
+
};
|
|
1052
|
+
};
|
|
892
1053
|
type CheckoutSessionDetailsFragment = {
|
|
893
1054
|
cartId: string | null;
|
|
894
1055
|
clientSecret: string;
|
|
@@ -4289,6 +4450,17 @@ type CalculateLandedCostRequest = {
|
|
|
4289
4450
|
};
|
|
4290
4451
|
};
|
|
4291
4452
|
|
|
4453
|
+
type GenericZonosSettings = {
|
|
4454
|
+
/**
|
|
4455
|
+
* Whether to enable company name input in the checkout.
|
|
4456
|
+
*/
|
|
4457
|
+
companyNameInputEnabled?: boolean;
|
|
4458
|
+
/**
|
|
4459
|
+
* List of countries that are allowed to use USD denominated cards for settlement.
|
|
4460
|
+
*/
|
|
4461
|
+
usdSettlementCountryEnabled?: CountryCode[];
|
|
4462
|
+
};
|
|
4463
|
+
|
|
4292
4464
|
type NormalizedItemAttribute = {
|
|
4293
4465
|
key: string;
|
|
4294
4466
|
value: string;
|
|
@@ -4333,6 +4505,23 @@ type NormalizedTempCart = {
|
|
|
4333
4505
|
storeBaseUrl: string;
|
|
4334
4506
|
storeId: number;
|
|
4335
4507
|
};
|
|
4508
|
+
type Settings = Omit<CartCheckoutWorkflowQuery['cartCheckoutWorkflow'], 'cart'> & {
|
|
4509
|
+
genericSettings: GenericZonosSettings | null;
|
|
4510
|
+
};
|
|
4511
|
+
type CartCheckoutResult = {
|
|
4512
|
+
cartData: NormalizedTempCart;
|
|
4513
|
+
settings: Settings & {
|
|
4514
|
+
organization: {
|
|
4515
|
+
id: string;
|
|
4516
|
+
name: string;
|
|
4517
|
+
references: {
|
|
4518
|
+
storeId: number | null;
|
|
4519
|
+
} | null;
|
|
4520
|
+
};
|
|
4521
|
+
};
|
|
4522
|
+
storeFaviconUrl: string;
|
|
4523
|
+
storeLogoUrl: string;
|
|
4524
|
+
};
|
|
4336
4525
|
|
|
4337
4526
|
type BuildLandedCostParams = {
|
|
4338
4527
|
billingAddress: CalculateLandedCostRequest['billingAddress'];
|
|
@@ -4808,6 +4997,10 @@ interface Zonos {
|
|
|
4808
4997
|
_paypalMockResponse: PaypalMockResponse | null;
|
|
4809
4998
|
cartData: NormalizedTempCart | null;
|
|
4810
4999
|
cartId: string | null;
|
|
5000
|
+
/**
|
|
5001
|
+
* Cart settings from `getCartCheckout`
|
|
5002
|
+
*/
|
|
5003
|
+
cartSettings: CartCheckoutResult['settings'] | null;
|
|
4811
5004
|
/**
|
|
4812
5005
|
* Toggle debug mode (add query param 'zonosDebug=1' to url)
|
|
4813
5006
|
* @default false
|
|
@@ -4845,6 +5038,10 @@ interface Zonos {
|
|
|
4845
5038
|
* Flag to send tracking event to api for conversion testing, since we don't send tracking event to api when in debug/development mode
|
|
4846
5039
|
*/
|
|
4847
5040
|
zonosConversionTest?: boolean;
|
|
5041
|
+
/**
|
|
5042
|
+
* Zonos mode
|
|
5043
|
+
*/
|
|
5044
|
+
zonosMode: 'production' | 'test' | null;
|
|
4848
5045
|
zonosQaUrl: string | null;
|
|
4849
5046
|
zonosQaUrlApi: string | null;
|
|
4850
5047
|
displayCurrency: () => void;
|
|
@@ -4861,6 +5058,7 @@ declare abstract class Zonos {
|
|
|
4861
5058
|
static stripe: Stripe;
|
|
4862
5059
|
static storeId: number;
|
|
4863
5060
|
static doneInit: boolean;
|
|
5061
|
+
static cartSettings: CartCheckoutResult['settings'] | null;
|
|
4864
5062
|
static debug: boolean;
|
|
4865
5063
|
static zonosConversionTest: boolean;
|
|
4866
5064
|
static _paypalMockResponse: PaypalMockResponse | null;
|
|
@@ -4879,6 +5077,7 @@ declare abstract class Zonos {
|
|
|
4879
5077
|
static modeAlerted: boolean;
|
|
4880
5078
|
static cartData: NormalizedTempCart | null;
|
|
4881
5079
|
static paypal: PayPalNamespace | null;
|
|
5080
|
+
static zonosMode: 'production' | 'test' | null;
|
|
4882
5081
|
static getCurrentTimestamp: () => number;
|
|
4883
5082
|
static cartId: string | null;
|
|
4884
5083
|
private static zonosController;
|
package/dist/scripts/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const e=performance.now(),o=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),l=[`(${a})`,...r];l.map(o).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(t,...l));let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>window.location.search.includes("zonosStagingMode=1"),l=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function c(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const d=["cloudflare","vercel"],u=d[0],p={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},m=p[u],w=(e=u)=>{const o=d.indexOf(e),t=d[o+1];return t||null},h=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},y=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},g=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],f=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=h(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},v=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||p[e]||u,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await f({response:n}),response:n,zonosMode:a}}const c=n.status.toString();try{const e=await f({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:c}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:c}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${c}: ${"Unknown error"}`,type:c}],json:null,response:null,zonosMode:a}}},b=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await v({basePathType:i,options:o,path:n}),{errors:d,response:u}=l,f=c(l,["errors","response"]),S=performance.now()-a;t(`${n} (${S.toFixed(2)}ms)`,"info");const z=null==u?void 0:u.headers.get("Zonos-Duration");200===(null==u?void 0:u.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(g.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=y(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(c=a,c||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var c;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:n,apiType:i,loadTimeInternal:z?Number(z):0,loadTimeTotal:S});const C=w(i),j=!!d.find((({type:e})=>"unknown"===e))||404===(null==u?void 0:u.status),Z=C&&j;return j&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),r){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${m}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=w();if(!o)return;fetch(`${p[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:p[i]+n,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:C,requestHeaders:null==o?void 0:o.headers,requestPayload:h(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==u?void 0:u.status,statusText:null==u?void 0:u.statusText},shouldPostReleaseErrorReporting:!0}),Z?(t(`=== "${n}" failed to fetch, trying next fallback ${C}`),b({basePathType:C,options:o,path:n})):Object.assign({errors:d,response:u},f)},S=async(e,o)=>{const t=c(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":a()?"1":void 0,"Zonos-Test-Mode":l()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return b({basePathType:d||u,options:i,path:e})},z=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),n="https://v1.3.174.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const r=`https://${o}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${r}' for loading elements script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),r},C="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Z="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let O=null;const k=e=>(null!==O||(O=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(Z),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${C}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&j.test(t.src))return t}return null})();r&&e?console.warn(Z):r||(r=(e=>{const o=document.createElement("script");o.src=`${C}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),O),A=Promise.resolve().then((()=>k(null)));let I=!1;A.catch((e=>{I||console.warn(e)}));const T=async({cartId:e,retries:o})=>{const n=l(),{errors:r,json:s}=await S("/api/zonos-elements/get-temp-cart",{body:{isTestMode:n,options:{noOnlineStoreSettings:!0},tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),i=!s||r.length;return i&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:o-1})):i?null:s},E=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,L=new RegExp(`^${E.source}$`),$=new RegExp(`^cart_${E.source}$`),N=/^[a-zA-Z0-9]{2,}$/,D=/^cart_[a-zA-Z0-9]{2,}$/,P=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:D.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:$.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:L.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await T({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,{cartData:s.cartData,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var U;const F=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),R="https://v1.3.174.js.zonos.com",x=F||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.174",M="https://fonts.googleapis.com",B=/^https:\/\/fonts\.googleapis\.com/;class q{}U=q,q.doneInit=!1,q.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),q.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),q._paypalMockResponse=null,q.isBigCommerce=!1,q.releaseDate="1742827853849",q.isLegacyCheckout=!1,q.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",q.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),q.isNpm=!0,q.zonosQaUrl=null,q.zonosQaUrlApi=null,q.version="v1.3.174",q.modeAlerted=!1,q.cartData=null,q.paypal=null,q.getCurrentTimestamp=()=>(new Date).getTime(),q.zonosController=null,q.loadTimeApiInfoList=[],q.logIntervalId=null,q.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:c,overrideCurrencyFormat:d,storeId:u,zonosApiKey:p}=e;if(U.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),U.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${U.version}) ======`),U.zonosApiKey=p,U.storeId=u,U.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=z();if(o&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=U.isNpm,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!U.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!U.cartData&&U.cartId){t("Initialize cart data");const e=await P(U.cartId);if(!e)return void n("Failed to get cart data");U.cartData=e.cartData,U.zonosApiKey=e.zonosApiKey}const r=await(async()=>{const e=l(),o=a();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await S("/api/get-test-public-credential");if(r.length||!s)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(t(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(U.zonosApiKey=r)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(U.cartId&&U.cartData||!!m){t("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),U.restoreNativeBrowserFunctions(),U.injectCustomScriptForHostedCheckout(),U.injectZonosCdn(),U.injectZonosCss(),U.injectFonts(),U.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:c,overrideCurrencyFormat:d}}),U.doneInit=!0},q.injectCustomScriptForHostedCheckout=()=>{const e=U.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),r=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||r)){if(n){t("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(r){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=r.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},q.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},q.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},q.showNotification=e=>{var o;null===(o=U.zonosController)||void 0===o||o.showNotification(e)},q.updateOrganizationName=e=>{var o;null===(o=U.zonosController)||void 0===o||o.updateOrganizationName(e)},q.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},q.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},q.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=U.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{I=!0;const o=Date.now();return A.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),U.zonosController=r,t("Zonos controller injected!")},q.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${U.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&U.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},q.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return x;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.174";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.174";case"vercel":return R}};if(U.isNpm){return z()||o()}return o()},q.injectZonosCdn=()=>{U.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),U.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},q.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=U.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${R}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&U.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},q.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(U.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},q.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${M}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!B.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=M,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${M}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),t("Zonos font injected!")},q.setupGoogleFont=e=>{var o;null===(o=U.zonosController)||void 0===o||o.setupGoogleFont(e)},q.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${M}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=M,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},exports.Zonos=q})();
|
|
1
|
+
(function(){"use strict";const e=performance.now(),o=e=>{if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(o){if(e&&"function"==typeof e.toString){return e.toString()}return"Unable to stringify info"}},t=(t,n,...r)=>{var s,i;const{elapsedTimePretty:a}=(()=>{const o=performance.now()-e,t=o>1e3?`${(o/1e3).toFixed(2)}s`:`${o.toFixed(2)}ms`;return{elapsedTime:o,elapsedTimePretty:t}})(),l=[`(${a})`,...r];l.map(o).join(" ");if(!(!!(null===(s=window.Zonos)||void 0===s?void 0:s.debug)||!!window.location.search.match(/\?.*(&*)zonosDebug=1/)))return void("error"===n&&console.error(t,...l));let c=document.querySelector("iframe#zonos---debug-logging-iframe");c||(c=document.createElement("iframe"),c.id="zonos---debug-logging-iframe",c.style.display="none",c.style.opacity="0",c.style.position="absolute",c.style.top="-9999px",c.style.left="-9999px",c.style.width="1px",c.style.height="1px",c.style.border="none",c.style.overflow="hidden",c.style.visibility="hidden",document.body.appendChild(c));const d=(null===(i=c.contentWindow)||void 0===i?void 0:i.window.console)||window.console;switch(n){case"warn":d.warn(t,...l);break;case"info":d.info(t,...l);break;case"error":d.error(t,...l);break;default:d.groupCollapsed(t,...l),d.trace(),d.groupEnd()}},n=(e,...o)=>{t(e,"error",...o)},r=["jsdelivr","cdnjs","unpkg","vercel"],s="jsdelivr",i=e=>{const o=r.indexOf(e);return r[o+1]||null},a=()=>window.location.search.includes("zonosStagingMode=1"),l=()=>{var e;return(null===(e=window.Zonos.zonosApiKey)||void 0===e?void 0:e.includes("test"))||window.location.search.includes("zonosTestMode=1")};function c(e,o){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)o.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(t[n[r]]=e[n[r]])}return t}"function"==typeof SuppressedError&&SuppressedError;const d=["cloudflare","vercel"],u=d[0],p={cloudflare:"https://route.elements.zonos.com",vercel:"https://route.js.zonos.com"},m=p[u],w=(e=u)=>{const o=d.indexOf(e),t=d[o+1];return t||null},h=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return null},y=()=>{const e="userAgentData"in window.navigator?window.navigator.userAgentData:null,o=(()=>{const e="connection"in window.navigator?window.navigator.connection:null,o="mozConnection"in window.navigator?window.navigator.mozConnection:null,t="webkitConnection"in window.navigator?window.navigator.webkitConnection:null;return e||o||t})();return{connectionDownlink:null==o?void 0:o.downlink,connectionEffectiveType:null==o?void 0:o.effectiveType,connectionRtt:null==o?void 0:o.rtt,connectionSaveData:null==o?void 0:o.saveData,isHostedCheckout:window.Zonos.isLegacyCheckout,screenHeight:window.screen.height,screenWidth:window.innerWidth,userAgent:e&&e.brands.length>0?e:window.navigator.userAgent}},g=["/api/zonos-elements/log-script-load","/api/zonos-elements/log-bulk-load-data"],f=async({response:e,shouldLog:o=!0,shouldThrow:t=!1})=>{try{const o=await e.text(),t=h(o);if(!t)throw new Error(`Failed to parse content: ${o}`);return t}catch(e){if(t)throw e;return o&&console.error(e),null}},v=async({basePathType:e,options:o,path:t})=>{let n;const r=window.Zonos.zonosQaUrlApi||p[e]||u,s=new URL(r+t),i=window.Zonos.cartId?`${window.location.hostname}-${window.Zonos.cartId}`:window.location.hostname;s.searchParams.set("zToken",(e=>{try{return btoa(e).replace(/=/g,"")}catch(o){return e.replace(/[^A-Za-z0-9]/g,"").split("").reverse().join("")}})(i));try{n=await fetch(s.toString(),o)}catch(e){if(e instanceof Error)return{baseUrl:r,errors:[{message:e.message,type:"unknown"}],json:null,response:null,zonosMode:null};return{baseUrl:r,errors:[{message:"Failed to fetch",type:"unknown"}],json:null,response:null,zonosMode:null}}const a=n.headers.get("Zonos-Mode"),l=window.Zonos.zonosQaUrl;if(!window.Zonos.modeAlerted&&a&&l&&(window.Zonos.modeAlerted=!0),n.ok){return{baseUrl:r,errors:[],json:await f({response:n}),response:n,zonosMode:a}}const c=n.status.toString();try{const e=await f({response:n,shouldThrow:!0});if(e&&"errors"in e&&Array.isArray(e.errors)){const o=e.errors;return{baseUrl:r,errors:o.map((e=>"string"==typeof e?{message:e,type:c}:e)),json:null,response:n,zonosMode:a}}return{baseUrl:r,errors:[{message:JSON.stringify(e),type:c}],json:null,response:n,zonosMode:a}}catch(e){return{baseUrl:r,errors:[{message:`${c}: ${"Unknown error"}`,type:c}],json:null,response:null,zonosMode:a}}},b=async({basePathType:e,options:o,path:n})=>{var r,s;const i=n.startsWith("/api/bigcommerce")?"vercel":e,a=performance.now(),l=await v({basePathType:i,options:o,path:n}),{errors:d,response:u}=l,f=c(l,["errors","response"]),S=performance.now()-a;t(`${n} (${S.toFixed(2)}ms)`,"info");const z=null==u?void 0:u.headers.get("Zonos-Duration");200===(null==u?void 0:u.status)&&(({apiPath:e,apiType:o,loadTimeInternal:t,loadTimeTotal:n})=>{if(g.includes(e))return;const r=n-t;if(r<0)return;const s=e.split("?")[0]||e,i=y(),a="object"==typeof i.userAgent&&i.userAgent.mobile,l={apiType:o,connectionType:i.connectionEffectiveType,href:s,isHostedCheckout:window.Zonos.isLegacyCheckout,isMobile:(c=a,c||window.innerWidth<890),loadTimeBrowserApi:r,loadTimeInternal:t,loadTimeTotal:n,metadata:Object.assign({},i),screenHeight:i.screenHeight,screenWidth:i.screenWidth,userAgent:"string"==typeof i.userAgent?i.userAgent:i.userAgent.brands.map((e=>e.brand)).filter((e=>!/Not.*A.*Brand.*/.test(e))).join(",")};var c;window.Zonos.loadTimeApiInfoList.push(l)})({apiPath:n,apiType:i,loadTimeInternal:z?Number(z):0,loadTimeTotal:S});const C=w(i),j=!!d.find((({type:e})=>"unknown"===e))||404===(null==u?void 0:u.status),Z=C&&j;return j&&(async({endpoint:e,errors:o,metadata:n,shouldPostReleaseErrorReporting:r})=>{if(t("sendErrorLog","warn",e,n,o),r){const e=Number(window.Zonos.releaseDate);if((new Date).getTime()-e>36e5)return}const s="userAgentData"in window.navigator?window.navigator.userAgentData:null,i={endpoint:e,errors:o,href:window.location.href,metadata:Object.assign({appVersion:window.Zonos.version,domain:window.Zonos.domain,publicCredential:window.Zonos.zonosApiKey,userAgent:s&&s.brands.length>0?s:window.navigator.userAgent},n)};try{fetch(`${m}/api/zonos-elements/log-error`,{body:JSON.stringify(i),headers:{"Zonos-Referer":window.location.hostname},method:"POST"})}catch(e){const o=w();if(!o)return;fetch(`${p[o]}/api/zonos-elements/log-error`,{body:JSON.stringify(i),method:"POST"})}})({endpoint:p[i]+n,errors:d.map((({message:e})=>`API: ${e}`)),metadata:{currentBasePath:i,nextFallbackApiType:C,requestHeaders:null==o?void 0:o.headers,requestPayload:h(null===(r=null==o?void 0:o.body)||void 0===r?void 0:r.toString())||(null===(s=null==o?void 0:o.body)||void 0===s?void 0:s.toString()),status:null==u?void 0:u.status,statusText:null==u?void 0:u.statusText},shouldPostReleaseErrorReporting:!0}),Z?(t(`=== "${n}" failed to fetch, trying next fallback ${C}`),b({basePathType:C,options:o,path:n})):Object.assign({errors:d,response:u},f)},S=async(e,o)=>{const t=c(o||{},[]),n=t.body?JSON.stringify(t.body):void 0,r=t.method||"GET",s=Object.assign({"Content-Type":"application/json","Zonos-Is-BigCommerce":window.Zonos.isBigCommerce.toString(),"Zonos-Referer":window.location.hostname,"Zonos-Staging-Mode":a()?"1":void 0,"Zonos-Test-Mode":l()?"1":void 0,"Zonos-Version":window.Zonos.version,credentialtoken:window.Zonos.zonosApiKey||"Empty credential token from zonos-elements"},t.headers);Object.keys(s).forEach((e=>void 0===s[e]&&delete s[e]));const i=Object.assign(Object.assign({},t),{body:"GET"===r?void 0:n,headers:s,method:r}),d=new URLSearchParams(window.location.search).get("useFallbackApi");return b({basePathType:d||u,options:i,path:e})},z=()=>{const e=window&&window.location.href.includes("forceLoadCdn");if("undefined"==typeof window||e)return null;const o=(e=>{if(!e)return null;const o=new URL(e).searchParams.get("zonosQaUrl");return o?/[^a-zA-Z0-9-_]+/.test(o)?null:o:null})(window.location.href),n="https://v1.3.176.js.zonos.com";if(!o&&(n.includes("test.")||n.includes("test-")))return n;if(!o&&["dev.demo.elements.zonos.com"].includes(window.location.hostname))return"https://dev.elements.zonos.com";if(!o)return null;if("dev-elements"===o)return"https://dev.elements.zonos.com";const r=`https://${o}.preview.js.zonos.com`;return t(`[ZONOS-WARNING] using '${r}' for loading elements script`,"warn"),fetch(r).then((()=>{window.sessionStorage.removeItem("zonos--checkout-session-id"),window.sessionStorage.removeItem("zonos--client-secret")})).catch((()=>{alert(`[ZONOS-WARNING] '${r}' IS NO LONGER AVAILABLE. REMOVING zonosQaUrl PARAM AND RELOADING THE PAGE`);const e=new URLSearchParams(window.location.search);e.delete("zonosQaUrl");const{pathname:o}=window.location,t=`${o}?${e.toString()}`;return window.history.replaceState(window.history.state,"",t),window.location.reload(),null})),r},C="https://js.stripe.com/v3",j=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Z="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used";let O=null;const k=e=>(null!==O||(O=new Promise(((o,t)=>{if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(Z),window.Stripe)o(window.Stripe);else try{let r=(()=>{const e=document.querySelectorAll(`script[src^="${C}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&j.test(t.src))return t}return null})();r&&e?console.warn(Z):r||(r=(e=>{const o=document.createElement("script");o.src=`${C}`;const t=document.head||document.body;return t?(t.appendChild(o),o):(n("Expected document.body not to be null. Stripe.js requires a <body> element."),null)})()),null==r||r.addEventListener("load",(()=>{window.Stripe?o(window.Stripe):t(new Error("Stripe.js not available"))})),null==r||r.addEventListener("error",(()=>{t(new Error("Failed to load Stripe.js"))}))}catch(e){return void t(e)}else o(null)}))),O),A=Promise.resolve().then((()=>k(null)));let I=!1;A.catch((e=>{I||console.warn(e)}));const T=async({cartId:e,retries:o})=>{const n=l(),{errors:r,json:s,zonosMode:i}=await S("/api/zonos-elements/get-cart",{body:{isTestMode:n,tempCartUUID:e},headers:{"Content-Type":"application/json"},method:"POST"}),a=!s||r.length;return a&&o?(t("[ZONOS - loadZonos] temp cart not ready, retrying in 1 second","info",{retries:o}),await new Promise((e=>setTimeout(e,500))),T({cartId:e,retries:o-1})):a?null:Object.assign(Object.assign({},s),{zonosMode:i})},E=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/,L=new RegExp(`^${E.source}$`),$=new RegExp(`^cart_${E.source}$`),N=/^[a-zA-Z0-9]{2,}$/,D=/^cart_[a-zA-Z0-9]{2,}$/,P=async e=>{const{isDgsCartId:o,isLegacyCartId:r}=(e=>e?e.includes("undefined")?{isDgsCartId:!1,isLegacyCartId:!1}:D.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:N.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:$.test(e)?{isDgsCartId:!0,isLegacyCartId:!1}:L.test(e)?{isDgsCartId:!1,isLegacyCartId:!0}:{isDgsCartId:!1,isLegacyCartId:!1}:{isDgsCartId:!1,isLegacyCartId:!1})(e);if(!r&&!o)return n("[ZONOS - loadZonos] invalid cart id"),null;const s=await T({cartId:e,retries:5});return t("[ZONOS - loadZonos] getting temp cart data","info",s),s?(window.Zonos.storeId=s.cartData.storeId,window.Zonos.zonosApiKey=s.cartData.credentialToken,window.Zonos.zonosMode=s.zonosMode,{cartData:s.cartData,settings:s.settings,storeFavicon:s.storeFaviconUrl,storeId:s.cartData.storeId,storeLogo:s.storeLogoUrl,zonosApiKey:s.cartData.credentialToken}):(n("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process."),null)};var U;const F=(()=>{if("undefined"==typeof document)return null;const e=document.querySelector('script[src*="/zonos.js"]'),{currentLoadScriptUrl:o,isWhiteListed:t}=(({loadScriptSrc:e})=>{if(!e)return{currentLoadScriptUrl:"",isForceLoadVersionDomain:!1,isWhiteListed:!1};const o=new URL(e).origin,t=["dev.elements.zonos.com","dev.assets-checkout.zonos.com",".js.zonos.com","zonos-elements-test-git","zonos-elements-git"].some((e=>o.includes(e))),n=["qa.js.zonos.com"].some((e=>o.includes(e)));return{currentLoadScriptUrl:o,isForceLoadVersionDomain:n,isWhiteListed:t}})({loadScriptSrc:null==e?void 0:e.src});return t?o:null})(),R="https://v1.3.176.js.zonos.com",M=F||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.176",x="https://fonts.googleapis.com",B=/^https:\/\/fonts\.googleapis\.com/;class q{}U=q,q.doneInit=!1,q.cartSettings=null,q.debug="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/),q.zonosConversionTest="undefined"!=typeof window&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/),q._paypalMockResponse=null,q.isBigCommerce=!1,q.releaseDate="1743432479930",q.isLegacyCheckout=!1,q.domain="undefined"!=typeof window?window.location!=window.parent.location&&document.referrer||document.location.hostname:"",q.showBaseForeign="undefined"!=typeof window&&window.location.search.includes("zonosShowBaseForeign"),q.isNpm=!0,q.zonosQaUrl=null,q.zonosQaUrlApi=null,q.version="v1.3.176",q.modeAlerted=!1,q.cartData=null,q.paypal=null,q.zonosMode=null,q.getCurrentTimestamp=()=>(new Date).getTime(),q.zonosController=null,q.loadTimeApiInfoList=[],q.logIntervalId=null,q.init=async e=>{const{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:c,overrideCurrencyFormat:d,storeId:u,zonosApiKey:p}=e;if(U.cartId=new URLSearchParams(window.location.search).get("tempCartUUID"),U.doneInit)return;if(t(`====== ZONOS DEBUG MODE: on (${U.version}) ======`),U.zonosApiKey=p,U.storeId=u,U.isNpm){t("====== ZONOS LOADING FROM NPM ======");const o=z();if(o&&!window.isZonosPreview){t(`====== RE-INJECT "zonos.js" FROM PRVIEW: ${o} ======`,"info");const n=document.createElement("script");return n.src=`${o}/dist/scripts/zonos.js`,document.head.appendChild(n),n.addEventListener("load",(()=>{window.Zonos.isNpm=U.isNpm,window.Zonos.isBigCommerce=U.isBigCommerce,window.Zonos.isLegacyCheckout=U.isLegacyCheckout,window.Zonos.init(e)})),n.addEventListener("error",(()=>{alert(`[ZONOS - loadZonos] Failed to load "loadZonos.js" from zonosQaUrl: ${o}`)})),void(window.isZonosPreview=!0)}if(!p&&!U.cartId)return void n("Zonos API key is required unless `tempCartUUID` is provided in url query params.");if(!U.cartData&&U.cartId){t("Initialize cart data");const e=await P(U.cartId);if(!e)return void n("Failed to get cart data");U.cartData=e.cartData,U.zonosApiKey=e.zonosApiKey,U.cartSettings=e.settings}const r=await(async()=>{const e=l(),o=a();if(!e&&!o||!window.Zonos.zonosApiKey)return null;if(t("[ZONOS - loadZonos] Attempt test public credential","info"),window.Zonos.zonosApiKey.includes("credential_test"))return t("[ZONOS - loadZonos] Test mode is enabled but the API key is already a test key","info"),null;const{errors:r,json:s}=await S("/api/get-test-public-credential");if(r.length||!s)return n("[ZONOS - loadZonos] Failed to get test public credential. Keep using production key",r),null;const i=s.publicCredential;return i?(t(`[ZONOS - loadZonos] Retrieve new test public token ${i}`,"info"),i):(n("[ZONOS - loadZonos] No test public key credential. Keep using production key"),null)})();r&&(U.zonosApiKey=r)}const m=new URL(window.location.href).searchParams.get("payment_intent_client_secret")||sessionStorage.getItem("zonos--client-secret");if(U.cartId&&U.cartData||!!m){t("Cart data or stripe client secret is available, inject hidden button and trigger checkout");const e=document.createElement("button");e.style.display="none",e.id="zonos--checkout-hidden-button",document.body.appendChild(e)}t("init zonos"),U.restoreNativeBrowserFunctions(),U.injectCustomScriptForHostedCheckout(),U.injectZonosCdn(),U.injectZonosCss(),U.injectFonts(),U.injectController({config:{appearance:o,checkoutSettings:r,currencyConverter:s,helloSettings:i,onCountryChange:c,overrideCurrencyFormat:d}}),U.doneInit=!0},q.injectCustomScriptForHostedCheckout=()=>{const e=U.cartData,o=(null==e?void 0:e.metadata)||[],n=o.find((e=>"customHeaderScript"===e.key)),r=o.find((e=>"customFooterScript"===e.key));if(window.Zonos.isLegacyCheckout&&(n||r)){if(n){t("Injecting custom header script");const e=document.createElement("script");e.textContent=n.value,document.head.appendChild(e)}if(r){t("Injecting custom footer script");const e=document.createElement("script");e.textContent=r.value,document.body.appendChild(e)}}else t("Skip injecting custom script for hosted checkout","info",{footerScript:r,headerScript:n,isLegacyCheckout:window.Zonos.isLegacyCheckout})},q.displayCurrency=()=>{const e=document.querySelector("zonos-hello");e&&e.displayCurrency()},q.openHelloDialog=e=>{const o=document.querySelector("zonos-hello");o&&o.openHelloDialog(null==e||e)},q.showNotification=e=>{var o;null===(o=U.zonosController)||void 0===o||o.showNotification(e)},q.updateOrganizationName=e=>{var o;null===(o=U.zonosController)||void 0===o||o.updateOrganizationName(e)},q.disablePlaceOrderButtons=({autoEnable:e=!0,config:o,disable:t,placeOrderButtonSelector:n})=>{var r;if(!(null===(r=o.checkoutSettings)||void 0===r?void 0:r.disablePlaceOrderButtonActivation)&&n){const o=document.querySelectorAll(n),r=e=>{e.target.getAttribute("disabled")&&(e.preventDefault(),e.stopPropagation())};o.forEach((e=>{e.getAttribute("data-zonos-checkout-attached")||(t?(e.setAttribute("disabled","true"),e.addEventListener("click",r)):(e.removeAttribute("disabled"),e.removeEventListener("click",r)))})),e&&t&&setTimeout((()=>{o.forEach((e=>{e.removeAttribute("disabled"),e.removeEventListener("click",r)}))}),5e3)}},q.restoreNativeBrowserFunctions=()=>{var e;if("1"===new URL(window.location.href).searchParams.get("useMerchantPolyfill"))return;const o="zonos---native-browser";let t=document.querySelector(`iframe#${o}`);t||(t=document.createElement("iframe"),t.id=o,t.style.display="none",t.style.opacity="0",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.width="1px",t.style.height="1px",t.style.border="none",t.style.overflow="hidden",t.style.visibility="hidden",document.body.appendChild(t));const n=(null===(e=t.contentWindow)||void 0===e?void 0:e.window.Array.from)||Array.from;Array.from=n,document.body.removeChild(t)},q.injectController=({config:e})=>{var o;if(document.querySelector("zonos-controller"))return;if(null===(o=e.checkoutSettings)||void 0===o?void 0:o.placeOrderButtonSelector){const o=e.checkoutSettings.placeOrderButtonSelector;U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o});new MutationObserver((()=>{U.disablePlaceOrderButtons({config:e,disable:!0,placeOrderButtonSelector:o})})).observe(document.body,{childList:!0,subtree:!0})}const r=document.createElement("zonos-controller");r.config=e,r.zonosApiKey=U.zonosApiKey||"",r.addEventListener("stripeInitEvent",(async e=>{const{detail:o}=e;t("loading Stripe");const s=await(async(...e)=>{I=!0;const o=Date.now();return A.then((t=>((e,o,t)=>{if(null===e)return null;const n=e.apply(void 0,o);return((e,o)=>{e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",startTime:o})})(n,t),n})(t,e,o)))})(o.publishableKey);s?(window.Zonos.stripe=s,r.initCheckoutElement(s)):n("API seems to be invalid or missing. Failed to load Stripe")})),document.body.appendChild(r),U.zonosController=r,t("Zonos controller injected!")},q.injectScript=({cdnType:e,isModule:o,theRestUrl:r})=>{const s=`${U.getZonosUrl(e)}/${r}`;if(document.querySelector(`script[src="${s}"]`))return void t(`Zonos script "${s}" already exists in the document`,"warn");const a=document.head||document.body,l=document.createElement("script");o?l.type="module":l.noModule=!0,l.src=s,l.crossOrigin="anonymous",l.onerror=()=>{n(`Failed to load ${l.src}`);const t=i(e);t&&U.injectScript({cdnType:t,isModule:o,theRestUrl:r})},a.appendChild(l)},q.getZonosUrl=e=>{const o=()=>{switch(e){case"jsdelivr":return M;case"unpkg":return"https://unpkg.com/@zonos/elements@1.3.176";case"cdnjs":return"https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.176";case"vercel":return R}};if(U.isNpm){return z()||o()}return o()},q.injectZonosCdn=()=>{U.injectScript({cdnType:s,isModule:!0,theRestUrl:"dist/zonos-elements/zonos-elements.esm.js"}),U.injectScript({cdnType:s,isModule:!1,theRestUrl:"dist/zonos-elements/zonos-elements.js"}),t("Zonos cdn script injected!")},q.injectStylesheet=({cdnType:e,theRestUrl:o})=>{const t=U.getZonosUrl(e),r=document.head||document.body,s=document.createElement("link");s.rel="preconnect",s.href=`${R}/`,r.appendChild(s);const a=document.createElement("link");a.rel="stylesheet",a.href=`${t}/${o}`,a.onerror=()=>{n(`Failed to load ${a.href}`);const t=i(e);t&&U.injectStylesheet({cdnType:t,theRestUrl:o})},r.appendChild(a)},q.injectZonosCss=()=>{document.querySelector('link[rel="stylesheet"][href*="/dist/zonos-elements/zonos-elements.css"]')?t("Zonos style links already injected","warn"):(U.injectStylesheet({cdnType:s,theRestUrl:"dist/zonos-elements/zonos-elements.css"}),t("Zonos style css injected!"))},q.injectFonts=()=>{if((()=>{if(document.fonts.check("1em Inter"))return void t("Inter font already loaded","warn");const e=document.querySelectorAll(`link[rel="stylesheet"][href^="${x}"]`);for(let o=0;o<e.length;o++){const t=e[o];if(t&&!B.test(t.href))return t}return null})())return void t("Inter font already injected","warn");const e=document.head||document.body,o=document.createElement("link");o.rel="preconnect",o.href=x,e.appendChild(o);const n=document.createElement("link");n.rel="stylesheet",n.href=`${x}/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap`,e.appendChild(n),t("Zonos font injected!")},q.setupGoogleFont=e=>{var o;null===(o=U.zonosController)||void 0===o||o.setupGoogleFont(e)},q.injectSupportGoogleFont=e=>{var o;t(`[FONT] injecting ${e}`);const n=null===(o=e.match(/family=(.*?):/))||void 0===o?void 0:o[1],r=document.head||document.body;if(!document.querySelector(`link[rel="preconnect"][href^="${x}"]`)){const e=document.createElement("link");e.rel="preconnect",e.href=x,r.appendChild(e)}if(document.querySelector(`link[rel="stylesheet"][href="${e}"]`))return void t(`[FONT] ${n} font already injected`,"warn");const s=document.createElement("link");s.rel="stylesheet",s.href=e,r.appendChild(s),t(`[FONT] ${n} font injected!`)},exports.Zonos=q})();
|