UNPKG

opay

Version:

opay library for Open Payment Protocol

2 lines (1 loc) 43.7 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).opay=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=function(t){return t&&t.Math==Math&&t},r=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||Function("return this")(),o=function(t){try{return!!t()}catch(t){return!0}},i=!o((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),a={}.propertyIsEnumerable,c=Object.getOwnPropertyDescriptor,u={f:c&&!a.call({1:2},1)?function(t){var e=c(this,t);return!!e&&e.enumerable}:a},s=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},l={}.toString,f=function(t){return l.call(t).slice(8,-1)},p="".split,h=o((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==f(t)?p.call(t,""):Object(t)}:Object,d=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},y=function(t){return h(d(t))},v=function(t){return"object"==typeof t?null!==t:"function"==typeof t},m=function(t,e){if(!v(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!v(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!v(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!v(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},g={}.hasOwnProperty,b=function(t,e){return g.call(t,e)},w=r.document,x=v(w)&&v(w.createElement),S=function(t){return x?w.createElement(t):{}},E=!i&&!o((function(){return 7!=Object.defineProperty(S("div"),"a",{get:function(){return 7}}).a})),O=Object.getOwnPropertyDescriptor,j={f:i?O:function(t,e){if(t=y(t),e=m(e,!0),E)try{return O(t,e)}catch(t){}if(b(t,e))return s(!u.f.call(t,e),t[e])}},k=function(t){if(!v(t))throw TypeError(String(t)+" is not an object");return t},_=Object.defineProperty,L={f:i?_:function(t,e,n){if(k(t),e=m(e,!0),k(n),E)try{return _(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},I=i?function(t,e,n){return L.f(t,e,s(1,n))}:function(t,e,n){return t[e]=n,t},P=function(t,e){try{I(r,t,e)}catch(n){r[t]=e}return e},T="__core-js_shared__",R=r[T]||P(T,{}),C=Function.toString;"function"!=typeof R.inspectSource&&(R.inspectSource=function(t){return C.call(t)});var A,D,M,N,q=R.inspectSource,F=r.WeakMap,U="function"==typeof F&&/native code/.test(q(F)),H=e((function(t){(t.exports=function(t,e){return R[t]||(R[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),B=0,G=Math.random(),V=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++B+G).toString(36)},J=H("keys"),W={},K=r.WeakMap;if(U){var $=new K,z=$.get,Q=$.has,Y=$.set;A=function(t,e){return Y.call($,t,e),e},D=function(t){return z.call($,t)||{}},M=function(t){return Q.call($,t)}}else{var X=J[N="state"]||(J[N]=V(N));W[X]=!0,A=function(t,e){return I(t,X,e),e},D=function(t){return b(t,X)?t[X]:{}},M=function(t){return b(t,X)}}var Z={set:A,get:D,has:M,enforce:function(t){return M(t)?D(t):A(t,{})},getterFor:function(t){return function(e){var n;if(!v(e)||(n=D(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},tt=e((function(t){var e=Z.get,n=Z.enforce,o=String(String).split("String");(t.exports=function(t,e,i,a){var c=!!a&&!!a.unsafe,u=!!a&&!!a.enumerable,s=!!a&&!!a.noTargetGet;"function"==typeof i&&("string"!=typeof e||b(i,"name")||I(i,"name",e),n(i).source=o.join("string"==typeof e?e:"")),t!==r?(c?!s&&t[e]&&(u=!0):delete t[e],u?t[e]=i:I(t,e,i)):u?t[e]=i:P(e,i)})(Function.prototype,"toString",(function(){return"function"==typeof this&&e(this).source||q(this)}))})),et=r,nt=function(t){return"function"==typeof t?t:void 0},rt=function(t,e){return arguments.length<2?nt(et[t])||nt(r[t]):et[t]&&et[t][e]||r[t]&&r[t][e]},ot=Math.ceil,it=Math.floor,at=function(t){return isNaN(t=+t)?0:(t>0?it:ot)(t)},ct=Math.min,ut=function(t){return t>0?ct(at(t),9007199254740991):0},st=Math.max,lt=Math.min,ft=function(t,e){var n=at(t);return n<0?st(n+e,0):lt(n,e)},pt=function(t){return function(e,n,r){var o,i=y(e),a=ut(i.length),c=ft(r,a);if(t&&n!=n){for(;a>c;)if((o=i[c++])!=o)return!0}else for(;a>c;c++)if((t||c in i)&&i[c]===n)return t||c||0;return!t&&-1}},ht={includes:pt(!0),indexOf:pt(!1)}.indexOf,dt=function(t,e){var n,r=y(t),o=0,i=[];for(n in r)!b(W,n)&&b(r,n)&&i.push(n);for(;e.length>o;)b(r,n=e[o++])&&(~ht(i,n)||i.push(n));return i},yt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],vt=yt.concat("length","prototype"),mt={f:Object.getOwnPropertyNames||function(t){return dt(t,vt)}},gt={f:Object.getOwnPropertySymbols},bt=rt("Reflect","ownKeys")||function(t){var e=mt.f(k(t)),n=gt.f;return n?e.concat(n(t)):e},wt=function(t,e){for(var n=bt(e),r=L.f,o=j.f,i=0;i<n.length;i++){var a=n[i];b(t,a)||r(t,a,o(e,a))}},xt=/#|\.prototype\./,St=function(t,e){var n=Ot[Et(t)];return n==kt||n!=jt&&("function"==typeof e?o(e):!!e)},Et=St.normalize=function(t){return String(t).replace(xt,".").toLowerCase()},Ot=St.data={},jt=St.NATIVE="N",kt=St.POLYFILL="P",_t=St,Lt=j.f,It=function(t,e){var n,o,i,a,c,u=t.target,s=t.global,l=t.stat;if(n=s?r:l?r[u]||P(u,{}):(r[u]||{}).prototype)for(o in e){if(a=e[o],i=t.noTargetGet?(c=Lt(n,o))&&c.value:n[o],!_t(s?o:u+(l?".":"#")+o,t.forced)&&void 0!==i){if(typeof a==typeof i)continue;wt(a,i)}(t.sham||i&&i.sham)&&I(a,"sham",!0),tt(n,o,a,t)}},Pt=function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t},Tt=function(t,e,n){if(Pt(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}},Rt=function(t){return Object(d(t))},Ct=Array.isArray||function(t){return"Array"==f(t)},At=!!Object.getOwnPropertySymbols&&!o((function(){return!String(Symbol())})),Dt=At&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Mt=H("wks"),Nt=r.Symbol,qt=Dt?Nt:Nt&&Nt.withoutSetter||V,Ft=function(t){return b(Mt,t)||(At&&b(Nt,t)?Mt[t]=Nt[t]:Mt[t]=qt("Symbol."+t)),Mt[t]},Ut=Ft("species"),Ht=function(t,e){var n;return Ct(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!Ct(n.prototype)?v(n)&&null===(n=n[Ut])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)},Bt=[].push,Gt=function(t){var e=1==t,n=2==t,r=3==t,o=4==t,i=6==t,a=5==t||i;return function(c,u,s,l){for(var f,p,d=Rt(c),y=h(d),v=Tt(u,s,3),m=ut(y.length),g=0,b=l||Ht,w=e?b(c,m):n?b(c,0):void 0;m>g;g++)if((a||g in y)&&(p=v(f=y[g],g,d),t))if(e)w[g]=p;else if(p)switch(t){case 3:return!0;case 5:return f;case 6:return g;case 2:Bt.call(w,f)}else if(o)return!1;return i?-1:r||o?o:w}},Vt={forEach:Gt(0),map:Gt(1),filter:Gt(2),some:Gt(3),every:Gt(4),find:Gt(5),findIndex:Gt(6)},Jt=function(t,e){var n=[][t];return!!n&&o((function(){n.call(null,e||function(){throw 1},1)}))},Wt=Object.defineProperty,Kt={},$t=function(t){throw t},zt=function(t,e){if(b(Kt,t))return Kt[t];e||(e={});var n=[][t],r=!!b(e,"ACCESSORS")&&e.ACCESSORS,a=b(e,0)?e[0]:$t,c=b(e,1)?e[1]:void 0;return Kt[t]=!!n&&!o((function(){if(r&&!i)return!0;var t={length:-1};r?Wt(t,1,{enumerable:!0,get:$t}):t[1]=1,n.call(t,a,c)}))},Qt=Vt.forEach,Yt=Jt("forEach"),Xt=zt("forEach"),Zt=Yt&&Xt?[].forEach:function(t){return Qt(this,t,arguments.length>1?arguments[1]:void 0)};It({target:"Array",proto:!0,forced:[].forEach!=Zt},{forEach:Zt});var te=Math.min,ee=[].lastIndexOf,ne=!!ee&&1/[1].lastIndexOf(1,-0)<0,re=Jt("lastIndexOf"),oe=zt("indexOf",{ACCESSORS:!0,1:0}),ie=ne||!re||!oe?function(t){if(ne)return ee.apply(this,arguments)||0;var e=y(this),n=ut(e.length),r=n-1;for(arguments.length>1&&(r=te(r,at(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in e&&e[r]===t)return r||0;return-1}:ee;It({target:"Array",proto:!0,forced:ie!==[].lastIndexOf},{lastIndexOf:ie});var ae,ce,ue=function(t,e,n){var r=m(e);r in t?L.f(t,r,s(0,n)):t[r]=n},se=rt("navigator","userAgent")||"",le=r.process,fe=le&&le.versions,pe=fe&&fe.v8;pe?ce=(ae=pe.split("."))[0]+ae[1]:se&&(!(ae=se.match(/Edge\/(\d+)/))||ae[1]>=74)&&(ae=se.match(/Chrome\/(\d+)/))&&(ce=ae[1]);var he,de=ce&&+ce,ye=Ft("species"),ve=(he="slice",de>=51||!o((function(){var t=[];return(t.constructor={})[ye]=function(){return{foo:1}},1!==t[he](Boolean).foo}))),me=zt("slice",{ACCESSORS:!0,0:0,1:2}),ge=Ft("species"),be=[].slice,we=Math.max;It({target:"Array",proto:!0,forced:!ve||!me},{slice:function(t,e){var n,r,o,i=y(this),a=ut(i.length),c=ft(t,a),u=ft(void 0===e?a:e,a);if(Ct(i)&&("function"!=typeof(n=i.constructor)||n!==Array&&!Ct(n.prototype)?v(n)&&null===(n=n[ge])&&(n=void 0):n=void 0,n===Array||void 0===n))return be.call(i,c,u);for(r=new(void 0===n?Array:n)(we(u-c,0)),o=0;c<u;c++,o++)c in i&&ue(r,o,i[c]);return r.length=o,r}});var xe=L.f,Se=Function.prototype,Ee=Se.toString,Oe=/^\s*function ([^ (]*)/,je="name";i&&!(je in Se)&&xe(Se,je,{configurable:!0,get:function(){try{return Ee.call(this).match(Oe)[1]}catch(t){return""}}});var ke=Object.keys||function(t){return dt(t,yt)};It({target:"Object",stat:!0,forced:o((function(){ke(1)}))},{keys:function(t){return ke(Rt(t))}});var _e={};_e[Ft("toStringTag")]="z";var Le="[object z]"===String(_e),Ie=Ft("toStringTag"),Pe="Arguments"==f(function(){return arguments}()),Te=Le?f:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),Ie))?n:Pe?f(e):"Object"==(r=f(e))&&"function"==typeof e.callee?"Arguments":r},Re=Le?{}.toString:function(){return"[object "+Te(this)+"]"};Le||tt(Object.prototype,"toString",Re,{unsafe:!0});var Ce=r.Promise,Ae=L.f,De=Ft("toStringTag"),Me=Ft("species"),Ne={},qe=Ft("iterator"),Fe=Array.prototype,Ue=Ft("iterator"),He=function(t,e,n,r){try{return r?e(k(n)[0],n[1]):e(n)}catch(e){var o=t.return;throw void 0!==o&&k(o.call(t)),e}},Be=e((function(t){var e=function(t,e){this.stopped=t,this.result=e};(t.exports=function(t,n,r,o,i){var a,c,u,s,l,f,p,h,d=Tt(n,r,o?2:1);if(i)a=t;else{if("function"!=typeof(c=function(t){if(null!=t)return t[Ue]||t["@@iterator"]||Ne[Te(t)]}(t)))throw TypeError("Target is not iterable");if(void 0!==(h=c)&&(Ne.Array===h||Fe[qe]===h)){for(u=0,s=ut(t.length);s>u;u++)if((l=o?d(k(p=t[u])[0],p[1]):d(t[u]))&&l instanceof e)return l;return new e(!1)}a=c.call(t)}for(f=a.next;!(p=f.call(a)).done;)if("object"==typeof(l=He(a,d,p.value,o))&&l&&l instanceof e)return l;return new e(!1)}).stop=function(t){return new e(!0,t)}})),Ge=Ft("iterator"),Ve=!1;try{var Je=0,We={next:function(){return{done:!!Je++}},return:function(){Ve=!0}};We[Ge]=function(){return this},Array.from(We,(function(){throw 2}))}catch(t){}var Ke,$e,ze,Qe=Ft("species"),Ye=function(t,e){var n,r=k(t).constructor;return void 0===r||null==(n=k(r)[Qe])?e:Pt(n)},Xe=rt("document","documentElement"),Ze=/(iphone|ipod|ipad).*applewebkit/i.test(se),tn=r.location,en=r.setImmediate,nn=r.clearImmediate,rn=r.process,on=r.MessageChannel,an=r.Dispatch,cn=0,un={},sn="onreadystatechange",ln=function(t){if(un.hasOwnProperty(t)){var e=un[t];delete un[t],e()}},fn=function(t){return function(){ln(t)}},pn=function(t){ln(t.data)},hn=function(t){r.postMessage(t+"",tn.protocol+"//"+tn.host)};en&&nn||(en=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return un[++cn]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},Ke(cn),cn},nn=function(t){delete un[t]},"process"==f(rn)?Ke=function(t){rn.nextTick(fn(t))}:an&&an.now?Ke=function(t){an.now(fn(t))}:on&&!Ze?(ze=($e=new on).port2,$e.port1.onmessage=pn,Ke=Tt(ze.postMessage,ze,1)):!r.addEventListener||"function"!=typeof postMessage||r.importScripts||o(hn)||"file:"===tn.protocol?Ke=sn in S("script")?function(t){Xe.appendChild(S("script")).onreadystatechange=function(){Xe.removeChild(this),ln(t)}}:function(t){setTimeout(fn(t),0)}:(Ke=hn,r.addEventListener("message",pn,!1)));var dn,yn,vn,mn,gn,bn,wn,xn,Sn={set:en,clear:nn},En=j.f,On=Sn.set,jn=r.MutationObserver||r.WebKitMutationObserver,kn=r.process,_n=r.Promise,Ln="process"==f(kn),In=En(r,"queueMicrotask"),Pn=In&&In.value;Pn||(dn=function(){var t,e;for(Ln&&(t=kn.domain)&&t.exit();yn;){e=yn.fn,yn=yn.next;try{e()}catch(t){throw yn?mn():vn=void 0,t}}vn=void 0,t&&t.enter()},Ln?mn=function(){kn.nextTick(dn)}:jn&&!Ze?(gn=!0,bn=document.createTextNode(""),new jn(dn).observe(bn,{characterData:!0}),mn=function(){bn.data=gn=!gn}):_n&&_n.resolve?(wn=_n.resolve(void 0),xn=wn.then,mn=function(){xn.call(wn,dn)}):mn=function(){On.call(r,dn)});var Tn,Rn,Cn,An,Dn,Mn,Nn,qn=Pn||function(t){var e={fn:t,next:void 0};vn&&(vn.next=e),yn||(yn=e,mn()),vn=e},Fn=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=Pt(e),this.reject=Pt(n)},Un={f:function(t){return new Fn(t)}},Hn=function(t,e){if(k(t),v(e)&&e.constructor===t)return e;var n=Un.f(t);return(0,n.resolve)(e),n.promise},Bn=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Gn=Sn.set,Vn=Ft("species"),Jn="Promise",Wn=Z.get,Kn=Z.set,$n=Z.getterFor(Jn),zn=Ce,Qn=r.TypeError,Yn=r.document,Xn=r.process,Zn=rt("fetch"),tr=Un.f,er=tr,nr="process"==f(Xn),rr=!!(Yn&&Yn.createEvent&&r.dispatchEvent),or="unhandledrejection",ir=_t(Jn,(function(){if(!(q(zn)!==String(zn))){if(66===de)return!0;if(!nr&&"function"!=typeof PromiseRejectionEvent)return!0}if(de>=51&&/native code/.test(zn))return!1;var t=zn.resolve(1),e=function(t){t((function(){}),(function(){}))};return(t.constructor={})[Vn]=e,!(t.then((function(){}))instanceof e)})),ar=ir||!function(t,e){if(!e&&!Ve)return!1;var n=!1;try{var r={};r[Ge]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n}((function(t){zn.all(t).catch((function(){}))})),cr=function(t){var e;return!(!v(t)||"function"!=typeof(e=t.then))&&e},ur=function(t,e,n){if(!e.notified){e.notified=!0;var r=e.reactions;qn((function(){for(var o=e.value,i=1==e.state,a=0;r.length>a;){var c,u,s,l=r[a++],f=i?l.ok:l.fail,p=l.resolve,h=l.reject,d=l.domain;try{f?(i||(2===e.rejection&&pr(t,e),e.rejection=1),!0===f?c=o:(d&&d.enter(),c=f(o),d&&(d.exit(),s=!0)),c===l.promise?h(Qn("Promise-chain cycle")):(u=cr(c))?u.call(c,p,h):p(c)):h(o)}catch(t){d&&!s&&d.exit(),h(t)}}e.reactions=[],e.notified=!1,n&&!e.rejection&&lr(t,e)}))}},sr=function(t,e,n){var o,i;rr?((o=Yn.createEvent("Event")).promise=e,o.reason=n,o.initEvent(t,!1,!0),r.dispatchEvent(o)):o={promise:e,reason:n},(i=r["on"+t])?i(o):t===or&&function(t,e){var n=r.console;n&&n.error&&(1===arguments.length?n.error(t):n.error(t,e))}("Unhandled promise rejection",n)},lr=function(t,e){Gn.call(r,(function(){var n,r=e.value;if(fr(e)&&(n=Bn((function(){nr?Xn.emit("unhandledRejection",r,t):sr(or,t,r)})),e.rejection=nr||fr(e)?2:1,n.error))throw n.value}))},fr=function(t){return 1!==t.rejection&&!t.parent},pr=function(t,e){Gn.call(r,(function(){nr?Xn.emit("rejectionHandled",t):sr("rejectionhandled",t,e.value)}))},hr=function(t,e,n,r){return function(o){t(e,n,o,r)}},dr=function(t,e,n,r){e.done||(e.done=!0,r&&(e=r),e.value=n,e.state=2,ur(t,e,!0))},yr=function(t,e,n,r){if(!e.done){e.done=!0,r&&(e=r);try{if(t===n)throw Qn("Promise can't be resolved itself");var o=cr(n);o?qn((function(){var r={done:!1};try{o.call(n,hr(yr,t,r,e),hr(dr,t,r,e))}catch(n){dr(t,r,n,e)}})):(e.value=n,e.state=1,ur(t,e,!1))}catch(n){dr(t,{done:!1},n,e)}}};ir&&(zn=function(t){!function(t,e,n){if(!(t instanceof e))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation")}(this,zn,Jn),Pt(t),Tn.call(this);var e=Wn(this);try{t(hr(yr,this,e),hr(dr,this,e))}catch(t){dr(this,e,t)}},(Tn=function(t){Kn(this,{type:Jn,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=function(t,e,n){for(var r in e)tt(t,r,e[r],n);return t}(zn.prototype,{then:function(t,e){var n=$n(this),r=tr(Ye(this,zn));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=nr?Xn.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&ur(this,n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),Rn=function(){var t=new Tn,e=Wn(t);this.promise=t,this.resolve=hr(yr,t,e),this.reject=hr(dr,t,e)},Un.f=tr=function(t){return t===zn||t===Cn?new Rn(t):er(t)},"function"==typeof Ce&&(An=Ce.prototype.then,tt(Ce.prototype,"then",(function(t,e){var n=this;return new zn((function(t,e){An.call(n,t,e)})).then(t,e)}),{unsafe:!0}),"function"==typeof Zn&&It({global:!0,enumerable:!0,forced:!0},{fetch:function(t){return Hn(zn,Zn.apply(r,arguments))}}))),It({global:!0,wrap:!0,forced:ir},{Promise:zn}),Mn=Jn,Nn=!1,(Dn=zn)&&!b(Dn=Nn?Dn:Dn.prototype,De)&&Ae(Dn,De,{configurable:!0,value:Mn}),function(t){var e=rt(t),n=L.f;i&&e&&!e[Me]&&n(e,Me,{configurable:!0,get:function(){return this}})}(Jn),Cn=rt(Jn),It({target:Jn,stat:!0,forced:ir},{reject:function(t){var e=tr(this);return e.reject.call(void 0,t),e.promise}}),It({target:Jn,stat:!0,forced:ir},{resolve:function(t){return Hn(this,t)}}),It({target:Jn,stat:!0,forced:ar},{all:function(t){var e=this,n=tr(e),r=n.resolve,o=n.reject,i=Bn((function(){var n=Pt(e.resolve),i=[],a=0,c=1;Be(t,(function(t){var u=a++,s=!1;i.push(void 0),c++,n.call(e,t).then((function(t){s||(s=!0,i[u]=t,--c||r(i))}),o)})),--c||r(i)}));return i.error&&o(i.value),n.promise},race:function(t){var e=this,n=tr(e),r=n.reject,o=Bn((function(){var o=Pt(e.resolve);Be(t,(function(t){o.call(e,t).then(n.resolve,r)}))}));return o.error&&r(o.value),n.promise}});var vr=function(){var t=k(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e};function mr(t,e){return RegExp(t,e)}var gr,br,wr={UNSUPPORTED_Y:o((function(){var t=mr("a","y");return t.lastIndex=2,null!=t.exec("abcd")})),BROKEN_CARET:o((function(){var t=mr("^r","gy");return t.lastIndex=2,null!=t.exec("str")}))},xr=RegExp.prototype.exec,Sr=String.prototype.replace,Er=xr,Or=(gr=/a/,br=/b*/g,xr.call(gr,"a"),xr.call(br,"a"),0!==gr.lastIndex||0!==br.lastIndex),jr=wr.UNSUPPORTED_Y||wr.BROKEN_CARET,kr=void 0!==/()??/.exec("")[1];(Or||kr||jr)&&(Er=function(t){var e,n,r,o,i=this,a=jr&&i.sticky,c=vr.call(i),u=i.source,s=0,l=t;return a&&(-1===(c=c.replace("y","")).indexOf("g")&&(c+="g"),l=String(t).slice(i.lastIndex),i.lastIndex>0&&(!i.multiline||i.multiline&&"\n"!==t[i.lastIndex-1])&&(u="(?: "+u+")",l=" "+l,s++),n=new RegExp("^(?:"+u+")",c)),kr&&(n=new RegExp("^"+u+"$(?!\\s)",c)),Or&&(e=i.lastIndex),r=xr.call(a?n:i,l),a?r?(r.input=r.input.slice(s),r[0]=r[0].slice(s),r.index=i.lastIndex,i.lastIndex+=r[0].length):i.lastIndex=0:Or&&r&&(i.lastIndex=i.global?r.index+r[0].length:e),kr&&r&&r.length>1&&Sr.call(r[0],n,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(r[o]=void 0)})),r});var _r=Er;It({target:"RegExp",proto:!0,forced:/./.exec!==_r},{exec:_r});var Lr="toString",Ir=RegExp.prototype,Pr=Ir.toString,Tr=o((function(){return"/a/b"!=Pr.call({source:"a",flags:"b"})})),Rr=Pr.name!=Lr;(Tr||Rr)&&tt(RegExp.prototype,Lr,(function(){var t=k(this),e=String(t.source),n=t.flags;return"/"+e+"/"+String(void 0===n&&t instanceof RegExp&&!("flags"in Ir)?vr.call(t):n)}),{unsafe:!0});var Cr=Ft("species"),Ar=!o((function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")})),Dr="$0"==="a".replace(/./,"$0"),Mr=Ft("replace"),Nr=!!/./[Mr]&&""===/./[Mr]("a","$0"),qr=!o((function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var n="ab".split(t);return 2!==n.length||"a"!==n[0]||"b"!==n[1]})),Fr=Ft("match"),Ur=function(t){return function(e,n){var r,o,i=String(d(e)),a=at(n),c=i.length;return a<0||a>=c?t?"":void 0:(r=i.charCodeAt(a))<55296||r>56319||a+1===c||(o=i.charCodeAt(a+1))<56320||o>57343?t?i.charAt(a):r:t?i.slice(a,a+2):o-56320+(r-55296<<10)+65536}},Hr={codeAt:Ur(!1),charAt:Ur(!0)}.charAt,Br=function(t,e,n){return e+(n?Hr(t,e).length:1)},Gr=function(t,e){var n=t.exec;if("function"==typeof n){var r=n.call(t,e);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==f(t))throw TypeError("RegExp#exec called on incompatible receiver");return _r.call(t,e)},Vr=[].push,Jr=Math.min,Wr=4294967295,Kr=!o((function(){return!RegExp(Wr,"y")}));!function(t,e,n,r){var i=Ft(t),a=!o((function(){var e={};return e[i]=function(){return 7},7!=""[t](e)})),c=a&&!o((function(){var e=!1,n=/a/;return"split"===t&&((n={}).constructor={},n.constructor[Cr]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return e=!0,null},n[i](""),!e}));if(!a||!c||"replace"===t&&(!Ar||!Dr||Nr)||"split"===t&&!qr){var u=/./[i],s=n(i,""[t],(function(t,e,n,r,o){return e.exec===_r?a&&!o?{done:!0,value:u.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1}}),{REPLACE_KEEPS_$0:Dr,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:Nr}),l=s[0],f=s[1];tt(String.prototype,t,l),tt(RegExp.prototype,i,2==e?function(t,e){return f.call(t,this,e)}:function(t){return f.call(t,this)})}r&&I(RegExp.prototype[i],"sham",!0)}("split",2,(function(t,e,n){var r;return r="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(t,n){var r=String(d(this)),o=void 0===n?Wr:n>>>0;if(0===o)return[];if(void 0===t)return[r];if(!function(t){var e;return v(t)&&(void 0!==(e=t[Fr])?!!e:"RegExp"==f(t))}(t))return e.call(r,t,o);for(var i,a,c,u=[],s=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),l=0,p=new RegExp(t.source,s+"g");(i=_r.call(p,r))&&!((a=p.lastIndex)>l&&(u.push(r.slice(l,i.index)),i.length>1&&i.index<r.length&&Vr.apply(u,i.slice(1)),c=i[0].length,l=a,u.length>=o));)p.lastIndex===i.index&&p.lastIndex++;return l===r.length?!c&&p.test("")||u.push(""):u.push(r.slice(l)),u.length>o?u.slice(0,o):u}:"0".split(void 0,0).length?function(t,n){return void 0===t&&0===n?[]:e.call(this,t,n)}:e,[function(e,n){var o=d(this),i=null==e?void 0:e[t];return void 0!==i?i.call(e,o,n):r.call(String(o),e,n)},function(t,o){var i=n(r,t,this,o,r!==e);if(i.done)return i.value;var a=k(t),c=String(this),u=Ye(a,RegExp),s=a.unicode,l=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.unicode?"u":"")+(Kr?"y":"g"),f=new u(Kr?a:"^(?:"+a.source+")",l),p=void 0===o?Wr:o>>>0;if(0===p)return[];if(0===c.length)return null===Gr(f,c)?[c]:[];for(var h=0,d=0,y=[];d<c.length;){f.lastIndex=Kr?d:0;var v,m=Gr(f,Kr?c:c.slice(d));if(null===m||(v=Jr(ut(f.lastIndex+(Kr?0:d)),c.length))===h)d=Br(c,d,s);else{if(y.push(c.slice(h,d)),y.length===p)return y;for(var g=1;g<=m.length-1;g++)if(y.push(m[g]),y.length===p)return y;d=h=v}}return y.push(c.slice(h)),y}]}),!Kr);for(var $r in{CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}){var zr=r[$r],Qr=zr&&zr.prototype;if(Qr&&Qr.forEach!==Zt)try{I(Qr,"forEach",Zt)}catch(t){Qr.forEach=Zt}}var Yr,Xr,Zr,to=e((function(t){var e=function(t){var e,n=Object.prototype,r=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function s(t,e,n,r){var o=e&&e.prototype instanceof v?e:v,i=Object.create(o.prototype),a=new L(r||[]);return i._invoke=function(t,e,n){var r=f;return function(o,i){if(r===h)throw new Error("Generator is already running");if(r===d){if("throw"===o)throw i;return P()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=j(a,n);if(c){if(c===y)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===f)throw r=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=h;var u=l(t,e,n);if("normal"===u.type){if(r=n.done?d:p,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=d,n.method="throw",n.arg=u.arg)}}}(t,n,a),i}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f="suspendedStart",p="suspendedYield",h="executing",d="completed",y={};function v(){}function m(){}function g(){}var b={};b[i]=function(){return this};var w=Object.getPrototypeOf,x=w&&w(w(I([])));x&&x!==n&&r.call(x,i)&&(b=x);var S=g.prototype=v.prototype=Object.create(b);function E(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function n(o,i,a,c){var u=l(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function j(t,n){var r=t.iterator[n.method];if(r===e){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=e,j(t,n),"throw"===n.method))return y;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var o=l(r,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,y;var i=o.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function I(t){if(t){var n=t[i];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}return{next:P}}function P(){return{value:e,done:!0}}return m.prototype=S.constructor=g,g.constructor=m,m.displayName=u(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,u(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},E(O.prototype),O.prototype[a]=function(){return this},t.AsyncIterator=O,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new O(s(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(S),u(S,c,"Generator"),S[i]=function(){return this},S.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n}return n.done=!0,n}},t.values=I,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(_),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),_(n),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;_(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:I(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function eo(t){return(eo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function no(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function ro(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function a(t){no(i,r,o,a,c,"next",t)}function c(t){no(i,r,o,a,c,"throw",t)}a(void 0)}))}}function oo(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function io(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ao(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function co(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ao(Object(n),!0).forEach((function(e){io(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ao(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}Xr=void 0,Zr=function(){var t="application/x-postmate-v1+json",e=0,n={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},r=function(e,r){return!("string"==typeof r&&e.origin!==r||!e.data||"object"==eo(e.data)&&!("postmate"in e.data)||e.data.type!==t||!n[e.data.postmate])},o=function(){function n(t){var e=this;this.parent=t.parent,this.frame=t.frame,this.child=t.child,this.childOrigin=t.childOrigin,this.events={},this.listener=function(t){if(!r(t,e.childOrigin))return!1;var n=((t||{}).data||{}).value||{},o=n.data,i=n.name;"emit"===t.data.postmate&&i in e.events&&e.events[i].forEach((function(t){t.call(e,o)}))},this.parent.addEventListener("message",this.listener,!1)}var o=n.prototype;return o.get=function(n){var r=this;return new a.Promise((function(o){var i=++e;r.parent.addEventListener("message",(function t(e){e.data.uid===i&&"reply"===e.data.postmate&&(r.parent.removeEventListener("message",t,!1),o(e.data.value))}),!1),r.child.postMessage({postmate:"request",type:t,property:n,uid:i},r.childOrigin)}))},o.call=function(e,n){this.child.postMessage({postmate:"call",type:t,property:e,data:n},this.childOrigin)},o.on=function(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)},o.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},n}(),i=function(){function e(e){var n=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",(function(e){if(r(e,n.parentOrigin)){var o,i,c,u=e.data,s=u.property,l=u.uid,f=u.data;"call"!==e.data.postmate?(o=n.model,i=s,c="function"==typeof o[i]?o[i]():o[i],a.Promise.resolve(c)).then((function(n){return e.source.postMessage({property:s,postmate:"reply",type:t,uid:l,value:n},e.origin)})):s in n.model&&"function"==typeof n.model[s]&&n.model[s](f)}}))}return e.prototype.emit=function(e,n){this.parent.postMessage({postmate:"emit",type:t,value:{name:e,data:n}},this.parentOrigin)},e}(),a=function(){function e(t){var e=t.container,n=void 0===e?void 0!==n?n:document.body:e,r=t.model,o=t.url,i=t.name,a=t.classListArray,c=void 0===a?[]:a;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=i||"",this.frame.classList.add.apply(this.frame.classList,c),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=r||{},this.sendHandshake(o)}return e.prototype.sendHandshake=function(n){var i,a=this,c=function(t){var e=document.createElement("a");e.href=t;var n=4<e.protocol.length?e.protocol:window.location.protocol,r=e.host.length?"80"===e.port||"443"===e.port?e.hostname:e.host:window.location.host;return e.origin||n+"//"+r}(n),u=0;return new e.Promise((function(e,s){a.parent.addEventListener("message",(function t(n){return!!r(n,c)&&("handshake-reply"===n.data.postmate?(clearInterval(i),a.parent.removeEventListener("message",t,!1),a.childOrigin=n.origin,e(new o(a))):s("Failed handshake"))}),!1);var l=function(){u++,a.child.postMessage({postmate:"handshake",type:t,model:a.model},c),5===u&&clearInterval(i)},f=function(){l(),i=setInterval(l,500)};a.frame.attachEvent?a.frame.attachEvent("onload",f):a.frame.addEventListener("load",f),a.frame.src=n}))},e}();return a.debug=!1,a.Promise=function(){try{return window?window.Promise:Promise}catch(t){return null}}(),a.Model=function(){function e(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}return e.prototype.sendHandshakeReply=function(){var e=this;return new a.Promise((function(n,r){e.child.addEventListener("message",(function o(a){if(a.data.postmate){if("handshake"!==a.data.postmate)return r("Handshake Reply Failed");e.child.removeEventListener("message",o,!1),a.source.postMessage({postmate:"handshake-reply",type:t},a.origin),e.parentOrigin=a.origin;var c=a.data.model;return c&&Object.keys(c).forEach((function(t){e.model[t]=c[t]})),n(new i(e))}}),!1)}))},e}(),a},"object"==("undefined"==typeof exports?"undefined":eo(exports))&&"undefined"!=typeof module?module.exports=Zr():"function"==typeof define&&define.amd?define(Zr):(Xr=Xr||self).Postmate=Zr();var uo={},so=(io(Yr={product:"OPay Product",timeout:300,app:{name:"Opay App"},debug:!1,handshake:null,child:null,elFrame:null,event_on:!1,cb:null},"debug",!1),io(Yr,"expireObj",{}),io(Yr,"current_orderID",0),io(Yr,"wallet",null),io(Yr,"UI",{close:!0}),Yr),lo=null,fo=document.currentScript.src,po="https://nb-namecheck.glitch.me",ho=console.log;function yo(t){ho("in clearChecker");var e=uo.expireObj[t];return!!e&&(ho("clearChecker timeoutID:",e.timeoutID),uo.expireObj[t]=null,!0)}function vo(t){return mo.apply(this,arguments)}function mo(){return(mo=ro(to.mark((function t(e){var n,r,o,i;return to.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(ho("checker:",uo.expireObj,"ID:",e),null!=(n=uo.expireObj[e])){t.next=5;break}return ho("no checkingObj"),t.abrupt("return");case 5:if(!(Date.now()>n.expire)){t.next=9;break}return yo(e),t.abrupt("return");case 9:return ho(r=po+"/get_pr/"+e+"?notify=1"),t.next=13,fetch(r);case 13:return o=t.sent,t.next=16,o.text();case 16:return i=t.sent,ho(i),"404"!=i?go(!1,i):(ho("continue to check"),n.timeoutID=setTimeout(vo,2e3,e)),t.abrupt("return",i);case 20:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function go(t,e){if(yo(uo.current_orderID)||t){var n=JSON.parse(e);n.usedWallet=uo.usedWallet,ho("got_reply1 data=",n,"isVbox:",t);var r=uo.cb(n);if(ho("return from app:",r),n.ack_url&&r){var o=r;o.id=n.id;var i=n.ack_url+"?ack="+JSON.stringify(o);fetch(i)}xo.close()}}function bo(t,e){return wo.apply(this,arguments)}function wo(){return(wo=ro(to.mark((function t(e,n){return to.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){var r=document.createElement("script");r.type="text/javascript",r.readyState?r.onreadystatechange=function(){"loaded"!=r.readyState&&"complete"!=r.readyState||(r.onreadystatechange=null,n&&(n(),t()))}:r.onload=function(){n&&(n(),t())},r.src=e,document.getElementsByTagName("head")[0].appendChild(r)})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var xo=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,n,r,o,i;return e=t,n=null,r=[{key:"init",value:(i=ro(to.mark((function t(e){return to.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(uo=co(co({},so),e),e.debug||(ho=function(t){}),ho("opay init option=",e),!window.opay_inited){t.next=5;break}return t.abrupt("return");case 5:return t.next=7,this._initLibs();case 7:window.opay_inited=!0;case 8:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"_initLibs",value:(o=ro(to.mark((function e(){var n;return to.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(window.filepay){e.next=6;break}return ho("loading filepay"),e.next=4,bo("https://unpkg.com/filepay@latest/dist/filepay.min.js",(function(){window.filepay?(t.filepay=window.filepay,t.bsv=window.filepay.bsv,ho("filepay loaded:",window.filepay)):ho("filepay failed to load")}));case 4:e.next=8;break;case 6:t.filepay=window.filepay,t.bsv=window.filepay.bsv;case 8:(n=document.createElement("style")).type="text/css",n.innerHTML="\n .opayClass { position: absolute;\n display:none;\n width:100%;\n height:100%;\n top: 0;\n left: 0;\n /* bring your own prefixes */\n border-radius: 5px;\n border:1px solid #BDBDBD;\n background:#fff;\n }\n\n ",document.getElementsByTagName("head")[0].appendChild(n);case 12:case"end":return e.stop()}}),e)}))),function(){return o.apply(this,arguments)})},{key:"_setupIframe",value:function(){var t=document.querySelector("iframe[name='my-iframe-opay']");if(ho("Create opay Frame"),lo){ho("gHandshake exist. Destroy child"),lo.then((function(t){return t.destroy()})),uo.event_on=!1;var e=document.querySelector("iframe[name='my-iframe-opay']");if(e){var n=e.parentNode;ho("found frame and destory it:",n),n.removeChild(e)}}var r=fo.slice(0,fo.lastIndexOf("/"))+"/iframe.html",o=document.querySelector("body");null!=uo.containerID&&((o=document.querySelector("#"+uo.containerID)).style.position="relative"),lo=new Postmate({container:o,url:r,name:"my-iframe-opay",classListArray:["opayClass"]}),uo.elFrame=document.querySelector("iframe[name='my-iframe-opay']"),t=uo.elFrame,uo.UI&&(uo.UI.border&&(t.style.border=uo.UI.border),lo.then((function(t){window.VBox&&(uo.UI.VBox=!0),ho("Calling child:",uo.UI),t.call("setUI",uo.UI)})))}},{key:"setWallet",value:function(t){uo.wallet=t}},{key:"close",value:function(){yo(uo.current_orderID),uo.elFrame&&(uo.elFrame.style.display="none")}},{key:"setUI",value:function(t){uo.UI=t}},{key:"changeContainer",value:function(t){var e=document.querySelector("#"+t);e&&(e.style.position="relative",uo.elFrame&&e.appendChild(uo.elFrame),uo.containerID=t)}},{key:"sha256",value:function(e){return t.bsv.crypto.Hash.sha256(t.bsv.deps.Buffer(e)).toString("hex")}},{key:"verify",value:function(e,n,r){var o=t.bsv,i=o.crypto.Signature.fromString(n),a=o.PublicKey.fromString(r),c=o.crypto.Hash.sha256(o.deps.Buffer.from(e,"hex"));return o.crypto.ECDSA.verify(c,i,a)}},{key:"getSupportedWallets",value:function(){return["vbox","dot"]}},{key:"genQRImg",value:function(e,n,r){uo.cb=r,bo("https://cdnjs.cloudflare.com/ajax/libs/qrcode-generator/1.4.4/qrcode.min.js",(function(){t._preHandleOptions(e);var r=t.genQRString(e),o=qrcode(0,"L");o.addData(r),o.make();var i=o.createImgTag();document.getElementById(n).innerHTML=i,t.start_checker()}))}},{key:"genQRString",value:function(t){var e=null;if(t.pay_request&&(e=t.pay_request),t.sign_request&&(e=t.sign_request),null==e.url){var n=e.data;n.notify_url=po+"/notify",fetch("https://nb-namecheck.glitch.me/save_pr",{method:"post",headers:{Accept:"application/json, text/plain, */*","Content-Type":"application/json"},body:JSON.stringify(n)}).then((function(t){return t.json()})).then((function(t){ho("reply from save_pr:",t)}));var r="https://nb-namecheck.glitch.me/get_pr/"+n.id,o=t.pay_request?{pay_request:{url:r}}:{sign_request:{url:r}};return JSON.stringify(o)}return null}},{key:"_preHandleOptions",value:function(t){uo.options=t;var e={};t.pay_request&&(e=t.pay_request),t.sign_request&&(e=t.sign_request),ho(JSON.stringify(t));var n=e.data;if(n.to)for(var r=0;r<n.to.length;r++){var o=n.to[r];if(o.data){var i=window.filepay.data2script(o.data).toHex();o.script=i,o.value=0,delete o.data}}n.product||(n.product=uo.product),n.expire||(n.expire=Date.now()+1e3*uo.timeout),n.id||(n.id=Date.now().toString()),n.v||(n.v=2),n.app||(n.app=uo.app)}},{key:"start_checker",value:function(){var t=uo.options.pay_request?uo.options.pay_request.data:uo.options.sign_request.data;if(uo.current_orderID=t.id,uo.current_orderID){var e=setTimeout(vo,2e3,uo.current_orderID);ho("checker started, timeoutID:",e),uo.expireObj[uo.current_orderID]={expire:t.expire,timeoutID:e}}}},{key:"request",value:function(e,n){uo.cb=n,t._preHandleOptions(e);var r=t.genQRString(e);if(uo.wallet)a(uo.wallet);else{var o={},i=("; "+document.cookie).split("; nbpay_state=").pop().split(";").shift();""!=i&&(o=JSON.parse(i)),uo.wallet||t._setupIframe(),lo.then((function(e){uo.child=e,uo.event_on||(e.on("opay_frm_cmd",(function(e){if(ho(e),"close"==e.cmd){uo.elFrame.style.display="none";var n=JSON.stringify(e.state);document.cookie="nbpay_state="+n,t.close(),"function"==typeof uo.UI.close&&uo.UI.close()}if("wallet"==e.cmd&&(a(e.name),e.state)){var r=JSON.stringify(e.state);document.cookie="nbpay_state="+r}})),uo.event_on=!0),function(e){console.log("calling setup:",e),uo.elFrame.style.display="block",e.call("setup",{strQR:r,state:o}),t.start_checker()}(e)}))}function a(e){if(uo.usedWallet=e,uo.wallet=e,"dot"===e){var n="https://www.ddpurse.com/wallet/open/nbdomain?opp=";n+=encodeURIComponent(r),window.open(n,uo.current_orderID),t.start_checker()}if("vbox"===e){var o=uo.options.pay_request?{pay_request:{data:JSON.stringify(uo.options.pay_request.data)}}:{sign_request:{data:JSON.stringify(uo.options.sign_request.data)}};ho("calling vbox with options:",o),VBox.Request(o,(function(t){go(!0,t)}))}}}}],n&&oo(e.prototype,n),r&&oo(e,r),t}();return xo}));