@fungies/fungies-js 0.0.4 → 0.0.6

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/CHANGELOG.md CHANGED
@@ -1,11 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix build options
8
+
9
+ ## 0.0.5
10
+
11
+ ### Patch Changes
12
+
13
+ - Auto open embed checkout
14
+ - Fix displaying checkout element
15
+
3
16
  ## 0.0.4
4
17
 
5
18
  ### Patch Changes
6
19
 
7
20
  - Auto open embed checkout
8
- - fix displaying checkout element
21
+ - Fix displaying checkout element
9
22
 
10
23
  ## 0.0.3
11
24
 
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var Fungies=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,i=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,r=(t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,s=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&r(e,n,t[n]);if(i)for(var n of i(t))a.call(t,n)&&r(e,n,t[n]);return e},d=(e,t)=>{var n={};for(var r in e)o.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&i)for(var r of i(e))t.indexOf(r)<0&&a.call(e,r)&&(n[r]=e[r]);return n},l={};((t,n)=>{for(var i in n)e(t,i,{get:n[i],enumerable:!0})})(l,{Fungies:()=>F});var c=(e,t="log",n=!1,i={isEnabled:!0})=>{if(!i.isEnabled)return;window.console.debug=window.console.debug||window.console.log;const o=`[Fungies Debug]${e}`;"log"===t?console.debug(o):"warning"===t&&console.warn(o),n&&console.warn(e)};function u(e,t){const n=document.getElementsByClassName(e);for(let e=0;e<n.length;e++){const i=n[e];if("function"!=typeof t)throw new Error("each(className, function() {... requires the callback argument to be of type Function");t(i)}}function m(){u("fungies-loader",(e=>{var t;null==(t=null==e?void 0:e.parentNode)||t.removeChild(e)}))}function g(e){const t=e.getAttribute("data-fungies-checkout-url");t||c("Element has data-fungies-checkout-url attribute but no value","warning");const n=e.getAttribute("data-fungies-mode"),i="embed"===n||"overlay"===n?n:"overlay",o=e.getAttribute("data-fungies-frame-target")||void 0,a=e.getAttribute("data-fungies-discount-code")||void 0,r=e.getAttribute("data-fungies-customer-email")||void 0,d=e.getAttribute("data-fungies-quantity"),l=d?Number.parseInt(d,10):void 0;let u;const m=e.getAttribute("data-fungies-items");if(m)try{u=JSON.parse(m)}catch(e){c(`Invalid JSON in data-fungies-items: ${m}`,"warning")}let g;const p=e.getAttribute("data-fungies-custom-fields");if(p)try{g=JSON.parse(p)}catch(e){c(`Invalid JSON in data-fungies-custom-fields: ${p}`,"warning")}return s(s(s(s(s({checkoutUrl:t,settings:s({mode:i},o&&{frameTarget:o})},a&&{discountCode:a}),r&&{customerEmail:r}),l&&{quantity:l}),u&&{items:u}),g&&{customFields:g})}var p="closeWindow",f="embed";var b=(e,t,n)=>{const i=new URL(t);var o;return i.searchParams.append("fngs-checkout-payload",(o=JSON.stringify(e),encodeURIComponent(encodeURIComponent(o)))),i.searchParams.append("fngs-display-mode",n),i.toString()},w=()=>{c("Checkout frame/window has been closed."),m(),u("fungies-frame",(e=>{var t;null==(t=e.parentNode)||t.removeChild(e)})),void 0===window.FungiesWindow||window.FungiesWindow.closed||window.FungiesWindow.close()},h=(e,t,n)=>{var i;const o=((e,t)=>{var n=e,{checkoutUrl:i}=n,o=d(n,["checkoutUrl"]);return b(o,i,t)})(e,t.mode);if(n||function(){m();const e=document.createElement("style");e.type="text/css",e.innerHTML="\t\t\t\t@-webkit-keyframes rotate {\t\t\t\t\t0% {\t\t\t\t\t\t-webkit-transform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\t100% {\t\t\t\t\t\t-webkit-transform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}\t\t\t\t@keyframes rotate {\t\t\t\t\tfrom {\t\t\t\t\t\ttransform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\tto {\t\t\t\t\t\ttransform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}";const t=document.getElementsByTagName("head")[0];t&&t.appendChild(e);const n=document.createElement("div");n.setAttribute("style","z-index:99998; display: block; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; right: 0px; bottom: 0px; margin: 0px; padding: 0px; background: rgba(0,0,0,0.38);"),n.setAttribute("class","fungies-loader");const i=document.createElement("main");i.setAttribute("style","align-items: center;display: flex;flex-direction: column;justify-content: center;left: 50%;margin: 0.5rem 0;position: absolute;text-align: center;top: 50%;transform: translate(-50%, -50%);width: 90%;");const o=document.createElement("div");o.setAttribute("style","border: 4px solid #f3f3f3;border-radius: 50%;border-top: 4px solid #ccc;width: 34px;height: 34px;-webkit-animation: rotate 1s ease-in-out infinite forwards;animation: rotate 1s ease-in-out infinite forwards;"),i.appendChild(o),n.appendChild(i);const a=()=>{const e=document.getElementsByTagName("body")[0];e&&e.appendChild(n)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",a):a()}(),window.FungiesFrame=document.createElement("iframe"),window.FungiesFrame.className="fungies-frame",window.FungiesFrame.name="fungies_frame",window.FungiesFrame.frameBorder="0",window.FungiesFrame.allowTransparency="true",window.FungiesFrame.allow="payment",n){window.FungiesFrame.classList.add("fungies-frame-embed"),window.FungiesFrame.setAttribute("style","width: 100%; height: 100%;");const e=document.createElement("style");e.type="text/css",e.innerHTML=".fungies-frame-embed::-webkit-scrollbar { display: none !important; }",null==(i=null==document?void 0:document.getElementsByTagName("head")[0])||i.appendChild(e)}else window.FungiesFrame.classList.add("fungies-frame-overlay");if(n||(!function(){let e=!1;var t;return t=navigator.userAgent||navigator.vendor,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(t.substr(0,4)))&&(e=!0),e}()?window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"):window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: scroll; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;")),window.FungiesFrame.src=o,(null==t?void 0:t.frameTarget)&&n){const e=document.getElementById(t.frameTarget);e&&e.appendChild(window.FungiesFrame)}else{const e=document.getElementsByTagName("body")[0];e&&e.appendChild(window.FungiesFrame)}},v=e=>{var t=e,{settings:n}=t,i=d(t,["settings"]);w();const o=()=>{c("Checkout.open() called"),h(i,n,(null==n?void 0:n.mode)===f)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)},y=()=>{c("Scanning for checkout elements");const e=document.querySelectorAll("[data-fungies-checkout-url]:not([data-fungies-initialized])");for(const t of e){const e=g(t);t.addEventListener("click",(t=>{t.preventDefault(),v(e)})),t.setAttribute("data-fungies-initialized","true")}const t=document.querySelectorAll("[data-fungies-button]:not([data-fungies-initialized])");for(const e of t){const t=e.getAttribute("data-fungies-button");if(t)try{const n=new URL(t).pathname.split("/"),i=n.indexOf("checkout-element"),o=n.indexOf("overlay");if(-1===i&&-1===o){c(`Invalid URL in data-fungies-button: ${t}`,"warning");continue}const a={checkoutUrl:t,settings:{mode:"overlay"}};e.addEventListener("click",(e=>{e.preventDefault(),v(a)})),e.setAttribute("data-fungies-initialized","true")}catch(e){c(e,"error")}else c("Element has data-fungies-button attribute but no value","warning")}},k=e=>{const{data:t}=e;if(("string"==typeof t?t:"")===p)w()};var x,F={Checkout:{open:v,close:()=>{w()}},Initialize:(e,t={completedSetup:!1,options:null})=>{t.completedSetup?c("Cannot call Fungies.Initialize() more than once per page, the call was ignored.","warning"):("undefined"!=typeof window&&window.addEventListener("message",k,!1),!1!==e.enableDataAttributes&&(c("Initializing DOM support"),"loading"!==document.readyState?y():document.addEventListener("DOMContentLoaded",y),new MutationObserver((e=>{let t=!1;for(const n of e)if("childList"===n.type&&n.addedNodes.length>0)for(const e of n.addedNodes)if(e.nodeType===Node.ELEMENT_NODE&&e.querySelector("[data-fungies-checkout-url]:not([data-fungies-initialized]), [data-fungies-button]:not([data-fungies-initialized])")){t=!0;break}t&&y()})).observe(document.body,{childList:!0,subtree:!0})),((e,t)=>{s(s({},e),t)})(t,{completedSetup:!0,options:e}))},ScanDOM:y};if("undefined"!=typeof window&&(window.Fungies=F),"undefined"!=typeof document){const e=document.currentScript;if((null==e?void 0:e.hasAttribute("data-auto-init"))&&(F.Initialize({enableDataAttributes:!0}),null==e?void 0:e.hasAttribute("data-auto-display-checkout"))){const t=g(e);F.Checkout.open(t)}}return x=l,((i,a,r,s)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let d of n(a))o.call(i,d)||d===r||e(i,d,{get:()=>a[d],enumerable:!(s=t(a,d))||s.enumerable});return i})(e({},"__esModule",{value:!0}),x)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungies/fungies-js",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
package/tsup.config.ts CHANGED
@@ -5,7 +5,14 @@ export const options: Options[] = [
5
5
  entry: ["src/index.ts"],
6
6
  format: ["esm", "iife"],
7
7
  dts: true,
8
+ globalName: "Fungies",
8
9
  minify: "terser",
10
+ clean: true,
11
+ outExtension({ format }) {
12
+ return {
13
+ js: format === "iife" ? ".js" : format === "esm" ? ".mjs" : ".cjs",
14
+ };
15
+ },
9
16
  },
10
17
  ];
11
18
 
@@ -1 +0,0 @@
1
- "use strict";(()=>{var e=Object.defineProperty,t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,o=(t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,a=(e,a)=>{for(var r in a||(a={}))n.call(a,r)&&o(e,r,a[r]);if(t)for(var r of t(a))i.call(a,r)&&o(e,r,a[r]);return e},r=(e,o)=>{var a={};for(var r in e)n.call(e,r)&&o.indexOf(r)<0&&(a[r]=e[r]);if(null!=e&&t)for(var r of t(e))o.indexOf(r)<0&&i.call(e,r)&&(a[r]=e[r]);return a},s=(e,t="log",n=!1,i={isEnabled:!0})=>{if(!i.isEnabled)return;window.console.debug=window.console.debug||window.console.log;const o=`[Fungies Debug]${e}`;"log"===t?console.debug(o):"warning"===t&&console.warn(o),n&&console.warn(e)};function d(e,t){const n=document.getElementsByClassName(e);for(let e=0;e<n.length;e++){const i=n[e];if("function"!=typeof t)throw new Error("each(className, function() {... requires the callback argument to be of type Function");t(i)}}function l(){d("fungies-loader",(e=>{var t;null==(t=null==e?void 0:e.parentNode)||t.removeChild(e)}))}function c(e){const t=e.getAttribute("data-fungies-checkout-url");t||s("Element has data-fungies-checkout-url attribute but no value","warning");const n=e.getAttribute("data-fungies-mode"),i="embed"===n||"overlay"===n?n:"overlay",o=e.getAttribute("data-fungies-frame-target")||void 0,r=e.getAttribute("data-fungies-discount-code")||void 0,d=e.getAttribute("data-fungies-customer-email")||void 0,l=e.getAttribute("data-fungies-quantity"),c=l?Number.parseInt(l,10):void 0;let u;const m=e.getAttribute("data-fungies-items");if(m)try{u=JSON.parse(m)}catch(e){s(`Invalid JSON in data-fungies-items: ${m}`,"warning")}let g;const p=e.getAttribute("data-fungies-custom-fields");if(p)try{g=JSON.parse(p)}catch(e){s(`Invalid JSON in data-fungies-custom-fields: ${p}`,"warning")}return a(a(a(a(a({checkoutUrl:t,settings:a({mode:i},o&&{frameTarget:o})},r&&{discountCode:r}),d&&{customerEmail:d}),c&&{quantity:c}),u&&{items:u}),g&&{customFields:g})}var u="closeWindow",m="embed";var g=(e,t,n)=>{const i=new URL(t);var o;return i.searchParams.append("fngs-checkout-payload",(o=JSON.stringify(e),encodeURIComponent(encodeURIComponent(o)))),i.searchParams.append("fngs-display-mode",n),i.toString()},p=()=>{s("Checkout frame/window has been closed."),l(),d("fungies-frame",(e=>{var t;null==(t=e.parentNode)||t.removeChild(e)})),void 0===window.FungiesWindow||window.FungiesWindow.closed||window.FungiesWindow.close()},f=(e,t,n)=>{var i;const o=((e,t)=>{var n=e,{checkoutUrl:i}=n,o=r(n,["checkoutUrl"]);return g(o,i,t)})(e,t.mode);if(n||function(){l();const e=document.createElement("style");e.type="text/css",e.innerHTML="\t\t\t\t@-webkit-keyframes rotate {\t\t\t\t\t0% {\t\t\t\t\t\t-webkit-transform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\t100% {\t\t\t\t\t\t-webkit-transform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}\t\t\t\t@keyframes rotate {\t\t\t\t\tfrom {\t\t\t\t\t\ttransform: rotate(45deg);\t\t\t\t\t}\t\t\t\t\tto {\t\t\t\t\t\ttransform: rotate(405deg);\t\t\t\t\t}\t\t\t\t}";const t=document.getElementsByTagName("head")[0];t&&t.appendChild(e);const n=document.createElement("div");n.setAttribute("style","z-index:99998; display: block; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; right: 0px; bottom: 0px; margin: 0px; padding: 0px; background: rgba(0,0,0,0.38);"),n.setAttribute("class","fungies-loader");const i=document.createElement("main");i.setAttribute("style","align-items: center;display: flex;flex-direction: column;justify-content: center;left: 50%;margin: 0.5rem 0;position: absolute;text-align: center;top: 50%;transform: translate(-50%, -50%);width: 90%;");const o=document.createElement("div");o.setAttribute("style","border: 4px solid #f3f3f3;border-radius: 50%;border-top: 4px solid #ccc;width: 34px;height: 34px;-webkit-animation: rotate 1s ease-in-out infinite forwards;animation: rotate 1s ease-in-out infinite forwards;"),i.appendChild(o),n.appendChild(i);const a=()=>{const e=document.getElementsByTagName("body")[0];e&&e.appendChild(n)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",a):a()}(),window.FungiesFrame=document.createElement("iframe"),window.FungiesFrame.className="fungies-frame",window.FungiesFrame.name="fungies_frame",window.FungiesFrame.frameBorder="0",window.FungiesFrame.allowTransparency="true",window.FungiesFrame.allow="payment",n){window.FungiesFrame.classList.add("fungies-frame-embed"),window.FungiesFrame.setAttribute("style","width: 100%; height: 100%;");const e=document.createElement("style");e.type="text/css",e.innerHTML=".fungies-frame-embed::-webkit-scrollbar { display: none !important; }",null==(i=null==document?void 0:document.getElementsByTagName("head")[0])||i.appendChild(e)}else window.FungiesFrame.classList.add("fungies-frame-overlay");if(n||(!function(){let e=!1;var t;return t=navigator.userAgent||navigator.vendor,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(t.substr(0,4)))&&(e=!0),e}()?window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: auto; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"):window.FungiesFrame.setAttribute("style","z-index: 2147483647; display: block; background-color: transparent; border: 0px none transparent; overflow-x: hidden; overflow-y: scroll; visibility: visible; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;")),window.FungiesFrame.src=o,(null==t?void 0:t.frameTarget)&&n){const e=document.getElementById(t.frameTarget);e&&e.appendChild(window.FungiesFrame)}else{const e=document.getElementsByTagName("body")[0];e&&e.appendChild(window.FungiesFrame)}},w=e=>{var t=e,{settings:n}=t,i=r(t,["settings"]);p();const o=()=>{s("Checkout.open() called"),f(i,n,(null==n?void 0:n.mode)===m)};"loading"!==document.readyState?o():document.addEventListener("DOMContentLoaded",o)},b=()=>{s("Scanning for checkout elements");const e=document.querySelectorAll("[data-fungies-checkout-url]:not([data-fungies-initialized])");for(const t of e){const e=c(t);t.addEventListener("click",(t=>{t.preventDefault(),w(e)})),t.setAttribute("data-fungies-initialized","true")}const t=document.querySelectorAll("[data-fungies-button]:not([data-fungies-initialized])");for(const e of t){const t=e.getAttribute("data-fungies-button");if(t)try{const n=new URL(t).pathname.split("/"),i=n.indexOf("checkout-element"),o=n.indexOf("overlay");if(-1===i&&-1===o){s(`Invalid URL in data-fungies-button: ${t}`,"warning");continue}const a={checkoutUrl:t,settings:{mode:"overlay"}};e.addEventListener("click",(e=>{e.preventDefault(),w(a)})),e.setAttribute("data-fungies-initialized","true")}catch(e){s(e,"error")}else s("Element has data-fungies-button attribute but no value","warning")}},h=e=>{const{data:t}=e;if(("string"==typeof t?t:"")===u)p()};var v={Checkout:{open:w,close:()=>{p()}},Initialize:(e,t={completedSetup:!1,options:null})=>{t.completedSetup?s("Cannot call Fungies.Initialize() more than once per page, the call was ignored.","warning"):("undefined"!=typeof window&&window.addEventListener("message",h,!1),!1!==e.enableDataAttributes&&(s("Initializing DOM support"),"loading"!==document.readyState?b():document.addEventListener("DOMContentLoaded",b),new MutationObserver((e=>{let t=!1;for(const n of e)if("childList"===n.type&&n.addedNodes.length>0)for(const e of n.addedNodes)if(e.nodeType===Node.ELEMENT_NODE&&e.querySelector("[data-fungies-checkout-url]:not([data-fungies-initialized]), [data-fungies-button]:not([data-fungies-initialized])")){t=!0;break}t&&b()})).observe(document.body,{childList:!0,subtree:!0})),((e,t)=>{a(a({},e),t)})(t,{completedSetup:!0,options:e}))},ScanDOM:b};if("undefined"!=typeof window&&(window.Fungies=v),"undefined"!=typeof document){const e=document.currentScript;if((null==e?void 0:e.hasAttribute("data-auto-init"))&&(v.Initialize({enableDataAttributes:!0}),null==e?void 0:e.hasAttribute("data-auto-display-checkout"))){const t=c(e);v.Checkout.open(t)}}})();