Socket
Socket
Sign inDemoInstall

airwallex-payment-elements

Package Overview
Dependencies
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

airwallex-payment-elements - npm Package Compare versions

Comparing version 0.0.55 to 0.0.56

.eslintignore

27

lib/airwallex.cjs.js

@@ -1,4 +0,27 @@

/* Airwallex Checkout Component Version [0.0.55] */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e="https://checkout.airwallex.com/assets/bundle.min.js",r=Promise.resolve().then(()=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;const r=document.querySelector(`script[src="${e}"], script[src="${e}/"]`)||(()=>{const r=document.createElement("script");r.src=e;const t=document.head||document.body;if(!t)throw new Error("Expected document.body not to be null. Airwallex.js requires a <head> or <body> element.");return t.appendChild(r),r})();return new Promise((e,t)=>{r.addEventListener("load",()=>{window.Airwallex?e():t(new Error("Failed to load Airwallex.js"))}),r.addEventListener("error",()=>{t(new Error("Failed to load Airwallex.js"))})})});exports.loadAirwallex=()=>r;
/* Airwallex Checkout Component Version [0.0.56] */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=new WeakMap,t=t=>"function"==typeof t&&e.has(t),i=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,n=(e,t,i=null)=>{for(;t!==i;){const i=t.nextSibling;e.removeChild(t),t=i}},s={},o={},r=`{{lit-${String(Math.random()).slice(2)}}}`,a=`\x3c!--${r}--\x3e`,l=new RegExp(`${r}|${a}`);class d{constructor(e,t){this.parts=[],this.element=t;const i=[],n=[],s=document.createTreeWalker(t.content,133,null,!1);let o=0,a=-1,d=0;const{strings:u,values:{length:m}}=e;for(;d<m;){const e=s.nextNode();if(null!==e){if(a++,1===e.nodeType){if(e.hasAttributes()){const t=e.attributes,{length:i}=t;let n=0;for(let e=0;e<i;e++)c(t[e].name,"$lit$")&&n++;for(;n-- >0;){const t=u[d],i=p.exec(t)[2],n=i.toLowerCase()+"$lit$",s=e.getAttribute(n);e.removeAttribute(n);const o=s.split(l);this.parts.push({type:"attribute",index:a,name:i,strings:o}),d+=o.length-1}}"TEMPLATE"===e.tagName&&(n.push(e),s.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(r)>=0){const n=e.parentNode,s=t.split(l),o=s.length-1;for(let t=0;t<o;t++){let i,o=s[t];if(""===o)i=h();else{const e=p.exec(o);null!==e&&c(e[2],"$lit$")&&(o=o.slice(0,e.index)+e[1]+e[2].slice(0,-"$lit$".length)+e[3]),i=document.createTextNode(o)}n.insertBefore(i,e),this.parts.push({type:"node",index:++a})}""===s[o]?(n.insertBefore(h(),e),i.push(e)):e.data=s[o],d+=o}}else if(8===e.nodeType)if(e.data===r){const t=e.parentNode;null!==e.previousSibling&&a!==o||(a++,t.insertBefore(h(),e)),o=a,this.parts.push({type:"node",index:a}),null===e.nextSibling?e.data="":(i.push(e),a--),d++}else{let t=-1;for(;-1!==(t=e.data.indexOf(r,t+1));)this.parts.push({type:"node",index:-1}),d++}}else s.currentNode=n.pop()}for(const e of i)e.parentNode.removeChild(e)}}const c=(e,t)=>{const i=e.length-t.length;return i>=0&&e.slice(i)===t},u=e=>-1!==e.index,h=()=>document.createComment(""),p=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class m{constructor(e,t,i){this.__parts=[],this.template=e,this.processor=t,this.options=i}update(e){let t=0;for(const i of this.__parts)void 0!==i&&i.setValue(e[t]),t++;for(const e of this.__parts)void 0!==e&&e.commit()}_clone(){const e=i?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),t=[],n=this.template.parts,s=document.createTreeWalker(e,133,null,!1);let o,r=0,a=0,l=s.nextNode();for(;r<n.length;)if(o=n[r],u(o)){for(;a<o.index;)a++,"TEMPLATE"===l.nodeName&&(t.push(l),s.currentNode=l.content),null===(l=s.nextNode())&&(s.currentNode=t.pop(),l=s.nextNode());if("node"===o.type){const e=this.processor.handleTextExpression(this.options);e.insertAfterNode(l.previousSibling),this.__parts.push(e)}else this.__parts.push(...this.processor.handleAttributeExpressions(l,o.name,o.strings,this.options));r++}else this.__parts.push(void 0),r++;return i&&(document.adoptNode(e),customElements.upgrade(e)),e}}const v=` ${r} `;class g{constructor(e,t,i,n){this.strings=e,this.values=t,this.type=i,this.processor=n}getHTML(){const e=this.strings.length-1;let t="",i=!1;for(let n=0;n<e;n++){const e=this.strings[n],s=e.lastIndexOf("\x3c!--");i=(s>-1||i)&&-1===e.indexOf("--\x3e",s+1);const o=p.exec(e);t+=null===o?e+(i?v:a):e.substr(0,o.index)+o[1]+o[2]+"$lit$"+o[3]+r}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");return e.innerHTML=this.getHTML(),e}}const w=e=>null===e||!("object"==typeof e||"function"==typeof e),f=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class y{constructor(e,t,i){this.dirty=!0,this.element=e,this.name=t,this.strings=i,this.parts=[];for(let e=0;e<i.length-1;e++)this.parts[e]=this._createPart()}_createPart(){return new _(this)}_getValue(){const e=this.strings,t=e.length-1;let i="";for(let n=0;n<t;n++){i+=e[n];const t=this.parts[n];if(void 0!==t){const e=t.value;if(w(e)||!f(e))i+="string"==typeof e?e:String(e);else for(const t of e)i+="string"==typeof t?t:String(t)}}return i+=e[t],i}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class _{constructor(e){this.value=void 0,this.committer=e}setValue(e){e===s||w(e)&&e===this.value||(this.value=e,t(e)||(this.committer.dirty=!0))}commit(){for(;t(this.value);){const e=this.value;this.value=s,e(this)}this.value!==s&&this.committer.commit()}}class S{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(h()),this.endNode=e.appendChild(h())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=h()),e.__insert(this.endNode=h())}insertAfterPart(e){e.__insert(this.startNode=h()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){for(;t(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=s,e(this)}const e=this.__pendingValue;e!==s&&(w(e)?e!==this.value&&this.__commitText(e):e instanceof g?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):f(e)?this.__commitIterable(e):e===o?(this.value=o,this.clear()):this.__commitText(e))}__insert(e){this.endNode.parentNode.insertBefore(e,this.endNode)}__commitNode(e){this.value!==e&&(this.clear(),this.__insert(e),this.value=e)}__commitText(e){const t=this.startNode.nextSibling,i="string"==typeof(e=null==e?"":e)?e:String(e);t===this.endNode.previousSibling&&3===t.nodeType?t.data=i:this.__commitNode(document.createTextNode(i)),this.value=e}__commitTemplateResult(e){const t=this.options.templateFactory(e);if(this.value instanceof m&&this.value.template===t)this.value.update(e.values);else{const i=new m(t,e.processor,this.options),n=i._clone();i.update(e.values),this.__commitNode(n),this.value=i}}__commitIterable(e){Array.isArray(this.value)||(this.value=[],this.clear());const t=this.value;let i,n=0;for(const s of e)i=t[n],void 0===i&&(i=new S(this.options),t.push(i),0===n?i.appendIntoPart(this):i.insertAfterPart(t[n-1])),i.setValue(s),i.commit(),n++;n<t.length&&(t.length=n,this.clear(i&&i.endNode))}clear(e=this.startNode){n(this.startNode.parentNode,e.nextSibling,this.endNode)}}class b{constructor(e,t,i){if(this.value=void 0,this.__pendingValue=void 0,2!==i.length||""!==i[0]||""!==i[1])throw new Error("Boolean attributes can only contain a single expression");this.element=e,this.name=t,this.strings=i}setValue(e){this.__pendingValue=e}commit(){for(;t(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=s,e(this)}if(this.__pendingValue===s)return;const e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=s}}class C extends y{constructor(e,t,i){super(e,t,i),this.single=2===i.length&&""===i[0]&&""===i[1]}_createPart(){return new x(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class x extends _{}let E=!1;try{const e={get capture(){return E=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}class A{constructor(e,t,i){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=i,this.__boundHandleEvent=e=>this.handleEvent(e)}setValue(e){this.__pendingValue=e}commit(){for(;t(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=s,e(this)}if(this.__pendingValue===s)return;const e=this.__pendingValue,i=this.value,n=null==e||null!=i&&(e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive),o=null!=e&&(null==i||n);n&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),o&&(this.__options=N(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=s}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}}const N=e=>e&&(E?{capture:e.capture,passive:e.passive,once:e.once}:e.capture);const U=new class{handleAttributeExpressions(e,t,i,n){const s=t[0];if("."===s){return new C(e,t.slice(1),i).parts}return"@"===s?[new A(e,t.slice(1),n.eventContext)]:"?"===s?[new b(e,t.slice(1),i)]:new y(e,t,i).parts}handleTextExpression(e){return new S(e)}};function P(e){let t=T.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},T.set(e.type,t));let i=t.stringsArray.get(e.strings);if(void 0!==i)return i;const n=e.strings.join(r);return i=t.keyString.get(n),void 0===i&&(i=new d(e,e.getTemplateElement()),t.keyString.set(n,i)),t.stringsArray.set(e.strings,i),i}const T=new Map,R=new WeakMap;(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.1.2");const $=(e,...t)=>new g(e,t,"html",U);function M(e,t){const{element:{content:i},parts:n}=e,s=document.createTreeWalker(i,133,null,!1);let o=O(n),r=n[o],a=-1,l=0;const d=[];let c=null;for(;s.nextNode();){a++;const e=s.currentNode;for(e.previousSibling===c&&(c=null),t.has(e)&&(d.push(e),null===c&&(c=e)),null!==c&&l++;void 0!==r&&r.index===a;)r.index=null!==c?-1:r.index-l,o=O(n,o),r=n[o]}d.forEach(e=>e.parentNode.removeChild(e))}const I=e=>{let t=11===e.nodeType?0:1;const i=document.createTreeWalker(e,133,null,!1);for(;i.nextNode();)t++;return t},O=(e,t=-1)=>{for(let i=t+1;i<e.length;i++){const t=e[i];if(u(t))return i}return-1};const L=(e,t)=>`${e}--${t}`;let W=!0;void 0===window.ShadyCSS?W=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),W=!1);const V=e=>t=>{const i=L(t.type,e);let n=T.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},T.set(i,n));let s=n.stringsArray.get(t.strings);if(void 0!==s)return s;const o=t.strings.join(r);if(s=n.keyString.get(o),void 0===s){const i=t.getTemplateElement();W&&window.ShadyCSS.prepareTemplateDom(i,e),s=new d(t,i),n.keyString.set(o,s)}return n.stringsArray.set(t.strings,s),s},k=["html","svg"],F=new Set,j=(e,t,i)=>{F.add(e);const n=i?i.element:document.createElement("template"),s=t.querySelectorAll("style"),{length:o}=s;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(n,e);const r=document.createElement("style");for(let e=0;e<o;e++){const t=s[e];t.parentNode.removeChild(t),r.textContent+=t.textContent}(e=>{k.forEach(t=>{const i=T.get(L(t,e));void 0!==i&&i.keyString.forEach(e=>{const{element:{content:t}}=e,i=new Set;Array.from(t.querySelectorAll("style")).forEach(e=>{i.add(e)}),M(e,i)})})})(e);const a=n.content;i?function(e,t,i=null){const{element:{content:n},parts:s}=e;if(null==i)return void n.appendChild(t);const o=document.createTreeWalker(n,133,null,!1);let r=O(s),a=0,l=-1;for(;o.nextNode();){for(l++,o.currentNode===i&&(a=I(t),i.parentNode.insertBefore(t,i));-1!==r&&s[r].index===l;){if(a>0){for(;-1!==r;)s[r].index+=a,r=O(s,r);return}r=O(s,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,e);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)t.insertBefore(l.cloneNode(!0),t.firstChild);else if(i){a.insertBefore(r,a.firstChild);const e=new Set;e.add(r),M(i,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const q={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},B=(e,t)=>t!==e&&(t==t||e==e),D={attribute:!0,type:String,converter:q,reflect:!1,hasChanged:B},H=Promise.resolve(!0);class z extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=H,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach((t,i)=>{const n=this._attributeNameForProperty(i,t);void 0!==n&&(this._attributeToPropertyMap.set(n,i),e.push(n))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach((e,t)=>this._classProperties.set(t,e))}}static createProperty(e,t=D){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const i="symbol"==typeof e?Symbol():`__${e}`;Object.defineProperty(this.prototype,e,{get(){return this[i]},set(t){const n=this[e];this[i]=t,this._requestUpdate(e,n)},configurable:!0,enumerable:!0})}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty("finalized")||e.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]];for(const i of t)this.createProperty(i,e[i])}}static _attributeNameForProperty(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}static _valueHasChanged(e,t,i=B){return i(e,t)}static _propertyValueFromAttribute(e,t){const i=t.type,n=t.converter||q,s="function"==typeof n?n:n.fromAttribute;return s?s(e,i):e}static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const i=t.type,n=t.converter;return(n&&n.toAttribute||q.toAttribute)(e,i)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach((e,t)=>{if(this.hasOwnProperty(t)){const e=this[t];delete this[t],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(t,e)}})}_applyInstanceProperties(){this._instanceProperties.forEach((e,t)=>this[t]=e),this._instanceProperties=void 0}connectedCallback(){this._updateState=32|this._updateState,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,t,i){t!==i&&this._attributeToProperty(e,i)}_propertyToAttribute(e,t,i=D){const n=this.constructor,s=n._attributeNameForProperty(e,i);if(void 0!==s){const e=n._propertyValueToAttribute(t,i);if(void 0===e)return;this._updateState=8|this._updateState,null==e?this.removeAttribute(s):this.setAttribute(s,e),this._updateState=-9&this._updateState}}_attributeToProperty(e,t){if(8&this._updateState)return;const i=this.constructor,n=i._attributeToPropertyMap.get(e);if(void 0!==n){const e=i._classProperties.get(n)||D;this._updateState=16|this._updateState,this[n]=i._propertyValueFromAttribute(t,e),this._updateState=-17&this._updateState}}_requestUpdate(e,t){let i=!0;if(void 0!==e){const n=this.constructor,s=n._classProperties.get(e)||D;n._valueHasChanged(this[e],t,s.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,t),!0!==s.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,s))):i=!1}!this._hasRequestedUpdate&&i&&this._enqueueUpdate()}requestUpdate(e,t){return this._requestUpdate(e,t),this.updateComplete}async _enqueueUpdate(){let e,t;this._updateState=4|this._updateState;const i=this._updatePromise;this._updatePromise=new Promise((i,n)=>{e=i,t=n});try{await i}catch(e){}this._hasConnected||await new Promise(e=>this._hasConnectedResolver=e);try{const e=this.performUpdate();null!=e&&await e}catch(e){t(e)}e(!this._hasRequestedUpdate)}get _hasConnected(){return 32&this._updateState}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let e=!1;const t=this._changedProperties;try{e=this.shouldUpdate(t),e&&this.update(t)}catch(t){throw e=!1,t}finally{this._markUpdated()}e&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(t)),this.updated(t))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((e,t)=>this._propertyToAttribute(t,this[t],e)),this._reflectingProperties=void 0)}updated(e){}firstUpdated(e){}}z.finalized=!0;const J="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,K=Symbol();class X{constructor(e,t){if(t!==K)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return void 0===this._styleSheet&&(J?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Y=(e,...t)=>{const i=t.reduce((t,i,n)=>t+(e=>{if(e instanceof X)return e.cssText;if("number"==typeof e)return e;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${e}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+e[n+1],e[0]);return new X(i,K)};(window.litElementVersions||(window.litElementVersions=[])).push("2.2.1");const G=e=>e.flat?e.flat(1/0):function e(t,i=[]){for(let n=0,s=t.length;n<s;n++){const s=t[n];Array.isArray(s)?e(s,i):i.push(s)}return i}(e);class Q extends z{static finalize(){super.finalize.call(this),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const e=this.styles,t=[];if(Array.isArray(e)){G(e).reduceRight((e,t)=>(e.add(t),e),new Set).forEach(e=>t.unshift(e))}else e&&t.push(e);return t}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?J?this.renderRoot.adoptedStyleSheets=e.map(e=>e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){super.update(e);const t=this.render();t instanceof g&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){}}Q.finalized=!0,Q.render=(e,t,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const s=i.scopeName,o=R.has(t),r=W&&11===t.nodeType&&!!t.host,a=r&&!F.has(s),l=a?document.createDocumentFragment():t;if(((e,t,i)=>{let s=R.get(t);void 0===s&&(n(t,t.firstChild),R.set(t,s=new S(Object.assign({templateFactory:P},i))),s.appendInto(t)),s.setValue(e),s.commit()})(e,l,Object.assign({templateFactory:V(s)},i)),a){const e=R.get(l);R.delete(l);const i=e.value instanceof m?e.value.template:void 0;j(s,l,i),n(t,t.firstChild),t.appendChild(l),R.set(t,e)}!o&&r&&window.ShadyCSS.styleElement(t.host)};let Z=null;const ee=e=>{if(!Z){const t="1snn5n9w",i="airwallex_cybs",n=document.createElement("script");Z=`${e}${Date.now()}`,n.src=`https://h.online-metrix.net/fp/tags.js?org_id=${t}&session_id=${i}${Z}`,document.body.appendChild(n)}return Z};class te{constructor(e,t){var i;this.addResizeListener=e=>{window.addEventListener("message",t=>{var i,n,s,o;if(t.origin===this.gatewayUrl&&t.isTrusted&&"onResize"===(null===(i=t.data)||void 0===i?void 0:i.code)&&e===(null===(n=t.data)||void 0===n?void 0:n.type)){const e=null===(s=this.iframe)||void 0===s?void 0:s.style;e&&(e.height=`${null===(o=t.data)||void 0===o?void 0:o.height}px`)}})},this.domElement="",this.gatewayUrl=e,this.options=t,this.iframe=window.document.createElement("iframe"),this.iframe.setAttribute("frameborder","0"),this.iframe.setAttribute("allowtransparency","true"),this.iframe.setAttribute("importance","high"),this.iframe.setAttribute("scrolling","no"),this.iframe.setAttribute("allowpaymentrequest","true"),null===(i=this.iframe)||void 0===i||i.setAttribute("style","\n height: 0;\n width: 100%;\n "),window.addEventListener("message",e=>{var t,i,n;if(e.origin===this.gatewayUrl&&e.isTrusted&&"onReady"===(null===(t=e.data)||void 0===t?void 0:t.code)){const t=new CustomEvent(null===(i=e.data)||void 0===i?void 0:i.code,{detail:{type:null===(n=e.data)||void 0===n?void 0:n.type},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}})}mount(e){var t;this.domElement=e,"string"!=typeof e?this.iframe&&e.appendChild(this.iframe):this.iframe&&(null===(t=window.document.getElementById(e))||void 0===t||t.appendChild(this.iframe))}blur(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"blur"},this.gatewayUrl)}clear(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"clear"},this.gatewayUrl)}destroy(){var e;null===(e=this.iframe)||void 0===e||e.remove(),this.iframe=null}focus(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"focus"},this.gatewayUrl)}unmount(){var e;"string"!=typeof this.domElement?this.iframe&&this.domElement.removeChild(this.iframe):this.iframe&&(null===(e=window.document.getElementById(this.domElement))||void 0===e||e.removeChild(this.iframe))}}class ie extends te{constructor(e,t,i){var n,s,o;super(e,i),this.confirmResponse=t,null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/3ds-frictionless?options=${JSON.stringify(this.options)}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex 3DS frictionless iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex 3DS frictionless iframe"),window.addEventListener("message",e=>{var t,i,n,s;e.origin===this.gatewayUrl&&e.isTrusted&&"onReady"===(null===(t=e.data)||void 0===t?void 0:t.code)&&"3DSFrictionless"===(null===(i=e.data)||void 0===i?void 0:i.type)&&(null===(s=null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)||void 0===s||s.postMessage({code:"update",data:this.confirmResponse},this.gatewayUrl))})}async confirm(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"confirm",data:{...this.confirmResponse,deviceId:ee()}},this.gatewayUrl)}}class ne extends te{constructor(e,t,i){var n,s,o,r,a,l;super(e,i),this.confirmResponse=t,null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/3ds-challenge?options=${JSON.stringify(this.options)}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex 3DS challenge iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex 3DS challenge iframe"),null===(r=this.iframe)||void 0===r||r.setAttribute("style",`\n position: absolute;\n background: #fff;\n top: 50%;\n left: 50%;\n width: 100%;\n transform: translate(-50%, -50%);\n height: ${null!==(a=null==i?void 0:i.popupHeight)&&void 0!==a?a:"695"}px;\n width: ${null!==(l=null==i?void 0:i.popupWidth)&&void 0!==l?l:"415"}px;\n border-radius: 4px;\n `),window.addEventListener("message",e=>{var t,i,n,s;e.origin===this.gatewayUrl&&e.isTrusted&&"onReady"===(null===(t=e.data)||void 0===t?void 0:t.code)&&"3DSChallenge"===(null===(i=e.data)||void 0===i?void 0:i.type)&&(null===(s=null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)||void 0===s||s.postMessage({code:"update",data:this.confirmResponse},this.gatewayUrl))})}async confirm(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"confirm",data:{...this.confirmResponse,deviceId:ee()}},this.gatewayUrl)}}const se=(e,t)=>{var i,n;"3DSFrictionless"===t?(null===(i=e.threeDsFrictionless)||void 0===i||i.clear(),e.threeDsFrictionless=null):(null===(n=e.threeDsChallenge)||void 0===n||n.clear(),e.threeDsChallenge=null);const s=document.getElementById(t);s&&document.body.removeChild(s)},oe=({elements:e,element:t,gatewayUrl:i,type:n,popupWidth:s,popupHeight:o})=>{window.addEventListener("message",r=>{var a,l,d;if(r.origin===i&&r.isTrusted&&(null===(a=r.data)||void 0===a?void 0:a.type)===n&&"onChallenge"===(null===(l=r.data)||void 0===l?void 0:l.code)){const n="3DSFrictionless";e.threeDsFrictionless=new ie(i,null===(d=r.data)||void 0===d?void 0:d.data,{origin:window.location.origin}),window.addEventListener("message",s=>{var o,r,a,l,d,c;if(s.origin===i&&s.isTrusted&&(null===(o=null==s?void 0:s.data)||void 0===o?void 0:o.type)===n){const{type:i,error:n,...o}=s.data;"onChallengeSuccess"===(null===(r=s.data)||void 0===r?void 0:r.code)&&(null===(a=e.threeDsFrictionless)||void 0===a||a.confirm()),"onSuccess"===(null===(l=s.data)||void 0===l?void 0:l.code)&&(se(e,i),null==t||t.success(o)),"onError"===(null===(d=s.data)||void 0===d?void 0:d.code)&&(null==t||t.cancel(n),se(e,i)),"onChallengeError"===(null===(c=s.data)||void 0===c?void 0:c.code)&&(null==t||t.cancel(n),se(e,i))}});const a=document.createElement("div");a.setAttribute("id",n),document.body.appendChild(a),e.threeDsFrictionless.mount(a),window.addEventListener("message",n=>{var r,a,l;if(n.origin===i&&n.isTrusted&&"3DSFrictionless"===(null===(r=null==n?void 0:n.data)||void 0===r?void 0:r.type)&&"onChallenge"===(null===(a=n.data)||void 0===a?void 0:a.code)){const r="3DSChallenge",a=document.createElement("div");se(e,"3DSFrictionless"),e.threeDsChallenge=new ne(i,null===(l=n.data)||void 0===l?void 0:l.data,{origin:window.location.origin,popupWidth:s,popupHeight:o}),window.addEventListener("message",n=>{var s,o,l,d,c,u,h;if(n.origin===i&&n.isTrusted&&(null===(s=null==n?void 0:n.data)||void 0===s?void 0:s.type)===r){const{type:i,error:s,...r}=n.data;"onReady"===(null===(o=n.data)||void 0===o?void 0:o.code)&&setTimeout(()=>{a.style.height="100%"},2e3),"onChallengeSuccess"===(null===(l=n.data)||void 0===l?void 0:l.code)&&(a.style.height="0",null===(d=e.threeDsChallenge)||void 0===d||d.confirm()),"onSuccess"===(null===(c=n.data)||void 0===c?void 0:c.code)&&(se(e,i),null==t||t.success(r)),"onError"===(null===(u=n.data)||void 0===u?void 0:u.code)&&(se(e,i),null==t||t.cancel(s)),"onChallengeError"===(null===(h=n.data)||void 0===h?void 0:h.code)&&(se(e,i),null==t||t.cancel(s))}}),a.setAttribute("id",r),a.setAttribute("style","\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 0;\n z-index: 1500;\n overflow: hidden;\n background: rgba(0, 0, 0, 0.75);\n "),document.body.appendChild(a),e.threeDsChallenge.mount(a)}})}})};class re extends te{constructor(e,t,i){var n,s,o;super(e,i),this.retrieve={resolver:null,reject:null,awaiting:!1},this.confirmIntent={resolver:null,reject:null,awaiting:!1},this.createMethod={resolver:null,reject:null,awaiting:!1},this.options=i,null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/card-number?options=${JSON.stringify(this.options)}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex card number element iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex card number element iframe"),this.addResizeListener("cardNumber"),window.addEventListener("message",n=>{var s,o,r,a,l,d,c,u,h,p,m,v,g,w,f,y,_,S,b,C,x;if(n.origin===this.gatewayUrl&&n.isTrusted&&"cardNumber"===(null===(s=null==n?void 0:n.data)||void 0===s?void 0:s.type)){if("onSubmit"===(null===(o=n.data)||void 0===o?void 0:o.code)){const e=new CustomEvent(null===(r=n.data)||void 0===r?void 0:r.code,{detail:{},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}if("onReady"===(null===(a=n.data)||void 0===a?void 0:a.code)&&oe({elements:t,element:null==t?void 0:t.cardNumber,gatewayUrl:e,type:"cardNumber",popupWidth:null==i?void 0:i.popupWidth,popupHeight:null==i?void 0:i.popupHeight}),"onSuccess"===(null===(l=n.data)||void 0===l?void 0:l.code)&&(this.confirmIntent.resolver(n.data),this.confirmIntent.awaiting=!1),"onError"===(null===(d=n.data)||void 0===d?void 0:d.code)&&(this.confirmIntent.reject(n.data),this.confirmIntent.awaiting=!1),"onRetrieveIntent"===(null===(c=n.data)||void 0===c?void 0:c.code)&&(this.retrieve.resolver(n.data),this.retrieve.awaiting=!1),"onRetrieveIntentError"===(null===(u=n.data)||void 0===u?void 0:u.code)&&(this.retrieve.reject(n.data),this.retrieve.awaiting=!1),"onPaymentMethodCreated"===(null===(h=n.data)||void 0===h?void 0:h.code)&&(this.createMethod.resolver(n.data),this.createMethod.awaiting=!1),"onPaymentMethodCreatedError"===(null===(p=n.data)||void 0===p?void 0:p.code)&&(this.createMethod.reject(n.data),this.createMethod.awaiting=!1),["onFocus","onBlur","onChange"].includes(null===(m=n.data)||void 0===m?void 0:m.code)){const e=new CustomEvent(null===(v=n.data)||void 0===v?void 0:v.code,{detail:{type:"cardNumber",complete:null!==(w=null===(g=n.data)||void 0===g?void 0:g.complete)&&void 0!==w&&w,empty:null!==(y=null===(f=n.data)||void 0===f?void 0:f.empty)&&void 0!==y&&y,error:null===(_=n.data)||void 0===_?void 0:_.error,bankName:null!==(b=null===(S=n.data)||void 0===S?void 0:S.bankName)&&void 0!==b?b:"",brand:null!==(x=null===(C=n.data)||void 0===C?void 0:C.brand)&&void 0!==x?x:""},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}}})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}async confirm(e){var t,i;this.confirmIntent.awaiting&&console.warn("Should waiting previous confirm finished before execute new one!");const{intentId:n}=e||{},s=ee(n||"");return null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"confirm",data:{...e,deviceId:s}},this.gatewayUrl),new Promise((e,t)=>{this.confirmIntent.resolver=e,this.confirmIntent.reject=t,this.confirmIntent.awaiting=!0})}async createPaymentMethod(e){var t,i;return this.createMethod.awaiting&&console.warn("Should waiting previous createPaymentMethod finished before execute new one!"),null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"createPaymentMethod",data:e},this.gatewayUrl),new Promise((e,t)=>{this.createMethod.resolver=e,this.createMethod.reject=t,this.createMethod.awaiting=!0})}async getPaymentIntent(e,t){var i,n;return this.retrieve.awaiting&&console.warn("Should waiting previous getPaymentIntent finished before execute new one!"),null===(n=null===(i=this.iframe)||void 0===i?void 0:i.contentWindow)||void 0===n||n.postMessage({code:"getIntent",intentId:e,clientSecret:t},this.gatewayUrl),new Promise((e,t)=>{this.retrieve.resolver=e,this.retrieve.reject=t,this.retrieve.awaiting=!0})}success(e){this.confirmIntent.resolver(e),this.confirmIntent.awaiting=!1}cancel(e="cancelled"){this.confirmIntent.awaiting&&this.confirmIntent.reject({reason:e}),this.retrieve.awaiting&&this.retrieve.reject({reason:e}),this.createMethod.awaiting&&this.createMethod.reject({reason:e}),this.retrieve={resolver:null,reject:null,awaiting:!1},this.confirmIntent={resolver:null,reject:null,awaiting:!1},this.createMethod={resolver:null,reject:null,awaiting:!1}}}class ae extends te{constructor(e,t){var i,n,s;super(e,t),null===(i=this.iframe)||void 0===i||i.setAttribute("src",`${e}/elements/expiry?options=${JSON.stringify(this.options)}`),null===(n=this.iframe)||void 0===n||n.setAttribute("name","Airwallex expiry number element iframe"),null===(s=this.iframe)||void 0===s||s.setAttribute("title","Airwallex expiry number element iframe"),this.addResizeListener("expiry"),window.addEventListener("message",e=>{var t,i,n;if(e.origin===this.gatewayUrl&&e.isTrusted&&"expiry"===(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.type)&&["onFocus","onBlur","onChange"].includes(null===(i=e.data)||void 0===i?void 0:i.code)){const t=new CustomEvent(null===(n=e.data)||void 0===n?void 0:n.code,{detail:{type:"expiry",complete:!0,empty:!1,error:void 0},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}}class le extends te{constructor(e,t){var i,n,s;super(e,t),null===(i=this.iframe)||void 0===i||i.setAttribute("src",`${e}/elements/cvc?options=${JSON.stringify(this.options)}`),null===(n=this.iframe)||void 0===n||n.setAttribute("name","Airwallex cvc number element iframe"),null===(s=this.iframe)||void 0===s||s.setAttribute("title","Airwallex cvc number element iframe"),this.addResizeListener("cvc"),window.addEventListener("message",e=>{var t,i,n,s,o,r,a;if(e.origin===this.gatewayUrl&&e.isTrusted)if("cvc"===(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.type)&&["onFocus","onBlur","onChange"].includes(null===(i=e.data)||void 0===i?void 0:i.code)){const t=new CustomEvent(null===(n=e.data)||void 0===n?void 0:n.code,{detail:{type:"cvc",complete:!0,empty:!1,error:void 0},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}else"cardNumber"===(null===(s=e.data)||void 0===s?void 0:s.type)&&"onChange"===(null===(o=e.data)||void 0===o?void 0:o.code)&&(null===(a=null===(r=this.iframe)||void 0===r?void 0:r.contentWindow)||void 0===a||a.postMessage({code:"update",options:{cvcLength:e.data.cvcLength}},this.gatewayUrl))})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}}class de extends te{constructor(e,t,i){var n,s,o;super(e,i);const{intent:r,...a}=i||{},l=ee(null==r?void 0:r.id);null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/payment-request-button?options=${encodeURIComponent(JSON.stringify({...a,deviceId:l}))}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex payment request element iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex payment request element iframe"),this.addResizeListener("paymentRequestButton"),window.addEventListener("message",n=>{var s,o,a,l,d,c;n.origin===this.gatewayUrl&&n.isTrusted&&"paymentRequestButton"===(null===(s=n.data)||void 0===s?void 0:s.type)&&("onReady"===(null===(o=n.data)||void 0===o?void 0:o.code)?(oe({elements:t,element:null==t?void 0:t.paymentRequestButton,gatewayUrl:e,type:"paymentRequestButton",popupWidth:null==i?void 0:i.popupWidth,popupHeight:null==i?void 0:i.popupHeight}),null===(l=null===(a=this.iframe)||void 0===a?void 0:a.contentWindow)||void 0===l||l.postMessage({code:"update",options:{intent:r}},this.gatewayUrl)):"onSuccess"===(null===(d=n.data)||void 0===d?void 0:d.code)?this.success(n.data):"onError"===(null===(c=n.data)||void 0===c?void 0:c.code)&&this.cancel(n.data))})}update(e){var t,i;this.options={...this.options,...e};const{intent:n}=this.options||{},s=ee(null==n?void 0:n.id);null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:{...e,deviceId:s}},this.gatewayUrl)}success(e){const t=new CustomEvent("CONFIRM_SUCCESS",{detail:{component:"paymentRequestButton",...e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}cancel(e="cancelled"){const t=new CustomEvent("CONFIRM_FAIL",{detail:{component:"paymentRequestButton",error:e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}}class ce extends te{constructor(e,t,i){var n,s,o;super(e,i);const{intent:r,...a}=i||{},l=ee(null==r?void 0:r.id);null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/card?options=${encodeURIComponent(JSON.stringify({...a,deviceId:l}))}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex card element iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex card element iframe"),this.addResizeListener("card"),window.addEventListener("message",n=>{var s,o,a,l,d,c;n.origin===this.gatewayUrl&&n.isTrusted&&"card"===(null===(s=n.data)||void 0===s?void 0:s.type)&&("onReady"===(null===(o=n.data)||void 0===o?void 0:o.code)?(oe({elements:t,element:null==t?void 0:t.card,gatewayUrl:e,type:"card",popupWidth:null==i?void 0:i.popupWidth,popupHeight:null==i?void 0:i.popupHeight}),null===(l=null===(a=this.iframe)||void 0===a?void 0:a.contentWindow)||void 0===l||l.postMessage({code:"update",options:{intent:r}},this.gatewayUrl)):"onSuccess"===(null===(d=n.data)||void 0===d?void 0:d.code)?this.success(n.data):"onError"===(null===(c=n.data)||void 0===c?void 0:c.code)&&this.cancel(n.data))})}update(e){var t,i;this.options={...this.options,...e};const{intent:n}=this.options||{},s=ee(null==n?void 0:n.id);null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:{...e,deviceId:s}},this.gatewayUrl)}success(e){const t=new CustomEvent("CONFIRM_SUCCESS",{detail:{component:"card",...e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}cancel(e="cancelled"){const t=new CustomEvent("CONFIRM_FAIL",{detail:{component:"card",error:e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}}class ue extends te{constructor(e,t){var i,n,s;super(e,t);const{intent:o,...r}=t||{};null===(i=this.iframe)||void 0===i||i.setAttribute("src",`${e}/elements/wechat?options=${encodeURIComponent(JSON.stringify({...r}))}`),null===(n=this.iframe)||void 0===n||n.setAttribute("name","Airwallex wechat element iframe"),null===(s=this.iframe)||void 0===s||s.setAttribute("title","Airwallex wechat element iframe"),this.addResizeListener("wechat"),window.addEventListener("message",e=>{var t,i,n,s,r,a;e.origin===this.gatewayUrl&&e.isTrusted&&"wechat"===(null===(t=e.data)||void 0===t?void 0:t.type)&&("onReady"===(null===(i=e.data)||void 0===i?void 0:i.code)?null===(s=null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)||void 0===s||s.postMessage({code:"update",options:{intent:o}},this.gatewayUrl):"onSuccess"===(null===(r=e.data)||void 0===r?void 0:r.code)?this.success():"onError"===(null===(a=e.data)||void 0===a?void 0:a.code)&&this.cancel())})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}success(){const e=new CustomEvent("CONFIRM_SUCCESS",{detail:{component:"wechat"},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}cancel(){const e=new CustomEvent("CONFIRM_FAIL",{detail:{component:"wechat"},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}}const he={clientSecret:"",gatewayUrl:"",options:{},cvcLength:4},pe={cardNumber:null,expiry:null,cvc:null,threeDsFrictionless:null,threeDsChallenge:null,paymentRequestButton:null,card:null,wechat:null};customElements.define("airwallex-element",class extends Q{constructor(){super(),this.gatewayBaseurl=this.clientSecret=this.currency=this.intentId=this.customerId="",this.successUrl=this.cancelUrl=this.errorUrl=this.autoCapture=this.enable3dSecure=this.component="",this.theme={},this.height=0}static get properties(){return{gatewayBaseurl:{type:String,reflect:!0},clientSecret:{type:String,reflect:!0},currency:{type:String,reflect:!0},intentId:{type:String,reflect:!0},customerId:{type:String,reflect:!0},successUrl:{type:String,reflect:!0},cancelUrl:{type:String,reflect:!0},errorUrl:{type:String,reflect:!0},enable3dSecure:{type:String,reflect:!0},autoCapture:{type:String,reflect:!0},component:{type:String,reflect:!0},theme:{type:Object,reflect:!0},height:{type:Number,hasChanged:()=>!0}}}static get styles(){return Y`
:host {
width: 100%;
height: 100%;
}
`}handleEvent(e){console.info(`Airwallex Checkout Message: [${JSON.stringify(e)}]`);const t=new CustomEvent("airwallex-checkout",{detail:e,bubbles:!0,composed:!0});this.dispatchEvent(t)}checkoutEventHandler(e){if(e.origin===this.gatewayBaseurl&&e.isTrusted){const{style:t,...i}=e.data;if(this.height=(t&&t.height||0)+8,"AWX_CHECKOUT_STYLE"!==e.data.code&&this.handleEvent(i),"AWX_CHECKOUT_SUCCESS"===e.data.code){const t=`${e.data.status?`status=${e.data.status}`:""}${e.data.id?`&intentId=${e.data.id}`:""}`;this.successUrl&&(window.location.href=-1===this.successUrl.indexOf("?")?`${this.successUrl}?${t}`:`${this.successUrl}&${t}`)}else"AWX_CHECKOUT_CANCEL"===e.data.code?this.cancelUrl&&(window.location.href=this.cancelUrl):"AWX_CHECKOUT_ERROR"===e.data.code&&this.errorUrl&&(window.location.href=this.errorUrl);this.requestUpdate()}}connectedCallback(){super.connectedCallback(),window.addEventListener("message",e=>this.checkoutEventHandler(e))}disconnectedCallback(){window.removeEventListener("message",e=>this.checkoutEventHandler(e)),super.disconnectedCallback()}render(){const e=`${this.gatewayBaseurl}/checkout/${this.intentId}?origin=${window.location.origin}&customerId=${this.customerId}&currency=${this.currency}&theme=${encodeURIComponent(JSON.stringify(this.theme))}&autoCapture=${this.autoCapture}&component=${this.component}&enable3dSecure=${this.enable3dSecure}&clientSecret=${encodeURIComponent(this.clientSecret)}&deviceId=${ee(this.intentId)}`;return $`
<style>
iframe {
width: 100%;
background: white;
height: ${this.height}px;
}
</style>
<iframe
frameborder="0"
allowtransparency="true"
importance="high"
scrolling="no"
name="${"airwallex_checkout_frame"}"
allowpaymentrequest="true"
src="${e}"
title="Secured airwallex payment frame"
/>
`}}),exports.confirmPaymentIntent=async(e,t)=>{console.info(`Confirm with client secret: ${e}`);const{element:i,...n}=t||{};return i?i.confirm(n):t.paymentMethodId?(console.warn("Confirm with payment method id is working in progress!"),!0):(console.warn("Either payment method id or element must be provided for card payment confirm!"),!1)},exports.createElement=(e,t)=>["cardNumber","expiry","cvc","paymentRequestButton","card","wechat"].includes(e)?"cardNumber"===e?(pe[e]=new re(he.gatewayUrl,pe,{clientSecret:he.clientSecret,...he.options,...t}),pe[e]):"card"===e?(pe[e]=new ce(he.gatewayUrl,pe,{clientSecret:he.clientSecret,...he.options,...t}),pe[e]):"wechat"===e?(pe[e]=new ue(he.gatewayUrl,{clientSecret:he.clientSecret,...he.options,...t}),pe[e]):"paymentRequestButton"===e?(pe[e]=new de(he.gatewayUrl,pe,{clientSecret:he.clientSecret,...he.options,...t}),pe[e]):"expiry"===e||"cvc"===e?(pe[e]="expiry"===e?new ae(he.gatewayUrl,{...he.options,...t}):new le(he.gatewayUrl,{...he.options,cvcLength:he.cvcLength,...t}),window.addEventListener("message",e=>{var t,i,n,s,o,r;e.origin===he.gatewayUrl&&e.isTrusted&&["expiry","cvc"].includes(null===(t=e.data)||void 0===t?void 0:t.type)&&"onChange"===(null===(i=e.data)||void 0===i?void 0:i.code)&&(null===(o=null===(s=null===(n=pe.cardNumber)||void 0===n?void 0:n.iframe)||void 0===s?void 0:s.contentWindow)||void 0===o||o.postMessage({code:`update_${null===(r=e.data)||void 0===r?void 0:r.type}`,data:e.data},he.gatewayUrl))}),pe[e]):null:(console.warn(`createElement with type: ${e} not support!`),null),exports.createPaymentMethod=async(e,t)=>(console.info(`Confirm with client secret: ${e}`),t.element?t.element.createPaymentMethod(t):(console.warn("Either payment method id or element must be provided for payment method create!"),!1)),exports.destroyElement=e=>{var t;return["cardNumber","expiry","cvc","paymentRequestButton","card","wechat"].includes(e)?(null===(t=pe[e])||void 0===t||t.destroy(),pe[e]=null,!0):(console.warn(`destroyElement with type: ${e} not support!`),!1)},exports.getElement=e=>["cardNumber","expiry","cvc","paymentRequestButton","card","wechat"].includes(e)?pe[e]:(console.warn(`getElement with type: ${e} not support!`),null),exports.getPaymentIntent=async(e,t)=>{var i;return(null===(i=pe.cardNumber)||void 0===i?void 0:i.getPaymentIntent(e,t))||!1},exports.init=(e,t,i)=>{he.clientSecret=e,he.gatewayUrl=t,he.options=i};
/* Airwallex @Charlie.Lang */
//# sourceMappingURL=airwallex.cjs.js.map

@@ -1,4 +0,27 @@

/* Airwallex Checkout Component Version [0.0.55] */
const e="https://checkout.airwallex.com/assets/bundle.min.js",r=Promise.resolve().then(()=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;const r=document.querySelector(`script[src="${e}"], script[src="${e}/"]`)||(()=>{const r=document.createElement("script");r.src=e;const o=document.head||document.body;if(!o)throw new Error("Expected document.body not to be null. Airwallex.js requires a <head> or <body> element.");return o.appendChild(r),r})();return new Promise((e,o)=>{r.addEventListener("load",()=>{window.Airwallex?e():o(new Error("Failed to load Airwallex.js"))}),r.addEventListener("error",()=>{o(new Error("Failed to load Airwallex.js"))})})}),o=()=>r;export{o as loadAirwallex};
/* Airwallex Checkout Component Version [0.0.56] */
const e=new WeakMap,t=t=>"function"==typeof t&&e.has(t),i=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,n=(e,t,i=null)=>{for(;t!==i;){const i=t.nextSibling;e.removeChild(t),t=i}},s={},o={},r=`{{lit-${String(Math.random()).slice(2)}}}`,a=`\x3c!--${r}--\x3e`,l=new RegExp(`${r}|${a}`);class d{constructor(e,t){this.parts=[],this.element=t;const i=[],n=[],s=document.createTreeWalker(t.content,133,null,!1);let o=0,a=-1,d=0;const{strings:u,values:{length:m}}=e;for(;d<m;){const e=s.nextNode();if(null!==e){if(a++,1===e.nodeType){if(e.hasAttributes()){const t=e.attributes,{length:i}=t;let n=0;for(let e=0;e<i;e++)c(t[e].name,"$lit$")&&n++;for(;n-- >0;){const t=u[d],i=p.exec(t)[2],n=i.toLowerCase()+"$lit$",s=e.getAttribute(n);e.removeAttribute(n);const o=s.split(l);this.parts.push({type:"attribute",index:a,name:i,strings:o}),d+=o.length-1}}"TEMPLATE"===e.tagName&&(n.push(e),s.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(r)>=0){const n=e.parentNode,s=t.split(l),o=s.length-1;for(let t=0;t<o;t++){let i,o=s[t];if(""===o)i=h();else{const e=p.exec(o);null!==e&&c(e[2],"$lit$")&&(o=o.slice(0,e.index)+e[1]+e[2].slice(0,-"$lit$".length)+e[3]),i=document.createTextNode(o)}n.insertBefore(i,e),this.parts.push({type:"node",index:++a})}""===s[o]?(n.insertBefore(h(),e),i.push(e)):e.data=s[o],d+=o}}else if(8===e.nodeType)if(e.data===r){const t=e.parentNode;null!==e.previousSibling&&a!==o||(a++,t.insertBefore(h(),e)),o=a,this.parts.push({type:"node",index:a}),null===e.nextSibling?e.data="":(i.push(e),a--),d++}else{let t=-1;for(;-1!==(t=e.data.indexOf(r,t+1));)this.parts.push({type:"node",index:-1}),d++}}else s.currentNode=n.pop()}for(const e of i)e.parentNode.removeChild(e)}}const c=(e,t)=>{const i=e.length-t.length;return i>=0&&e.slice(i)===t},u=e=>-1!==e.index,h=()=>document.createComment(""),p=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class m{constructor(e,t,i){this.__parts=[],this.template=e,this.processor=t,this.options=i}update(e){let t=0;for(const i of this.__parts)void 0!==i&&i.setValue(e[t]),t++;for(const e of this.__parts)void 0!==e&&e.commit()}_clone(){const e=i?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),t=[],n=this.template.parts,s=document.createTreeWalker(e,133,null,!1);let o,r=0,a=0,l=s.nextNode();for(;r<n.length;)if(o=n[r],u(o)){for(;a<o.index;)a++,"TEMPLATE"===l.nodeName&&(t.push(l),s.currentNode=l.content),null===(l=s.nextNode())&&(s.currentNode=t.pop(),l=s.nextNode());if("node"===o.type){const e=this.processor.handleTextExpression(this.options);e.insertAfterNode(l.previousSibling),this.__parts.push(e)}else this.__parts.push(...this.processor.handleAttributeExpressions(l,o.name,o.strings,this.options));r++}else this.__parts.push(void 0),r++;return i&&(document.adoptNode(e),customElements.upgrade(e)),e}}const v=` ${r} `;class g{constructor(e,t,i,n){this.strings=e,this.values=t,this.type=i,this.processor=n}getHTML(){const e=this.strings.length-1;let t="",i=!1;for(let n=0;n<e;n++){const e=this.strings[n],s=e.lastIndexOf("\x3c!--");i=(s>-1||i)&&-1===e.indexOf("--\x3e",s+1);const o=p.exec(e);t+=null===o?e+(i?v:a):e.substr(0,o.index)+o[1]+o[2]+"$lit$"+o[3]+r}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");return e.innerHTML=this.getHTML(),e}}const w=e=>null===e||!("object"==typeof e||"function"==typeof e),f=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class y{constructor(e,t,i){this.dirty=!0,this.element=e,this.name=t,this.strings=i,this.parts=[];for(let e=0;e<i.length-1;e++)this.parts[e]=this._createPart()}_createPart(){return new _(this)}_getValue(){const e=this.strings,t=e.length-1;let i="";for(let n=0;n<t;n++){i+=e[n];const t=this.parts[n];if(void 0!==t){const e=t.value;if(w(e)||!f(e))i+="string"==typeof e?e:String(e);else for(const t of e)i+="string"==typeof t?t:String(t)}}return i+=e[t],i}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class _{constructor(e){this.value=void 0,this.committer=e}setValue(e){e===s||w(e)&&e===this.value||(this.value=e,t(e)||(this.committer.dirty=!0))}commit(){for(;t(this.value);){const e=this.value;this.value=s,e(this)}this.value!==s&&this.committer.commit()}}class S{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(h()),this.endNode=e.appendChild(h())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=h()),e.__insert(this.endNode=h())}insertAfterPart(e){e.__insert(this.startNode=h()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){for(;t(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=s,e(this)}const e=this.__pendingValue;e!==s&&(w(e)?e!==this.value&&this.__commitText(e):e instanceof g?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):f(e)?this.__commitIterable(e):e===o?(this.value=o,this.clear()):this.__commitText(e))}__insert(e){this.endNode.parentNode.insertBefore(e,this.endNode)}__commitNode(e){this.value!==e&&(this.clear(),this.__insert(e),this.value=e)}__commitText(e){const t=this.startNode.nextSibling,i="string"==typeof(e=null==e?"":e)?e:String(e);t===this.endNode.previousSibling&&3===t.nodeType?t.data=i:this.__commitNode(document.createTextNode(i)),this.value=e}__commitTemplateResult(e){const t=this.options.templateFactory(e);if(this.value instanceof m&&this.value.template===t)this.value.update(e.values);else{const i=new m(t,e.processor,this.options),n=i._clone();i.update(e.values),this.__commitNode(n),this.value=i}}__commitIterable(e){Array.isArray(this.value)||(this.value=[],this.clear());const t=this.value;let i,n=0;for(const s of e)i=t[n],void 0===i&&(i=new S(this.options),t.push(i),0===n?i.appendIntoPart(this):i.insertAfterPart(t[n-1])),i.setValue(s),i.commit(),n++;n<t.length&&(t.length=n,this.clear(i&&i.endNode))}clear(e=this.startNode){n(this.startNode.parentNode,e.nextSibling,this.endNode)}}class b{constructor(e,t,i){if(this.value=void 0,this.__pendingValue=void 0,2!==i.length||""!==i[0]||""!==i[1])throw new Error("Boolean attributes can only contain a single expression");this.element=e,this.name=t,this.strings=i}setValue(e){this.__pendingValue=e}commit(){for(;t(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=s,e(this)}if(this.__pendingValue===s)return;const e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=s}}class C extends y{constructor(e,t,i){super(e,t,i),this.single=2===i.length&&""===i[0]&&""===i[1]}_createPart(){return new x(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class x extends _{}let E=!1;try{const e={get capture(){return E=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}class A{constructor(e,t,i){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=i,this.__boundHandleEvent=e=>this.handleEvent(e)}setValue(e){this.__pendingValue=e}commit(){for(;t(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=s,e(this)}if(this.__pendingValue===s)return;const e=this.__pendingValue,i=this.value,n=null==e||null!=i&&(e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive),o=null!=e&&(null==i||n);n&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),o&&(this.__options=N(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=s}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}}const N=e=>e&&(E?{capture:e.capture,passive:e.passive,once:e.once}:e.capture);const U=new class{handleAttributeExpressions(e,t,i,n){const s=t[0];if("."===s){return new C(e,t.slice(1),i).parts}return"@"===s?[new A(e,t.slice(1),n.eventContext)]:"?"===s?[new b(e,t.slice(1),i)]:new y(e,t,i).parts}handleTextExpression(e){return new S(e)}};function P(e){let t=T.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},T.set(e.type,t));let i=t.stringsArray.get(e.strings);if(void 0!==i)return i;const n=e.strings.join(r);return i=t.keyString.get(n),void 0===i&&(i=new d(e,e.getTemplateElement()),t.keyString.set(n,i)),t.stringsArray.set(e.strings,i),i}const T=new Map,R=new WeakMap;(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.1.2");const $=(e,...t)=>new g(e,t,"html",U);function M(e,t){const{element:{content:i},parts:n}=e,s=document.createTreeWalker(i,133,null,!1);let o=O(n),r=n[o],a=-1,l=0;const d=[];let c=null;for(;s.nextNode();){a++;const e=s.currentNode;for(e.previousSibling===c&&(c=null),t.has(e)&&(d.push(e),null===c&&(c=e)),null!==c&&l++;void 0!==r&&r.index===a;)r.index=null!==c?-1:r.index-l,o=O(n,o),r=n[o]}d.forEach(e=>e.parentNode.removeChild(e))}const I=e=>{let t=11===e.nodeType?0:1;const i=document.createTreeWalker(e,133,null,!1);for(;i.nextNode();)t++;return t},O=(e,t=-1)=>{for(let i=t+1;i<e.length;i++){const t=e[i];if(u(t))return i}return-1};const L=(e,t)=>`${e}--${t}`;let W=!0;void 0===window.ShadyCSS?W=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),W=!1);const V=e=>t=>{const i=L(t.type,e);let n=T.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},T.set(i,n));let s=n.stringsArray.get(t.strings);if(void 0!==s)return s;const o=t.strings.join(r);if(s=n.keyString.get(o),void 0===s){const i=t.getTemplateElement();W&&window.ShadyCSS.prepareTemplateDom(i,e),s=new d(t,i),n.keyString.set(o,s)}return n.stringsArray.set(t.strings,s),s},k=["html","svg"],F=new Set,q=(e,t,i)=>{F.add(e);const n=i?i.element:document.createElement("template"),s=t.querySelectorAll("style"),{length:o}=s;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(n,e);const r=document.createElement("style");for(let e=0;e<o;e++){const t=s[e];t.parentNode.removeChild(t),r.textContent+=t.textContent}(e=>{k.forEach(t=>{const i=T.get(L(t,e));void 0!==i&&i.keyString.forEach(e=>{const{element:{content:t}}=e,i=new Set;Array.from(t.querySelectorAll("style")).forEach(e=>{i.add(e)}),M(e,i)})})})(e);const a=n.content;i?function(e,t,i=null){const{element:{content:n},parts:s}=e;if(null==i)return void n.appendChild(t);const o=document.createTreeWalker(n,133,null,!1);let r=O(s),a=0,l=-1;for(;o.nextNode();){for(l++,o.currentNode===i&&(a=I(t),i.parentNode.insertBefore(t,i));-1!==r&&s[r].index===l;){if(a>0){for(;-1!==r;)s[r].index+=a,r=O(s,r);return}r=O(s,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,e);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)t.insertBefore(l.cloneNode(!0),t.firstChild);else if(i){a.insertBefore(r,a.firstChild);const e=new Set;e.add(r),M(i,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const j={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},B=(e,t)=>t!==e&&(t==t||e==e),D={attribute:!0,type:String,converter:j,reflect:!1,hasChanged:B},H=Promise.resolve(!0);class z extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=H,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach((t,i)=>{const n=this._attributeNameForProperty(i,t);void 0!==n&&(this._attributeToPropertyMap.set(n,i),e.push(n))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach((e,t)=>this._classProperties.set(t,e))}}static createProperty(e,t=D){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const i="symbol"==typeof e?Symbol():`__${e}`;Object.defineProperty(this.prototype,e,{get(){return this[i]},set(t){const n=this[e];this[i]=t,this._requestUpdate(e,n)},configurable:!0,enumerable:!0})}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty("finalized")||e.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]];for(const i of t)this.createProperty(i,e[i])}}static _attributeNameForProperty(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}static _valueHasChanged(e,t,i=B){return i(e,t)}static _propertyValueFromAttribute(e,t){const i=t.type,n=t.converter||j,s="function"==typeof n?n:n.fromAttribute;return s?s(e,i):e}static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const i=t.type,n=t.converter;return(n&&n.toAttribute||j.toAttribute)(e,i)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach((e,t)=>{if(this.hasOwnProperty(t)){const e=this[t];delete this[t],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(t,e)}})}_applyInstanceProperties(){this._instanceProperties.forEach((e,t)=>this[t]=e),this._instanceProperties=void 0}connectedCallback(){this._updateState=32|this._updateState,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,t,i){t!==i&&this._attributeToProperty(e,i)}_propertyToAttribute(e,t,i=D){const n=this.constructor,s=n._attributeNameForProperty(e,i);if(void 0!==s){const e=n._propertyValueToAttribute(t,i);if(void 0===e)return;this._updateState=8|this._updateState,null==e?this.removeAttribute(s):this.setAttribute(s,e),this._updateState=-9&this._updateState}}_attributeToProperty(e,t){if(8&this._updateState)return;const i=this.constructor,n=i._attributeToPropertyMap.get(e);if(void 0!==n){const e=i._classProperties.get(n)||D;this._updateState=16|this._updateState,this[n]=i._propertyValueFromAttribute(t,e),this._updateState=-17&this._updateState}}_requestUpdate(e,t){let i=!0;if(void 0!==e){const n=this.constructor,s=n._classProperties.get(e)||D;n._valueHasChanged(this[e],t,s.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,t),!0!==s.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,s))):i=!1}!this._hasRequestedUpdate&&i&&this._enqueueUpdate()}requestUpdate(e,t){return this._requestUpdate(e,t),this.updateComplete}async _enqueueUpdate(){let e,t;this._updateState=4|this._updateState;const i=this._updatePromise;this._updatePromise=new Promise((i,n)=>{e=i,t=n});try{await i}catch(e){}this._hasConnected||await new Promise(e=>this._hasConnectedResolver=e);try{const e=this.performUpdate();null!=e&&await e}catch(e){t(e)}e(!this._hasRequestedUpdate)}get _hasConnected(){return 32&this._updateState}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let e=!1;const t=this._changedProperties;try{e=this.shouldUpdate(t),e&&this.update(t)}catch(t){throw e=!1,t}finally{this._markUpdated()}e&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(t)),this.updated(t))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((e,t)=>this._propertyToAttribute(t,this[t],e)),this._reflectingProperties=void 0)}updated(e){}firstUpdated(e){}}z.finalized=!0;const J="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,K=Symbol();class X{constructor(e,t){if(t!==K)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return void 0===this._styleSheet&&(J?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Y=(e,...t)=>{const i=t.reduce((t,i,n)=>t+(e=>{if(e instanceof X)return e.cssText;if("number"==typeof e)return e;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${e}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+e[n+1],e[0]);return new X(i,K)};(window.litElementVersions||(window.litElementVersions=[])).push("2.2.1");const G=e=>e.flat?e.flat(1/0):function e(t,i=[]){for(let n=0,s=t.length;n<s;n++){const s=t[n];Array.isArray(s)?e(s,i):i.push(s)}return i}(e);class Q extends z{static finalize(){super.finalize.call(this),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const e=this.styles,t=[];if(Array.isArray(e)){G(e).reduceRight((e,t)=>(e.add(t),e),new Set).forEach(e=>t.unshift(e))}else e&&t.push(e);return t}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?J?this.renderRoot.adoptedStyleSheets=e.map(e=>e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){super.update(e);const t=this.render();t instanceof g&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){}}Q.finalized=!0,Q.render=(e,t,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const s=i.scopeName,o=R.has(t),r=W&&11===t.nodeType&&!!t.host,a=r&&!F.has(s),l=a?document.createDocumentFragment():t;if(((e,t,i)=>{let s=R.get(t);void 0===s&&(n(t,t.firstChild),R.set(t,s=new S(Object.assign({templateFactory:P},i))),s.appendInto(t)),s.setValue(e),s.commit()})(e,l,Object.assign({templateFactory:V(s)},i)),a){const e=R.get(l);R.delete(l);const i=e.value instanceof m?e.value.template:void 0;q(s,l,i),n(t,t.firstChild),t.appendChild(l),R.set(t,e)}!o&&r&&window.ShadyCSS.styleElement(t.host)};let Z=null;const ee=e=>{if(!Z){const t="1snn5n9w",i="airwallex_cybs",n=document.createElement("script");Z=`${e}${Date.now()}`,n.src=`https://h.online-metrix.net/fp/tags.js?org_id=${t}&session_id=${i}${Z}`,document.body.appendChild(n)}return Z};class te{constructor(e,t){var i;this.addResizeListener=e=>{window.addEventListener("message",t=>{var i,n,s,o;if(t.origin===this.gatewayUrl&&t.isTrusted&&"onResize"===(null===(i=t.data)||void 0===i?void 0:i.code)&&e===(null===(n=t.data)||void 0===n?void 0:n.type)){const e=null===(s=this.iframe)||void 0===s?void 0:s.style;e&&(e.height=`${null===(o=t.data)||void 0===o?void 0:o.height}px`)}})},this.domElement="",this.gatewayUrl=e,this.options=t,this.iframe=window.document.createElement("iframe"),this.iframe.setAttribute("frameborder","0"),this.iframe.setAttribute("allowtransparency","true"),this.iframe.setAttribute("importance","high"),this.iframe.setAttribute("scrolling","no"),this.iframe.setAttribute("allowpaymentrequest","true"),null===(i=this.iframe)||void 0===i||i.setAttribute("style","\n height: 0;\n width: 100%;\n "),window.addEventListener("message",e=>{var t,i,n;if(e.origin===this.gatewayUrl&&e.isTrusted&&"onReady"===(null===(t=e.data)||void 0===t?void 0:t.code)){const t=new CustomEvent(null===(i=e.data)||void 0===i?void 0:i.code,{detail:{type:null===(n=e.data)||void 0===n?void 0:n.type},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}})}mount(e){var t;this.domElement=e,"string"!=typeof e?this.iframe&&e.appendChild(this.iframe):this.iframe&&(null===(t=window.document.getElementById(e))||void 0===t||t.appendChild(this.iframe))}blur(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"blur"},this.gatewayUrl)}clear(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"clear"},this.gatewayUrl)}destroy(){var e;null===(e=this.iframe)||void 0===e||e.remove(),this.iframe=null}focus(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"focus"},this.gatewayUrl)}unmount(){var e;"string"!=typeof this.domElement?this.iframe&&this.domElement.removeChild(this.iframe):this.iframe&&(null===(e=window.document.getElementById(this.domElement))||void 0===e||e.removeChild(this.iframe))}}class ie extends te{constructor(e,t,i){var n,s,o;super(e,i),this.confirmResponse=t,null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/3ds-frictionless?options=${JSON.stringify(this.options)}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex 3DS frictionless iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex 3DS frictionless iframe"),window.addEventListener("message",e=>{var t,i,n,s;e.origin===this.gatewayUrl&&e.isTrusted&&"onReady"===(null===(t=e.data)||void 0===t?void 0:t.code)&&"3DSFrictionless"===(null===(i=e.data)||void 0===i?void 0:i.type)&&(null===(s=null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)||void 0===s||s.postMessage({code:"update",data:this.confirmResponse},this.gatewayUrl))})}async confirm(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"confirm",data:{...this.confirmResponse,deviceId:ee()}},this.gatewayUrl)}}class ne extends te{constructor(e,t,i){var n,s,o,r,a,l;super(e,i),this.confirmResponse=t,null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/3ds-challenge?options=${JSON.stringify(this.options)}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex 3DS challenge iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex 3DS challenge iframe"),null===(r=this.iframe)||void 0===r||r.setAttribute("style",`\n position: absolute;\n background: #fff;\n top: 50%;\n left: 50%;\n width: 100%;\n transform: translate(-50%, -50%);\n height: ${null!==(a=null==i?void 0:i.popupHeight)&&void 0!==a?a:"695"}px;\n width: ${null!==(l=null==i?void 0:i.popupWidth)&&void 0!==l?l:"415"}px;\n border-radius: 4px;\n `),window.addEventListener("message",e=>{var t,i,n,s;e.origin===this.gatewayUrl&&e.isTrusted&&"onReady"===(null===(t=e.data)||void 0===t?void 0:t.code)&&"3DSChallenge"===(null===(i=e.data)||void 0===i?void 0:i.type)&&(null===(s=null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)||void 0===s||s.postMessage({code:"update",data:this.confirmResponse},this.gatewayUrl))})}async confirm(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"confirm",data:{...this.confirmResponse,deviceId:ee()}},this.gatewayUrl)}}const se=(e,t)=>{var i,n;"3DSFrictionless"===t?(null===(i=e.threeDsFrictionless)||void 0===i||i.clear(),e.threeDsFrictionless=null):(null===(n=e.threeDsChallenge)||void 0===n||n.clear(),e.threeDsChallenge=null);const s=document.getElementById(t);s&&document.body.removeChild(s)},oe=({elements:e,element:t,gatewayUrl:i,type:n,popupWidth:s,popupHeight:o})=>{window.addEventListener("message",r=>{var a,l,d;if(r.origin===i&&r.isTrusted&&(null===(a=r.data)||void 0===a?void 0:a.type)===n&&"onChallenge"===(null===(l=r.data)||void 0===l?void 0:l.code)){const n="3DSFrictionless";e.threeDsFrictionless=new ie(i,null===(d=r.data)||void 0===d?void 0:d.data,{origin:window.location.origin}),window.addEventListener("message",s=>{var o,r,a,l,d,c;if(s.origin===i&&s.isTrusted&&(null===(o=null==s?void 0:s.data)||void 0===o?void 0:o.type)===n){const{type:i,error:n,...o}=s.data;"onChallengeSuccess"===(null===(r=s.data)||void 0===r?void 0:r.code)&&(null===(a=e.threeDsFrictionless)||void 0===a||a.confirm()),"onSuccess"===(null===(l=s.data)||void 0===l?void 0:l.code)&&(se(e,i),null==t||t.success(o)),"onError"===(null===(d=s.data)||void 0===d?void 0:d.code)&&(null==t||t.cancel(n),se(e,i)),"onChallengeError"===(null===(c=s.data)||void 0===c?void 0:c.code)&&(null==t||t.cancel(n),se(e,i))}});const a=document.createElement("div");a.setAttribute("id",n),document.body.appendChild(a),e.threeDsFrictionless.mount(a),window.addEventListener("message",n=>{var r,a,l;if(n.origin===i&&n.isTrusted&&"3DSFrictionless"===(null===(r=null==n?void 0:n.data)||void 0===r?void 0:r.type)&&"onChallenge"===(null===(a=n.data)||void 0===a?void 0:a.code)){const r="3DSChallenge",a=document.createElement("div");se(e,"3DSFrictionless"),e.threeDsChallenge=new ne(i,null===(l=n.data)||void 0===l?void 0:l.data,{origin:window.location.origin,popupWidth:s,popupHeight:o}),window.addEventListener("message",n=>{var s,o,l,d,c,u,h;if(n.origin===i&&n.isTrusted&&(null===(s=null==n?void 0:n.data)||void 0===s?void 0:s.type)===r){const{type:i,error:s,...r}=n.data;"onReady"===(null===(o=n.data)||void 0===o?void 0:o.code)&&setTimeout(()=>{a.style.height="100%"},2e3),"onChallengeSuccess"===(null===(l=n.data)||void 0===l?void 0:l.code)&&(a.style.height="0",null===(d=e.threeDsChallenge)||void 0===d||d.confirm()),"onSuccess"===(null===(c=n.data)||void 0===c?void 0:c.code)&&(se(e,i),null==t||t.success(r)),"onError"===(null===(u=n.data)||void 0===u?void 0:u.code)&&(se(e,i),null==t||t.cancel(s)),"onChallengeError"===(null===(h=n.data)||void 0===h?void 0:h.code)&&(se(e,i),null==t||t.cancel(s))}}),a.setAttribute("id",r),a.setAttribute("style","\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 0;\n z-index: 1500;\n overflow: hidden;\n background: rgba(0, 0, 0, 0.75);\n "),document.body.appendChild(a),e.threeDsChallenge.mount(a)}})}})};class re extends te{constructor(e,t,i){var n,s,o;super(e,i),this.retrieve={resolver:null,reject:null,awaiting:!1},this.confirmIntent={resolver:null,reject:null,awaiting:!1},this.createMethod={resolver:null,reject:null,awaiting:!1},this.options=i,null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/card-number?options=${JSON.stringify(this.options)}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex card number element iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex card number element iframe"),this.addResizeListener("cardNumber"),window.addEventListener("message",n=>{var s,o,r,a,l,d,c,u,h,p,m,v,g,w,f,y,_,S,b,C,x;if(n.origin===this.gatewayUrl&&n.isTrusted&&"cardNumber"===(null===(s=null==n?void 0:n.data)||void 0===s?void 0:s.type)){if("onSubmit"===(null===(o=n.data)||void 0===o?void 0:o.code)){const e=new CustomEvent(null===(r=n.data)||void 0===r?void 0:r.code,{detail:{},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}if("onReady"===(null===(a=n.data)||void 0===a?void 0:a.code)&&oe({elements:t,element:null==t?void 0:t.cardNumber,gatewayUrl:e,type:"cardNumber",popupWidth:null==i?void 0:i.popupWidth,popupHeight:null==i?void 0:i.popupHeight}),"onSuccess"===(null===(l=n.data)||void 0===l?void 0:l.code)&&(this.confirmIntent.resolver(n.data),this.confirmIntent.awaiting=!1),"onError"===(null===(d=n.data)||void 0===d?void 0:d.code)&&(this.confirmIntent.reject(n.data),this.confirmIntent.awaiting=!1),"onRetrieveIntent"===(null===(c=n.data)||void 0===c?void 0:c.code)&&(this.retrieve.resolver(n.data),this.retrieve.awaiting=!1),"onRetrieveIntentError"===(null===(u=n.data)||void 0===u?void 0:u.code)&&(this.retrieve.reject(n.data),this.retrieve.awaiting=!1),"onPaymentMethodCreated"===(null===(h=n.data)||void 0===h?void 0:h.code)&&(this.createMethod.resolver(n.data),this.createMethod.awaiting=!1),"onPaymentMethodCreatedError"===(null===(p=n.data)||void 0===p?void 0:p.code)&&(this.createMethod.reject(n.data),this.createMethod.awaiting=!1),["onFocus","onBlur","onChange"].includes(null===(m=n.data)||void 0===m?void 0:m.code)){const e=new CustomEvent(null===(v=n.data)||void 0===v?void 0:v.code,{detail:{type:"cardNumber",complete:null!==(w=null===(g=n.data)||void 0===g?void 0:g.complete)&&void 0!==w&&w,empty:null!==(y=null===(f=n.data)||void 0===f?void 0:f.empty)&&void 0!==y&&y,error:null===(_=n.data)||void 0===_?void 0:_.error,bankName:null!==(b=null===(S=n.data)||void 0===S?void 0:S.bankName)&&void 0!==b?b:"",brand:null!==(x=null===(C=n.data)||void 0===C?void 0:C.brand)&&void 0!==x?x:""},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}}})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}async confirm(e){var t,i;this.confirmIntent.awaiting&&console.warn("Should waiting previous confirm finished before execute new one!");const{intentId:n}=e||{},s=ee(n||"");return null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"confirm",data:{...e,deviceId:s}},this.gatewayUrl),new Promise((e,t)=>{this.confirmIntent.resolver=e,this.confirmIntent.reject=t,this.confirmIntent.awaiting=!0})}async createPaymentMethod(e){var t,i;return this.createMethod.awaiting&&console.warn("Should waiting previous createPaymentMethod finished before execute new one!"),null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"createPaymentMethod",data:e},this.gatewayUrl),new Promise((e,t)=>{this.createMethod.resolver=e,this.createMethod.reject=t,this.createMethod.awaiting=!0})}async getPaymentIntent(e,t){var i,n;return this.retrieve.awaiting&&console.warn("Should waiting previous getPaymentIntent finished before execute new one!"),null===(n=null===(i=this.iframe)||void 0===i?void 0:i.contentWindow)||void 0===n||n.postMessage({code:"getIntent",intentId:e,clientSecret:t},this.gatewayUrl),new Promise((e,t)=>{this.retrieve.resolver=e,this.retrieve.reject=t,this.retrieve.awaiting=!0})}success(e){this.confirmIntent.resolver(e),this.confirmIntent.awaiting=!1}cancel(e="cancelled"){this.confirmIntent.awaiting&&this.confirmIntent.reject({reason:e}),this.retrieve.awaiting&&this.retrieve.reject({reason:e}),this.createMethod.awaiting&&this.createMethod.reject({reason:e}),this.retrieve={resolver:null,reject:null,awaiting:!1},this.confirmIntent={resolver:null,reject:null,awaiting:!1},this.createMethod={resolver:null,reject:null,awaiting:!1}}}class ae extends te{constructor(e,t){var i,n,s;super(e,t),null===(i=this.iframe)||void 0===i||i.setAttribute("src",`${e}/elements/expiry?options=${JSON.stringify(this.options)}`),null===(n=this.iframe)||void 0===n||n.setAttribute("name","Airwallex expiry number element iframe"),null===(s=this.iframe)||void 0===s||s.setAttribute("title","Airwallex expiry number element iframe"),this.addResizeListener("expiry"),window.addEventListener("message",e=>{var t,i,n;if(e.origin===this.gatewayUrl&&e.isTrusted&&"expiry"===(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.type)&&["onFocus","onBlur","onChange"].includes(null===(i=e.data)||void 0===i?void 0:i.code)){const t=new CustomEvent(null===(n=e.data)||void 0===n?void 0:n.code,{detail:{type:"expiry",complete:!0,empty:!1,error:void 0},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}}class le extends te{constructor(e,t){var i,n,s;super(e,t),null===(i=this.iframe)||void 0===i||i.setAttribute("src",`${e}/elements/cvc?options=${JSON.stringify(this.options)}`),null===(n=this.iframe)||void 0===n||n.setAttribute("name","Airwallex cvc number element iframe"),null===(s=this.iframe)||void 0===s||s.setAttribute("title","Airwallex cvc number element iframe"),this.addResizeListener("cvc"),window.addEventListener("message",e=>{var t,i,n,s,o,r,a;if(e.origin===this.gatewayUrl&&e.isTrusted)if("cvc"===(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.type)&&["onFocus","onBlur","onChange"].includes(null===(i=e.data)||void 0===i?void 0:i.code)){const t=new CustomEvent(null===(n=e.data)||void 0===n?void 0:n.code,{detail:{type:"cvc",complete:!0,empty:!1,error:void 0},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}else"cardNumber"===(null===(s=e.data)||void 0===s?void 0:s.type)&&"onChange"===(null===(o=e.data)||void 0===o?void 0:o.code)&&(null===(a=null===(r=this.iframe)||void 0===r?void 0:r.contentWindow)||void 0===a||a.postMessage({code:"update",options:{cvcLength:e.data.cvcLength}},this.gatewayUrl))})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}}class de extends te{constructor(e,t,i){var n,s,o;super(e,i);const{intent:r,...a}=i||{},l=ee(null==r?void 0:r.id);null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/payment-request-button?options=${encodeURIComponent(JSON.stringify({...a,deviceId:l}))}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex payment request element iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex payment request element iframe"),this.addResizeListener("paymentRequestButton"),window.addEventListener("message",n=>{var s,o,a,l,d,c;n.origin===this.gatewayUrl&&n.isTrusted&&"paymentRequestButton"===(null===(s=n.data)||void 0===s?void 0:s.type)&&("onReady"===(null===(o=n.data)||void 0===o?void 0:o.code)?(oe({elements:t,element:null==t?void 0:t.paymentRequestButton,gatewayUrl:e,type:"paymentRequestButton",popupWidth:null==i?void 0:i.popupWidth,popupHeight:null==i?void 0:i.popupHeight}),null===(l=null===(a=this.iframe)||void 0===a?void 0:a.contentWindow)||void 0===l||l.postMessage({code:"update",options:{intent:r}},this.gatewayUrl)):"onSuccess"===(null===(d=n.data)||void 0===d?void 0:d.code)?this.success(n.data):"onError"===(null===(c=n.data)||void 0===c?void 0:c.code)&&this.cancel(n.data))})}update(e){var t,i;this.options={...this.options,...e};const{intent:n}=this.options||{},s=ee(null==n?void 0:n.id);null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:{...e,deviceId:s}},this.gatewayUrl)}success(e){const t=new CustomEvent("CONFIRM_SUCCESS",{detail:{component:"paymentRequestButton",...e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}cancel(e="cancelled"){const t=new CustomEvent("CONFIRM_FAIL",{detail:{component:"paymentRequestButton",error:e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}}class ce extends te{constructor(e,t,i){var n,s,o;super(e,i);const{intent:r,...a}=i||{},l=ee(null==r?void 0:r.id);null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/card?options=${encodeURIComponent(JSON.stringify({...a,deviceId:l}))}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex card element iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex card element iframe"),this.addResizeListener("card"),window.addEventListener("message",n=>{var s,o,a,l,d,c;n.origin===this.gatewayUrl&&n.isTrusted&&"card"===(null===(s=n.data)||void 0===s?void 0:s.type)&&("onReady"===(null===(o=n.data)||void 0===o?void 0:o.code)?(oe({elements:t,element:null==t?void 0:t.card,gatewayUrl:e,type:"card",popupWidth:null==i?void 0:i.popupWidth,popupHeight:null==i?void 0:i.popupHeight}),null===(l=null===(a=this.iframe)||void 0===a?void 0:a.contentWindow)||void 0===l||l.postMessage({code:"update",options:{intent:r}},this.gatewayUrl)):"onSuccess"===(null===(d=n.data)||void 0===d?void 0:d.code)?this.success(n.data):"onError"===(null===(c=n.data)||void 0===c?void 0:c.code)&&this.cancel(n.data))})}update(e){var t,i;this.options={...this.options,...e};const{intent:n}=this.options||{},s=ee(null==n?void 0:n.id);null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:{...e,deviceId:s}},this.gatewayUrl)}success(e){const t=new CustomEvent("CONFIRM_SUCCESS",{detail:{component:"card",...e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}cancel(e="cancelled"){const t=new CustomEvent("CONFIRM_FAIL",{detail:{component:"card",error:e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}}class ue extends te{constructor(e,t){var i,n,s;super(e,t);const{intent:o,...r}=t||{};null===(i=this.iframe)||void 0===i||i.setAttribute("src",`${e}/elements/wechat?options=${encodeURIComponent(JSON.stringify({...r}))}`),null===(n=this.iframe)||void 0===n||n.setAttribute("name","Airwallex wechat element iframe"),null===(s=this.iframe)||void 0===s||s.setAttribute("title","Airwallex wechat element iframe"),this.addResizeListener("wechat"),window.addEventListener("message",e=>{var t,i,n,s,r,a;e.origin===this.gatewayUrl&&e.isTrusted&&"wechat"===(null===(t=e.data)||void 0===t?void 0:t.type)&&("onReady"===(null===(i=e.data)||void 0===i?void 0:i.code)?null===(s=null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)||void 0===s||s.postMessage({code:"update",options:{intent:o}},this.gatewayUrl):"onSuccess"===(null===(r=e.data)||void 0===r?void 0:r.code)?this.success():"onError"===(null===(a=e.data)||void 0===a?void 0:a.code)&&this.cancel())})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}success(){const e=new CustomEvent("CONFIRM_SUCCESS",{detail:{component:"wechat"},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}cancel(){const e=new CustomEvent("CONFIRM_FAIL",{detail:{component:"wechat"},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}}const he={clientSecret:"",gatewayUrl:"",options:{},cvcLength:4},pe={cardNumber:null,expiry:null,cvc:null,threeDsFrictionless:null,threeDsChallenge:null,paymentRequestButton:null,card:null,wechat:null},me=(e,t,i)=>{he.clientSecret=e,he.gatewayUrl=t,he.options=i},ve=(e,t)=>["cardNumber","expiry","cvc","paymentRequestButton","card","wechat"].includes(e)?"cardNumber"===e?(pe[e]=new re(he.gatewayUrl,pe,{clientSecret:he.clientSecret,...he.options,...t}),pe[e]):"card"===e?(pe[e]=new ce(he.gatewayUrl,pe,{clientSecret:he.clientSecret,...he.options,...t}),pe[e]):"wechat"===e?(pe[e]=new ue(he.gatewayUrl,{clientSecret:he.clientSecret,...he.options,...t}),pe[e]):"paymentRequestButton"===e?(pe[e]=new de(he.gatewayUrl,pe,{clientSecret:he.clientSecret,...he.options,...t}),pe[e]):"expiry"===e||"cvc"===e?(pe[e]="expiry"===e?new ae(he.gatewayUrl,{...he.options,...t}):new le(he.gatewayUrl,{...he.options,cvcLength:he.cvcLength,...t}),window.addEventListener("message",e=>{var t,i,n,s,o,r;e.origin===he.gatewayUrl&&e.isTrusted&&["expiry","cvc"].includes(null===(t=e.data)||void 0===t?void 0:t.type)&&"onChange"===(null===(i=e.data)||void 0===i?void 0:i.code)&&(null===(o=null===(s=null===(n=pe.cardNumber)||void 0===n?void 0:n.iframe)||void 0===s?void 0:s.contentWindow)||void 0===o||o.postMessage({code:`update_${null===(r=e.data)||void 0===r?void 0:r.type}`,data:e.data},he.gatewayUrl))}),pe[e]):null:(console.warn(`createElement with type: ${e} not support!`),null),ge=e=>{var t;return["cardNumber","expiry","cvc","paymentRequestButton","card","wechat"].includes(e)?(null===(t=pe[e])||void 0===t||t.destroy(),pe[e]=null,!0):(console.warn(`destroyElement with type: ${e} not support!`),!1)},we=e=>["cardNumber","expiry","cvc","paymentRequestButton","card","wechat"].includes(e)?pe[e]:(console.warn(`getElement with type: ${e} not support!`),null),fe=async(e,t)=>{console.info(`Confirm with client secret: ${e}`);const{element:i,...n}=t||{};return i?i.confirm(n):t.paymentMethodId?(console.warn("Confirm with payment method id is working in progress!"),!0):(console.warn("Either payment method id or element must be provided for card payment confirm!"),!1)},ye=async(e,t)=>(console.info(`Confirm with client secret: ${e}`),t.element?t.element.createPaymentMethod(t):(console.warn("Either payment method id or element must be provided for payment method create!"),!1)),_e=async(e,t)=>{var i;return(null===(i=pe.cardNumber)||void 0===i?void 0:i.getPaymentIntent(e,t))||!1};customElements.define("airwallex-element",class extends Q{constructor(){super(),this.gatewayBaseurl=this.clientSecret=this.currency=this.intentId=this.customerId="",this.successUrl=this.cancelUrl=this.errorUrl=this.autoCapture=this.enable3dSecure=this.component="",this.theme={},this.height=0}static get properties(){return{gatewayBaseurl:{type:String,reflect:!0},clientSecret:{type:String,reflect:!0},currency:{type:String,reflect:!0},intentId:{type:String,reflect:!0},customerId:{type:String,reflect:!0},successUrl:{type:String,reflect:!0},cancelUrl:{type:String,reflect:!0},errorUrl:{type:String,reflect:!0},enable3dSecure:{type:String,reflect:!0},autoCapture:{type:String,reflect:!0},component:{type:String,reflect:!0},theme:{type:Object,reflect:!0},height:{type:Number,hasChanged:()=>!0}}}static get styles(){return Y`
:host {
width: 100%;
height: 100%;
}
`}handleEvent(e){console.info(`Airwallex Checkout Message: [${JSON.stringify(e)}]`);const t=new CustomEvent("airwallex-checkout",{detail:e,bubbles:!0,composed:!0});this.dispatchEvent(t)}checkoutEventHandler(e){if(e.origin===this.gatewayBaseurl&&e.isTrusted){const{style:t,...i}=e.data;if(this.height=(t&&t.height||0)+8,"AWX_CHECKOUT_STYLE"!==e.data.code&&this.handleEvent(i),"AWX_CHECKOUT_SUCCESS"===e.data.code){const t=`${e.data.status?`status=${e.data.status}`:""}${e.data.id?`&intentId=${e.data.id}`:""}`;this.successUrl&&(window.location.href=-1===this.successUrl.indexOf("?")?`${this.successUrl}?${t}`:`${this.successUrl}&${t}`)}else"AWX_CHECKOUT_CANCEL"===e.data.code?this.cancelUrl&&(window.location.href=this.cancelUrl):"AWX_CHECKOUT_ERROR"===e.data.code&&this.errorUrl&&(window.location.href=this.errorUrl);this.requestUpdate()}}connectedCallback(){super.connectedCallback(),window.addEventListener("message",e=>this.checkoutEventHandler(e))}disconnectedCallback(){window.removeEventListener("message",e=>this.checkoutEventHandler(e)),super.disconnectedCallback()}render(){const e=`${this.gatewayBaseurl}/checkout/${this.intentId}?origin=${window.location.origin}&customerId=${this.customerId}&currency=${this.currency}&theme=${encodeURIComponent(JSON.stringify(this.theme))}&autoCapture=${this.autoCapture}&component=${this.component}&enable3dSecure=${this.enable3dSecure}&clientSecret=${encodeURIComponent(this.clientSecret)}&deviceId=${ee(this.intentId)}`;return $`
<style>
iframe {
width: 100%;
background: white;
height: ${this.height}px;
}
</style>
<iframe
frameborder="0"
allowtransparency="true"
importance="high"
scrolling="no"
name="${"airwallex_checkout_frame"}"
allowpaymentrequest="true"
src="${e}"
title="Secured airwallex payment frame"
/>
`}});export{fe as confirmPaymentIntent,ve as createElement,ye as createPaymentMethod,ge as destroyElement,we as getElement,_e as getPaymentIntent,me as init};
/* Airwallex @Charlie.Lang */
//# sourceMappingURL=airwallex.es.js.map

@@ -1,4 +0,27 @@

/* Airwallex Checkout Component Version [0.0.55] */
var Airwallex=function(e){"use strict";const r="https://checkout.airwallex.com/assets/bundle.min.js",t=Promise.resolve().then(()=>{if("undefined"==typeof window)return null;if(window.Airwallex)return window.Airwallex;const e=document.querySelector(`script[src="${r}"], script[src="${r}/"]`)||(()=>{const e=document.createElement("script");e.src=r;const t=document.head||document.body;if(!t)throw new Error("Expected document.body not to be null. Airwallex.js requires a <head> or <body> element.");return t.appendChild(e),e})();return new Promise((r,t)=>{e.addEventListener("load",()=>{window.Airwallex?r():t(new Error("Failed to load Airwallex.js"))}),e.addEventListener("error",()=>{t(new Error("Failed to load Airwallex.js"))})})});return e.loadAirwallex=()=>t,e}({});
/* Airwallex Checkout Component Version [0.0.56] */
var Airwallex=function(e){"use strict";const t=new WeakMap,i=e=>"function"==typeof e&&t.has(e),n=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,s=(e,t,i=null)=>{for(;t!==i;){const i=t.nextSibling;e.removeChild(t),t=i}},o={},r={},a=`{{lit-${String(Math.random()).slice(2)}}}`,l=`\x3c!--${a}--\x3e`,d=new RegExp(`${a}|${l}`);class c{constructor(e,t){this.parts=[],this.element=t;const i=[],n=[],s=document.createTreeWalker(t.content,133,null,!1);let o=0,r=-1,l=0;const{strings:c,values:{length:h}}=e;for(;l<h;){const e=s.nextNode();if(null!==e){if(r++,1===e.nodeType){if(e.hasAttributes()){const t=e.attributes,{length:i}=t;let n=0;for(let e=0;e<i;e++)u(t[e].name,"$lit$")&&n++;for(;n-- >0;){const t=c[l],i=m.exec(t)[2],n=i.toLowerCase()+"$lit$",s=e.getAttribute(n);e.removeAttribute(n);const o=s.split(d);this.parts.push({type:"attribute",index:r,name:i,strings:o}),l+=o.length-1}}"TEMPLATE"===e.tagName&&(n.push(e),s.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(a)>=0){const n=e.parentNode,s=t.split(d),o=s.length-1;for(let t=0;t<o;t++){let i,o=s[t];if(""===o)i=p();else{const e=m.exec(o);null!==e&&u(e[2],"$lit$")&&(o=o.slice(0,e.index)+e[1]+e[2].slice(0,-"$lit$".length)+e[3]),i=document.createTextNode(o)}n.insertBefore(i,e),this.parts.push({type:"node",index:++r})}""===s[o]?(n.insertBefore(p(),e),i.push(e)):e.data=s[o],l+=o}}else if(8===e.nodeType)if(e.data===a){const t=e.parentNode;null!==e.previousSibling&&r!==o||(r++,t.insertBefore(p(),e)),o=r,this.parts.push({type:"node",index:r}),null===e.nextSibling?e.data="":(i.push(e),r--),l++}else{let t=-1;for(;-1!==(t=e.data.indexOf(a,t+1));)this.parts.push({type:"node",index:-1}),l++}}else s.currentNode=n.pop()}for(const e of i)e.parentNode.removeChild(e)}}const u=(e,t)=>{const i=e.length-t.length;return i>=0&&e.slice(i)===t},h=e=>-1!==e.index,p=()=>document.createComment(""),m=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class v{constructor(e,t,i){this.__parts=[],this.template=e,this.processor=t,this.options=i}update(e){let t=0;for(const i of this.__parts)void 0!==i&&i.setValue(e[t]),t++;for(const e of this.__parts)void 0!==e&&e.commit()}_clone(){const e=n?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),t=[],i=this.template.parts,s=document.createTreeWalker(e,133,null,!1);let o,r=0,a=0,l=s.nextNode();for(;r<i.length;)if(o=i[r],h(o)){for(;a<o.index;)a++,"TEMPLATE"===l.nodeName&&(t.push(l),s.currentNode=l.content),null===(l=s.nextNode())&&(s.currentNode=t.pop(),l=s.nextNode());if("node"===o.type){const e=this.processor.handleTextExpression(this.options);e.insertAfterNode(l.previousSibling),this.__parts.push(e)}else this.__parts.push(...this.processor.handleAttributeExpressions(l,o.name,o.strings,this.options));r++}else this.__parts.push(void 0),r++;return n&&(document.adoptNode(e),customElements.upgrade(e)),e}}const g=` ${a} `;class w{constructor(e,t,i,n){this.strings=e,this.values=t,this.type=i,this.processor=n}getHTML(){const e=this.strings.length-1;let t="",i=!1;for(let n=0;n<e;n++){const e=this.strings[n],s=e.lastIndexOf("\x3c!--");i=(s>-1||i)&&-1===e.indexOf("--\x3e",s+1);const o=m.exec(e);t+=null===o?e+(i?g:l):e.substr(0,o.index)+o[1]+o[2]+"$lit$"+o[3]+a}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");return e.innerHTML=this.getHTML(),e}}const f=e=>null===e||!("object"==typeof e||"function"==typeof e),y=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class _{constructor(e,t,i){this.dirty=!0,this.element=e,this.name=t,this.strings=i,this.parts=[];for(let e=0;e<i.length-1;e++)this.parts[e]=this._createPart()}_createPart(){return new S(this)}_getValue(){const e=this.strings,t=e.length-1;let i="";for(let n=0;n<t;n++){i+=e[n];const t=this.parts[n];if(void 0!==t){const e=t.value;if(f(e)||!y(e))i+="string"==typeof e?e:String(e);else for(const t of e)i+="string"==typeof t?t:String(t)}}return i+=e[t],i}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class S{constructor(e){this.value=void 0,this.committer=e}setValue(e){e===o||f(e)&&e===this.value||(this.value=e,i(e)||(this.committer.dirty=!0))}commit(){for(;i(this.value);){const e=this.value;this.value=o,e(this)}this.value!==o&&this.committer.commit()}}class b{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(p()),this.endNode=e.appendChild(p())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=p()),e.__insert(this.endNode=p())}insertAfterPart(e){e.__insert(this.startNode=p()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){for(;i(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=o,e(this)}const e=this.__pendingValue;e!==o&&(f(e)?e!==this.value&&this.__commitText(e):e instanceof w?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):y(e)?this.__commitIterable(e):e===r?(this.value=r,this.clear()):this.__commitText(e))}__insert(e){this.endNode.parentNode.insertBefore(e,this.endNode)}__commitNode(e){this.value!==e&&(this.clear(),this.__insert(e),this.value=e)}__commitText(e){const t=this.startNode.nextSibling,i="string"==typeof(e=null==e?"":e)?e:String(e);t===this.endNode.previousSibling&&3===t.nodeType?t.data=i:this.__commitNode(document.createTextNode(i)),this.value=e}__commitTemplateResult(e){const t=this.options.templateFactory(e);if(this.value instanceof v&&this.value.template===t)this.value.update(e.values);else{const i=new v(t,e.processor,this.options),n=i._clone();i.update(e.values),this.__commitNode(n),this.value=i}}__commitIterable(e){Array.isArray(this.value)||(this.value=[],this.clear());const t=this.value;let i,n=0;for(const s of e)i=t[n],void 0===i&&(i=new b(this.options),t.push(i),0===n?i.appendIntoPart(this):i.insertAfterPart(t[n-1])),i.setValue(s),i.commit(),n++;n<t.length&&(t.length=n,this.clear(i&&i.endNode))}clear(e=this.startNode){s(this.startNode.parentNode,e.nextSibling,this.endNode)}}class C{constructor(e,t,i){if(this.value=void 0,this.__pendingValue=void 0,2!==i.length||""!==i[0]||""!==i[1])throw new Error("Boolean attributes can only contain a single expression");this.element=e,this.name=t,this.strings=i}setValue(e){this.__pendingValue=e}commit(){for(;i(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=o,e(this)}if(this.__pendingValue===o)return;const e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=o}}class x extends _{constructor(e,t,i){super(e,t,i),this.single=2===i.length&&""===i[0]&&""===i[1]}_createPart(){return new E(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class E extends S{}let A=!1;try{const e={get capture(){return A=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}class N{constructor(e,t,i){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=i,this.__boundHandleEvent=e=>this.handleEvent(e)}setValue(e){this.__pendingValue=e}commit(){for(;i(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=o,e(this)}if(this.__pendingValue===o)return;const e=this.__pendingValue,t=this.value,n=null==e||null!=t&&(e.capture!==t.capture||e.once!==t.once||e.passive!==t.passive),s=null!=e&&(null==t||n);n&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),s&&(this.__options=U(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=o}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}}const U=e=>e&&(A?{capture:e.capture,passive:e.passive,once:e.once}:e.capture);const P=new class{handleAttributeExpressions(e,t,i,n){const s=t[0];if("."===s){return new x(e,t.slice(1),i).parts}return"@"===s?[new N(e,t.slice(1),n.eventContext)]:"?"===s?[new C(e,t.slice(1),i)]:new _(e,t,i).parts}handleTextExpression(e){return new b(e)}};function T(e){let t=R.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},R.set(e.type,t));let i=t.stringsArray.get(e.strings);if(void 0!==i)return i;const n=e.strings.join(a);return i=t.keyString.get(n),void 0===i&&(i=new c(e,e.getTemplateElement()),t.keyString.set(n,i)),t.stringsArray.set(e.strings,i),i}const R=new Map,$=new WeakMap;(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.1.2");const I=(e,...t)=>new w(e,t,"html",P);function M(e,t){const{element:{content:i},parts:n}=e,s=document.createTreeWalker(i,133,null,!1);let o=L(n),r=n[o],a=-1,l=0;const d=[];let c=null;for(;s.nextNode();){a++;const e=s.currentNode;for(e.previousSibling===c&&(c=null),t.has(e)&&(d.push(e),null===c&&(c=e)),null!==c&&l++;void 0!==r&&r.index===a;)r.index=null!==c?-1:r.index-l,o=L(n,o),r=n[o]}d.forEach(e=>e.parentNode.removeChild(e))}const O=e=>{let t=11===e.nodeType?0:1;const i=document.createTreeWalker(e,133,null,!1);for(;i.nextNode();)t++;return t},L=(e,t=-1)=>{for(let i=t+1;i<e.length;i++){const t=e[i];if(h(t))return i}return-1};const W=(e,t)=>`${e}--${t}`;let V=!0;void 0===window.ShadyCSS?V=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),V=!1);const k=e=>t=>{const i=W(t.type,e);let n=R.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},R.set(i,n));let s=n.stringsArray.get(t.strings);if(void 0!==s)return s;const o=t.strings.join(a);if(s=n.keyString.get(o),void 0===s){const i=t.getTemplateElement();V&&window.ShadyCSS.prepareTemplateDom(i,e),s=new c(t,i),n.keyString.set(o,s)}return n.stringsArray.set(t.strings,s),s},F=["html","svg"],q=new Set,j=(e,t,i)=>{q.add(e);const n=i?i.element:document.createElement("template"),s=t.querySelectorAll("style"),{length:o}=s;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(n,e);const r=document.createElement("style");for(let e=0;e<o;e++){const t=s[e];t.parentNode.removeChild(t),r.textContent+=t.textContent}(e=>{F.forEach(t=>{const i=R.get(W(t,e));void 0!==i&&i.keyString.forEach(e=>{const{element:{content:t}}=e,i=new Set;Array.from(t.querySelectorAll("style")).forEach(e=>{i.add(e)}),M(e,i)})})})(e);const a=n.content;i?function(e,t,i=null){const{element:{content:n},parts:s}=e;if(null==i)return void n.appendChild(t);const o=document.createTreeWalker(n,133,null,!1);let r=L(s),a=0,l=-1;for(;o.nextNode();){for(l++,o.currentNode===i&&(a=O(t),i.parentNode.insertBefore(t,i));-1!==r&&s[r].index===l;){if(a>0){for(;-1!==r;)s[r].index+=a,r=L(s,r);return}r=L(s,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,e);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)t.insertBefore(l.cloneNode(!0),t.firstChild);else if(i){a.insertBefore(r,a.firstChild);const e=new Set;e.add(r),M(i,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const B={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},D=(e,t)=>t!==e&&(t==t||e==e),H={attribute:!0,type:String,converter:B,reflect:!1,hasChanged:D},z=Promise.resolve(!0);class J extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=z,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach((t,i)=>{const n=this._attributeNameForProperty(i,t);void 0!==n&&(this._attributeToPropertyMap.set(n,i),e.push(n))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach((e,t)=>this._classProperties.set(t,e))}}static createProperty(e,t=H){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const i="symbol"==typeof e?Symbol():`__${e}`;Object.defineProperty(this.prototype,e,{get(){return this[i]},set(t){const n=this[e];this[i]=t,this._requestUpdate(e,n)},configurable:!0,enumerable:!0})}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty("finalized")||e.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]];for(const i of t)this.createProperty(i,e[i])}}static _attributeNameForProperty(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}static _valueHasChanged(e,t,i=D){return i(e,t)}static _propertyValueFromAttribute(e,t){const i=t.type,n=t.converter||B,s="function"==typeof n?n:n.fromAttribute;return s?s(e,i):e}static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const i=t.type,n=t.converter;return(n&&n.toAttribute||B.toAttribute)(e,i)}initialize(){this._saveInstanceProperties(),this._requestUpdate()}_saveInstanceProperties(){this.constructor._classProperties.forEach((e,t)=>{if(this.hasOwnProperty(t)){const e=this[t];delete this[t],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(t,e)}})}_applyInstanceProperties(){this._instanceProperties.forEach((e,t)=>this[t]=e),this._instanceProperties=void 0}connectedCallback(){this._updateState=32|this._updateState,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,t,i){t!==i&&this._attributeToProperty(e,i)}_propertyToAttribute(e,t,i=H){const n=this.constructor,s=n._attributeNameForProperty(e,i);if(void 0!==s){const e=n._propertyValueToAttribute(t,i);if(void 0===e)return;this._updateState=8|this._updateState,null==e?this.removeAttribute(s):this.setAttribute(s,e),this._updateState=-9&this._updateState}}_attributeToProperty(e,t){if(8&this._updateState)return;const i=this.constructor,n=i._attributeToPropertyMap.get(e);if(void 0!==n){const e=i._classProperties.get(n)||H;this._updateState=16|this._updateState,this[n]=i._propertyValueFromAttribute(t,e),this._updateState=-17&this._updateState}}_requestUpdate(e,t){let i=!0;if(void 0!==e){const n=this.constructor,s=n._classProperties.get(e)||H;n._valueHasChanged(this[e],t,s.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,t),!0!==s.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,s))):i=!1}!this._hasRequestedUpdate&&i&&this._enqueueUpdate()}requestUpdate(e,t){return this._requestUpdate(e,t),this.updateComplete}async _enqueueUpdate(){let e,t;this._updateState=4|this._updateState;const i=this._updatePromise;this._updatePromise=new Promise((i,n)=>{e=i,t=n});try{await i}catch(e){}this._hasConnected||await new Promise(e=>this._hasConnectedResolver=e);try{const e=this.performUpdate();null!=e&&await e}catch(e){t(e)}e(!this._hasRequestedUpdate)}get _hasConnected(){return 32&this._updateState}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let e=!1;const t=this._changedProperties;try{e=this.shouldUpdate(t),e&&this.update(t)}catch(t){throw e=!1,t}finally{this._markUpdated()}e&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(t)),this.updated(t))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((e,t)=>this._propertyToAttribute(t,this[t],e)),this._reflectingProperties=void 0)}updated(e){}firstUpdated(e){}}J.finalized=!0;const K="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,X=Symbol();class Y{constructor(e,t){if(t!==X)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return void 0===this._styleSheet&&(K?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const G=(e,...t)=>{const i=t.reduce((t,i,n)=>t+(e=>{if(e instanceof Y)return e.cssText;if("number"==typeof e)return e;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${e}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+e[n+1],e[0]);return new Y(i,X)};(window.litElementVersions||(window.litElementVersions=[])).push("2.2.1");const Q=e=>e.flat?e.flat(1/0):function e(t,i=[]){for(let n=0,s=t.length;n<s;n++){const s=t[n];Array.isArray(s)?e(s,i):i.push(s)}return i}(e);class Z extends J{static finalize(){super.finalize.call(this),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const e=this.styles,t=[];if(Array.isArray(e)){Q(e).reduceRight((e,t)=>(e.add(t),e),new Set).forEach(e=>t.unshift(e))}else e&&t.push(e);return t}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?K?this.renderRoot.adoptedStyleSheets=e.map(e=>e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){super.update(e);const t=this.render();t instanceof w&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){}}Z.finalized=!0,Z.render=(e,t,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const n=i.scopeName,o=$.has(t),r=V&&11===t.nodeType&&!!t.host,a=r&&!q.has(n),l=a?document.createDocumentFragment():t;if(((e,t,i)=>{let n=$.get(t);void 0===n&&(s(t,t.firstChild),$.set(t,n=new b(Object.assign({templateFactory:T},i))),n.appendInto(t)),n.setValue(e),n.commit()})(e,l,Object.assign({templateFactory:k(n)},i)),a){const e=$.get(l);$.delete(l);const i=e.value instanceof v?e.value.template:void 0;j(n,l,i),s(t,t.firstChild),t.appendChild(l),$.set(t,e)}!o&&r&&window.ShadyCSS.styleElement(t.host)};let ee=null;const te=e=>{if(!ee){const t="1snn5n9w",i="airwallex_cybs",n=document.createElement("script");ee=`${e}${Date.now()}`,n.src=`https://h.online-metrix.net/fp/tags.js?org_id=${t}&session_id=${i}${ee}`,document.body.appendChild(n)}return ee};class ie{constructor(e,t){var i;this.addResizeListener=e=>{window.addEventListener("message",t=>{var i,n,s,o;if(t.origin===this.gatewayUrl&&t.isTrusted&&"onResize"===(null===(i=t.data)||void 0===i?void 0:i.code)&&e===(null===(n=t.data)||void 0===n?void 0:n.type)){const e=null===(s=this.iframe)||void 0===s?void 0:s.style;e&&(e.height=`${null===(o=t.data)||void 0===o?void 0:o.height}px`)}})},this.domElement="",this.gatewayUrl=e,this.options=t,this.iframe=window.document.createElement("iframe"),this.iframe.setAttribute("frameborder","0"),this.iframe.setAttribute("allowtransparency","true"),this.iframe.setAttribute("importance","high"),this.iframe.setAttribute("scrolling","no"),this.iframe.setAttribute("allowpaymentrequest","true"),null===(i=this.iframe)||void 0===i||i.setAttribute("style","\n height: 0;\n width: 100%;\n "),window.addEventListener("message",e=>{var t,i,n;if(e.origin===this.gatewayUrl&&e.isTrusted&&"onReady"===(null===(t=e.data)||void 0===t?void 0:t.code)){const t=new CustomEvent(null===(i=e.data)||void 0===i?void 0:i.code,{detail:{type:null===(n=e.data)||void 0===n?void 0:n.type},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}})}mount(e){var t;this.domElement=e,"string"!=typeof e?this.iframe&&e.appendChild(this.iframe):this.iframe&&(null===(t=window.document.getElementById(e))||void 0===t||t.appendChild(this.iframe))}blur(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"blur"},this.gatewayUrl)}clear(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"clear"},this.gatewayUrl)}destroy(){var e;null===(e=this.iframe)||void 0===e||e.remove(),this.iframe=null}focus(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"focus"},this.gatewayUrl)}unmount(){var e;"string"!=typeof this.domElement?this.iframe&&this.domElement.removeChild(this.iframe):this.iframe&&(null===(e=window.document.getElementById(this.domElement))||void 0===e||e.removeChild(this.iframe))}}class ne extends ie{constructor(e,t,i){var n,s,o;super(e,i),this.confirmResponse=t,null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/3ds-frictionless?options=${JSON.stringify(this.options)}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex 3DS frictionless iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex 3DS frictionless iframe"),window.addEventListener("message",e=>{var t,i,n,s;e.origin===this.gatewayUrl&&e.isTrusted&&"onReady"===(null===(t=e.data)||void 0===t?void 0:t.code)&&"3DSFrictionless"===(null===(i=e.data)||void 0===i?void 0:i.type)&&(null===(s=null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)||void 0===s||s.postMessage({code:"update",data:this.confirmResponse},this.gatewayUrl))})}async confirm(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"confirm",data:{...this.confirmResponse,deviceId:te()}},this.gatewayUrl)}}class se extends ie{constructor(e,t,i){var n,s,o,r,a,l;super(e,i),this.confirmResponse=t,null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/3ds-challenge?options=${JSON.stringify(this.options)}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex 3DS challenge iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex 3DS challenge iframe"),null===(r=this.iframe)||void 0===r||r.setAttribute("style",`\n position: absolute;\n background: #fff;\n top: 50%;\n left: 50%;\n width: 100%;\n transform: translate(-50%, -50%);\n height: ${null!==(a=null==i?void 0:i.popupHeight)&&void 0!==a?a:"695"}px;\n width: ${null!==(l=null==i?void 0:i.popupWidth)&&void 0!==l?l:"415"}px;\n border-radius: 4px;\n `),window.addEventListener("message",e=>{var t,i,n,s;e.origin===this.gatewayUrl&&e.isTrusted&&"onReady"===(null===(t=e.data)||void 0===t?void 0:t.code)&&"3DSChallenge"===(null===(i=e.data)||void 0===i?void 0:i.type)&&(null===(s=null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)||void 0===s||s.postMessage({code:"update",data:this.confirmResponse},this.gatewayUrl))})}async confirm(){var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===t||t.postMessage({code:"confirm",data:{...this.confirmResponse,deviceId:te()}},this.gatewayUrl)}}const oe=(e,t)=>{var i,n;"3DSFrictionless"===t?(null===(i=e.threeDsFrictionless)||void 0===i||i.clear(),e.threeDsFrictionless=null):(null===(n=e.threeDsChallenge)||void 0===n||n.clear(),e.threeDsChallenge=null);const s=document.getElementById(t);s&&document.body.removeChild(s)},re=({elements:e,element:t,gatewayUrl:i,type:n,popupWidth:s,popupHeight:o})=>{window.addEventListener("message",r=>{var a,l,d;if(r.origin===i&&r.isTrusted&&(null===(a=r.data)||void 0===a?void 0:a.type)===n&&"onChallenge"===(null===(l=r.data)||void 0===l?void 0:l.code)){const n="3DSFrictionless";e.threeDsFrictionless=new ne(i,null===(d=r.data)||void 0===d?void 0:d.data,{origin:window.location.origin}),window.addEventListener("message",s=>{var o,r,a,l,d,c;if(s.origin===i&&s.isTrusted&&(null===(o=null==s?void 0:s.data)||void 0===o?void 0:o.type)===n){const{type:i,error:n,...o}=s.data;"onChallengeSuccess"===(null===(r=s.data)||void 0===r?void 0:r.code)&&(null===(a=e.threeDsFrictionless)||void 0===a||a.confirm()),"onSuccess"===(null===(l=s.data)||void 0===l?void 0:l.code)&&(oe(e,i),null==t||t.success(o)),"onError"===(null===(d=s.data)||void 0===d?void 0:d.code)&&(null==t||t.cancel(n),oe(e,i)),"onChallengeError"===(null===(c=s.data)||void 0===c?void 0:c.code)&&(null==t||t.cancel(n),oe(e,i))}});const a=document.createElement("div");a.setAttribute("id",n),document.body.appendChild(a),e.threeDsFrictionless.mount(a),window.addEventListener("message",n=>{var r,a,l;if(n.origin===i&&n.isTrusted&&"3DSFrictionless"===(null===(r=null==n?void 0:n.data)||void 0===r?void 0:r.type)&&"onChallenge"===(null===(a=n.data)||void 0===a?void 0:a.code)){const r="3DSChallenge",a=document.createElement("div");oe(e,"3DSFrictionless"),e.threeDsChallenge=new se(i,null===(l=n.data)||void 0===l?void 0:l.data,{origin:window.location.origin,popupWidth:s,popupHeight:o}),window.addEventListener("message",n=>{var s,o,l,d,c,u,h;if(n.origin===i&&n.isTrusted&&(null===(s=null==n?void 0:n.data)||void 0===s?void 0:s.type)===r){const{type:i,error:s,...r}=n.data;"onReady"===(null===(o=n.data)||void 0===o?void 0:o.code)&&setTimeout(()=>{a.style.height="100%"},2e3),"onChallengeSuccess"===(null===(l=n.data)||void 0===l?void 0:l.code)&&(a.style.height="0",null===(d=e.threeDsChallenge)||void 0===d||d.confirm()),"onSuccess"===(null===(c=n.data)||void 0===c?void 0:c.code)&&(oe(e,i),null==t||t.success(r)),"onError"===(null===(u=n.data)||void 0===u?void 0:u.code)&&(oe(e,i),null==t||t.cancel(s)),"onChallengeError"===(null===(h=n.data)||void 0===h?void 0:h.code)&&(oe(e,i),null==t||t.cancel(s))}}),a.setAttribute("id",r),a.setAttribute("style","\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 0;\n z-index: 1500;\n overflow: hidden;\n background: rgba(0, 0, 0, 0.75);\n "),document.body.appendChild(a),e.threeDsChallenge.mount(a)}})}})};class ae extends ie{constructor(e,t,i){var n,s,o;super(e,i),this.retrieve={resolver:null,reject:null,awaiting:!1},this.confirmIntent={resolver:null,reject:null,awaiting:!1},this.createMethod={resolver:null,reject:null,awaiting:!1},this.options=i,null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/card-number?options=${JSON.stringify(this.options)}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex card number element iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex card number element iframe"),this.addResizeListener("cardNumber"),window.addEventListener("message",n=>{var s,o,r,a,l,d,c,u,h,p,m,v,g,w,f,y,_,S,b,C,x;if(n.origin===this.gatewayUrl&&n.isTrusted&&"cardNumber"===(null===(s=null==n?void 0:n.data)||void 0===s?void 0:s.type)){if("onSubmit"===(null===(o=n.data)||void 0===o?void 0:o.code)){const e=new CustomEvent(null===(r=n.data)||void 0===r?void 0:r.code,{detail:{},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}if("onReady"===(null===(a=n.data)||void 0===a?void 0:a.code)&&re({elements:t,element:null==t?void 0:t.cardNumber,gatewayUrl:e,type:"cardNumber",popupWidth:null==i?void 0:i.popupWidth,popupHeight:null==i?void 0:i.popupHeight}),"onSuccess"===(null===(l=n.data)||void 0===l?void 0:l.code)&&(this.confirmIntent.resolver(n.data),this.confirmIntent.awaiting=!1),"onError"===(null===(d=n.data)||void 0===d?void 0:d.code)&&(this.confirmIntent.reject(n.data),this.confirmIntent.awaiting=!1),"onRetrieveIntent"===(null===(c=n.data)||void 0===c?void 0:c.code)&&(this.retrieve.resolver(n.data),this.retrieve.awaiting=!1),"onRetrieveIntentError"===(null===(u=n.data)||void 0===u?void 0:u.code)&&(this.retrieve.reject(n.data),this.retrieve.awaiting=!1),"onPaymentMethodCreated"===(null===(h=n.data)||void 0===h?void 0:h.code)&&(this.createMethod.resolver(n.data),this.createMethod.awaiting=!1),"onPaymentMethodCreatedError"===(null===(p=n.data)||void 0===p?void 0:p.code)&&(this.createMethod.reject(n.data),this.createMethod.awaiting=!1),["onFocus","onBlur","onChange"].includes(null===(m=n.data)||void 0===m?void 0:m.code)){const e=new CustomEvent(null===(v=n.data)||void 0===v?void 0:v.code,{detail:{type:"cardNumber",complete:null!==(w=null===(g=n.data)||void 0===g?void 0:g.complete)&&void 0!==w&&w,empty:null!==(y=null===(f=n.data)||void 0===f?void 0:f.empty)&&void 0!==y&&y,error:null===(_=n.data)||void 0===_?void 0:_.error,bankName:null!==(b=null===(S=n.data)||void 0===S?void 0:S.bankName)&&void 0!==b?b:"",brand:null!==(x=null===(C=n.data)||void 0===C?void 0:C.brand)&&void 0!==x?x:""},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}}})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}async confirm(e){var t,i;this.confirmIntent.awaiting&&console.warn("Should waiting previous confirm finished before execute new one!");const{intentId:n}=e||{},s=te(n||"");return null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"confirm",data:{...e,deviceId:s}},this.gatewayUrl),new Promise((e,t)=>{this.confirmIntent.resolver=e,this.confirmIntent.reject=t,this.confirmIntent.awaiting=!0})}async createPaymentMethod(e){var t,i;return this.createMethod.awaiting&&console.warn("Should waiting previous createPaymentMethod finished before execute new one!"),null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"createPaymentMethod",data:e},this.gatewayUrl),new Promise((e,t)=>{this.createMethod.resolver=e,this.createMethod.reject=t,this.createMethod.awaiting=!0})}async getPaymentIntent(e,t){var i,n;return this.retrieve.awaiting&&console.warn("Should waiting previous getPaymentIntent finished before execute new one!"),null===(n=null===(i=this.iframe)||void 0===i?void 0:i.contentWindow)||void 0===n||n.postMessage({code:"getIntent",intentId:e,clientSecret:t},this.gatewayUrl),new Promise((e,t)=>{this.retrieve.resolver=e,this.retrieve.reject=t,this.retrieve.awaiting=!0})}success(e){this.confirmIntent.resolver(e),this.confirmIntent.awaiting=!1}cancel(e="cancelled"){this.confirmIntent.awaiting&&this.confirmIntent.reject({reason:e}),this.retrieve.awaiting&&this.retrieve.reject({reason:e}),this.createMethod.awaiting&&this.createMethod.reject({reason:e}),this.retrieve={resolver:null,reject:null,awaiting:!1},this.confirmIntent={resolver:null,reject:null,awaiting:!1},this.createMethod={resolver:null,reject:null,awaiting:!1}}}class le extends ie{constructor(e,t){var i,n,s;super(e,t),null===(i=this.iframe)||void 0===i||i.setAttribute("src",`${e}/elements/expiry?options=${JSON.stringify(this.options)}`),null===(n=this.iframe)||void 0===n||n.setAttribute("name","Airwallex expiry number element iframe"),null===(s=this.iframe)||void 0===s||s.setAttribute("title","Airwallex expiry number element iframe"),this.addResizeListener("expiry"),window.addEventListener("message",e=>{var t,i,n;if(e.origin===this.gatewayUrl&&e.isTrusted&&"expiry"===(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.type)&&["onFocus","onBlur","onChange"].includes(null===(i=e.data)||void 0===i?void 0:i.code)){const t=new CustomEvent(null===(n=e.data)||void 0===n?void 0:n.code,{detail:{type:"expiry",complete:!0,empty:!1,error:void 0},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}}class de extends ie{constructor(e,t){var i,n,s;super(e,t),null===(i=this.iframe)||void 0===i||i.setAttribute("src",`${e}/elements/cvc?options=${JSON.stringify(this.options)}`),null===(n=this.iframe)||void 0===n||n.setAttribute("name","Airwallex cvc number element iframe"),null===(s=this.iframe)||void 0===s||s.setAttribute("title","Airwallex cvc number element iframe"),this.addResizeListener("cvc"),window.addEventListener("message",e=>{var t,i,n,s,o,r,a;if(e.origin===this.gatewayUrl&&e.isTrusted)if("cvc"===(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.type)&&["onFocus","onBlur","onChange"].includes(null===(i=e.data)||void 0===i?void 0:i.code)){const t=new CustomEvent(null===(n=e.data)||void 0===n?void 0:n.code,{detail:{type:"cvc",complete:!0,empty:!1,error:void 0},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}else"cardNumber"===(null===(s=e.data)||void 0===s?void 0:s.type)&&"onChange"===(null===(o=e.data)||void 0===o?void 0:o.code)&&(null===(a=null===(r=this.iframe)||void 0===r?void 0:r.contentWindow)||void 0===a||a.postMessage({code:"update",options:{cvcLength:e.data.cvcLength}},this.gatewayUrl))})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}}class ce extends ie{constructor(e,t,i){var n,s,o;super(e,i);const{intent:r,...a}=i||{},l=te(null==r?void 0:r.id);null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/payment-request-button?options=${encodeURIComponent(JSON.stringify({...a,deviceId:l}))}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex payment request element iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex payment request element iframe"),this.addResizeListener("paymentRequestButton"),window.addEventListener("message",n=>{var s,o,a,l,d,c;n.origin===this.gatewayUrl&&n.isTrusted&&"paymentRequestButton"===(null===(s=n.data)||void 0===s?void 0:s.type)&&("onReady"===(null===(o=n.data)||void 0===o?void 0:o.code)?(re({elements:t,element:null==t?void 0:t.paymentRequestButton,gatewayUrl:e,type:"paymentRequestButton",popupWidth:null==i?void 0:i.popupWidth,popupHeight:null==i?void 0:i.popupHeight}),null===(l=null===(a=this.iframe)||void 0===a?void 0:a.contentWindow)||void 0===l||l.postMessage({code:"update",options:{intent:r}},this.gatewayUrl)):"onSuccess"===(null===(d=n.data)||void 0===d?void 0:d.code)?this.success(n.data):"onError"===(null===(c=n.data)||void 0===c?void 0:c.code)&&this.cancel(n.data))})}update(e){var t,i;this.options={...this.options,...e};const{intent:n}=this.options||{},s=te(null==n?void 0:n.id);null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:{...e,deviceId:s}},this.gatewayUrl)}success(e){const t=new CustomEvent("CONFIRM_SUCCESS",{detail:{component:"paymentRequestButton",...e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}cancel(e="cancelled"){const t=new CustomEvent("CONFIRM_FAIL",{detail:{component:"paymentRequestButton",error:e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}}class ue extends ie{constructor(e,t,i){var n,s,o;super(e,i);const{intent:r,...a}=i||{},l=te(null==r?void 0:r.id);null===(n=this.iframe)||void 0===n||n.setAttribute("src",`${e}/elements/card?options=${encodeURIComponent(JSON.stringify({...a,deviceId:l}))}`),null===(s=this.iframe)||void 0===s||s.setAttribute("name","Airwallex card element iframe"),null===(o=this.iframe)||void 0===o||o.setAttribute("title","Airwallex card element iframe"),this.addResizeListener("card"),window.addEventListener("message",n=>{var s,o,a,l,d,c;n.origin===this.gatewayUrl&&n.isTrusted&&"card"===(null===(s=n.data)||void 0===s?void 0:s.type)&&("onReady"===(null===(o=n.data)||void 0===o?void 0:o.code)?(re({elements:t,element:null==t?void 0:t.card,gatewayUrl:e,type:"card",popupWidth:null==i?void 0:i.popupWidth,popupHeight:null==i?void 0:i.popupHeight}),null===(l=null===(a=this.iframe)||void 0===a?void 0:a.contentWindow)||void 0===l||l.postMessage({code:"update",options:{intent:r}},this.gatewayUrl)):"onSuccess"===(null===(d=n.data)||void 0===d?void 0:d.code)?this.success(n.data):"onError"===(null===(c=n.data)||void 0===c?void 0:c.code)&&this.cancel(n.data))})}update(e){var t,i;this.options={...this.options,...e};const{intent:n}=this.options||{},s=te(null==n?void 0:n.id);null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:{...e,deviceId:s}},this.gatewayUrl)}success(e){const t=new CustomEvent("CONFIRM_SUCCESS",{detail:{component:"card",...e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}cancel(e="cancelled"){const t=new CustomEvent("CONFIRM_FAIL",{detail:{component:"card",error:e},bubbles:!0,composed:!0});window.document.dispatchEvent(t)}}class he extends ie{constructor(e,t){var i,n,s;super(e,t);const{intent:o,...r}=t||{};null===(i=this.iframe)||void 0===i||i.setAttribute("src",`${e}/elements/wechat?options=${encodeURIComponent(JSON.stringify({...r}))}`),null===(n=this.iframe)||void 0===n||n.setAttribute("name","Airwallex wechat element iframe"),null===(s=this.iframe)||void 0===s||s.setAttribute("title","Airwallex wechat element iframe"),this.addResizeListener("wechat"),window.addEventListener("message",e=>{var t,i,n,s,r,a;e.origin===this.gatewayUrl&&e.isTrusted&&"wechat"===(null===(t=e.data)||void 0===t?void 0:t.type)&&("onReady"===(null===(i=e.data)||void 0===i?void 0:i.code)?null===(s=null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)||void 0===s||s.postMessage({code:"update",options:{intent:o}},this.gatewayUrl):"onSuccess"===(null===(r=e.data)||void 0===r?void 0:r.code)?this.success():"onError"===(null===(a=e.data)||void 0===a?void 0:a.code)&&this.cancel())})}update(e){var t,i;this.options={...this.options,...e},null===(i=null===(t=this.iframe)||void 0===t?void 0:t.contentWindow)||void 0===i||i.postMessage({code:"update",options:e},this.gatewayUrl)}success(){const e=new CustomEvent("CONFIRM_SUCCESS",{detail:{component:"wechat"},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}cancel(){const e=new CustomEvent("CONFIRM_FAIL",{detail:{component:"wechat"},bubbles:!0,composed:!0});window.document.dispatchEvent(e)}}const pe={clientSecret:"",gatewayUrl:"",options:{},cvcLength:4},me={cardNumber:null,expiry:null,cvc:null,threeDsFrictionless:null,threeDsChallenge:null,paymentRequestButton:null,card:null,wechat:null};return customElements.define("airwallex-element",class extends Z{constructor(){super(),this.gatewayBaseurl=this.clientSecret=this.currency=this.intentId=this.customerId="",this.successUrl=this.cancelUrl=this.errorUrl=this.autoCapture=this.enable3dSecure=this.component="",this.theme={},this.height=0}static get properties(){return{gatewayBaseurl:{type:String,reflect:!0},clientSecret:{type:String,reflect:!0},currency:{type:String,reflect:!0},intentId:{type:String,reflect:!0},customerId:{type:String,reflect:!0},successUrl:{type:String,reflect:!0},cancelUrl:{type:String,reflect:!0},errorUrl:{type:String,reflect:!0},enable3dSecure:{type:String,reflect:!0},autoCapture:{type:String,reflect:!0},component:{type:String,reflect:!0},theme:{type:Object,reflect:!0},height:{type:Number,hasChanged:()=>!0}}}static get styles(){return G`
:host {
width: 100%;
height: 100%;
}
`}handleEvent(e){console.info(`Airwallex Checkout Message: [${JSON.stringify(e)}]`);const t=new CustomEvent("airwallex-checkout",{detail:e,bubbles:!0,composed:!0});this.dispatchEvent(t)}checkoutEventHandler(e){if(e.origin===this.gatewayBaseurl&&e.isTrusted){const{style:t,...i}=e.data;if(this.height=(t&&t.height||0)+8,"AWX_CHECKOUT_STYLE"!==e.data.code&&this.handleEvent(i),"AWX_CHECKOUT_SUCCESS"===e.data.code){const t=`${e.data.status?`status=${e.data.status}`:""}${e.data.id?`&intentId=${e.data.id}`:""}`;this.successUrl&&(window.location.href=-1===this.successUrl.indexOf("?")?`${this.successUrl}?${t}`:`${this.successUrl}&${t}`)}else"AWX_CHECKOUT_CANCEL"===e.data.code?this.cancelUrl&&(window.location.href=this.cancelUrl):"AWX_CHECKOUT_ERROR"===e.data.code&&this.errorUrl&&(window.location.href=this.errorUrl);this.requestUpdate()}}connectedCallback(){super.connectedCallback(),window.addEventListener("message",e=>this.checkoutEventHandler(e))}disconnectedCallback(){window.removeEventListener("message",e=>this.checkoutEventHandler(e)),super.disconnectedCallback()}render(){const e=`${this.gatewayBaseurl}/checkout/${this.intentId}?origin=${window.location.origin}&customerId=${this.customerId}&currency=${this.currency}&theme=${encodeURIComponent(JSON.stringify(this.theme))}&autoCapture=${this.autoCapture}&component=${this.component}&enable3dSecure=${this.enable3dSecure}&clientSecret=${encodeURIComponent(this.clientSecret)}&deviceId=${te(this.intentId)}`;return I`
<style>
iframe {
width: 100%;
background: white;
height: ${this.height}px;
}
</style>
<iframe
frameborder="0"
allowtransparency="true"
importance="high"
scrolling="no"
name="${"airwallex_checkout_frame"}"
allowpaymentrequest="true"
src="${e}"
title="Secured airwallex payment frame"
/>
`}}),e.confirmPaymentIntent=async(e,t)=>{console.info(`Confirm with client secret: ${e}`);const{element:i,...n}=t||{};return i?i.confirm(n):t.paymentMethodId?(console.warn("Confirm with payment method id is working in progress!"),!0):(console.warn("Either payment method id or element must be provided for card payment confirm!"),!1)},e.createElement=(e,t)=>["cardNumber","expiry","cvc","paymentRequestButton","card","wechat"].includes(e)?"cardNumber"===e?(me[e]=new ae(pe.gatewayUrl,me,{clientSecret:pe.clientSecret,...pe.options,...t}),me[e]):"card"===e?(me[e]=new ue(pe.gatewayUrl,me,{clientSecret:pe.clientSecret,...pe.options,...t}),me[e]):"wechat"===e?(me[e]=new he(pe.gatewayUrl,{clientSecret:pe.clientSecret,...pe.options,...t}),me[e]):"paymentRequestButton"===e?(me[e]=new ce(pe.gatewayUrl,me,{clientSecret:pe.clientSecret,...pe.options,...t}),me[e]):"expiry"===e||"cvc"===e?(me[e]="expiry"===e?new le(pe.gatewayUrl,{...pe.options,...t}):new de(pe.gatewayUrl,{...pe.options,cvcLength:pe.cvcLength,...t}),window.addEventListener("message",e=>{var t,i,n,s,o,r;e.origin===pe.gatewayUrl&&e.isTrusted&&["expiry","cvc"].includes(null===(t=e.data)||void 0===t?void 0:t.type)&&"onChange"===(null===(i=e.data)||void 0===i?void 0:i.code)&&(null===(o=null===(s=null===(n=me.cardNumber)||void 0===n?void 0:n.iframe)||void 0===s?void 0:s.contentWindow)||void 0===o||o.postMessage({code:`update_${null===(r=e.data)||void 0===r?void 0:r.type}`,data:e.data},pe.gatewayUrl))}),me[e]):null:(console.warn(`createElement with type: ${e} not support!`),null),e.createPaymentMethod=async(e,t)=>(console.info(`Confirm with client secret: ${e}`),t.element?t.element.createPaymentMethod(t):(console.warn("Either payment method id or element must be provided for payment method create!"),!1)),e.destroyElement=e=>{var t;return["cardNumber","expiry","cvc","paymentRequestButton","card","wechat"].includes(e)?(null===(t=me[e])||void 0===t||t.destroy(),me[e]=null,!0):(console.warn(`destroyElement with type: ${e} not support!`),!1)},e.getElement=e=>["cardNumber","expiry","cvc","paymentRequestButton","card","wechat"].includes(e)?me[e]:(console.warn(`getElement with type: ${e} not support!`),null),e.getPaymentIntent=async(e,t)=>{var i;return(null===(i=me.cardNumber)||void 0===i?void 0:i.getPaymentIntent(e,t))||!1},e.init=(e,t,i)=>{pe.clientSecret=e,pe.gatewayUrl=t,pe.options=i},e}({});
/* Airwallex @Charlie.Lang */
//# sourceMappingURL=airwallex.iife.js.map

7

package.json
{
"name": "airwallex-payment-elements",
"version": "0.0.55",
"module": "lib/airwallex.es.js",
"types": "types/index.d.ts",
"version": "0.0.56",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"directories": {

@@ -7,0 +8,0 @@ "lib": "lib"

# airwallex-payment-elements
This universal component is a lightweight wrapper of airwallex checkout widget, which allow merchant site to integrate with airwallex checkout flow.
This universal library is a lightweight javascript SDK, which allow merchant site to integrate with airwallex checkout flow with convenient
By adopt render props pattern, all interaction with the component base on component props, the props interface give merchant fully control on the checkout flow without violation the PCI compliance, also provide maximum flexibility on look and feels customize.
From the merchant perspective, The (Hosted Payment Page)HPP / Drop-in / Elements integration happen after shopper decide to checkout an order, Airwallex javascript SDK help merchant accept payments on merchant website, the whole user experience include create an [PaymentIntent](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/Intro) entity to tacking the payment request which link to merchant’s order information, Airwallex using a payment attempt entity to collect payment methods details from a shopper, and the PaymentIntent entity tracking the [payment attempts](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Attempts/Intro) and state change all the way through user interactions, you can checkout the [PaymentIntent](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/Intro) section for more details
The component provide universal support for all FE framework, no matter Angular / React / VUE. Take advantages of [Web Component](https://github.com/w3c/webcomponents/wiki/Why-Web-Components%3F), more details could be found [W3C Web Component](https://github.com/w3c/webcomponents).
With the API integration from merchant server, after PaymentIntent is successfully created, the response of the API call will also return a unique ID for the PaymentIntent, and a client_secret which act as a single source of truth cross over the shopping experience, each time user's interaction trigger a service call Airwallex client API will validate against the client_secret to secure the payment flow
## Staging Demo
So long story short, the merchant website checkout start with PaymentIntent and client_secret
https://staging-pacheckoutdemo.airwallex.com
Below are the step by step guide to use this library
## Demo
https://demo-pacheckoutdemo.airwallex.com
## Installation

@@ -28,197 +24,242 @@

```js
npm add airwallex-payment-elements
npm install airwallex-payment-elements
```
Or using UMD build:
Or using UMD build from your client HTML:
```js
WIP, will provide when CDN is ready
```html
<script src="https://js.airwallex.com/checkout.min.js"></script>
```
### Getting Started
## Getting Started
### Initialize
```ts
window.Airwallex.init(client_secret: string, gateway_url: string, options?: InitOptions);
```
```client_secret```
Can find it from response when create [PaymentIntent](https://www.airwallex.com/docs/api#/Payment_Acceptance/Payment_Intents/_api_v1_pa_payment_intents_create/post)
```gateway_url``` - [REQUIRED], is the domain url to loading airwallex checkout assets (html, javascript, css, fonts), it's also the server url for user interaction like submit checkout form.
```js
import 'airwallex-payment-elements';
Production: https://checkout.airwallex.com
Demo: https://demo-checkout.airwallex.com
Staging: https://staging-pacheckoutui.airwallex.com
Dev: https://dev-pacheckoutui.airwallex.com/
```
### Render checkout component
```options``` is useful to customize looks and feel of the checkout form when you are adopt Drop-in / Elements integration
#### Sign Up as Airwallex merchant and get merchant ID and Authentication
```ts
interface FontOptions {
family?: string;
src?: string;
weight?: string;
}
export interface InitOptions {
locale?: string;
font?: FontOptions;
}
```
Reference: [Airwallex Web APP](https://www.airwallex.com/app/signup)
### Host Payment Page (HPP) integration
#### Generate Payment Intents
The HPP provide the most convenient way to integrate
Reference: [Airwallex API Doc](https://www.airwallex.com/docs/api)
#### HPP interface
#### [OPTIONAL] Create customer info
```ts
export interface HostPaymentPage {
host: string; // {env}-checkout.airwallex.com | checkout.airwallex.com
clientSecret: string;
theme?: Style;
customerId?: string;
component?: 'default' | 'cards' | 'wechatpay';
successUrl?: string;
failUrl?: string;
cancelUrl?: string;
encodeLogoUrl?: string;
}
```
Reference: [Airwallex API Doc](https://www.airwallex.com/docs/api)
i.e Using default method and looks & feel
#### Render the airwallex-elements on merchant page
```js
<airwallex-element
gatewayBaseurl="https://staging-checkout.airwallex.com"
intentId={intentId}
clientSecret={clientSecret}
countryOrRegion={countryOrRegionCode}
currency={currency}
/>
airwallex.redirectToCheckout({
host: 'checkout.airwallex.com',
clientSecret: 'client_secret',
}
```
### Arguments in action
### Drop-in / Elements integration
```<airwallex-element />```
is a web component customer element, which interacting with Airwallex UI FE to render the payment methods
The primary integration path through this library is with Elements, which enables merchant to collect sensitive payment information(PCI) using customizable UI elements. this library also provides a single interface for Payment Request API
```gatewayBaseurl``` - [REQUIRED], is the domain url to loading airwallex checkout assets (html, javascript, css, fonts), it's also the server url for user interaction like submit checkout form.
With this library, you can also tokenize sensitive information, and handle 3D Secure authentication
```js
Production: https://checkout.airwallex.com
Demo: https://demo-checkout.airwallex.com
Staging: https://staging-pacheckoutui.airwallex.com
Dev: https://dev-pacheckoutui.airwallex.com/
```
Airwallex element is a set of prebuilt UI components, like inputs and buttons, for building your checkout flow. It’s available as a feature of this library. this library handle checkout confirm within an Element without ever having it touch your server
```intentId``` - [REQUIRED], is payment intent id create by calling ```/api/v1/payment_intents/create```
Elements includes features like:
```clientSecret``` - [REQUIRED], is your secret key get from your backend server when create payment intent, Airwallex payment api will use it to verify your true identity
>Formatting card information automatically as it’s entered
```customerId``` - [OPTIONAL], is using for known customer, whom we allow reuse token for fast payment, can be create by calling ```/api/v1/customer/create```, for anonymous user just ignore this prop.
>Customize placeholders to fit your UX design
```countryOrRegionCode``` - [REQUIRED], is two characters code [Country Code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
>Using responsive design to fit the width of your customer’s screen or mobile device
```currency``` - [REQUIRED], is three characters code [Currency Code](https://en.wikipedia.org/wiki/ISO_4217)
>Customizing the styling to match the look and feel of your checkout flow
```component``` - [OPTIONAL],allow value *wechatPay* if you only want to use WeChat Pay, ignore it will render all possible payment methods
#### Create *cardNumber* | *expiry* | *cvc* | *paymentRequestButton* | *card* elements
```enable3dSecure``` - [OPTIONAL], config 3d secure for card payment, using *true* or *false* to enable or disable
***When you select card element type you are actually adopt Drop-in integration***
```autoCapture``` - [OPTIONAL], config whether auto capture for card payment, using *true* or *false* to enable or disable
With Drop-in integration, those prebuilt UI components has been composed into a payment form, you can put it directly into you html page, and integrate with the rest your own components to render your checkout page.
```theme``` - [OPTIONAL], is looks and feels config ***STRING*** prop which give merchant interface to customize the checkout UI, below are support values:
With *cardNumber* | *expiry* | *cvc* | *paymentRequestButton* elements, they are just building blocks:
> You can arrange with any order you want
> Show and hide any one of them at any moment you want
> Customize the looks and feel with your wishes, and most importantly
> You own component can even interact with shoppers when they click or typing in those elements by listen on the events
#### Create element interface
```ts
interface ITheme {
variant: 'outlined' | 'filled' | 'standard' | 'bootstrap';
palette: {
primary: Color; // https://material-ui.com/customization/color/#color
secondary: Color; // https://material-ui.com/customization/color/#color
error: Color; // https://material-ui.com/customization/color/#color
background: {
paper: string;
default: string;
export declare const createElement: (type: "cardNumber" | "expiry" | "cvc" | "paymentRequestButton" | "card" | "wechat", options?: ElementOptions | undefined) => ElementBase | null;
export interface Intent {
id: string;
latest_payment_attempt: {
id: string;
};
text: {
primary: string;
secondary: string;
disabled: string;
hint: string;
};
};
typography: {
htmlFontSize: number;
fontSize: number;
fontFamily: string;
fontWeightLight: number;
fontWeightRegular: number;
fontWeightMedium: number;
fontWeightBold: number;
button: {
textTransform: string;
fontSize: number;
fontWeight: number;
lineHeight: number;
};
};
shape: {
borderRadius: number;
};
zIndex: {
mobileStepper: number;
appBar: number;
drawer: number;
modal: number;
snackbar: number;
tooltip: number;
};
}
export interface Style {
variant: 'outlined' | 'filled' | 'standard' | 'bootstrap';
hidden?: boolean;
backgroundColor?: string;
color?: string;
fontSize?: string;
fontSmoothing?: string;
fontStyle?: string;
fontVariant?: string;
fontWeight?: string;
lineHeight?: string;
letterSpacing?: string;
textAlign?: string;
padding?: number;
textDecoration?: string;
textShadow?: string;
textTransform?: string;
}
export interface ElementOptions {
style?: Style;
placeholder?: string;
cvcLength?: number;
origin?: string;
intent?: Intent;
}
```
Default themes value as below:
#### Browser javascript
```json
{
variant: 'outlined',
palette: {
primary: orange,
secondary: grey,
error: red,
background: {
paper: '#fff',
default: '#fafafa'
},
text: {
primary: '#2A2A2A',
secondary: '#54545E',
disabled: '#A9A9AE',
hint: '#d1d2d5'
}
},
typography: {
htmlFontSize: 16,
fontSize: 14,
fontFamily: 'AxFFDIN'
fontWeightLight: 300,
fontWeightRegular: 400,
fontWeightMedium: 500,
fontWeightBold: 700,
button: {
textTransform: 'unset',
fontSize: 16,
fontWeight: 500,
lineHeight: 2.15
}
},
shape: {
borderRadius: 4
},
zIndex: {
mobileStepper: 1000,
appBar: 1100,
drawer: 1200,
modal: 1300,
snackbar: 1400,
tooltip: 1500
}
}
```js
window.Airwallex.createElement(type, options);
```
Before passing into the theme props, you must ```stringify```(i.e. ```JSON.stringify()```) it as string.
### Mount element
```successUrl / cancelUrl / errorUrl``` - [OPTIONAL], urls for checkout redirection, any valid url works, the checkout component will append status to the url and do the redirection upon user checkout interaction.
i.e
i.e Mount element to div, you can add card html div element in your html template, and call below method will mount them:
```.js
successUrl="https://www.yourwebsite.com/success"
cancelUrl="https://www.yourwebsite.com/cancel"
errorUrl="https://www.yourwebsite.com/error"
```html
<div id='card'></div>
```
```EVENT``` IS NOT PASSING BY PROPS, WILL TRIGGER BY CHECKOUT FLOW.
```js
const cardElement = window.Airwallex.createElement('card');
cardElement.mount('card');
```
To listen on checkout event, merchant page need to add event listener, below is an example:
### Confirm PaymentIntent using mounted element
#### Confirm interface
```ts
export declare const confirmPaymentIntent: (clientSecret: string, data: ConfirmIntentData) => Promise<boolean | Intent>;
```
i.e Confirm using card element
```js
const airwallexElement: any = document.querySelector('airwallex-element');
airwallexElement.addEventListener('airwallex-checkout', ({ detail }: any) => {
// Merchant business flow
});
const payload = {
element: window.Airwallex.getElement('card'),
intentId,
clientSecret,
payment_method: {
billing
}
};
try {
const res = await window.Airwallex.confirmPaymentIntent(clientSecret, payload);
const { confirmResult } = res || {};
const { id, status } = confirmResult || {};
/*
Handle success with below parameters
...({
id,
email,
status
})
*/
} catch (err) {
const { reason } = err;
const { error: { code, message } } = reason || {};
/*
... Handle error with checkout
*/
}
```
### TODO
### Listen to event trigger by shopper interaction
```WIP``` Checkout UI can also listen on merchant event and take on actions.
#### Event interface
```ts
export interface ElementBaseEvent {
type: 'cardNumber' | 'expiry' | 'cvc' | 'paymentRequestButton' | 'card' | 'wechat';
code: 'onReady' | 'onSubmit' | 'onSuccess' | 'onError' | 'onCancel' | 'onFocus' | 'onBlur' | 'onChange' | 'onClick';
complete: boolean;
empty: boolean;
bankName: 'TBD';
brand: string;
error?: {
msg: string;
code: string;
value?: string;
};
}
```
i.e Listen to event when user typing on the input
```ts
window.addEventListener('CONFIRM_SUCCESS', (event: ElementBaseEvent) => {
/*
... Handle event
*/
}
```
## Below are the live demo site you can play with
### Staging Demo
[LINK](https://staging-pacheckoutdemo.airwallex.com)
### Demo
[LINK](https://demo-pacheckoutdemo.airwallex.com)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc