@malga-checkout-full/core
Version:
Core components for Malga Checkout Full
1 lines • 23.5 kB
JavaScript
import{c as e,s as t}from"./p-e69718a5.js";import{b as r,s as i}from"./p-d5eacf76.js";import{c as o}from"./p-2a19115a.js";import"./p-a0ceaf8b.js";import{c as n,a}from"./p-3e8ff66b.js";import{Z as s}from"./p-a24853cf.js";const l=e=>e?e.replace(/[^a-zA-Z0-9]/g,"").trim():e;var d,b=new Uint8Array(16);function c(){if(!d&&!(d="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return d(b)}const u=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function p(e){return"string"==typeof e&&u.test(e)}for(var m=[],h=0;h<256;++h)m.push((h+256).toString(16).substr(1));function f(e,t,r){var i=(e=e||{}).random||(e.rng||c)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){r=r||0;for(var o=0;o<16;++o)t[r+o]=i[o];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(m[e[t+0]]+m[e[t+1]]+m[e[t+2]]+m[e[t+3]]+"-"+m[e[t+4]]+m[e[t+5]]+"-"+m[e[t+6]]+m[e[t+7]]+"-"+m[e[t+8]]+m[e[t+9]]+"-"+m[e[t+10]]+m[e[t+11]]+m[e[t+12]]+m[e[t+13]]+m[e[t+14]]+m[e[t+15]]).toLowerCase();if(!p(r))throw TypeError("Stringified UUID is invalid");return r}(i)}const{state:S}=e({configs:{mode:"success",open:!1,amount:0,paymentCode:"",paymentImageUrl:"",expirationDate:"",expirationTime:0,successMessage:"",errorTitle:"",errorMessage:""}}),y=e=>{if(!e)return{};const t="br"===e.country.toLowerCase()?o(e.zipCode):l(e.zipCode);return{address:{country:e.country,state:e.state,city:e.city,district:e.district,zipCode:t,street:e.street,streetNumber:e.streetNumber,complement:e.complement}}},g=(e,t=!1)=>{if(!e||"noDocument"===e.type)return t?null:{document:{type:"noDocument"}};const r=["cpf","cnpj"].includes(e.type.toLowerCase())?o(e.number):l(e.number);return{document:{type:t?e.type.toUpperCase():e.type.toLowerCase(),number:r,country:e.country}}},x=(e,t=!1)=>{const r=y(e.address),i=g(e.document,t);return Object.assign(Object.assign(Object.assign({},r),i),{phoneNumber:(null==e?void 0:e.phoneNumber)?o(e.phoneNumber):" ",name:e.name,email:e.email})},O=e=>{const t=y(e.address),r=g(e.document),i=(null==e?void 0:e.phoneNumber)?o(e.phoneNumber):" ",n=Object.values(e.address?e.address:{}).some((e=>e)),a=Object.assign(Object.assign({},r),{name:e.name,email:e.email,phoneNumber:i});return n?Object.assign(Object.assign({},t),a):a};class v{constructor({customerId:e,customer:t}){this.customerId=e,this.customer=t}getCustomerMethod(){return this.customerId?{customerId:this.customerId}:{customer:O(this.customer)}}getPaymentSource(){const e=this.getCustomerMethod();return Object.assign({sourceType:"customer"},e)}}var w=n((function(e,t){(function(){var r={function:!0,object:!0},i=r[typeof window]&&window||this,o=r.object&&t,n=r.object&&e&&!e.nodeType&&e,s=o&&n&&"object"==typeof a&&a;!s||s.global!==s&&s.window!==s&&s.self!==s||(i=s);var l=Math.pow(2,53)-1,d=/\bOpera/,b=Object.prototype,c=b.hasOwnProperty,u=b.toString;function p(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function m(e){return e=g(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:p(e)}function h(e,t){for(var r in e)c.call(e,r)&&t(e[r],r,e)}function f(e){return null==e?p(e):u.call(e).slice(8,-1)}function S(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function y(e,t){var r=null;return function(e,t){var r=-1,i=e?e.length:0;if("number"==typeof i&&i>-1&&i<=l)for(;++r<i;)t(e[r],r);else h(e,t)}(e,(function(i,o){r=t(r,i,o,e)})),r}function g(e){return String(e).replace(/^ +| +$/g,"")}var x=function e(t){var r=i,o=t&&"object"==typeof t&&"String"!=f(t);o&&(r=t,t=null);var n=r.navigator||{},a=n.userAgent||"";t||(t=a);var s,l,b,c,p=o?!!n.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(u.toString()),x="Object",O=o?x:"ScriptBridgingProxyObject",v=o?x:"Environment",w=o&&r.java?"JavaPackage":f(r.java),M=o?x:"RuntimeObject",E=/\bJava/.test(w)&&r.java,C=E&&f(r.environment)==v,P=E?"a":"α",k=E?"b":"β",I=r.document||{},B=r.operamini||r.opera,A=d.test(A=o&&B?B["[[Class]]"]:f(B))?A:B=null,j=t,R=[],W=null,T=t==a,F=T&&B&&"function"==typeof B.version&&B.version(),$=y([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,r){return e||RegExp("\\b"+(r.pattern||S(r))+"\\b","i").exec(t)&&(r.label||r)})),G=y(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"],(function(e,r){return e||RegExp("\\b"+(r.pattern||S(r))+"\\b","i").exec(t)&&(r.label||r)})),K=D([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),X=y({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}},(function(e,r,i){return e||(r[K]||r[/^[a-z]+(?: +[a-z]+\b)*/i.exec(K)]||RegExp("\\b"+S(i)+"(?:\\b|\\w*\\d)","i").exec(t))&&i})),N=y(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "],(function(e,r){var i=r.pattern||S(r);return!e&&(e=RegExp("\\b"+i+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,r){var i={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&r&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(i=i[/[\d.]+$/.exec(e)])&&(e="Windows "+i),e=String(e),t&&r&&(e=e.replace(RegExp(t,"i"),r)),m(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,i,r.label||r)),e}));function D(e){return y(e,(function(e,r){var i=r.pattern||S(r);return!e&&(e=RegExp("\\b"+i+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+i+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+i+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(r.label&&!RegExp(i,"i").test(r.label)?r.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),r=r.label||r,e=m(e[0].replace(RegExp(i,"i"),r).replace(RegExp("; *(?:"+r+"[_-])?","i")," ").replace(RegExp("("+r+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function U(e){return y(e,(function(e,r){return e||(RegExp(r+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if($&&($=[$]),/\bAndroid\b/.test(N)&&!K&&(s=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(K=g(s[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),X&&!K?K=D([X]):X&&K&&(K=K.replace(RegExp("^("+S(X)+")[-_.\\s]","i"),X+" ").replace(RegExp("^("+S(X)+")[-_.]?(\\w)","i"),X+" $2")),(s=/\bGoogle TV\b/.exec(K))&&(K=s[0]),/\bSimulator\b/i.test(t)&&(K=(K?K+" ":"")+"Simulator"),"Opera Mini"==G&&/\bOPiOS\b/.test(t)&&R.push("running in Turbo/Uncompressed mode"),"IE"==G&&/\blike iPhone OS\b/.test(t)?(X=(s=e(t.replace(/like iPhone OS/,""))).manufacturer,K=s.product):/^iP/.test(K)?(G||(G="Safari"),N="iOS"+((s=/ OS ([\d_]+)/i.exec(t))?" "+s[1].replace(/_/g,"."):"")):"Konqueror"==G&&/^Linux\b/i.test(N)?N="Kubuntu":X&&"Google"!=X&&(/Chrome/.test(G)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(K))||/\bAndroid\b/.test(N)&&/^Chrome/.test(G)&&/\bVersion\//i.test(t)?(G="Android Browser",N=/\bAndroid\b/.test(N)?N:"Android"):"Silk"==G?(/\bMobi/i.test(t)||(N="Android",R.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&R.unshift("accelerated")):"UC Browser"==G&&/\bUCWEB\b/.test(t)?R.push("speed mode"):"PaleMoon"==G&&(s=/\bFirefox\/([\d.]+)\b/.exec(t))?R.push("identifying as Firefox "+s[1]):"Firefox"==G&&(s=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(N||(N="Firefox OS"),K||(K=s[1])):!G||(s=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(G))?(G&&!K&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(s+"/")+8))&&(G=null),(s=K||X||N)&&(K||X||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(N))&&(G=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(N)?N:s)+" Browser")):"Electron"==G&&(s=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&R.push("Chromium "+s),F||(F=U(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",S(G),"(?:Firefox|Minefield|NetFront)"])),(s=("iCab"==$&&parseFloat(F)>3?"WebKit":/\bOpera\b/.test(G)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test($)&&"WebKit"||!$&&/\bMSIE\b/i.test(t)&&("Mac OS"==N?"Tasman":"Trident")||"WebKit"==$&&/\bPlayStation\b(?! Vita\b)/i.test(G)&&"NetFront")&&($=[s]),"IE"==G&&(s=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(G+=" Mobile",N="Windows Phone "+(/\+$/.test(s)?s:s+".x"),R.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(G="IE Mobile",N="Windows Phone 8.x",R.unshift("desktop mode"),F||(F=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=G&&"Trident"==$&&(s=/\brv:([\d.]+)/.exec(t))&&(G&&R.push("identifying as "+G+(F?" "+F:"")),G="IE",F=s[1]),T){if("global",/^(?:boolean|number|string|undefined)$/.test(c=null!=(b=r)?typeof b.global:"number")||"object"==c&&!b.global)f(s=r.runtime)==O?(G="Adobe AIR",N=s.flash.system.Capabilities.os):f(s=r.phantom)==M?(G="PhantomJS",F=(s=s.version||null)&&s.major+"."+s.minor+"."+s.patch):"number"==typeof I.documentMode&&(s=/\bTrident\/(\d+)/i.exec(t))?((s=+s[1]+4)!=(F=[F,I.documentMode])[1]&&(R.push("IE "+F[1]+" mode"),$&&($[1]=""),F[1]=s),F="IE"==G?String(F[1].toFixed(1)):F[0]):"number"==typeof I.documentMode&&/^(?:Chrome|Firefox)\b/.test(G)&&(R.push("masking as "+G+" "+F),G="IE",F="11.0",$=["Trident"],N="Windows");else if(E&&(j=(s=E.lang.System).getProperty("os.arch"),N=N||s.getProperty("os.name")+" "+s.getProperty("os.version")),C){try{F=r.require("ringo/engine").version.join("."),G="RingoJS"}catch(e){(s=r.system)&&s.global.system==r.system&&(G="Narwhal",N||(N=s[0].os||null))}G||(G="Rhino")}else"object"==typeof r.process&&!r.process.browser&&(s=r.process)&&("object"==typeof s.versions&&("string"==typeof s.versions.electron?(R.push("Node "+s.versions.node),G="Electron",F=s.versions.electron):"string"==typeof s.versions.nw&&(R.push("Chromium "+F,"Node "+s.versions.node),G="NW.js",F=s.versions.nw)),G||(G="Node.js",j=s.arch,N=s.platform,F=(F=/[\d.]+/.exec(s.version))?F[0]:null));N=N&&m(N)}if(F&&(s=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(F)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(T&&n.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(W=/b/i.test(s)?"beta":"alpha",F=F.replace(RegExp(s+"\\+?$"),"")+("beta"==W?k:P)+(/\d+\+?/.exec(s)||"")),"Fennec"==G||"Firefox"==G&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(N))G="Firefox Mobile";else if("Maxthon"==G&&F)F=F.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(K))"Xbox 360"==K&&(N=null),"Xbox 360"==K&&/\bIEMobile\b/.test(t)&&R.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(G)&&(!G||K||/Browser|Mobi/.test(G))||"Windows CE"!=N&&!/Mobi/i.test(t))if("IE"==G&&T)try{null===r.external&&R.unshift("platform preview")}catch(e){R.unshift("embedded")}else(/\bBlackBerry\b/.test(K)||/\bBB10\b/.test(t))&&(s=(RegExp(K.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||F)?(N=((s=[s,/BB10/.test(t)])[1]?(K=null,X="BlackBerry"):"Device Software")+" "+s[0],F=null):this!=h&&"Wii"!=K&&(T&&B||/Opera/.test(G)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==G&&/\bOS X (?:\d+\.){2,}/.test(N)||"IE"==G&&(N&&!/^Win/.test(N)&&F>5.5||/\bWindows XP\b/.test(N)&&F>8||8==F&&!/\bTrident\b/.test(t)))&&!d.test(s=e.call(h,t.replace(d,"")+";"))&&s.name&&(s="ing as "+s.name+((s=s.version)?" "+s:""),d.test(G)?(/\bIE\b/.test(s)&&"Mac OS"==N&&(N=null),s="identify"+s):(s="mask"+s,G=A?m(A.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(s)&&(N=null),T||(F=null)),$=["Presto"],R.push(s));else G+=" Mobile";(s=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(s=[parseFloat(s.replace(/\.(\d)$/,".0$1")),s],"Safari"==G&&"+"==s[1].slice(-1)?(G="WebKit Nightly",W="alpha",F=s[1].slice(0,-1)):F!=s[1]&&F!=(s[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(F=null),s[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==s[0]&&537.36==s[2]&&parseFloat(s[1])>=28&&"WebKit"==$&&($=["Blink"]),T&&(p||s[1])?($&&($[1]="like Chrome"),s=s[1]||((s=s[0])<530?1:s<532?2:s<532.05?3:s<533?4:s<534.03?5:s<534.07?6:s<534.1?7:s<534.13?8:s<534.16?9:s<534.24?10:s<534.3?11:s<535.01?12:s<535.02?"13+":s<535.07?15:s<535.11?16:s<535.19?17:s<536.05?18:s<536.1?19:s<537.01?20:s<537.11?"21+":s<537.13?23:s<537.18?24:s<537.24?25:s<537.36?26:"Blink"!=$?"27":"28")):($&&($[1]="like Safari"),s=(s=s[0])<400?1:s<500?2:s<526?3:s<533?4:s<534?"4+":s<535?5:s<537?6:s<538?7:s<601?8:s<602?9:s<604?10:s<606?11:s<608?12:"12"),$&&($[1]+=" "+(s+="number"==typeof s?".x":/[.+]/.test(s)?"":"+")),"Safari"==G&&(!F||parseInt(F)>45)?F=s:"Chrome"==G&&/\bHeadlessChrome/i.test(t)&&R.unshift("headless")),"Opera"==G&&(s=/\bzbov|zvav$/.exec(N))?(G+=" ",R.unshift("desktop mode"),"zvav"==s?(G+="Mini",F=null):G+="Mobile",N=N.replace(RegExp(" *"+s+"$"),"")):"Safari"==G&&/\bChrome\b/.exec($&&$[1])?(R.unshift("desktop mode"),G="Chrome Mobile",F=null,/\bOS X\b/.test(N)?(X="Apple",N="iOS 4.3+"):N=null):/\bSRWare Iron\b/.test(G)&&!F&&(F=U("Chrome")),F&&0==F.indexOf(s=/[\d.]+$/.exec(N))&&t.indexOf("/"+s+"-")>-1&&(N=g(N.replace(s,""))),N&&-1!=N.indexOf(G)&&!RegExp(G+" OS").test(N)&&(N=N.replace(RegExp(" *"+S(G)+" *"),"")),$&&!/\b(?:Avant|Nook)\b/.test(G)&&(/Browser|Lunascape|Maxthon/.test(G)||"Safari"!=G&&/^iOS/.test(N)&&/\bSafari\b/.test($[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(G)&&$[1])&&(s=$[$.length-1])&&R.push(s),R.length&&(R=["("+R.join("; ")+")"]),X&&K&&K.indexOf(X)<0&&R.push("on "+X),K&&R.push((/^on /.test(R[R.length-1])?"":"on ")+K),N&&(s=/ ([\d.+]+)$/.exec(N),l=s&&"/"==N.charAt(N.length-s[0].length-1),N={architecture:32,family:s&&!l?N.replace(s[0],""):N,version:s?s[1]:null,toString:function(){var e=this.version;return this.family+(e&&!l?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(s=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(j))&&!/\bi686\b/i.test(j)?(N&&(N.architecture=64,N.family=N.family.replace(RegExp(" *"+s),"")),G&&(/\bWOW64\b/i.test(t)||T&&/\w(?:86|32)$/.test(n.cpuClass||n.platform)&&!/\bWin64; x64\b/i.test(t))&&R.unshift("32-bit")):N&&/^OS X/.test(N.family)&&"Chrome"==G&&parseFloat(F)>=39&&(N.architecture=64),t||(t=null);var z={};return z.description=t,z.layout=$&&$[0],z.manufacturer=X,z.name=G,z.prerelease=W,z.product=K,z.ua=t,z.version=G&&F,z.os=N||{architecture:null,family:null,version:null,toString:function(){return"null"}},z.parse=e,z.toString=function(){return this.description||""},z.version&&R.unshift(F),z.name&&R.unshift(G),N&&G&&(N!=String(N).split(" ")[0]||N!=G.split(" ")[0]&&!K)&&R.push(K?"("+N+")":"on "+N),R.length&&(z.description=R.join(" ")),z}();o&&n?h(x,(function(e,t){o[t]=e})):i.platform=x}).call(a)}));class M{constructor(){this.axiosConfig={baseURL:this.getCurrentHost(),headers:{"Content-Type":"application/json","X-Client-Id":t.clientId,"X-Api-Key":t.publicKey}},this.api=r.create(this.axiosConfig)}getCurrentHost(){return t.debug?"https://api.dev.malga.io/v1":t.sandbox?"https://sandbox-api.malga.io/v1":"https://api.malga.io/v1"}async create({endpoint:e,data:t,headers:r}){return this.api.post(e,t,{headers:r})}async fetch({endpoint:e}){return this.api.get(e)}}function E(e,t=!1){return t?{paymentSource:e.paymentSource,paymentMethod:e.paymentMethod,customerId:e.customerId,fraudAnalysis:e.fraudAnalysis,paymentFlow:e.paymentFlow,splitRules:e.splitRules}:e}class C{constructor({provider:e}){this.api=new M,this.provider=e}async pay({headers:e,payload:r}){const i=!!t.sessionId,o=i?`/sessions/${t.sessionId}/charge`:"/charges",n=await this.api.create({endpoint:o,data:E(r,i),headers:e});return{hasError:["failed","charged_back","canceled","voided"].includes(n.data.status),data:n.data}}}class P{constructor({provider:e}){this.api=new M,this.provider=e,this.payments=new C({provider:e})}async create(e){var i,o,n,a,s,l;const d=await(async e=>{var i;const o=(null==e?void 0:e.customer)||t.transactionConfig.customer;if(!e||!(null==o?void 0:o.address)&&!(null==e?void 0:e.usePartialCustomer))return null;const n=x(o,!0),a=n.address&&Object.assign(Object.assign({},n.address),{number:n.address.streetNumber}),s=await(async(e,t)=>{if(!e)return{};const i=await(async()=>{const{data:e}=await r.get("https://geolocation-db.com/json/");return e.IPv4})(),o=location.hostname;return{browser:{browserFingerprint:e,email:t,cookiesAccepted:(()=>{try{document.cookie="cookietest=1; SameSite=Strict;";const e=-1!==document.cookie.indexOf("cookietest=");return document.cookie="cookietest=1; SameSite=Strict; expires=Thu, 01-Jan-1970 00:00:01 GMT",e}catch(e){return!1}})(),hostName:o,ipAddress:i,type:navigator.userAgent}}})(e.browserFingerprint,n.email);a&&delete a.streetNumber;const l=(null===(i=null==n?void 0:n.phoneNumber)||void 0===i?void 0:i.trim())?{phone:n.phoneNumber}:{};return{customer:Object.assign(Object.assign(Object.assign(Object.assign({name:n.name,email:n.email},n.document&&{identityType:n.document.type,identity:n.document.number}),o.address&&{deliveryAddress:a,billingAddress:a}),l),s),cart:{items:e.cart}}})(t.transactionConfig.fraudAnalysis),b=(e=>Object.entries(e).filter((([,e])=>"boolean"==typeof e||!!e)).reduce(((e,[t,r])=>Object.assign(Object.assign({},e),{[t]:r})),{}))(Object.assign({customerId:e||t.transactionConfig.customerId,currency:t.transactionConfig.currency,orderId:t.transactionConfig.orderId,description:t.transactionConfig.description,merchantId:t.merchantId,amount:t.transactionConfig.amount,statementDescriptor:t.transactionConfig.statementDescriptor,capture:t.transactionConfig.capture,sessionId:t.sessionId,splitRules:t.transactionConfig.splitRules,providerReferenceKey:t.transactionConfig.providerReferenceKey,fraudAnalysis:d},t.transactionConfig.paymentFlowMetadata&&{paymentFlow:{metadata:t.transactionConfig.paymentFlowMetadata}})),c=Object.assign(Object.assign({},b),{paymentMethod:this.provider.getPaymentMethod(),paymentSource:await this.provider.getPaymentSource(),appInfo:Object.assign(Object.assign({},t.appInfo),{platform:{integrator:"Malga",name:null!==(n=null===(o=null===(i=null==t?void 0:t.appInfo)||void 0===i?void 0:i.platform)||void 0===o?void 0:o.name)&&void 0!==n?n:"Checkout SDK",version:null!==(l=null===(s=null===(a=null==t?void 0:t.appInfo)||void 0===a?void 0:a.platform)||void 0===s?void 0:s.version)&&void 0!==l?l:"1.23.0"},device:{name:w.name,version:w.version}})});return this.payments.pay({headers:t.idempotencyKey?{"X-Idempotency-Key":t.idempotencyKey}:{},payload:c})}async find(e){const t=await this.api.fetch({endpoint:`/charges/${e}`});return{hasError:["failed","charged_back","canceled","voided","pending"].includes(t.data.status),data:t.data}}}class k{constructor(){this.api=new M,this.endpoint=t.sessionId?"/sessions/customers":"/customers"}async create(e,t){return this.api.create({endpoint:`${this.endpoint}/${t}/cards`,data:{cardId:e}})}async list(e){return{data:(await this.api.fetch({endpoint:`${this.endpoint}/${e}/cards`})).data}}}class I extends v{constructor({pix:e}){super({customerId:t.transactionConfig.customerId,customer:t.transactionConfig.customer}),this.pix=e}getPaymentMethod(){const e=(t=this.pix).items&&(null===(r=t.items)||void 0===r?void 0:r.length)?{items:t.items}:{};var t,r;return Object.assign({paymentType:"pix",expiresIn:this.pix.expiresIn},e)}}class B{constructor({onPaymentSuccess:e,onPaymentFailed:t,onShowDialog:r,data:i}){this.charge=new P({provider:new I({pix:i})}),this.data=i,this.onPaymentSuccess=e,this.onPaymentFailed=t,this.onShowDialog=r}handlePaymentSuccess(e){i.chargeId=e.id;const r=e.paymentMethod;t.dialogConfig.show&&this.onShowDialog({mode:"pix",amount:e.amount,open:!0,paymentCode:r.qrCodeData,paymentImageUrl:r.qrCodeImageUrl,expirationTime:r.expiresIn}),this.onPaymentSuccess(e)}handlePaymentFailed(e){t.automaticallyGeneratedIdempotencyKey&&(t.idempotencyKey=f()),t.dialogConfig.show&&this.onShowDialog({open:!0,mode:"error",errorMessage:s("dialogs.pix.errorMessage",t.locale)}),this.onPaymentFailed(e)}async pay(){try{const e=await this.charge.create();if(e.hasError)return void this.handlePaymentFailed({type:e.data.status,message:"Your transaction cannot be completed",errorStack:e.data});this.handlePaymentSuccess(e.data)}catch(e){this.handlePaymentFailed({type:e.response.status,message:"Your transaction cannot be completed",errorStack:e.response.data})}}async findCharge(e){try{const r=await this.charge.find(e);if(r.hasError)return this.onShowDialog({open:!0,mode:"error",errorTitle:s("dialogs.pix.errorTitleExpired",t.locale),errorMessage:s("dialogs.pix.errorMessageExpired",t.locale)}),void this.handlePaymentFailed({type:"400",message:"Pix not paid",errorStack:r.data});this.onShowDialog({mode:"success",open:!0,successMessage:s("dialogs.pix.successMessage",t.locale)})}catch(e){this.onShowDialog({open:!0,mode:"error",errorMessage:s("dialogs.pix.errorMessage",t.locale)}),this.handlePaymentFailed({type:"400",message:"Pix not paid",errorStack:e.response.data})}}}export{M as A,v as B,P as C,B as M,k as a,l as c,x as f,S as s,f as v}