coinley-test 0.40.103 โ 0.41.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/coinley-vanilla.min.js +25 -27
- package/dist/coinley-vanilla.min.js.map +1 -1
- package/dist/index.esm.js +21119 -138
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +9 -8
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react"),require("wagmi"),require("@tanstack/react-query"),require("@wagmi/core"),require("@wagmi/core/chains"),require("@wagmi/connectors"),require("viem"),require("react-dom"),require("qrcode"),require("axios"),require("react-dom/client")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","wagmi","@tanstack/react-query","@wagmi/core","@wagmi/core/chains","@wagmi/connectors","viem","react-dom","qrcode","axios","react-dom/client"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CoinleyTest={},e.React,e.React,e.Wagmi,e.ReactQuery,e.WagmiCore,e.chains,e.connectors,e.Viem,e.ReactDOM,e.QRCode,e.axios,e.ReactDOM)}(this,function(e,t,n,s,a,r,i,o,c,l,d,m,u){"use strict";const h="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABxCAYAAAAj+QZ8AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAzrSURBVHgB7V3dcRs5Em4MtXWPq41gZ1+v7mwrgh3rArAUgagITNcFYDmAK9ERSBuBfQGsxY3Aku26V/MiOO7j1nqAQwMgRQ4xQONnhqOfr8q2TA4H1HzoRqO70c1g4JhUH/dhNKqgrhfT2cEMOoQaqxidyx+P5J8F8PpYjnkNPYLBgPGq+vxSFOJM/rhvXpp39ZAkGaUk40r+WK69jKT8JMdbQE8oYKDAByTJmMItGQj10OR7zyA3itFr2CQD1NhFMYYeMVhCHA8C1co7pV4yYXL4aSz/GVvfFFBBjxguIcCeOt4szYxOhiG2/V7M+T2yY7iEMOaTgIl8mBWkoth7Cduqah2u97JjuIQIUXqvYWlSohZyUEaDE/88/M+P0BMGrLIIYFAZ/R+HTGovJ+42IRqvYxZ485kKBob7QEgZZZoWoyMgrg//+vDX/0JPuA+ESLCXEApG/kxvm0LEkK2secDVZYjFpRZzIWibSyHm0COGSwjnYWoiyOIqjujXskcJUWCBqgItLuriPipOgAombqBH7EEGTKovUvz/xIdxnc8Rx8IdiHpxn7ouCVJXGnPIBD1h9p5BIU6kS6ZkBXt//uvf365fk0SIcvJJv5LUL6Wcdvq1w09z+c9MeknfSHLmEAteX8t7B30EBHsBHkLkPSsI+h482bOs3froERAT+UdLMcPlSch91M0P0w9Pz5bXpqksRcaW6Yj/H8v3vkpyLvRuOBzGxd6F2voZwpBEyKT6XMln8dF4BCzfjW2oz2hCjAu89FxmiPkctyNmMWprdOS5J11dSQsrVgXjxJAT8lyqp2aMpTnGxv1TJCRgdyzO5Jf7Giwtgv8GwWhfH5T0hK0fUQu6UeUf8UfvxY1Jl0LIHMJQBksL5zMIhXCqpLDAFpNrYSAwymnIKEkf4PUv6/+NJsQs2BHirKTlHUVaTAw9cB1xqaQijJDACYGTzUQ5adAqcbb+UuI+RPwCcTgyodjSe6UQ/4ZAtLrLi4DYhn5Y5DVscvjlguLK3xyDvWm+lEYI5+8hHiWJFMEvIRA1/3ZgfYMV9OgfYzPKZWrxfv5JLtx8DCFQhD+5bL6cRIgSN+IXb4GXlCi1VbQEt0IWdA40yRztXaG5DaEQ/Nj2crrrpP72BtJAkJRg1bhlAZr9Cc0y1LPXK/1KTYVZbcsB3rapw2RC1AwW0WvJEktS7A8sWDWyH61jkD/ul3q1xwhVUwj0HnN+1vZ2Huei4Ghvp/qwSumxfWd7I4NqRND3TdLt43rbmO7+PYYNgj93bTazEKIG4PUppELHyM+t76WrRhoEzFw+uMk/Ph0FW1O3N3/l8+9lc7/Lgd6jboR0TF5VNyeW++eQEj8EtKpf7SmGC4i78VvpRPTuUfLGQ1A3CpHkjEOIgk2ti3zXUtJiiq6gc38DXEar+15LMkgqLishSnWhOZce9tyX68mF5f4pUjL3XmHZqC1hVGkJocBnIdcN6uXZI4ZKR2obO22Rx/VE6esG6m+n/nsLW/jX/Rnp5GuTDpP7Fb6IGzJCPMadhHCVjc1rnBVppAg4b5rCinBeHzs/x7fd9uqhuNz59TfrPY3qDA8f3JIxD/lYZzH1TKRgztXEcu8ZWiztH6vtD17wlt23w/qxH1NwI5IMNRx0iDyk2POntMUiLDpftIeOOZ9ufxd5fYv1Y6RjDCFIIAPRywkq9YuxQvp8WAkxkKS2HWdT+VgFpvWw7zG24Dv2Jq8/kv6nl3rH7L4eQ9AQQojcw4BQJ7yiJ2AvhCAMKe+CQqgrKBs+bmecAIxyAlldKUk7g0R4s070ovpdadJ8DL6TM+DPoHizEeGDyeHNmZwHYYukiDA3E0HMGUAsD4fOIAP2LF/EnKtjGAqtQG2EOCzTfDT0/+UM0jFhte8QN+rnur526U+cRXIMuZ8oLgJUWG/nM9bg3wBqFXWalO7UwEplbeYORexGN+6qSLp26Wijws7ktf4sQvQvXT0hb65ywOw92twk0oSG0+mvfhd9KBQhLUeCc2EOjsQ5EjFc/vIul0YHUBOUFR8bUrxQ/jpprXV1VFoTcvgJ3d5H0D0uncRgEvSoeCGlqzIvL1xmaddYfScFft114QIEM9LxFfrFZXKq6T0FbgzT1os4YEbjR2lx9W7KDh3M1Pf4H+wKHVgqdxmFdpknx8TjgRkb1BytBwDtyxIq6N6J1UBEKd0Z7+ARmhDj0k53l6dAiGd6F/+wsfL2rjyzPR9y3ARhk3jPseF+V6RguHF3a0rZZxmLIaLV26uca9o7W0Kf4PUP0x4Lhg0NXve78ukI8boXYnbgsxoayPEQRQz6m27dGnmRGGm7LwgOUK38OwxO4oJNFjxuDldIihiazdwzGT+p1NkLnQlOdcUsVFY75+/7cNrdFWQP4Zq0nRI0MeiW2SSIq4yQxaM0POJOoCsJ0VJSjMqtC3g9x5j8dPa35Bzg+4hkQnSlAv7MxOCpiQGIOeQowXHPEEWIJkFgXZEx5ImnPAasDOj7kJxJEHagg/PgIe/SEbS8rGYlm26Aaw5meRzDA4ZTQizF8LvHA/dlWSVEp+aMLgTryE3iwKj4y/ew22DZTmHJXFQLNkbvdpH8ADX/43d4wNiIh7yqvpyY+k47IUPi8qEv6itCMP4hivC6IlnhOR/+EKAIMalAO04y8J/hfgjQEhJQdrsb7C5ddGjQi7oOPMFuICXjkYwVstTtjYKOEGJQarY6FKR8YsvSSgx37rOHpsZM9vvNNKqgfRxWKf2mqDCOW0G7ZTedfnjyCnYAU8zyRE6Mt31NDL2GpFWGo0IdLcA2dMCLmar8o01sXL9cZvaktSBN1xjt4bgTU4P4nFATOBnLzMWZ/YhxFqwRIc1q9FchEWFV2CZ9PIwtbJapnaiM/Rx9rxy4zVzUJ0hPM2UuGrVUP5fqRpXSZrB3Ysqnxh0M6rmfoML2uXZdaC22MDQBVueiOV+H8Y4K/Lv2hfkjg03YSYDPmuXrjMqZQBouJbnpNbkCoc612/Zo6oDrt+Pca4s/UW4zaWEdc/zLWexL9bHdu4qrS7gFJyE4VojbBR2o1IfpMHqyt4LtrHBABwdJrYTcdmhQ43iDXJbrvQ+05QDoGvLtpTqpddLNqV7xe8s46x0arMVqNrB1vf+w0KoOWGtYgJ3nWleyE2LUlK2NRRpsprmNdKHWvrbvZkvCsBZLa0JLkcsSxRLq6aTklxAsZ5RnzbiFpUa6+eXLrWtdSeGjkf29tmJpDZgKRI66kumkZCUkqXyqC42yfqZlats47VahcL5H2vipIjjOMoOq2UBkocyMhFD7ykahGSfRRcVaH177oR9nf13/+rMEVp9zF/scx5KST0K0Ps+PRh3dqKJiZLCXJCmhFfscx6ivLIS06vMcEFbp6Ar7VCkxxT49ZzLD15RkQjz6PA1aOmabY/mlo713LaV7KE1KEF2Qki4hHn2eBNEoX95Pu+39EL8ZlRRbtW4bkggxMzbOWeiFtZhl5f+YY7FVmfeUodkLCACFFFOt27sdSO1jWEEX0oH7jkb9QrNPKP0fdvaunQMFuh9iBQEgkLJP8QqkEcI6OOjfVprbsQPfgLt3Ldn5qI7pBSKAlNZJnEZI7h25uidvO/xJU428fdNmnI5zICEupL1GSpvqbO2Tgkjt9JlXXalSftsHQI36II7lXSeorvL92OjgihSA99YLVJ8Uu+XVU6dPAlx1FQty//OFNzbBxW9ARYTaWgKlUYYLjtsdkuLMRng8IUWLoy4UusL0gbPIJSt+Btq9CA87oPuzYLRxHdDGSUudep1EsYF4QqgmpAuqYICq3tD6kIL619JapdIJoXWf9kJ5iTHJo7nYW0pSpaislLDlQkXZrp74S2mMlGlNA6FVqmlb4b1uDVkMl7XFvlFpadMzkNILN/QX0xDq5O0BOeRJlY6QVqkhXaiLIgshCCRlevV0DJvZPUjGaow0sxe73VDThjQRz0lSsQ7q+hEyOYKaDjN6u1Yi5GJ/KScFtoc9bVqWGc6pOytTL1Lrmci4AlZM9etxDseU7pzB98WGXldPD6AnJCdbm9k+lsScgSpEY2qb6JomQR0Umghqlwr1DEKAXagpnoY+6oStIVv2uyFmDnlB1d/hR+GwCzUbUVw/+6E5XynotOVROogLKrWz8yZQgkkP2ZwM7gXDJoTSkJ7Y2bkJPeNpxT5r/sdP0BMGLiHMX6FUQHy7V+oxjFxeCcpQMGQwRljQ48+29NZfNwADlxAvLpOzz/vqQk3E3SYkw7n2oUnJsAkRwmEFiXzn/gYkJQOXEGFP51Eue07zhREwJCkZupVldxYWLH/VB1cXat5fdaJhE8JriwUl3nTRrk4T3Bbdq1NCDUEYNCFm87Z8SAtzUukMOoK94bHo7Yw6orMjbTmxDOD05U/SBz2l2wab3ncgjS78H0eagrHjdQciAAAAAElFTkSuQmCC",p="YWG990wOlIikc1tU7-WWTepfU8d1f4dp",y="qtIcCe_-8t4rIWktnWJm0",g=r.createConfig({chains:[i.mainnet,i.bsc,i.polygon,i.arbitrum,i.optimism,i.avalanche,i.celo,i.base],connectors:[o.injected(),o.metaMask({dappMetadata:{name:"Coinley Payment",icon:h}}),o.coinbaseWallet({appName:"Coinley Payment",appLogoUrl:h})],transports:{[i.mainnet.id]:r.fallback([r.http(`https://eth-mainnet.g.alchemy.com/v2/${p}`,{timeout:1e4,retryCount:1}),r.http(`https://eth-mainnet.g.alchemy.com/v2/${y}`,{timeout:1e4,retryCount:1}),r.http("https://cloudflare-eth.com",{timeout:1e4,retryCount:1}),r.http("https://eth.llamarpc.com",{timeout:1e4,retryCount:1}),r.http("https://ethereum.publicnode.com",{timeout:1e4,retryCount:1})]),[i.bsc.id]:r.fallback([r.http(`https://bnb-mainnet.g.alchemy.com/v2/${p}`,{timeout:1e4,retryCount:1}),r.http(`https://bnb-mainnet.g.alchemy.com/v2/${y}`,{timeout:1e4,retryCount:1}),r.http("https://bsc-dataseed.bnbchain.org",{timeout:1e4,retryCount:1}),r.http("https://bsc-dataseed-public.bnbchain.org",{timeout:1e4,retryCount:1}),r.http("https://bsc.nodereal.io",{timeout:1e4,retryCount:1})]),[i.polygon.id]:r.fallback([r.http(`https://polygon-mainnet.g.alchemy.com/v2/${p}`,{timeout:1e4,retryCount:1}),r.http(`https://polygon-mainnet.g.alchemy.com/v2/${y}`,{timeout:1e4,retryCount:1}),r.http("https://polygon.llamarpc.com",{timeout:1e4,retryCount:1}),r.http("https://polygon-rpc.com",{timeout:1e4,retryCount:1}),r.http("https://polygon.drpc.org",{timeout:1e4,retryCount:1})]),[i.arbitrum.id]:r.fallback([r.http(`https://arb-mainnet.g.alchemy.com/v2/${p}`,{timeout:1e4,retryCount:1}),r.http(`https://arb-mainnet.g.alchemy.com/v2/${y}`,{timeout:1e4,retryCount:1}),r.http("https://arb1.arbitrum.io/rpc",{timeout:1e4,retryCount:1}),r.http("https://arbitrum.llamarpc.com",{timeout:1e4,retryCount:1})]),[i.optimism.id]:r.fallback([r.http(`https://opt-mainnet.g.alchemy.com/v2/${p}`,{timeout:1e4,retryCount:1}),r.http(`https://opt-mainnet.g.alchemy.com/v2/${y}`,{timeout:1e4,retryCount:1}),r.http("https://mainnet.optimism.io",{timeout:1e4,retryCount:1}),r.http("https://optimism.llamarpc.com",{timeout:1e4,retryCount:1})]),[i.avalanche.id]:r.fallback([r.http(`https://avax-mainnet.g.alchemy.com/v2/${p}`,{timeout:1e4,retryCount:1}),r.http(`https://avax-mainnet.g.alchemy.com/v2/${y}`,{timeout:1e4,retryCount:1}),r.http("https://api.avax.network/ext/bc/C/rpc",{timeout:1e4,retryCount:1}),r.http("https://avalanche.public-rpc.com",{timeout:1e4,retryCount:1})]),[i.celo.id]:r.fallback([r.http(`https://celo-mainnet.g.alchemy.com/v2/${p}`,{timeout:1e4,retryCount:1}),r.http(`https://celo-mainnet.g.alchemy.com/v2/${y}`,{timeout:1e4,retryCount:1}),r.http("https://forno.celo.org",{timeout:1e4,retryCount:1}),r.http("https://celo.drpc.org",{timeout:1e4,retryCount:1})]),[i.base.id]:r.fallback([r.http(`https://base-mainnet.g.alchemy.com/v2/${p}`,{timeout:1e4,retryCount:1}),r.http(`https://base-mainnet.g.alchemy.com/v2/${y}`,{timeout:1e4,retryCount:1}),r.http("https://mainnet.base.org",{timeout:1e4,retryCount:1}),r.http("https://base.llamarpc.com",{timeout:1e4,retryCount:1}),r.http("https://base.meowrpc.com",{timeout:1e4,retryCount:1})])}});let f=class{constructor(e,t,n=null){this.baseURL=e.endsWith("/")?e.slice(0,-1):e,t&&t.startsWith("pk_")?(this.publicKey=t,this.apiKey=null,this.apiSecret=null):(this.publicKey=null,this.apiKey=t,this.apiSecret=n)}async request(e,t={}){const n=`${this.baseURL}${e}`,s={"Content-Type":"application/json",...t.headers};this.publicKey?s["X-Public-Key"]=this.publicKey:(s["X-API-Key"]=this.apiKey,s["X-API-Secret"]=this.apiSecret);const a=t.timeout||6e4,r=new AbortController,i=setTimeout(()=>r.abort(),a);try{const e=await fetch(n,{...t,headers:s,signal:r.signal});if(clearTimeout(i),!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.error||`HTTP ${e.status}`)}return e.json()}catch(o){if(clearTimeout(i),"AbortError"===o.name)throw new Error(`Request timeout after ${a/1e3}s: ${e}`);throw o}}async getNetworks(){try{return await this.request("/api/networks")}catch(e){return{networks:[{id:"1",name:"Ethereum",shortName:"ethereum",chainId:"0x1",type:"ethereum"},{id:"56",name:"BSC",shortName:"bsc",chainId:"0x38",type:"bsc"},{id:"137",name:"Polygon",shortName:"polygon",chainId:"0x89",type:"polygon"},{id:"42161",name:"Arbitrum",shortName:"arbitrum",chainId:"0xa4b1",type:"arbitrum"},{id:"10",name:"Optimism",shortName:"optimism",chainId:"0xa",type:"optimism"},{id:"43114",name:"Avalanche",shortName:"avalanche",chainId:"0xa86a",type:"avalanche"}]}}}async getTokens(){try{return await this.request("/api/networks/stablecoins")}catch(e){return{stablecoins:[{id:"1",name:"Tether USD",symbol:"USDT",contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"2",name:"USD Coin",symbol:"USDC",contractAddress:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"3",name:"Tether USD",symbol:"USDT",contractAddress:"0x55d398326f99059fF775485246999027B3197955",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"4",name:"USD Coin",symbol:"USDC",contractAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"5",name:"Tether USD",symbol:"USDT",contractAddress:"0xc2132D05D31c914a87c6611C10748AEb04B58e8F",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"6",name:"USD Coin",symbol:"USDC",contractAddress:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"7",name:"Tether USD",symbol:"USDT",contractAddress:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"8",name:"USD Coin",symbol:"USDC",contractAddress:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"9",name:"Tether USD",symbol:"USDT",contractAddress:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"10",name:"USD Coin",symbol:"USDC",contractAddress:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"11",name:"Tether USD",symbol:"USDT",contractAddress:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"12",name:"USD Coin",symbol:"USDC",contractAddress:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"13",name:"Tether USD",symbol:"USDT",contractAddress:"0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"14",name:"USD Coin",symbol:"USDC",contractAddress:"0xcebA9300f2b948710d2653dD7B07f33A8B32118C",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"15",name:"Tether USD",symbol:"USDT",contractAddress:"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}},{id:"16",name:"USD Coin",symbol:"USDC",contractAddress:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}}]}}}async createPayment(e){return await this.request("/api/payments/create",{method:"POST",body:JSON.stringify(e)})}async verifyQRPayment(e){return await this.request("/api/payments/verify-qr",{method:"POST",body:JSON.stringify({paymentId:e})})}async checkPaymentStatus(e){return await this.request(`/api/payments/status/${e}`)}async getContractInfo(e){try{const t=await this.request(`/api/payments/contract/${e}`);if(!t.success)throw new Error("Contract not supported on this network");return t.contractInfo}catch(t){throw new Error(t.message||"Failed to get contract information")}}async processPayment(e,t,n,s){try{return await this.request("/api/payments/process",{method:"POST",body:JSON.stringify({paymentId:e,transactionHash:t,network:n,senderAddress:s}),timeout:9e4})}catch(a){throw a}}async failPayment(e,t="Payment cancelled by user"){return await this.request("/api/payments/fail",{method:"POST",body:JSON.stringify({paymentId:e,reason:t,status:"failed"})})}};const b={ethereum:1,bsc:56,polygon:137,arbitrum:42161,optimism:10,avalanche:43114,celo:42220,base:8453},x=e=>"number"==typeof e?e:"string"==typeof e?e.startsWith("0x")?parseInt(e,16):parseInt(e,10):1,w=e=>b[e]||1;function v(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const k="2.39.0";let N={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${k}`};class C extends Error{constructor(e,t={}){var n;const s=t.cause instanceof C?t.cause.details:(null==(a=t.cause)?void 0:a.message)?t.cause.message:t.details;var a;const r=t.cause instanceof C&&t.cause.docsPath||t.docsPath,i=null==(n=N.getDocsUrl)?void 0:n.call(N,{...t,docsPath:r});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...s?[`Details: ${s}`]:[],...N.version?[`Version: ${N.version}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=s,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=k}walk(e){return P(this,e)}}function P(e,t){return(null==t?void 0:t(e))?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?P(e.cause,t):t?null:e}class j extends C{constructor({max:e,min:t,signed:n,size:s,value:a}){super(`Number "${a}" is not in safe ${s?`${8*s}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class I extends C{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function S(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function A(e){return S(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function E(e,{dir:t="left"}={}){let n="string"==typeof e?e.replace("0x",""):e,s=0;for(let a=0;a<n.length-1&&"0"===n["left"===t?a:n.length-a-1].toString();a++)s++;return n="left"===t?n.slice(s):n.slice(0,n.length-s),"string"==typeof e?(1===n.length&&"right"===t&&(n=`${n}0`),`0x${n.length%2==1?`0${n}`:n}`):n}class F extends C{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class U extends C{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function D(e,{dir:t,size:n=32}={}){return"string"==typeof e?function(e,{dir:t,size:n=32}={}){if(null===n)return e;const s=e.replace("0x","");if(s.length>2*n)throw new U({size:Math.ceil(s.length/2),targetSize:n,type:"hex"});return`0x${s["right"===t?"padEnd":"padStart"](2*n,"0")}`}(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new U({size:e.length,targetSize:n,type:"bytes"});const s=new Uint8Array(n);for(let a=0;a<n;a++){const r="right"===t;s[r?a:n-a-1]=e[r?a:e.length-a-1]}return s}(e,{dir:t,size:n})}const T=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function B(e,t={}){return"number"==typeof e||"bigint"==typeof e?M(e,t):"string"==typeof e?function(e,t={}){const n=R.encode(e);return L(n,t)}(e,t):"boolean"==typeof e?function(e,t={}){const n=`0x${Number(e)}`;if("number"==typeof t.size)return q(n,{size:t.size}),D(n,{size:t.size});return n}(e,t):L(e,t)}function L(e,t={}){let n="";for(let a=0;a<e.length;a++)n+=T[e[a]];const s=`0x${n}`;return"number"==typeof t.size?(q(s,{size:t.size}),D(s,{dir:"right",size:t.size})):s}function M(e,t={}){const{signed:n,size:s}=t,a=BigInt(e);let r;s?r=n?(1n<<8n*BigInt(s)-1n)-1n:2n**(8n*BigInt(s))-1n:"number"==typeof e&&(r=BigInt(Number.MAX_SAFE_INTEGER));const i="bigint"==typeof r&&n?-r-1n:0;if(r&&a>r||a<i){const t="bigint"==typeof e?"n":"";throw new j({max:r?`${r}${t}`:void 0,min:`${i}${t}`,signed:n,size:s,value:`${e}${t}`})}const o=`0x${(n&&a<0?(1n<<BigInt(8*s))+BigInt(a):a).toString(16)}`;return s?D(o,{size:s}):o}const R=new TextEncoder;const $=new TextEncoder;function G(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=M(e,t);return W(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return q(n,{size:t.size}),D(n,{size:t.size});return n}(e,t):S(e)?W(e,t):H(e,t)}const O={zero:48,nine:57,A:65,F:70,a:97,f:102};function z(e){return e>=O.zero&&e<=O.nine?e-O.zero:e>=O.A&&e<=O.F?e-(O.A-10):e>=O.a&&e<=O.f?e-(O.a-10):void 0}function W(e,t={}){let n=e;t.size&&(q(n,{size:t.size}),n=D(n,{dir:"right",size:t.size}));let s=n.slice(2);s.length%2&&(s=`0${s}`);const a=s.length/2,r=new Uint8Array(a);for(let i=0,o=0;i<a;i++){const e=z(s.charCodeAt(o++)),t=z(s.charCodeAt(o++));if(void 0===e||void 0===t)throw new C(`Invalid byte sequence ("${s[o-2]}${s[o-1]}" in "${s}").`);r[i]=16*e+t}return r}function H(e,t={}){const n=$.encode(e);return"number"==typeof t.size?(q(n,{size:t.size}),D(n,{dir:"right",size:t.size})):n}function q(e,{size:t}){if(A(e)>t)throw new I({givenSize:A(e),maxSize:t})}function V(e,t={}){const{signed:n}=t;t.size&&q(e,{size:t.size});const s=BigInt(e);if(!n)return s;const a=(e.length-2)/2;return s<=(1n<<8n*BigInt(a)-1n)-1n?s:s-BigInt(`0x${"f".padStart(2*a,"f")}`)-1n}function Q(e,t={}){return Number(V(e,t))}function K(e,t){return({exclude:n,format:s})=>({exclude:n,format:(e,a)=>{const r=t(e,a);if(n)for(const t of n)delete r[t];return{...r,...s(e,a)}},type:e})}const Z={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Y(e,t){const n={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Q(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?Q(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Z[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(n.authorizationList=e.authorizationList.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))),n.yParity=(()=>{if(e.yParity)return Number(e.yParity);if("bigint"==typeof n.v){if(0n===n.v||27n===n.v)return 0;if(1n===n.v||28n===n.v)return 1;if(n.v>=35n)return n.v%2n==0n?1:0}})(),"legacy"===n.type&&(delete n.accessList,delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.yParity),"eip2930"===n.type&&(delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas),"eip1559"===n.type&&delete n.maxFeePerBlobGas,n}const _=K("transaction",Y);function J(e,t){const n=(e.transactions??[]).map(e=>"string"==typeof e?e:Y(e));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:n,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const X=K("block",J);const ee={"0x0":"reverted","0x1":"success"};function te(e,t){const n={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(e=>function(e,{args:t,eventName:n}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...n?{args:t,eventName:n}:{}}}(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Q(e.transactionIndex):null,status:e.status?ee[e.status]:null,type:e.type?Z[e.type]||e.type:null};return e.blobGasPrice&&(n.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(n.blobGasUsed=BigInt(e.blobGasUsed)),n}const ne=K("transactionReceipt",te),se={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function ae(e,t){const n={};return void 0!==e.authorizationList&&(n.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?M(BigInt(e.r)):e.r,s:e.s?M(BigInt(e.s)):e.s,chainId:M(e.chainId),nonce:M(e.nonce),...void 0!==e.yParity?{yParity:M(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:M(e.v)}:{}}))),void 0!==e.accessList&&(n.accessList=e.accessList),void 0!==e.blobVersionedHashes&&(n.blobVersionedHashes=e.blobVersionedHashes),void 0!==e.blobs&&("string"!=typeof e.blobs[0]?n.blobs=e.blobs.map(e=>L(e)):n.blobs=e.blobs),void 0!==e.data&&(n.data=e.data),e.account&&(n.from=e.account.address),void 0!==e.from&&(n.from=e.from),void 0!==e.gas&&(n.gas=M(e.gas)),void 0!==e.gasPrice&&(n.gasPrice=M(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(n.maxFeePerBlobGas=M(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(n.maxFeePerGas=M(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=M(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(n.nonce=M(e.nonce)),void 0!==e.to&&(n.to=e.to),void 0!==e.type&&(n.type=se[e.type]),void 0!==e.value&&(n.value=M(e.value)),n}const re=K("transactionRequest",ae);const ie=2n**256n-1n;function oe(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}class ce extends C{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class le extends C{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class de extends C{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const me={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new de({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new le({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new ce({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new ce({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function ue(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(me);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function he(e,t="hex"){const n=pe(e),s=ue(new Uint8Array(n.length));return n.encode(s),"hex"===t?L(s.bytes):s.bytes}function pe(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),n=ye(t);return{length:t<=55?1+t:1+n+t,encode(s){t<=55?s.pushByte(192+t):(s.pushByte(247+n),1===n?s.pushUint8(t):2===n?s.pushUint16(t):3===n?s.pushUint24(t):s.pushUint32(t));for(const{encode:t}of e)t(s)}}}(e.map(e=>pe(e))):function(e){const t="string"==typeof e?W(e):e,n=ye(t.length),s=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length;return{length:s,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+n),1===n?e.pushUint8(t.length):2===n?e.pushUint16(t.length):3===n?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function ye(e){if(e<256)return 1;if(e<65536)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new C("Length is too large.")}const ge={ether:-9,wei:9};function fe(e,t="wei"){return function(e,t){let n=e.toString();const s=n.startsWith("-");s&&(n=n.slice(1)),n=n.padStart(t,"0");let[a,r]=[n.slice(0,n.length-t),n.slice(n.length-t)];return r=r.replace(/(0+)$/,""),`${s?"-":""}${a||"0"}${r?`.${r}`:""}`}(e,ge[t])}function be(e){const t=Object.entries(e).map(([e,t])=>void 0===t||!1===t?null:[e,t]).filter(Boolean),n=t.reduce((e,[t])=>Math.max(e,t.length),0);return t.map(([e,t])=>` ${`${e}:`.padEnd(n+1)} ${t}`).join("\n")}class xe extends C{constructor({v:e}){super(`Invalid \`v\` value "${e}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class we extends C{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",be(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class ve extends C{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${Math.floor((e.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}function ke(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),s="string"==typeof e.blobs[0]?e.blobs.map(e=>W(e)):e.blobs,a=[];for(const r of s)a.push(Uint8Array.from(t.blobToKzgCommitment(r)));return"bytes"===n?a:a.map(e=>L(e))}function Ne(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),s="string"==typeof e.blobs[0]?e.blobs.map(e=>W(e)):e.blobs,a="string"==typeof e.commitments[0]?e.commitments.map(e=>W(e)):e.commitments,r=[];for(let i=0;i<s.length;i++){const e=s[i],n=a[i];r.push(Uint8Array.from(t.computeBlobKzgProof(e,n)))}return"bytes"===n?r:r.map(e=>L(e))}
|
|
2
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ce(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Pe(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function je(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ie(e,t){Pe(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Se(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ae(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ee(e,t){return e<<32-t|e>>>t}function Fe(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Ue=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=Fe(e[t]);return e};function De(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),Pe(e),e}class Te{}function Be(e){const t=t=>e().update(De(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Le(e,t,n){return e&t^~e&n}function Me(e,t,n){return e&t^e&n^t&n}class Re extends Te{constructor(e,t,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(e),this.view=Ae(this.buffer)}update(e){je(this),Pe(e=De(e));const{view:t,buffer:n,blockLen:s}=this,a=e.length;for(let r=0;r<a;){const i=Math.min(s-this.pos,a-r);if(i===s){const t=Ae(e);for(;s<=a-r;r+=s)this.process(t,r);continue}n.set(e.subarray(r,r+i),this.pos),this.pos+=i,r+=i,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){je(this),Ie(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:a}=this;let{pos:r}=this;t[r++]=128,Se(this.buffer.subarray(r)),this.padOffset>s-r&&(this.process(n,0),r=0);for(let d=r;d<s;d++)t[d]=0;!function(e,t,n,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,s);const a=BigInt(32),r=BigInt(4294967295),i=Number(n>>a&r),o=Number(n&r),c=s?4:0,l=s?0:4;e.setUint32(t+c,i,s),e.setUint32(t+l,o,s)}(n,s-8,BigInt(8*this.length),a),this.process(n,0);const i=Ae(e),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=o/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)i.setUint32(4*d,l[d],a)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:s,finished:a,destroyed:r,pos:i}=this;return e.destroyed=r,e.finished=a,e.length=s,e.pos=i,s%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const $e=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ge=BigInt(2**32-1),Oe=BigInt(32);function ze(e,t=!1){return t?{h:Number(e&Ge),l:Number(e>>Oe&Ge)}:{h:0|Number(e>>Oe&Ge),l:0|Number(e&Ge)}}const We=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),He=new Uint32Array(64);class qe extends Re{constructor(e=32){super(64,e,8,!1),this.A=0|$e[0],this.B=0|$e[1],this.C=0|$e[2],this.D=0|$e[3],this.E=0|$e[4],this.F=0|$e[5],this.G=0|$e[6],this.H=0|$e[7]}get(){const{A:e,B:t,C:n,D:s,E:a,F:r,G:i,H:o}=this;return[e,t,n,s,a,r,i,o]}set(e,t,n,s,a,r,i,o){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|s,this.E=0|a,this.F=0|r,this.G=0|i,this.H=0|o}process(e,t){for(let d=0;d<16;d++,t+=4)He[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){const e=He[d-15],t=He[d-2],n=Ee(e,7)^Ee(e,18)^e>>>3,s=Ee(t,17)^Ee(t,19)^t>>>10;He[d]=s+He[d-7]+n+He[d-16]|0}let{A:n,B:s,C:a,D:r,E:i,F:o,G:c,H:l}=this;for(let d=0;d<64;d++){const e=l+(Ee(i,6)^Ee(i,11)^Ee(i,25))+Le(i,o,c)+We[d]+He[d]|0,t=(Ee(n,2)^Ee(n,13)^Ee(n,22))+Me(n,s,a)|0;l=c,c=o,o=i,i=r+e|0,r=a,a=s,s=n,n=e+t|0}n=n+this.A|0,s=s+this.B|0,a=a+this.C|0,r=r+this.D|0,i=i+this.E|0,o=o+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,s,a,r,i,o,c,l)}roundClean(){Se(He)}destroy(){this.set(0,0,0,0,0,0,0,0),Se(this.buffer)}}const Ve=Be(()=>new qe);function Qe(e){const{commitment:t,version:n=1}=e,s=e.to??("string"==typeof t?"hex":"bytes"),a=Ve(S(r=t,{strict:!1})?G(r):r);var r;return a.set([n],0),"bytes"===s?a:L(a)}const Ke=4096,Ze=131072,Ye=761855;class _e extends C{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class Je extends C{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class Xe extends C{constructor({hash:e,size:t}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`],name:"InvalidVersionedHashSizeError"})}}class et extends C{constructor({hash:e,version:t}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:["Expected: 1",`Received: ${t}`],name:"InvalidVersionedHashVersionError"})}}function tt(e){const{data:t,kzg:n,to:s}=e,a=e.blobs??function(e){const t=e.to??("string"==typeof e.data?"hex":"bytes"),n="string"==typeof e.data?W(e.data):e.data,s=A(n);if(!s)throw new Je;if(s>Ye)throw new _e({maxSize:Ye,size:s});const a=[];let r=!0,i=0;for(;r;){const e=ue(new Uint8Array(Ze));let t=0;for(;t<Ke;){const s=n.slice(i,i+31);if(e.pushByte(0),e.pushBytes(s),s.length<31){e.pushByte(128),r=!1;break}t++,i+=31}a.push(e)}return"bytes"===t?a.map(e=>e.bytes):a.map(e=>L(e.bytes))}({data:t,to:s}),r=e.commitments??ke({blobs:a,kzg:n,to:s}),i=e.proofs??Ne({blobs:a,commitments:r,kzg:n,to:s}),o=[];for(let c=0;c<a.length;c++)o.push({blob:a[c],commitment:r[c],proof:i[c]});return o}class nt extends C{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class st extends C{constructor({chainId:e}){super("number"==typeof e?`Chain ID "${e}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}class at extends C{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${fe(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(at,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class rt extends C{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${fe(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${fe(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(rt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class it extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const ot=BigInt(0),ct=BigInt(1),lt=BigInt(2),dt=BigInt(7),mt=BigInt(256),ut=BigInt(113),ht=[],pt=[],yt=[];for(let Xn=0,es=ct,ts=1,ns=0;Xn<24;Xn++){[ts,ns]=[ns,(2*ts+3*ns)%5],ht.push(2*(5*ns+ts)),pt.push((Xn+1)*(Xn+2)/2%64);let e=ot;for(let t=0;t<7;t++)es=(es<<ct^(es>>dt)*ut)%mt,es<&&(e^=ct<<(ct<<BigInt(t))-ct);yt.push(e)}const gt=function(e,t=!1){const n=e.length;let s=new Uint32Array(n),a=new Uint32Array(n);for(let r=0;r<n;r++){const{h:n,l:i}=ze(e[r],t);[s[r],a[r]]=[n,i]}return[s,a]}(yt,!0),ft=gt[0],bt=gt[1],xt=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),wt=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class vt extends Te{constructor(e,t,n,s=!1,a=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=a,Ce(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var r;this.state=new Uint8Array(200),this.state32=(r=this.state,new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)))}clone(){return this._cloneInto()}keccak(){Ue(this.state32),function(e,t=24){const n=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const t=(s+8)%10,a=(s+2)%10,r=n[a],i=n[a+1],o=xt(r,i,1)^n[t],c=wt(r,i,1)^n[t+1];for(let n=0;n<50;n+=10)e[s+n]^=o,e[s+n+1]^=c}let t=e[2],a=e[3];for(let n=0;n<24;n++){const s=pt[n],r=xt(t,a,s),i=wt(t,a,s),o=ht[n];t=e[o],a=e[o+1],e[o]=r,e[o+1]=i}for(let s=0;s<50;s+=10){for(let t=0;t<10;t++)n[t]=e[s+t];for(let t=0;t<10;t++)e[s+t]^=~n[(t+2)%10]&n[(t+4)%10]}e[0]^=ft[s],e[1]^=bt[s]}Se(n)}(this.state32,this.rounds),Ue(this.state32),this.posOut=0,this.pos=0}update(e){je(this),Pe(e=De(e));const{blockLen:t,state:n}=this,s=e.length;for(let a=0;a<s;){const r=Math.min(t-this.pos,s-a);for(let t=0;t<r;t++)n[this.pos++]^=e[a++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:s}=this;e[n]^=t,128&t&&n===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){je(this,!1),Pe(e),this.finish();const t=this.state,{blockLen:n}=this;for(let s=0,a=e.length;s<a;){this.posOut>=n&&this.keccak();const r=Math.min(n-this.posOut,a-s);e.set(t.subarray(this.posOut,this.posOut+r),s),this.posOut+=r,s+=r}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ce(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ie(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Se(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:s,rounds:a,enableXOF:r}=this;return e||(e=new vt(t,n,s,r,a)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=a,e.suffix=n,e.outputLen=s,e.enableXOF=r,e.destroyed=this.destroyed,e}}const kt=(()=>{return e=1,t=136,n=32,Be(()=>new vt(t,e,n));var e,t,n})();const Nt=new it(8192);function Ct(e,t){if(Nt.has(`${e}.${t}`))return Nt.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),s=(a=H(n),kt(S(a,{strict:!1})?G(a):a));var a;const r=n.split("");for(let o=0;o<40;o+=2)s[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(15&s[o>>1])>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const i=`0x${r.join("")}`;return Nt.set(`${e}.${t}`,i),i}const Pt=/^0x[a-fA-F0-9]{40}$/,jt=new it(8192);function It(e,t){const{strict:n=!0}=t??{},s=`${e}.${n}`;if(jt.has(s))return jt.get(s);const a=!(!Pt.test(e)||e.toLowerCase()!==e&&n&&Ct(e)!==e);return jt.set(s,a),a}function St(e,t,n,{strict:s}={}){return S(e,{strict:!1})?function(e,t,n,{strict:s}={}){const a=`0x${e.replace("0x","").slice(2*t,2*n)}`;s&&At(a,t,n);return a}(e,t,n,{strict:s}):function(e,t,n,{strict:s}={}){const a=e.slice(t,n);s&&At(a,t,n);return a}(e,t,n,{strict:s})}function At(e,t,n){if(A(e)!==n-t)throw new F({offset:n,position:"end",size:A(e)})}function Et(e){const{chainId:t,maxPriorityFeePerGas:n,maxFeePerGas:s,to:a}=e;if(t<=0)throw new st({chainId:t});if(a&&!It(a))throw new nt({address:a});if(s&&s>ie)throw new at({maxFeePerGas:s});if(n&&s&&n>s)throw new rt({maxFeePerGas:s,maxPriorityFeePerGas:n})}function Ft(e){if(!e||0===e.length)return[];const t=[];for(let n=0;n<e.length;n++){const{address:s,storageKeys:a}=e[n];for(let e=0;e<a.length;e++)if(a[e].length-2!=64)throw new ve({storageKey:a[e]});if(!It(s,{strict:!1}))throw new nt({address:s});t.push([s,a])}return t}function Ut(e,t){const n=function(e){if(e.type)return e.type;if(void 0!==e.authorizationList)return"eip7702";if(void 0!==e.blobs||void 0!==e.blobVersionedHashes||void 0!==e.maxFeePerBlobGas||void 0!==e.sidecars)return"eip4844";if(void 0!==e.maxFeePerGas||void 0!==e.maxPriorityFeePerGas)return"eip1559";if(void 0!==e.gasPrice)return void 0!==e.accessList?"eip2930":"legacy";throw new we({transaction:e})}(e);return"eip1559"===n?function(e,t){const{chainId:n,gas:s,nonce:a,to:r,value:i,maxFeePerGas:o,maxPriorityFeePerGas:c,accessList:l,data:d}=e;Et(e);const m=Ft(l),u=[M(n),a?M(a):"0x",c?M(c):"0x",o?M(o):"0x",s?M(s):"0x",r??"0x",i?M(i):"0x",d??"0x",m,...Dt(e,t)];return oe(["0x02",he(u)])}(e,t):"eip2930"===n?function(e,t){const{chainId:n,gas:s,data:a,nonce:r,to:i,value:o,accessList:c,gasPrice:l}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:s,maxFeePerGas:a,to:r}=e;if(t<=0)throw new st({chainId:t});if(r&&!It(r))throw new nt({address:r});if(n||a)throw new C("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(s&&s>ie)throw new at({maxFeePerGas:s})}(e);const d=Ft(c),m=[M(n),r?M(r):"0x",l?M(l):"0x",s?M(s):"0x",i??"0x",o?M(o):"0x",a??"0x",d,...Dt(e,t)];return oe(["0x01",he(m)])}(e,t):"eip4844"===n?function(e,t){const{chainId:n,gas:s,nonce:a,to:r,value:i,maxFeePerBlobGas:o,maxFeePerGas:c,maxPriorityFeePerGas:l,accessList:d,data:m}=e;!function(e){const{blobVersionedHashes:t}=e;if(t){if(0===t.length)throw new Je;for(const e of t){const t=A(e),n=Q(St(e,0,1));if(32!==t)throw new Xe({hash:e,size:t});if(1!==n)throw new et({hash:e,version:n})}}Et(e)}(e);let u=e.blobVersionedHashes,h=e.sidecars;if(e.blobs&&(void 0===u||void 0===h)){const t="string"==typeof e.blobs[0]?e.blobs:e.blobs.map(e=>L(e)),n=e.kzg,s=ke({blobs:t,kzg:n});if(void 0===u&&(u=function(e){const{commitments:t,version:n}=e,s=e.to??("string"==typeof t[0]?"hex":"bytes"),a=[];for(const r of t)a.push(Qe({commitment:r,to:s,version:n}));return a}({commitments:s})),void 0===h){h=tt({blobs:t,commitments:s,proofs:Ne({blobs:t,commitments:s,kzg:n})})}}const p=Ft(d),y=[M(n),a?M(a):"0x",l?M(l):"0x",c?M(c):"0x",s?M(s):"0x",r??"0x",i?M(i):"0x",m??"0x",p,o?M(o):"0x",u??[],...Dt(e,t)],g=[],f=[],b=[];if(h)for(let x=0;x<h.length;x++){const{blob:e,commitment:t,proof:n}=h[x];g.push(e),f.push(t),b.push(n)}return oe(["0x03",he(h?[y,g,f,b]:y)])}(e,t):"eip7702"===n?function(e,t){const{authorizationList:n,chainId:s,gas:a,nonce:r,to:i,value:o,maxFeePerGas:c,maxPriorityFeePerGas:l,accessList:d,data:m}=e;!function(e){const{authorizationList:t}=e;if(t)for(const n of t){const{chainId:e}=n,t=n.address;if(!It(t))throw new nt({address:t});if(e<0)throw new st({chainId:e})}Et(e)}(e);const u=Ft(d),h=function(e){if(!e||0===e.length)return[];const t=[];for(const n of e){const{chainId:e,nonce:s,...a}=n,r=n.address;t.push([e?B(e):"0x",r,s?B(s):"0x",...Dt({},a)])}return t}(n);return oe(["0x04",he([M(s),r?M(r):"0x",l?M(l):"0x",c?M(c):"0x",a?M(a):"0x",i??"0x",o?M(o):"0x",m??"0x",u,h,...Dt(e,t)])])}(e,t):function(e,t){const{chainId:n=0,gas:s,data:a,nonce:r,to:i,value:o,gasPrice:c}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:s,maxFeePerGas:a,to:r}=e;if(r&&!It(r))throw new nt({address:r});if(void 0!==t&&t<=0)throw new st({chainId:t});if(n||a)throw new C("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(s&&s>ie)throw new at({maxFeePerGas:s})}(e);let l=[r?M(r):"0x",c?M(c):"0x",s?M(s):"0x",i??"0x",o?M(o):"0x",a??"0x"];if(t){const e=(()=>{if(t.v>=35n){return(t.v-35n)/2n>0?t.v:27n+(35n===t.v?0n:1n)}if(n>0)return BigInt(2*n)+BigInt(35n+t.v-27n);const e=27n+(27n===t.v?0n:1n);if(t.v!==e)throw new xe({v:t.v});return e})(),s=E(t.r),a=E(t.s);l=[...l,M(e),"0x00"===s?"0x":s,"0x00"===a?"0x":a]}else n>0&&(l=[...l,M(n),"0x","0x"]);return he(l)}(e,t)}function Dt(e,t){const n=t??e,{v:s,yParity:a}=n;if(void 0===n.r)return[];if(void 0===n.s)return[];if(void 0===s&&void 0===a)return[];const r=E(n.r),i=E(n.s);return["number"==typeof a?a?M(1):"0x":0n===s?"0x":1n===s?M(1):27n===s?"0x":M(1),"0x00"===r?"0x":r,"0x00"===i?"0x":i]}const Tt={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};function Bt(e,t){return function(e){return"deposit"===e.type||void 0!==e.sourceHash}(e)?function(e){!function(e){const{from:t,to:n}=e;if(t&&!It(t))throw new nt({address:t});if(n&&!It(n))throw new nt({address:n})}(e);const{sourceHash:t,data:n,from:s,gas:a,isSystemTx:r,mint:i,to:o,value:c}=e;return oe(["0x7e",he([t,s,o??"0x",i?B(i):"0x",c?B(c):"0x",a?B(a):"0x",r?"0x1":"0x",n??"0x"])])}(e):Ut(e,t)}const Lt={blockTime:2e3,contracts:Tt,formatters:{block:X({format(e){var t;return{transactions:null==(t=e.transactions)?void 0:t.map(e=>{if("string"==typeof e)return e;const t=Y(e);return"0x7e"===t.typeHex&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?V(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}),stateRoot:e.stateRoot}}}),transaction:_({format(e){const t={};return"0x7e"===e.type&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?V(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:ne({format:e=>({l1GasPrice:e.l1GasPrice?V(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?V(e.l1GasUsed):null,l1Fee:e.l1Fee?V(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null})})},serializers:{transaction:Bt}},Mt=v({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:250,rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),Rt=v({id:43114,name:"Avalanche",blockTime:1700,nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{default:{name:"SnowTrace",url:"https://snowtrace.io",apiUrl:"https://api.snowtrace.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:11907934}}}),$t=1,Gt=v({...Lt,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...Lt.contracts,disputeGameFactory:{[$t]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[$t]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[$t]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[$t]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:1}),Ot=v({id:56,name:"BNB Smart Chain",blockTime:750,nativeCurrency:{decimals:18,name:"BNB",symbol:"BNB"},rpcUrls:{default:{http:["https://56.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com",apiUrl:"https://api.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15921452}}}),zt={estimateFeesPerGas:async e=>{var t;if(!(null==(t=e.request)?void 0:t.feeCurrency))return null;const[n,s]=await Promise.all([Wt(e.client,e.request.feeCurrency),Ht(e.client,e.request.feeCurrency)]);return{maxFeePerGas:e.multiply(n-s)+s,maxPriorityFeePerGas:s}}};async function Wt(e,t){const n=await e.request({method:"eth_gasPrice",params:[t]});return BigInt(n)}async function Ht(e,t){const n=await e.request({method:"eth_maxPriorityFeePerGas",params:[t]});return BigInt(n)}function qt(e){return 0===e||0n===e||null==e||"0"===e||""===e||"string"==typeof e&&("0x"===E(e).toLowerCase()||"0x00"===E(e).toLowerCase())}function Vt(e){return!qt(e)}function Qt(e){return"cip64"===e.type||function(e){return void 0!==e.maxFeePerGas&&void 0!==e.maxPriorityFeePerGas}(e)&&Vt(e.feeCurrency)}const Kt={transaction:function(e,t){return Qt(e)?function(e,t){!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:s,maxFeePerGas:a,to:r,feeCurrency:i}=e;if(t<=0)throw new st({chainId:t});if(r&&!It(r))throw new nt({address:r});if(s)throw new C("`gasPrice` is not a valid CIP-64 Transaction attribute.");if(Vt(a)&&a>Zt)throw new at({maxFeePerGas:a});if(Vt(n)&&Vt(a)&&n>a)throw new rt({maxFeePerGas:a,maxPriorityFeePerGas:n});if(Vt(i)&&!It(i))throw new C("`feeCurrency` MUST be a token address for CIP-64 transactions.");if(qt(i))throw new C("`feeCurrency` must be provided for CIP-64 transactions.")}(e);const{chainId:n,gas:s,nonce:a,to:r,value:i,maxFeePerGas:o,maxPriorityFeePerGas:c,accessList:l,feeCurrency:d,data:m}=e,u=[B(n),a?B(a):"0x",c?B(c):"0x",o?B(o):"0x",s?B(s):"0x",r??"0x",i?B(i):"0x",m??"0x",Ft(l),d,...Dt(e,t)];return oe(["0x7b",he(u)])}(e,t):Bt(e,t)}};const Zt=ie;const Yt=v({...{blockTime:1e3,contracts:Tt,formatters:{block:X({format(e){var t;return{transactions:null==(t=e.transactions)?void 0:t.map(e=>{if("string"==typeof e)return e;return{...Y(e),...e.gatewayFee?{gatewayFee:V(e.gatewayFee),gatewayFeeRecipient:e.gatewayFeeRecipient}:{},feeCurrency:e.feeCurrency}})}}}),transaction:_({format(e){if("0x7e"===e.type)return{isSystemTx:e.isSystemTx,mint:e.mint?V(e.mint):void 0,sourceHash:e.sourceHash,type:"deposit"};const t={feeCurrency:e.feeCurrency};return"0x7b"===e.type?t.type="cip64":("0x7c"===e.type&&(t.type="cip42"),t.gatewayFee=e.gatewayFee?V(e.gatewayFee):null,t.gatewayFeeRecipient=e.gatewayFeeRecipient),t}}),transactionRequest:re({format(e){const t={};return e.feeCurrency&&(t.feeCurrency=e.feeCurrency),Qt(e)&&(t.type="0x7b"),t}})},serializers:Kt,fees:zt},id:42220,name:"Celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://celoscan.io",apiUrl:"https://api.celoscan.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:13112599}},testnet:!1}),_t=v({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),Jt=1,Xt=v({...Lt,id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimism Explorer",url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io/api"}},contracts:{...Lt.contracts,disputeGameFactory:{[Jt]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[Jt]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[Jt]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[Jt]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId:1}),en=v({id:137,name:"Polygon",blockTime:2e3,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}}),tn=(e,t,n=!1)=>{if(!e||"string"!=typeof e)throw new Error(`Missing ${t} address`);if(!e.startsWith("0x"))throw new Error(`Invalid ${t} address format: must start with 0x`);if(42!==e.length)throw new Error(`Invalid ${t} address length: expected 42 characters, got ${e.length}`);if("0x0000000000000000000000000000000000000000"===e&&!n)throw new Error(`Invalid ${t} address: cannot be zero address`)},nn=e=>{const t=(e=>{tn(e.token,"token"),tn(e.recipient1,"recipient1"),tn(e.recipient2,"recipient2");const t=0n===BigInt(e.recipient3Percentage||0);if(tn(e.recipient3,"recipient3",t),!e.paymentId||"string"!=typeof e.paymentId||0===e.paymentId.length)throw new Error("Invalid payment ID: must be a non-empty string");let n,s,a,r;try{n=BigInt(e.amount||0),s=BigInt(e.recipient1Percentage||0),a=BigInt(e.recipient2Percentage||0),r=BigInt(e.recipient3Percentage||0)}catch(o){throw new Error("Invalid numeric values: cannot convert to BigInt")}if(n<=0n)throw new Error(`Invalid amount: ${e.amount} (must be greater than 0)`);const i=s+a+r;if(10000n!==i)throw new Error(`Invalid percentages: total is ${i} but must equal 10000 basis points (100%). Individual: ${s}, ${a}, ${r}`);return{amount:n,percentage1:s,percentage2:a,percentage3:r}})(e);return{token:e.token,amount:t.amount,paymentId:e.paymentId,recipient1:e.recipient1,recipient2:e.recipient2,recipient3:e.recipient3,recipient1Percentage:t.percentage1,recipient2Percentage:t.percentage2,recipient3Percentage:t.percentage3}},sn=[{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"}],an=[{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],rn=e=>{var t,n;const s=(null==(t=null==e?void 0:e.message)?void 0:t.toLowerCase())||(null==(n=null==e?void 0:e.toString())?void 0:n.toLowerCase())||"",a=(null==e?void 0:e.code)||(null==e?void 0:e.reason)||"";return s.includes("user rejected")||s.includes("user denied")||s.includes("user cancelled")||s.includes("rejected by user")||4001===a||"ACTION_REJECTED"===a?{type:"user_rejected",title:"Transaction Cancelled",message:"You cancelled the transaction. No charges were made.",suggestion:'Click "Pay Now" to try again when you\'re ready.'}:s.includes("insufficient funds")||s.includes("insufficient balance")||s.includes("insufficient eth")||s.includes("insufficient matic")||s.includes("insufficient bnb")||-32e3===a?{type:"insufficient_funds",title:"Insufficient Funds",message:"You don't have enough tokens or gas fees in your wallet.",suggestion:"Add more funds to your wallet and try again."}:s.includes("network error")||s.includes("rpc error")||s.includes("connection failed")||s.includes("timeout")||s.includes("request failed")?{type:"network_error",title:"Network Error",message:"Unable to connect to the blockchain network.",suggestion:"Check your internet connection and try again."}:s.includes("wrong network")||s.includes("unsupported network")||s.includes("chain mismatch")||4902===a?{type:"wrong_network",title:"Wrong Network",message:"Please switch to the correct network in your wallet.",suggestion:"Your wallet should prompt you to switch networks."}:s.includes("wallet not connected")||s.includes("no provider")||s.includes("wallet disconnected")||4900===a?{type:"wallet_disconnected",title:"Wallet Disconnected",message:"Your wallet is not connected.",suggestion:"Please reconnect your wallet and try again."}:s.includes("gas estimation failed")||s.includes("execution reverted")||s.includes("out of gas")?{type:"gas_error",title:"Transaction Failed",message:"The transaction couldn't be processed.",suggestion:"This might be a temporary issue. Please try again."}:s.includes("approve")&&s.includes("failed")?{type:"approval_failed",title:"Token Approval Failed",message:"Failed to approve token spending.",suggestion:"Please try the approval step again."}:s.includes("transaction failed")||s.includes("revert")||s.includes("contract call failed")?{type:"transaction_failed",title:"Transaction Failed",message:"The blockchain transaction was unsuccessful.",suggestion:"Please check your wallet and try again."}:s.includes("popup")||s.includes("blocked")?{type:"popup_blocked",title:"Wallet Popup Blocked",message:"Your browser blocked the wallet popup.",suggestion:"Please allow popups for this site and try again."}:s.includes("rate limit")||s.includes("too many requests")?{type:"rate_limited",title:"Too Many Requests",message:"Please wait a moment before trying again.",suggestion:"Wait 30 seconds and retry your transaction."}:s.includes("payment not yet confirmed")||s.includes("not yet confirmed on-chain")||s.includes("payment not found on-chain")||s.includes("please complete the payment")?{type:"payment_pending",title:"Payment Pending",message:"Your payment is still being confirmed on the blockchain.",suggestion:"Please wait a moment and try again, or check if your transaction completed successfully."}:s.includes("deep link")||s.includes("app not installed")||s.includes("wallet app")?{type:"mobile_wallet_error",title:"Wallet App Issue",message:"Unable to open or connect to your wallet app.",suggestion:"Make sure your wallet app is installed and try again."}:{type:"unknown_error",title:"Something Went Wrong",message:"An unexpected error occurred.",suggestion:"Please try again or contact support if the problem persists."}},on=(e,t="")=>({timestamp:(new Date).toISOString(),context:t,userFriendly:rn(e),technical:{message:(null==e?void 0:e.message)||"Unknown error",code:null==e?void 0:e.code,reason:null==e?void 0:e.reason,stack:null==e?void 0:e.stack,name:null==e?void 0:e.name}}),cn=async(e,t)=>{try{const n=await r.estimateFeesPerGas(e,{chainId:t}),s=120n,a=100n;return{maxFeePerGas:n.maxFeePerGas?n.maxFeePerGas*s/a:void 0,maxPriorityFeePerGas:n.maxPriorityFeePerGas?n.maxPriorityFeePerGas*s/a:void 0}}catch(n){return{}}},ln="YWG990wOlIikc1tU7-WWTepfU8d1f4dp",dn=(e,t,a,i,o,l)=>{const[d,m]=n.useState("idle"),[u,h]=n.useState(""),[p,y]=n.useState(null),{data:f,isPending:b,error:w,sendTransaction:v}=s.useSendTransaction(),{isLoading:k,isSuccess:N}=s.useWaitForTransactionReceipt({hash:f}),C=async()=>{var e,t,n,s,a,i,c;try{m("splitPayment");const u=window.coinleyPendingSplitPayment;if(!u)throw new Error("Missing split payment data");const{contractCall:h,selectedToken:p,paymentData:f,selectedNetwork:b}=u,w=b.chainId||10,v=await o.getContractInfo(w),{abi:k}=v,N=nn(h.params),C=x(w),P=1===C,j=P||43114===C;try{const{request:e}=await r.simulateContract(g,{address:h.contractAddress,abi:k,functionName:"splitPayment",args:[N]})}catch(l){const a=l.data||(null==(e=l.cause)?void 0:e.data);a&&("string"==typeof a&&a.startsWith("0x08c379a0")||"string"==typeof a&&a.startsWith("0x4e487b71"));l.reason||(null==(t=l.cause)?void 0:t.reason)||(null==(n=l.cause)?void 0:n.shortMessage)||(null==(s=l.data)||s.message);if(!j){const{userFriendlyMessage:e}=(e=>{if(!e.message)return{revertReason:"Transaction will revert",userFriendlyMessage:"Transaction simulation failed"};const t=e.message.toLowerCase();return t.includes("abi encoding params/values length mismatch")?{revertReason:"Smart contract parameter mismatch. This is likely a technical issue.",userFriendlyMessage:"Technical error: Contract parameters mismatch. Please try again or contact support."}:t.includes("payment id already used")?{revertReason:"This payment ID has already been used.",userFriendlyMessage:"This payment has already been processed. Please check your transaction history."}:t.includes("percentages must equal 100")?{revertReason:"Payment split percentages are incorrect.",userFriendlyMessage:"Internal error: Payment split configuration is invalid. Please contact support."}:t.includes("token transfer failed")||t.includes("transfer amount exceeds")?{revertReason:"Insufficient token balance or approval.",userFriendlyMessage:"Insufficient balance or token approval. Please check your wallet balance."}:t.includes("amount must be greater than 0")?{revertReason:"Payment amount is invalid.",userFriendlyMessage:"Invalid payment amount. Please try again."}:t.includes("invalid recipient")||t.includes("zero address")?{revertReason:"One of the payment recipients has an invalid address.",userFriendlyMessage:"Payment configuration error: Invalid recipient address. Please contact support."}:t.includes("insufficient gas")||t.includes("out of gas")?{revertReason:"Insufficient gas for transaction.",userFriendlyMessage:"Not enough gas to process transaction. Please increase gas limit or check ETH balance."}:t.includes("nonce")?{revertReason:"Transaction nonce conflict.",userFriendlyMessage:"Transaction ordering conflict. Please try again in a moment."}:{revertReason:e.message,userFriendlyMessage:`Transaction simulation failed: ${e.message.substring(0,100)}${e.message.length>100?"...":""}`}})(l);throw new Error(e)}}const I=await cn(g,w),S="arbitrum"===b.shortName,A=S?2:0;let E;for(let e=0;e<=A;e++)try{if(e>0){const t=2e3*e;await new Promise(e=>setTimeout(e,t))}E=await r.writeContract(g,{address:h.contractAddress,abi:k,functionName:"splitPayment",args:[N],...I});break}catch(d){const t=(null==(a=d.message)?void 0:a.includes("Internal JSON-RPC error"))||(null==(i=d.message)?void 0:i.includes("-32603"))||(null==(c=d.message)?void 0:c.includes("nonce"));if(e===A||!t&&!S)throw d}return y(E),m("processing"),window.coinleyPendingSplitPayment=null,E}catch(u){on(u,"split_payment_transaction");const e=rn(u);throw h(e),m("error"),u}},P=async t=>{try{if(m("processing"),!o||!o.processPayment)throw new Error("API instance not available or missing processPayment method");await new Promise(e=>setTimeout(e,8e3));const n=await o.processPayment(e.id,t,a.shortName,i);return m("success"),n}catch(n){on(n,"final_payment_processing");const e=rn(n);throw h(e),m("error"),n}};return{transactionStep:d,transactionError:u,currentTransactionHash:p,txPending:b,isConfirming:k,isConfirmed:N,executePaymentTransaction:async()=>{var n,s;if(!i||!(null==e?void 0:e.contractCall))throw new Error("Missing wallet connection or payment data");const o=e.contractCall;if(!o.contractAddress)throw new Error("PaymentSplitter contract data missing from payment response");if((null==l?void 0:l.ensureCorrectNetwork)&&a){if(!(await l.ensureCorrectNetwork(a)))throw new Error("Network verification failed. Please ensure you are on the correct network.")}if(!t.contractAddress)throw new Error("Native token transactions not yet supported with PaymentSplitter. Please use ERC-20 tokens.");{const l=t.decimals||6,k=o.approvalAmount||Math.floor(e.totalAmount*Math.pow(10,l));try{let e,n="unknown";try{e=await r.readContract(g,{address:o.tokenAddress,abi:an,functionName:"balanceOf",args:[i]}),n="wallet-rpc"}catch(d){const t=(null==a?void 0:a.chainId)||(null==a?void 0:a.id);if(!t)throw d;{const s=(e=>{const t={1:_t,56:Ot,137:en,42161:Mt,10:Xt,43114:Rt,42220:Yt,8453:Gt}[e],n={1:[`https://eth-mainnet.g.alchemy.com/v2/${ln}`,"https://cloudflare-eth.com","https://eth.llamarpc.com","https://ethereum.publicnode.com"],56:[`https://bnb-mainnet.g.alchemy.com/v2/${ln}`,"https://bsc-dataseed.bnbchain.org","https://bsc-dataseed-public.bnbchain.org","https://bsc.nodereal.io"],137:[`https://polygon-mainnet.g.alchemy.com/v2/${ln}`,"https://polygon.llamarpc.com","https://polygon-rpc.com","https://polygon.drpc.org"],42161:[`https://arb-mainnet.g.alchemy.com/v2/${ln}`,"https://arb1.arbitrum.io/rpc","https://arbitrum.llamarpc.com"],10:[`https://opt-mainnet.g.alchemy.com/v2/${ln}`,"https://mainnet.optimism.io","https://optimism.llamarpc.com"],43114:[`https://avax-mainnet.g.alchemy.com/v2/${ln}`,"https://api.avax.network/ext/bc/C/rpc","https://avalanche.public-rpc.com"],42220:[`https://celo-mainnet.g.alchemy.com/v2/${ln}`,"https://forno.celo.org","https://celo.drpc.org"],8453:[`https://base-mainnet.g.alchemy.com/v2/${ln}`,"https://mainnet.base.org","https://base.llamarpc.com","https://base.meowrpc.com"]}[e];if(!t||!n)return null;const s=n.map(e=>c.http(e,{timeout:1e4,retryCount:1}));return c.createPublicClient({chain:t,transport:c.fallback(s)})})(x(t));if(!s)throw d;try{e=await s.readContract({address:o.tokenAddress,abi:an,functionName:"balanceOf",args:[i]}),n="fallback-rpc"}catch(u){throw d}}}const s=BigInt(k);if(e<s){const n=`Insufficient ${t.symbol} balance. You have ${(Number(e)/Math.pow(10,l)).toFixed(6)} ${t.symbol} but need ${(Number(s)/Math.pow(10,l)).toFixed(6)} ${t.symbol}`;throw new Error(n)}}catch(p){if(p.message.includes("Insufficient"))throw p}m("approve"),window.coinleyPendingSplitPayment={contractCall:o,selectedToken:t,paymentData:e,selectedNetwork:a};try{const e="0xdac17f958d2ee523a2206206994597c13d831ec7"===o.tokenAddress.toLowerCase()||"USDT"===t.symbol.toUpperCase();let n,s=c.erc20Abi;e&&(s=sn);try{n=BigInt(k)}catch(f){throw new Error(`Invalid amount value: ${k}`)}let l=0n,d=0;const u=3;for(;d<u;)try{l=await r.readContract(g,{address:o.tokenAddress,abi:c.erc20Abi,functionName:"allowance",args:[i,o.contractAddress]});break}catch(b){d++,d<u?await new Promise(e=>setTimeout(e,2e3)):l=0n}if(l>=n){m("splitPayment");const e=await C();return e&&await P(e),e}if(e&&l>0n){const e=await cn(g,a.chainId),t=await r.writeContract(g,{address:o.tokenAddress,abi:c.erc20Abi,functionName:"approve",args:[o.contractAddress,0n],...e});await r.waitForTransactionReceipt(g,{hash:t,confirmations:1,timeout:12e4})}const h=await cn(g,a.chainId),p=await r.writeContract(g,{address:o.tokenAddress,abi:c.erc20Abi,functionName:"approve",args:[o.contractAddress,n],...h});y(p);await r.waitForTransactionReceipt(g,{hash:p,confirmations:1,timeout:12e4});await new Promise(e=>setTimeout(e,3e3));let x=0;const v=3;let N=!1;for(;x<v&&!N;){try{if(await r.readContract(g,{address:o.tokenAddress,abi:c.erc20Abi,functionName:"allowance",args:[i,o.contractAddress]})>=n){N=!0;break}x<v-1&&await new Promise(e=>setTimeout(e,2e3))}catch(w){x<v-1&&await new Promise(e=>setTimeout(e,2e3))}x++}const j=await C();return j&&await P(j),j}catch(v){on(v,"approve_transaction");const e=rn(v);if(h(e),m("idle"),(null==(n=v.message)?void 0:n.includes("User rejected"))||(null==(s=v.message)?void 0:s.includes("User denied"))||4001===v.code)throw new Error("Transaction was cancelled by user");throw new Error(`Approve failed: ${v.message}`)}}},executeSplitPayment:C,processFinalPayment:P,resetTransaction:()=>{m("idle"),h(""),y(null),window.coinleyPendingSplitPayment=null},setTransactionError:h,setTransactionStep:m}},mn=({options:e=[],value:s,onChange:a,placeholder:r,renderOption:i,getOptionKey:o,getOptionValue:c,getSearchableText:d,disabled:m=!1})=>{const[u,h]=n.useState(!1),[p,y]=n.useState(""),[g,f]=n.useState({top:0,left:0,width:400,maxHeight:450}),b=n.useRef(null),x=n.useRef(null),w=e.filter(e=>(d?d(e):"").toLowerCase().includes(p.toLowerCase())),v=e.find(e=>c(e)===s),k=()=>{if(x.current){const e=window.innerWidth,t=window.innerHeight,n=Math.min(400,e-40),s=Math.min(450,t-100);f({top:t/2-s/2,left:e/2-n/2,width:n,maxHeight:s})}};n.useEffect(()=>{const e=e=>{b.current&&!b.current.contains(e.target)&&x.current&&!x.current.contains(e.target)&&(h(!1),y(""))},t=()=>{u&&k()};if(u){k();const n=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${n}px`,document.body.style.width="100%",document.addEventListener("mousedown",e),window.addEventListener("resize",t)}return()=>{if(u){const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",window.scrollTo(0,-1*parseInt(e||"0"))}document.removeEventListener("mousedown",e),window.removeEventListener("resize",t)}},[u]);const N=u&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-30 transition-opacity",style:{zIndex:999998},onClick:()=>{h(!1),y("")}}),t.jsxs("div",{ref:b,className:"fixed bg-white border-2 border-gray-200 rounded-3xl shadow-2xl overflow-hidden",style:{top:g.top,left:g.left,width:g.width,maxHeight:g.maxHeight,zIndex:999999,transform:"translateZ(0)",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05)"},children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 bg-gradient-to-r from-[#7042D2]/10 to-purple-50",children:[t.jsx("h3",{className:"text-lg font-semibold text-[#7042D2]",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:r||"Select Option"}),t.jsx("button",{onClick:()=>{h(!1),y("")},className:"text-gray-500 hover:text-gray-700 transition-colors p-1 rounded-full hover:bg-gray-100",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"p-4 border-b border-gray-200 bg-gray-50",children:t.jsx("input",{type:"text",placeholder:"Search networks and tokens...",value:p,onChange:e=>y(e.target.value),className:"w-full p-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-[#7042D2]/20 focus:border-[#7042D2] text-sm",style:{fontFamily:"Bricolage Grotesque, sans-serif"},autoFocus:!0})}),t.jsx("div",{className:"overflow-y-auto custom-scrollbar",style:{maxHeight:(g.maxHeight||450)-180+"px",minHeight:"200px"},children:0===w.length?t.jsxs("div",{className:"p-8 text-gray-500 text-center",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[t.jsx("div",{className:"text-4xl mb-3",children:"๐"}),t.jsx("div",{className:"text-lg mb-2",children:"No options found"}),t.jsx("div",{className:"text-sm text-gray-400",children:"Try a different search term"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-4 py-3 bg-gray-50 border-b border-gray-100 text-sm text-gray-600",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[t.jsx("span",{className:"font-semibold",children:w.length})," option",1!==w.length?"s":""," available"]}),t.jsx("div",{className:"p-2",children:w.map(e=>t.jsx("button",{type:"button",onClick:()=>{a(c(e)),h(!1),y("")},className:"w-full p-4 text-left hover:bg-[#7042D2]/10 transition-all duration-200 rounded-xl mb-2 last:mb-0 "+(c(e)===s?"bg-[#7042D2]/20 text-[#7042D2] border-2 border-[#7042D2]/30":"text-gray-800 border-2 border-transparent hover:border-[#7042D2]/20"),style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:i(e)},o(e)))})]})}),t.jsx("div",{className:"p-3 bg-gradient-to-r from-gray-50 to-gray-100 border-t border-gray-200 text-center",children:t.jsx("div",{className:"text-xs text-gray-500",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:w.length>5?"โ๏ธ Scroll to see more options":"โจ Select your preferred option"})})]})]});return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative",children:t.jsx("button",{ref:x,type:"button",onClick:()=>{m||(u||k(),h(!u))},disabled:m,className:`w-full p-4 border-2 rounded-2xl bg-gradient-to-r from-white to-gray-50 text-left focus:outline-none focus:ring-3 focus:ring-[#7042D2]/20 focus:border-[#7042D2] transition-all duration-300 ease-out shadow-lg hover:shadow-xl ${m?"opacity-50 cursor-not-allowed":"hover:border-[#7042D2]/50 cursor-pointer"} ${u?"border-[#7042D2] ring-3 ring-[#7042D2]/20":"border-gray-200"}`,style:{minHeight:"60px",fontFamily:"Bricolage Grotesque, sans-serif",fontSize:"16px",fontWeight:"500"},children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center space-x-3",children:v?i(v):t.jsx("span",{className:"text-gray-500",children:r})}),t.jsx("div",{className:"transform transition-transform duration-200 "+(u?"rotate-180":""),children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-[#7042D2]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})})}),"undefined"!=typeof document&&document.body&&l.createPortal(N,document.body),t.jsx("style",{jsx:!0,children:"\n .custom-scrollbar {\n scrollbar-width: thin;\n scrollbar-color: #7042D2 #f1f1f1;\n }\n .custom-scrollbar::-webkit-scrollbar {\n width: 12px;\n }\n .custom-scrollbar::-webkit-scrollbar-track {\n background: #f8f9fa;\n border-radius: 10px;\n margin: 4px;\n }\n .custom-scrollbar::-webkit-scrollbar-thumb {\n background: linear-gradient(180deg, #7042D2 0%, #5b34b1 100%);\n border-radius: 10px;\n border: 2px solid #f8f9fa;\n }\n .custom-scrollbar::-webkit-scrollbar-thumb:hover {\n background: linear-gradient(180deg, #5b34b1 0%, #4c2a93 100%);\n }\n .custom-scrollbar::-webkit-scrollbar-corner {\n background: #f8f9fa;\n }\n "})]})},un=({currentStep:e,targetStep:s,children:a,className:r="",duration:i=300})=>{const[o,c]=n.useState(e===s),[l,d]=n.useState(e===s);return n.useEffect(()=>{e===s?(d(!0),setTimeout(()=>c(!0),10)):(c(!1),setTimeout(()=>d(!1),i))},[e,s,i]),l?t.jsx("div",{className:`\n transition-all duration-300 ease-out\n ${o?"transform translate-y-0 opacity-100":"transform translate-y-full opacity-0"}\n ${r}\n `,style:{transitionDuration:`${i}ms`},children:a}):null},hn=({status:e,message:s,theme:a="light",payment:r=null,transactionHash:i=null,selectedPaymentMethod:o=null,selectedNetwork:c=null,merchantName:l="Merchant",onClose:d=null})=>{const[m,u]=n.useState(!1),[h,p]=n.useState(0);n.useEffect(()=>{if("processing"===e){const e=setInterval(()=>{p(e=>e>=90?e:e+15*Math.random())},500);return()=>clearInterval(e)}},[e]);const y=async()=>{if(i)try{await navigator.clipboard.writeText(i),u(!0),setTimeout(()=>u(!1),2e3)}catch(e){}},g=()=>{switch(e){case"processing":return t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-[#7042D2] border-blue-500/20"}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-6 h-6 bg-[#7042D2] rounded-full animate-pulse"})})]});case"success":return t.jsx("div",{className:"rounded-full h-16 w-16 bg-green-500 flex items-center justify-center animate-bounce",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return t.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}};return"processing"===e?t.jsxs("div",{className:"flex flex-col items-center justify-center py-6 px-4",children:[t.jsx("div",{className:"mb-6",children:g()}),t.jsx("h3",{className:"text-xl font-bold mb-3 text-gray-900",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Processing Payment"}),t.jsx("p",{className:"text-center text-gray-600 mb-6",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Your transaction has been sent to the blockchain and is being processed..."}),t.jsxs("div",{className:"w-full max-w-xs mb-4",children:[t.jsx("div",{className:"bg-gray-200 rounded-full h-3",children:t.jsx("div",{className:"bg-[#7042D2] h-3 rounded-full transition-all duration-500 ease-out",style:{width:`${h}%`}})}),t.jsxs("div",{className:"text-center mt-2 text-sm text-gray-500",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Processing... ",Math.round(h),"%"]})]}),t.jsxs("div",{className:"text-center space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),t.jsx("span",{className:"text-sm text-gray-600",children:"Transaction submitted"})]}),t.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 bg-yellow-500 rounded-full animate-pulse"}),t.jsx("span",{className:"text-sm text-gray-600",children:"Confirming on blockchain..."})]}),t.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 bg-gray-300 rounded-full"}),t.jsx("span",{className:"text-sm text-gray-400",children:"Finalizing payment..."})]})]}),t.jsx("div",{className:"mt-6 p-3 bg-blue-50 rounded-lg border border-blue-200",children:t.jsx("p",{className:"text-xs text-blue-800 text-center",children:"Please don't close this window. This usually takes 10-30 seconds."})})]}):"success"===e?t.jsxs("div",{className:"flex flex-col items-center justify-center py-6 px-4",children:[t.jsx("div",{className:"mb-6",children:g()}),t.jsx("h3",{className:"text-2xl font-bold mb-3 text-gray-900",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Payment Successful!"}),r&&o&&t.jsxs("p",{className:"text-center max-w-[235px] mb-6 text-gray-600",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Your payment of ",t.jsxs("span",{className:"text-[#7042D2] font-semibold",children:[r.totalAmount||r.amount," ",o.currency]})," has been completed."]}),i&&t.jsxs("div",{className:"w-full mb-6 px-4",children:[t.jsx("p",{className:"text-sm font-medium mb-2 text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Transaction Details"}),t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors bg-gray-50 border-gray-200 hover:bg-gray-100 mb-3",onClick:y,children:[t.jsx("span",{className:"font-mono text-sm text-gray-700",children:(f=i,f?f.length<=16?f:`${f.slice(0,8)}...${f.slice(-8)}`:"")}),t.jsxs("div",{className:"flex items-center",children:[m?t.jsx("span",{className:"text-green-500 text-xs font-medium mr-2",children:"Copied!"}):null,t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})]}),(()=>{const e=((e,t)=>{if(!e||!t)return null;const n="string"==typeof t?t:t.shortName||t.name;return{ethereum:`https://etherscan.io/tx/${e}`,bsc:`https://bscscan.com/tx/${e}`,polygon:`https://polygonscan.com/tx/${e}`,arbitrum:`https://arbiscan.io/tx/${e}`,optimism:`https://optimistic.etherscan.io/tx/${e}`,avalanche:`https://snowtrace.io/tx/${e}`,celo:`https://celoscan.io/tx/${e}`,base:`https://basescan.org/tx/${e}`}[null==n?void 0:n.toLowerCase()]||null})(i,c),n=(e=>{if(!e)return"Explorer";const t="string"==typeof e?e:e.shortName||e.name;return{ethereum:"Etherscan",bsc:"BscScan",polygon:"PolygonScan",arbitrum:"Arbiscan",optimism:"Optimistic Etherscan",avalanche:"SnowTrace",celo:"CeloScan",base:"BaseScan"}[null==t?void 0:t.toLowerCase()]||"Explorer"})(c);return c&&e&&t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full p-3 rounded-lg border border-[#7042D2] bg-white hover:bg-purple-50 transition-colors group",children:[t.jsxs("span",{className:"text-sm font-medium text-[#7042D2]",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["View on ",n]}),t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2] group-hover:translate-x-1 transition-transform",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})})()]}),d&&t.jsx("button",{onClick:d,className:"w-full py-3 px-4 bg-[#7042D2] text-white font-semibold rounded-2xl text-lg shadow-md hover:bg-[#5b34b1] transition-colors",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Close"})]}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[t.jsx("div",{className:"mb-4",children:g()}),t.jsx("h3",{className:"text-xl font-bold mb-2 text-gray-900",children:"processing"===e?"Processing Payment":"error"===e?"Payment Failed":"Unknown Status"}),t.jsx("p",{className:"text-center text-gray-600",children:s})]});var f},pn={bitcoin:1,ethereum:1027,bsc:1839,polygon:3890,cardano:2010,avalanche:5805,fantom:3513,arbitrum:11841,optimism:11840,USDT:825,USDC:3408,BUSD:4687,DAI:4943,FRAX:6952,TUSD:2563,USDP:5992,USDD:5994,FDUSD:26081,PYUSD:28295,WBTC:3717,LINK:1975,UNI:7083,AAVE:7278,COMP:5692,YFI:5864,MKR:1518,SUSHI:6758,CRV:6538,SNX:2586,UMA:5617,BAL:5728,MANA:1966,SAND:6210,APE:18876,LDO:8e3,GRT:6719,ENS:13855,RPL:2943,SHIB:5994,MATIC:3890,BNB:1839,ADA:2010,SOL:5426,DOT:6636,AVAX:5805,TRX:1958,ALGO:4030,FTM:3513,ARB:11841,OP:11840,"1INCH":8104,DYDX:11156,ICP:8916,FIL:2280,CAKE:7186,RUNE:4157,ALPHA:7232,BNT:1727,KNC:1982,ZRX:1896,REN:2539,LRC:1934,WETH:2396,WMATIC:3890,WBNB:1839,UST:7129,USTC:7129,LUSD:8115,MIM:9681,FEI:8642,TRIBE:8741,RAI:8525,SUSD:2927},yn={ethereum:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",bsc:"https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png",polygon:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png",arbitrum:"https://s2.coinmarketcap.com/static/img/coins/64x64/11841.png",avalanche:"https://s2.coinmarketcap.com/static/img/coins/64x64/5805.png",celo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5567.png",optimism:"https://s2.coinmarketcap.com/static/img/coins/64x64/11840.png",base:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",eth:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",bnb:"https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png",trx:"https://s2.coinmarketcap.com/static/img/coins/64x64/1958.png",algo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",sol:"https://s2.coinmarketcap.com/static/img/coins/64x64/5426.png",matic:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png",arb:"https://s2.coinmarketcap.com/static/img/coins/64x64/11841.png",avax:"https://s2.coinmarketcap.com/static/img/coins/64x64/5805.png",op:"https://s2.coinmarketcap.com/static/img/coins/64x64/11840.png"},gn={metamask:"https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Fox.svg",coinbase:"https://avatars.githubusercontent.com/u/18060234?s=280&v=4",rabby:"https://rabby.io/logo-128.png",zerion:"https://app.zerion.io/favicon-32x32.png",phantom:"https://phantom.app/favicons/apple-touch-icon.png",trust:"https://trustwallet.com/favicon-196x196.png",okx:"https://static.okx.com/cdn/assets/imgs/248/58E63FEA47A2B7D7.png",binance:"https://bin.bnbstatic.com/static/images/common/favicon.ico",cryptocom:"https://crypto.com/favicon.ico",hot:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiNGRjZBNkEiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMmg0djhoLTR2LTJoMnYtNGgtMnYtMnptNiAwaDJ2MmgtdjdoLTJ2LTIiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg==",backpack:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiMwMEQ0QUEiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMGg4djJoLTJ2NmgtdjhoLTZWMTB6bTIgMnY0aDJWMTJ6IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4=","1inch":"https://1inch.io/favicon.svg",default:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiM2MzY2RjEiIHN0cm9rZT0iI0Y5RkFGQiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMmgxMnY4SDEweiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxLjUiIHJ4PSIxIi8+CjxjaXJjbGUgY3g9IjE4IiBjeT0iMTYiIHI9IjEiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg=="},fn=e=>(e=>{if(!e)return null;const t=pn[e.toUpperCase()];return t?`https://s2.coinmarketcap.com/static/img/coins/64x64/${t}.png`:null})(e),bn=(e,t)=>{const n=e.toLowerCase(),s=t.toLowerCase();for(const[a,r]of Object.entries(gn))if(n.includes(a)||s.includes(a))return r;return gn.default},xn=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),wn=e=>{switch(e){case"trust":return window.ethereum&&!0===window.ethereum.isTrust;case"metaMask":return window.ethereum&&!0===window.ethereum.isMetaMask;case"injected":return window.ethereum&&!window.ethereum.isMetaMask&&!window.ethereum.isCoinbaseWallet;default:return!1}},vn=(e,t)=>{if(!t)return[];if(!["ethereum","bsc","polygon","arbitrum","optimism","avalanche","celo","base"].includes(t.shortName))return[];return[...(e||[]).map(e=>(e=>({type:e.id,name:e.name,icon:bn(e.name,e.id),description:`Connect using ${e.name}`,isInstalled:!0,connector:e,isWagmi:!0}))(e)),...xn()?[{type:"trust",name:"Trust Wallet",icon:"๐ก๏ธ",description:"Multi-chain wallet with transaction deep links",isInstalled:!1,connector:null,isWagmi:!1,mobileOnly:!0,hasTransactionDeepLinks:!0}]:[]]},kn=(e,t,n,s,a="metamask",r=null)=>{if(!e)return null;try{const t="https://paymentscreen.vercel.app",s=new URLSearchParams,r=(null==e?void 0:e.id)||(null==e?void 0:e.splitterPaymentId);if(!r)return null;s.set("paymentId",r),s.set("preferredWallet",a),s.set("isMobile","true");const i=`${t}?${s.toString()}`;let o;switch(a){case"metamask":o=`https://metamask.app.link/dapp/${i.replace("https://","")}`;break;case"trust":const e=(null==n?void 0:n.chainId)||1;o=`https://link.trustwallet.com/open_url?coin_id=${(e=>{const t="string"==typeof e&&e.startsWith("0x")?parseInt(e,16):parseInt(e);return[1,56,137,42161,10,43114,42220,8453].includes(t)?60:{}[t]||60})(e)}&url=${encodeURIComponent(i)}`;break;case"coinbase":o=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(i)}`;break;default:o=i}return o}catch(i){return null}},Nn=(e,t)=>{if(!t)return null;try{switch(e){case"metamask":return t.includes("metamask.app.link")?t:`https://metamask.app.link/dapp/${t.replace("https://","")}`;case"trust":return t.includes("link.trustwallet.com")?t:`https://link.trustwallet.com/open_url?coin_id=60&url=${encodeURIComponent(t)}`;case"coinbase":return t.includes("go.cb-w.com")?t:`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(t)}`;default:return t}}catch(n){return t}},Cn=Object.freeze(Object.defineProperty({__proto__:null,generateMobilePaymentDeepLink:Nn,generateQRPaymentURI:kn},Symbol.toStringTag,{value:"Module"})),Pn=({walletAddress:e,amount:s,currency:a,network:r,theme:i="light",paymentData:o=null,onPaymentDetected:c=null,config:l=null,selectedToken:m=null,selectedNetwork:u=null,preferredWallet:h="metamask",compact:p=!1})=>{const[y,g]=n.useState(""),[f,b]=n.useState(""),[x,w]=n.useState(!0),[v,k]=n.useState(!1),[N,C]=n.useState(!1),P=n.useRef(null);return n.useEffect(()=>{(async()=>{if(null==o?void 0:o.id){w(!0);try{if(!m||!m.contractAddress)throw new Error("Cannot generate QR code: Token contract address required");if(!u||!u.chainId)throw new Error("Cannot generate QR code: Network chain ID required");const e=kn(o,0,u,0,h);if(e.includes("metamask.app.link")||e.includes("link.trustwallet.com")||e.includes("go.cb-w.com"),!e)throw new Error("Failed to generate Coinley payment URL");g(e);const t=xn(),n=await d.toDataURL(e,{width:p?140:t?350:280,margin:2,errorCorrectionLevel:"M",color:{dark:"dark"===i?"#FFFFFF":"#000000",light:"dark"===i?"#000000":"#FFFFFF"}});b(n),w(!1)}catch(e){w(!1)}}else w(!1)})()},[o,s,a,r,i,m,u,l,h]),n.useEffect(()=>()=>{P.current&&clearInterval(P.current)},[]),t.jsx("div",{className:"flex flex-col items-center",children:t.jsxs("div",{className:"flex gap-3 items-start w-full mb-2",children:[t.jsx("div",{className:"p-1.5 rounded-lg bg-white shadow-sm border flex-shrink-0",children:x?t.jsx("div",{className:"flex items-center justify-center",style:{width:140,height:140},children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-purple-600 mx-auto mb-1"}),t.jsx("div",{className:"text-xs text-gray-600",children:"Generating..."})]})}):f?t.jsx("img",{src:f,alt:"Payment QR Code",className:"rounded-lg",style:{width:140,height:140}}):t.jsx("div",{className:"flex items-center justify-center bg-gray-100 rounded-lg",style:{width:140,height:140},children:t.jsxs("div",{className:"text-center p-2",children:[t.jsx("div",{className:"text-lg mb-1",children:"โ ๏ธ"}),t.jsx("div",{className:"text-xs text-gray-600",children:(null==o?void 0:o.id)?"QR Failed":"Payment not created"})]})})}),t.jsxs("div",{className:"flex-1 flex flex-col justify-center",children:[t.jsxs("div",{className:"p-2 bg-gray-50 rounded-lg mb-2",children:[t.jsxs("div",{className:"flex justify-between items-center mb-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-600",children:"Amount:"}),t.jsxs("span",{className:"text-sm font-bold text-[#7042D2]",children:[s," ",a]})]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),t.jsx("span",{className:"text-xs font-medium text-gray-700",children:r})]})]}),N?t.jsxs("div",{className:"flex items-center justify-center text-xs font-semibold text-green-600 p-1.5 bg-green-50 rounded-lg",children:[t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Payment Received!"]}):t.jsx("div",{className:"p-1.5 rounded-lg bg-blue-50 border border-blue-200",children:t.jsx("p",{className:"text-xs text-blue-700 text-center leading-tight",children:"๐ฑ Scan with phone camera"})})]})]})})},jn=({selectedNetwork:e,onWalletSelect:a,onConnect:r,connectedWallet:i,loading:o,paymentData:c=null,selectedToken:l=null,api:d=null})=>{const[m,u]=n.useState(null),{connectors:h}=s.useConnect(),{isConnected:p,address:y}=s.useAccount(),g=vn(h,e),f=async(t,n)=>{if(xn())if(c)try{const{generateQRPaymentURI:s,generateMobilePaymentDeepLink:a}=await Promise.resolve().then(()=>Cn),r=s(c,l,e,(null==d?void 0:d.config)||{},n);if(!r)throw new Error("Failed to generate payment URL");const i=a(n,r);if(!i)throw new Error(`Failed to generate ${t.name} deep link`);window.location.href=i}catch(s){alert(`Failed to open ${t.name}: ${s.message}`)}else alert("Please create a payment first before selecting a mobile wallet.");else alert(`Please install ${t.name} mobile app or use the browser extension if available.`)};return e?0===g.length?t.jsxs("div",{className:"text-center p-4",children:[t.jsxs("p",{className:"text-gray-500 mb-4",children:["No compatible wallets found for ",e.name]}),t.jsx("div",{className:"p-3 bg-amber-50 rounded-lg border border-amber-200",children:t.jsxs("div",{className:"text-sm text-amber-800",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[t.jsx("div",{className:"font-medium mb-2",children:"Install a compatible wallet:"}),t.jsxs("div",{className:"space-y-1 text-xs",children:[t.jsxs("div",{children:["โข ",t.jsx("a",{href:"https://metamask.io/download/",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-900",children:"Install MetaMask Wallet"})]}),t.jsxs("div",{children:["โข ",t.jsx("a",{href:"https://www.coinbase.com/wallet",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-900",children:"Install Coinbase Wallet"})]})]})]})})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Select Wallet for ",e.name]}),t.jsx(mn,{options:g,value:(null==i?void 0:i.walletType)||m||"",onChange:async e=>{u(e);const t=g.find(t=>t.type===e);t&&(a(e),t.isWagmi&&t.connector?await r(t.connector):t.isWagmi||await f(t,e))},placeholder:"Choose your wallet...",renderOption:e=>{var n,s;return t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsxs("div",{className:"w-8 h-8 flex items-center justify-center",children:[e.icon.startsWith("http")||e.icon.startsWith("data:")?t.jsx("img",{src:e.icon,alt:e.name,className:"w-6 h-6 rounded-full object-contain",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="block"}}):t.jsx("div",{className:"text-2xl",children:e.icon}),t.jsx("div",{className:"text-xl",style:{display:"none"},children:"๐"})]}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"font-semibold text-gray-800 flex items-center",children:[e.name,wn(e.type)&&t.jsx("span",{className:"ml-2 px-2 py-1 bg-blue-100 text-blue-700 text-xs rounded-full",children:"DETECTED"}),(null==i?void 0:i.walletType)===e.type&&t.jsx("span",{className:"ml-2 px-2 py-1 bg-green-100 text-green-700 text-xs rounded-full",children:"CONNECTED"})]}),t.jsx("div",{className:"text-sm text-gray-500",children:(null==i?void 0:i.walletType)===e.type?`Connected โข ${null==(n=i.account)?void 0:n.slice(0,6)}...${null==(s=i.account)?void 0:s.slice(-4)}`:e.description})]}),o&&m===e.type&&t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-[#7042D2]"})]})},getOptionKey:e=>e.type,getOptionValue:e=>e.type,getSearchableText:e=>`${e.name} ${e.description}`,disabled:o})]}):t.jsx("div",{className:"text-center p-4",children:t.jsx("p",{className:"text-gray-500",children:"Please select a network first"})})},In=(()=>{if("undefined"!=typeof process&&process.env)return!1;if("undefined"!=typeof window){const e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e||e.includes("192.168.")}return!1})()||(()=>{if("undefined"!=typeof window){const e=new URLSearchParams(window.location.search);return"true"===e.get("debug")||"true"===e.get("debugMode")}return!1})(),Sn=({paymentData:e,selectedToken:s,selectedNetwork:a,config:r,onPaymentStarted:i=()=>{},onError:o=()=>{}})=>{var c,l;const[d,m]=n.useState(null),[u,h]=n.useState(!1),[p,y]=n.useState([]),[g,f]=n.useState(!1),[b,x]=n.useState(0);n.useEffect(()=>{var t,n,r;(null==e?void 0:e.id)&&(null==s?void 0:s.contractAddress)&&(null==a?void 0:a.chainId)&&((null==(t=null==e?void 0:e.contractCall)?void 0:t.contractAddress)||(null==e?void 0:e.contractAddress))?w("success","โ
Payment data complete",{paymentId:e.id,tokenContract:s.contractAddress,chainId:a.chainId,paymentContract:(null==(r=null==e?void 0:e.contractCall)?void 0:r.contractAddress)||(null==e?void 0:e.contractAddress)}):(w("debug","โณ Waiting for complete payment data",{hasPaymentId:!!(null==e?void 0:e.id),hasTokenContract:!!(null==s?void 0:s.contractAddress),hasChainId:!!(null==a?void 0:a.chainId),hasPaymentContract:!(!(null==(n=null==e?void 0:e.contractCall)?void 0:n.contractAddress)&&!(null==e?void 0:e.contractAddress)),checkCount:b}),x(e=>e+1))},[e,s,a,b]);const w=(e,t,n=null)=>{const s=(new Date).toLocaleTimeString(),a={id:Date.now()+Math.random(),type:e,message:t,data:n,timestamp:s};In&&(y(e=>[...e,a].slice(-20)),e.toUpperCase())},v=[{id:"metamask",name:"MetaMask",icon:"๐ฆ",description:"Connect with MetaMask mobile"},{id:"trust",name:"Trust Wallet",icon:"๐ก๏ธ",description:"Connect with Trust Wallet"},{id:"coinbase",name:"Coinbase Wallet",icon:"๐",description:"Connect with Coinbase Wallet"}];if(!e)return t.jsx("div",{className:"p-4 bg-amber-50 rounded-lg border border-amber-200",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-amber-800 font-medium mb-2",children:"โ ๏ธ Payment Required"}),t.jsx("div",{className:"text-sm text-amber-700",children:"Please create a payment before selecting a wallet"})]})});const k=(null==e?void 0:e.id)&&(null==s?void 0:s.contractAddress)&&(null==a?void 0:a.chainId)&&((null==(c=null==e?void 0:e.contractCall)?void 0:c.contractAddress)||(null==e?void 0:e.contractAddress));return t.jsx("div",{className:"space-y-4",children:k?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Select Mobile Wallet"}),t.jsx(mn,{options:v,value:d||"",onChange:async t=>{const n=v.find(e=>e.id===t);if(n){m(t),h(!0);try{if(w("info",`๐ Mobile wallet selected: ${n.name}`),!e)throw new Error("Payment data not available. Please create payment first.");w("debug","๐ Payment Data Check",{hasPaymentData:!!e,hasSelectedToken:!!s,hasSelectedNetwork:!!a,hasConfig:!!r,paymentId:(null==e?void 0:e.id)||(null==e?void 0:e.splitterPaymentId),tokenAddress:null==s?void 0:s.contractAddress,networkChainId:null==a?void 0:a.chainId,amount:(null==e?void 0:e.totalAmount)||(null==e?void 0:e.amount)||(null==r?void 0:r.amount)});const o=kn(e,0,a,0,t);if(!o)throw new Error("Failed to generate payment URL");w("success","๐ฑ Generated payment URL",{url:o,length:o.length});const c=Nn(t,o);if(!c)throw new Error(`Failed to generate ${n.name} deep link`);w("success",`๐ Deep link generated for ${n.name}`,{deepLink:c}),i({walletType:t,walletName:n.name,paymentUrl:o,deepLink:c}),setTimeout(()=>{w("info",`๐ฑ Opening ${n.name}...`),window.location.href=c},500)}catch(c){w("error","โ Mobile wallet connection failed",{error:c.message,walletId:t,hasPaymentData:!!e,hasSelectedToken:!!s,hasSelectedNetwork:!!a}),o(c.message),h(!1),m(null)}}},placeholder:"Choose your wallet...",renderOption:e=>t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("div",{className:"w-8 h-8 flex items-center justify-center",children:t.jsx("div",{className:"text-2xl",children:e.icon})}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"font-semibold text-gray-800",children:[e.name,d===e.id&&u&&t.jsx("span",{className:"ml-2 px-2 py-1 bg-blue-100 text-blue-700 text-xs rounded-full animate-pulse",children:"Opening..."})]}),t.jsx("div",{className:"text-sm text-gray-500",children:e.description})]})]}),getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.description}`,disabled:u}),t.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"Select a wallet to open it with your payment details"})]}),u&&d&&t.jsx("div",{className:"p-3 bg-blue-50 border border-blue-200 rounded-lg animate-pulse",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-blue-600 border-t-transparent"}),t.jsxs("div",{className:"text-sm text-blue-700",children:["Opening ",null==(l=v.find(e=>e.id===d))?void 0:l.name,"..."]})]})}),t.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[t.jsxs("div",{className:"flex justify-between items-center text-sm",children:[t.jsx("span",{className:"text-gray-600",children:"Amount:"}),t.jsxs("span",{className:"font-semibold text-gray-800",children:[e.totalAmount," ",(null==s?void 0:s.symbol)||"USDC"]})]}),t.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[t.jsx("span",{className:"text-gray-600",children:"Network:"}),t.jsx("span",{className:"text-gray-800",children:(null==a?void 0:a.name)||"Ethereum"})]})]}),t.jsx("div",{className:"p-3 bg-purple-50 border border-purple-200 rounded-lg",children:t.jsxs("div",{className:"text-xs text-purple-700",children:[t.jsx("div",{className:"font-medium mb-1",children:"๐ฑ Mobile Payment"}),t.jsx("div",{children:"Your selected wallet app will open with payment details pre-filled"})]})}),In&&t.jsxs("div",{className:"mt-4",children:[t.jsxs("button",{onClick:()=>f(!g),className:"w-full text-xs py-2 px-3 bg-gray-100 text-gray-600 rounded-lg hover:bg-gray-200 transition-colors",children:[g?"๐ฝ Hide Debug Info":"๐ง Show Debug Info"," (",p.length," logs)"]}),g&&t.jsxs("div",{className:"mt-2 p-3 bg-gray-900 text-green-400 rounded-lg text-xs font-mono max-h-80 overflow-y-auto",children:[t.jsx("div",{className:"text-white mb-2 font-bold",children:"๐ฑ Mobile Debug Panel"}),0===p.length?t.jsx("div",{className:"text-gray-400",children:"No debug logs yet. Try selecting a wallet..."}):p.map(e=>t.jsxs("div",{className:"mb-3 pb-2 border-b border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"px-2 py-1 rounded text-xs font-bold "+("error"===e.type?"bg-red-600 text-white":"success"===e.type?"bg-green-600 text-white":"debug"===e.type?"bg-blue-600 text-white":"bg-gray-600 text-white"),children:e.type.toUpperCase()}),t.jsx("span",{className:"text-gray-400",children:e.timestamp})]}),t.jsx("div",{className:"text-yellow-300 mb-1",children:e.message}),e.data&&t.jsx("div",{className:"text-gray-300 text-xs",children:t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-blue-300 hover:text-blue-200",children:"๐ Data"}),t.jsx("pre",{className:"mt-1 p-2 bg-gray-800 rounded overflow-x-auto whitespace-pre-wrap",children:JSON.stringify(e.data,null,2)})]})})]},e.id)),t.jsx("button",{onClick:()=>y([]),className:"mt-2 px-3 py-1 bg-red-600 text-white rounded text-xs hover:bg-red-700",children:"Clear Logs"})]})]})]}):t.jsx("div",{className:"p-4 bg-amber-50 rounded-lg border border-amber-200",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-amber-800 font-medium mb-2",children:"โณ Preparing Payment..."}),t.jsx("div",{className:"text-sm text-amber-700",children:"Payment is being prepared. Please wait a moment..."}),t.jsx("div",{className:"mt-3",children:t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-amber-600 border-t-transparent mx-auto"})})]})})})},An=({error:e,onRetry:n,onDismiss:s,context:a="payment",className:r=""})=>{if(!e)return null;const i=rn(e),o=(e=>{switch(e){case"user_rejected":return"info";case"insufficient_funds":case"wrong_network":case"wallet_disconnected":case"payment_pending":return"warning";case"network_error":case"gas_error":case"rate_limited":return"error";default:return"critical"}})(i.type),c=(e=>{switch(e){case"user_rejected":default:return"Try Again";case"insufficient_funds":return"Add Funds & Retry";case"wrong_network":return"Switch Network & Retry";case"wallet_disconnected":return"Reconnect Wallet";case"payment_pending":return"Check Again";case"network_error":case"rate_limited":return"Retry";case"popup_blocked":return"Allow Popups & Retry";case"mobile_wallet_error":return"Open Wallet App"}})(i.type),l={info:{container:"bg-blue-50 border-blue-200",title:"text-blue-800",message:"text-blue-700",icon:"โน๏ธ",button:"bg-blue-600 hover:bg-blue-700"},warning:{container:"bg-amber-50 border-amber-200",title:"text-amber-800",message:"text-amber-700",icon:"โ ๏ธ",button:"bg-amber-600 hover:bg-amber-700"},error:{container:"bg-red-50 border-red-200",title:"text-red-800",message:"text-red-700",icon:"โ",button:"bg-red-600 hover:bg-red-700"},critical:{container:"bg-red-50 border-red-300",title:"text-red-900",message:"text-red-800",icon:"๐จ",button:"bg-red-700 hover:bg-red-800"}},d=l[o]||l.error;return t.jsxs("div",{className:`p-4 border rounded-lg ${d.container} ${r}`,children:[t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("div",{className:"flex-shrink-0 text-xl",children:d.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:`font-semibold ${d.title} mb-1`,children:i.title}),t.jsx("div",{className:`text-sm ${d.message} mb-2`,children:i.message}),i.suggestion&&t.jsxs("div",{className:`text-xs ${d.message} opacity-90`,children:["๐ก ",i.suggestion]})]}),s&&t.jsx("button",{onClick:s,className:"flex-shrink-0 text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Dismiss error",children:t.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),n&&t.jsxs("div",{className:"mt-3 flex justify-end space-x-2",children:[s&&"info"===o&&t.jsx("button",{onClick:s,className:"px-3 py-1.5 text-xs text-gray-600 hover:text-gray-800 transition-colors",children:"Cancel"}),t.jsx("button",{onClick:n,className:`px-4 py-2 text-sm font-medium text-white rounded-md transition-colors ${d.button}`,children:c})]}),!1]})},En="method",Fn="confirm",Un="processing",Dn="success",Tn="wallet",Bn="qr",Ln="Bricolage Grotesque, sans-serif",Mn=new a.QueryClient,Rn=({publicKey:e,apiKey:a,apiSecret:i,apiUrl:o,config:c,onSuccess:l,onError:d,onClose:m,isOpen:u,theme:p="light"})=>{const y=((e,t,s)=>{const[a,r]=n.useState("method"),[i,o]=n.useState([]),[c,l]=n.useState([]),[d,m]=n.useState(null),[u,h]=n.useState(null),[p,y]=n.useState(null),[g,b]=n.useState(null),[x,w]=n.useState(!1),[v,k]=n.useState(""),[N,C]=n.useState(!1),[P,j]=n.useState("Processing transaction..."),[I,S]=n.useState("wallet"),[A,E]=n.useState(null),F=n.useRef(new f(e,t,s));return{currentStep:a,networks:i,tokens:c,selectedNetwork:d,selectedToken:u,paymentMethod:p,paymentData:g,loading:x,error:v,processing:N,processingMessage:P,paymentType:I,actualTransactionHash:A,setCurrentStep:r,setSelectedNetwork:m,setSelectedToken:h,setPaymentMethod:y,setError:k,setProcessing:C,setProcessingMessage:j,setPaymentType:S,setActualTransactionHash:E,loadData:async()=>{var e,t;try{w(!0),k("");const[n,s]=await Promise.all([F.current.getNetworks(),F.current.getTokens()]),a=(null==(e=n.networks)?void 0:e.reduce((e,t)=>{if("solana"===t.shortName||"tron"===t.shortName||"algorand"===t.shortName)return e;if(!t.chainId||null===t.chainId)return e;const n=`${t.chainId}-${t.shortName}`;return e.some(e=>`${e.chainId}-${e.shortName}`===n)||e.push(t),e},[]))||[],r=(null==(t=s.stablecoins)?void 0:t.reduce((e,t)=>{var n,s,a;if("USDC"!==t.symbol&&"USDT"!==t.symbol)return e;if("solana"===(null==(n=t.Network)?void 0:n.shortName)||"tron"===(null==(s=t.Network)?void 0:s.shortName)||"algorand"===(null==(a=t.Network)?void 0:a.shortName))return e;const r=`${t.symbol}-${t.networkId}`;return e.some(e=>`${e.symbol}-${e.networkId}`===r)||e.push(t),e},[]))||[];o(a),l(r)}catch(n){k("Failed to load payment options. Using fallback data.")}finally{w(!1)}},createPayment:async e=>{try{w(!0),k("");const t={amount:e.amount,currency:u.symbol,network:d.shortName,customerEmail:e.customerEmail,callbackUrl:e.callbackUrl,metadata:{...e.metadata,merchantWalletAddresses:e.merchantWalletAddresses,paymentMethod:p,selectedNetwork:d.shortName,selectedToken:u.symbol,wagmiEnabled:!0}},n=await F.current.createPayment(t);b(n.payment),r("confirm")}catch(t){k(t.message)}finally{w(!1)}},failPayment:async(e="Payment cancelled by user")=>{if(null==g?void 0:g.id)try{await F.current.failPayment(g.id,e)}catch(t){}},resetState:()=>{r("method"),m(null),h(null),y(null),b(null),k(""),C(!1),E(null),S("wallet")},resetTransactionState:()=>{k(""),C(!1),E(null),r("confirm")},api:F.current}})(o,e||a,e?null:i),b=(()=>{const[e,t]=n.useState(null),[a,i]=n.useState(null),[o,c]=n.useState(""),{connect:l,connectors:d}=s.useConnect(),{isConnected:m,address:u,chain:h}=s.useAccount(),{switchChain:p}=s.useSwitchChain();return n.useEffect(()=>{i(m&&u?{account:u,chainId:null==h?void 0:h.id,walletType:e}:null)},[m,u,h,e]),{selectedWalletType:e,connectedWallet:a,connectionError:o,isConnected:m,address:u,chain:h,connectors:d,handleWalletSelection:e=>{t(e),c("")},connectWallet:async(e,t=null)=>{var n,s,a;if(!e)return c("Please select a wallet first"),!1;try{if(c(""),await l({connector:e}),t){const o=w(t.shortName),l=(null==(n=e.name)?void 0:n.toLowerCase())||"",d=l.includes("zerion")||l.includes("trust")||l.includes("rabby")?5e3:500;await new Promise(e=>setTimeout(e,d));const m=r.getAccount(g).chainId;if(o&&m!==o)try{await p({chainId:o}),await new Promise(e=>setTimeout(e,1e3))}catch(i){return 4001===i.code||(null==(s=i.message)?void 0:s.includes("User rejected"))?c("Network switch was cancelled by user"):(null==(a=i.message)?void 0:a.includes("Unrecognized chain ID"))?c(`${t.name} network is not added to your wallet. Please add it manually.`):c(`Failed to switch to ${t.name}. Please switch manually in your wallet.`),!1}}return!0}catch(o){return 4001===o.code||o.message.includes("User rejected")||o.message.includes("rejected")?c("User cancelled the connection request"):c(`Failed to connect to ${e.name}. Please try again.`),!1}},disconnectWallet:()=>{i(null),t(null),c("")},switchChain:p,ensureCorrectNetwork:async e=>{var t,n;if(!e)return!0;try{const a=w(e.shortName),i=r.getAccount(g).chainId;if(a&&i!==a)try{return await p({chainId:a}),await new Promise(e=>setTimeout(e,1e3)),!0}catch(s){return 4001===s.code||(null==(t=s.message)?void 0:t.includes("User rejected"))?c("Network switch was cancelled. Please switch to the correct network in your wallet."):(null==(n=s.message)?void 0:n.includes("Unrecognized chain ID"))?c(`${e.name} network is not added to your wallet. Please add it manually.`):c(`Failed to switch to ${e.name}. Please switch manually in your wallet.`),!1}return!0}catch(B){return c("Failed to verify network. Please check your wallet connection."),!1}},clearError:()=>{c("")},setSelectedWalletType:t,connect:l}})(),[x,v]=n.useState("metamask"),[k,N]=n.useState(!1),[C,P]=n.useState(()=>!("undefined"==typeof window||!window.sessionStorage)&&"true"===sessionStorage.getItem("coinley_mobile_payment_started")),[j,I]=n.useState(!1);n.useEffect(()=>{N(xn())},[]);const{currentStep:S,networks:A,tokens:E,selectedNetwork:F,selectedToken:U,paymentData:D,loading:T,error:B,paymentType:L,loadData:M,createPayment:R,failPayment:$,resetState:G,setSelectedNetwork:O,setSelectedToken:z,setPaymentType:W,setCurrentStep:H,setError:q}=y,{connectedWallet:V,address:Q,connectWallet:K,handleWalletSelection:Z}=b,Y=dn(D,U,F,Q,y.api,b),{executePaymentTransaction:_,processFinalPayment:J,transactionStep:X,transactionError:ee,currentTransactionHash:te}=Y;n.useEffect(()=>{S===Dn&&"undefined"!=typeof window&&window.sessionStorage&&sessionStorage.removeItem("coinley_mobile_payment_started")},[S]),n.useEffect(()=>{if(u){M(),G();const e=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${e}px`,document.body.style.width="100%",document.body.style.overflow="hidden"}else{const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,-1*parseInt(e||"0"))}return()=>{if(u){const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,-1*parseInt(e||"0"))}}},[u]),n.useEffect(()=>{if("processing"===X||"approve"===X||"splitPayment"===X){const e=setTimeout(()=>{q("Transaction timed out. Please try again."),H(Fn),Y.resetTransaction()},12e4);return()=>clearTimeout(e)}},[X]);const ne=async()=>{await $(),m()};return u?t.jsxs("div",{className:"fixed inset-0 z-50",children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:ne,"aria-hidden":"true"}),t.jsx("div",{className:"fixed inset-0 flex items-center justify-center p-4",style:{zIndex:51},children:t.jsxs("div",{className:"relative pt-4 w-full max-w-md max-h-[90vh] mx-auto shadow-xl bg-gray-100 rounded-3xl flex flex-col overflow-hidden",style:{zIndex:52},children:[t.jsxs("div",{className:"flex-shrink-0 bg-white flex justify-between items-center mb-3 mr-3 ml-3 py-3 px-2 rounded-full",children:[t.jsxs("div",{className:"flex-1 flex items-center gap-2 px-4",children:[t.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center",children:t.jsx("img",{src:h,alt:"Coinley"})}),t.jsx("span",{className:"text-base font-semibold text-gray-800",style:{fontFamily:Ln},children:"Payment Details"})]}),S!==Dn&&S!==Un&&t.jsx("button",{onClick:ne,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),c&&S!==Dn&&t.jsx("div",{className:"flex-shrink-0 mb-3 px-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs text-gray-600",children:"Total Amount"}),t.jsxs("div",{className:"text-3xl font-bold text-[#7042D2] mt-1 leading-tight tracking-tight",style:{fontFamily:Ln},children:["$",(se=c.amount,parseFloat(se).toFixed(2))]}),t.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"No additional fees"}),t.jsx("div",{className:"text-xs text-gray-600 mt-2",children:"Payment to:"}),t.jsxs("div",{className:"text-sm font-semibold mt-0.5 flex gap-1.5 items-center justify-center",style:{fontFamily:Ln},children:[t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M15.3 7.50065L15.8 10.0007H4.2L4.7 7.50065H15.3ZM16.6667 3.33398H3.33333V5.00065H16.6667V3.33398ZM16.6667 5.83398H3.33333L2.5 10.0007V11.6673H3.33333V16.6673H11.6667V11.6673H15V16.6673H16.6667V11.6673H17.5V10.0007L16.6667 5.83398ZM5 15.0007V11.6673H10V15.0007H5Z",fill:"#7042D2"})}),c.merchantName||"Merchant"]})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-contain",children:[t.jsx(un,{currentStep:S,targetStep:En,children:t.jsxs("div",{className:"pb-4 pt-3 px-5 bg-white rounded-t-2xl",children:[t.jsx("h3",{className:"font-semibold text-center mb-3 text-sm",style:{fontFamily:Ln},children:"Choose Payment Method"}),t.jsxs("div",{className:"space-y-3 mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:Ln},children:"Select Network"}),t.jsx(mn,{options:A,value:(null==F?void 0:F.id)||"",onChange:e=>{const t=A.find(t=>t.id===e);O(t),z(null)},placeholder:"Choose your network...",renderOption:e=>{var n,s;const a="object"==typeof(r=e)&&(null==r?void 0:r.logo)?r.logo:"object"==typeof r&&(null==r?void 0:r.shortName)?yn[r.shortName.toLowerCase()]:"string"==typeof r?yn[r.toLowerCase()]:null;var r;return t.jsxs("div",{className:"flex items-center space-x-3",children:[a?t.jsx("img",{src:a,alt:e.name,className:"w-8 h-8 rounded-full",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="flex"}}):null,t.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center",style:{display:a?"none":"flex"},children:t.jsx("span",{className:"text-xs font-bold text-gray-600",children:null==(n=e.shortName)?void 0:n.slice(0,2).toUpperCase()})}),t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold text-gray-800",children:e.name}),t.jsx("div",{className:"text-sm text-gray-500",children:null==(s=e.shortName)?void 0:s.toUpperCase()})]})]})},getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.shortName}`,disabled:T})]}),F&&t.jsxs("div",{className:"space-y-3 mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:Ln},children:"Select Token"}),t.jsx(mn,{options:E.filter(e=>{var t;return(null==(t=e.Network)?void 0:t.shortName)===(null==F?void 0:F.shortName)||e.networkId===(null==F?void 0:F.id)}),value:(null==U?void 0:U.id)||"",onChange:e=>{const t=E.filter(e=>{var t;return(null==(t=e.Network)?void 0:t.shortName)===(null==F?void 0:F.shortName)||e.networkId===(null==F?void 0:F.id)}).find(t=>t.id===e);z(t)},placeholder:"Choose your token...",renderOption:e=>{var n,s;const a=fn(e.symbol);return t.jsxs("div",{className:"flex items-center space-x-3",children:[a?t.jsx("img",{src:a,alt:e.symbol,className:"w-8 h-8 rounded-full",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="flex"}}):null,t.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center",style:{display:a?"none":"flex"},children:t.jsx("span",{className:"text-xs font-bold text-gray-600",children:null==(n=e.symbol)?void 0:n.slice(0,2)})}),t.jsxs("div",{children:[t.jsxs("div",{className:"font-semibold text-gray-800",children:[e.name," (",e.symbol,")"]}),t.jsxs("div",{className:"text-sm text-gray-500",children:[(null==(s=e.Network)?void 0:s.name)||"Unknown Network",e.isStablecoin&&t.jsx("span",{className:"ml-2 text-green-600",children:"โข Stablecoin"})]})]})]})},getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.symbol}`,disabled:T})]}),F&&U&&t.jsx("button",{onClick:()=>R(c),disabled:T,className:"w-full bg-[#7042D2] text-white py-4 px-4 rounded-xl hover:bg-[#5b34b1] disabled:opacity-50 font-semibold transition-all duration-200 shadow-lg hover:shadow-xl",style:{fontFamily:Ln},children:T?"Creating Payment...":"Continue"})]})}),t.jsx(un,{currentStep:S,targetStep:Fn,children:F&&U&&D&&t.jsxs("div",{className:"pb-4 pt-4 px-4 bg-white rounded-t-2xl",children:[!k&&t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"flex border-b border-gray-200",children:[t.jsx("button",{onClick:()=>W(Tn),className:"py-3 px-6 text-sm font-semibold transition-all duration-200 "+(L===Tn?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),style:{fontFamily:Ln},children:"Connect Wallet"}),t.jsx("button",{onClick:()=>W(Bn),className:"py-3 px-6 text-sm font-semibold transition-all duration-200 "+(L===Bn?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),style:{fontFamily:Ln},children:"QR Code"})]})}),k?t.jsx(Sn,{paymentData:D,selectedToken:U,selectedNetwork:F,config:c,onPaymentStarted:e=>{P(!0),"undefined"!=typeof window&&window.sessionStorage&&sessionStorage.setItem("coinley_mobile_payment_started","true"),e.walletName},onError:e=>{q(e)}}):L===Tn?t.jsx(jn,{selectedNetwork:F,onWalletSelect:Z,onConnect:async e=>{await K(e,F)},connectedWallet:V,loading:T}):null,L===Bn&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"text-xs font-medium text-gray-600 mb-1.5 text-center",style:{fontFamily:Ln},children:"Optimize QR for:"}),t.jsx("div",{className:"flex gap-1.5 justify-center flex-wrap",children:[{id:"metamask",name:"MetaMask",icon:"๐ฆ"},{id:"trust",name:"Trust",icon:"๐ก๏ธ"},{id:"coinbase",name:"Coinbase",icon:"๐"}].map(e=>t.jsxs("button",{onClick:()=>v(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all duration-200 "+(x===e.id?"bg-[#7042D2] text-white shadow-md":"bg-gray-100 text-gray-700 hover:bg-gray-200"),style:{fontFamily:Ln},children:[t.jsx("span",{className:"text-sm",children:e.icon}),t.jsx("span",{children:e.name})]},e.id))})]}),t.jsx(Pn,{amount:(null==D?void 0:D.totalAmount)||(null==D?void 0:D.amount)||(null==c?void 0:c.amount),currency:null==U?void 0:U.symbol,network:null==F?void 0:F.shortName,theme:p,paymentData:D,config:c,selectedToken:U,selectedNetwork:F,preferredWallet:x,compact:!0})]}),(B||ee)&&t.jsx("div",{className:"mt-4",children:t.jsx(An,{error:ee||B,onRetry:()=>{q(""),Y.resetTransaction(),"error"===X&&V&&_()},onDismiss:()=>{q(""),Y.resetTransaction()},context:"payment"})}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-4",children:[t.jsx("button",{type:"button",onClick:()=>H(En),className:"w-full py-2.5 px-3 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-semibold rounded-xl transition-all duration-200 text-sm",style:{fontFamily:Ln},children:"Back"}),t.jsx("button",{type:"button",onClick:async()=>{var e,t,n,s,a,r,i,o,c,d;if(k&&C){if(!(null==D?void 0:D.id))return void q("Payment ID not found. Please refresh and try again.");try{I(!0),H(Un),q("");const a=await y.api.checkPaymentStatus(D.id);if("completed"===(null==(e=a.payment)?void 0:e.status))H(Dn),l&&l({paymentId:D.id,transactionHash:a.payment.transactionHash,paymentDetails:a.payment});else if("pending"===(null==(t=a.payment)?void 0:t.status)){const e=await y.api.verifyQRPayment(D.id);if(e.success&&e.verified)H(Dn),l&&l({paymentId:D.id,transactionHash:null==(n=e.onChainData)?void 0:n.transactionHash,paymentDetails:e.payment});else{const t=e.message||"Payment not yet confirmed on blockchain";q(`${t}. Please complete the payment in your wallet and try again.`),H(Fn)}}else"failed"===(null==(s=a.payment)?void 0:s.status)?(q("Payment failed. Please try creating a new payment."),H(Fn)):(q("Payment not found. Please verify the payment ID and try again."),H(Fn))}catch(m){q(`Verification failed: ${m.message}. Please ensure payment was completed and try again.`),H(Fn)}finally{I(!1)}}else if(L!==Bn){if(V&&Q)try{H(Un),q("");const e=await _();e&&(q(""),Y.setTransactionError(""),H(Dn),l&&l({paymentId:D.id,transactionHash:e,paymentDetails:D}))}catch(m){H(Fn),(null==(c=m.message)?void 0:c.includes("User rejected"))||(null==(d=m.message)?void 0:d.includes("User denied"))||4001===m.code||"ACTION_REJECTED"===m.code?q("Transaction was cancelled by user. Please try again."):q(m.message||"Transaction failed. Please try again."),Y.resetTransaction()}}else{if(!(null==D?void 0:D.id))return void q("Payment ID not found. Please refresh and try again.");try{H(Un),q("");const e=await y.api.checkPaymentStatus(D.id);if("completed"===(null==(a=e.payment)?void 0:a.status))H(Dn),l&&l({paymentId:D.id,transactionHash:e.payment.transactionHash,paymentDetails:e.payment});else if("pending"===(null==(r=e.payment)?void 0:r.status)){const e=await y.api.verifyQRPayment(D.id);if(e.success&&e.verified)H(Dn),l&&l({paymentId:D.id,transactionHash:null==(i=e.onChainData)?void 0:i.transactionHash,paymentDetails:e.payment});else{const t=e.message||"Payment not yet confirmed on blockchain";q(`${t}. Please complete the payment and try again.`),H(Fn)}}else"failed"===(null==(o=e.payment)?void 0:o.status)?(q("Payment failed. Please try creating a new payment."),H(Fn)):(q("Payment not found. Please verify the payment ID and try again."),H(Fn))}catch(m){q(`Verification failed: ${m.message}. Please ensure payment was completed and try again.`),H(Fn)}}},className:"bg-green-600 text-white w-full py-2.5 px-3 font-semibold rounded-xl hover:bg-green-700 transition-all duration-200 shadow-lg hover:shadow-xl disabled:opacity-50 text-sm",disabled:L===Tn&&!V&&!k||k&&!C||"processing"===X||j,style:{fontFamily:Ln},children:j?"Verifying...":"processing"===X?"Processing...":k&&C?"I Have Paid":k?"Select Wallet":L===Bn?"I Have Paid":"Pay Now"})]})]})}),t.jsx(un,{currentStep:S,targetStep:Un,children:t.jsx(hn,{status:"processing",message:"approve"===X?"Approving token spending...":"splitPayment"===X?"Processing payment split...":te?"Confirming transaction on blockchain...":"Processing your payment...",theme:p,transactionHash:te,selectedNetwork:F})}),t.jsx(un,{currentStep:S,targetStep:Dn,children:t.jsx(hn,{status:"success",message:"Payment completed successfully!",theme:p,payment:D,transactionHash:te||(null==D?void 0:D.transactionHash),selectedPaymentMethod:U,selectedNetwork:F,merchantName:(null==c?void 0:c.merchantName)||"Merchant",onClose:m})}),(B||ee)&&t.jsxs("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg mx-6 mb-4",children:[t.jsx("p",{className:"text-red-800 text-sm",children:B||ee}),t.jsx("button",{onClick:()=>{q(""),Y.setTransactionError("")},className:"mt-2 text-red-600 hover:text-red-800 text-xs underline",children:"Dismiss"})]})]}),S!==Dn&&t.jsxs("div",{className:"text-center text-xs text-gray-500 flex items-center justify-center gap-1 py-6 bg-white rounded-b-3xl",style:{fontFamily:Ln},children:[t.jsxs("p",{children:["Powered by ",t.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Coinley"})," - Multi-Wallet Support"]}),t.jsxs("svg",{className:"inline w-4 h-4 text-green-500 ml-1",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}),t.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})})]}):null;var se},$n=e=>t.jsx(s.WagmiProvider,{config:g,children:t.jsx(a.QueryClientProvider,{client:Mn,children:t.jsx(Rn,{...e})})}),Gn=n.createContext(null),On=n.forwardRef(({customerEmail:e="",merchantName:t="",onSuccess:s,onError:a,onClose:r,theme:i="light",autoOpen:o=!1,testMode:c=!1,debug:l=!1,merchantWalletAddresses:d={}},m)=>{const u=n.useContext(Gn);if(!u)throw new Error("CoinleyCheckout must be used within a CoinleyProvider");const{openPayment:h,closePayment:p}=u,y=t=>{try{if(!t.amount||t.amount<=0)throw new Error("Amount must be greater than 0");const n={...t,customerEmail:t.customerEmail||e,merchantWalletAddresses:{...d,...t.merchantWalletAddresses},metadata:{...t.metadata,testMode:c,checkoutVersion:"1.0.0"}};h(n,{onSuccess:s,onError:a,onClose:r})}catch(n){a&&a(n)}},g=()=>{p()};return n.useImperativeHandle(m,()=>({open:y,close:g})),null});On.displayName="CoinleyCheckout";const zn={ethereum:_t,bsc:Ot,polygon:en,arbitrum:Mt,optimism:Xt,avalanche:Rt},Wn=[{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],type:"function"}];const Hn=new class{constructor(){this.clients=new Map}getClient(e){if(!this.clients.has(e)){const t=zn[e];if(!t)throw new Error(`Unsupported network: ${e}`);const n=c.createPublicClient({chain:t,transport:c.http()});this.clients.set(e,n)}return this.clients.get(e)}async checkNativeBalance(e,t){try{const n=this.getClient(t),s=await n.getBalance({address:e}),a=c.formatUnits(s,18);return{balance:parseFloat(a),balanceWei:s.toString(),symbol:this.getNativeTokenSymbol(t),decimals:18}}catch(n){throw new Error(`Failed to check native balance: ${n.message}`)}}async checkTokenBalance(e,t,n){try{const s=this.getClient(n),a=c.getContract({address:t,abi:Wn,client:s}),[r,i,o]=await Promise.all([a.read.balanceOf([e]),a.read.decimals().catch(()=>18),a.read.symbol().catch(()=>"TOKEN")]);return{balance:parseFloat(c.formatUnits(r,i)),balanceWei:r.toString(),symbol:o,decimals:i,tokenAddress:t}}catch(s){throw new Error(`Failed to check token balance: ${s.message}`)}}async validateBalance(e,t,n,s,a=!0){try{let r,i=null;r=t.contractAddress?await this.checkTokenBalance(e,t.contractAddress,s):await this.checkNativeBalance(e,s),t.contractAddress&&a&&(i=await this.checkNativeBalance(e,s));const o=r.balance>=n,c=o?0:n-r.balance;let l=0,d=!0,m=0;if(a)if(l=this.estimateGasFee(s,!!t.contractAddress),t.contractAddress)d=i.balance>=l,m=d?0:l-i.balance;else{const e=n+l;d=r.balance>=e,m=d?0:e-r.balance}const u={isValid:o&&d,tokenBalance:r,nativeBalance:i,requiredAmount:n,estimatedGasFee:l,hasEnoughTokens:o,hasEnoughForGas:d,tokenShortfall:c,gasShortfall:m,errors:[]};if(o||u.errors.push(`Insufficient ${t.symbol} balance. Need ${n} ${t.symbol}, have ${r.balance.toFixed(6)} ${t.symbol}`),!d){const e=(null==i?void 0:i.symbol)||this.getNativeTokenSymbol(s);t.contractAddress?u.errors.push(`Insufficient ${e} for gas fees. Need ~${l.toFixed(6)} ${e}, have ${i.balance.toFixed(6)} ${e}`):u.errors.push(`Insufficient ${e} for payment + gas. Need ${(n+l).toFixed(6)} ${e} total, have ${r.balance.toFixed(6)} ${e}`)}return u}catch(r){return{isValid:!1,errors:[`Failed to check balance: ${r.message}`],tokenBalance:null,nativeBalance:null}}}estimateGasFee(e,t=!1){return{ethereum:t?.001:5e-4,bsc:t?5e-4:3e-4,polygon:t?.01:.005,arbitrum:t?3e-4:2e-4,optimism:t?3e-4:2e-4,avalanche:t?.001:5e-4}[e]||.001}getNativeTokenSymbol(e){return{ethereum:"ETH",bsc:"BNB",polygon:"MATIC",arbitrum:"ETH",optimism:"ETH",avalanche:"AVAX"}[e]||"ETH"}async getBalance(e,t,n){return t.contractAddress?await this.checkTokenBalance(e,t.contractAddress,n):await this.checkNativeBalance(e,n)}formatBalance(e,t,n=6){return null==e?"Unknown":0===e?`0 ${t}`:e<.001?`${e.toFixed(8)} ${t}`:e<1?`${e.toFixed(6)} ${t}`:`${e.toFixed(4)} ${t}`}async checkMultipleBalances(e,t,n){try{const s=t.map(t=>this.getBalance(e,t,n).catch(e=>({error:e.message,symbol:t.symbol,balance:0})));return await Promise.all(s)}catch(s){throw s}}};class qn{constructor(e,t,n){this.baseURL=e.endsWith("/")?e.slice(0,-1):e,this.apiKey=t,this.apiSecret=n}async request(e,t={}){const n=`${this.baseURL}${e}`,s={"Content-Type":"application/json","X-API-Key":this.apiKey,"X-API-Secret":this.apiSecret,...t.headers},a=await fetch(n,{...t,headers:s});if(!a.ok){const e=await a.json().catch(()=>({}));throw new Error(e.error||`HTTP ${a.status}`)}return a.json()}async getNetworks(){try{return await this.request("/api/networks")}catch(e){return{networks:[{id:"1",name:"Ethereum",shortName:"ethereum",chainId:"0x1",type:"ethereum"},{id:"56",name:"BSC",shortName:"bsc",chainId:"0x38",type:"bsc"},{id:"137",name:"Polygon",shortName:"polygon",chainId:"0x89",type:"polygon"},{id:"42161",name:"Arbitrum",shortName:"arbitrum",chainId:"0xa4b1",type:"arbitrum"},{id:"10",name:"Optimism",shortName:"optimism",chainId:"0xa",type:"optimism"},{id:"43114",name:"Avalanche",shortName:"avalanche",chainId:"0xa86a",type:"avalanche"},{id:"42220",name:"Celo",shortName:"celo",chainId:"0xa4ec",type:"celo"},{id:"8453",name:"Base",shortName:"base",chainId:"0x2105",type:"base"}]}}}async getTokens(){try{return await this.request("/api/networks/stablecoins")}catch(e){return{stablecoins:[{id:"1",name:"Tether USD",symbol:"USDT",contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"2",name:"USD Coin",symbol:"USDC",contractAddress:"0xA0b86a33E641a3FA62e50A9da1CE0647a2bFBC5A",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"3",name:"Binance USD",symbol:"BUSD",contractAddress:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"4",name:"USD Coin",symbol:"USDC",contractAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"5",name:"USD Coin",symbol:"USDC",contractAddress:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"6",name:"Tether USD",symbol:"USDT",contractAddress:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"7",name:"Tether USD",symbol:"USDT",contractAddress:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"8",name:"USD Coin",symbol:"USDC",contractAddress:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"9",name:"Tether USD",symbol:"USDT",contractAddress:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"10",name:"USD Coin",symbol:"USDC",contractAddress:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"11",name:"Tether USD",symbol:"USDT",contractAddress:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"12",name:"USD Coin",symbol:"USDC",contractAddress:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"13",name:"Tether USD",symbol:"USDT",contractAddress:"0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"14",name:"USD Coin",symbol:"USDC",contractAddress:"0xcebA9300f2b948710d2653dD7B07f33A8B32118C",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"15",name:"Tether USD",symbol:"USDT",contractAddress:"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}},{id:"16",name:"USD Coin",symbol:"USDC",contractAddress:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}}]}}}async createPayment(e){return await this.request("/api/payments/create",{method:"POST",body:JSON.stringify(e)})}async updatePaymentStatus(e,t,n=null){return await this.request(`/api/payments/${e}/status`,{method:"PUT",body:JSON.stringify({status:t,transactionHash:n})})}}class Vn{constructor(e={}){if(!e.publicKey&&!e.apiKey)throw new Error("CoinleyVanilla: publicKey or apiKey is required");if(!e.publicKey&&!e.apiSecret)throw new Error("CoinleyVanilla: apiSecret is required when using apiKey");if(!e.apiUrl)throw new Error("CoinleyVanilla: apiUrl is required");this.config={publicKey:e.publicKey||null,apiKey:e.apiKey||null,apiSecret:e.apiSecret||null,apiUrl:e.apiUrl.replace(/\/$/,""),theme:e.theme||"light",debug:e.debug||!1,...e},this.isOpen=!1,this.root=null,this.container=null,this.callbacks={},this.currentPayment=null,this.config.debug}open(e,t={}){if(!this.isOpen)try{this._validatePaymentConfig(e),this.callbacks=t,this.currentPayment=e,this._createContainer(),this.root=u.createRoot(this.container),this.isOpen=!0,this.root.render(n.createElement($n,{publicKey:this.config.publicKey,apiKey:this.config.apiKey,apiSecret:this.config.apiSecret,apiUrl:this.config.apiUrl,isOpen:!0,theme:this.config.theme,config:{amount:e.amount,customerEmail:e.customerEmail,merchantName:e.merchantName||"Merchant",callbackUrl:e.callbackUrl||this._getDefaultCallbackUrl(),merchantWalletAddresses:e.merchantWalletAddresses||{},preferredNetwork:e.preferredNetwork,preferredCurrency:e.preferredCurrency,metadata:{...e.metadata,source:"vanilla-sdk",sdkVersion:"2.0.0",timestamp:(new Date).toISOString()}},onSuccess:this._handleSuccess.bind(this),onError:this._handleError.bind(this),onClose:this._handleClose.bind(this)})),this.config.debug}catch(s){t.onError&&t.onError(s.message||"Failed to open payment modal")}}close(){this.isOpen&&(this._cleanup(),this.config.debug)}isPaymentOpen(){return this.isOpen}updateConfig(e){this.config={...this.config,...e},this.config.debug}getConfig(){return{...this.config}}getCurrentPayment(){return this.currentPayment?{...this.currentPayment}:null}_validatePaymentConfig(e){if(!e)throw new Error("Payment configuration is required");if(!e.amount||"number"!=typeof e.amount||e.amount<=0)throw new Error("Valid amount (number > 0) is required");if(!e.customerEmail||"string"!=typeof e.customerEmail)throw new Error("Customer email is required");if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.customerEmail))throw new Error("Invalid email format");if(e.merchantWalletAddresses){if("object"!=typeof e.merchantWalletAddresses)throw new Error("merchantWalletAddresses must be an object");Object.keys(e.merchantWalletAddresses).length}}_createContainer(){this.container||(this.container=document.createElement("div"),this.container.id="coinley-payment-container",this.container.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 999999;\n ",document.body.appendChild(this.container))}_getDefaultCallbackUrl(){return"undefined"!=typeof window?`${window.location.origin}/api/webhooks/coinley`:""}_handleSuccess(e,t,n){this.config.debug,this.callbacks.onSuccess&&this.callbacks.onSuccess(e,t,n)}_handleError(e){this.config.debug,this.callbacks.onError&&this.callbacks.onError(e)}_handleClose(){this._cleanup(),this.callbacks.onClose&&this.callbacks.onClose()}_cleanup(){if(this.isOpen=!1,this.root){try{this.root.unmount()}catch(e){}this.root=null}this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null),this.currentPayment=null}}function Qn(){document.querySelectorAll('script[src*="coinley-vanilla"]').forEach(e=>{const t=e.getAttribute("data-public-key"),n=e.getAttribute("data-api-key"),s=e.getAttribute("data-api-secret"),a=e.getAttribute("data-api-url"),r=e.getAttribute("data-theme")||"light",i=e.hasAttribute("data-debug");if((t||n&&s)&&a)try{window.coinley=new Vn({publicKey:t,apiKey:n,apiSecret:s,apiUrl:a,theme:r,debug:i})}catch(o){}})}"undefined"!=typeof window&&(window.CoinleyVanilla=Vn,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",Qn):Qn());class Kn{constructor(e="https://paymentscreen.vercel.app/"){this.basePaymentUrl=e.endsWith("/")?e:e+"/"}generatePaymentURL(e){const{merchant:t,amount:n,productAmount:s,platformFee:a,networkFee:r,token:i="USDC",network:o="Ethereum Mainnet",merchantAddress:c}=e;if(!t)throw new Error("Merchant name is required");if(!n)throw new Error("Amount is required");if(!c)throw new Error("Merchant address (smart contract) is required");const l=s||.95*n,d=a||.03*n,m=r||.02*n,u=new URLSearchParams({merchant:t,amount:n.toString(),productAmount:l.toString(),platformFee:d.toString(),networkFee:m.toString(),token:i,network:o,merchantAddress:c});return this.basePaymentUrl+"?"+u.toString()}async generateQRCode(e,t={}){const{width:n=300,margin:s=2,colorDark:a="#7c3aed",colorLight:r="#ffffff"}=t;try{const t=this.generatePaymentURL(e);return{qrCodeDataURL:await d.toDataURL(t,{width:n,margin:s,color:{dark:a,light:r}}),paymentURL:t,paymentData:{...e,qrCodeUrl:t}}}catch(i){throw new Error(`Failed to generate QR code: ${i.message}`)}}async generateQRCodeToCanvas(e,t,n={}){const{width:s=300,margin:a=2,colorDark:r="#7c3aed",colorLight:i="#ffffff"}=n;try{const n=this.generatePaymentURL(e);return await d.toCanvas(t,n,{width:s,margin:a,color:{dark:r,light:i}}),n}catch(o){throw new Error(`Failed to generate QR code to canvas: ${o.message}`)}}validatePaymentData(e){const t=[],n=[];e.merchant||t.push("Merchant name is required"),(!e.amount||e.amount<=0)&&t.push("Valid amount is required"),e.merchantAddress||t.push("Merchant address (smart contract) is required"),e.merchantAddress&&!/^0x[a-fA-F0-9]{40}$/.test(e.merchantAddress)&&t.push("Invalid Ethereum address format for merchantAddress"),e.amount>1e4&&n.push("Large payment amount detected");return(e.platformFee||0)+(e.networkFee||0)>.1*e.amount&&n.push("High fees detected (>10% of total amount)"),{isValid:0===t.length,errors:t,warnings:n}}async createPaymentQR(e){const{merchantName:t,amount:n,productAmount:s,platformFee:a,networkFee:r,token:i,network:o,merchantWalletAddresses:c,selectedNetwork:l="ethereum",...d}=e,m={merchant:t||"Coinley Merchant",amount:n,productAmount:s,platformFee:a,networkFee:r,token:i||"USDC",network:o||"Ethereum Mainnet",merchantAddress:(null==c?void 0:c[l])||(null==c?void 0:c.ethereum)||(null==c?void 0:c.splitPaymentContract),...d},u=this.validatePaymentData(m);if(!u.isValid)throw new Error(`Payment validation failed: ${u.errors.join(", ")}`);return{...await this.generateQRCode(m),validation:u,instructions:{userAction:"Scan this QR code with your mobile wallet to pay",expectedFlow:"QR Scan โ Payment Screen โ Wallet Connect โ Split Payment โ Confirmation",supportedWallets:["MetaMask","Trust Wallet","Coinbase Wallet","WalletConnect compatible wallets"]}}}}const Zn=new Kn,Yn={formatAmount:(e,t=2)=>e.toFixed(t),truncateAddress:(e,t=6,n=4)=>e?e.length<=t+n?e:`${e.slice(0,t)}...${e.slice(-n)}`:"",isValidAddress:(e,t)=>{if(!e)return!1;switch(t.toLowerCase()){case"ethereum":case"bsc":case"polygon":return/^0x[a-fA-F0-9]{40}$/.test(e);case"tron":return/^T[a-zA-Z0-9]{33}$/.test(e);case"solana":return/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e);default:return e.length>0}},copyToClipboard:async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}};class _n extends Error{constructor(e,t){super(e),this.name="CoinleyError",this.code=t}}const Jn={react:'\nimport { CoinleyProvider, CoinleyCheckout } from \'coinley-test\';\n\n// New recommended way - using publicKey only\n<CoinleyProvider\n publicKey="pk_your-public-key"\n apiUrl="https://api.coinley.io"\n>\n <CoinleyCheckout\n ref={checkoutRef}\n onSuccess={(paymentId, txHash, details) => console.log(\'Success!\')}\n onError={(error) => console.error(\'Error:\', error)}\n onClose={() => console.log(\'Closed\')}\n />\n</CoinleyProvider>\n\n// Legacy way (still supported) - using apiKey + apiSecret\n<CoinleyProvider\n apiKey="your-api-key"\n apiSecret="your-api-secret"\n apiUrl="https://api.coinley.io"\n>\n ...\n</CoinleyProvider>\n ',vanilla:'\n\x3c!-- Include via CDN --\x3e\n<script src="https://unpkg.com/coinley-test@latest/vanilla"><\/script>\n<link rel="stylesheet" href="https://unpkg.com/coinley-test@latest/vanilla/style.css">\n\n<script>\n// New recommended way - using publicKey only\nconst coinley = new CoinleyVanilla({\n publicKey: "pk_your-public-key",\n apiUrl: "https://api.coinley.io",\n theme: "light"\n});\n\n// Legacy way (still supported)\nconst coinleyLegacy = new CoinleyVanilla({\n apiKey: "your-api-key",\n apiSecret: "your-api-secret",\n apiUrl: "https://api.coinley.io",\n theme: "light"\n});\n\n// Use in checkout\ncoinley.open({\n amount: 100,\n customerEmail: "customer@example.com",\n merchantName: "Your Store",\n merchantWalletAddresses: {\n ethereum: "0x...",\n bsc: "0x..."\n }\n}, {\n onSuccess: (paymentId, txHash, details) => console.log(\'Success!\'),\n onError: (error) => console.error(\'Error:\', error),\n onClose: () => console.log(\'Closed\')\n});\n<\/script>\n '};e.CoinleyCheckout=On,e.CoinleyError=_n,e.CoinleyProvider=({publicKey:e,apiKey:s,apiSecret:a,apiUrl:r,theme:i="light",debug:o=!1,children:c})=>{const[l,d]=n.useState(!1),[m,u]=n.useState(null),[h,p]=n.useState({}),[y,g]=n.useState(""),f=()=>{d(!1),u(null),h.onClose&&h.onClose()},b={openPayment:(e,t)=>{u(e),t&&p(t),d(!0)},closePayment:f};return t.jsxs(Gn.Provider,{value:b,children:[c,l&&m&&t.jsx($n,{publicKey:e,apiKey:s,apiSecret:a,apiUrl:r,isOpen:l,config:m,theme:i,debug:o,merchantName:y,onSuccess:h.onSuccess,onError:h.onError,onClose:f})]})},e.CoinleyVanilla=Vn,e.DEFAULT_CONFIG={theme:"light",debug:!1,testMode:!1,autoOpen:!1},e.EnhancedSimpleCoinleyPayment=$n,e.PaymentAPI=class{constructor(e,t,n=null){t&&t.startsWith("pk_")?(this.publicKey=t,this.apiKey=null,this.apiSecret=null):(this.publicKey=null,this.apiKey=t,this.apiSecret=n),this.api=m.create({baseURL:e.endsWith("/")?e.slice(0,-1):e,timeout:3e4,headers:{"Content-Type":"application/json"}}),this.api.interceptors.request.use(e=>{if(this.publicKey)e.headers["x-public-key"]=this.publicKey;else{e.headers["x-api-key"]=this.apiKey,e.headers["x-api-secret"]=this.apiSecret;const t=this.generateMerchantToken();t&&(e.headers.Authorization=`Bearer ${t}`)}return e},e=>Promise.reject(e)),this.api.interceptors.response.use(e=>e,e=>{var t,n,s;if(401===(null==(t=e.response)?void 0:t.status))throw new Error("Authentication failed. Please check your API credentials.");if(404===(null==(n=e.response)?void 0:n.status))throw new Error("API endpoint not found. Please check your API URL.");if((null==(s=e.response)?void 0:s.status)>=500)throw new Error("Server error. Please try again later.");throw e})}generateMerchantToken(){try{const e=`${this.apiKey}:${this.apiSecret}`;return btoa(e)}catch(e){return null}}async request(e,t={}){var n,s;try{return(await this.api({url:e,method:t.method||"GET",data:t.data||t.body?JSON.parse(t.body||"{}"):void 0,...t})).data}catch(a){if(null==(s=null==(n=a.response)?void 0:n.data)?void 0:s.error)throw new Error(a.response.data.error);throw new Error(a.message||"Request failed")}}async createPayment(e){var t,n;try{return(await this.api.post("/api/payments/create",e)).data}catch(s){if(null==(n=null==(t=s.response)?void 0:t.data)?void 0:n.error)throw new Error(s.response.data.error);throw new Error(s.message||"Failed to create payment")}}async getPayment(e){var t,n;try{return(await this.api.get(`/api/payments/${e}`)).data}catch(s){if(null==(n=null==(t=s.response)?void 0:t.data)?void 0:n.error)throw new Error(s.response.data.error);throw new Error(s.message||"Failed to get payment details")}}async getNetworks(){try{return(await this.api.get("/api/networks")).data}catch(e){return{networks:[{id:"ethereum",name:"Ethereum",shortName:"ethereum",chainId:1,type:"ethereum",explorerUrl:"https://etherscan.io",isTestnet:!1},{id:"bsc",name:"Binance Smart Chain",shortName:"bsc",chainId:56,type:"bsc",explorerUrl:"https://bscscan.com",isTestnet:!1},{id:"polygon",name:"Polygon",shortName:"polygon",chainId:137,type:"ethereum",explorerUrl:"https://polygonscan.com",isTestnet:!1}]}}}async getStablecoins(){try{return(await this.api.get("/api/networks/stablecoins")).data}catch(e){return{stablecoins:[{id:"usdt-eth",name:"Tether USD",symbol:"USDT",contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,isStablecoin:!0,networkId:"ethereum",Network:{id:"ethereum",name:"Ethereum",shortName:"ethereum",type:"ethereum"}},{id:"usdc-eth",name:"USD Coin",symbol:"USDC",contractAddress:"0xA0b86a33E6441d81d0B93bF9EE0f74ca32F7e6f6",decimals:6,isStablecoin:!0,networkId:"ethereum",Network:{id:"ethereum",name:"Ethereum",shortName:"ethereum",type:"ethereum"}}]}}}async verifyQRPayment(e){var t,n;try{return(await this.api.post("/api/payments/verify-qr",{paymentId:e})).data}catch(s){if(null==(n=null==(t=s.response)?void 0:t.data)?void 0:n.error)throw new Error(s.response.data.error);throw new Error(s.message||"Failed to verify payment")}}async processPayment(e,t,n,s){var a;try{return(await this.api.post("/api/payments/process",{paymentId:e,transactionHash:t,network:n,senderAddress:s})).data}catch(r){if(null==(a=r.response)?void 0:a.data){const e=r.response.data,t=e.error||e.message||"Payment processing failed",n=new Error(t);throw n.isAlreadyCompleted=e.isAlreadyCompleted||!1,n.verificationAttempts=e.verificationAttempts||0,n.statusCode=r.response.status,n.originalData=e,n}throw new Error(r.message||"Failed to process PaymentSplitter transaction")}}async getContractInfo(e){var t,n;try{return(await this.api.get(`/api/payments/contract/${e}`)).data.contractInfo}catch(s){if(null==(n=null==(t=s.response)?void 0:t.data)?void 0:n.error)throw new Error(s.response.data.error);throw new Error(s.message||"Failed to get contract information")}}async getPaymentSplitterStatus(e){var t,n;try{return(await this.api.get(`/api/payments/splitter-status/${e}`)).data.paymentSplitterStatus}catch(s){if(null==(n=null==(t=s.response)?void 0:t.data)?void 0:n.error)throw new Error(s.response.data.error);throw new Error(s.message||"Failed to get PaymentSplitter status")}}async checkPaymentSplitterHealth(){try{return(await this.api.get("/api/payments/health")).data.paymentSplitterHealth}catch(e){return{error:e.message}}}async healthCheck(){try{return 200===(await this.api.get("/api/health")).status}catch(e){return!1}}},e.PaymentQRGenerator=Kn,e.QRCodePayment=({apiKey:e,apiSecret:s,apiUrl:a,config:r,onSuccess:i,onError:o,onClose:c,isOpen:l,theme:m="light",mode:u="splitpayment",splitPaymentUrl:h="https://paymentscreen.vercel.app/"})=>{var p;const[y,g]=n.useState("network"),[f,b]=n.useState([]),[x,w]=n.useState([]),[v,k]=n.useState(null),[N,C]=n.useState(null),[P,j]=n.useState(null),[I,S]=n.useState(!1),[A,E]=n.useState(""),[F,U]=n.useState(""),[D,T]=n.useState(""),[B,L]=n.useState(""),[M,R]=n.useState(!1),[$,G]=n.useState(""),[O,z]=n.useState(!1),[W,H]=n.useState(null),q=n.useRef(new qn(a,e,s)),V=n.useRef(null);n.useEffect(()=>(l&&(K(),Q()),()=>{V.current&&clearInterval(V.current)}),[l]);const Q=()=>{g("network"),k(null),C(null),j(null),E(""),U(""),T(""),L(""),R(!1),G(""),z(!1),H(null),V.current&&clearInterval(V.current)},K=async()=>{try{S(!0),E("");const[e,t]=await Promise.all([q.current.getNetworks(),q.current.getTokens()]);b(e.networks||[]),w(t.stablecoins||[])}catch(e){E("Failed to load payment options.")}finally{S(!1)}},Z=async e=>{if(!N||!v||!P)return!1;try{const t=await Hn.validateBalance(e,N,P.totalAmount,v.shortName,!0);return H(t),!!t.isValid||(E(`Insufficient balance: ${t.errors.join(", ")}`),!1)}catch(t){return E(`Failed to check balance: ${t.message}`),!1}};if(!l)return null;const Y="dark"===m;return t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"rounded-lg shadow-xl max-w-md w-full mx-4 "+(Y?"bg-gray-900 text-white":"bg-white text-gray-900"),children:[t.jsxs("div",{className:"p-4 border-b flex justify-between items-center "+(Y?"border-gray-700":"border-gray-200"),children:[t.jsxs("div",{className:"text-center flex-1",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"splitpayment"===u?"Split Payment QR":"QR Code Payment"}),r.amount&&t.jsxs("p",{className:"text-2xl font-bold text-purple-600",children:["$",r.amount.toFixed(2)]}),t.jsx("p",{className:"text-xs text-blue-600",children:"splitpayment"===u?"๐ฑ Scan to redirect to payment screen":"๐ฑ Scan with mobile wallet"})]}),t.jsx("button",{onClick:c,className:"ml-4 text-gray-500 hover:text-gray-700 "+(Y?"hover:text-gray-300":""),children:"โ"})]}),t.jsxs("div",{className:"p-4 min-h-[400px]",children:[A&&t.jsxs("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded border border-red-200",children:[A,t.jsx("button",{onClick:()=>E(""),className:"ml-2 text-red-500 hover:text-red-700",children:"โ"})]}),"network"===y&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"font-medium text-center",children:"Select Network"}),t.jsx("div",{className:"space-y-2",children:f.map(e=>{var n;const s=null==(n=r.merchantWalletAddresses)?void 0:n[e.shortName];return t.jsxs("button",{onClick:()=>{k(e),g("token")},disabled:!s,className:"w-full p-3 border rounded-lg text-left transition-colors "+(s?"hover:border-purple-500 "+(Y?"border-gray-600 hover:bg-gray-800":"border-gray-200 hover:bg-gray-50"):"opacity-50 cursor-not-allowed "+(Y?"border-gray-700":"border-gray-100")),children:[t.jsx("div",{className:"font-medium",children:e.name}),t.jsxs("div",{className:"text-sm "+(Y?"text-gray-400":"text-gray-500"),children:[e.shortName.toUpperCase(),!s&&" (No merchant address configured)"]})]},e.id)})})]}),"token"===y&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>g("network"),className:""+(Y?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),children:"โ"}),t.jsxs("h3",{className:"font-medium",children:["Select Token on ",null==v?void 0:v.name]})]}),t.jsx("div",{className:"space-y-2",children:x.filter(e=>{var t;return(null==(t=e.Network)?void 0:t.shortName)===(null==v?void 0:v.shortName)}).map(e=>t.jsxs("button",{onClick:()=>{C(e),(async e=>{var t,n;try{S(!0),E("");const s={amount:r.amount,currency:e.symbol,network:v.shortName,customerEmail:r.customerEmail,callbackUrl:r.callbackUrl,metadata:{...r.metadata,merchantWalletAddresses:r.merchantWalletAddresses,paymentMethod:"split_payment_qr",selectedNetwork:v.shortName,selectedToken:e.symbol}},a=await q.current.createPayment(s);j(a.payment);const i=(null==(t=r.merchantWalletAddresses)?void 0:t.splitPaymentContract)||(null==(n=r.merchantWalletAddresses)?void 0:n[v.shortName]);if(!i)throw new Error("Split payment contract address not found in config");const o=new URLSearchParams({merchant:r.merchantName||"Coinley Merchant",amount:a.payment.totalAmount.toString(),productAmount:(.95*a.payment.totalAmount).toFixed(2),platformFee:(.03*a.payment.totalAmount).toFixed(2),networkFee:(.02*a.payment.totalAmount).toFixed(2),token:e.symbol,network:v.name,merchantAddress:i,paymentId:a.payment.id}),c=h+"?"+o.toString();U(c);const l=await d.toDataURL(c,{width:256,margin:2,color:{dark:"#7c3aed",light:"#ffffff"}});T(l),g("scan")}catch(s){E(s.message||"Failed to generate split payment QR code")}finally{S(!1)}})(e)},disabled:I,className:"w-full p-3 border rounded-lg hover:border-purple-500 text-left transition-colors disabled:opacity-50 "+(Y?"border-gray-600 hover:bg-gray-800":"border-gray-200 hover:bg-gray-50"),children:[t.jsx("div",{className:"font-medium",children:e.name}),t.jsx("div",{className:"text-sm "+(Y?"text-gray-400":"text-gray-500"),children:e.symbol})]},e.id))})]}),"scan"===y&&t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"font-medium mb-4",children:"splitpayment"===u?"Scan QR Code to Open Payment Screen":"Scan QR Code with Mobile Wallet"}),D?t.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[t.jsx("div",{className:"p-4 rounded-lg "+(Y?"bg-gray-800":"bg-gray-50"),children:t.jsx("img",{src:D,alt:"Payment QR Code",className:"mx-auto",style:{width:"200px",height:"200px"}})}),t.jsxs("div",{className:"text-sm space-y-1 "+(Y?"text-gray-300":"text-gray-600"),children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Amount:"}),t.jsxs("span",{className:"font-medium",children:[null==P?void 0:P.totalAmount," ",null==N?void 0:N.symbol]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Network:"}),t.jsx("span",{className:"font-medium",children:null==v?void 0:v.name})]}),"splitpayment"===u&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Merchant:"}),t.jsx("span",{className:"font-medium",children:r.merchantName||"Coinley Merchant"})]})]}),t.jsx("div",{className:"p-3 rounded-lg text-xs "+(Y?"bg-blue-900 text-blue-200":"bg-blue-50 text-blue-600"),children:"splitpayment"===u?t.jsxs(t.Fragment,{children:["๐ฑ Scan this QR code with your mobile wallet to open the payment screen.",t.jsx("br",{}),"The payment screen will auto-connect your wallet and execute the split payment."]}):"๐ฑ Open your mobile wallet and scan this QR code to connect and pay"}),"splitpayment"===u?t.jsx("button",{onClick:()=>window.open(F,"_blank"),className:"w-full bg-purple-600 text-white py-2 px-4 rounded hover:bg-purple-700 text-sm",children:"๐ Test Payment Screen (Opens in new tab)"}):t.jsx("button",{onClick:async()=>{try{S(!0),E("");const e="0x742d35Cc6634C0532925a3b8D9a5C7C47C77E4";G(e),R(!0),await Z(e),g("confirm")}catch(e){E("Failed to simulate wallet connection")}finally{S(!1)}},disabled:I,className:"w-full bg-gray-600 text-white py-2 px-4 rounded hover:bg-gray-700 disabled:opacity-50 text-sm",children:I?"Connecting...":"๐งช Simulate Wallet Scan (Test)"})]}):t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-purple-600"}),t.jsx("span",{className:"ml-2",children:"Generating QR Code..."})]})]})}),"confirm"===y&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4",children:t.jsx("span",{className:"text-2xl",children:"๐ฑ"})}),t.jsx("h3",{className:"font-medium",children:"Mobile Wallet Connected"}),t.jsx("p",{className:"text-sm mt-2 "+(Y?"text-gray-300":"text-gray-600"),children:"Ready to complete payment"})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-3 bg-green-50 rounded-lg border border-green-200",children:[t.jsx("p",{className:"text-green-600 text-sm font-medium",children:"โ
Wallet Connected"}),t.jsxs("p",{className:"font-mono text-xs text-green-700 mt-1",children:[null==$?void 0:$.slice(0,6),"...",null==$?void 0:$.slice(-4)]})]}),W&&t.jsx("div",{className:"p-3 rounded-lg border "+(W.isValid?"bg-green-50 border-green-200":"bg-red-50 border-red-200"),children:t.jsxs("div",{className:"space-y-2 text-sm",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Required:"}),t.jsxs("span",{className:"font-medium",children:[null==P?void 0:P.totalAmount," ",null==N?void 0:N.symbol]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Your Balance:"}),t.jsx("span",{className:"font-medium "+(W.hasEnoughTokens?"text-green-600":"text-red-600"),children:Hn.formatBalance(null==(p=W.tokenBalance)?void 0:p.balance,null==N?void 0:N.symbol)})]}),W.nativeBalance&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Gas Balance:"}),t.jsx("span",{className:"font-medium "+(W.hasEnoughForGas?"text-green-600":"text-red-600"),children:Hn.formatBalance(W.nativeBalance.balance,W.nativeBalance.symbol)})]})]})}),t.jsx("button",{onClick:async()=>{try{z(!0),E("");const e=`0x${Math.random().toString(16).substring(2,66)}`;await new Promise(e=>setTimeout(e,3e3)),g("success"),null==i||i(P.id,e,{network:v.name,token:N.symbol,amount:P.totalAmount,method:"qr_code",walletAddress:$})}catch(e){E("Transaction confirmation failed")}finally{z(!1)}},disabled:O||!(null==W?void 0:W.isValid),className:"w-full bg-green-600 text-white py-3 px-4 rounded-lg hover:bg-green-700 disabled:opacity-50 font-medium",children:O?"Processing Payment...":(null==W?void 0:W.isValid)?`Confirm Payment of ${null==P?void 0:P.totalAmount} ${null==N?void 0:N.symbol}`:"Insufficient Balance"})]})]}),"success"===y&&t.jsxs("div",{className:"text-center space-y-4",children:[t.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto",children:t.jsx("span",{className:"text-2xl",children:"โ
"})}),t.jsx("h3",{className:"font-medium text-green-600",children:"Payment Successful!"}),t.jsx("p",{className:"text-sm "+(Y?"text-gray-300":"text-gray-600"),children:"Transaction completed via QR code scan"}),t.jsx("button",{onClick:c,className:"w-full bg-green-600 text-white py-3 px-4 rounded-lg hover:bg-green-700 font-medium",children:"Close"})]}),I&&"scan"!==y&&"confirm"!==y&&t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-purple-600"})})]})]})})},e.SimpleCoinleyProvider=({children:e,...t})=>e,e.ThemeProvider=({initialTheme:e="light",children:s})=>{const[a,r]=n.useState(e);return n.useEffect(()=>{document.documentElement.setAttribute("data-coinley-theme",a)},[a]),t.jsx("div",{className:`coinley-theme-${a}`,children:s})},e.USAGE_EXAMPLES=Jn,e.VERSION="0.0.26",e.generatePaymentQR=(e,t)=>Zn.generateQRCode(e,t),e.generatePaymentURL=e=>Zn.generatePaymentURL(e),e.paymentQR=Zn,e.useCoinley=()=>{const e=n.useContext(Gn);if(!e)throw new Error("useCoinley must be used within a CoinleyProvider");return e},e.utils=Yn,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react"),require("wagmi"),require("@tanstack/react-query"),require("@wagmi/core"),require("@wagmi/core/chains"),require("@wagmi/connectors"),require("viem"),require("react-dom"),require("qrcode"),require("axios"),require("react-dom/client")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react","wagmi","@tanstack/react-query","@wagmi/core","@wagmi/core/chains","@wagmi/connectors","viem","react-dom","qrcode","axios","react-dom/client"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).CoinleyTest={},e.React,e.React,e.Wagmi,e.ReactQuery,e.WagmiCore,e.chains,e.connectors,e.Viem,e.ReactDOM,e.QRCode,e.axios,e.ReactDOM)}(this,function(e,t,r,n,i,o,s,a,c,l,u,d,h){"use strict";var p,f=["buffer","Buffer"];if("undefined"==typeof window){var m={hostname:""};p={crypto:{randomUUID:function(){throw Error("unsupported")}},navigator:{userAgent:"",onLine:!0},document:{createElement:function(){return{}},location:m,referrer:""},screen:{width:0,height:0},location:m,addEventListener:function(){},removeEventListener:function(){}}}else p=window;function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function y(e,t,r,n,i,o,s){try{var a=e[o](s),c=a.value}catch(gu){return void r(gu)}a.done?t(c):Promise.resolve(c).then(n,i)}function v(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){y(o,n,i,s,a,"next",e)}function a(e){y(o,n,i,s,a,"throw",e)}s(void 0)})}}function b(e,t,r){return(b=A()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&I(i,r.prototype),i}).apply(null,arguments)}function w(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(e.prototype,t),e}function x(){return x=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},x.apply(this,arguments)}function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function k(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&I(e,t)}function S(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function C(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function N(e){var t="function"==typeof Map?new Map:void 0;return N=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return b(e,arguments,_(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),I(n,e)},N(e)}function A(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(A=function(){return!!e})()}function P(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}(e))||t){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function O(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(a){o=[6,a],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function M(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var T,R=Object.defineProperty,j=function(e,t,r){return function(e,t,r){return t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r}(e,"symbol"!==(void 0===t?"undefined":E(t))?t+"":t,r)},D=Object.defineProperty,F=function(e,t,r){return function(e,t,r){return t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r}(e,"symbol"!==(void 0===t?"undefined":E(t))?t+"":t,r)},L=function(e){return e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e}(L||{}),U={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},B={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},z={};function q(e){if(z[e])return z[e];var t=globalThis[e],r=t.prototype,n=e in U?U[e]:void 0,i=Boolean(n&&n.every(function(e){var t,n;return Boolean(null==(n=null==(t=Object.getOwnPropertyDescriptor(r,e))?void 0:t.get)?void 0:n.toString().includes("[native code]"))})),o=e in B?B[e]:void 0,s=Boolean(o&&o.every(function(e){var t;return"function"==typeof r[e]&&(null==(t=r[e])?void 0:t.toString().includes("[native code]"))}));if(i&&s&&!globalThis.Zone)return z[e]=t.prototype,t.prototype;try{var a=document.createElement("iframe");document.body.appendChild(a);var c=a.contentWindow;if(!c)return t.prototype;var l=c[e].prototype;return document.body.removeChild(a),l?z[e]=l:r}catch(u){return r}}var $={};function G(e,t,r){var n,i=e+"."+String(r);if($[i])return $[i].call(t);var o=q(e),s=null==(n=Object.getOwnPropertyDescriptor(o,r))?void 0:n.get;return s?($[i]=s,s.call(t)):t[r]}var W={};function V(e,t,r){var n=e+"."+String(r);if(W[n])return W[n].bind(t);var i=q(e)[r];return"function"!=typeof i?t[r]:(W[n]=i,i.bind(t))}var H={childNodes:function(e){return G("Node",e,"childNodes")},parentNode:function(e){return G("Node",e,"parentNode")},parentElement:function(e){return G("Node",e,"parentElement")},textContent:function(e){return G("Node",e,"textContent")},contains:function(e,t){return V("Node",e,"contains")(t)},getRootNode:function(e){return V("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?G("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?G("Element",e,"shadowRoot"):null},querySelector:function(e,t){return G("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return G("Element",e,"querySelectorAll")(t)},mutationObserver:function(){return q("MutationObserver").constructor},patch:function(e,t,r){try{if(!(t in e))return function(){};var n=e[t],i=r(n);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=i,function(){e[t]=n}}catch(o){return function(){}}}};function Y(e){return e.nodeType===e.ELEMENT_NODE}function Z(e){var t=e&&"host"in e&&"mode"in e&&H.host(e)||null;return Boolean(t&&"shadowRoot"in t&&H.shadowRoot(t)===e)}function K(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function J(e){try{var t=e.rules||e.cssRules;if(!t)return null;var r=e.href;!r&&e.ownerNode&&e.ownerNode.ownerDocument&&(r=e.ownerNode.ownerDocument.location.href);var n=Array.from(t,function(e){return X(e,r)}).join("");return(i=n).includes(" background-clip: text;")&&!i.includes(" -webkit-background-clip: text;")&&(i=i.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),i}catch(gu){return null}var i}function X(e,t){if(function(e){return"styleSheet"in e}(e)){var r;try{r=J(e.styleSheet)||function(e){var t=e.cssText;if(t.split('"').length<3)return t;var r=["@import","url("+JSON.stringify(e.href)+")"];return""===e.layerName?r.push("layer"):e.layerName&&r.push("layer("+e.layerName+")"),e.supportsText&&r.push("supports("+e.supportsText+")"),e.media.length&&r.push(e.media.mediaText),r.join(" ")+";"}(e)}catch(gu){r=e.cssText}return e.styleSheet.href?le(r,e.styleSheet.href):r}var n,i=e.cssText;return function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":")&&(n=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,i=i.replace(n,"$1\\$2")),t?le(i,t):i}var Q=function(){function e(){F(this,"idNodeMap",new Map),F(this,"nodeMetaMap",new WeakMap)}var t=e.prototype;return t.getId=function(e){var t;if(!e)return-1;var r=null==(t=this.getMeta(e))?void 0:t.id;return null!=r?r:-1},t.getNode=function(e){return this.idNodeMap.get(e)||null},t.getIds=function(){return Array.from(this.idNodeMap.keys())},t.getMeta=function(e){return this.nodeMetaMap.get(e)||null},t.removeNodeFromMap=function(e){var t=this,r=this.getId(e);this.idNodeMap.delete(r),e.childNodes&&e.childNodes.forEach(function(e){return t.removeNodeFromMap(e)})},t.has=function(e){return this.idNodeMap.has(e)},t.hasNode=function(e){return this.nodeMetaMap.has(e)},t.add=function(e,t){var r=t.id;this.idNodeMap.set(r,e),this.nodeMetaMap.set(e,t)},t.replace=function(e,t){var r=this.getNode(e);if(r){var n=this.nodeMetaMap.get(r);n&&this.nodeMetaMap.set(t,n)}this.idNodeMap.set(e,t)},t.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function ee(e){var t=e.element,r=e.maskInputOptions,n=e.tagName,i=e.type,o=e.value,s=e.maskInputFn,a=o||"",c=i&&te(i);return(r[n.toLowerCase()]||c&&r[c])&&(a=s?s(a,t):"*".repeat(a.length)),a}function te(e){return e.toLowerCase()}var re="__rrweb_original__";function ne(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?te(t):null}function ie(e,t){var r;try{r=new URL(e,null!=t?t:window.location.href)}catch(o){return null}var n,i=r.pathname.match(/\.([0-9a-z]+)(?:$)/i);return null!=(n=null==i?void 0:i[1])?n:null}var oe=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,se=/^(?:[a-z+]+:)?\/\//i,ae=/^www\..*/i,ce=/^(data:)([^,]*),(.*)/i;function le(e,t){return(e||"").replace(oe,function(e,r,n,i,o,s){var a,c=n||o||s,l=r||i||"";if(!c)return e;if(se.test(c)||ae.test(c))return"url("+l+c+l+")";if(ce.test(c))return"url("+l+c+l+")";if("/"===c[0])return"url("+l+(((a=t).indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)+l+")";var u=t.split("/"),d=c.split("/");u.pop();for(var h,p=P(d);!(h=p()).done;){var f=h.value;"."!==f&&(".."===f?u.pop():u.push(f))}return"url("+l+u.join("/")+l+")"})}function ue(e,t){return void 0===t&&(t=!1),t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function de(e,t){return function(e,t,r){void 0===r&&(r=!1);var n=Array.from(t.childNodes),i=[],o=0;if(n.length>1&&e&&"string"==typeof e)for(var s=ue(e,r),a=s.length/e.length,c=1;c<n.length;c++)if(n[c].textContent&&"string"==typeof n[c].textContent){for(var l=ue(n[c].textContent,r),u=3;u<l.length&&(l[u].match(/[a-zA-Z0-9]/)||-1!==l.indexOf(l.substring(0,u),1));u++);for(;u<l.length;u++){var d=l.substring(0,u),h=s.split(d),p=-1;if(2===h.length)p=h[0].length;else if(h.length>2&&""===h[0]&&""!==n[c-1].textContent)p=s.indexOf(d,1);else if(1===h.length){if(d=d.substring(0,d.length-1),(h=s.split(d)).length<=1)return i.push(e),i;u=101}else u===l.length-1&&(p=s.indexOf(d));if(h.length>=2&&u>100){var f=n[c-1].textContent;if(f&&"string"==typeof f){var m=ue(f).length;p=s.indexOf(d,m)}-1===p&&(p=h[0].length)}if(-1!==p){for(var g=Math.floor(p/a);g>0&&g<e.length;){if((o+=1)>50*n.length)return i.push(e),i;var y=ue(e.substring(0,g),r);if(y.length===p){i.push(e.substring(0,g)),e=e.substring(g),s=s.substring(p);break}y.length<p?g+=Math.max(1,Math.floor((p-y.length)/a)):g-=Math.max(1,Math.floor((y.length-p)*a))}break}}}return i.push(e),i}(e,t).join("/* rr_split */")}var he,pe,fe=1,me=new RegExp("[^a-z0-9-_:]");function ge(){return fe++}var ye=/^[^ \t\n\r\u000c]+/,ve=/^[, \t\n\r\u000c]+/;var be=new WeakMap;function we(e,t){return t&&""!==t.trim()?_e(e,t):t}function xe(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function _e(e,t){var r=be.get(e);if(r||(r=e.createElement("a"),be.set(e,r)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return r.setAttribute("href",t),r.href}function ke(e,t,r,n){return n?"src"===r||"href"===r&&("use"!==t||"#"!==n[0])||"xlink:href"===r&&"#"!==n[0]?we(e,n):"background"!==r||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===r?function(e,t){if(""===t.trim())return t;var r=0;function n(e){var n,i=e.exec(t.substring(r));return i?(n=i[0],r+=n.length,n):""}for(var i=[];n(ve),!(r>=t.length);){var o=n(ye);if(","===o.slice(-1))o=we(e,o.substring(0,o.length-1)),i.push(o);else{var s="";o=we(e,o);for(var a=!1;;){var c=t.charAt(r);if(""===c){i.push((o+s).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){r+=1,i.push((o+s).trim());break}"("===c&&(a=!0)}s+=c,r+=1}}}return i.join(", ")}(e,n):"style"===r?le(n,_e(e)):"object"===t&&"data"===r?we(e,n):n:we(e,n):n}function Se(e,t,r){return("video"===e||"audio"===e)&&"autoplay"===t}function Ce(e,t,r){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!r&&Ce(H.parentNode(e),t,r);for(var n=e.classList.length;n--;){var i=e.classList[n];if(t.test(i))return!0}return!!r&&Ce(H.parentNode(e),t,r)}function Ie(e,t,r,n){var i;if(Y(e)){if(i=e,!H.childNodes(i).length)return!1}else{if(null===H.parentElement(e))return!1;i=H.parentElement(e)}try{if("string"==typeof t){if(n){if(i.closest("."+t))return!0}else if(i.classList.contains(t))return!0}else if(Ce(i,t,n))return!0;if(r)if(n){if(i.closest(r))return!0}else if(i.matches(r))return!0}catch(o){}return!1}function Ee(e,t){var r=t.doc,n=t.mirror,i=t.blockClass,o=t.blockSelector,s=t.needsMask,a=t.inlineStylesheet,c=t.maskInputOptions,l=void 0===c?{}:c,u=t.maskTextFn,d=t.maskInputFn,h=t.dataURLOptions,p=void 0===h?{}:h,f=t.inlineImages,m=t.recordCanvas,g=t.keepIframeSrcFn,y=t.newlyAddedElement,v=void 0!==y&&y,b=t.cssCaptured,w=void 0!==b&&b,x=function(e,t){if(!t.hasNode(e))return;var r=t.getId(e);return 1===r?void 0:r}(r,n);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:L.Document,childNodes:[],compatMode:e.compatMode}:{type:L.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:L.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:x};case e.ELEMENT_NODE:return function(e,t){for(var r,n=t.doc,i=t.blockClass,o=t.blockSelector,s=t.inlineStylesheet,a=t.maskInputOptions,c=void 0===a?{}:a,l=t.maskInputFn,u=t.dataURLOptions,d=void 0===u?{}:u,h=t.inlineImages,p=t.recordCanvas,f=t.keepIframeSrcFn,m=t.newlyAddedElement,g=void 0!==m&&m,y=t.rootId,v=function(e,t,r){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var n=e.classList.length;n--;){var i=e.classList[n];if(t.test(i))return!0}if(r)return e.matches(r)}catch(o){}return!1}(e,i,o),b=function(e){if(S(e,HTMLFormElement))return"form";var t=te(e.tagName);return me.test(t)?"div":t}(e),w={},x=e.attributes.length,_=0;_<x;_++){var k=e.attributes[_];Se(b,k.name,k.value)||(w[k.name]=ke(n,b,te(k.name),k.value))}if("link"===b&&s){var C=Array.from(n.styleSheets).find(function(t){return t.href===e.href}),I=null;C&&(I=J(C)),I&&(delete w.rel,delete w.href,w._cssText=I)}if("style"===b&&e.sheet){var E=J(e.sheet);E&&(e.childNodes.length>1&&(E=de(E,e)),w._cssText=E)}if("input"===b||"textarea"===b||"select"===b){var N=e.value,A=e.checked;"radio"!==w.type&&"checkbox"!==w.type&&"submit"!==w.type&&"button"!==w.type&&N?w.value=ee({element:e,type:ne(e),tagName:b,value:N,maskInputOptions:c,maskInputFn:l}):A&&(w.checked=A)}"option"===b&&(e.selected&&!c.select?w.selected=!0:delete w.selected);"dialog"===b&&e.open&&(w.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal");if("canvas"===b&&p)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var r=0;r<e.width;r+=50)for(var n=0;n<e.height;n+=50){var i=t.getImageData,o=re in i?i[re]:i;if(new Uint32Array(o.call(t,r,n,Math.min(50,e.width-r),Math.min(50,e.height-n)).data.buffer).some(function(e){return 0!==e}))return!1}return!0})(e)||(w.rr_dataURL=e.toDataURL(d.type,d.quality));else if(!("__context"in e)){var P=e.toDataURL(d.type,d.quality),O=n.createElement("canvas");O.width=e.width,O.height=e.height,P!==O.toDataURL(d.type,d.quality)&&(w.rr_dataURL=P)}if("img"===b&&h){he||(he=n.createElement("canvas"),pe=he.getContext("2d"));var M=e,T=M.currentSrc||M.getAttribute("src")||"<unknown-src>",R=M.crossOrigin,j=function(){M.removeEventListener("load",j);try{he.width=M.naturalWidth,he.height=M.naturalHeight,pe.drawImage(M,0,0),w.rr_dataURL=he.toDataURL(d.type,d.quality)}catch(e){if("anonymous"!==M.crossOrigin)return M.crossOrigin="anonymous",void(M.complete&&0!==M.naturalWidth?j():M.addEventListener("load",j));console.warn("Cannot inline img src="+T+"! Error: "+e)}"anonymous"===M.crossOrigin&&(R?w.crossOrigin=R:M.removeAttribute("crossorigin"))};M.complete&&0!==M.naturalWidth?j():M.addEventListener("load",j)}if("audio"===b||"video"===b){var D=w;D.rr_mediaState=e.paused?"paused":"played",D.rr_mediaCurrentTime=e.currentTime,D.rr_mediaPlaybackRate=e.playbackRate,D.rr_mediaMuted=e.muted,D.rr_mediaLoop=e.loop,D.rr_mediaVolume=e.volume}g||(e.scrollLeft&&(w.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(w.rr_scrollTop=e.scrollTop));if(v){var F=e.getBoundingClientRect(),U=F.width,B=F.height;w={class:w.class,rr_width:U+"px",rr_height:B+"px"}}"iframe"!==b||f(w.src)||(e.contentDocument||(w.rr_src=w.src),delete w.src);try{customElements.get(b)&&(r=!0)}catch(z){}return{type:L.Element,tagName:b,attributes:w,childNodes:[],isSVG:xe(e)||void 0,needBlock:v,rootId:y,isCustom:r}}(e,{doc:r,blockClass:i,blockSelector:o,inlineStylesheet:a,maskInputOptions:l,maskInputFn:d,dataURLOptions:p,inlineImages:f,recordCanvas:m,keepIframeSrcFn:g,newlyAddedElement:v,rootId:x});case e.TEXT_NODE:return function(e,t){var r=t.needsMask,n=t.maskTextFn,i=t.rootId,o=t.cssCaptured,s=H.parentNode(e),a=s&&s.tagName,c="",l="STYLE"===a||void 0,u="SCRIPT"===a||void 0;u?c="SCRIPT_PLACEHOLDER":o||(c=H.textContent(e),l&&c&&(c=le(c,_e(t.doc))));!l&&!u&&c&&r&&(c=n?n(c,H.parentElement(e)):c.replace(/[\S]/g,"*"));return{type:L.Text,textContent:c||"",rootId:i}}(e,{doc:r,needsMask:s,maskTextFn:u,rootId:x,cssCaptured:w});case e.CDATA_SECTION_NODE:return{type:L.CDATA,textContent:"",rootId:x};case e.COMMENT_NODE:return{type:L.Comment,textContent:H.textContent(e)||"",rootId:x};default:return!1}}function Ne(e){return null==e?"":e.toLowerCase()}function Ae(e,t){var r=t.doc,n=t.mirror,i=t.blockClass,o=t.blockSelector,s=t.maskTextClass,a=t.maskTextSelector,c=t.skipChild,l=void 0!==c&&c,u=t.inlineStylesheet,d=void 0===u||u,h=t.maskInputOptions,p=void 0===h?{}:h,f=t.maskTextFn,m=t.maskInputFn,g=t.slimDOMOptions,y=t.dataURLOptions,v=void 0===y?{}:y,b=t.inlineImages,w=void 0!==b&&b,x=t.recordCanvas,_=void 0!==x&&x,k=t.onSerialize,S=t.onIframeLoad,C=t.iframeLoadTimeout,I=void 0===C?5e3:C,E=t.onStylesheetLoad,N=t.stylesheetLoadTimeout,A=void 0===N?5e3:N,O=t.keepIframeSrcFn,M=void 0===O?function(){return!1}:O,T=t.newlyAddedElement,R=void 0!==T&&T,j=t.cssCaptured,D=void 0!==j&&j,F=t.needsMask,U=t.preserveWhiteSpace,B=void 0===U||U;F||(F=Ie(e,s,a,void 0===F));var z,q=Ee(e,{doc:r,mirror:n,blockClass:i,blockSelector:o,needsMask:F,inlineStylesheet:d,maskInputOptions:p,maskTextFn:f,maskInputFn:m,dataURLOptions:v,inlineImages:w,recordCanvas:_,keepIframeSrcFn:M,newlyAddedElement:R,cssCaptured:D});if(!q)return console.warn(e,"not serialized"),null;z=n.hasNode(e)?n.getId(e):function(e,t){if(t.comment&&e.type===L.Comment)return!0;if(e.type===L.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===ie(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(Ne(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===Ne(e.attributes.name)||"icon"===Ne(e.attributes.rel)||"apple-touch-icon"===Ne(e.attributes.rel)||"shortcut icon"===Ne(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&Ne(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(Ne(e.attributes.property).match(/^(og|twitter|fb):/)||Ne(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===Ne(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===Ne(e.attributes.name)||"googlebot"===Ne(e.attributes.name)||"bingbot"===Ne(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===Ne(e.attributes.name)||"generator"===Ne(e.attributes.name)||"framework"===Ne(e.attributes.name)||"publisher"===Ne(e.attributes.name)||"progid"===Ne(e.attributes.name)||Ne(e.attributes.property).match(/^article:/)||Ne(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===Ne(e.attributes.name)||"yandex-verification"===Ne(e.attributes.name)||"csrf-token"===Ne(e.attributes.name)||"p:domain_verify"===Ne(e.attributes.name)||"verify-v1"===Ne(e.attributes.name)||"verification"===Ne(e.attributes.name)||"shopify-checkout-api-token"===Ne(e.attributes.name)))return!0}}return!1}(q,g)||!B&&q.type===L.Text&&!q.textContent.replace(/^\s+|\s+$/gm,"").length?-2:ge();var $=Object.assign(q,{id:z});if(n.add(e,$),-2===z)return null;k&&k(e);var G=!l;if($.type===L.Element){G=G&&!$.needBlock,delete $.needBlock;var W=H.shadowRoot(e);W&&K(W)&&($.isShadowHost=!0)}if(($.type===L.Document||$.type===L.Element)&&G){g.headWhitespace&&$.type===L.Element&&"head"===$.tagName&&(B=!1);var V={doc:r,mirror:n,blockClass:i,blockSelector:o,needsMask:F,maskTextClass:s,maskTextSelector:a,skipChild:l,inlineStylesheet:d,maskInputOptions:p,maskTextFn:f,maskInputFn:m,slimDOMOptions:g,dataURLOptions:v,inlineImages:w,recordCanvas:_,preserveWhiteSpace:B,onSerialize:k,onIframeLoad:S,iframeLoadTimeout:I,onStylesheetLoad:E,stylesheetLoadTimeout:A,keepIframeSrcFn:M,cssCaptured:!1};if($.type===L.Element&&"textarea"===$.tagName&&void 0!==$.attributes.value);else{$.type===L.Element&&void 0!==$.attributes._cssText&&"string"==typeof $.attributes._cssText&&(V.cssCaptured=!0);for(var J,X=P(Array.from(H.childNodes(e)));!(J=X()).done;){var Q=Ae(J.value,V);Q&&$.childNodes.push(Q)}}var ee=null;if(Y(e)&&(ee=H.shadowRoot(e)))for(var te,re=P(Array.from(H.childNodes(ee)));!(te=re()).done;){var ne=Ae(te.value,V);ne&&(K(ee)&&(ne.isShadow=!0),$.childNodes.push(ne))}}var oe=H.parentNode(e);return oe&&Z(oe)&&K(oe)&&($.isShadow=!0),$.type===L.Element&&"iframe"===$.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var i,o=!1;try{i=n.document.readyState}catch(gu){return}if("complete"===i){var s="about:blank";if(n.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout(function(){o||(t(),o=!0)},r);e.addEventListener("load",function(){clearTimeout(a),o=!0,t()})}}}(e,function(){var t=e.contentDocument;if(t&&S){var r=Ae(t,{doc:t,mirror:n,blockClass:i,blockSelector:o,needsMask:F,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:f,maskInputFn:m,slimDOMOptions:g,dataURLOptions:v,inlineImages:w,recordCanvas:_,preserveWhiteSpace:B,onSerialize:k,onIframeLoad:S,iframeLoadTimeout:I,onStylesheetLoad:E,stylesheetLoadTimeout:A,keepIframeSrcFn:M});r&&S(e,r)}},I),$.type===L.Element&&"link"===$.tagName&&"string"==typeof $.attributes.rel&&("stylesheet"===$.attributes.rel||"preload"===$.attributes.rel&&"string"==typeof $.attributes.href&&"css"===ie($.attributes.href))&&function(e,t,r){var n,i=!1;try{n=e.sheet}catch(gu){return}if(!n){var o=setTimeout(function(){i||(t(),i=!0)},r);e.addEventListener("load",function(){clearTimeout(o),i=!0,t()})}}(e,function(){if(E){var t=Ae(e,{doc:r,mirror:n,blockClass:i,blockSelector:o,needsMask:F,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:f,maskInputFn:m,slimDOMOptions:g,dataURLOptions:v,inlineImages:w,recordCanvas:_,preserveWhiteSpace:B,onSerialize:k,onIframeLoad:S,iframeLoadTimeout:I,onStylesheetLoad:E,stylesheetLoadTimeout:A,keepIframeSrcFn:M});t&&E(e,t)}},A),$}function Pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Oe(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return S(this,e)?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}var Me={exports:{}},Te=String,Re=function(){return{isColorSupported:!1,reset:Te,bold:Te,dim:Te,italic:Te,underline:Te,inverse:Te,hidden:Te,strikethrough:Te,black:Te,red:Te,green:Te,yellow:Te,blue:Te,magenta:Te,cyan:Te,white:Te,gray:Te,bgBlack:Te,bgRed:Te,bgGreen:Te,bgYellow:Te,bgBlue:Te,bgMagenta:Te,bgCyan:Te,bgWhite:Te}};Me.exports=Re(),Me.exports.createColors=Re;var je=Me.exports,De=Oe(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),Fe=je,Le=De,Ue=function(e){function t(r,n,i,o,s,a){var c;return(c=e.call(this,r)||this).name="CssSyntaxError",c.reason=r,s&&(c.file=s),o&&(c.source=o),a&&(c.plugin=a),void 0!==n&&void 0!==i&&("number"==typeof n?(c.line=n,c.column=i):(c.line=n.line,c.column=n.column,c.endLine=i.line,c.endColumn=i.column)),c.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(c,t),c}k(t,e);var r=t.prototype;return r.setMessage=function(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason},r.showSourceCode=function(e){var t=this;if(!this.source)return"";var r=this.source;null==e&&(e=Fe.isColorSupported),Le&&e&&(r=Le(r));var n,i,o=r.split(/\r?\n/),s=Math.max(this.line-3,0),a=Math.min(this.line+2,o.length),c=String(a).length;if(e){var l=Fe.createColors(!0),u=l.bold,d=l.gray,h=l.red;n=function(e){return u(h(e))},i=function(e){return d(e)}}else n=i=function(e){return e};return o.slice(s,a).map(function(e,r){var o=s+1+r,a=" "+(" "+o).slice(-c)+" | ";if(o===t.line){var l=i(a.replace(/\d/g," "))+e.slice(0,t.column-1).replace(/[^\t]/g," ");return n(">")+i(a)+e+"\n "+l+n("^")}return" "+i(a)+e}).join("\n")},r.toString=function(){var e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e},t}(N(Error)),Be=Ue;Ue.default=Ue;var ze={};ze.isClean=Symbol("isClean"),ze.my=Symbol("my");var qe={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var $e=function(){function e(e){this.builder=e}var t=e.prototype;return t.atrule=function(e,t){var r="@"+e.name,n=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?r+=e.raws.afterName:n&&(r+=" "),e.nodes)this.block(e,r+n);else{var i=(e.raws.between||"")+(t?";":"");this.builder(r+n+i,e)}},t.beforeAfter=function(e,t){var r;r="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===t?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");for(var n=e.parent,i=0;n&&"root"!==n.type;)i+=1,n=n.parent;if(r.includes("\n")){var o=this.raw(e,null,"indent");if(o.length)for(var s=0;s<i;s++)r+=o}return r},t.block=function(e,t){var r,n=this.raw(e,"between","beforeOpen");this.builder(t+n+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),r=this.raw(e,"after")):r=this.raw(e,"after","emptyBody"),r&&this.builder(r),this.builder("}",e,"end")},t.body=function(e){for(var t=e.nodes.length-1;t>0&&"comment"===e.nodes[t].type;)t-=1;for(var r=this.raw(e,"semicolon"),n=0;n<e.nodes.length;n++){var i=e.nodes[n],o=this.raw(i,"before");o&&this.builder(o),this.stringify(i,t!==n||r)}},t.comment=function(e){var t=this.raw(e,"left","commentLeft"),r=this.raw(e,"right","commentRight");this.builder("/*"+t+e.text+r+"*/",e)},t.decl=function(e,t){var r=this.raw(e,"between","colon"),n=e.prop+r+this.rawValue(e,"value");e.important&&(n+=e.raws.important||" !important"),t&&(n+=";"),this.builder(n,e)},t.document=function(e){this.body(e)},t.raw=function(e,t,r){var n;if(r||(r=t),t&&void 0!==(n=e.raws[t]))return n;var i=e.parent;if("before"===r){if(!i||"root"===i.type&&i.first===e)return"";if(i&&"document"===i.type)return""}if(!i)return qe[r];var o=e.root();if(o.rawCache||(o.rawCache={}),void 0!==o.rawCache[r])return o.rawCache[r];if("before"===r||"after"===r)return this.beforeAfter(e,r);var s,a="raw"+((s=r)[0].toUpperCase()+s.slice(1));return this[a]?n=this[a](o,e):o.walk(function(e){if(void 0!==(n=e.raws[t]))return!1}),void 0===n&&(n=qe[r]),o.rawCache[r]=n,n},t.rawBeforeClose=function(e){var t;return e.walk(function(e){if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return(t=e.raws.after).includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t},t.rawBeforeComment=function(e,t){var r;return e.walkComments(function(e){if(void 0!==e.raws.before)return(r=e.raws.before).includes("\n")&&(r=r.replace(/[^\n]+$/,"")),!1}),void 0===r?r=this.raw(t,null,"beforeDecl"):r&&(r=r.replace(/\S/g,"")),r},t.rawBeforeDecl=function(e,t){var r;return e.walkDecls(function(e){if(void 0!==e.raws.before)return(r=e.raws.before).includes("\n")&&(r=r.replace(/[^\n]+$/,"")),!1}),void 0===r?r=this.raw(t,null,"beforeRule"):r&&(r=r.replace(/\S/g,"")),r},t.rawBeforeOpen=function(e){var t;return e.walk(function(e){if("decl"!==e.type&&void 0!==(t=e.raws.between))return!1}),t},t.rawBeforeRule=function(e){var t;return e.walk(function(r){if(r.nodes&&(r.parent!==e||e.first!==r)&&void 0!==r.raws.before)return(t=r.raws.before).includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t},t.rawColon=function(e){var t;return e.walkDecls(function(e){if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,""),!1}),t},t.rawEmptyBody=function(e){var t;return e.walk(function(e){if(e.nodes&&0===e.nodes.length&&void 0!==(t=e.raws.after))return!1}),t},t.rawIndent=function(e){return e.raws.indent?e.raws.indent:(e.walk(function(r){var n=r.parent;if(n&&n!==e&&n.parent&&n.parent===e&&void 0!==r.raws.before){var i=r.raws.before.split("\n");return t=(t=i[i.length-1]).replace(/\S/g,""),!1}}),t);var t},t.rawSemicolon=function(e){var t;return e.walk(function(e){if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&void 0!==(t=e.raws.semicolon))return!1}),t},t.rawValue=function(e,t){var r=e[t],n=e.raws[t];return n&&n.value===r?n.raw:r},t.root=function(e){this.body(e),e.raws.after&&this.builder(e.raws.after)},t.rule=function(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")},t.stringify=function(e,t){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,t)},e}(),Ge=$e;$e.default=$e;var We=Ge;function Ve(e,t){new We(t).stringify(e)}var He=Ve;Ve.default=Ve;var Ye=ze.isClean,Ze=ze.my,Ke=Be,Je=Ge,Xe=He;function Qe(e,t){var r=new e.constructor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&"proxyCache"!==n){var i=e[n],o=void 0===i?"undefined":E(i);"parent"===n&&"object"===o?t&&(r[n]=t):"source"===n?r[n]=i:Array.isArray(i)?r[n]=i.map(function(e){return Qe(e,r)}):("object"===o&&null!==i&&(i=Qe(i)),r[n]=i)}return r}var et=function(){function e(e){for(var t in void 0===e&&(e={}),this.raws={},this[Ye]=!1,this[Ze]=!0,e)if("nodes"===t){this.nodes=[];for(var r,n=P(e[t]);!(r=n()).done;){var i=r.value;"function"==typeof i.clone?this.append(i.clone()):this.append(i)}}else this[t]=e[t]}var t=e.prototype;return t.addToError=function(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){var t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,"$&"+t.input.from+":"+t.start.line+":"+t.start.column+"$&")}return e},t.after=function(e){return this.parent.insertAfter(this,e),this},t.assign=function(e){for(var t in void 0===e&&(e={}),e)this[t]=e[t];return this},t.before=function(e){return this.parent.insertBefore(this,e),this},t.cleanRaws=function(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between},t.clone=function(e){void 0===e&&(e={});var t=Qe(this);for(var r in e)t[r]=e[r];return t},t.cloneAfter=function(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertAfter(this,t),t},t.cloneBefore=function(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertBefore(this,t),t},t.error=function(e,t){if(void 0===t&&(t={}),this.source){var r=this.rangeBy(t),n=r.end,i=r.start;return this.source.input.error(e,{column:i.column,line:i.line},{column:n.column,line:n.line},t)}return new Ke(e)},t.getProxyProcessor=function(){return{get:function(e,t){return"proxyOf"===t?e:"root"===t?function(){return e.root().toProxy()}:e[t]},set:function(e,t,r){return e[t]===r||(e[t]=r,"prop"!==t&&"value"!==t&&"name"!==t&&"params"!==t&&"important"!==t&&"text"!==t||e.markDirty()),!0}}},t.markDirty=function(){if(this[Ye]){this[Ye]=!1;for(var e=this;e=e.parent;)e[Ye]=!1}},t.next=function(){if(this.parent){var e=this.parent.index(this);return this.parent.nodes[e+1]}},t.positionBy=function(e,t){var r=this.source.start;if(e.index)r=this.positionInside(e.index,t);else if(e.word){var n=(t=this.toString()).indexOf(e.word);-1!==n&&(r=this.positionInside(n,t))}return r},t.positionInside=function(e,t){for(var r=t||this.toString(),n=this.source.start.column,i=this.source.start.line,o=0;o<e;o++)"\n"===r[o]?(n=1,i+=1):n+=1;return{column:n,line:i}},t.prev=function(){if(this.parent){var e=this.parent.index(this);return this.parent.nodes[e-1]}},t.rangeBy=function(e){var t={column:this.source.start.column,line:this.source.start.line},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:t.column+1,line:t.line};if(e.word){var n=this.toString(),i=n.indexOf(e.word);-1!==i&&(t=this.positionInside(i,n),r=this.positionInside(i+e.word.length,n))}else e.start?t={column:e.start.column,line:e.start.line}:e.index&&(t=this.positionInside(e.index)),e.end?r={column:e.end.column,line:e.end.line}:"number"==typeof e.endIndex?r=this.positionInside(e.endIndex):e.index&&(r=this.positionInside(e.index+1));return(r.line<t.line||r.line===t.line&&r.column<=t.column)&&(r={column:t.column+1,line:t.line}),{end:r,start:t}},t.raw=function(e,t){return(new Je).raw(this,e,t)},t.remove=function(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this},t.replaceWith=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(this.parent){for(var n,i=this,o=!1,s=P(t);!(n=s()).done;){var a=n.value;a===this?o=!0:o?(this.parent.insertAfter(i,a),i=a):this.parent.insertBefore(i,a)}o||this.remove()}return this},t.root=function(){for(var e=this;e.parent&&"document"!==e.parent.type;)e=e.parent;return e},t.toJSON=function(e,t){var r={},n=null==t;t=t||new Map;var i=0;for(var o in this)if(Object.prototype.hasOwnProperty.call(this,o)&&"parent"!==o&&"proxyCache"!==o){var s=this[o];if(Array.isArray(s))r[o]=s.map(function(e){return"object"===(void 0===e?"undefined":E(e))&&e.toJSON?e.toJSON(null,t):e});else if("object"===(void 0===s?"undefined":E(s))&&s.toJSON)r[o]=s.toJSON(null,t);else if("source"===o){var a=t.get(s.input);null==a&&(a=i,t.set(s.input,i),i++),r[o]={end:s.end,inputId:a,start:s.start}}else r[o]=s}return n&&(r.inputs=[].concat(t.keys()).map(function(e){return e.toJSON()})),r},t.toProxy=function(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache},t.toString=function(e){void 0===e&&(e=Xe),e.stringify&&(e=e.stringify);var t="";return e(this,function(e){t+=e}),t},t.warn=function(e,t,r){var n={node:this};for(var i in r)n[i]=r[i];return e.warn(t,n)},w(e,[{key:"proxyOf",get:function(){return this}}]),e}(),tt=et;et.default=et;var rt=function(e){function t(t){var r;return t&&void 0!==t.value&&"string"!=typeof t.value&&(t=x({},t,{value:String(t.value)})),(r=e.call(this,t)||this).type="decl",r}return k(t,e),w(t,[{key:"variable",get:function(){return this.prop.startsWith("--")||"$"===this.prop[0]}}]),t}(tt),nt=rt;rt.default=rt;var it=function(e){void 0===e&&(e=21);for(var t="",r=e;r--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t},ot=De.SourceMapConsumer,st=De.SourceMapGenerator,at=De.existsSync,ct=De.readFileSync,lt=De.dirname,ut=De.join;var dt=function(){function e(e,t){if(!1!==t.map){this.loadAnnotation(e),this.inline=this.startWith(this.annotation,"data:");var r=t.map?t.map.prev:void 0,n=this.loadMap(t.from,r);!this.mapFile&&t.from&&(this.mapFile=t.from),this.mapFile&&(this.root=lt(this.mapFile)),n&&(this.text=n)}}var t=e.prototype;return t.consumer=function(){return this.consumerCache||(this.consumerCache=new ot(this.text)),this.consumerCache},t.decodeInline=function(e){var t;if(/^data:application\/json;charset=utf-?8,/.test(e)||/^data:application\/json,/.test(e))return decodeURIComponent(e.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(e)||/^data:application\/json;base64,/.test(e))return t=e.substr(RegExp.lastMatch.length),f?f.from(t,"base64").toString():window.atob(t);var r=e.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+r)},t.getAnnotationURL=function(e){return e.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()},t.isMap=function(e){return"object"===(void 0===e?"undefined":E(e))&&("string"==typeof e.mappings||"string"==typeof e._mappings||Array.isArray(e.sections))},t.loadAnnotation=function(e){var t=e.match(/\/\*\s*# sourceMappingURL=/gm);if(t){var r=e.lastIndexOf(t.pop()),n=e.indexOf("*/",r);r>-1&&n>-1&&(this.annotation=this.getAnnotationURL(e.substring(r,n)))}},t.loadFile=function(e){if(this.root=lt(e),at(e))return this.mapFile=e,ct(e,"utf-8").toString().trim()},t.loadMap=function(e,t){if(!1===t)return!1;if(t){if("string"==typeof t)return t;if("function"!=typeof t){if(S(t,ot))return st.fromSourceMap(t).toString();if(S(t,st))return t.toString();if(this.isMap(t))return JSON.stringify(t);throw new Error("Unsupported previous source map format: "+t.toString())}var r=t(e);if(r){var n=this.loadFile(r);if(!n)throw new Error("Unable to load previous source map: "+r.toString());return n}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){var i=this.annotation;return e&&(i=ut(lt(e),i)),this.loadFile(i)}}},t.startWith=function(e,t){return!!e&&e.substr(0,t.length)===t},t.withContent=function(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)},e}(),ht=dt;dt.default=dt;var pt=De.SourceMapConsumer,ft=De.SourceMapGenerator,mt=De.fileURLToPath,gt=De.pathToFileURL,yt=De.isAbsolute,vt=De.resolve,bt=it,wt=De,xt=Be,_t=ht,kt=Symbol("fromOffsetCache"),St=Boolean(pt&&ft),Ct=Boolean(vt&&yt),It=function(){function e(e,t){if(void 0===t&&(t={}),null==e||"object"===(void 0===e?"undefined":E(e))&&!e.toString)throw new Error("PostCSS received "+e+" instead of CSS string");if(this.css=e.toString(),"\ufeff"===this.css[0]||"๏ฟพ"===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,t.from&&(!Ct||/^\w+:\/\//.test(t.from)||yt(t.from)?this.file=t.from:this.file=vt(t.from)),Ct&&St){var r=new _t(this.css,t);if(r.text){this.map=r;var n=r.consumer().file;!this.file&&n&&(this.file=this.mapResolve(n))}}this.file||(this.id="<input css "+bt(6)+">"),this.map&&(this.map.file=this.from)}var t=e.prototype;return t.error=function(e,t,r,n){var i,o,s;if(void 0===n&&(n={}),t&&"object"===(void 0===t?"undefined":E(t))){var a=t,c=r;if("number"==typeof a.offset){var l=this.fromOffset(a.offset);t=l.line,r=l.col}else t=a.line,r=a.column;if("number"==typeof c.offset){var u=this.fromOffset(c.offset);o=u.line,s=u.col}else o=c.line,s=c.column}else if(!r){var d=this.fromOffset(t);t=d.line,r=d.col}var h=this.origin(t,r,o,s);return(i=h?new xt(e,void 0===h.endLine?h.line:{column:h.column,line:h.line},void 0===h.endLine?h.column:{column:h.endColumn,line:h.endLine},h.source,h.file,n.plugin):new xt(e,void 0===o?t:{column:r,line:t},void 0===o?r:{column:s,line:o},this.css,this.file,n.plugin)).input={column:r,endColumn:s,endLine:o,line:t,source:this.css},this.file&&(gt&&(i.input.url=gt(this.file).toString()),i.input.file=this.file),i},t.fromOffset=function(e){var t;if(this[kt])t=this[kt];else{var r=this.css.split("\n");t=new Array(r.length);for(var n=0,i=0,o=r.length;i<o;i++)t[i]=n,n+=r[i].length+1;this[kt]=t}var s=0;if(e>=t[t.length-1])s=t.length-1;else for(var a,c=t.length-2;s<c;)if(e<t[a=s+(c-s>>1)])c=a-1;else{if(!(e>=t[a+1])){s=a;break}s=a+1}return{col:e-t[s]+1,line:s+1}},t.mapResolve=function(e){return/^\w+:\/\//.test(e)?e:vt(this.map.consumer().sourceRoot||this.map.root||".",e)},t.origin=function(e,t,r,n){if(!this.map)return!1;var i,o,s=this.map.consumer(),a=s.originalPositionFor({column:t,line:e});if(!a.source)return!1;"number"==typeof r&&(i=s.originalPositionFor({column:n,line:r})),o=yt(a.source)?gt(a.source):new URL(a.source,this.map.consumer().sourceRoot||gt(this.map.mapFile));var c={column:a.column,endColumn:i&&i.column,endLine:i&&i.line,line:a.line,url:o.toString()};if("file:"===o.protocol){if(!mt)throw new Error("file: protocol is not available in this PostCSS build");c.file=mt(o)}var l=s.sourceContentFor(a.source);return l&&(c.source=l),c},t.toJSON=function(){for(var e={},t=0,r=["hasBOM","css","file","id"];t<r.length;t++){var n=r[t];null!=this[n]&&(e[n]=this[n])}return this.map&&(e.map=x({},this.map),e.map.consumerCache&&(e.map.consumerCache=void 0)),e},w(e,[{key:"from",get:function(){return this.file||this.id}}]),e}(),Et=It;It.default=It,wt&&wt.registerInput&&wt.registerInput(It);var Nt=De.SourceMapConsumer,At=De.SourceMapGenerator,Pt=De.dirname,Ot=De.relative,Mt=De.resolve,Tt=De.sep,Rt=De.pathToFileURL,jt=Et,Dt=Boolean(Nt&&At),Ft=Boolean(Pt&&Mt&&Ot&&Tt),Lt=function(){function e(e,t,r,n){this.stringify=e,this.mapOpts=r.map||{},this.root=t,this.opts=r,this.css=n,this.originalCSS=n,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=new Map,this.memoizedPaths=new Map,this.memoizedURLs=new Map}var t=e.prototype;return t.addAnnotation=function(){var e;e=this.isInline()?"data:application/json;base64,"+this.toBase64(this.map.toString()):"string"==typeof this.mapOpts.annotation?this.mapOpts.annotation:"function"==typeof this.mapOpts.annotation?this.mapOpts.annotation(this.opts.to,this.root):this.outputFile()+".map";var t="\n";this.css.includes("\r\n")&&(t="\r\n"),this.css+=t+"/*# sourceMappingURL="+e+" */"},t.applyPrevMaps=function(){for(var e,t=P(this.previous());!(e=t()).done;){var r=e.value,n=this.toUrl(this.path(r.file)),i=r.root||Pt(r.file),o=void 0;!1===this.mapOpts.sourcesContent?(o=new Nt(r.text)).sourcesContent&&(o.sourcesContent=null):o=r.consumer(),this.map.applySourceMap(o,n,this.toUrl(this.path(i)))}},t.clearAnnotation=function(){if(!1!==this.mapOpts.annotation)if(this.root)for(var e,t=this.root.nodes.length-1;t>=0;t--)"comment"===(e=this.root.nodes[t]).type&&0===e.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(t);else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))},t.generate=function(){if(this.clearAnnotation(),Ft&&Dt&&this.isMap())return this.generateMap();var e="";return this.stringify(this.root,function(t){e+=t}),[e]},t.generateMap=function(){if(this.root)this.generateString();else if(1===this.previous().length){var e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=At.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new At({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]},t.generateString=function(){var e=this;this.css="",this.map=new At({file:this.outputFile(),ignoreInvalidMapping:!0});var t,r,n=1,i=1,o="<no source>",s={generated:{column:0,line:0},original:{column:0,line:0},source:""};this.stringify(this.root,function(a,c,l){if(e.css+=a,c&&"end"!==l&&(s.generated.line=n,s.generated.column=i-1,c.source&&c.source.start?(s.source=e.sourcePath(c),s.original.line=c.source.start.line,s.original.column=c.source.start.column-1,e.map.addMapping(s)):(s.source=o,s.original.line=1,s.original.column=0,e.map.addMapping(s))),(t=a.match(/\n/g))?(n+=t.length,r=a.lastIndexOf("\n"),i=a.length-r):i+=a.length,c&&"start"!==l){var u=c.parent||{raws:{}};("decl"===c.type||"atrule"===c.type&&!c.nodes)&&c===u.last&&!u.raws.semicolon||(c.source&&c.source.end?(s.source=e.sourcePath(c),s.original.line=c.source.end.line,s.original.column=c.source.end.column-1,s.generated.line=n,s.generated.column=i-2,e.map.addMapping(s)):(s.source=o,s.original.line=1,s.original.column=0,s.generated.line=n,s.generated.column=i-1,e.map.addMapping(s)))}})},t.isAnnotation=function(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(function(e){return e.annotation}))},t.isInline=function(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;var e=this.mapOpts.annotation;return(void 0===e||!0===e)&&(!this.previous().length||this.previous().some(function(e){return e.inline}))},t.isMap=function(){return void 0!==this.opts.map?!!this.opts.map:this.previous().length>0},t.isSourcesContent=function(){return void 0!==this.mapOpts.sourcesContent?this.mapOpts.sourcesContent:!this.previous().length||this.previous().some(function(e){return e.withContent()})},t.outputFile=function(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"},t.path=function(e){if(this.mapOpts.absolute)return e;if(60===e.charCodeAt(0))return e;if(/^\w+:\/\//.test(e))return e;var t=this.memoizedPaths.get(e);if(t)return t;var r=this.opts.to?Pt(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(r=Pt(Mt(r,this.mapOpts.annotation)));var n=Ot(r,e);return this.memoizedPaths.set(e,n),n},t.previous=function(){var e=this;if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(function(t){if(t.source&&t.source.input.map){var r=t.source.input.map;e.previousMaps.includes(r)||e.previousMaps.push(r)}});else{var t=new jt(this.originalCSS,this.opts);t.map&&this.previousMaps.push(t.map)}return this.previousMaps},t.setSourcesContent=function(){var e=this,t={};if(this.root)this.root.walk(function(r){if(r.source){var n=r.source.input.from;if(n&&!t[n]){t[n]=!0;var i=e.usesFileUrls?e.toFileUrl(n):e.toUrl(e.path(n));e.map.setSourceContent(i,r.source.input.css)}}});else if(this.css){var r=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(r,this.css)}},t.sourcePath=function(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))},t.toBase64=function(e){return f?f.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))},t.toFileUrl=function(e){var t=this.memoizedFileURLs.get(e);if(t)return t;if(Rt){var r=Rt(e).toString();return this.memoizedFileURLs.set(e,r),r}throw new Error("`map.absolute` option is not available in this PostCSS build")},t.toUrl=function(e){var t=this.memoizedURLs.get(e);if(t)return t;"\\"===Tt&&(e=e.replace(/\\/g,"/"));var r=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,r),r},e}(),Ut=function(e){function t(t){var r;return(r=e.call(this,t)||this).type="comment",r}return k(t,e),t}(tt),Bt=Ut;Ut.default=Ut;var zt,qt,$t,Gt,Wt=ze.isClean,Vt=ze.my,Ht=nt,Yt=Bt;function Zt(e){return e.map(function(e){return e.nodes&&(e.nodes=Zt(e.nodes)),delete e.source,e})}function Kt(e){if(e[Wt]=!1,e.proxyOf.nodes)for(var t,r=P(e.proxyOf.nodes);!(t=r()).done;){Kt(t.value)}}var Jt=function(e){function t(){return e.apply(this,arguments)||this}k(t,e);var r=t.prototype;return r.append=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var n,i=P(t);!(n=i()).done;)for(var o,s=n.value,a=P(this.normalize(s,this.last));!(o=a()).done;){var c=o.value;this.proxyOf.nodes.push(c)}return this.markDirty(),this},r.cleanRaws=function(t){if(e.prototype.cleanRaws.call(this,t),this.nodes)for(var r,n=P(this.nodes);!(r=n()).done;){r.value.cleanRaws(t)}},r.each=function(e){if(this.proxyOf.nodes){for(var t,r,n=this.getIterator();this.indexes[n]<this.proxyOf.nodes.length&&(t=this.indexes[n],!1!==(r=e(this.proxyOf.nodes[t],t)));)this.indexes[n]+=1;return delete this.indexes[n],r}},r.every=function(e){return this.nodes.every(e)},r.getIterator=function(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var e=this.lastEach;return this.indexes[e]=0,e},r.getProxyProcessor=function(){return{get:function(e,t){return"proxyOf"===t?e:e[t]?"each"===t||"string"==typeof t&&t.startsWith("walk")?function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];var o;return(o=e)[t].apply(o,[].concat(n.map(function(e){return"function"==typeof e?function(t,r){return e(t.toProxy(),r)}:e})))}:"every"===t||"some"===t?function(r){return e[t](function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return r.apply(void 0,[].concat([e.toProxy()],n))})}:"root"===t?function(){return e.root().toProxy()}:"nodes"===t?e.nodes.map(function(e){return e.toProxy()}):"first"===t||"last"===t?e[t].toProxy():e[t]:e[t]},set:function(e,t,r){return e[t]===r||(e[t]=r,"name"!==t&&"params"!==t&&"selector"!==t||e.markDirty()),!0}}},r.index=function(e){return"number"==typeof e?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))},r.insertAfter=function(e,t){var r,n=this.index(e),i=this.normalize(t,this.proxyOf.nodes[n]).reverse();n=this.index(e);for(var o,s=P(i);!(o=s()).done;){var a=o.value;this.proxyOf.nodes.splice(n+1,0,a)}for(var c in this.indexes)n<(r=this.indexes[c])&&(this.indexes[c]=r+i.length);return this.markDirty(),this},r.insertBefore=function(e,t){var r,n=this.index(e),i=0===n&&"prepend",o=this.normalize(t,this.proxyOf.nodes[n],i).reverse();n=this.index(e);for(var s,a=P(o);!(s=a()).done;){var c=s.value;this.proxyOf.nodes.splice(n,0,c)}for(var l in this.indexes)n<=(r=this.indexes[l])&&(this.indexes[l]=r+o.length);return this.markDirty(),this},r.normalize=function(e,r){var n=this;if("string"==typeof e)e=Zt(zt(e).nodes);else if(void 0===e)e=[];else if(Array.isArray(e))for(var i,o=P(e=e.slice(0));!(i=o()).done;){var s=i.value;s.parent&&s.parent.removeChild(s,"ignore")}else if("root"===e.type&&"document"!==this.type)for(var a,c=P(e=e.nodes.slice(0));!(a=c()).done;){var l=a.value;l.parent&&l.parent.removeChild(l,"ignore")}else if(e.type)e=[e];else if(e.prop){if(void 0===e.value)throw new Error("Value field is missed in node creation");"string"!=typeof e.value&&(e.value=String(e.value)),e=[new Ht(e)]}else if(e.selector)e=[new qt(e)];else if(e.name)e=[new $t(e)];else{if(!e.text)throw new Error("Unknown node type in node creation");e=[new Yt(e)]}return e.map(function(e){return e[Vt]||t.rebuild(e),(e=e.proxyOf).parent&&e.parent.removeChild(e),e[Wt]&&Kt(e),void 0===e.raws.before&&r&&void 0!==r.raws.before&&(e.raws.before=r.raws.before.replace(/\S/g,"")),e.parent=n.proxyOf,e})},r.prepend=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var n,i=P(t=t.reverse());!(n=i()).done;){for(var o,s=n.value,a=this.normalize(s,this.first,"prepend").reverse(),c=P(a);!(o=c()).done;){var l=o.value;this.proxyOf.nodes.unshift(l)}for(var u in this.indexes)this.indexes[u]=this.indexes[u]+a.length}return this.markDirty(),this},r.push=function(e){return e.parent=this,this.proxyOf.nodes.push(e),this},r.removeAll=function(){for(var e,t=P(this.proxyOf.nodes);!(e=t()).done;){e.value.parent=void 0}return this.proxyOf.nodes=[],this.markDirty(),this},r.removeChild=function(e){var t;for(var r in e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1),this.indexes)(t=this.indexes[r])>=e&&(this.indexes[r]=t-1);return this.markDirty(),this},r.replaceValues=function(e,t,r){return r||(r=t,t={}),this.walkDecls(function(n){t.props&&!t.props.includes(n.prop)||t.fast&&!n.value.includes(t.fast)||(n.value=n.value.replace(e,r))}),this.markDirty(),this},r.some=function(e){return this.nodes.some(e)},r.walk=function(e){return this.each(function(t,r){var n;try{n=e(t,r)}catch(i){throw t.addToError(i)}return!1!==n&&t.walk&&(n=t.walk(e)),n})},r.walkAtRules=function(e,t){return t?S(e,RegExp)?this.walk(function(r,n){if("atrule"===r.type&&e.test(r.name))return t(r,n)}):this.walk(function(r,n){if("atrule"===r.type&&r.name===e)return t(r,n)}):(t=e,this.walk(function(e,r){if("atrule"===e.type)return t(e,r)}))},r.walkComments=function(e){return this.walk(function(t,r){if("comment"===t.type)return e(t,r)})},r.walkDecls=function(e,t){return t?S(e,RegExp)?this.walk(function(r,n){if("decl"===r.type&&e.test(r.prop))return t(r,n)}):this.walk(function(r,n){if("decl"===r.type&&r.prop===e)return t(r,n)}):(t=e,this.walk(function(e,r){if("decl"===e.type)return t(e,r)}))},r.walkRules=function(e,t){return t?S(e,RegExp)?this.walk(function(r,n){if("rule"===r.type&&e.test(r.selector))return t(r,n)}):this.walk(function(r,n){if("rule"===r.type&&r.selector===e)return t(r,n)}):(t=e,this.walk(function(e,r){if("rule"===e.type)return t(e,r)}))},w(t,[{key:"first",get:function(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}},{key:"last",get:function(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}}]),t}(tt);Jt.registerParse=function(e){zt=e},Jt.registerRule=function(e){qt=e},Jt.registerAtRule=function(e){$t=e},Jt.registerRoot=function(e){Gt=e};var Xt=Jt;Jt.default=Jt,Jt.rebuild=function(e){"atrule"===e.type?Object.setPrototypeOf(e,$t.prototype):"rule"===e.type?Object.setPrototypeOf(e,qt.prototype):"decl"===e.type?Object.setPrototypeOf(e,Ht.prototype):"comment"===e.type?Object.setPrototypeOf(e,Yt.prototype):"root"===e.type&&Object.setPrototypeOf(e,Gt.prototype),e[Vt]=!0,e.nodes&&e.nodes.forEach(function(e){Jt.rebuild(e)})};var Qt,er,tr=function(e){function t(t){var r;return(r=e.call(this,x({type:"document"},t))||this).nodes||(r.nodes=[]),r}return k(t,e),t.prototype.toResult=function(e){return void 0===e&&(e={}),new Qt(new er,this,e).stringify()},t}(Xt);tr.registerLazyResult=function(e){Qt=e},tr.registerProcessor=function(e){er=e};var rr=tr;tr.default=tr;var nr=function(){function e(e,t){if(void 0===t&&(t={}),this.type="warning",this.text=e,t.node&&t.node.source){var r=t.node.rangeBy(t);this.line=r.start.line,this.column=r.start.column,this.endLine=r.end.line,this.endColumn=r.end.column}for(var n in t)this[n]=t[n]}return e.prototype.toString=function(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text},e}(),ir=nr;nr.default=nr;var or=ir,sr=function(){function e(e,t,r){this.processor=e,this.messages=[],this.root=t,this.opts=r,this.css=void 0,this.map=void 0}var t=e.prototype;return t.toString=function(){return this.css},t.warn=function(e,t){void 0===t&&(t={}),t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);var r=new or(e,t);return this.messages.push(r),r},t.warnings=function(){return this.messages.filter(function(e){return"warning"===e.type})},w(e,[{key:"content",get:function(){return this.css}}]),e}(),ar=sr;sr.default=sr;var cr="'".charCodeAt(0),lr='"'.charCodeAt(0),ur="\\".charCodeAt(0),dr="/".charCodeAt(0),hr="\n".charCodeAt(0),pr=" ".charCodeAt(0),fr="\f".charCodeAt(0),mr="\t".charCodeAt(0),gr="\r".charCodeAt(0),yr="[".charCodeAt(0),vr="]".charCodeAt(0),br="(".charCodeAt(0),wr=")".charCodeAt(0),xr="{".charCodeAt(0),_r="}".charCodeAt(0),kr=";".charCodeAt(0),Sr="*".charCodeAt(0),Cr=":".charCodeAt(0),Ir="@".charCodeAt(0),Er=/[\t\n\f\r "#'()/;[\\\]{}]/g,Nr=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,Ar=/.[\r\n"'(/\\]/,Pr=/[\da-f]/i,Or=Xt,Mr=function(e){function t(t){var r;return(r=e.call(this,t)||this).type="atrule",r}k(t,e);var r=t.prototype;return r.append=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];var i;return this.proxyOf.nodes||(this.nodes=[]),(i=e.prototype.append).call.apply(i,[].concat([this],r))},r.prepend=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];var i;return this.proxyOf.nodes||(this.nodes=[]),(i=e.prototype.prepend).call.apply(i,[].concat([this],r))},t}(Or),Tr=Mr;Mr.default=Mr,Or.registerAtRule(Mr);var Rr,jr,Dr=Xt,Fr=function(e){function t(t){var r;return(r=e.call(this,t)||this).type="root",r.nodes||(r.nodes=[]),r}k(t,e);var r=t.prototype;return r.normalize=function(t,r,n){var i=e.prototype.normalize.call(this,t);if(r)if("prepend"===n)this.nodes.length>1?r.raws.before=this.nodes[1].raws.before:delete r.raws.before;else if(this.first!==r)for(var o,s=P(i);!(o=s()).done;){o.value.raws.before=r.raws.before}return i},r.removeChild=function(t,r){var n=this.index(t);return!r&&0===n&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),e.prototype.removeChild.call(this,t)},r.toResult=function(e){return void 0===e&&(e={}),new Rr(new jr,this,e).stringify()},t}(Dr);Fr.registerLazyResult=function(e){Rr=e},Fr.registerProcessor=function(e){jr=e};var Lr=Fr;Fr.default=Fr,Dr.registerRoot(Fr);var Ur={comma:function(e){return Ur.split(e,[","],!0)},space:function(e){return Ur.split(e,[" ","\n","\t"])},split:function(e,t,r){for(var n,i=[],o="",s=!1,a=0,c=!1,l="",u=!1,d=P(e);!(n=d()).done;){var h=n.value;u?u=!1:"\\"===h?u=!0:c?h===l&&(c=!1):'"'===h||"'"===h?(c=!0,l=h):"("===h?a+=1:")"===h?a>0&&(a-=1):0===a&&t.includes(h)&&(s=!0),s?(""!==o&&i.push(o.trim()),o="",s=!1):o+=h}return(r||""!==o)&&i.push(o.trim()),i}},Br=Ur;Ur.default=Ur;var zr=Xt,qr=Br,$r=function(e){function t(t){var r;return(r=e.call(this,t)||this).type="rule",r.nodes||(r.nodes=[]),r}return k(t,e),w(t,[{key:"selectors",get:function(){return qr.comma(this.selector)},set:function(e){var t=this.selector?this.selector.match(/,\s*/):null,r=t?t[0]:","+this.raw("between","beforeOpen");this.selector=e.join(r)}}]),t}(zr),Gr=$r;$r.default=$r,zr.registerRule($r);var Wr=nt,Vr=function(e,t){void 0===t&&(t={});var r,n,i,o,s,a,c,l,u,d,h=e.css.valueOf(),p=t.ignoreErrors,f=h.length,m=0,g=[],y=[];function v(t){throw e.error("Unclosed "+t,m)}return{back:function(e){y.push(e)},endOfFile:function(){return 0===y.length&&m>=f},nextToken:function(e){if(y.length)return y.pop();if(!(m>=f)){var t=!!e&&e.ignoreUnclosed;switch(r=h.charCodeAt(m)){case hr:case pr:case mr:case gr:case fr:n=m;do{n+=1,r=h.charCodeAt(n)}while(r===pr||r===hr||r===mr||r===gr||r===fr);d=["space",h.slice(m,n)],m=n-1;break;case yr:case vr:case xr:case _r:case Cr:case kr:case wr:var b=String.fromCharCode(r);d=[b,b,m];break;case br:if(l=g.length?g.pop()[1]:"",u=h.charCodeAt(m+1),"url"===l&&u!==cr&&u!==lr&&u!==pr&&u!==hr&&u!==mr&&u!==fr&&u!==gr){n=m;do{if(a=!1,-1===(n=h.indexOf(")",n+1))){if(p||t){n=m;break}v("bracket")}for(c=n;h.charCodeAt(c-1)===ur;)c-=1,a=!a}while(a);d=["brackets",h.slice(m,n+1),m,n],m=n}else n=h.indexOf(")",m+1),o=h.slice(m,n+1),-1===n||Ar.test(o)?d=["(","(",m]:(d=["brackets",o,m,n],m=n);break;case cr:case lr:i=r===cr?"'":'"',n=m;do{if(a=!1,-1===(n=h.indexOf(i,n+1))){if(p||t){n=m+1;break}v("string")}for(c=n;h.charCodeAt(c-1)===ur;)c-=1,a=!a}while(a);d=["string",h.slice(m,n+1),m,n],m=n;break;case Ir:Er.lastIndex=m+1,Er.test(h),n=0===Er.lastIndex?h.length-1:Er.lastIndex-2,d=["at-word",h.slice(m,n+1),m,n],m=n;break;case ur:for(n=m,s=!0;h.charCodeAt(n+1)===ur;)n+=1,s=!s;if(r=h.charCodeAt(n+1),s&&r!==dr&&r!==pr&&r!==hr&&r!==mr&&r!==gr&&r!==fr&&(n+=1,Pr.test(h.charAt(n)))){for(;Pr.test(h.charAt(n+1));)n+=1;h.charCodeAt(n+1)===pr&&(n+=1)}d=["word",h.slice(m,n+1),m,n],m=n;break;default:r===dr&&h.charCodeAt(m+1)===Sr?(0===(n=h.indexOf("*/",m+2)+1)&&(p||t?n=h.length:v("comment")),d=["comment",h.slice(m,n+1),m,n],m=n):(Nr.lastIndex=m+1,Nr.test(h),n=0===Nr.lastIndex?h.length-1:Nr.lastIndex-2,d=["word",h.slice(m,n+1),m,n],g.push(d),m=n)}return m++,d}},position:function(){return m}}},Hr=Bt,Yr=Tr,Zr=Lr,Kr=Gr,Jr={empty:!0,space:!0};var Xr=function(){function e(e){this.input=e,this.root=new Zr,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}var t=e.prototype;return t.atrule=function(e){var t,r,n,i=new Yr;i.name=e[1].slice(1),""===i.name&&this.unnamedAtrule(i,e),this.init(i,e[2]);for(var o=!1,s=!1,a=[],c=[];!this.tokenizer.endOfFile();){if("("===(t=(e=this.tokenizer.nextToken())[0])||"["===t?c.push("("===t?")":"]"):"{"===t&&c.length>0?c.push("}"):t===c[c.length-1]&&c.pop(),0===c.length){if(";"===t){i.source.end=this.getPosition(e[2]),i.source.end.offset++,this.semicolon=!0;break}if("{"===t){s=!0;break}if("}"===t){if(a.length>0){for(r=a[n=a.length-1];r&&"space"===r[0];)r=a[--n];r&&(i.source.end=this.getPosition(r[3]||r[2]),i.source.end.offset++)}this.end(e);break}a.push(e)}else a.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(i.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(i,"params",a),o&&(e=a[a.length-1],i.source.end=this.getPosition(e[3]||e[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),s&&(i.nodes=[],this.current=i)},t.checkMissedSemicolon=function(e){var t=this.colon(e);if(!1!==t){for(var r,n=0,i=t-1;i>=0&&("space"===(r=e[i])[0]||2!==(n+=1));i--);throw this.input.error("Missed semicolon","word"===r[0]?r[3]+1:r[2])}},t.colon=function(e){for(var t,r,n,i,o=0,s=P(e.entries());!(i=s()).done;){var a=i.value,c=a[0];if("("===(r=(t=a[1])[0])&&(o+=1),")"===r&&(o-=1),0===o&&":"===r){if(n){if("word"===n[0]&&"progid"===n[1])continue;return c}this.doubleColon(t)}n=t}return!1},t.comment=function(e){var t=new Hr;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;var r=e[1].slice(2,-2);if(/^\s*$/.test(r))t.text="",t.raws.left=r,t.raws.right="";else{var n=r.match(/^(\s*)([^]*\S)(\s*)$/);t.text=n[2],t.raws.left=n[1],t.raws.right=n[3]}},t.createTokenizer=function(){this.tokenizer=Vr(this.input)},t.decl=function(e,t){var r=new Wr;this.init(r,e[0][2]);var n,i=e[e.length-1];for(";"===i[0]&&(this.semicolon=!0,e.pop()),r.source.end=this.getPosition(i[3]||i[2]||function(e){for(var t=e.length-1;t>=0;t--){var r=e[t],n=r[3]||r[2];if(n)return n}}(e)),r.source.end.offset++;"word"!==e[0][0];)1===e.length&&this.unknownWord(e),r.raws.before+=e.shift()[1];for(r.source.start=this.getPosition(e[0][2]),r.prop="";e.length;){var o=e[0][0];if(":"===o||"space"===o||"comment"===o)break;r.prop+=e.shift()[1]}for(r.raws.between="";e.length;){if(":"===(n=e.shift())[0]){r.raws.between+=n[1];break}"word"===n[0]&&/\w/.test(n[1])&&this.unknownWord([n]),r.raws.between+=n[1]}"_"!==r.prop[0]&&"*"!==r.prop[0]||(r.raws.before+=r.prop[0],r.prop=r.prop.slice(1));for(var s,a=[];e.length&&("space"===(s=e[0][0])||"comment"===s);)a.push(e.shift());this.precheckMissedSemicolon(e);for(var c=e.length-1;c>=0;c--){if("!important"===(n=e[c])[1].toLowerCase()){r.important=!0;var l=this.stringFrom(e,c);" !important"!==(l=this.spacesFromEnd(e)+l)&&(r.raws.important=l);break}if("important"===n[1].toLowerCase()){for(var u=e.slice(0),d="",h=c;h>0;h--){var p=u[h][0];if(0===d.trim().indexOf("!")&&"space"!==p)break;d=u.pop()[1]+d}0===d.trim().indexOf("!")&&(r.important=!0,r.raws.important=d,e=u)}if("space"!==n[0]&&"comment"!==n[0])break}e.some(function(e){return"space"!==e[0]&&"comment"!==e[0]})&&(r.raws.between+=a.map(function(e){return e[1]}).join(""),a=[]),this.raw(r,"value",a.concat(e),t),r.value.includes(":")&&!t&&this.checkMissedSemicolon(e)},t.doubleColon=function(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})},t.emptyRule=function(e){var t=new Kr;this.init(t,e[2]),t.selector="",t.raws.between="",this.current=t},t.end=function(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)},t.endFile=function(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())},t.freeSemicolon=function(e){if(this.spaces+=e[1],this.current.nodes){var t=this.current.nodes[this.current.nodes.length-1];t&&"rule"===t.type&&!t.raws.ownSemicolon&&(t.raws.ownSemicolon=this.spaces,this.spaces="")}},t.getPosition=function(e){var t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}},t.init=function(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces="","comment"!==e.type&&(this.semicolon=!1)},t.other=function(e){for(var t=!1,r=null,n=!1,i=null,o=[],s=e[1].startsWith("--"),a=[],c=e;c;){if(r=c[0],a.push(c),"("===r||"["===r)i||(i=c),o.push("("===r?")":"]");else if(s&&n&&"{"===r)i||(i=c),o.push("}");else if(0===o.length){if(";"===r){if(n)return void this.decl(a,s);break}if("{"===r)return void this.rule(a);if("}"===r){this.tokenizer.back(a.pop()),t=!0;break}":"===r&&(n=!0)}else r===o[o.length-1]&&(o.pop(),0===o.length&&(i=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),o.length>0&&this.unclosedBracket(i),t&&n){if(!s)for(;a.length&&("space"===(c=a[a.length-1][0])||"comment"===c);)this.tokenizer.back(a.pop());this.decl(a,s)}else this.unknownWord(a)},t.parse=function(){for(var e;!this.tokenizer.endOfFile();)switch((e=this.tokenizer.nextToken())[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e)}this.endFile()},t.precheckMissedSemicolon=function(){},t.raw=function(e,t,r,n){for(var i,o,s,a,c=r.length,l="",u=!0,d=0;d<c;d+=1)"space"!==(o=(i=r[d])[0])||d!==c-1||n?"comment"===o?(a=r[d-1]?r[d-1][0]:"empty",s=r[d+1]?r[d+1][0]:"empty",Jr[a]||Jr[s]||","===l.slice(-1)?u=!1:l+=i[1]):l+=i[1]:u=!1;if(!u){var h=r.reduce(function(e,t){return e+t[1]},"");e.raws[t]={raw:h,value:l}}e[t]=l},t.rule=function(e){e.pop();var t=new Kr;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t},t.spacesAndCommentsFromEnd=function(e){for(var t,r="";e.length&&("space"===(t=e[e.length-1][0])||"comment"===t);)r=e.pop()[1]+r;return r},t.spacesAndCommentsFromStart=function(e){for(var t,r="";e.length&&("space"===(t=e[0][0])||"comment"===t);)r+=e.shift()[1];return r},t.spacesFromEnd=function(e){for(var t="";e.length&&"space"===e[e.length-1][0];)t=e.pop()[1]+t;return t},t.stringFrom=function(e,t){for(var r="",n=t;n<e.length;n++)r+=e[n][1];return e.splice(t,e.length-t),r},t.unclosedBlock=function(){var e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)},t.unclosedBracket=function(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})},t.unexpectedClose=function(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})},t.unknownWord=function(e){throw this.input.error("Unknown word",{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})},t.unnamedAtrule=function(e,t){throw this.input.error("At-rule without name",{offset:t[2]},{offset:t[2]+t[1].length})},e}(),Qr=Xt,en=Xr,tn=Et;function rn(e,t){var r=new tn(e,t),n=new en(r);try{n.parse()}catch(i){throw i}return n.root}var nn=rn;rn.default=rn,Qr.registerParse(rn);var on=ze.isClean,sn=ze.my,an=Lt,cn=He,ln=Xt,un=rr,dn=ar,hn=nn,pn=Lr,fn={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},mn={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},gn={Once:!0,postcssPlugin:!0,prepare:!0};function yn(e){return"object"===(void 0===e?"undefined":E(e))&&"function"==typeof e.then}function vn(e){var t=!1,r=fn[e.type];return"decl"===e.type?t=e.prop.toLowerCase():"atrule"===e.type&&(t=e.name.toLowerCase()),t&&e.append?[r,r+"-"+t,0,r+"Exit",r+"Exit-"+t]:t?[r,r+"-"+t,r+"Exit",r+"Exit-"+t]:e.append?[r,0,r+"Exit"]:[r,r+"Exit"]}function bn(e){return{eventIndex:0,events:"document"===e.type?["Document",0,"DocumentExit"]:"root"===e.type?["Root",0,"RootExit"]:vn(e),iterator:0,node:e,visitorIndex:0,visitors:[]}}function wn(e){return e[on]=!1,e.nodes&&e.nodes.forEach(function(e){return wn(e)}),e}var xn={},_n=function(){function e(t,r,n){var i,o=this;if(this.stringified=!1,this.processed=!1,"object"!==(void 0===r?"undefined":E(r))||null===r||"root"!==r.type&&"document"!==r.type)if(S(r,e)||S(r,dn))i=wn(r.root),r.map&&(void 0===n.map&&(n.map={}),n.map.inline||(n.map.inline=!1),n.map.prev=r.map);else{var s=hn;n.syntax&&(s=n.syntax.parse),n.parser&&(s=n.parser),s.parse&&(s=s.parse);try{i=s(r,n)}catch(gu){this.processed=!0,this.error=gu}i&&!i[sn]&&ln.rebuild(i)}else i=wn(r);this.result=new dn(t,i,n),this.helpers=x({},xn,{postcss:xn,result:this.result}),this.plugins=this.processor.plugins.map(function(e){return"object"===(void 0===e?"undefined":E(e))&&e.prepare?x({},e,e.prepare(o.result)):e})}var t=e.prototype;return t.async=function(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)},t.catch=function(e){return this.async().catch(e)},t.finally=function(e){return this.async().then(e,e)},t.getAsyncError=function(){throw new Error("Use process(css).then(cb) to work with async plugins")},t.handleError=function(e,t){var r=this.result.lastPlugin;try{if(t&&t.addToError(e),this.error=e,"CssSyntaxError"!==e.name||e.plugin){if(r.postcssVersion){0}}else e.plugin=r.postcssPlugin,e.setMessage()}catch(n){console&&console.error&&console.error(n)}return e},t.prepareVisitors=function(){var e=this;this.listeners={};for(var t,r=function(t,r,n){e.listeners[r]||(e.listeners[r]=[]),e.listeners[r].push([t,n])},n=P(this.plugins);!(t=n()).done;){var i=t.value;if("object"===(void 0===i?"undefined":E(i)))for(var o in i){if(!mn[o]&&/^[A-Z]/.test(o))throw new Error("Unknown event "+o+" in "+i.postcssPlugin+". Try to update PostCSS ("+this.processor.version+" now).");if(!gn[o])if("object"===E(i[o]))for(var s in i[o])r(i,"*"===s?o:o+"-"+s.toLowerCase(),i[o][s]);else"function"==typeof i[o]&&r(i,o,i[o])}}this.hasListener=Object.keys(this.listeners).length>0},t.runAsync=function(){var e=this;return v(function(){var t,r,n,i,o,s,a,c,l,u,d,h;return O(this,function(p){switch(p.label){case 0:e.plugin=0,t=0,p.label=1;case 1:if(!(t<e.plugins.length))return[3,6];if(r=e.plugins[t],!yn(n=e.runOnRoot(r)))return[3,5];p.label=2;case 2:return p.trys.push([2,4,,5]),[4,n];case 3:return p.sent(),[3,5];case 4:throw i=p.sent(),e.handleError(i);case 5:return t++,[3,1];case 6:if(e.prepareVisitors(),!e.hasListener)return[3,18];o=e.result.root,p.label=7;case 7:if(o[on])return[3,14];o[on]=!0,s=[bn(o)],p.label=8;case 8:if(!(s.length>0))return[3,13];if(!yn(a=e.visitTick(s)))return[3,12];p.label=9;case 9:return p.trys.push([9,11,,12]),[4,a];case 10:return p.sent(),[3,12];case 11:throw c=p.sent(),l=s[s.length-1].node,e.handleError(c,l);case 12:return[3,8];case 13:return[3,7];case 14:if(!e.listeners.OnceExit)return[3,18];u=function(){var t,r,n,i,s;return O(this,function(a){switch(a.label){case 0:t=h.value,r=t[0],n=t[1],e.result.lastPlugin=r,a.label=1;case 1:return a.trys.push([1,6,,7]),"document"!==o.type?[3,3]:(i=o.nodes.map(function(t){return n(t,e.helpers)}),[4,Promise.all(i)]);case 2:return a.sent(),[3,5];case 3:return[4,n(o,e.helpers)];case 4:a.sent(),a.label=5;case 5:return[3,7];case 6:throw s=a.sent(),e.handleError(s);case 7:return[2]}})},d=P(e.listeners.OnceExit),p.label=15;case 15:return(h=d()).done?[3,18]:[5,M(u())];case 16:p.sent(),p.label=17;case 17:return[3,15];case 18:return e.processed=!0,[2,e.stringify()]}})})()},t.runOnRoot=function(e){var t=this;this.result.lastPlugin=e;try{if("object"===(void 0===e?"undefined":E(e))&&e.Once){if("document"===this.result.root.type){var r=this.result.root.nodes.map(function(r){return e.Once(r,t.helpers)});return yn(r[0])?Promise.all(r):r}return e.Once(this.result.root,this.helpers)}if("function"==typeof e)return e(this.result.root,this.result)}catch(gu){throw this.handleError(gu)}},t.stringify=function(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();var e=this.result.opts,t=cn;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);var r=new an(t,this.result.root,this.result.opts).generate();return this.result.css=r[0],this.result.map=r[1],this.result},t.sync=function(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(var e,t=P(this.plugins);!(e=t()).done;){var r=e.value;if(yn(this.runOnRoot(r)))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){for(var n=this.result.root;!n[on];)n[on]=!0,this.walkSync(n);if(this.listeners.OnceExit)if("document"===n.type)for(var i,o=P(n.nodes);!(i=o()).done;){var s=i.value;this.visitSync(this.listeners.OnceExit,s)}else this.visitSync(this.listeners.OnceExit,n)}return this.result},t.then=function(e,t){return this.async().then(e,t)},t.toString=function(){return this.css},t.visitSync=function(e,t){for(var r,n=P(e);!(r=n()).done;){var i=r.value,o=i[0],s=i[1];this.result.lastPlugin=o;var a=void 0;try{a=s(t,this.helpers)}catch(c){throw this.handleError(c,t.proxyOf)}if("root"!==t.type&&"document"!==t.type&&!t.parent)return!0;if(yn(a))throw this.getAsyncError()}},t.visitTick=function(e){var t=e[e.length-1],r=t.node,n=t.visitors;if("root"===r.type||"document"===r.type||r.parent){if(n.length>0&&t.visitorIndex<n.length){var i=n[t.visitorIndex],o=i[0],s=i[1];t.visitorIndex+=1,t.visitorIndex===n.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=o;try{return s(r.toProxy(),this.helpers)}catch(d){throw this.handleError(d,r)}}if(0!==t.iterator){for(var a,c=t.iterator;a=r.nodes[r.indexes[c]];)if(r.indexes[c]+=1,!a[on])return a[on]=!0,void e.push(bn(a));t.iterator=0,delete r.indexes[c]}for(var l=t.events;t.eventIndex<l.length;){var u=l[t.eventIndex];if(t.eventIndex+=1,0===u)return void(r.nodes&&r.nodes.length&&(r[on]=!0,t.iterator=r.getIterator()));if(this.listeners[u])return void(t.visitors=this.listeners[u])}e.pop()}else e.pop()},t.walkSync=function(e){var t=this;e[on]=!0;for(var r,n=P(vn(e));!(r=n()).done;){var i=r.value;if(0===i)e.nodes&&e.each(function(e){e[on]||t.walkSync(e)});else{var o=this.listeners[i];if(o&&this.visitSync(o,e.toProxy()))return}}},t.warnings=function(){return this.sync().warnings()},w(e,[{key:"content",get:function(){return this.stringify().content}},{key:"css",get:function(){return this.stringify().css}},{key:"map",get:function(){return this.stringify().map}},{key:"messages",get:function(){return this.sync().messages}},{key:"opts",get:function(){return this.result.opts}},{key:"processor",get:function(){return this.result.processor}},{key:"root",get:function(){return this.sync().root}},{key:Symbol.toStringTag,get:function(){return"LazyResult"}}]),e}();_n.registerPostcss=function(e){xn=e};var kn=_n;_n.default=_n,pn.registerLazyResult(_n),un.registerLazyResult(_n);var Sn=Lt,Cn=He,In=nn,En=ar,Nn=function(){function e(e,t,r){var n;t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=r,this._map=void 0;var i=Cn;this.result=new En(this._processor,n,this._opts),this.result.css=t;var o=this;Object.defineProperty(this.result,"root",{get:function(){return o.root}});var s=new Sn(i,n,this._opts,t);if(s.isMap()){var a=s.generate(),c=a[0],l=a[1];c&&(this.result.css=c),l&&(this.result.map=l)}else s.clearAnnotation(),this.result.css=s.css}var t=e.prototype;return t.async=function(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)},t.catch=function(e){return this.async().catch(e)},t.finally=function(e){return this.async().then(e,e)},t.sync=function(){if(this.error)throw this.error;return this.result},t.then=function(e,t){return this.async().then(e,t)},t.toString=function(){return this._css},t.warnings=function(){return[]},w(e,[{key:"content",get:function(){return this.result.css}},{key:"css",get:function(){return this.result.css}},{key:"map",get:function(){return this.result.map}},{key:"messages",get:function(){return[]}},{key:"opts",get:function(){return this.result.opts}},{key:"processor",get:function(){return this.result.processor}},{key:"root",get:function(){if(this._root)return this._root;var e,t=In;try{e=t(this._css,this._opts)}catch(gu){this.error=gu}if(this.error)throw this.error;return this._root=e,e}},{key:Symbol.toStringTag,get:function(){return"NoWorkResult"}}]),e}(),An=Nn;Nn.default=Nn;var Pn=An,On=kn,Mn=rr,Tn=Lr,Rn=function(){function e(e){void 0===e&&(e=[]),this.version="8.4.38",this.plugins=this.normalize(e)}var t=e.prototype;return t.normalize=function(e){for(var t,r=[],n=P(e);!(t=n()).done;){var i=t.value;if(!0===i.postcss?i=i():i.postcss&&(i=i.postcss),"object"===(void 0===i?"undefined":E(i))&&Array.isArray(i.plugins))r=r.concat(i.plugins);else if("object"===(void 0===i?"undefined":E(i))&&i.postcssPlugin)r.push(i);else if("function"==typeof i)r.push(i);else if("object"!==(void 0===i?"undefined":E(i))||!i.parse&&!i.stringify)throw new Error(i+" is not a PostCSS plugin")}return r},t.process=function(e,t){return void 0===t&&(t={}),this.plugins.length||t.parser||t.stringifier||t.syntax?new On(this,e,t):new Pn(this,e,t)},t.use=function(e){return this.plugins=this.plugins.concat(this.normalize([e])),this},e}(),jn=Rn;Rn.default=Rn,Tn.registerProcessor(Rn),Mn.registerProcessor(Rn);var Dn=nt,Fn=ht,Ln=Bt,Un=Tr,Bn=Et,zn=Lr,qn=Gr;function $n(e,t){if(Array.isArray(e))return e.map(function(e){return $n(e)});var r=e.inputs,n=C(e,["inputs"]);if(r){t=[];for(var i,o=P(r);!(i=o()).done;){var s=x({},i.value,{__proto__:Bn.prototype});s.map&&(s.map=x({},s.map,{__proto__:Fn.prototype})),t.push(s)}}if(n.nodes&&(n.nodes=e.nodes.map(function(e){return $n(e,t)})),n.source){var a=n.source,c=a.inputId,l=C(a,["inputId"]);n.source=l,null!=c&&(n.source.input=t[c])}if("root"===n.type)return new zn(n);if("decl"===n.type)return new Dn(n);if("rule"===n.type)return new qn(n);if("comment"===n.type)return new Ln(n);if("atrule"===n.type)return new Un(n);throw new Error("Unknown node type: "+e.type)}var Gn=$n;$n.default=$n;var Wn=Be,Vn=nt,Hn=kn,Yn=Xt,Zn=jn,Kn=He,Jn=Gn,Xn=rr,Qn=ir,ei=Bt,ti=Tr,ri=ar,ni=Et,ii=nn,oi=Br,si=Gr,ai=Lr,ci=tt;function li(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 1===t.length&&Array.isArray(t[0])&&(t=t[0]),new Zn(t)}li.plugin=function(e,t){var r,n=!1;function i(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];console&&console.warn&&!n&&(n=!0,console.warn(e+": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration"),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(e+": ้้ข postcss.plugin ่ขซๅผ็จ. ่ฟ็งปๆๅ:\nhttps://www.w3ctech.com/topic/2226"));var s=t.apply(void 0,[].concat(i));return s.postcssPlugin=e,s.postcssVersion=(new Zn).version,s}return Object.defineProperty(i,"postcss",{get:function(){return r||(r=i()),r}}),i.process=function(e,t,r){return li([i(r)]).process(e,t)},i},li.stringify=Kn,li.parse=ii,li.fromJSON=Jn,li.list=oi,li.comment=function(e){return new ei(e)},li.atRule=function(e){return new ti(e)},li.decl=function(e){return new Vn(e)},li.rule=function(e){return new si(e)},li.root=function(e){return new ai(e)},li.document=function(e){return new Xn(e)},li.CssSyntaxError=Wn,li.Declaration=Vn,li.Container=Yn,li.Processor=Zn,li.Document=Xn,li.Comment=ei,li.Warning=Qn,li.AtRule=ti,li.Result=ri,li.Input=ni,li.Rule=si,li.Root=ai,li.Node=ci,Hn.registerPostcss(li);var ui=li;li.default=li;var di=Pe(ui);di.stringify,di.fromJSON,di.plugin,di.parse,di.list,di.document,di.comment,di.atRule,di.rule,di.decl,di.root,di.CssSyntaxError,di.Declaration,di.Container,di.Processor,di.Document,di.Comment,di.Warning,di.AtRule,di.Result,di.Input,di.Rule,di.Root,di.Node;var hi=Object.defineProperty,pi=function(e,t,r){return function(e,t,r){return t in e?hi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r}(e,"symbol"!==(void 0===t?"undefined":E(t))?t+"":t,r)};function fi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function mi(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return S(this,e)?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}var gi={exports:{}},yi=String,vi=function(){return{isColorSupported:!1,reset:yi,bold:yi,dim:yi,italic:yi,underline:yi,inverse:yi,hidden:yi,strikethrough:yi,black:yi,red:yi,green:yi,yellow:yi,blue:yi,magenta:yi,cyan:yi,white:yi,gray:yi,bgBlack:yi,bgRed:yi,bgGreen:yi,bgYellow:yi,bgBlue:yi,bgMagenta:yi,bgCyan:yi,bgWhite:yi}};gi.exports=vi(),gi.exports.createColors=vi;var bi=gi.exports,wi=mi(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}))),xi=bi,_i=wi,ki=function(e){function t(r,n,i,o,s,a){var c;return(c=e.call(this,r)||this).name="CssSyntaxError",c.reason=r,s&&(c.file=s),o&&(c.source=o),a&&(c.plugin=a),void 0!==n&&void 0!==i&&("number"==typeof n?(c.line=n,c.column=i):(c.line=n.line,c.column=n.column,c.endLine=i.line,c.endColumn=i.column)),c.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(c,t),c}k(t,e);var r=t.prototype;return r.setMessage=function(){this.message=this.plugin?this.plugin+": ":"",this.message+=this.file?this.file:"<css input>",void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason},r.showSourceCode=function(e){var t=this;if(!this.source)return"";var r=this.source;null==e&&(e=xi.isColorSupported),_i&&e&&(r=_i(r));var n,i,o=r.split(/\r?\n/),s=Math.max(this.line-3,0),a=Math.min(this.line+2,o.length),c=String(a).length;if(e){var l=xi.createColors(!0),u=l.bold,d=l.gray,h=l.red;n=function(e){return u(h(e))},i=function(e){return d(e)}}else n=i=function(e){return e};return o.slice(s,a).map(function(e,r){var o=s+1+r,a=" "+(" "+o).slice(-c)+" | ";if(o===t.line){var l=i(a.replace(/\d/g," "))+e.slice(0,t.column-1).replace(/[^\t]/g," ");return n(">")+i(a)+e+"\n "+l+n("^")}return" "+i(a)+e}).join("\n")},r.toString=function(){var e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e},t}(N(Error)),Si=ki;ki.default=ki;var Ci={};Ci.isClean=Symbol("isClean"),Ci.my=Symbol("my");var Ii={after:"\n",beforeClose:"\n",beforeComment:"\n",beforeDecl:"\n",beforeOpen:" ",beforeRule:"\n",colon:": ",commentLeft:" ",commentRight:" ",emptyBody:"",indent:" ",semicolon:!1};var Ei=function(){function e(e){this.builder=e}var t=e.prototype;return t.atrule=function(e,t){var r="@"+e.name,n=e.params?this.rawValue(e,"params"):"";if(void 0!==e.raws.afterName?r+=e.raws.afterName:n&&(r+=" "),e.nodes)this.block(e,r+n);else{var i=(e.raws.between||"")+(t?";":"");this.builder(r+n+i,e)}},t.beforeAfter=function(e,t){var r;r="decl"===e.type?this.raw(e,null,"beforeDecl"):"comment"===e.type?this.raw(e,null,"beforeComment"):"before"===t?this.raw(e,null,"beforeRule"):this.raw(e,null,"beforeClose");for(var n=e.parent,i=0;n&&"root"!==n.type;)i+=1,n=n.parent;if(r.includes("\n")){var o=this.raw(e,null,"indent");if(o.length)for(var s=0;s<i;s++)r+=o}return r},t.block=function(e,t){var r,n=this.raw(e,"between","beforeOpen");this.builder(t+n+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),r=this.raw(e,"after")):r=this.raw(e,"after","emptyBody"),r&&this.builder(r),this.builder("}",e,"end")},t.body=function(e){for(var t=e.nodes.length-1;t>0&&"comment"===e.nodes[t].type;)t-=1;for(var r=this.raw(e,"semicolon"),n=0;n<e.nodes.length;n++){var i=e.nodes[n],o=this.raw(i,"before");o&&this.builder(o),this.stringify(i,t!==n||r)}},t.comment=function(e){var t=this.raw(e,"left","commentLeft"),r=this.raw(e,"right","commentRight");this.builder("/*"+t+e.text+r+"*/",e)},t.decl=function(e,t){var r=this.raw(e,"between","colon"),n=e.prop+r+this.rawValue(e,"value");e.important&&(n+=e.raws.important||" !important"),t&&(n+=";"),this.builder(n,e)},t.document=function(e){this.body(e)},t.raw=function(e,t,r){var n;if(r||(r=t),t&&void 0!==(n=e.raws[t]))return n;var i=e.parent;if("before"===r){if(!i||"root"===i.type&&i.first===e)return"";if(i&&"document"===i.type)return""}if(!i)return Ii[r];var o=e.root();if(o.rawCache||(o.rawCache={}),void 0!==o.rawCache[r])return o.rawCache[r];if("before"===r||"after"===r)return this.beforeAfter(e,r);var s,a="raw"+((s=r)[0].toUpperCase()+s.slice(1));return this[a]?n=this[a](o,e):o.walk(function(e){if(void 0!==(n=e.raws[t]))return!1}),void 0===n&&(n=Ii[r]),o.rawCache[r]=n,n},t.rawBeforeClose=function(e){var t;return e.walk(function(e){if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return(t=e.raws.after).includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t},t.rawBeforeComment=function(e,t){var r;return e.walkComments(function(e){if(void 0!==e.raws.before)return(r=e.raws.before).includes("\n")&&(r=r.replace(/[^\n]+$/,"")),!1}),void 0===r?r=this.raw(t,null,"beforeDecl"):r&&(r=r.replace(/\S/g,"")),r},t.rawBeforeDecl=function(e,t){var r;return e.walkDecls(function(e){if(void 0!==e.raws.before)return(r=e.raws.before).includes("\n")&&(r=r.replace(/[^\n]+$/,"")),!1}),void 0===r?r=this.raw(t,null,"beforeRule"):r&&(r=r.replace(/\S/g,"")),r},t.rawBeforeOpen=function(e){var t;return e.walk(function(e){if("decl"!==e.type&&void 0!==(t=e.raws.between))return!1}),t},t.rawBeforeRule=function(e){var t;return e.walk(function(r){if(r.nodes&&(r.parent!==e||e.first!==r)&&void 0!==r.raws.before)return(t=r.raws.before).includes("\n")&&(t=t.replace(/[^\n]+$/,"")),!1}),t&&(t=t.replace(/\S/g,"")),t},t.rawColon=function(e){var t;return e.walkDecls(function(e){if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,""),!1}),t},t.rawEmptyBody=function(e){var t;return e.walk(function(e){if(e.nodes&&0===e.nodes.length&&void 0!==(t=e.raws.after))return!1}),t},t.rawIndent=function(e){return e.raws.indent?e.raws.indent:(e.walk(function(r){var n=r.parent;if(n&&n!==e&&n.parent&&n.parent===e&&void 0!==r.raws.before){var i=r.raws.before.split("\n");return t=(t=i[i.length-1]).replace(/\S/g,""),!1}}),t);var t},t.rawSemicolon=function(e){var t;return e.walk(function(e){if(e.nodes&&e.nodes.length&&"decl"===e.last.type&&void 0!==(t=e.raws.semicolon))return!1}),t},t.rawValue=function(e,t){var r=e[t],n=e.raws[t];return n&&n.value===r?n.raw:r},t.root=function(e){this.body(e),e.raws.after&&this.builder(e.raws.after)},t.rule=function(e){this.block(e,this.rawValue(e,"selector")),e.raws.ownSemicolon&&this.builder(e.raws.ownSemicolon,e,"end")},t.stringify=function(e,t){if(!this[e.type])throw new Error("Unknown AST node type "+e.type+". Maybe you need to change PostCSS stringifier.");this[e.type](e,t)},e}(),Ni=Ei;Ei.default=Ei;var Ai=Ni;function Pi(e,t){new Ai(t).stringify(e)}var Oi=Pi;Pi.default=Pi;var Mi=Ci.isClean,Ti=Ci.my,Ri=Si,ji=Ni,Di=Oi;function Fi(e,t){var r=new e.constructor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&"proxyCache"!==n){var i=e[n],o=void 0===i?"undefined":E(i);"parent"===n&&"object"===o?t&&(r[n]=t):"source"===n?r[n]=i:Array.isArray(i)?r[n]=i.map(function(e){return Fi(e,r)}):("object"===o&&null!==i&&(i=Fi(i)),r[n]=i)}return r}var Li=function(){function e(e){for(var t in void 0===e&&(e={}),this.raws={},this[Mi]=!1,this[Ti]=!0,e)if("nodes"===t){this.nodes=[];for(var r,n=P(e[t]);!(r=n()).done;){var i=r.value;"function"==typeof i.clone?this.append(i.clone()):this.append(i)}}else this[t]=e[t]}var t=e.prototype;return t.addToError=function(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){var t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,"$&"+t.input.from+":"+t.start.line+":"+t.start.column+"$&")}return e},t.after=function(e){return this.parent.insertAfter(this,e),this},t.assign=function(e){for(var t in void 0===e&&(e={}),e)this[t]=e[t];return this},t.before=function(e){return this.parent.insertBefore(this,e),this},t.cleanRaws=function(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between},t.clone=function(e){void 0===e&&(e={});var t=Fi(this);for(var r in e)t[r]=e[r];return t},t.cloneAfter=function(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertAfter(this,t),t},t.cloneBefore=function(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertBefore(this,t),t},t.error=function(e,t){if(void 0===t&&(t={}),this.source){var r=this.rangeBy(t),n=r.end,i=r.start;return this.source.input.error(e,{column:i.column,line:i.line},{column:n.column,line:n.line},t)}return new Ri(e)},t.getProxyProcessor=function(){return{get:function(e,t){return"proxyOf"===t?e:"root"===t?function(){return e.root().toProxy()}:e[t]},set:function(e,t,r){return e[t]===r||(e[t]=r,"prop"!==t&&"value"!==t&&"name"!==t&&"params"!==t&&"important"!==t&&"text"!==t||e.markDirty()),!0}}},t.markDirty=function(){if(this[Mi]){this[Mi]=!1;for(var e=this;e=e.parent;)e[Mi]=!1}},t.next=function(){if(this.parent){var e=this.parent.index(this);return this.parent.nodes[e+1]}},t.positionBy=function(e,t){var r=this.source.start;if(e.index)r=this.positionInside(e.index,t);else if(e.word){var n=(t=this.toString()).indexOf(e.word);-1!==n&&(r=this.positionInside(n,t))}return r},t.positionInside=function(e,t){for(var r=t||this.toString(),n=this.source.start.column,i=this.source.start.line,o=0;o<e;o++)"\n"===r[o]?(n=1,i+=1):n+=1;return{column:n,line:i}},t.prev=function(){if(this.parent){var e=this.parent.index(this);return this.parent.nodes[e-1]}},t.rangeBy=function(e){var t={column:this.source.start.column,line:this.source.start.line},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line}:{column:t.column+1,line:t.line};if(e.word){var n=this.toString(),i=n.indexOf(e.word);-1!==i&&(t=this.positionInside(i,n),r=this.positionInside(i+e.word.length,n))}else e.start?t={column:e.start.column,line:e.start.line}:e.index&&(t=this.positionInside(e.index)),e.end?r={column:e.end.column,line:e.end.line}:"number"==typeof e.endIndex?r=this.positionInside(e.endIndex):e.index&&(r=this.positionInside(e.index+1));return(r.line<t.line||r.line===t.line&&r.column<=t.column)&&(r={column:t.column+1,line:t.line}),{end:r,start:t}},t.raw=function(e,t){return(new ji).raw(this,e,t)},t.remove=function(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this},t.replaceWith=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(this.parent){for(var n,i=this,o=!1,s=P(t);!(n=s()).done;){var a=n.value;a===this?o=!0:o?(this.parent.insertAfter(i,a),i=a):this.parent.insertBefore(i,a)}o||this.remove()}return this},t.root=function(){for(var e=this;e.parent&&"document"!==e.parent.type;)e=e.parent;return e},t.toJSON=function(e,t){var r={},n=null==t;t=t||new Map;var i=0;for(var o in this)if(Object.prototype.hasOwnProperty.call(this,o)&&"parent"!==o&&"proxyCache"!==o){var s=this[o];if(Array.isArray(s))r[o]=s.map(function(e){return"object"===(void 0===e?"undefined":E(e))&&e.toJSON?e.toJSON(null,t):e});else if("object"===(void 0===s?"undefined":E(s))&&s.toJSON)r[o]=s.toJSON(null,t);else if("source"===o){var a=t.get(s.input);null==a&&(a=i,t.set(s.input,i),i++),r[o]={end:s.end,inputId:a,start:s.start}}else r[o]=s}return n&&(r.inputs=[].concat(t.keys()).map(function(e){return e.toJSON()})),r},t.toProxy=function(){return this.proxyCache||(this.proxyCache=new Proxy(this,this.getProxyProcessor())),this.proxyCache},t.toString=function(e){void 0===e&&(e=Di),e.stringify&&(e=e.stringify);var t="";return e(this,function(e){t+=e}),t},t.warn=function(e,t,r){var n={node:this};for(var i in r)n[i]=r[i];return e.warn(t,n)},w(e,[{key:"proxyOf",get:function(){return this}}]),e}(),Ui=Li;Li.default=Li;var Bi=function(e){function t(t){var r;return t&&void 0!==t.value&&"string"!=typeof t.value&&(t=x({},t,{value:String(t.value)})),(r=e.call(this,t)||this).type="decl",r}return k(t,e),w(t,[{key:"variable",get:function(){return this.prop.startsWith("--")||"$"===this.prop[0]}}]),t}(Ui),zi=Bi;Bi.default=Bi;var qi=function(e){void 0===e&&(e=21);for(var t="",r=e;r--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t},$i=wi.SourceMapConsumer,Gi=wi.SourceMapGenerator,Wi=wi.existsSync,Vi=wi.readFileSync,Hi=wi.dirname,Yi=wi.join;var Zi=function(){function e(e,t){if(!1!==t.map){this.loadAnnotation(e),this.inline=this.startWith(this.annotation,"data:");var r=t.map?t.map.prev:void 0,n=this.loadMap(t.from,r);!this.mapFile&&t.from&&(this.mapFile=t.from),this.mapFile&&(this.root=Hi(this.mapFile)),n&&(this.text=n)}}var t=e.prototype;return t.consumer=function(){return this.consumerCache||(this.consumerCache=new $i(this.text)),this.consumerCache},t.decodeInline=function(e){var t;if(/^data:application\/json;charset=utf-?8,/.test(e)||/^data:application\/json,/.test(e))return decodeURIComponent(e.substr(RegExp.lastMatch.length));if(/^data:application\/json;charset=utf-?8;base64,/.test(e)||/^data:application\/json;base64,/.test(e))return t=e.substr(RegExp.lastMatch.length),f?f.from(t,"base64").toString():window.atob(t);var r=e.match(/data:application\/json;([^,]+),/)[1];throw new Error("Unsupported source map encoding "+r)},t.getAnnotationURL=function(e){return e.replace(/^\/\*\s*# sourceMappingURL=/,"").trim()},t.isMap=function(e){return"object"===(void 0===e?"undefined":E(e))&&("string"==typeof e.mappings||"string"==typeof e._mappings||Array.isArray(e.sections))},t.loadAnnotation=function(e){var t=e.match(/\/\*\s*# sourceMappingURL=/gm);if(t){var r=e.lastIndexOf(t.pop()),n=e.indexOf("*/",r);r>-1&&n>-1&&(this.annotation=this.getAnnotationURL(e.substring(r,n)))}},t.loadFile=function(e){if(this.root=Hi(e),Wi(e))return this.mapFile=e,Vi(e,"utf-8").toString().trim()},t.loadMap=function(e,t){if(!1===t)return!1;if(t){if("string"==typeof t)return t;if("function"!=typeof t){if(S(t,$i))return Gi.fromSourceMap(t).toString();if(S(t,Gi))return t.toString();if(this.isMap(t))return JSON.stringify(t);throw new Error("Unsupported previous source map format: "+t.toString())}var r=t(e);if(r){var n=this.loadFile(r);if(!n)throw new Error("Unable to load previous source map: "+r.toString());return n}}else{if(this.inline)return this.decodeInline(this.annotation);if(this.annotation){var i=this.annotation;return e&&(i=Yi(Hi(e),i)),this.loadFile(i)}}},t.startWith=function(e,t){return!!e&&e.substr(0,t.length)===t},t.withContent=function(){return!!(this.consumer().sourcesContent&&this.consumer().sourcesContent.length>0)},e}(),Ki=Zi;Zi.default=Zi;var Ji=wi.SourceMapConsumer,Xi=wi.SourceMapGenerator,Qi=wi.fileURLToPath,eo=wi.pathToFileURL,to=wi.isAbsolute,ro=wi.resolve,no=qi,io=wi,oo=Si,so=Ki,ao=Symbol("fromOffsetCache"),co=Boolean(Ji&&Xi),lo=Boolean(ro&&to),uo=function(){function e(e,t){if(void 0===t&&(t={}),null==e||"object"===(void 0===e?"undefined":E(e))&&!e.toString)throw new Error("PostCSS received "+e+" instead of CSS string");if(this.css=e.toString(),"\ufeff"===this.css[0]||"๏ฟพ"===this.css[0]?(this.hasBOM=!0,this.css=this.css.slice(1)):this.hasBOM=!1,t.from&&(!lo||/^\w+:\/\//.test(t.from)||to(t.from)?this.file=t.from:this.file=ro(t.from)),lo&&co){var r=new so(this.css,t);if(r.text){this.map=r;var n=r.consumer().file;!this.file&&n&&(this.file=this.mapResolve(n))}}this.file||(this.id="<input css "+no(6)+">"),this.map&&(this.map.file=this.from)}var t=e.prototype;return t.error=function(e,t,r,n){var i,o,s;if(void 0===n&&(n={}),t&&"object"===(void 0===t?"undefined":E(t))){var a=t,c=r;if("number"==typeof a.offset){var l=this.fromOffset(a.offset);t=l.line,r=l.col}else t=a.line,r=a.column;if("number"==typeof c.offset){var u=this.fromOffset(c.offset);o=u.line,s=u.col}else o=c.line,s=c.column}else if(!r){var d=this.fromOffset(t);t=d.line,r=d.col}var h=this.origin(t,r,o,s);return(i=h?new oo(e,void 0===h.endLine?h.line:{column:h.column,line:h.line},void 0===h.endLine?h.column:{column:h.endColumn,line:h.endLine},h.source,h.file,n.plugin):new oo(e,void 0===o?t:{column:r,line:t},void 0===o?r:{column:s,line:o},this.css,this.file,n.plugin)).input={column:r,endColumn:s,endLine:o,line:t,source:this.css},this.file&&(eo&&(i.input.url=eo(this.file).toString()),i.input.file=this.file),i},t.fromOffset=function(e){var t;if(this[ao])t=this[ao];else{var r=this.css.split("\n");t=new Array(r.length);for(var n=0,i=0,o=r.length;i<o;i++)t[i]=n,n+=r[i].length+1;this[ao]=t}var s=0;if(e>=t[t.length-1])s=t.length-1;else for(var a,c=t.length-2;s<c;)if(e<t[a=s+(c-s>>1)])c=a-1;else{if(!(e>=t[a+1])){s=a;break}s=a+1}return{col:e-t[s]+1,line:s+1}},t.mapResolve=function(e){return/^\w+:\/\//.test(e)?e:ro(this.map.consumer().sourceRoot||this.map.root||".",e)},t.origin=function(e,t,r,n){if(!this.map)return!1;var i,o,s=this.map.consumer(),a=s.originalPositionFor({column:t,line:e});if(!a.source)return!1;"number"==typeof r&&(i=s.originalPositionFor({column:n,line:r})),o=to(a.source)?eo(a.source):new URL(a.source,this.map.consumer().sourceRoot||eo(this.map.mapFile));var c={column:a.column,endColumn:i&&i.column,endLine:i&&i.line,line:a.line,url:o.toString()};if("file:"===o.protocol){if(!Qi)throw new Error("file: protocol is not available in this PostCSS build");c.file=Qi(o)}var l=s.sourceContentFor(a.source);return l&&(c.source=l),c},t.toJSON=function(){for(var e={},t=0,r=["hasBOM","css","file","id"];t<r.length;t++){var n=r[t];null!=this[n]&&(e[n]=this[n])}return this.map&&(e.map=x({},this.map),e.map.consumerCache&&(e.map.consumerCache=void 0)),e},w(e,[{key:"from",get:function(){return this.file||this.id}}]),e}(),ho=uo;uo.default=uo,io&&io.registerInput&&io.registerInput(uo);var po=wi.SourceMapConsumer,fo=wi.SourceMapGenerator,mo=wi.dirname,go=wi.relative,yo=wi.resolve,vo=wi.sep,bo=wi.pathToFileURL,wo=ho,xo=Boolean(po&&fo),_o=Boolean(mo&&yo&&go&&vo),ko=function(){function e(e,t,r,n){this.stringify=e,this.mapOpts=r.map||{},this.root=t,this.opts=r,this.css=n,this.originalCSS=n,this.usesFileUrls=!this.mapOpts.from&&this.mapOpts.absolute,this.memoizedFileURLs=new Map,this.memoizedPaths=new Map,this.memoizedURLs=new Map}var t=e.prototype;return t.addAnnotation=function(){var e;e=this.isInline()?"data:application/json;base64,"+this.toBase64(this.map.toString()):"string"==typeof this.mapOpts.annotation?this.mapOpts.annotation:"function"==typeof this.mapOpts.annotation?this.mapOpts.annotation(this.opts.to,this.root):this.outputFile()+".map";var t="\n";this.css.includes("\r\n")&&(t="\r\n"),this.css+=t+"/*# sourceMappingURL="+e+" */"},t.applyPrevMaps=function(){for(var e,t=P(this.previous());!(e=t()).done;){var r=e.value,n=this.toUrl(this.path(r.file)),i=r.root||mo(r.file),o=void 0;!1===this.mapOpts.sourcesContent?(o=new po(r.text)).sourcesContent&&(o.sourcesContent=null):o=r.consumer(),this.map.applySourceMap(o,n,this.toUrl(this.path(i)))}},t.clearAnnotation=function(){if(!1!==this.mapOpts.annotation)if(this.root)for(var e,t=this.root.nodes.length-1;t>=0;t--)"comment"===(e=this.root.nodes[t]).type&&0===e.text.indexOf("# sourceMappingURL=")&&this.root.removeChild(t);else this.css&&(this.css=this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm,""))},t.generate=function(){if(this.clearAnnotation(),_o&&xo&&this.isMap())return this.generateMap();var e="";return this.stringify(this.root,function(t){e+=t}),[e]},t.generateMap=function(){if(this.root)this.generateString();else if(1===this.previous().length){var e=this.previous()[0].consumer();e.file=this.outputFile(),this.map=fo.fromSourceMap(e,{ignoreInvalidMapping:!0})}else this.map=new fo({file:this.outputFile(),ignoreInvalidMapping:!0}),this.map.addMapping({generated:{column:0,line:1},original:{column:0,line:1},source:this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>"});return this.isSourcesContent()&&this.setSourcesContent(),this.root&&this.previous().length>0&&this.applyPrevMaps(),this.isAnnotation()&&this.addAnnotation(),this.isInline()?[this.css]:[this.css,this.map]},t.generateString=function(){var e=this;this.css="",this.map=new fo({file:this.outputFile(),ignoreInvalidMapping:!0});var t,r,n=1,i=1,o="<no source>",s={generated:{column:0,line:0},original:{column:0,line:0},source:""};this.stringify(this.root,function(a,c,l){if(e.css+=a,c&&"end"!==l&&(s.generated.line=n,s.generated.column=i-1,c.source&&c.source.start?(s.source=e.sourcePath(c),s.original.line=c.source.start.line,s.original.column=c.source.start.column-1,e.map.addMapping(s)):(s.source=o,s.original.line=1,s.original.column=0,e.map.addMapping(s))),(t=a.match(/\n/g))?(n+=t.length,r=a.lastIndexOf("\n"),i=a.length-r):i+=a.length,c&&"start"!==l){var u=c.parent||{raws:{}};("decl"===c.type||"atrule"===c.type&&!c.nodes)&&c===u.last&&!u.raws.semicolon||(c.source&&c.source.end?(s.source=e.sourcePath(c),s.original.line=c.source.end.line,s.original.column=c.source.end.column-1,s.generated.line=n,s.generated.column=i-2,e.map.addMapping(s)):(s.source=o,s.original.line=1,s.original.column=0,s.generated.line=n,s.generated.column=i-1,e.map.addMapping(s)))}})},t.isAnnotation=function(){return!!this.isInline()||(void 0!==this.mapOpts.annotation?this.mapOpts.annotation:!this.previous().length||this.previous().some(function(e){return e.annotation}))},t.isInline=function(){if(void 0!==this.mapOpts.inline)return this.mapOpts.inline;var e=this.mapOpts.annotation;return(void 0===e||!0===e)&&(!this.previous().length||this.previous().some(function(e){return e.inline}))},t.isMap=function(){return void 0!==this.opts.map?!!this.opts.map:this.previous().length>0},t.isSourcesContent=function(){return void 0!==this.mapOpts.sourcesContent?this.mapOpts.sourcesContent:!this.previous().length||this.previous().some(function(e){return e.withContent()})},t.outputFile=function(){return this.opts.to?this.path(this.opts.to):this.opts.from?this.path(this.opts.from):"to.css"},t.path=function(e){if(this.mapOpts.absolute)return e;if(60===e.charCodeAt(0))return e;if(/^\w+:\/\//.test(e))return e;var t=this.memoizedPaths.get(e);if(t)return t;var r=this.opts.to?mo(this.opts.to):".";"string"==typeof this.mapOpts.annotation&&(r=mo(yo(r,this.mapOpts.annotation)));var n=go(r,e);return this.memoizedPaths.set(e,n),n},t.previous=function(){var e=this;if(!this.previousMaps)if(this.previousMaps=[],this.root)this.root.walk(function(t){if(t.source&&t.source.input.map){var r=t.source.input.map;e.previousMaps.includes(r)||e.previousMaps.push(r)}});else{var t=new wo(this.originalCSS,this.opts);t.map&&this.previousMaps.push(t.map)}return this.previousMaps},t.setSourcesContent=function(){var e=this,t={};if(this.root)this.root.walk(function(r){if(r.source){var n=r.source.input.from;if(n&&!t[n]){t[n]=!0;var i=e.usesFileUrls?e.toFileUrl(n):e.toUrl(e.path(n));e.map.setSourceContent(i,r.source.input.css)}}});else if(this.css){var r=this.opts.from?this.toUrl(this.path(this.opts.from)):"<no source>";this.map.setSourceContent(r,this.css)}},t.sourcePath=function(e){return this.mapOpts.from?this.toUrl(this.mapOpts.from):this.usesFileUrls?this.toFileUrl(e.source.input.from):this.toUrl(this.path(e.source.input.from))},t.toBase64=function(e){return f?f.from(e).toString("base64"):window.btoa(unescape(encodeURIComponent(e)))},t.toFileUrl=function(e){var t=this.memoizedFileURLs.get(e);if(t)return t;if(bo){var r=bo(e).toString();return this.memoizedFileURLs.set(e,r),r}throw new Error("`map.absolute` option is not available in this PostCSS build")},t.toUrl=function(e){var t=this.memoizedURLs.get(e);if(t)return t;"\\"===vo&&(e=e.replace(/\\/g,"/"));var r=encodeURI(e).replace(/[#?]/g,encodeURIComponent);return this.memoizedURLs.set(e,r),r},e}(),So=function(e){function t(t){var r;return(r=e.call(this,t)||this).type="comment",r}return k(t,e),t}(Ui),Co=So;So.default=So;var Io,Eo,No,Ao,Po=Ci.isClean,Oo=Ci.my,Mo=zi,To=Co;function Ro(e){return e.map(function(e){return e.nodes&&(e.nodes=Ro(e.nodes)),delete e.source,e})}function jo(e){if(e[Po]=!1,e.proxyOf.nodes)for(var t,r=P(e.proxyOf.nodes);!(t=r()).done;){jo(t.value)}}var Do=function(e){function t(){return e.apply(this,arguments)||this}k(t,e);var r=t.prototype;return r.append=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var n,i=P(t);!(n=i()).done;)for(var o,s=n.value,a=P(this.normalize(s,this.last));!(o=a()).done;){var c=o.value;this.proxyOf.nodes.push(c)}return this.markDirty(),this},r.cleanRaws=function(t){if(e.prototype.cleanRaws.call(this,t),this.nodes)for(var r,n=P(this.nodes);!(r=n()).done;){r.value.cleanRaws(t)}},r.each=function(e){if(this.proxyOf.nodes){for(var t,r,n=this.getIterator();this.indexes[n]<this.proxyOf.nodes.length&&(t=this.indexes[n],!1!==(r=e(this.proxyOf.nodes[t],t)));)this.indexes[n]+=1;return delete this.indexes[n],r}},r.every=function(e){return this.nodes.every(e)},r.getIterator=function(){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var e=this.lastEach;return this.indexes[e]=0,e},r.getProxyProcessor=function(){return{get:function(e,t){return"proxyOf"===t?e:e[t]?"each"===t||"string"==typeof t&&t.startsWith("walk")?function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];var o;return(o=e)[t].apply(o,[].concat(n.map(function(e){return"function"==typeof e?function(t,r){return e(t.toProxy(),r)}:e})))}:"every"===t||"some"===t?function(r){return e[t](function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return r.apply(void 0,[].concat([e.toProxy()],n))})}:"root"===t?function(){return e.root().toProxy()}:"nodes"===t?e.nodes.map(function(e){return e.toProxy()}):"first"===t||"last"===t?e[t].toProxy():e[t]:e[t]},set:function(e,t,r){return e[t]===r||(e[t]=r,"name"!==t&&"params"!==t&&"selector"!==t||e.markDirty()),!0}}},r.index=function(e){return"number"==typeof e?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))},r.insertAfter=function(e,t){var r,n=this.index(e),i=this.normalize(t,this.proxyOf.nodes[n]).reverse();n=this.index(e);for(var o,s=P(i);!(o=s()).done;){var a=o.value;this.proxyOf.nodes.splice(n+1,0,a)}for(var c in this.indexes)n<(r=this.indexes[c])&&(this.indexes[c]=r+i.length);return this.markDirty(),this},r.insertBefore=function(e,t){var r,n=this.index(e),i=0===n&&"prepend",o=this.normalize(t,this.proxyOf.nodes[n],i).reverse();n=this.index(e);for(var s,a=P(o);!(s=a()).done;){var c=s.value;this.proxyOf.nodes.splice(n,0,c)}for(var l in this.indexes)n<=(r=this.indexes[l])&&(this.indexes[l]=r+o.length);return this.markDirty(),this},r.normalize=function(e,r){var n=this;if("string"==typeof e)e=Ro(Io(e).nodes);else if(void 0===e)e=[];else if(Array.isArray(e))for(var i,o=P(e=e.slice(0));!(i=o()).done;){var s=i.value;s.parent&&s.parent.removeChild(s,"ignore")}else if("root"===e.type&&"document"!==this.type)for(var a,c=P(e=e.nodes.slice(0));!(a=c()).done;){var l=a.value;l.parent&&l.parent.removeChild(l,"ignore")}else if(e.type)e=[e];else if(e.prop){if(void 0===e.value)throw new Error("Value field is missed in node creation");"string"!=typeof e.value&&(e.value=String(e.value)),e=[new Mo(e)]}else if(e.selector)e=[new Eo(e)];else if(e.name)e=[new No(e)];else{if(!e.text)throw new Error("Unknown node type in node creation");e=[new To(e)]}return e.map(function(e){return e[Oo]||t.rebuild(e),(e=e.proxyOf).parent&&e.parent.removeChild(e),e[Po]&&jo(e),void 0===e.raws.before&&r&&void 0!==r.raws.before&&(e.raws.before=r.raws.before.replace(/\S/g,"")),e.parent=n.proxyOf,e})},r.prepend=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var n,i=P(t=t.reverse());!(n=i()).done;){for(var o,s=n.value,a=this.normalize(s,this.first,"prepend").reverse(),c=P(a);!(o=c()).done;){var l=o.value;this.proxyOf.nodes.unshift(l)}for(var u in this.indexes)this.indexes[u]=this.indexes[u]+a.length}return this.markDirty(),this},r.push=function(e){return e.parent=this,this.proxyOf.nodes.push(e),this},r.removeAll=function(){for(var e,t=P(this.proxyOf.nodes);!(e=t()).done;){e.value.parent=void 0}return this.proxyOf.nodes=[],this.markDirty(),this},r.removeChild=function(e){var t;for(var r in e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1),this.indexes)(t=this.indexes[r])>=e&&(this.indexes[r]=t-1);return this.markDirty(),this},r.replaceValues=function(e,t,r){return r||(r=t,t={}),this.walkDecls(function(n){t.props&&!t.props.includes(n.prop)||t.fast&&!n.value.includes(t.fast)||(n.value=n.value.replace(e,r))}),this.markDirty(),this},r.some=function(e){return this.nodes.some(e)},r.walk=function(e){return this.each(function(t,r){var n;try{n=e(t,r)}catch(i){throw t.addToError(i)}return!1!==n&&t.walk&&(n=t.walk(e)),n})},r.walkAtRules=function(e,t){return t?S(e,RegExp)?this.walk(function(r,n){if("atrule"===r.type&&e.test(r.name))return t(r,n)}):this.walk(function(r,n){if("atrule"===r.type&&r.name===e)return t(r,n)}):(t=e,this.walk(function(e,r){if("atrule"===e.type)return t(e,r)}))},r.walkComments=function(e){return this.walk(function(t,r){if("comment"===t.type)return e(t,r)})},r.walkDecls=function(e,t){return t?S(e,RegExp)?this.walk(function(r,n){if("decl"===r.type&&e.test(r.prop))return t(r,n)}):this.walk(function(r,n){if("decl"===r.type&&r.prop===e)return t(r,n)}):(t=e,this.walk(function(e,r){if("decl"===e.type)return t(e,r)}))},r.walkRules=function(e,t){return t?S(e,RegExp)?this.walk(function(r,n){if("rule"===r.type&&e.test(r.selector))return t(r,n)}):this.walk(function(r,n){if("rule"===r.type&&r.selector===e)return t(r,n)}):(t=e,this.walk(function(e,r){if("rule"===e.type)return t(e,r)}))},w(t,[{key:"first",get:function(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}},{key:"last",get:function(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}}]),t}(Ui);Do.registerParse=function(e){Io=e},Do.registerRule=function(e){Eo=e},Do.registerAtRule=function(e){No=e},Do.registerRoot=function(e){Ao=e};var Fo=Do;Do.default=Do,Do.rebuild=function(e){"atrule"===e.type?Object.setPrototypeOf(e,No.prototype):"rule"===e.type?Object.setPrototypeOf(e,Eo.prototype):"decl"===e.type?Object.setPrototypeOf(e,Mo.prototype):"comment"===e.type?Object.setPrototypeOf(e,To.prototype):"root"===e.type&&Object.setPrototypeOf(e,Ao.prototype),e[Oo]=!0,e.nodes&&e.nodes.forEach(function(e){Do.rebuild(e)})};var Lo,Uo,Bo=function(e){function t(t){var r;return(r=e.call(this,x({type:"document"},t))||this).nodes||(r.nodes=[]),r}return k(t,e),t.prototype.toResult=function(e){return void 0===e&&(e={}),new Lo(new Uo,this,e).stringify()},t}(Fo);Bo.registerLazyResult=function(e){Lo=e},Bo.registerProcessor=function(e){Uo=e};var zo=Bo;Bo.default=Bo;var qo=function(){function e(e,t){if(void 0===t&&(t={}),this.type="warning",this.text=e,t.node&&t.node.source){var r=t.node.rangeBy(t);this.line=r.start.line,this.column=r.start.column,this.endLine=r.end.line,this.endColumn=r.end.column}for(var n in t)this[n]=t[n]}return e.prototype.toString=function(){return this.node?this.node.error(this.text,{index:this.index,plugin:this.plugin,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text},e}(),$o=qo;qo.default=qo;var Go=$o,Wo=function(){function e(e,t,r){this.processor=e,this.messages=[],this.root=t,this.opts=r,this.css=void 0,this.map=void 0}var t=e.prototype;return t.toString=function(){return this.css},t.warn=function(e,t){void 0===t&&(t={}),t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);var r=new Go(e,t);return this.messages.push(r),r},t.warnings=function(){return this.messages.filter(function(e){return"warning"===e.type})},w(e,[{key:"content",get:function(){return this.css}}]),e}(),Vo=Wo;Wo.default=Wo;var Ho="'".charCodeAt(0),Yo='"'.charCodeAt(0),Zo="\\".charCodeAt(0),Ko="/".charCodeAt(0),Jo="\n".charCodeAt(0),Xo=" ".charCodeAt(0),Qo="\f".charCodeAt(0),es="\t".charCodeAt(0),ts="\r".charCodeAt(0),rs="[".charCodeAt(0),ns="]".charCodeAt(0),is="(".charCodeAt(0),os=")".charCodeAt(0),ss="{".charCodeAt(0),as="}".charCodeAt(0),cs=";".charCodeAt(0),ls="*".charCodeAt(0),us=":".charCodeAt(0),ds="@".charCodeAt(0),hs=/[\t\n\f\r "#'()/;[\\\]{}]/g,ps=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,fs=/.[\r\n"'(/\\]/,ms=/[\da-f]/i,gs=Fo,ys=function(e){function t(t){var r;return(r=e.call(this,t)||this).type="atrule",r}k(t,e);var r=t.prototype;return r.append=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];var i;return this.proxyOf.nodes||(this.nodes=[]),(i=e.prototype.append).call.apply(i,[].concat([this],r))},r.prepend=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];var i;return this.proxyOf.nodes||(this.nodes=[]),(i=e.prototype.prepend).call.apply(i,[].concat([this],r))},t}(gs),vs=ys;ys.default=ys,gs.registerAtRule(ys);var bs,ws,xs=Fo,_s=function(e){function t(t){var r;return(r=e.call(this,t)||this).type="root",r.nodes||(r.nodes=[]),r}k(t,e);var r=t.prototype;return r.normalize=function(t,r,n){var i=e.prototype.normalize.call(this,t);if(r)if("prepend"===n)this.nodes.length>1?r.raws.before=this.nodes[1].raws.before:delete r.raws.before;else if(this.first!==r)for(var o,s=P(i);!(o=s()).done;){o.value.raws.before=r.raws.before}return i},r.removeChild=function(t,r){var n=this.index(t);return!r&&0===n&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),e.prototype.removeChild.call(this,t)},r.toResult=function(e){return void 0===e&&(e={}),new bs(new ws,this,e).stringify()},t}(xs);_s.registerLazyResult=function(e){bs=e},_s.registerProcessor=function(e){ws=e};var ks=_s;_s.default=_s,xs.registerRoot(_s);var Ss={comma:function(e){return Ss.split(e,[","],!0)},space:function(e){return Ss.split(e,[" ","\n","\t"])},split:function(e,t,r){for(var n,i=[],o="",s=!1,a=0,c=!1,l="",u=!1,d=P(e);!(n=d()).done;){var h=n.value;u?u=!1:"\\"===h?u=!0:c?h===l&&(c=!1):'"'===h||"'"===h?(c=!0,l=h):"("===h?a+=1:")"===h?a>0&&(a-=1):0===a&&t.includes(h)&&(s=!0),s?(""!==o&&i.push(o.trim()),o="",s=!1):o+=h}return(r||""!==o)&&i.push(o.trim()),i}},Cs=Ss;Ss.default=Ss;var Is=Fo,Es=Cs,Ns=function(e){function t(t){var r;return(r=e.call(this,t)||this).type="rule",r.nodes||(r.nodes=[]),r}return k(t,e),w(t,[{key:"selectors",get:function(){return Es.comma(this.selector)},set:function(e){var t=this.selector?this.selector.match(/,\s*/):null,r=t?t[0]:","+this.raw("between","beforeOpen");this.selector=e.join(r)}}]),t}(Is),As=Ns;Ns.default=Ns,Is.registerRule(Ns);var Ps=zi,Os=function(e,t){void 0===t&&(t={});var r,n,i,o,s,a,c,l,u,d,h=e.css.valueOf(),p=t.ignoreErrors,f=h.length,m=0,g=[],y=[];function v(t){throw e.error("Unclosed "+t,m)}return{back:function(e){y.push(e)},endOfFile:function(){return 0===y.length&&m>=f},nextToken:function(e){if(y.length)return y.pop();if(!(m>=f)){var t=!!e&&e.ignoreUnclosed;switch(r=h.charCodeAt(m)){case Jo:case Xo:case es:case ts:case Qo:n=m;do{n+=1,r=h.charCodeAt(n)}while(r===Xo||r===Jo||r===es||r===ts||r===Qo);d=["space",h.slice(m,n)],m=n-1;break;case rs:case ns:case ss:case as:case us:case cs:case os:var b=String.fromCharCode(r);d=[b,b,m];break;case is:if(l=g.length?g.pop()[1]:"",u=h.charCodeAt(m+1),"url"===l&&u!==Ho&&u!==Yo&&u!==Xo&&u!==Jo&&u!==es&&u!==Qo&&u!==ts){n=m;do{if(a=!1,-1===(n=h.indexOf(")",n+1))){if(p||t){n=m;break}v("bracket")}for(c=n;h.charCodeAt(c-1)===Zo;)c-=1,a=!a}while(a);d=["brackets",h.slice(m,n+1),m,n],m=n}else n=h.indexOf(")",m+1),o=h.slice(m,n+1),-1===n||fs.test(o)?d=["(","(",m]:(d=["brackets",o,m,n],m=n);break;case Ho:case Yo:i=r===Ho?"'":'"',n=m;do{if(a=!1,-1===(n=h.indexOf(i,n+1))){if(p||t){n=m+1;break}v("string")}for(c=n;h.charCodeAt(c-1)===Zo;)c-=1,a=!a}while(a);d=["string",h.slice(m,n+1),m,n],m=n;break;case ds:hs.lastIndex=m+1,hs.test(h),n=0===hs.lastIndex?h.length-1:hs.lastIndex-2,d=["at-word",h.slice(m,n+1),m,n],m=n;break;case Zo:for(n=m,s=!0;h.charCodeAt(n+1)===Zo;)n+=1,s=!s;if(r=h.charCodeAt(n+1),s&&r!==Ko&&r!==Xo&&r!==Jo&&r!==es&&r!==ts&&r!==Qo&&(n+=1,ms.test(h.charAt(n)))){for(;ms.test(h.charAt(n+1));)n+=1;h.charCodeAt(n+1)===Xo&&(n+=1)}d=["word",h.slice(m,n+1),m,n],m=n;break;default:r===Ko&&h.charCodeAt(m+1)===ls?(0===(n=h.indexOf("*/",m+2)+1)&&(p||t?n=h.length:v("comment")),d=["comment",h.slice(m,n+1),m,n],m=n):(ps.lastIndex=m+1,ps.test(h),n=0===ps.lastIndex?h.length-1:ps.lastIndex-2,d=["word",h.slice(m,n+1),m,n],g.push(d),m=n)}return m++,d}},position:function(){return m}}},Ms=Co,Ts=vs,Rs=ks,js=As,Ds={empty:!0,space:!0};var Fs=function(){function e(e){this.input=e,this.root=new Rs,this.current=this.root,this.spaces="",this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}var t=e.prototype;return t.atrule=function(e){var t,r,n,i=new Ts;i.name=e[1].slice(1),""===i.name&&this.unnamedAtrule(i,e),this.init(i,e[2]);for(var o=!1,s=!1,a=[],c=[];!this.tokenizer.endOfFile();){if("("===(t=(e=this.tokenizer.nextToken())[0])||"["===t?c.push("("===t?")":"]"):"{"===t&&c.length>0?c.push("}"):t===c[c.length-1]&&c.pop(),0===c.length){if(";"===t){i.source.end=this.getPosition(e[2]),i.source.end.offset++,this.semicolon=!0;break}if("{"===t){s=!0;break}if("}"===t){if(a.length>0){for(r=a[n=a.length-1];r&&"space"===r[0];)r=a[--n];r&&(i.source.end=this.getPosition(r[3]||r[2]),i.source.end.offset++)}this.end(e);break}a.push(e)}else a.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}i.raws.between=this.spacesAndCommentsFromEnd(a),a.length?(i.raws.afterName=this.spacesAndCommentsFromStart(a),this.raw(i,"params",a),o&&(e=a[a.length-1],i.source.end=this.getPosition(e[3]||e[2]),i.source.end.offset++,this.spaces=i.raws.between,i.raws.between="")):(i.raws.afterName="",i.params=""),s&&(i.nodes=[],this.current=i)},t.checkMissedSemicolon=function(e){var t=this.colon(e);if(!1!==t){for(var r,n=0,i=t-1;i>=0&&("space"===(r=e[i])[0]||2!==(n+=1));i--);throw this.input.error("Missed semicolon","word"===r[0]?r[3]+1:r[2])}},t.colon=function(e){for(var t,r,n,i,o=0,s=P(e.entries());!(i=s()).done;){var a=i.value,c=a[0];if("("===(r=(t=a[1])[0])&&(o+=1),")"===r&&(o-=1),0===o&&":"===r){if(n){if("word"===n[0]&&"progid"===n[1])continue;return c}this.doubleColon(t)}n=t}return!1},t.comment=function(e){var t=new Ms;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;var r=e[1].slice(2,-2);if(/^\s*$/.test(r))t.text="",t.raws.left=r,t.raws.right="";else{var n=r.match(/^(\s*)([^]*\S)(\s*)$/);t.text=n[2],t.raws.left=n[1],t.raws.right=n[3]}},t.createTokenizer=function(){this.tokenizer=Os(this.input)},t.decl=function(e,t){var r=new Ps;this.init(r,e[0][2]);var n,i=e[e.length-1];for(";"===i[0]&&(this.semicolon=!0,e.pop()),r.source.end=this.getPosition(i[3]||i[2]||function(e){for(var t=e.length-1;t>=0;t--){var r=e[t],n=r[3]||r[2];if(n)return n}}(e)),r.source.end.offset++;"word"!==e[0][0];)1===e.length&&this.unknownWord(e),r.raws.before+=e.shift()[1];for(r.source.start=this.getPosition(e[0][2]),r.prop="";e.length;){var o=e[0][0];if(":"===o||"space"===o||"comment"===o)break;r.prop+=e.shift()[1]}for(r.raws.between="";e.length;){if(":"===(n=e.shift())[0]){r.raws.between+=n[1];break}"word"===n[0]&&/\w/.test(n[1])&&this.unknownWord([n]),r.raws.between+=n[1]}"_"!==r.prop[0]&&"*"!==r.prop[0]||(r.raws.before+=r.prop[0],r.prop=r.prop.slice(1));for(var s,a=[];e.length&&("space"===(s=e[0][0])||"comment"===s);)a.push(e.shift());this.precheckMissedSemicolon(e);for(var c=e.length-1;c>=0;c--){if("!important"===(n=e[c])[1].toLowerCase()){r.important=!0;var l=this.stringFrom(e,c);" !important"!==(l=this.spacesFromEnd(e)+l)&&(r.raws.important=l);break}if("important"===n[1].toLowerCase()){for(var u=e.slice(0),d="",h=c;h>0;h--){var p=u[h][0];if(0===d.trim().indexOf("!")&&"space"!==p)break;d=u.pop()[1]+d}0===d.trim().indexOf("!")&&(r.important=!0,r.raws.important=d,e=u)}if("space"!==n[0]&&"comment"!==n[0])break}e.some(function(e){return"space"!==e[0]&&"comment"!==e[0]})&&(r.raws.between+=a.map(function(e){return e[1]}).join(""),a=[]),this.raw(r,"value",a.concat(e),t),r.value.includes(":")&&!t&&this.checkMissedSemicolon(e)},t.doubleColon=function(e){throw this.input.error("Double colon",{offset:e[2]},{offset:e[2]+e[1].length})},t.emptyRule=function(e){var t=new js;this.init(t,e[2]),t.selector="",t.raws.between="",this.current=t},t.end=function(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.spaces="",this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)},t.endFile=function(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||"")+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())},t.freeSemicolon=function(e){if(this.spaces+=e[1],this.current.nodes){var t=this.current.nodes[this.current.nodes.length-1];t&&"rule"===t.type&&!t.raws.ownSemicolon&&(t.raws.ownSemicolon=this.spaces,this.spaces="")}},t.getPosition=function(e){var t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}},t.init=function(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces="","comment"!==e.type&&(this.semicolon=!1)},t.other=function(e){for(var t=!1,r=null,n=!1,i=null,o=[],s=e[1].startsWith("--"),a=[],c=e;c;){if(r=c[0],a.push(c),"("===r||"["===r)i||(i=c),o.push("("===r?")":"]");else if(s&&n&&"{"===r)i||(i=c),o.push("}");else if(0===o.length){if(";"===r){if(n)return void this.decl(a,s);break}if("{"===r)return void this.rule(a);if("}"===r){this.tokenizer.back(a.pop()),t=!0;break}":"===r&&(n=!0)}else r===o[o.length-1]&&(o.pop(),0===o.length&&(i=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),o.length>0&&this.unclosedBracket(i),t&&n){if(!s)for(;a.length&&("space"===(c=a[a.length-1][0])||"comment"===c);)this.tokenizer.back(a.pop());this.decl(a,s)}else this.unknownWord(a)},t.parse=function(){for(var e;!this.tokenizer.endOfFile();)switch((e=this.tokenizer.nextToken())[0]){case"space":this.spaces+=e[1];break;case";":this.freeSemicolon(e);break;case"}":this.end(e);break;case"comment":this.comment(e);break;case"at-word":this.atrule(e);break;case"{":this.emptyRule(e);break;default:this.other(e)}this.endFile()},t.precheckMissedSemicolon=function(){},t.raw=function(e,t,r,n){for(var i,o,s,a,c=r.length,l="",u=!0,d=0;d<c;d+=1)"space"!==(o=(i=r[d])[0])||d!==c-1||n?"comment"===o?(a=r[d-1]?r[d-1][0]:"empty",s=r[d+1]?r[d+1][0]:"empty",Ds[a]||Ds[s]||","===l.slice(-1)?u=!1:l+=i[1]):l+=i[1]:u=!1;if(!u){var h=r.reduce(function(e,t){return e+t[1]},"");e.raws[t]={raw:h,value:l}}e[t]=l},t.rule=function(e){e.pop();var t=new js;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t},t.spacesAndCommentsFromEnd=function(e){for(var t,r="";e.length&&("space"===(t=e[e.length-1][0])||"comment"===t);)r=e.pop()[1]+r;return r},t.spacesAndCommentsFromStart=function(e){for(var t,r="";e.length&&("space"===(t=e[0][0])||"comment"===t);)r+=e.shift()[1];return r},t.spacesFromEnd=function(e){for(var t="";e.length&&"space"===e[e.length-1][0];)t=e.pop()[1]+t;return t},t.stringFrom=function(e,t){for(var r="",n=t;n<e.length;n++)r+=e[n][1];return e.splice(t,e.length-t),r},t.unclosedBlock=function(){var e=this.current.source.start;throw this.input.error("Unclosed block",e.line,e.column)},t.unclosedBracket=function(e){throw this.input.error("Unclosed bracket",{offset:e[2]},{offset:e[2]+1})},t.unexpectedClose=function(e){throw this.input.error("Unexpected }",{offset:e[2]},{offset:e[2]+1})},t.unknownWord=function(e){throw this.input.error("Unknown word",{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})},t.unnamedAtrule=function(e,t){throw this.input.error("At-rule without name",{offset:t[2]},{offset:t[2]+t[1].length})},e}(),Ls=Fo,Us=Fs,Bs=ho;function zs(e,t){var r=new Bs(e,t),n=new Us(r);try{n.parse()}catch(i){throw i}return n.root}var qs=zs;zs.default=zs,Ls.registerParse(zs);var $s=Ci.isClean,Gs=Ci.my,Ws=ko,Vs=Oi,Hs=Fo,Ys=zo,Zs=Vo,Ks=qs,Js=ks,Xs={atrule:"AtRule",comment:"Comment",decl:"Declaration",document:"Document",root:"Root",rule:"Rule"},Qs={AtRule:!0,AtRuleExit:!0,Comment:!0,CommentExit:!0,Declaration:!0,DeclarationExit:!0,Document:!0,DocumentExit:!0,Once:!0,OnceExit:!0,postcssPlugin:!0,prepare:!0,Root:!0,RootExit:!0,Rule:!0,RuleExit:!0},ea={Once:!0,postcssPlugin:!0,prepare:!0};function ta(e){return"object"===(void 0===e?"undefined":E(e))&&"function"==typeof e.then}function ra(e){var t=!1,r=Xs[e.type];return"decl"===e.type?t=e.prop.toLowerCase():"atrule"===e.type&&(t=e.name.toLowerCase()),t&&e.append?[r,r+"-"+t,0,r+"Exit",r+"Exit-"+t]:t?[r,r+"-"+t,r+"Exit",r+"Exit-"+t]:e.append?[r,0,r+"Exit"]:[r,r+"Exit"]}function na(e){return{eventIndex:0,events:"document"===e.type?["Document",0,"DocumentExit"]:"root"===e.type?["Root",0,"RootExit"]:ra(e),iterator:0,node:e,visitorIndex:0,visitors:[]}}function ia(e){return e[$s]=!1,e.nodes&&e.nodes.forEach(function(e){return ia(e)}),e}var oa={},sa=function(){function e(t,r,n){var i,o=this;if(this.stringified=!1,this.processed=!1,"object"!==(void 0===r?"undefined":E(r))||null===r||"root"!==r.type&&"document"!==r.type)if(S(r,e)||S(r,Zs))i=ia(r.root),r.map&&(void 0===n.map&&(n.map={}),n.map.inline||(n.map.inline=!1),n.map.prev=r.map);else{var s=Ks;n.syntax&&(s=n.syntax.parse),n.parser&&(s=n.parser),s.parse&&(s=s.parse);try{i=s(r,n)}catch(gu){this.processed=!0,this.error=gu}i&&!i[Gs]&&Hs.rebuild(i)}else i=ia(r);this.result=new Zs(t,i,n),this.helpers=x({},oa,{postcss:oa,result:this.result}),this.plugins=this.processor.plugins.map(function(e){return"object"===(void 0===e?"undefined":E(e))&&e.prepare?x({},e,e.prepare(o.result)):e})}var t=e.prototype;return t.async=function(){return this.error?Promise.reject(this.error):this.processed?Promise.resolve(this.result):(this.processing||(this.processing=this.runAsync()),this.processing)},t.catch=function(e){return this.async().catch(e)},t.finally=function(e){return this.async().then(e,e)},t.getAsyncError=function(){throw new Error("Use process(css).then(cb) to work with async plugins")},t.handleError=function(e,t){var r=this.result.lastPlugin;try{if(t&&t.addToError(e),this.error=e,"CssSyntaxError"!==e.name||e.plugin){if(r.postcssVersion){0}}else e.plugin=r.postcssPlugin,e.setMessage()}catch(n){console&&console.error&&console.error(n)}return e},t.prepareVisitors=function(){var e=this;this.listeners={};for(var t,r=function(t,r,n){e.listeners[r]||(e.listeners[r]=[]),e.listeners[r].push([t,n])},n=P(this.plugins);!(t=n()).done;){var i=t.value;if("object"===(void 0===i?"undefined":E(i)))for(var o in i){if(!Qs[o]&&/^[A-Z]/.test(o))throw new Error("Unknown event "+o+" in "+i.postcssPlugin+". Try to update PostCSS ("+this.processor.version+" now).");if(!ea[o])if("object"===E(i[o]))for(var s in i[o])r(i,"*"===s?o:o+"-"+s.toLowerCase(),i[o][s]);else"function"==typeof i[o]&&r(i,o,i[o])}}this.hasListener=Object.keys(this.listeners).length>0},t.runAsync=function(){var e=this;return v(function(){var t,r,n,i,o,s,a,c,l,u,d,h;return O(this,function(p){switch(p.label){case 0:e.plugin=0,t=0,p.label=1;case 1:if(!(t<e.plugins.length))return[3,6];if(r=e.plugins[t],!ta(n=e.runOnRoot(r)))return[3,5];p.label=2;case 2:return p.trys.push([2,4,,5]),[4,n];case 3:return p.sent(),[3,5];case 4:throw i=p.sent(),e.handleError(i);case 5:return t++,[3,1];case 6:if(e.prepareVisitors(),!e.hasListener)return[3,18];o=e.result.root,p.label=7;case 7:if(o[$s])return[3,14];o[$s]=!0,s=[na(o)],p.label=8;case 8:if(!(s.length>0))return[3,13];if(!ta(a=e.visitTick(s)))return[3,12];p.label=9;case 9:return p.trys.push([9,11,,12]),[4,a];case 10:return p.sent(),[3,12];case 11:throw c=p.sent(),l=s[s.length-1].node,e.handleError(c,l);case 12:return[3,8];case 13:return[3,7];case 14:if(!e.listeners.OnceExit)return[3,18];u=function(){var t,r,n,i,s;return O(this,function(a){switch(a.label){case 0:t=h.value,r=t[0],n=t[1],e.result.lastPlugin=r,a.label=1;case 1:return a.trys.push([1,6,,7]),"document"!==o.type?[3,3]:(i=o.nodes.map(function(t){return n(t,e.helpers)}),[4,Promise.all(i)]);case 2:return a.sent(),[3,5];case 3:return[4,n(o,e.helpers)];case 4:a.sent(),a.label=5;case 5:return[3,7];case 6:throw s=a.sent(),e.handleError(s);case 7:return[2]}})},d=P(e.listeners.OnceExit),p.label=15;case 15:return(h=d()).done?[3,18]:[5,M(u())];case 16:p.sent(),p.label=17;case 17:return[3,15];case 18:return e.processed=!0,[2,e.stringify()]}})})()},t.runOnRoot=function(e){var t=this;this.result.lastPlugin=e;try{if("object"===(void 0===e?"undefined":E(e))&&e.Once){if("document"===this.result.root.type){var r=this.result.root.nodes.map(function(r){return e.Once(r,t.helpers)});return ta(r[0])?Promise.all(r):r}return e.Once(this.result.root,this.helpers)}if("function"==typeof e)return e(this.result.root,this.result)}catch(gu){throw this.handleError(gu)}},t.stringify=function(){if(this.error)throw this.error;if(this.stringified)return this.result;this.stringified=!0,this.sync();var e=this.result.opts,t=Vs;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);var r=new Ws(t,this.result.root,this.result.opts).generate();return this.result.css=r[0],this.result.map=r[1],this.result},t.sync=function(){if(this.error)throw this.error;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw this.getAsyncError();for(var e,t=P(this.plugins);!(e=t()).done;){var r=e.value;if(ta(this.runOnRoot(r)))throw this.getAsyncError()}if(this.prepareVisitors(),this.hasListener){for(var n=this.result.root;!n[$s];)n[$s]=!0,this.walkSync(n);if(this.listeners.OnceExit)if("document"===n.type)for(var i,o=P(n.nodes);!(i=o()).done;){var s=i.value;this.visitSync(this.listeners.OnceExit,s)}else this.visitSync(this.listeners.OnceExit,n)}return this.result},t.then=function(e,t){return this.async().then(e,t)},t.toString=function(){return this.css},t.visitSync=function(e,t){for(var r,n=P(e);!(r=n()).done;){var i=r.value,o=i[0],s=i[1];this.result.lastPlugin=o;var a=void 0;try{a=s(t,this.helpers)}catch(c){throw this.handleError(c,t.proxyOf)}if("root"!==t.type&&"document"!==t.type&&!t.parent)return!0;if(ta(a))throw this.getAsyncError()}},t.visitTick=function(e){var t=e[e.length-1],r=t.node,n=t.visitors;if("root"===r.type||"document"===r.type||r.parent){if(n.length>0&&t.visitorIndex<n.length){var i=n[t.visitorIndex],o=i[0],s=i[1];t.visitorIndex+=1,t.visitorIndex===n.length&&(t.visitors=[],t.visitorIndex=0),this.result.lastPlugin=o;try{return s(r.toProxy(),this.helpers)}catch(d){throw this.handleError(d,r)}}if(0!==t.iterator){for(var a,c=t.iterator;a=r.nodes[r.indexes[c]];)if(r.indexes[c]+=1,!a[$s])return a[$s]=!0,void e.push(na(a));t.iterator=0,delete r.indexes[c]}for(var l=t.events;t.eventIndex<l.length;){var u=l[t.eventIndex];if(t.eventIndex+=1,0===u)return void(r.nodes&&r.nodes.length&&(r[$s]=!0,t.iterator=r.getIterator()));if(this.listeners[u])return void(t.visitors=this.listeners[u])}e.pop()}else e.pop()},t.walkSync=function(e){var t=this;e[$s]=!0;for(var r,n=P(ra(e));!(r=n()).done;){var i=r.value;if(0===i)e.nodes&&e.each(function(e){e[$s]||t.walkSync(e)});else{var o=this.listeners[i];if(o&&this.visitSync(o,e.toProxy()))return}}},t.warnings=function(){return this.sync().warnings()},w(e,[{key:"content",get:function(){return this.stringify().content}},{key:"css",get:function(){return this.stringify().css}},{key:"map",get:function(){return this.stringify().map}},{key:"messages",get:function(){return this.sync().messages}},{key:"opts",get:function(){return this.result.opts}},{key:"processor",get:function(){return this.result.processor}},{key:"root",get:function(){return this.sync().root}},{key:Symbol.toStringTag,get:function(){return"LazyResult"}}]),e}();sa.registerPostcss=function(e){oa=e};var aa=sa;sa.default=sa,Js.registerLazyResult(sa),Ys.registerLazyResult(sa);var ca=ko,la=Oi,ua=qs,da=Vo,ha=function(){function e(e,t,r){var n;t=t.toString(),this.stringified=!1,this._processor=e,this._css=t,this._opts=r,this._map=void 0;var i=la;this.result=new da(this._processor,n,this._opts),this.result.css=t;var o=this;Object.defineProperty(this.result,"root",{get:function(){return o.root}});var s=new ca(i,n,this._opts,t);if(s.isMap()){var a=s.generate(),c=a[0],l=a[1];c&&(this.result.css=c),l&&(this.result.map=l)}else s.clearAnnotation(),this.result.css=s.css}var t=e.prototype;return t.async=function(){return this.error?Promise.reject(this.error):Promise.resolve(this.result)},t.catch=function(e){return this.async().catch(e)},t.finally=function(e){return this.async().then(e,e)},t.sync=function(){if(this.error)throw this.error;return this.result},t.then=function(e,t){return this.async().then(e,t)},t.toString=function(){return this._css},t.warnings=function(){return[]},w(e,[{key:"content",get:function(){return this.result.css}},{key:"css",get:function(){return this.result.css}},{key:"map",get:function(){return this.result.map}},{key:"messages",get:function(){return[]}},{key:"opts",get:function(){return this.result.opts}},{key:"processor",get:function(){return this.result.processor}},{key:"root",get:function(){if(this._root)return this._root;var e,t=ua;try{e=t(this._css,this._opts)}catch(gu){this.error=gu}if(this.error)throw this.error;return this._root=e,e}},{key:Symbol.toStringTag,get:function(){return"NoWorkResult"}}]),e}(),pa=ha;ha.default=ha;var fa=pa,ma=aa,ga=zo,ya=ks,va=function(){function e(e){void 0===e&&(e=[]),this.version="8.4.38",this.plugins=this.normalize(e)}var t=e.prototype;return t.normalize=function(e){for(var t,r=[],n=P(e);!(t=n()).done;){var i=t.value;if(!0===i.postcss?i=i():i.postcss&&(i=i.postcss),"object"===(void 0===i?"undefined":E(i))&&Array.isArray(i.plugins))r=r.concat(i.plugins);else if("object"===(void 0===i?"undefined":E(i))&&i.postcssPlugin)r.push(i);else if("function"==typeof i)r.push(i);else if("object"!==(void 0===i?"undefined":E(i))||!i.parse&&!i.stringify)throw new Error(i+" is not a PostCSS plugin")}return r},t.process=function(e,t){return void 0===t&&(t={}),this.plugins.length||t.parser||t.stringifier||t.syntax?new ma(this,e,t):new fa(this,e,t)},t.use=function(e){return this.plugins=this.plugins.concat(this.normalize([e])),this},e}(),ba=va;va.default=va,ya.registerProcessor(va),ga.registerProcessor(va);var wa=zi,xa=Ki,_a=Co,ka=vs,Sa=ho,Ca=ks,Ia=As;function Ea(e,t){if(Array.isArray(e))return e.map(function(e){return Ea(e)});var r=e.inputs,n=C(e,["inputs"]);if(r){t=[];for(var i,o=P(r);!(i=o()).done;){var s=x({},i.value,{__proto__:Sa.prototype});s.map&&(s.map=x({},s.map,{__proto__:xa.prototype})),t.push(s)}}if(n.nodes&&(n.nodes=e.nodes.map(function(e){return Ea(e,t)})),n.source){var a=n.source,c=a.inputId,l=C(a,["inputId"]);n.source=l,null!=c&&(n.source.input=t[c])}if("root"===n.type)return new Ca(n);if("decl"===n.type)return new wa(n);if("rule"===n.type)return new Ia(n);if("comment"===n.type)return new _a(n);if("atrule"===n.type)return new ka(n);throw new Error("Unknown node type: "+e.type)}var Na=Ea;Ea.default=Ea;var Aa=Si,Pa=zi,Oa=aa,Ma=Fo,Ta=ba,Ra=Oi,ja=Na,Da=zo,Fa=$o,La=Co,Ua=vs,Ba=Vo,za=ho,qa=qs,$a=Cs,Ga=As,Wa=ks,Va=Ui;function Ha(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return 1===t.length&&Array.isArray(t[0])&&(t=t[0]),new Ta(t)}Ha.plugin=function(e,t){var r,n=!1;function i(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];console&&console.warn&&!n&&(n=!0,console.warn(e+": postcss.plugin was deprecated. Migration guide:\nhttps://evilmartians.com/chronicles/postcss-8-plugin-migration"),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(e+": ้้ข postcss.plugin ่ขซๅผ็จ. ่ฟ็งปๆๅ:\nhttps://www.w3ctech.com/topic/2226"));var s=t.apply(void 0,[].concat(i));return s.postcssPlugin=e,s.postcssVersion=(new Ta).version,s}return Object.defineProperty(i,"postcss",{get:function(){return r||(r=i()),r}}),i.process=function(e,t,r){return Ha([i(r)]).process(e,t)},i},Ha.stringify=Ra,Ha.parse=qa,Ha.fromJSON=ja,Ha.list=$a,Ha.comment=function(e){return new La(e)},Ha.atRule=function(e){return new Ua(e)},Ha.decl=function(e){return new Pa(e)},Ha.rule=function(e){return new Ga(e)},Ha.root=function(e){return new Wa(e)},Ha.document=function(e){return new Da(e)},Ha.CssSyntaxError=Aa,Ha.Declaration=Pa,Ha.Container=Ma,Ha.Processor=Ta,Ha.Document=Da,Ha.Comment=La,Ha.Warning=Fa,Ha.AtRule=Ua,Ha.Result=Ba,Ha.Input=za,Ha.Rule=Ga,Ha.Root=Wa,Ha.Node=Va,Oa.registerPostcss(Ha);var Ya=Ha;Ha.default=Ha;var Za=fi(Ya);Za.stringify,Za.fromJSON,Za.plugin,Za.parse,Za.list,Za.document,Za.comment,Za.atRule,Za.rule,Za.decl,Za.root,Za.CssSyntaxError,Za.Declaration,Za.Container,Za.Processor,Za.Document,Za.Comment,Za.Warning,Za.AtRule,Za.Result,Za.Input,Za.Rule,Za.Root,Za.Node;var Ka=function(){function e(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];pi(this,"parentElement",null),pi(this,"parentNode",null),pi(this,"ownerDocument"),pi(this,"firstChild",null),pi(this,"lastChild",null),pi(this,"previousSibling",null),pi(this,"nextSibling",null),pi(this,"ELEMENT_NODE",1),pi(this,"TEXT_NODE",3),pi(this,"nodeType"),pi(this,"nodeName"),pi(this,"RRNodeType")}var t=e.prototype;return t.contains=function(t){if(!S(t,e))return!1;if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1},t.appendChild=function(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")},t.insertBefore=function(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")},t.removeChild=function(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")},t.toString=function(){return"RRNode"},w(e,[{key:"childNodes",get:function(){for(var e=[],t=this.firstChild;t;)e.push(t),t=t.nextSibling;return e}}]),e}(),Ja={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},Xa={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},Qa={};function ec(e){if(Qa[e])return Qa[e];var t=globalThis[e],r=t.prototype,n=e in Ja?Ja[e]:void 0,i=Boolean(n&&n.every(function(e){var t,n;return Boolean(null==(n=null==(t=Object.getOwnPropertyDescriptor(r,e))?void 0:t.get)?void 0:n.toString().includes("[native code]"))})),o=e in Xa?Xa[e]:void 0,s=Boolean(o&&o.every(function(e){var t;return"function"==typeof r[e]&&(null==(t=r[e])?void 0:t.toString().includes("[native code]"))}));if(i&&s&&!globalThis.Zone)return Qa[e]=t.prototype,t.prototype;try{var a=document.createElement("iframe");document.body.appendChild(a);var c=a.contentWindow;if(!c)return t.prototype;var l=c[e].prototype;return document.body.removeChild(a),l?Qa[e]=l:r}catch(u){return r}}var tc={};function rc(e,t,r){var n,i=e+"."+String(r);if(tc[i])return tc[i].call(t);var o=ec(e),s=null==(n=Object.getOwnPropertyDescriptor(o,r))?void 0:n.get;return s?(tc[i]=s,s.call(t)):t[r]}var nc={};function ic(e,t,r){var n=e+"."+String(r);if(nc[n])return nc[n].bind(t);var i=ec(e)[r];return"function"!=typeof i?t[r]:(nc[n]=i,i.bind(t))}function oc(){return ec("MutationObserver").constructor}function sc(e,t,r){try{if(!(t in e))return function(){};var n=e[t],i=r(n);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=i,function(){e[t]=n}}catch(o){return function(){}}}var ac={childNodes:function(e){return rc("Node",e,"childNodes")},parentNode:function(e){return rc("Node",e,"parentNode")},parentElement:function(e){return rc("Node",e,"parentElement")},textContent:function(e){return rc("Node",e,"textContent")},contains:function(e,t){return ic("Node",e,"contains")(t)},getRootNode:function(e){return ic("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?rc("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?rc("Element",e,"shadowRoot"):null},querySelector:function(e,t){return rc("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return rc("Element",e,"querySelectorAll")(t)},mutationObserver:oc,patch:sc};function cc(e,t,r){void 0===r&&(r=document);var n={capture:!0,passive:!0};return r.addEventListener(e,t,n),function(){return r.removeEventListener(e,t,n)}}var lc="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.",uc={map:{},getId:function(){return console.error(lc),-1},getNode:function(){return console.error(lc),null},removeNodeFromMap:function(){console.error(lc)},has:function(){return console.error(lc),!1},reset:function(){console.error(lc)}};function dc(e,t,r){void 0===r&&(r={});var n=null,i=0;return function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];var c=Date.now();i||!1!==r.leading||(i=c);var l=t-(c-i),u=this;l<=0||l>t?(n&&(clearTimeout(n),n=null),i=c,e.apply(u,s)):n||!1===r.trailing||(n=setTimeout(function(){i=!1===r.leading?0:Date.now(),n=null,e.apply(u,s)},l))}}function hc(e,t,r,n,i){void 0===i&&(i=window);var o=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,n?r:{set:function(e){var t=this;setTimeout(function(){r.set.call(t,e)},0),o&&o.set&&o.set.call(this,e)}}),function(){return hc(e,t,o||{},!0)}}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(uc=new Proxy(uc,{get:function(e,t,r){return"map"===t&&console.error(lc),Reflect.get(e,t,r)}}));var pc=Date.now;function fc(e){var t,r,n,i,o=e.document;return{left:o.scrollingElement?o.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:o.documentElement.scrollLeft||(null==o?void 0:o.body)&&(null==(t=ac.parentElement(o.body))?void 0:t.scrollLeft)||(null==(r=null==o?void 0:o.body)?void 0:r.scrollLeft)||0,top:o.scrollingElement?o.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==o?void 0:o.documentElement.scrollTop)||(null==o?void 0:o.body)&&(null==(n=ac.parentElement(o.body))?void 0:n.scrollTop)||(null==(i=null==o?void 0:o.body)?void 0:i.scrollTop)||0}}function mc(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function gc(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function yc(e){return e?e.nodeType===e.ELEMENT_NODE?e:ac.parentElement(e):null}function vc(e,t,r,n){if(!e)return!1;var i=yc(e);if(!i)return!1;try{if("string"==typeof t){if(i.classList.contains(t))return!0;if(n&&null!==i.closest("."+t))return!0}else if(Ce(i,t,n))return!0}catch(o){}if(r){if(i.matches(r))return!0;if(n&&null!==i.closest(r))return!0}return!1}function bc(e,t,r){return!("TITLE"!==e.tagName||!r.headTitleMutations)||-2===t.getId(e)}function wc(e,t){if(Z(e))return!1;var r=t.getId(e);if(!t.has(r))return!0;var n=ac.parentNode(e);return(!n||n.nodeType!==e.DOCUMENT_NODE)&&(!n||wc(n,t))}function xc(e){return Boolean(e.changedTouches)}function _c(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function kc(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Sc(e){return!!e&&(S(e,Ka)&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(ac.shadowRoot(e)))}/[1-9][0-9]{12}/.test(Date.now().toString())||(pc=function(){return(new Date).getTime()});var Cc=function(){function e(){j(this,"id",1),j(this,"styleIDMap",new WeakMap),j(this,"idStyleMap",new Map)}var t=e.prototype;return t.getId=function(e){var t;return null!=(t=this.styleIDMap.get(e))?t:-1},t.has=function(e){return this.styleIDMap.has(e)},t.add=function(e,t){return this.has(e)?this.getId(e):(r=void 0===t?this.id++:t,this.styleIDMap.set(e,r),this.idStyleMap.set(r,e),r);var r},t.getStyle=function(e){return this.idStyleMap.get(e)||null},t.reset=function(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1},t.generateId=function(){return this.id++},e}();function Ic(e){var t,r=null;return"getRootNode"in e&&(null==(t=ac.getRootNode(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&ac.host(ac.getRootNode(e))&&(r=ac.host(ac.getRootNode(e))),r}function Ec(e){var t=e.ownerDocument;if(!t)return!1;var r=function(e){for(var t,r=e;t=Ic(r);)r=t;return r}(e);return ac.contains(t,r)}function Nc(e){var t=e.ownerDocument;return!!t&&(ac.contains(t,e)||Ec(e))}var Ac=function(e){return e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e}(Ac||{}),Pc=function(e){return e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e}(Pc||{}),Oc=function(e){return e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e}(Oc||{}),Mc=function(e){return e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e}(Mc||{}),Tc=function(e){return e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e}(Tc||{}),Rc=function(e){return e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e}(Rc||{}),jc=function(e){return e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e}(jc||{});function Dc(e){return"__ln"in e}var Fc,Lc=function(){function e(){j(this,"length",0),j(this,"head",null),j(this,"tail",null)}var t=e.prototype;return t.get=function(e){if(e>=this.length)throw new Error("Position outside of list range");for(var t=this.head,r=0;r<e;r++)t=(null==t?void 0:t.next)||null;return t},t.addNode=function(e){var t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&Dc(e.previousSibling)){var r=e.previousSibling.__ln.next;t.next=r,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,r&&(r.previous=t)}else if(e.nextSibling&&Dc(e.nextSibling)&&e.nextSibling.__ln.previous){var n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++},t.removeNode=function(e){var t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)},e}(),Uc=function(e,t){return e+"@"+t},Bc=function(){function e(){var e=this;j(this,"frozen",!1),j(this,"locked",!1),j(this,"texts",[]),j(this,"attributes",[]),j(this,"attributeMap",new WeakMap),j(this,"removes",[]),j(this,"mapRemoves",[]),j(this,"movedMap",{}),j(this,"addedSet",new Set),j(this,"movedSet",new Set),j(this,"droppedSet",new Set),j(this,"removesSubTreeCache",new Set),j(this,"mutationCb"),j(this,"blockClass"),j(this,"blockSelector"),j(this,"maskTextClass"),j(this,"maskTextSelector"),j(this,"inlineStylesheet"),j(this,"maskInputOptions"),j(this,"maskTextFn"),j(this,"maskInputFn"),j(this,"keepIframeSrcFn"),j(this,"recordCanvas"),j(this,"inlineImages"),j(this,"slimDOMOptions"),j(this,"dataURLOptions"),j(this,"doc"),j(this,"mirror"),j(this,"iframeManager"),j(this,"stylesheetManager"),j(this,"shadowDomManager"),j(this,"canvasManager"),j(this,"processedNodeManager"),j(this,"unattachedDoc"),j(this,"processMutations",function(t){t.forEach(e.processMutation),e.emit()}),j(this,"emit",function(){if(!e.frozen&&!e.locked){for(var t=[],r=new Set,n=new Lc,i=function(t){for(var r=t,n=-2;-2===n;)n=(r=r&&r.nextSibling)&&e.mirror.getId(r);return n},o=function(o){var s=ac.parentNode(o);if(s&&Nc(o)){var a=!1;if(o.nodeType===Node.TEXT_NODE){var c=s.tagName;if("TEXTAREA"===c)return;"STYLE"===c&&e.addedSet.has(s)&&(a=!0)}var l=Z(s)?e.mirror.getId(Ic(o)):e.mirror.getId(s),u=i(o);if(-1===l||-1===u)return n.addNode(o);var d=Ae(o,{doc:e.doc,mirror:e.mirror,blockClass:e.blockClass,blockSelector:e.blockSelector,maskTextClass:e.maskTextClass,maskTextSelector:e.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:e.inlineStylesheet,maskInputOptions:e.maskInputOptions,maskTextFn:e.maskTextFn,maskInputFn:e.maskInputFn,slimDOMOptions:e.slimDOMOptions,dataURLOptions:e.dataURLOptions,recordCanvas:e.recordCanvas,inlineImages:e.inlineImages,onSerialize:function(t){_c(t,e.mirror)&&e.iframeManager.addIframe(t),kc(t,e.mirror)&&e.stylesheetManager.trackLinkElement(t),Sc(o)&&e.shadowDomManager.addShadowRoot(ac.shadowRoot(o),e.doc)},onIframeLoad:function(t,r){e.iframeManager.attachIframe(t,r),e.shadowDomManager.observeAttachShadow(t)},onStylesheetLoad:function(t,r){e.stylesheetManager.attachLinkElement(t,r)},cssCaptured:a});d&&(t.push({parentId:l,nextId:u,node:d}),r.add(d.id))}};e.mapRemoves.length;)e.mirror.removeNodeFromMap(e.mapRemoves.shift());for(var s,a=P(e.movedSet);!(s=a()).done;){var c=s.value;qc(e.removesSubTreeCache,c,e.mirror)&&!e.movedSet.has(ac.parentNode(c))||o(c)}for(var l,u=P(e.addedSet);!(l=u()).done;){var d=l.value;$c(e.droppedSet,d)||qc(e.removesSubTreeCache,d,e.mirror)?$c(e.movedSet,d)?o(d):e.droppedSet.add(d):o(d)}for(var h=null;n.length;){var p=null;if(h){var f=e.mirror.getId(ac.parentNode(h.value)),m=i(h.value);-1!==f&&-1!==m&&(p=h)}if(!p)for(var g=n.tail;g;){var y=g;if(g=g.previous,y){var v=e.mirror.getId(ac.parentNode(y.value));if(-1===i(y.value))continue;if(-1!==v){p=y;break}var b=y.value,w=ac.parentNode(b);if(w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE){var x=ac.host(w);if(-1!==e.mirror.getId(x)){p=y;break}}}}if(!p){for(;n.head;)n.removeNode(n.head.value);break}h=p.previous,n.removeNode(p.value),o(p.value)}var _={texts:e.texts.map(function(t){var r=t.node,n=ac.parentNode(r);return n&&"TEXTAREA"===n.tagName&&e.genTextAreaValueMutation(n),{id:e.mirror.getId(r),value:t.value}}).filter(function(e){return!r.has(e.id)}).filter(function(t){return e.mirror.has(t.id)}),attributes:e.attributes.map(function(t){var r=t.attributes;if("string"==typeof r.style){var n=JSON.stringify(t.styleDiff),i=JSON.stringify(t._unchangedStyles);n.length<r.style.length&&(n+i).split("var(").length===r.style.split("var(").length&&(r.style=t.styleDiff)}return{id:e.mirror.getId(t.node),attributes:r}}).filter(function(e){return!r.has(e.id)}).filter(function(t){return e.mirror.has(t.id)}),removes:e.removes,adds:t};(_.texts.length||_.attributes.length||_.removes.length||_.adds.length)&&(e.texts=[],e.attributes=[],e.attributeMap=new WeakMap,e.removes=[],e.addedSet=new Set,e.movedSet=new Set,e.droppedSet=new Set,e.removesSubTreeCache=new Set,e.movedMap={},e.mutationCb(_))}}),j(this,"genTextAreaValueMutation",function(t){var r=e.attributeMap.get(t);r||(r={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},e.attributes.push(r),e.attributeMap.set(t,r));var n=Array.from(ac.childNodes(t),function(e){return ac.textContent(e)||""}).join("");r.attributes.value=ee({element:t,maskInputOptions:e.maskInputOptions,tagName:t.tagName,type:ne(t),value:n,maskInputFn:e.maskInputFn})}),j(this,"processMutation",function(t){if(!bc(t.target,e.mirror,e.slimDOMOptions))switch(t.type){case"characterData":var r=ac.textContent(t.target);vc(t.target,e.blockClass,e.blockSelector,!1)||r===t.oldValue||e.texts.push({value:Ie(t.target,e.maskTextClass,e.maskTextSelector,!0)&&r?e.maskTextFn?e.maskTextFn(r,yc(t.target)):r.replace(/[\S]/g,"*"):r,node:t.target});break;case"attributes":var n=t.target,i=t.attributeName,o=t.target.getAttribute(i);if("value"===i){var s=ne(n);o=ee({element:n,maskInputOptions:e.maskInputOptions,tagName:n.tagName,type:s,value:o,maskInputFn:e.maskInputFn})}if(vc(t.target,e.blockClass,e.blockSelector,!1)||o===t.oldValue)return;var a=e.attributeMap.get(t.target);if("IFRAME"===n.tagName&&"src"===i&&!e.keepIframeSrcFn(o)){if(n.contentDocument)return;i="rr_src"}if(a||(a={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},e.attributes.push(a),e.attributeMap.set(t.target,a)),"type"===i&&"INPUT"===n.tagName&&"password"===(t.oldValue||"").toLowerCase()&&n.setAttribute("data-rr-is-password","true"),!Se(n.tagName,i))if(a.attributes[i]=ke(e.doc,te(n.tagName),te(i),o),"style"===i){if(!e.unattachedDoc)try{e.unattachedDoc=document.implementation.createHTMLDocument()}catch(y){e.unattachedDoc=e.doc}var c=e.unattachedDoc.createElement("span");t.oldValue&&c.setAttribute("style",t.oldValue);for(var l,u=P(Array.from(n.style));!(l=u()).done;){var d=l.value,h=n.style.getPropertyValue(d),p=n.style.getPropertyPriority(d);h!==c.style.getPropertyValue(d)||p!==c.style.getPropertyPriority(d)?a.styleDiff[d]=""===p?h:[h,p]:a._unchangedStyles[d]=[h,p]}for(var f,m=P(Array.from(c.style));!(f=m()).done;){var g=f.value;""===n.style.getPropertyValue(g)&&(a.styleDiff[g]=!1)}}else"open"===i&&"DIALOG"===n.tagName&&(n.matches("dialog:modal")?a.attributes.rr_open_mode="modal":a.attributes.rr_open_mode="non-modal");break;case"childList":if(vc(t.target,e.blockClass,e.blockSelector,!0))return;if("TEXTAREA"===t.target.tagName)return void e.genTextAreaValueMutation(t.target);t.addedNodes.forEach(function(r){return e.genAdds(r,t.target)}),t.removedNodes.forEach(function(r){var n=e.mirror.getId(r),i=Z(t.target)?e.mirror.getId(ac.host(t.target)):e.mirror.getId(t.target);vc(t.target,e.blockClass,e.blockSelector,!1)||bc(r,e.mirror,e.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(r,e.mirror)||(e.addedSet.has(r)?(zc(e.addedSet,r),e.droppedSet.add(r)):e.addedSet.has(t.target)&&-1===n||wc(t.target,e.mirror)||(e.movedSet.has(r)&&e.movedMap[Uc(n,i)]?zc(e.movedSet,r):(e.removes.push({parentId:i,id:n,isShadow:!(!Z(t.target)||!K(t.target))||void 0}),function(e,t){var r=[e];for(;r.length;){var n=r.pop();t.has(n)||(t.add(n),ac.childNodes(n).forEach(function(e){return r.push(e)}))}}(r,e.removesSubTreeCache))),e.mapRemoves.push(r))})}}),j(this,"genAdds",function(t,r){if(!e.processedNodeManager.inOtherBuffer(t,e)&&!e.addedSet.has(t)&&!e.movedSet.has(t)){if(e.mirror.hasNode(t)){if(bc(t,e.mirror,e.slimDOMOptions))return;e.movedSet.add(t);var n=null;r&&e.mirror.hasNode(r)&&(n=e.mirror.getId(r)),n&&-1!==n&&(e.movedMap[Uc(e.mirror.getId(t),n)]=!0)}else e.addedSet.add(t),e.droppedSet.delete(t);vc(t,e.blockClass,e.blockSelector,!1)||(ac.childNodes(t).forEach(function(t){return e.genAdds(t)}),Sc(t)&&ac.childNodes(ac.shadowRoot(t)).forEach(function(r){e.processedNodeManager.add(r,e),e.genAdds(r,t)}))}})}var t=e.prototype;return t.init=function(e){var t=this;["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(function(r){t[r]=e[r]})},t.freeze=function(){this.frozen=!0,this.canvasManager.freeze()},t.unfreeze=function(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()},t.isFrozen=function(){return this.frozen},t.lock=function(){this.locked=!0,this.canvasManager.lock()},t.unlock=function(){this.locked=!1,this.canvasManager.unlock(),this.emit()},t.reset=function(){this.shadowDomManager.reset(),this.canvasManager.reset()},e}();function zc(e,t){e.delete(t),ac.childNodes(t).forEach(function(t){return zc(e,t)})}function qc(e,t,r){return 0!==e.size&&function(e,t){var r=ac.parentNode(t);return!!r&&e.has(r)}(e,t)}function $c(e,t){return 0!==e.size&&Gc(e,t)}function Gc(e,t){var r=ac.parentNode(t);return!!r&&(!!e.has(r)||Gc(e,r))}var Wc=function(e){if(!Fc)return e;return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];try{return e.apply(void 0,[].concat(r))}catch(gu){if(Fc&&!0===Fc(gu))return;throw gu}}},Vc=[];function Hc(e){try{if("composedPath"in e){var t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(r){}return e&&e.target}function Yc(e,t){var r=new Bc;Vc.push(r),r.init(e);var n=new(oc())(Wc(r.processMutations.bind(r)));return n.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),n}function Zc(e){var t=e.mouseInteractionCb,r=e.doc,n=e.mirror,i=e.blockClass,o=e.blockSelector,s=e.sampling;if(!1===s.mouseInteraction)return function(){};var a=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,c=[],l=null;return Object.keys(Oc).filter(function(e){return Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==a[e]}).forEach(function(e){var s=te(e),a=function(e){return function(r){var s=Hc(r);if(!vc(s,i,o,!0)){var a=null,c=e;if("pointerType"in r){switch(r.pointerType){case"mouse":a=Mc.Mouse;break;case"touch":a=Mc.Touch;break;case"pen":a=Mc.Pen}a===Mc.Touch?Oc[e]===Oc.MouseDown?c="TouchStart":Oc[e]===Oc.MouseUp&&(c="TouchEnd"):Mc.Pen}else xc(r)&&(a=Mc.Touch);null!==a?(l=a,(c.startsWith("Touch")&&a===Mc.Touch||c.startsWith("Mouse")&&a===Mc.Mouse)&&(a=null)):Oc[e]===Oc.Click&&(a=l,l=null);var u=xc(r)?r.changedTouches[0]:r;if(u){var d=n.getId(s),h=u.clientX,p=u.clientY;Wc(t)(x({type:Oc[c],id:d,x:h,y:p},null!==a&&{pointerType:a}))}}}}(e);if(window.PointerEvent)switch(Oc[e]){case Oc.MouseDown:case Oc.MouseUp:s=s.replace("mouse","pointer");break;case Oc.TouchStart:case Oc.TouchEnd:return}c.push(cc(s,a,r))}),Wc(function(){c.forEach(function(e){return e()})})}function Kc(e){var t=e.scrollCb,r=e.doc,n=e.mirror,i=e.blockClass,o=e.blockSelector,s=e.sampling;return cc("scroll",Wc(dc(Wc(function(e){var s=Hc(e);if(s&&!vc(s,i,o,!0)){var a=n.getId(s);if(s===r&&r.defaultView){var c=fc(r.defaultView);t({id:a,x:c.left,y:c.top})}else t({id:a,x:s.scrollLeft,y:s.scrollTop})}}),s.scroll||100)),r)}var Jc=["INPUT","TEXTAREA","SELECT"],Xc=new WeakMap;function Qc(e){return function(e,t){if(nl("CSSGroupingRule")&&S(e.parentRule,CSSGroupingRule)||nl("CSSMediaRule")&&S(e.parentRule,CSSMediaRule)||nl("CSSSupportsRule")&&S(e.parentRule,CSSSupportsRule)||nl("CSSConditionRule")&&S(e.parentRule,CSSConditionRule)){var r=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(r)}else if(e.parentStyleSheet){var n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function el(e,t,r){var n,i;return e?(e.ownerNode?n=t.getId(e.ownerNode):i=r.getId(e),{styleId:i,id:n}):{}}function tl(e,t){var r,n,i,o=e.mirror,s=e.stylesheetManager,a=null;a="#document"===t.nodeName?o.getId(t):o.getId(ac.host(t));var c="#document"===t.nodeName?null==(r=t.defaultView)?void 0:r.Document:null==(i=null==(n=t.ownerDocument)?void 0:n.defaultView)?void 0:i.ShadowRoot,l=(null==c?void 0:c.prototype)?Object.getOwnPropertyDescriptor(null==c?void 0:c.prototype,"adoptedStyleSheets"):void 0;return null!==a&&-1!==a&&c&&l?(Object.defineProperty(t,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:function(){var e;return null==(e=l.get)?void 0:e.call(this)},set:function(e){var t,r=null==(t=l.set)?void 0:t.call(this,e);if(null!==a&&-1!==a)try{s.adoptStyleSheets(e,a)}catch(n){}return r}}),Wc(function(){Object.defineProperty(t,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):function(){}}function rl(e,t){void 0===t&&(t={});var r,n=e.doc.defaultView;if(!n)return function(){};!function(e,t){var r=e.mutationCb,n=e.mousemoveCb,i=e.mouseInteractionCb,o=e.scrollCb,s=e.viewportResizeCb,a=e.inputCb,c=e.mediaInteractionCb,l=e.styleSheetRuleCb,u=e.styleDeclarationCb,d=e.canvasMutationCb,h=e.fontCb,p=e.selectionCb,f=e.customElementCb;e.mutationCb=function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var o;t.mutation&&(o=t).mutation.apply(o,[].concat(n)),r.apply(void 0,[].concat(n))},e.mousemoveCb=function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];var o;t.mousemove&&(o=t).mousemove.apply(o,[].concat(r)),n.apply(void 0,[].concat(r))},e.mouseInteractionCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o;t.mouseInteraction&&(o=t).mouseInteraction.apply(o,[].concat(r)),i.apply(void 0,[].concat(r))},e.scrollCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i;t.scroll&&(i=t).scroll.apply(i,[].concat(r)),o.apply(void 0,[].concat(r))},e.viewportResizeCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i;t.viewportResize&&(i=t).viewportResize.apply(i,[].concat(r)),s.apply(void 0,[].concat(r))},e.inputCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i;t.input&&(i=t).input.apply(i,[].concat(r)),a.apply(void 0,[].concat(r))},e.mediaInteractionCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i;t.mediaInteaction&&(i=t).mediaInteaction.apply(i,[].concat(r)),c.apply(void 0,[].concat(r))},e.styleSheetRuleCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i;t.styleSheetRule&&(i=t).styleSheetRule.apply(i,[].concat(r)),l.apply(void 0,[].concat(r))},e.styleDeclarationCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i;t.styleDeclaration&&(i=t).styleDeclaration.apply(i,[].concat(r)),u.apply(void 0,[].concat(r))},e.canvasMutationCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i;t.canvasMutation&&(i=t).canvasMutation.apply(i,[].concat(r)),d.apply(void 0,[].concat(r))},e.fontCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i;t.font&&(i=t).font.apply(i,[].concat(r)),h.apply(void 0,[].concat(r))},e.selectionCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i;t.selection&&(i=t).selection.apply(i,[].concat(r)),p.apply(void 0,[].concat(r))},e.customElementCb=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i;t.customElement&&(i=t).customElement.apply(i,[].concat(r)),f.apply(void 0,[].concat(r))}}(e,t),e.recordDOM&&(r=Yc(e,e.doc));var i,o,s,a,c,l=function(e){var t=e.mousemoveCb,r=e.sampling,n=e.doc,i=e.mirror;if(!1===r.mousemove)return function(){};var o,s="number"==typeof r.mousemove?r.mousemove:50,a="number"==typeof r.mousemoveCallback?r.mousemoveCallback:500,c=[],l=dc(Wc(function(e){var r=Date.now()-o;t(c.map(function(e){return e.timeOffset-=r,e}),e),c=[],o=null}),a),u=Wc(dc(Wc(function(e){var t=Hc(e),r=xc(e)?e.changedTouches[0]:e,n=r.clientX,s=r.clientY;o||(o=pc()),c.push({x:n,y:s,id:i.getId(t),timeOffset:pc()-o}),l("undefined"!=typeof DragEvent&&S(e,DragEvent)?Pc.Drag:S(e,MouseEvent)?Pc.MouseMove:Pc.TouchMove)}),s,{trailing:!1})),d=[cc("mousemove",u,n),cc("touchmove",u,n),cc("drag",u,n)];return Wc(function(){d.forEach(function(e){return e()})})}(e),u=Zc(e),d=Kc(e),h=(i={win:n},o=e.viewportResizeCb,s=i.win,a=-1,c=-1,cc("resize",Wc(dc(Wc(function(){var e=mc(),t=gc();a===e&&c===t||(o({width:Number(t),height:Number(e)}),a=e,c=t)}),200)),s)),p=function(e){var t=e.inputCb,r=e.doc,n=e.mirror,i=e.blockClass,o=e.blockSelector,s=e.ignoreClass,a=e.ignoreSelector,c=e.maskInputOptions,l=e.maskInputFn,u=e.sampling,d=e.userTriggeredOnInput;function h(e){var t=Hc(e),n=e.isTrusted,u=t&&t.tagName;if(t&&"OPTION"===u&&(t=ac.parentElement(t)),t&&u&&!(Jc.indexOf(u)<0)&&!vc(t,i,o,!0)&&!(t.classList.contains(s)||a&&t.matches(a))){var h=t.value,f=!1,m=ne(t)||"";"radio"===m||"checkbox"===m?f=t.checked:(c[u.toLowerCase()]||c[m])&&(h=ee({element:t,maskInputOptions:c,tagName:u,type:m,value:h,maskInputFn:l})),p(t,d?{text:h,isChecked:f,userTriggered:n}:{text:h,isChecked:f});var g=t.name;"radio"===m&&g&&f&&r.querySelectorAll('input[type="radio"][name="'+g+'"]').forEach(function(e){if(e!==t){var r=e.value;p(e,d?{text:r,isChecked:!f,userTriggered:!1}:{text:r,isChecked:!f})}})}}function p(e,r){var i=Xc.get(e);if(!i||i.text!==r.text||i.isChecked!==r.isChecked){Xc.set(e,r);var o=n.getId(e);Wc(t)(x({},r,{id:o}))}}var f=("last"===u.input?["change"]:["input","change"]).map(function(e){return cc(e,Wc(h),r)}),m=r.defaultView;if(!m)return function(){f.forEach(function(e){return e()})};var g,y=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),v=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return y&&y.set&&(g=f).push.apply(g,[].concat(v.map(function(e){return hc(e[0],e[1],{set:function(){Wc(h)({target:this,isTrusted:!1})}},!1,m)}))),Wc(function(){f.forEach(function(e){return e()})})}(e),f=function(e){var t=e.mediaInteractionCb,r=e.blockClass,n=e.blockSelector,i=e.mirror,o=e.sampling,s=e.doc,a=Wc(function(e){return dc(Wc(function(o){var s=Hc(o);if(s&&!vc(s,r,n,!0)){var a=s.currentTime,c=s.volume,l=s.muted,u=s.playbackRate,d=s.loop;t({type:e,id:i.getId(s),currentTime:a,volume:c,muted:l,playbackRate:u,loop:d})}}),o.media||500)}),c=[cc("play",a(Rc.Play),s),cc("pause",a(Rc.Pause),s),cc("seeked",a(Rc.Seeked),s),cc("volumechange",a(Rc.VolumeChange),s),cc("ratechange",a(Rc.RateChange),s)];return Wc(function(){c.forEach(function(e){return e()})})}(e),m=function(){},g=function(){},y=function(){},v=function(){};e.recordDOM&&(m=function(e,t){var r=e.styleSheetRuleCb,n=e.mirror,i=e.stylesheetManager,o=t.win;if(!o.CSSStyleSheet||!o.CSSStyleSheet.prototype)return function(){};var s=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=new Proxy(s,{apply:Wc(function(e,t,o){var s=o[0],a=o[1],c=el(t,n,i.styleMirror),l=c.id,u=c.styleId;return(l&&-1!==l||u&&-1!==u)&&r({id:l,styleId:u,adds:[{rule:s,index:a}]}),e.apply(t,o)})}),o.CSSStyleSheet.prototype.addRule=function(e,t,r){void 0===r&&(r=this.cssRules.length);var n=e+" { "+t+" }";return o.CSSStyleSheet.prototype.insertRule.apply(this,[n,r])};var a,c,l=o.CSSStyleSheet.prototype.deleteRule;o.CSSStyleSheet.prototype.deleteRule=new Proxy(l,{apply:Wc(function(e,t,o){var s=o[0],a=el(t,n,i.styleMirror),c=a.id,l=a.styleId;return(c&&-1!==c||l&&-1!==l)&&r({id:c,styleId:l,removes:[{index:s}]}),e.apply(t,o)})}),o.CSSStyleSheet.prototype.removeRule=function(e){return o.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},o.CSSStyleSheet.prototype.replace&&(a=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:Wc(function(e,t,o){var s=o[0],a=el(t,n,i.styleMirror),c=a.id,l=a.styleId;return(c&&-1!==c||l&&-1!==l)&&r({id:c,styleId:l,replace:s}),e.apply(t,o)})})),o.CSSStyleSheet.prototype.replaceSync&&(c=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=new Proxy(c,{apply:Wc(function(e,t,o){var s=o[0],a=el(t,n,i.styleMirror),c=a.id,l=a.styleId;return(c&&-1!==c||l&&-1!==l)&&r({id:c,styleId:l,replaceSync:s}),e.apply(t,o)})}));var u={};il("CSSGroupingRule")?u.CSSGroupingRule=o.CSSGroupingRule:(il("CSSMediaRule")&&(u.CSSMediaRule=o.CSSMediaRule),il("CSSConditionRule")&&(u.CSSConditionRule=o.CSSConditionRule),il("CSSSupportsRule")&&(u.CSSSupportsRule=o.CSSSupportsRule));var d={};return Object.entries(u).forEach(function(e){var t=e[0],o=e[1];d[t]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(d[t].insertRule,{apply:Wc(function(e,t,o){var s=o[0],a=o[1],c=el(t.parentStyleSheet,n,i.styleMirror),l=c.id,u=c.styleId;return(l&&-1!==l||u&&-1!==u)&&r({id:l,styleId:u,adds:[{rule:s,index:[].concat(Qc(t),[a||0])}]}),e.apply(t,o)})}),o.prototype.deleteRule=new Proxy(d[t].deleteRule,{apply:Wc(function(e,t,o){var s=o[0],a=el(t.parentStyleSheet,n,i.styleMirror),c=a.id,l=a.styleId;return(c&&-1!==c||l&&-1!==l)&&r({id:c,styleId:l,removes:[{index:[].concat(Qc(t),[s])}]}),e.apply(t,o)})})}),Wc(function(){o.CSSStyleSheet.prototype.insertRule=s,o.CSSStyleSheet.prototype.deleteRule=l,a&&(o.CSSStyleSheet.prototype.replace=a),c&&(o.CSSStyleSheet.prototype.replaceSync=c),Object.entries(u).forEach(function(e){var t=e[0],r=e[1];r.prototype.insertRule=d[t].insertRule,r.prototype.deleteRule=d[t].deleteRule})})}(e,{win:n}),g=tl(e,e.doc),y=function(e,t){var r=e.styleDeclarationCb,n=e.mirror,i=e.ignoreCSSAttributes,o=e.stylesheetManager,s=t.win,a=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=new Proxy(a,{apply:Wc(function(e,t,s){var c,l=s[0],u=s[1],d=s[2];if(i.has(l))return a.apply(t,[l,u,d]);var h=el(null==(c=t.parentRule)?void 0:c.parentStyleSheet,n,o.styleMirror),p=h.id,f=h.styleId;return(p&&-1!==p||f&&-1!==f)&&r({id:p,styleId:f,set:{property:l,value:u,priority:d},index:Qc(t.parentRule)}),e.apply(t,s)})});var c=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=new Proxy(c,{apply:Wc(function(e,t,s){var a,l=s[0];if(i.has(l))return c.apply(t,[l]);var u=el(null==(a=t.parentRule)?void 0:a.parentStyleSheet,n,o.styleMirror),d=u.id,h=u.styleId;return(d&&-1!==d||h&&-1!==h)&&r({id:d,styleId:h,remove:{property:l},index:Qc(t.parentRule)}),e.apply(t,s)})}),Wc(function(){s.CSSStyleDeclaration.prototype.setProperty=a,s.CSSStyleDeclaration.prototype.removeProperty=c})}(e,{win:n}),e.collectFonts&&(v=function(e){var t=e.fontCb,r=e.doc,n=r.defaultView;if(!n)return function(){};var i=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,r){var n=new s(e,t,r);return o.set(n,{family:e,buffer:"string"!=typeof t,descriptors:r,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),n};var a=sc(r.fonts,"add",function(e){return function(r){return setTimeout(Wc(function(){var e=o.get(r);e&&(t(e),o.delete(r))}),0),e.apply(this,[r])}});return i.push(function(){n.FontFace=s}),i.push(a),Wc(function(){i.forEach(function(e){return e()})})}(e)));for(var b,w=function(e){var t=e.doc,r=e.mirror,n=e.blockClass,i=e.blockSelector,o=e.selectionCb,s=!0,a=Wc(function(){var e=t.getSelection();if(!(!e||s&&(null==e?void 0:e.isCollapsed))){s=e.isCollapsed||!1;for(var a=[],c=e.rangeCount||0,l=0;l<c;l++){var u=e.getRangeAt(l),d=u.startContainer,h=u.startOffset,p=u.endContainer,f=u.endOffset;vc(d,n,i,!0)||vc(p,n,i,!0)||a.push({start:r.getId(d),startOffset:h,end:r.getId(p),endOffset:f})}o({ranges:a})}});return a(),cc("selectionchange",a)}(e),_=function(e){var t=e.doc,r=e.customElementCb,n=t.defaultView;return n&&n.customElements?sc(n.customElements,"define",function(e){return function(t,n,i){try{r({define:{name:t}})}catch(o){console.warn("Custom element callback failed for "+t)}return e.apply(this,[t,n,i])}}):function(){}}(e),k=[],C=P(e.plugins);!(b=C()).done;){var I=b.value;k.push(I.observer(I.callback,n,I.options))}return Wc(function(){Vc.forEach(function(e){return e.reset()}),null==r||r.disconnect(),l(),u(),d(),h(),p(),f(),m(),g(),y(),v(),w(),_(),k.forEach(function(e){return e()})})}function nl(e){return void 0!==window[e]}function il(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}for(var ol=function(){function e(e){j(this,"iframeIdToRemoteIdMap",new WeakMap),j(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=e}var t=e.prototype;return t.getId=function(e,t,r,n){var i=r||this.getIdToRemoteIdMap(e),o=n||this.getRemoteIdToIdMap(e),s=i.get(t);return s||(s=this.generateIdFn(),i.set(t,s),o.set(s,t)),s},t.getIds=function(e,t){var r=this,n=this.getIdToRemoteIdMap(e),i=this.getRemoteIdToIdMap(e);return t.map(function(t){return r.getId(e,t,n,i)})},t.getRemoteId=function(e,t,r){var n=r||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;var i=n.get(t);return i||-1},t.getRemoteIds=function(e,t){var r=this,n=this.getRemoteIdToIdMap(e);return t.map(function(t){return r.getRemoteId(e,t,n)})},t.reset=function(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)},t.getIdToRemoteIdMap=function(e){var t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t},t.getRemoteIdToIdMap=function(e){var t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t},e}(),sl=function(){function e(e){j(this,"iframes",new WeakMap),j(this,"crossOriginIframeMap",new WeakMap),j(this,"crossOriginIframeMirror",new ol(ge)),j(this,"crossOriginIframeStyleMirror"),j(this,"crossOriginIframeRootIdMap",new WeakMap),j(this,"mirror"),j(this,"mutationCb"),j(this,"wrappedEmit"),j(this,"loadListener"),j(this,"stylesheetManager"),j(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new ol(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}var t=e.prototype;return t.addIframe=function(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)},t.addLoadListener=function(e){this.loadListener=e},t.attachIframe=function(e,t){var r,n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&(null==(r=e.contentWindow)||r.addEventListener("message",this.handleMessage.bind(this))),null==(n=this.loadListener)||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))},t.handleMessage=function(e){var t=e;if("rrweb"===t.data.type&&t.origin===t.data.origin&&e.source){var r=this.crossOriginIframeMap.get(e.source);if(r){var n=this.transformCrossOriginEvent(r,t.data.event);n&&this.wrappedEmit(n,t.data.isCheckout)}}},t.transformCrossOriginEvent=function(e,t){var r,n=this;switch(t.type){case Ac.FullSnapshot:this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);var i=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,i),this.patchRootIdOnNode(t.data.node,i),{timestamp:t.timestamp,type:Ac.IncrementalSnapshot,data:{source:Pc.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case Ac.Meta:case Ac.Load:case Ac.DomContentLoaded:return!1;case Ac.Plugin:return t;case Ac.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case Ac.IncrementalSnapshot:switch(t.data.source){case Pc.Mutation:return t.data.adds.forEach(function(t){n.replaceIds(t,e,["parentId","nextId","previousId"]),n.replaceIdOnNode(t.node,e);var r=n.crossOriginIframeRootIdMap.get(e);r&&n.patchRootIdOnNode(t.node,r)}),t.data.removes.forEach(function(t){n.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(function(t){n.replaceIds(t,e,["id"])}),t.data.texts.forEach(function(t){n.replaceIds(t,e,["id"])}),t;case Pc.Drag:case Pc.TouchMove:case Pc.MouseMove:return t.data.positions.forEach(function(t){n.replaceIds(t,e,["id"])}),t;case Pc.ViewportResize:return!1;case Pc.MediaInteraction:case Pc.MouseInteraction:case Pc.Scroll:case Pc.CanvasMutation:case Pc.Input:return this.replaceIds(t.data,e,["id"]),t;case Pc.StyleSheetRule:case Pc.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Pc.Font:return t;case Pc.Selection:return t.data.ranges.forEach(function(t){n.replaceIds(t,e,["start","end"])}),t;case Pc.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null==(r=t.data.styles)||r.forEach(function(t){n.replaceStyleIds(t,e,["styleId"])}),t}}return!1},t.replace=function(e,t,r,n){for(var i,o=P(n);!(i=o()).done;){var s=i.value;(Array.isArray(t[s])||"number"==typeof t[s])&&(Array.isArray(t[s])?t[s]=e.getIds(r,t[s]):t[s]=e.getId(r,t[s]))}return t},t.replaceIds=function(e,t,r){return this.replace(this.crossOriginIframeMirror,e,t,r)},t.replaceStyleIds=function(e,t,r){return this.replace(this.crossOriginIframeStyleMirror,e,t,r)},t.replaceIdOnNode=function(e,t){var r=this;this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(function(e){r.replaceIdOnNode(e,t)})},t.patchRootIdOnNode=function(e,t){var r=this;e.type===jc.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(function(e){r.patchRootIdOnNode(e,t)})},e}(),al=function(){function e(e){j(this,"shadowDoms",new WeakSet),j(this,"mutationCb"),j(this,"scrollCb"),j(this,"bypassOptions"),j(this,"mirror"),j(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}var t=e.prototype;return t.init=function(){this.reset(),this.patchAttachShadow(Element,document)},t.addShadowRoot=function(e,t){var r=this;if(K(e)&&!this.shadowDoms.has(e)){this.shadowDoms.add(e);var n=Yc(x({},this.bypassOptions,{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push(function(){return n.disconnect()}),this.restoreHandlers.push(Kc(x({},this.bypassOptions,{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout(function(){e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&r.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,r.mirror.getId(ac.host(e))),r.restoreHandlers.push(tl({mirror:r.mirror,stylesheetManager:r.bypassOptions.stylesheetManager},e))},0)}},t.observeAttachShadow=function(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)},t.patchAttachShadow=function(e,t){var r=this;this.restoreHandlers.push(sc(e.prototype,"attachShadow",function(e){return function(n){var i=e.call(this,n),o=ac.shadowRoot(this);return o&&Nc(this)&&r.addShadowRoot(o,t),i}}))},t.reset=function(){this.restoreHandlers.forEach(function(e){try{e()}catch(t){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet},e}(),cl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ll="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ul=0;ul<64;ul++)ll[cl.charCodeAt(ul)]=ul;var dl=new Map;var hl=function(e,t,r){if(e&&(ml(e,t)||"object"===(void 0===e?"undefined":E(e)))){var n=function(e,t){var r=dl.get(e);return r||(r=new Map,dl.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}(r,e.constructor.name),i=n.indexOf(e);return-1===i&&(i=n.length,n.push(e)),i}};function pl(e,t,r){if(S(e,Array))return e.map(function(e){return pl(e,t,r)});if(null===e)return e;if(S(e,Float32Array)||S(e,Float64Array)||S(e,Int32Array)||S(e,Uint32Array)||S(e,Uint8Array)||S(e,Uint16Array)||S(e,Int16Array)||S(e,Int8Array)||S(e,Uint8ClampedArray))return{rr_type:e.constructor.name,args:[Object.values(e)]};if(S(e,ArrayBuffer))return{rr_type:e.constructor.name,base64:function(e){var t,r=new Uint8Array(e),n=r.length,i="";for(t=0;t<n;t+=3)i+=cl[r[t]>>2],i+=cl[(3&r[t])<<4|r[t+1]>>4],i+=cl[(15&r[t+1])<<2|r[t+2]>>6],i+=cl[63&r[t+2]];return n%3==2?i=i.substring(0,i.length-1)+"=":n%3==1&&(i=i.substring(0,i.length-2)+"=="),i}(e)};if(S(e,DataView))return{rr_type:e.constructor.name,args:[pl(e.buffer,t,r),e.byteOffset,e.byteLength]};if(S(e,HTMLImageElement))return{rr_type:e.constructor.name,src:e.src};if(S(e,HTMLCanvasElement)){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}return S(e,ImageData)?{rr_type:e.constructor.name,args:[pl(e.data,t,r),e.width,e.height]}:ml(e,t)||"object"===(void 0===e?"undefined":E(e))?{rr_type:e.constructor.name,index:hl(e,t,r)}:e}var fl=function(e,t,r){return e.map(function(e){return pl(e,t,r)})},ml=function(e,t){var r=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(function(e){return"function"==typeof t[e]});return Boolean(r.find(function(r){return S(e,t[r])}))};function gl(e,t,r,n){var i=[];try{var o=sc(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(i){for(var o=arguments.length,s=new Array(o>1?o-1:0),a=1;a<o;a++)s[a-1]=arguments[a];if(!vc(this,t,r,!0)){var c=function(e){return"experimental-webgl"===e?"webgl":e}(i);if("__context"in this||(this.__context=c),n&&["webgl","webgl2"].includes(c))if(s[0]&&"object"===E(s[0])){var l=s[0];l.preserveDrawingBuffer||(l.preserveDrawingBuffer=!0)}else s.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[].concat([i],s))}});i.push(o)}catch(s){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return function(){i.forEach(function(e){return e()})}}function yl(e,t,r,n,i,o){for(var s,a=function(){var a=s.value;if(["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(a))return"continue";try{if("function"!=typeof e[a])return"continue";var l=sc(e,a,function(e){return function(){for(var s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var u=e.apply(this,c);if(hl(u,o,this),"tagName"in this.canvas&&!vc(this.canvas,n,i,!0)){var d=fl(c,o,this),h={type:t,property:a,args:d};r(this.canvas,h)}return u}});c.push(l)}catch(d){var u=hc(e,a,{set:function(e){r(this.canvas,{type:t,property:a,args:[e],setter:!0})}});c.push(u)}},c=[],l=P(Object.getOwnPropertyNames(e));!(s=l()).done;)a();return c}var vl,bl="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",wl="undefined"!=typeof window&&window.Blob&&new Blob([(vl=bl,Uint8Array.from(atob(vl),function(e){return e.charCodeAt(0)}))],{type:"text/javascript;charset=utf-8"});function xl(e){var t;try{if(!(t=wl&&(window.URL||window.webkitURL).createObjectURL(wl)))throw"";var r=new Worker(t,{name:null==e?void 0:e.name});return r.addEventListener("error",function(){(window.URL||window.webkitURL).revokeObjectURL(t)}),r}catch(n){return new Worker("data:text/javascript;base64,"+bl,{name:null==e?void 0:e.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}var _l,kl,Sl,Cl=function(){function e(e){var t=this;j(this,"pendingCanvasMutations",new Map),j(this,"rafStamps",{latestId:0,invokeId:null}),j(this,"mirror"),j(this,"mutationCb"),j(this,"resetObservers"),j(this,"frozen",!1),j(this,"locked",!1),j(this,"processMutation",function(e,r){!(t.rafStamps.invokeId&&t.rafStamps.latestId!==t.rafStamps.invokeId)&&t.rafStamps.invokeId||(t.rafStamps.invokeId=t.rafStamps.latestId),t.pendingCanvasMutations.has(e)||t.pendingCanvasMutations.set(e,[]),t.pendingCanvasMutations.get(e).push(r)});var r=e.sampling,n=void 0===r?"all":r,i=e.win,o=e.blockClass,s=e.blockSelector,a=e.recordCanvas,c=e.dataURLOptions;this.mutationCb=e.mutationCb,this.mirror=e.mirror,a&&"all"===n&&this.initCanvasMutationObserver(i,o,s),a&&"number"==typeof n&&this.initCanvasFPSObserver(n,i,o,s,{dataURLOptions:c})}var t=e.prototype;return t.reset=function(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()},t.freeze=function(){this.frozen=!0},t.unfreeze=function(){this.frozen=!1},t.lock=function(){this.locked=!0},t.unlock=function(){this.locked=!1},t.initCanvasFPSObserver=function(e,t,r,n,i){var o=this,s=gl(t,r,n,!0),a=new Map,c=new xl;c.onmessage=function(e){var t=e.data.id;if(a.set(t,!1),"base64"in e.data){var r=e.data,n=r.base64,i=r.type,s=r.width,c=r.height;o.mutationCb({id:t,type:Tc["2D"],commands:[{property:"clearRect",args:[0,0,s,c]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:i}]},0,0]}]})}};var l,u=1e3/e,d=0,h=function(e){if(d&&e-d<u)l=requestAnimationFrame(h);else{d=e;var s,p=o;(s=[],t.document.querySelectorAll("canvas").forEach(function(e){vc(e,r,n,!0)||s.push(e)}),s).forEach(v(function(e){var t,r,n,o;return O(this,function(s){switch(s.label){case 0:return r=p.mirror.getId(e),a.get(r)?[2]:0===e.width||0===e.height?[2]:(a.set(r,!0),["webgl","webgl2"].includes(e.__context)&&(n=e.getContext(e.__context),!1===(null==(t=null==n?void 0:n.getContextAttributes())?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)),[4,createImageBitmap(e)]);case 1:return o=s.sent(),c.postMessage({id:r,bitmap:o,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[o]),[2]}})})),l=requestAnimationFrame(h)}};l=requestAnimationFrame(h),this.resetObservers=function(){s(),cancelAnimationFrame(l)}},t.initCanvasMutationObserver=function(e,t,r){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();var n=gl(e,t,r,!1),i=function(e,t,r,n){for(var i,o=function(){var o=i.value;try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[o])return"continue";var a=sc(t.CanvasRenderingContext2D.prototype,o,function(i){return function(){for(var s=this,a=arguments.length,c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];return vc(this.canvas,r,n,!0)||setTimeout(function(){var r=fl(c,t,s);e(s.canvas,{type:Tc["2D"],property:o,args:r})},0),i.apply(this,c)}});s.push(a)}catch(l){var c=hc(t.CanvasRenderingContext2D.prototype,o,{set:function(t){e(this.canvas,{type:Tc["2D"],property:o,args:[t],setter:!0})}});s.push(c)}},s=[],a=P(Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype));!(i=a()).done;)o();return function(){s.forEach(function(e){return e()})}}(this.processMutation.bind(this),e,t,r),o=function(e,t,r,n){var i,o,s=[];return(i=s).push.apply(i,[].concat(yl(t.WebGLRenderingContext.prototype,Tc.WebGL,e,r,n,t))),void 0!==t.WebGL2RenderingContext&&(o=s).push.apply(o,[].concat(yl(t.WebGL2RenderingContext.prototype,Tc.WebGL2,e,r,n,t))),function(){s.forEach(function(e){return e()})}}(this.processMutation.bind(this),e,t,r);this.resetObservers=function(){n(),i(),o()}},t.startPendingCanvasMutationFlusher=function(){var e=this;requestAnimationFrame(function(){return e.flushPendingCanvasMutations()})},t.startRAFTimestamping=function(){var e=this,t=function(r){e.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)},t.flushPendingCanvasMutations=function(){var e=this;this.pendingCanvasMutations.forEach(function(t,r){var n=e.mirror.getId(r);e.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(function(){return e.flushPendingCanvasMutations()})},t.flushPendingCanvasMutationFor=function(e,t){if(!this.frozen&&!this.locked){var r=this.pendingCanvasMutations.get(e);if(r&&-1!==t){var n=r.map(function(e){return e.type,C(e,["type"])}),i=r[0].type;this.mutationCb({id:t,type:i,commands:n}),this.pendingCanvasMutations.delete(e)}}},e}(),Il=function(){function e(e){j(this,"trackedLinkElements",new WeakSet),j(this,"mutationCb"),j(this,"adoptedStyleSheetCb"),j(this,"styleMirror",new Cc),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}var t=e.prototype;return t.attachLinkElement=function(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)},t.trackLinkElement=function(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))},t.adoptStyleSheets=function(e,t){var r,n=function(){var e=i.value,t=void 0;r.styleMirror.has(e)?t=r.styleMirror.getId(e):(t=r.styleMirror.add(e),s.push({styleId:t,rules:Array.from(e.rules||CSSRule,function(t,r){return{rule:X(t,e.href),index:r}})})),o.styleIds.push(t)};if(0!==e.length){for(var i,o={id:t,styleIds:[]},s=[],a=P(e);!(i=a()).done;)r=this,n();s.length>0&&(o.styles=s),this.adoptedStyleSheetCb(o)}},t.reset=function(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet},t.trackStylesheetInLinkElement=function(e){},e}(),El=function(){function e(){j(this,"nodeMap",new WeakMap),j(this,"active",!1)}var t=e.prototype;return t.inOtherBuffer=function(e,t){var r=this.nodeMap.get(e);return r&&Array.from(r).some(function(e){return e!==t})},t.add=function(e,t){var r=this;this.active||(this.active=!0,requestAnimationFrame(function(){r.nodeMap=new WeakMap,r.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))},t.destroy=function(){},e}(),Nl=!1;try{if(2!==Array.from([1],function(e){return 2*e})[0]){var Al=document.createElement("iframe");document.body.appendChild(Al),Array.from=(null==(T=Al.contentWindow)?void 0:T.Array.from)||Array.from,document.body.removeChild(Al)}}catch(Hy){}var Pl,Ol,Ml=new Q;function Tl(e){void 0===e&&(e={});var t=e.emit,r=e.checkoutEveryNms,n=e.checkoutEveryNth,i=e.blockClass,o=void 0===i?"rr-block":i,s=e.blockSelector,a=void 0===s?null:s,c=e.ignoreClass,l=void 0===c?"rr-ignore":c,u=e.ignoreSelector,d=void 0===u?null:u,h=e.maskTextClass,p=void 0===h?"rr-mask":h,f=e.maskTextSelector,m=void 0===f?null:f,g=e.inlineStylesheet,y=void 0===g||g,v=e.maskAllInputs,b=e.maskInputOptions,w=e.slimDOMOptions,_=e.maskInputFn,k=e.maskTextFn,S=e.hooks,C=e.packFn,I=e.sampling,E=void 0===I?{}:I,N=e.dataURLOptions,A=void 0===N?{}:N,O=e.mousemoveWait,M=e.recordDOM,T=void 0===M||M,R=e.recordCanvas,j=void 0!==R&&R,D=e.recordCrossOriginIframes,F=void 0!==D&&D,L=e.recordAfter,U=void 0===L?"DOMContentLoaded"===e.recordAfter?e.recordAfter:"load":L,B=e.userTriggeredOnInput,z=void 0!==B&&B,q=e.collectFonts,$=void 0!==q&&q,G=e.inlineImages,W=void 0!==G&&G,V=e.plugins,H=e.keepIframeSrcFn,Y=void 0===H?function(){return!1}:H,Z=e.ignoreCSSAttributes,K=void 0===Z?new Set([]):Z,J=e.errorHandler;Fc=J;var X=!F||window.parent===window,ee=!1;if(!X)try{window.parent.document&&(ee=!1)}catch(we){ee=!0}if(X&&!t)throw new Error("emit function is required");if(!X&&!ee)return function(){};void 0!==O&&void 0===E.mousemove&&(E.mousemove=O),Ml.reset();var te,re,ne=!0===v?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0,hidden:!0}:void 0!==b?b:{password:!0},ie=!0===w||"all"===w?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===w,headMetaDescKeywords:"all"===w,headTitleMutations:"all"===w}:w||{};void 0===te&&(te=window),"NodeList"in te&&!te.NodeList.prototype.forEach&&(te.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in te&&!te.DOMTokenList.prototype.forEach&&(te.DOMTokenList.prototype.forEach=Array.prototype.forEach);var oe=0,se=function(e){for(var t,r=P(V||[]);!(t=r()).done;){var n=t.value;n.eventProcessor&&(e=n.eventProcessor(e))}return C&&!ee&&(e=C(e)),e};_l=function(e,i){var o,s=e;if(s.timestamp=pc(),!(null==(o=Vc[0])?void 0:o.isFrozen())||s.type===Ac.FullSnapshot||s.type===Ac.IncrementalSnapshot&&s.data.source===Pc.Mutation||Vc.forEach(function(e){return e.unfreeze()}),X)null==t||t(se(s),i);else if(ee){var a={type:"rrweb",event:se(s),origin:window.location.origin,isCheckout:i};window.parent.postMessage(a,"*")}if(s.type===Ac.FullSnapshot)re=s,oe=0;else if(s.type===Ac.IncrementalSnapshot){if(s.data.source===Pc.Mutation&&s.data.isAttachIframe)return;oe++;var c=n&&oe>=n,l=r&&s.timestamp-re.timestamp>r;(c||l)&&kl(!0)}};for(var ae,ce=function(e){_l({type:Ac.IncrementalSnapshot,data:x({source:Pc.Mutation},e)})},le=function(e){return _l({type:Ac.IncrementalSnapshot,data:x({source:Pc.Scroll},e)})},ue=function(e){return _l({type:Ac.IncrementalSnapshot,data:x({source:Pc.CanvasMutation},e)})},de=new Il({mutationCb:ce,adoptedStyleSheetCb:function(e){return _l({type:Ac.IncrementalSnapshot,data:x({source:Pc.AdoptedStyleSheet},e)})}}),he=new sl({mirror:Ml,mutationCb:ce,stylesheetManager:de,recordCrossOriginIframes:F,wrappedEmit:_l}),pe=P(V||[]);!(ae=pe()).done;){var fe=ae.value;fe.getMirror&&fe.getMirror({nodeMirror:Ml,crossOriginIframeMirror:he.crossOriginIframeMirror,crossOriginIframeStyleMirror:he.crossOriginIframeStyleMirror})}var me=new El;Sl=new Cl({recordCanvas:j,mutationCb:ue,win:window,blockClass:o,blockSelector:a,mirror:Ml,sampling:E.canvas,dataURLOptions:A});var ge=new al({mutationCb:ce,scrollCb:le,bypassOptions:{blockClass:o,blockSelector:a,maskTextClass:p,maskTextSelector:m,inlineStylesheet:y,maskInputOptions:ne,dataURLOptions:A,maskTextFn:k,maskInputFn:_,recordCanvas:j,inlineImages:W,sampling:E,slimDOMOptions:ie,iframeManager:he,stylesheetManager:de,canvasManager:Sl,keepIframeSrcFn:Y,processedNodeManager:me},mirror:Ml});kl=function(e){if(void 0===e&&(e=!1),T){_l({type:Ac.Meta,data:{href:window.location.href,width:gc(),height:mc()}},e),de.reset(),ge.init(),Vc.forEach(function(e){return e.lock()});var t=function(e,t){var r=t||{},n=r.mirror,i=void 0===n?new Q:n,o=r.blockClass,s=void 0===o?"rr-block":o,a=r.blockSelector,c=void 0===a?null:a,l=r.maskTextClass,u=void 0===l?"rr-mask":l,d=r.maskTextSelector,h=void 0===d?null:d,p=r.inlineStylesheet,f=void 0===p||p,m=r.inlineImages,g=void 0!==m&&m,y=r.recordCanvas,v=void 0!==y&&y,b=r.maskAllInputs,w=void 0!==b&&b,x=r.maskTextFn,_=r.maskInputFn,k=r.slimDOM,S=void 0!==k&&k,C=r.dataURLOptions,I=r.preserveWhiteSpace,E=r.onSerialize,N=r.onIframeLoad,A=r.iframeLoadTimeout,P=r.onStylesheetLoad,O=r.stylesheetLoadTimeout,M=r.keepIframeSrcFn;return Ae(e,{doc:e,mirror:i,blockClass:s,blockSelector:c,maskTextClass:u,maskTextSelector:h,skipChild:!1,inlineStylesheet:f,maskInputOptions:!0===w?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0,hidden:!0}:!1===w?{password:!0}:w,maskTextFn:x,maskInputFn:_,slimDOMOptions:!0===S||"all"===S?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===S,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===S?{}:S,dataURLOptions:C,inlineImages:g,recordCanvas:v,preserveWhiteSpace:I,onSerialize:E,onIframeLoad:N,iframeLoadTimeout:A,onStylesheetLoad:P,stylesheetLoadTimeout:O,keepIframeSrcFn:void 0===M?function(){return!1}:M,newlyAddedElement:!1})}(document,{mirror:Ml,blockClass:o,blockSelector:a,maskTextClass:p,maskTextSelector:m,inlineStylesheet:y,maskAllInputs:ne,maskTextFn:k,maskInputFn:_,slimDOM:ie,dataURLOptions:A,recordCanvas:j,inlineImages:W,onSerialize:function(e){_c(e,Ml)&&he.addIframe(e),kc(e,Ml)&&de.trackLinkElement(e),Sc(e)&&ge.addShadowRoot(ac.shadowRoot(e),document)},onIframeLoad:function(e,t){he.attachIframe(e,t),ge.observeAttachShadow(e)},onStylesheetLoad:function(e,t){de.attachLinkElement(e,t)},keepIframeSrcFn:Y});if(!t)return console.warn("Failed to snapshot the document");_l({type:Ac.FullSnapshot,data:{node:t,initialOffset:fc(window)}},e),Vc.forEach(function(e){return e.unlock()}),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&de.adoptStyleSheets(document.adoptedStyleSheets,Ml.getId(document))}};try{var ye=[],ve=function(e){var t;return Wc(rl)({mutationCb:ce,mousemoveCb:function(e,t){return _l({type:Ac.IncrementalSnapshot,data:{source:t,positions:e}})},mouseInteractionCb:function(e){return _l({type:Ac.IncrementalSnapshot,data:x({source:Pc.MouseInteraction},e)})},scrollCb:le,viewportResizeCb:function(e){return _l({type:Ac.IncrementalSnapshot,data:x({source:Pc.ViewportResize},e)})},inputCb:function(e){return _l({type:Ac.IncrementalSnapshot,data:x({source:Pc.Input},e)})},mediaInteractionCb:function(e){return _l({type:Ac.IncrementalSnapshot,data:x({source:Pc.MediaInteraction},e)})},styleSheetRuleCb:function(e){return _l({type:Ac.IncrementalSnapshot,data:x({source:Pc.StyleSheetRule},e)})},styleDeclarationCb:function(e){return _l({type:Ac.IncrementalSnapshot,data:x({source:Pc.StyleDeclaration},e)})},canvasMutationCb:ue,fontCb:function(e){return _l({type:Ac.IncrementalSnapshot,data:x({source:Pc.Font},e)})},selectionCb:function(e){_l({type:Ac.IncrementalSnapshot,data:x({source:Pc.Selection},e)})},customElementCb:function(e){_l({type:Ac.IncrementalSnapshot,data:x({source:Pc.CustomElement},e)})},blockClass:o,ignoreClass:l,ignoreSelector:d,maskTextClass:p,maskTextSelector:m,maskInputOptions:ne,inlineStylesheet:y,sampling:E,recordDOM:T,recordCanvas:j,inlineImages:W,userTriggeredOnInput:z,collectFonts:$,doc:e,maskInputFn:_,maskTextFn:k,keepIframeSrcFn:Y,blockSelector:a,slimDOMOptions:ie,dataURLOptions:A,mirror:Ml,iframeManager:he,stylesheetManager:de,shadowDomManager:ge,processedNodeManager:me,canvasManager:Sl,ignoreCSSAttributes:K,plugins:(null==(t=null==V?void 0:V.filter(function(e){return e.observer}))?void 0:t.map(function(e){return{observer:e.observer,options:e.options,callback:function(t){return _l({type:Ac.Plugin,data:{plugin:e.name,payload:t}})}}}))||[]},S)};he.addLoadListener(function(e){try{ye.push(ve(e.contentDocument))}catch(gu){console.warn(gu)}});var be=function(){kl(),ye.push(ve(document)),Nl=!0};return"interactive"===document.readyState||"complete"===document.readyState?be():(ye.push(cc("DOMContentLoaded",function(){_l({type:Ac.DomContentLoaded,data:{}}),"DOMContentLoaded"===U&&be()})),ye.push(cc("load",function(){_l({type:Ac.Load,data:{}}),"load"===U&&be()},window))),function(){ye.forEach(function(e){try{e()}catch(gu){String(gu).toLowerCase().includes("cross-origin")||console.warn(gu)}}),me.destroy(),Nl=!1,Fc=void 0}}catch(gu){console.warn(gu)}}Tl.addCustomEvent=function(e,t){if(!Nl)throw new Error("please add custom event after start recording");_l({type:Ac.Custom,data:{tag:e,payload:t}})},Tl.freezePage=function(){Vc.forEach(function(e){return e.freeze()})},Tl.takeFullSnapshot=function(e){if(!Nl)throw new Error("please take full snapshot after start recording");kl(e)},Tl.mirror=Ml,(Ol=Pl||(Pl={}))[Ol.NotStarted=0]="NotStarted",Ol[Ol.Running=1]="Running",Ol[Ol.Stopped=2]="Stopped",Tl.addCustomEvent,Tl.freezePage,Tl.takeFullSnapshot;var Rl=Object.defineProperty,jl=function(e,t,r){return function(e,t,r){return t in e?Rl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r}(e,"symbol"!==(void 0===t?"undefined":E(t))?t+"":t,r)};var Dl=function(){function e(e){jl(this,"fileName"),jl(this,"functionName"),jl(this,"lineNumber"),jl(this,"columnNumber"),this.fileName=e.fileName||"",this.functionName=e.functionName||"",this.lineNumber=e.lineNumber,this.columnNumber=e.columnNumber}return e.prototype.toString=function(){var e=this.lineNumber||"",t=this.columnNumber||"";return this.functionName?this.functionName+" ("+this.fileName+":"+e+":"+t+")":this.fileName+":"+e+":"+t},e}(),Fl=/(^|@)\S+:\d+/,Ll=/^\s*at .*(\S+:\d+|\(native\))/m,Ul=/^(eval@)?(\[native code])?$/,Bl={parse:function(e){return e?void 0!==e.stacktrace||void 0!==e["opera#sourceloc"]?this.parseOpera(e):e.stack&&e.stack.match(Ll)?this.parseV8OrIE(e):e.stack?this.parseFFOrSafari(e):(console.warn("[console-record-plugin]: Failed to parse error object:",e),[]):[]},extractLocation:function(e){if(-1===e.indexOf(":"))return[e];var t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));if(!t)throw new Error("Cannot parse given url: "+e);return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE:function(e){return e.stack.split("\n").filter(function(e){return!!e.match(Ll)},this).map(function(e){e.indexOf("(eval ")>-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));var t=e.replace(/^\s+/,"").replace(/\(eval code/g,"("),r=t.match(/ (\((.+):(\d+):(\d+)\)$)/),n=(t=r?t.replace(r[0],""):t).split(/\s+/).slice(1),i=this.extractLocation(r?r[1]:n.pop()),o=n.join(" ")||void 0,s=["eval","<anonymous>"].indexOf(i[0])>-1?void 0:i[0];return new Dl({functionName:o,fileName:s,lineNumber:i[1],columnNumber:i[2]})},this)},parseFFOrSafari:function(e){return e.stack.split("\n").filter(function(e){return!e.match(Ul)},this).map(function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new Dl({functionName:e});var t=/((.*".+"[^@]*)?[^@]*)(?:@)/,r=e.match(t),n=r&&r[1]?r[1]:void 0,i=this.extractLocation(e.replace(t,""));return new Dl({functionName:n,fileName:i[0],lineNumber:i[1],columnNumber:i[2]})},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){for(var t=/Line (\d+).*script (?:in )?(\S+)/i,r=e.message.split("\n"),n=[],i=2,o=r.length;i<o;i+=2){var s=t.exec(r[i]);s&&n.push(new Dl({fileName:s[2],lineNumber:parseFloat(s[1])}))}return n},parseOpera10:function(e){for(var t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,r=e.stacktrace.split("\n"),n=[],i=0,o=r.length;i<o;i+=2){var s=t.exec(r[i]);s&&n.push(new Dl({functionName:s[3]||void 0,fileName:s[2],lineNumber:parseFloat(s[1])}))}return n},parseOpera11:function(e){return e.stack.split("\n").filter(function(e){return!!e.match(Fl)&&!e.match(/^Error created at/)},this).map(function(e){var t=e.split("@"),r=this.extractLocation(t.pop()),n=(t.shift()||"").replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;return new Dl({functionName:n,fileName:r[0],lineNumber:r[1],columnNumber:r[2]})},this)}};function zl(e){if(!e||!e.outerHTML)return"";for(var t="";e.parentElement;){var r=e.localName;if(!r)break;r=r.toLowerCase();var n=e.parentElement,i=[];if(n.children&&n.children.length>0)for(var o=0;o<n.children.length;o++){var s=n.children[o];s.localName&&s.localName.toLowerCase&&s.localName.toLowerCase()===r&&i.push(s)}i.length>1&&(r+=":eq("+i.indexOf(e)+")"),t=r+(t?">"+t:""),e=n}return t}function ql(e){return"[object Object]"===Object.prototype.toString.call(e)}function $l(e,t){if(0===t)return!0;for(var r,n=P(Object.keys(e));!(r=n()).done;){var i=r.value;if(ql(e[i])&&$l(e[i],t-1))return!0}return!1}function Gl(e,t){var r={numOfKeysLimit:50,depthOfLimit:4};Object.assign(r,t);var n=[],i=[];return JSON.stringify(e,function(e,t){if(n.length>0){var o=n.indexOf(this);~o?n.splice(o+1):n.push(this),~o?i.splice(o,1/0,e):i.push(e),~n.indexOf(t)&&(t=n[0]===t?"[Circular ~]":"[Circular ~."+i.slice(0,n.indexOf(t)).join(".")+"]")}else n.push(t);if(null===t)return t;if(void 0===t)return"undefined";if(function(e){if(ql(e)&&Object.keys(e).length>r.numOfKeysLimit)return!0;if("function"==typeof e)return!0;if(ql(e)&&$l(e,r.depthOfLimit))return!0;return!1}(t))return function(e){var t=e.toString();r.stringLengthLimit&&t.length>r.stringLengthLimit&&(t=t.slice(0,r.stringLengthLimit)+"...");return t}(t);if("bigint"===(void 0===t?"undefined":E(t)))return t.toString()+"n";if(S(t,Event)){var s={};for(var a in t){var c=t[a];Array.isArray(c)?s[a]=zl(c.length?c[0]:null):s[a]=c}return s}return S(t,Node)?S(t,HTMLElement)?t?t.outerHTML:"":t.nodeName:S(t,Error)?t.stack?t.stack+"\nEnd of stack for Error object":t.name+": "+t.message:t})}var Wl={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],lengthThreshold:1e3,logger:"console"};function Vl(e,t,r){var n,i=r?Object.assign({},Wl,r):Wl,o=i.logger;if(!o)return function(){};n="string"==typeof o?t[o]:o;var s=0,a=!1,c=[];if(i.level.includes("error")){var l=function(t){var r=t.message,n=t.error,o=Bl.parse(n).map(function(e){return e.toString()}),s=[Gl(r,i.stringifyOptions)];e({level:"error",trace:o,payload:s})};t.addEventListener("error",l),c.push(function(){t.removeEventListener("error",l)});var u=function(t){var r,n;S(t.reason,Error)?n=[Gl("Uncaught (in promise) "+(r=t.reason).name+": "+r.message,i.stringifyOptions)]:(r=new Error,n=[Gl("Uncaught (in promise)",i.stringifyOptions),Gl(t.reason,i.stringifyOptions)]);var o=Bl.parse(r).map(function(e){return e.toString()});e({level:"error",trace:o,payload:n})};t.addEventListener("unhandledrejection",u),c.push(function(){t.removeEventListener("unhandledrejection",u)})}for(var d,h=P(i.level);!(d=h()).done;){var p=d.value;c.push(f(n,p))}return function(){c.forEach(function(e){return e()})};function f(t,r){var n=this;return t[r]?function(e,t,r){try{if(!(t in e))return function(){};var n=e[t],i=r(n);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=i,function(){e[t]=n}}catch(o){return function(){}}}(t,r,function(t){var o=n;return function(){for(var n=arguments.length,c=new Array(n),l=0;l<n;l++)c[l]=arguments[l];if(t.apply(o,c),!("assert"===r&&c[0]||a)){a=!0;try{var u=Bl.parse(new Error).map(function(e){return e.toString()}).splice(1),d=("assert"===r?c.slice(1):c).map(function(e){return Gl(e,i.stringifyOptions)});++s<i.lengthThreshold?e({level:r,trace:u,payload:d}):s===i.lengthThreshold&&e({level:"warn",trace:[],payload:[Gl("The number of log records reached the threshold.")]})}catch(gu){t.apply(void 0,[].concat(["rrweb logger error:",gu],c))}finally{a=!1}}}}):function(){}}}var Hl,Yl,Zl,Kl=p.setImmediate,Jl=Object.prototype.toString,Xl=void 0!==Kl?function(e){return Kl(e)}:setTimeout;try{Object.defineProperty({},"x",{}),Hl=function(e,t,r,n){return Object.defineProperty(e,t,{value:r,writable:!0,configurable:!1!==n})}}catch(Hy){Hl=function(e,t,r){return e[t]=r,e}}function Ql(e,t){Zl.add(e,t),Yl||(Yl=Xl(Zl.drain))}function eu(e){var t,r=typeof e;return null===e||"object"!==r&&"function"!==r||(t=e.then),"function"==typeof t&&t}function tu(){for(var e=0;e<this.chain.length;e++)ru(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function ru(e,t,r){var n,i;try{!1===t?r.reject(e.msg):(n=!0===t?e.msg:t.call(void 0,e.msg))===r.promise?r.reject(TypeError("Promise-chain cycle")):(i=eu(n))?i.call(n,r.resolve,r.reject):r.resolve(n)}catch(Hy){r.reject(Hy)}}function nu(e){var t,r=this;if(!r.triggered){r.triggered=!0,r.def&&(r=r.def);try{(t=eu(e))?Ql(function(){var n=new su(r);try{t.call(e,function(){nu.apply(n,arguments)},function(){iu.apply(n,arguments)})}catch(Hy){iu.call(n,Hy)}}):(r.msg=e,r.state=1,r.chain.length>0&&Ql(tu,r))}catch(Hy){iu.call(new su(r),Hy)}}}function iu(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&Ql(tu,t))}function ou(e,t,r,n){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){r(i,e)},n)})(i)}function su(e){this.def=e,this.triggered=!1}function au(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function cu(e){if("function"!=typeof e)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var t=new au(this);this.then=function(e,r){var n={success:"function"!=typeof e||e,failure:"function"==typeof r&&r};return n.promise=new this.constructor(function(e,t){if("function"!=typeof e||"function"!=typeof t)throw TypeError("Not a function");n.resolve=e,n.reject=t}),t.chain.push(n),0!==t.state&&Ql(tu,t),n.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){nu.call(t,e)},function(e){iu.call(t,e)})}catch(Hy){iu.call(t,Hy)}}Zl=function(){var e,t,r;function n(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(i,o){r=new n(i,o),t?t.next=r:e=r,t=r,r=void 0},drain:function(){var r=e;for(e=t=Yl=void 0;r;)r.fn.call(r.self),r=r.next}}}();var lu,uu=Hl({},"constructor",cu,!1);cu.prototype=uu,Hl(uu,"__NPO__",0,!1),Hl(cu,"resolve",function(e){return e&&"object"==typeof e&&1===e.__NPO__?e:new this(function(t,r){if("function"!=typeof t||"function"!=typeof r)throw TypeError("Not a function");t(e)})}),Hl(cu,"reject",function(e){return new this(function(t,r){if("function"!=typeof t||"function"!=typeof r)throw TypeError("Not a function");r(e)})}),Hl(cu,"all",function(e){var t=this;return"[object Array]"!==Jl.call(e)?t.reject(TypeError("Not an array")):0===e.length?t.resolve([]):new t(function(r,n){if("function"!=typeof r||"function"!=typeof n)throw TypeError("Not a function");var i=e.length,o=Array(i),s=0;ou(t,e,function(e,t){o[e]=t,++s===i&&r(o)},n)})}),Hl(cu,"race",function(e){var t=this;return"[object Array]"!==Jl.call(e)?t.reject(TypeError("Not an array")):new t(function(r,n){if("function"!=typeof r||"function"!=typeof n)throw TypeError("Not a function");ou(t,e,function(e,t){r(t)},n)})}),lu="undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]")?Promise:cu;var du,hu,pu,fu,mu,gu,yu,vu,bu,wu,xu={DEBUG:!1,LIB_VERSION:"2.72.0"},_u=864e5,ku=8e3,Su=Array.prototype,Cu=Function.prototype,Iu=Object.prototype,Eu=Su.slice,Nu=Iu.toString,Au=Iu.hasOwnProperty,Pu=p.console,Ou=p.navigator,Mu=p.document,Tu=p.opera,Ru=p.screen,ju=Ou.userAgent,Du=Cu.bind,Fu=Su.forEach,Lu=Su.indexOf,Uu=Su.map,Bu=Array.isArray,zu={},qu={trim:function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}},$u={log:function(){if(xu.DEBUG&&!qu.isUndefined(Pu)&&Pu)try{Pu.log.apply(Pu,arguments)}catch(Hy){qu.each(arguments,function(e){Pu.log(e)})}},warn:function(){if(xu.DEBUG&&!qu.isUndefined(Pu)&&Pu){var e=["Mixpanel warning:"].concat(qu.toArray(arguments));try{Pu.warn.apply(Pu,e)}catch(Hy){qu.each(e,function(e){Pu.warn(e)})}}},error:function(){if(xu.DEBUG&&!qu.isUndefined(Pu)&&Pu){var e=["Mixpanel error:"].concat(qu.toArray(arguments));try{Pu.error.apply(Pu,e)}catch(Hy){qu.each(e,function(e){Pu.error(e)})}}},critical:function(){if(!qu.isUndefined(Pu)&&Pu){var e=["Mixpanel error:"].concat(qu.toArray(arguments));try{Pu.error.apply(Pu,e)}catch(Hy){qu.each(e,function(e){Pu.error(e)})}}}},Gu=function(e,t){return function(){return arguments[0]="["+t+"] "+arguments[0],e.apply($u,arguments)}},Wu=function(e){return{log:Gu($u.log,e),error:Gu($u.error,e),critical:Gu($u.critical,e)}},Vu=function(e){return function(){try{return e.apply(this,arguments)}catch(t){$u.critical("Implementation error. Please turn on debug and contact support@mixpanel.com."),xu.DEBUG&&$u.critical(t)}}},Hu=function(e){var t=e.prototype;for(var r in t)"function"==typeof t[r]&&(t[r]=Vu(t[r]))};qu.bind=function(e,t){var r,n;if(Du&&e.bind===Du)return Du.apply(e,Eu.call(arguments,1));if(!qu.isFunction(e))throw new TypeError;return r=Eu.call(arguments,2),n=function(){if(!(this instanceof n))return e.apply(t,r.concat(Eu.call(arguments)));var i={};i.prototype=e.prototype;var o=new i;i.prototype=null;var s=e.apply(o,r.concat(Eu.call(arguments)));return Object(s)===s?s:o},n},qu.each=function(e,t,r){if(null!=e)if(Fu&&e.forEach===Fu)e.forEach(t,r);else if(e.length===+e.length){for(var n=0,i=e.length;n<i;n++)if(n in e&&t.call(r,e[n],n,e)===zu)return}else for(var o in e)if(Au.call(e,o)&&t.call(r,e[o],o,e)===zu)return},qu.extend=function(e){return qu.each(Eu.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e},qu.isArray=Bu||function(e){return"[object Array]"===Nu.call(e)},qu.isFunction=function(e){try{return/^\s*\bfunction\b/.test(e)}catch(t){return!1}},qu.isArguments=function(e){return!(!e||!Au.call(e,"callee"))},qu.toArray=function(e){return e?e.toArray?e.toArray():qu.isArray(e)||qu.isArguments(e)?Eu.call(e):qu.values(e):[]},qu.map=function(e,t,r){if(Uu&&e.map===Uu)return e.map(t,r);var n=[];return qu.each(e,function(e){n.push(t.call(r,e))}),n},qu.keys=function(e){var t=[];return null===e||qu.each(e,function(e,r){t[t.length]=r}),t},qu.values=function(e){var t=[];return null===e||qu.each(e,function(e){t[t.length]=e}),t},qu.include=function(e,t){var r=!1;return null===e?r:Lu&&e.indexOf===Lu?-1!=e.indexOf(t):(qu.each(e,function(e){if(r||(r=e===t))return zu}),r)},qu.includes=function(e,t){return-1!==e.indexOf(t)},qu.inherit=function(e,t){return e.prototype=new t,e.prototype.constructor=e,e.superclass=t.prototype,e},qu.isObject=function(e){return e===Object(e)&&!qu.isArray(e)},qu.isEmptyObject=function(e){if(qu.isObject(e)){for(var t in e)if(Au.call(e,t))return!1;return!0}return!1},qu.isUndefined=function(e){return void 0===e},qu.isString=function(e){return"[object String]"==Nu.call(e)},qu.isDate=function(e){return"[object Date]"==Nu.call(e)},qu.isNumber=function(e){return"[object Number]"==Nu.call(e)},qu.isElement=function(e){return!(!e||1!==e.nodeType)},qu.encodeDates=function(e){return qu.each(e,function(t,r){qu.isDate(t)?e[r]=qu.formatDate(t):qu.isObject(t)&&(e[r]=qu.encodeDates(t))}),e},qu.timestamp=function(){return Date.now=Date.now||function(){return+new Date},Date.now()},qu.formatDate=function(e){function t(e){return e<10?"0"+e:e}return e.getUTCFullYear()+"-"+t(e.getUTCMonth()+1)+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())},qu.strip_empty_properties=function(e){var t={};return qu.each(e,function(e,r){qu.isString(e)&&e.length>0&&(t[r]=e)}),t},qu.truncate=function(e,t){var r;return"string"==typeof e?r=e.slice(0,t):qu.isArray(e)?(r=[],qu.each(e,function(e){r.push(qu.truncate(e,t))})):qu.isObject(e)?(r={},qu.each(e,function(e,n){r[n]=qu.truncate(e,t)})):r=e,r},qu.JSONEncode=function(){return function(e){var t=function(e){var t=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,r={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return t.lastIndex=0,t.test(e)?'"'+e.replace(t,function(e){var t=r[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'},r=function(e,n){var i="",o=0,s="",a="",c=0,l=i,u=[],d=n[e];switch(d&&"object"==typeof d&&"function"==typeof d.toJSON&&(d=d.toJSON(e)),typeof d){case"string":return t(d);case"number":return isFinite(d)?String(d):"null";case"boolean":case"null":return String(d);case"object":if(!d)return"null";if(i+=" ",u=[],"[object Array]"===Nu.apply(d)){for(c=d.length,o=0;o<c;o+=1)u[o]=r(o,d)||"null";return a=0===u.length?"[]":i?"[\n"+i+u.join(",\n"+i)+"\n"+l+"]":"["+u.join(",")+"]",i=l,a}for(s in d)Au.call(d,s)&&(a=r(s,d))&&u.push(t(s)+(i?": ":":")+a);return a=0===u.length?"{}":i?"{"+u.join(",")+l+"}":"{"+u.join(",")+"}",i=l,a}};return r("",{"":e})}}(),qu.JSONDecode=(mu={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},gu=function(e){var t=new SyntaxError(e);throw t.at=du,t.text=pu,t},yu=function(e){return e&&e!==hu&&gu("Expected '"+e+"' instead of '"+hu+"'"),hu=pu.charAt(du),du+=1,hu},vu=function(){var e,t="";for("-"===hu&&(t="-",yu("-"));hu>="0"&&hu<="9";)t+=hu,yu();if("."===hu)for(t+=".";yu()&&hu>="0"&&hu<="9";)t+=hu;if("e"===hu||"E"===hu)for(t+=hu,yu(),"-"!==hu&&"+"!==hu||(t+=hu,yu());hu>="0"&&hu<="9";)t+=hu,yu();if(e=+t,isFinite(e))return e;gu("Bad number")},bu=function(){var e,t,r,n="";if('"'===hu)for(;yu();){if('"'===hu)return yu(),n;if("\\"===hu)if(yu(),"u"===hu){for(r=0,t=0;t<4&&(e=parseInt(yu(),16),isFinite(e));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else{if("string"!=typeof mu[hu])break;n+=mu[hu]}else n+=hu}gu("Bad string")},wu=function(){for(;hu&&hu<=" ";)yu()},fu=function(){switch(wu(),hu){case"{":return function(){var e,t={};if("{"===hu){if(yu("{"),wu(),"}"===hu)return yu("}"),t;for(;hu;){if(e=bu(),wu(),yu(":"),Object.hasOwnProperty.call(t,e)&&gu('Duplicate key "'+e+'"'),t[e]=fu(),wu(),"}"===hu)return yu("}"),t;yu(","),wu()}}gu("Bad object")}();case"[":return function(){var e=[];if("["===hu){if(yu("["),wu(),"]"===hu)return yu("]"),e;for(;hu;){if(e.push(fu()),wu(),"]"===hu)return yu("]"),e;yu(","),wu()}}gu("Bad array")}();case'"':return bu();case"-":return vu();default:return hu>="0"&&hu<="9"?vu():function(){switch(hu){case"t":return yu("t"),yu("r"),yu("u"),yu("e"),!0;case"f":return yu("f"),yu("a"),yu("l"),yu("s"),yu("e"),!1;case"n":return yu("n"),yu("u"),yu("l"),yu("l"),null}gu('Unexpected "'+hu+'"')}()}},function(e){var t;return pu=e,du=0,hu=" ",t=fu(),wu(),hu&&gu("Syntax error"),t}),qu.base64Encode=function(e){var t,r,n,i,o,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,c=0,l="",u=[];if(!e)return e;e=qu.utf8Encode(e);do{t=(o=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,r=o>>12&63,n=o>>6&63,i=63&o,u[c++]=s.charAt(t)+s.charAt(r)+s.charAt(n)+s.charAt(i)}while(a<e.length);switch(l=u.join(""),e.length%3){case 1:l=l.slice(0,-2)+"==";break;case 2:l=l.slice(0,-1)+"="}return l},qu.utf8Encode=function(e){var t,r,n,i,o="";for(t=r=0,n=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,i=0;i<n;i++){var s=e.charCodeAt(i),a=null;s<128?r++:a=s>127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==a&&(r>t&&(o+=e.substring(t,r)),o+=a,t=r=i+1)}return r>t&&(o+=e.substring(t,e.length)),o},qu.UUID=function(){try{return p.crypto.randomUUID()}catch(Hy){for(var e=new Array(36),t=0;t<36;t++)e[t]=Math.floor(16*Math.random());return e[14]=4,e[19]=e[19]&=-5,e[19]=e[19]|=8,e[8]=e[13]=e[18]=e[23]="-",qu.map(e,function(e){return e.toString(16)}).join("")}};var Yu=["ahrefsbot","ahrefssiteaudit","amazonbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","facebookexternal","petalbot","pinterest","screaming frog","yahoo! slurp","yandex","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"];qu.isBlockedUA=function(e){var t;for(e=e.toLowerCase(),t=0;t<Yu.length;t++)if(-1!==e.indexOf(Yu[t]))return!0;return!1},qu.HTTPBuildQuery=function(e,t){var r,n,i=[];return qu.isUndefined(t)&&(t="&"),qu.each(e,function(e,t){r=encodeURIComponent(e.toString()),n=encodeURIComponent(t),i[i.length]=n+"="+r}),i.join(t)},qu.getQueryParam=function(e,t){t=t.replace(/[[]/g,"\\[").replace(/[\]]/g,"\\]");var r=new RegExp("[\\?&]"+t+"=([^&#]*)").exec(e);if(null===r||r&&"string"!=typeof r[1]&&r[1].length)return"";var n=r[1];try{n=decodeURIComponent(n)}catch(Hy){$u.error("Skipping decoding for malformed query param: "+n)}return n.replace(/\+/g," ")},qu.cookie={get:function(e){for(var t=e+"=",r=Mu.cookie.split(";"),n=0;n<r.length;n++){for(var i=r[n];" "==i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return decodeURIComponent(i.substring(t.length,i.length))}return null},parse:function(e){var t;try{t=qu.JSONDecode(qu.cookie.get(e))||{}}catch(Hy){}return t},set_seconds:function(e,t,r,n,i,o,s){var a="",c="",l="";if(s)a="; domain="+s;else if(n){var u=sd(Mu.location.hostname);a=u?"; domain=."+u:""}if(r){var d=new Date;d.setTime(d.getTime()+1e3*r),c="; expires="+d.toGMTString()}o&&(i=!0,l="; SameSite=None"),i&&(l+="; secure"),Mu.cookie=e+"="+encodeURIComponent(t)+c+"; path=/"+a+l},set:function(e,t,r,n,i,o,s){var a="",c="",l="";if(s)a="; domain="+s;else if(n){var u=sd(Mu.location.hostname);a=u?"; domain=."+u:""}if(r){var d=new Date;d.setTime(d.getTime()+24*r*60*60*1e3),c="; expires="+d.toGMTString()}o&&(i=!0,l="; SameSite=None"),i&&(l+="; secure");var h=e+"="+encodeURIComponent(t)+c+"; path=/"+a+l;return Mu.cookie=h,h},remove:function(e,t,r){qu.cookie.set(e,"",-1,t,!1,!1,r)}};var Zu=function(e){var t=!0;try{var r="__mplss_"+nd(8);e.setItem(r,"xyz"),"xyz"!==e.getItem(r)&&(t=!1),e.removeItem(r)}catch(Hy){t=!1}return t},Ku=null,Ju=function(e,t){return null===Ku||t?Ku=Zu(e||p.localStorage):Ku},Xu=null;function Qu(e,t,r){var n=function(e){$u.error(t+" error: "+e)};return{is_supported:function(n){var i=r(e,n);return i||$u.error(t+" unsupported"),i},error:n,get:function(t){try{return e.getItem(t)}catch(Hy){n(Hy)}return null},parse:function(t){try{return qu.JSONDecode(e.getItem(t))||{}}catch(Hy){}return null},set:function(t,r){try{e.setItem(t,r)}catch(Hy){n(Hy)}},remove:function(t){try{e.removeItem(t)}catch(Hy){n(Hy)}}}}qu.localStorage=Qu(p.localStorage,"localStorage",Ju),qu.sessionStorage=Qu(p.sessionStorage,"sessionStorage",function(e,t){return null===Xu||t?Xu=Zu(e||p.sessionStorage):Xu}),qu.register_event=function(){function e(t){return t&&(t.preventDefault=e.preventDefault,t.stopPropagation=e.stopPropagation),t}return e.preventDefault=function(){this.returnValue=!1},e.stopPropagation=function(){this.cancelBubble=!0},function(t,r,n,i,o){if(t)if(t.addEventListener&&!i)t.addEventListener(r,n,!!o);else{var s="on"+r,a=t[s];t[s]=function(t,r,n){var i=function(i){if(i=i||e(p.event)){var o,s,a=!0;return qu.isFunction(n)&&(o=n(i)),s=r.call(t,i),!1!==o&&!1!==s||(a=!1),a}};return i}(t,n,a)}else $u.error("No valid element provided to register_event")}}();var ed=new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');qu.dom_query=function(){function e(e){return e.all?e.all:e.getElementsByTagName("*")}var t=/[\t\r\n]/g;function r(e,r){var n=" "+r+" ";return(" "+e.className+" ").replace(t," ").indexOf(n)>=0}function n(t){if(!Mu.getElementsByTagName)return[];var n,i,o,s,a,c,l,u,d,h,p=t.split(" "),f=[Mu];for(c=0;c<p.length;c++)if((n=p[c].replace(/^\s+/,"").replace(/\s+$/,"")).indexOf("#")>-1){o=(i=n.split("#"))[0];var m=i[1],g=Mu.getElementById(m);if(!g||o&&g.nodeName.toLowerCase()!=o)return[];f=[g]}else if(n.indexOf(".")>-1){o=(i=n.split("."))[0];var y=i[1];for(o||(o="*"),s=[],a=0,l=0;l<f.length;l++)for(d="*"==o?e(f[l]):f[l].getElementsByTagName(o),u=0;u<d.length;u++)s[a++]=d[u];for(f=[],h=0,l=0;l<s.length;l++)s[l].className&&qu.isString(s[l].className)&&r(s[l],y)&&(f[h++]=s[l])}else{var v=n.match(ed);if(v){o=v[1];var b,w=v[2],x=v[3],_=v[4];for(o||(o="*"),s=[],a=0,l=0;l<f.length;l++)for(d="*"==o?e(f[l]):f[l].getElementsByTagName(o),u=0;u<d.length;u++)s[a++]=d[u];switch(f=[],h=0,x){case"=":b=function(e){return e.getAttribute(w)==_};break;case"~":b=function(e){return e.getAttribute(w).match(new RegExp("\\b"+_+"\\b"))};break;case"|":b=function(e){return e.getAttribute(w).match(new RegExp("^"+_+"-?"))};break;case"^":b=function(e){return 0===e.getAttribute(w).indexOf(_)};break;case"$":b=function(e){return e.getAttribute(w).lastIndexOf(_)==e.getAttribute(w).length-_.length};break;case"*":b=function(e){return e.getAttribute(w).indexOf(_)>-1};break;default:b=function(e){return e.getAttribute(w)}}for(f=[],h=0,l=0;l<s.length;l++)b(s[l])&&(f[h++]=s[l])}else{for(o=n,s=[],a=0,l=0;l<f.length;l++)for(d=f[l].getElementsByTagName(o),u=0;u<d.length;u++)s[a++]=d[u];f=s}}return f}return function(e){return qu.isElement(e)?[e]:qu.isObject(e)&&!qu.isUndefined(e.length)?e:n.call(this,e)}}();var td=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","utm_id","utm_source_platform","utm_campaign_id","utm_creative_format","utm_marketing_tactic"],rd=["dclid","fbclid","gclid","ko_click_id","li_fat_id","msclkid","sccid","ttclid","twclid","wbraid"];qu.info={campaignParams:function(e){var t="",r={};return qu.each(td,function(n){(t=qu.getQueryParam(Mu.URL,n)).length?r[n]=t:void 0!==e&&(r[n]=e)}),r},clickParams:function(){var e="",t={};return qu.each(rd,function(r){(e=qu.getQueryParam(Mu.URL,r)).length&&(t[r]=e)}),t},marketingParams:function(){return qu.extend(qu.info.campaignParams(),qu.info.clickParams())},searchEngine:function(e){return 0===e.search("https?://(.*)google.([^/?]*)")?"google":0===e.search("https?://(.*)bing.com")?"bing":0===e.search("https?://(.*)yahoo.com")?"yahoo":0===e.search("https?://(.*)duckduckgo.com")?"duckduckgo":null},searchInfo:function(e){var t=qu.info.searchEngine(e),r="yahoo"!=t?"q":"p",n={};if(null!==t){n.$search_engine=t;var i=qu.getQueryParam(e,r);i.length&&(n.mp_keyword=i)}return n},browser:function(e,t,r){return t=t||"",r||qu.includes(e," OPR/")?qu.includes(e,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":qu.includes(e,"IEMobile")||qu.includes(e,"WPDesktop")?"Internet Explorer Mobile":qu.includes(e,"SamsungBrowser/")?"Samsung Internet":qu.includes(e,"Edge")||qu.includes(e,"Edg/")?"Microsoft Edge":qu.includes(e,"FBIOS")?"Facebook Mobile":qu.includes(e,"Whale/")?"Whale Browser":qu.includes(e,"Chrome")?"Chrome":qu.includes(e,"CriOS")?"Chrome iOS":qu.includes(e,"UCWEB")||qu.includes(e,"UCBrowser")?"UC Browser":qu.includes(e,"FxiOS")?"Firefox iOS":qu.includes(t,"Apple")?qu.includes(e,"Mobile")?"Mobile Safari":"Safari":qu.includes(e,"Android")?"Android Mobile":qu.includes(e,"Konqueror")?"Konqueror":qu.includes(e,"Firefox")?"Firefox":qu.includes(e,"MSIE")||qu.includes(e,"Trident/")?"Internet Explorer":qu.includes(e,"Gecko")?"Mozilla":""},browserVersion:function(e,t,r){var n={"Internet Explorer Mobile":/rv:(\d+(\.\d+)?)/,"Microsoft Edge":/Edge?\/(\d+(\.\d+)?)/,Chrome:/Chrome\/(\d+(\.\d+)?)/,"Chrome iOS":/CriOS\/(\d+(\.\d+)?)/,"UC Browser":/(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,Safari:/Version\/(\d+(\.\d+)?)/,"Mobile Safari":/Version\/(\d+(\.\d+)?)/,Opera:/(Opera|OPR)\/(\d+(\.\d+)?)/,Firefox:/Firefox\/(\d+(\.\d+)?)/,"Firefox iOS":/FxiOS\/(\d+(\.\d+)?)/,Konqueror:/Konqueror:(\d+(\.\d+)?)/,BlackBerry:/BlackBerry (\d+(\.\d+)?)/,"Android Mobile":/android\s(\d+(\.\d+)?)/,"Samsung Internet":/SamsungBrowser\/(\d+(\.\d+)?)/,"Internet Explorer":/(rv:|MSIE )(\d+(\.\d+)?)/,Mozilla:/rv:(\d+(\.\d+)?)/,"Whale Browser":/Whale\/(\d+(\.\d+)?)/}[qu.info.browser(e,t,r)];if(void 0===n)return null;var i=e.match(n);return i?parseFloat(i[i.length-2]):null},os:function(){var e=ju;return/Windows/i.test(e)?/Phone/.test(e)||/WPDesktop/.test(e)?"Windows Phone":"Windows":/(iPhone|iPad|iPod)/.test(e)?"iOS":/Android/.test(e)?"Android":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Mac/i.test(e)?"Mac OS X":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"Chrome OS":""},device:function(e){return/Windows Phone/i.test(e)||/WPDesktop/.test(e)?"Windows Phone":/iPad/.test(e)?"iPad":/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(e)?"BlackBerry":/Android/.test(e)?"Android":""},referringDomain:function(e){var t=e.split("/");return t.length>=3?t[2]:""},currentUrl:function(){return p.location.href},properties:function(e){return"object"!=typeof e&&(e={}),qu.extend(qu.strip_empty_properties({$os:qu.info.os(),$browser:qu.info.browser(ju,Ou.vendor,Tu),$referrer:Mu.referrer,$referring_domain:qu.info.referringDomain(Mu.referrer),$device:qu.info.device(ju)}),{$current_url:qu.info.currentUrl(),$browser_version:qu.info.browserVersion(ju,Ou.vendor,Tu),$screen_height:Ru.height,$screen_width:Ru.width,mp_lib:"web",$lib_version:xu.LIB_VERSION,$insert_id:nd(),time:qu.timestamp()/1e3},qu.strip_empty_properties(e))},people_properties:function(){return qu.extend(qu.strip_empty_properties({$os:qu.info.os(),$browser:qu.info.browser(ju,Ou.vendor,Tu)}),{$browser_version:qu.info.browserVersion(ju,Ou.vendor,Tu)})},mpPageViewProperties:function(){return qu.strip_empty_properties({current_page_title:Mu.title,current_domain:p.location.hostname,current_url_path:p.location.pathname,current_url_protocol:p.location.protocol,current_url_search:p.location.search})}};var nd=function(e){var t=Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10);return e?t.substring(0,e):t},id=/[a-z0-9][a-z0-9-]*\.[a-z]+$/i,od=/[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i,sd=function(e){var t=od,r=e.split("."),n=r[r.length-1];(n.length>4||"com"===n||"org"===n)&&(t=id);var i=e.match(t);return i?i[0]:""},ad=function(){},cd=null,ld=null;"undefined"!=typeof JSON&&(cd=JSON.stringify,ld=JSON.parse),cd=cd||qu.JSONEncode,ld=ld||qu.JSONDecode;qu.info=qu.info,qu.info.browser=qu.info.browser,qu.info.browserVersion=qu.info.browserVersion,qu.info.device=qu.info.device,qu.info.properties=qu.info.properties,qu.isBlockedUA=qu.isBlockedUA,qu.isEmptyObject=qu.isEmptyObject,qu.isObject=qu.isObject,qu.JSONDecode=qu.JSONDecode,qu.JSONEncode=qu.JSONEncode,qu.toArray=qu.toArray,qu.NPO=cu;var ud="mixpanelRecordingEvents",dd="mixpanelRecordingRegistry",hd=[ud,dd],pd=function(e){this.dbPromise=null,this.storeName=e};pd.prototype._openDb=function(){return new lu(function(e,t){var r=p.indexedDB.open("mixpanelBrowserDb",1);r.onerror=function(){t(r.error)},r.onsuccess=function(){e(r.result)},r.onupgradeneeded=function(e){var t=e.target.result;hd.forEach(function(e){t.createObjectStore(e)})}})},pd.prototype.init=function(){return p.indexedDB?(this.dbPromise||(this.dbPromise=this._openDb()),this.dbPromise.then(function(e){return e instanceof p.IDBDatabase?lu.resolve():lu.reject(e)})):lu.reject("indexedDB is not supported in this browser")},pd.prototype.isInitialized=function(){return!!this.dbPromise},pd.prototype.makeTransaction=function(e,t){var r=this.storeName,n=function(n){return new lu(function(i,o){var s=n.transaction(r,e);s.oncomplete=function(){i(s)},s.onabort=s.onerror=function(){o(s.error)},t(s.objectStore(r))})};return this.dbPromise.then(n).catch(function(e){return e&&"InvalidStateError"===e.name?(this.dbPromise=this._openDb(),this.dbPromise.then(n)):lu.reject(e)}.bind(this))},pd.prototype.setItem=function(e,t){return this.makeTransaction("readwrite",function(r){r.put(t,e)})},pd.prototype.getItem=function(e){var t;return this.makeTransaction("readonly",function(r){t=r.get(e)}).then(function(){return t.result})},pd.prototype.removeItem=function(e){return this.makeTransaction("readwrite",function(t){t.delete(e)})},pd.prototype.getAll=function(){var e;return this.makeTransaction("readonly",function(t){e=t.getAll()}).then(function(){return e.result})};function fd(e,t){Cd(!0,e,t)}function md(e,t){Cd(!1,e,t)}function gd(e,t){return"1"===Sd(e,t)}function yd(e,t){if(function(e){if(e&&e.ignoreDnt)return!1;var t=e&&e.window||p,r=t.navigator||{},n=!1;return qu.each([r.doNotTrack,r.msDoNotTrack,t.doNotTrack],function(e){qu.includes([!0,1,"1","yes"],e)&&(n=!0)}),n}(t))return $u.warn('This browser has "Do Not Track" enabled. This will prevent the Mixpanel SDK from sending any data. To ignore the "Do Not Track" browser setting, initialize the Mixpanel instance with the config "ignore_dnt: true"'),!0;var r="0"===Sd(e,t);return r&&$u.warn("You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data."),r}function vd(e){return Id(e,function(e){return this.get_config(e)})}function bd(e){return Id(e,function(e){return this._get_config(e)})}function wd(e){return Id(e,function(e){return this._get_config(e)})}function xd(e,t){_d(t=t||{}).remove(kd(e,t),!!t.crossSubdomainCookie,t.cookieDomain)}function _d(e){return"localStorage"===(e=e||{}).persistenceType?qu.localStorage:qu.cookie}function kd(e,t){return((t=t||{}).persistencePrefix||"__mp_opt_in_out_")+e}function Sd(e,t){return _d(t).get(kd(e,t))}function Cd(e,t,r){qu.isString(t)&&t.length?(_d(r=r||{}).set(kd(t,r),e?1:0,qu.isNumber(r.cookieExpiration)?r.cookieExpiration:null,!!r.crossSubdomainCookie,!!r.secureCookie,!!r.crossSiteCookie,r.cookieDomain),r.track&&e&&r.track(r.trackEventName||"$opt_in",r.trackProperties,{send_immediately:!0})):$u.error("gdpr."+(e?"optIn":"optOut")+" called with an invalid token")}function Id(e,t){return function(){var r=!1;try{var n=t.call(this,"token"),i=t.call(this,"ignore_dnt"),o=t.call(this,"opt_out_tracking_persistence_type"),s=t.call(this,"opt_out_tracking_cookie_prefix"),a=t.call(this,"window");n&&(r=yd(n,{ignoreDnt:i,persistenceType:o,persistencePrefix:s,window:a}))}catch(Hy){$u.error("Unexpected error when checking tracking opt-out status: "+Hy)}if(!r)return e.apply(this,arguments);var c=arguments[arguments.length-1];"function"==typeof c&&c(0)}}var Ed=Wu("lock"),Nd=function(e,t){t=t||{},this.storageKey=e,this.storage=t.storage||p.localStorage,this.pollIntervalMS=t.pollIntervalMS||100,this.timeoutMS=t.timeoutMS||2e3,this.promiseImpl=t.promiseImpl||lu};Nd.prototype.withLock=function(e,t){return new(0,this.promiseImpl)(qu.bind(function(r,n){var i=t||(new Date).getTime()+"|"+Math.random(),o=(new Date).getTime(),s=this.storageKey,a=this.pollIntervalMS,c=this.timeoutMS,l=this.storage,u=s+":X",d=s+":Y",h=s+":Z",p=function(e){if((new Date).getTime()-o>c)return Ed.error("Timeout waiting for mutex on "+s+"; clearing lock. ["+i+"]"),l.removeItem(h),l.removeItem(d),void g();setTimeout(function(){try{e()}catch(Hy){n(Hy)}},a*(Math.random()+.1))},f=function(e,t){e()?t():p(function(){f(e,t)})},m=function(){var e=l.getItem(d);return(!e||e===i)&&(l.setItem(d,i),l.getItem(d)===i||(Ju(l,!0)||n(new Error("localStorage support dropped while acquiring lock")),!1))},g=function(){l.setItem(u,i),f(m,function(){l.getItem(u)!==i?p(function(){l.getItem(d)===i?f(function(){return!l.getItem(h)},y):g()}):y()})},y=function(){l.setItem(h,"1");var t=function(){l.removeItem(h),l.getItem(d)===i&&l.removeItem(d),l.getItem(u)===i&&l.removeItem(u)};e().then(function(e){t(),r(e)}).catch(function(e){t(),n(e)})};try{if(!Ju(l,!0))throw new Error("localStorage support check failed");g()}catch(Hy){n(Hy)}},this))};var Ad=function(e){this.storage=e||p.localStorage};Ad.prototype.init=function(){return lu.resolve()},Ad.prototype.isInitialized=function(){return!0},Ad.prototype.setItem=function(e,t){return new lu(qu.bind(function(r,n){try{this.storage.setItem(e,cd(t))}catch(i){n(i)}r()},this))},Ad.prototype.getItem=function(e){return new lu(qu.bind(function(t,r){var n;try{n=ld(this.storage.getItem(e))}catch(i){r(i)}t(n)},this))},Ad.prototype.removeItem=function(e){return new lu(qu.bind(function(t,r){try{this.storage.removeItem(e)}catch(n){r(n)}t()},this))};var Pd=Wu("batch"),Od=function(e,t){var r,n,i,o;t=t||{},this.storageKey=e,this.usePersistence=t.usePersistence,this.usePersistence&&(this.queueStorage=t.queueStorage||new Ad,this.lock=new Nd(e,{storage:t.sharedLockStorage||p.localStorage,timeoutMS:t.sharedLockTimeoutMS})),this.reportError=t.errorReporter||qu.bind(Pd.error,Pd),this.pid=t.pid||null,this.memQueue=[],this.initialized=!1,t.enqueueThrottleMs?this.enqueuePersisted=(r=qu.bind(this._enqueuePersisted,this),n=t.enqueueThrottleMs,i=null,o=[],function(e){var t=this;return o.push(e),i||(i=new lu(function(e){setTimeout(function(){var n=r.apply(t,[o]);i=null,o=[],e(n)},n)})),i}):this.enqueuePersisted=qu.bind(function(e){return this._enqueuePersisted([e])},this)};Od.prototype.ensureInit=function(){return this.initialized||!this.usePersistence?lu.resolve():this.queueStorage.init().then(qu.bind(function(){this.initialized=!0},this)).catch(qu.bind(function(e){this.reportError("Error initializing queue persistence. Disabling persistence",e),this.initialized=!0,this.usePersistence=!1},this))},Od.prototype.enqueue=function(e,t){var r={id:nd(),flushAfter:(new Date).getTime()+2*t,payload:e};return this.usePersistence?this.enqueuePersisted(r):(this.memQueue.push(r),lu.resolve(!0))},Od.prototype._enqueuePersisted=function(e){var t=qu.bind(function(){return this.ensureInit().then(qu.bind(function(){return this.readFromStorage()},this)).then(qu.bind(function(t){return this.saveToStorage(t.concat(e))},this)).then(qu.bind(function(t){return t&&(this.memQueue=this.memQueue.concat(e)),t},this)).catch(qu.bind(function(t){return this.reportError("Error enqueueing items",t,e),!1},this))},this);return this.lock.withLock(t,this.pid).catch(qu.bind(function(e){return this.reportError("Error acquiring storage lock",e),!1},this))},Od.prototype.fillBatch=function(e){var t=this.memQueue.slice(0,e);return this.usePersistence&&t.length<e?this.ensureInit().then(qu.bind(function(){return this.readFromStorage()},this)).then(qu.bind(function(r){if(r.length){var n={};qu.each(t,function(e){n[e.id]=!0});for(var i=0;i<r.length;i++){var o=r[i];if((new Date).getTime()>o.flushAfter&&!n[o.id]&&(o.orphaned=!0,t.push(o),t.length>=e))break}}return t},this)):lu.resolve(t)};var Md=function(e,t){var r=[];return qu.each(e,function(e){e.id&&!t[e.id]&&r.push(e)}),r};Od.prototype.removeItemsByID=function(e){var t={};if(qu.each(e,function(e){t[e]=!0}),this.memQueue=Md(this.memQueue,t),this.usePersistence){var r=qu.bind(function(){return this.ensureInit().then(qu.bind(function(){return this.readFromStorage()},this)).then(qu.bind(function(e){return e=Md(e,t),this.saveToStorage(e)},this)).then(qu.bind(function(){return this.readFromStorage()},this)).then(qu.bind(function(e){for(var r=0;r<e.length;r++){var n=e[r];if(n.id&&t[n.id])throw new Error("Item not removed from storage")}return!0},this)).catch(qu.bind(function(t){return this.reportError("Error removing items",t,e),!1},this))},this);return this.lock.withLock(r,this.pid).catch(qu.bind(function(e){return this.reportError("Error acquiring storage lock",e),!Ju(this.lock.storage,!0)&&r().then(qu.bind(function(e){return e||this.queueStorage.removeItem(this.storageKey).then(function(){return e})},this)).catch(qu.bind(function(e){return this.reportError("Error clearing queue",e),!1},this))},this))}return lu.resolve(!0)};var Td=function(e,t){var r=[];return qu.each(e,function(e){var n=e.id;if(n in t){var i=t[n];null!==i&&(e.payload=i,r.push(e))}else r.push(e)}),r};Od.prototype.updatePayloads=function(e){return this.memQueue=Td(this.memQueue,e),this.usePersistence?this.lock.withLock(qu.bind(function(){return this.ensureInit().then(qu.bind(function(){return this.readFromStorage()},this)).then(qu.bind(function(t){return t=Td(t,e),this.saveToStorage(t)},this)).catch(qu.bind(function(t){return this.reportError("Error updating items",e,t),!1},this))},this),this.pid).catch(qu.bind(function(e){return this.reportError("Error acquiring storage lock",e),!1},this)):lu.resolve(!0)},Od.prototype.readFromStorage=function(){return this.ensureInit().then(qu.bind(function(){return this.queueStorage.getItem(this.storageKey)},this)).then(qu.bind(function(e){return e&&(qu.isArray(e)||(this.reportError("Invalid storage entry:",e),e=null)),e||[]},this)).catch(qu.bind(function(e){return this.reportError("Error retrieving queue",e),[]},this))},Od.prototype.saveToStorage=function(e){return this.ensureInit().then(qu.bind(function(){return this.queueStorage.setItem(this.storageKey,e)},this)).then(function(){return!0}).catch(qu.bind(function(e){return this.reportError("Error saving queue",e),!1},this))},Od.prototype.clear=function(){return this.memQueue=[],this.usePersistence?this.ensureInit().then(qu.bind(function(){return this.queueStorage.removeItem(this.storageKey)},this)):lu.resolve()};var Rd=Wu("batch"),jd=function(e,t){this.errorReporter=t.errorReporter,this.queue=new Od(e,{errorReporter:qu.bind(this.reportError,this),queueStorage:t.queueStorage,sharedLockStorage:t.sharedLockStorage,sharedLockTimeoutMS:t.sharedLockTimeoutMS,usePersistence:t.usePersistence,enqueueThrottleMs:t.enqueueThrottleMs}),this.libConfig=t.libConfig,this.sendRequest=t.sendRequestFunc,this.beforeSendHook=t.beforeSendHook,this.stopAllBatching=t.stopAllBatchingFunc,this.batchSize=this.libConfig.batch_size,this.flushInterval=this.libConfig.batch_flush_interval_ms,this.stopped=!this.libConfig.batch_autostart,this.consecutiveRemovalFailures=0,this.itemIdsSentSuccessfully={},this.flushOnlyOnInterval=t.flushOnlyOnInterval||!1,this._flushPromise=null};jd.prototype.enqueue=function(e){return this.queue.enqueue(e,this.flushInterval)},jd.prototype.start=function(){return this.stopped=!1,this.consecutiveRemovalFailures=0,this.flush()},jd.prototype.stop=function(){this.stopped=!0,this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null)},jd.prototype.clear=function(){return this.queue.clear()},jd.prototype.resetBatchSize=function(){this.batchSize=this.libConfig.batch_size},jd.prototype.resetFlush=function(){this.scheduleFlush(this.libConfig.batch_flush_interval_ms)},jd.prototype.scheduleFlush=function(e){this.flushInterval=e,this.stopped||(this.timeoutID=setTimeout(qu.bind(function(){this.stopped||(this._flushPromise=this.flush())},this),this.flushInterval))},jd.prototype.sendRequestPromise=function(e,t){return new lu(qu.bind(function(r){this.sendRequest(e,t,r)},this))},jd.prototype.flush=function(e){if(this.requestInProgress)return Rd.log("Flush: Request already in progress"),lu.resolve();this.requestInProgress=!0,e=e||{};var t=this.libConfig.batch_request_timeout_ms,r=(new Date).getTime(),n=this.batchSize;return this.queue.fillBatch(n).then(qu.bind(function(i){var o=i.length===n,s=[],a={};if(qu.each(i,function(e){var t=e.payload;if(this.beforeSendHook&&!e.orphaned&&(t=this.beforeSendHook(t)),t){t.event&&t.properties&&(t.properties=qu.extend({},t.properties,{mp_sent_by_lib_version:xu.LIB_VERSION}));var r=!0,n=e.id;n?(this.itemIdsSentSuccessfully[n]||0)>5&&(this.reportError("[dupe] item ID sent too many times, not sending",{item:e,batchSize:i.length,timesSent:this.itemIdsSentSuccessfully[n]}),r=!1):this.reportError("[dupe] found item with no ID",{item:e}),r&&s.push(t)}a[e.id]=t},this),s.length<1)return this.requestInProgress=!1,this.resetFlush(),lu.resolve();var c=qu.bind(function(){return this.queue.removeItemsByID(qu.map(i,function(e){return e.id})).then(qu.bind(function(e){return qu.each(i,qu.bind(function(e){var t=e.id;t?(this.itemIdsSentSuccessfully[t]=this.itemIdsSentSuccessfully[t]||0,this.itemIdsSentSuccessfully[t]++,this.itemIdsSentSuccessfully[t]>5&&this.reportError("[dupe] item ID sent too many times",{item:e,batchSize:i.length,timesSent:this.itemIdsSentSuccessfully[t]})):this.reportError("[dupe] found item with no ID while removing",{item:e})},this)),e?(this.consecutiveRemovalFailures=0,this.flushOnlyOnInterval&&!o?(this.resetFlush(),lu.resolve()):this.flush()):(++this.consecutiveRemovalFailures>5?(this.reportError("Too many queue failures; disabling batching system."),this.stopAllBatching()):this.resetFlush(),lu.resolve())},this))},this),l=qu.bind(function(o){this.requestInProgress=!1;try{if(e.unloading)return this.queue.updatePayloads(a);if(qu.isObject(o)&&"timeout"===o.error&&(new Date).getTime()-r>=t)return this.reportError("Network timeout; retrying"),this.flush();if(qu.isObject(o)&&(o.httpStatusCode>=500||429===o.httpStatusCode||o.httpStatusCode<=0&&(u=p.navigator.onLine,!qu.isUndefined(u)&&!u)||"timeout"===o.error)){var s=2*this.flushInterval;return o.retryAfter&&(s=1e3*parseInt(o.retryAfter,10)||s),s=Math.min(6e5,s),this.reportError("Error; retry in "+s+" ms"),this.scheduleFlush(s),lu.resolve()}if(qu.isObject(o)&&413===o.httpStatusCode){if(i.length>1){var l=Math.max(1,Math.floor(n/2));return this.batchSize=Math.min(this.batchSize,l,i.length-1),this.reportError("413 response; reducing batch size to "+this.batchSize),this.resetFlush(),lu.resolve()}return this.reportError("Single-event request too large; dropping",i),this.resetBatchSize(),c()}return c()}catch(Hy){this.reportError("Error handling API response",Hy),this.resetFlush()}var u},this),u={method:"POST",verbose:!0,ignore_json_errors:!0,timeout_ms:t};return e.unloading&&(u.transport="sendBeacon"),Rd.log("MIXPANEL REQUEST:",s),this.sendRequestPromise(s,u).then(l)},this)).catch(qu.bind(function(e){this.reportError("Error flushing request queue",e),this.resetFlush()},this))},jd.prototype.reportError=function(e,t){if(Rd.error.apply(Rd.error,arguments),this.errorReporter)try{t instanceof Error||(t=new Error(e)),this.errorReporter(e,t)}catch(r){Rd.error(r)}};var Dd=function(e){var t=Date.now();return!e||t>e.maxExpires||t>e.idleExpires},Fd=Wu("recorder"),Ld=p.CompressionStream,Ud={batch_size:1e3,batch_flush_interval_ms:1e4,batch_request_timeout_ms:9e4,batch_autostart:!0},Bd=new Set([Pc.MouseMove,Pc.MouseInteraction,Pc.Scroll,Pc.ViewportResize,Pc.Input,Pc.TouchMove,Pc.MediaInteraction,Pc.Drag,Pc.Selection]);var zd=function(e){this._mixpanel=e.mixpanelInstance,this._onIdleTimeout=e.onIdleTimeout||ad,this._onMaxLengthReached=e.onMaxLengthReached||ad,this._onBatchSent=e.onBatchSent||ad,this._rrwebRecord=e.rrwebRecord||null,this._stopRecording=null,this.replayId=e.replayId,this.batchStartUrl=e.batchStartUrl||null,this.replayStartUrl=e.replayStartUrl||null,this.idleExpires=e.idleExpires||null,this.maxExpires=e.maxExpires||null,this.replayStartTime=e.replayStartTime||null,this.lastEventTimestamp=e.lastEventTimestamp||null,this.seqNo=e.seqNo||0,this.idleTimeoutId=null,this.maxTimeoutId=null,this.recordMaxMs=_u,this.recordMinMs=0;var t=Ju(e.sharedLockStorage,!0)&&!this.getConfig("disable_persistence");this.batcherKey="__mprec_"+this.getConfig("name")+"_"+this.getConfig("token")+"_"+this.replayId,this.queueStorage=new pd(ud),this.batcher=new jd(this.batcherKey,{errorReporter:this.reportError.bind(this),flushOnlyOnInterval:!0,libConfig:Ud,sendRequestFunc:this.flushEventsWithOptOut.bind(this),queueStorage:this.queueStorage,sharedLockStorage:e.sharedLockStorage,usePersistence:t,stopAllBatchingFunc:this.stopRecording.bind(this),enqueueThrottleMs:250,sharedLockTimeoutMS:1e4})};zd.prototype.getUserIdInfo=function(){if(this.finalFlushUserIdInfo)return this.finalFlushUserIdInfo;var e={distinct_id:String(this._mixpanel.get_distinct_id())},t=this._mixpanel.get_property("$device_id");t&&(e.$device_id=t);var r=this._mixpanel.get_property("$user_id");return r&&(e.$user_id=r),e},zd.prototype.unloadPersistedData=function(){return this.batcher.stop(),this.queueStorage.init().catch(function(){this.reportError("Error initializing IndexedDB storage for unloading persisted data.")}.bind(this)).then(function(){return this.getDurationMs()<this._getRecordMinMs()?this.queueStorage.removeItem(this.batcherKey):this.batcher.flush().then(function(){return this.queueStorage.removeItem(this.batcherKey)}.bind(this))}.bind(this))},zd.prototype.getConfig=function(e){return this._mixpanel.get_config(e)},zd.prototype.get_config=function(e){return this.getConfig(e)},zd.prototype.startRecording=function(e){if(null!==this._rrwebRecord)if(null===this._stopRecording){this.recordMaxMs=this.getConfig("record_max_ms"),this.recordMaxMs>_u&&(this.recordMaxMs=_u,Fd.critical("record_max_ms cannot be greater than "+_u+"ms. Capping value.")),this.maxExpires||(this.maxExpires=(new Date).getTime()+this.recordMaxMs),this.recordMinMs=this._getRecordMinMs(),this.replayStartTime||(this.replayStartTime=(new Date).getTime(),this.batchStartUrl=qu.info.currentUrl(),this.replayStartUrl=qu.info.currentUrl()),e||this.recordMinMs>0?this.batcher.stop():this.batcher.start();var t=function(){clearTimeout(this.idleTimeoutId);var e=this.getConfig("record_idle_timeout_ms");this.idleTimeoutId=setTimeout(this._onIdleTimeout,e),this.idleExpires=(new Date).getTime()+e}.bind(this);t();var r,n=this.getConfig("record_block_selector");""!==n&&null!==n||(n=void 0);try{this._stopRecording=this._rrwebRecord({emit:function(e){this.idleExpires&&this.idleExpires<e.timestamp?this._onIdleTimeout():(function(e){return e.type===Ac.IncrementalSnapshot&&Bd.has(e.data.source)}(e)&&(this.batcher.stopped&&(new Date).getTime()-this.replayStartTime>=this.recordMinMs&&this.batcher.start(),t()),this.__enqueuePromise=this.batcher.enqueue(e),(null===this.lastEventTimestamp||e.timestamp>this.lastEventTimestamp)&&(this.lastEventTimestamp=e.timestamp))}.bind(this),blockClass:this.getConfig("record_block_class"),blockSelector:n,collectFonts:this.getConfig("record_collect_fonts"),dataURLOptions:{type:"image/webp",quality:.6},maskAllInputs:!0,maskTextClass:this.getConfig("record_mask_text_class"),maskTextSelector:this.getConfig("record_mask_text_selector"),recordCanvas:this.getConfig("record_canvas"),sampling:{canvas:15},plugins:this.getConfig("record_console")?[(r={stringifyOptions:{stringLengthLimit:1e3,numOfKeysLimit:50,depthOfLimit:2}},{name:"rrweb/console@1",observer:Vl,options:r})]:[]})}catch(Hy){this.reportError("Unexpected error when starting rrweb recording.",Hy)}if("function"!=typeof this._stopRecording)return this.reportError("rrweb failed to start, skipping this recording."),this._stopRecording=null,void this.stopRecording();var i=this.maxExpires-(new Date).getTime();this.maxTimeoutId=setTimeout(this._onMaxLengthReached.bind(this),i)}else Fd.log("Recording already in progress, skipping startRecording.");else this.reportError("rrweb record function not provided. ")},zd.prototype.stopRecording=function(e){if(this.finalFlushUserIdInfo=this.getUserIdInfo(),!this.isRrwebStopped()){try{this._stopRecording()}catch(Hy){this.reportError("Error with rrweb stopRecording",Hy)}this._stopRecording=null}var t;return this.batcher.stopped?t=this.batcher.clear():e||(t=this.batcher.flush()),this.batcher.stop(),clearTimeout(this.idleTimeoutId),clearTimeout(this.maxTimeoutId),t},zd.prototype.isRrwebStopped=function(){return null===this._stopRecording},zd.prototype.flushEventsWithOptOut=function(e,t,r){var n=function(e){0===e&&(this.stopRecording(),r({error:"Tracking has been opted out, stopping recording."}))}.bind(this);this._flushEvents(e,t,r,n)},zd.prototype.serialize=function(){var e;try{e=this._mixpanel.get_tab_id()}catch(t){this.reportError("Error getting tab ID for serialization ",t),e=null}return{replayId:this.replayId,seqNo:this.seqNo,replayStartTime:this.replayStartTime,batchStartUrl:this.batchStartUrl,replayStartUrl:this.replayStartUrl,lastEventTimestamp:this.lastEventTimestamp,idleExpires:this.idleExpires,maxExpires:this.maxExpires,tabId:e}},zd.deserialize=function(e,t){return new zd(qu.extend({},t,{replayId:e.replayId,batchStartUrl:e.batchStartUrl,replayStartUrl:e.replayStartUrl,idleExpires:e.idleExpires,maxExpires:e.maxExpires,replayStartTime:e.replayStartTime,lastEventTimestamp:e.lastEventTimestamp,seqNo:e.seqNo,sharedLockStorage:t.sharedLockStorage}))},zd.prototype._sendRequest=function(e,t,r,n){var i=function(t,r){200===t.status&&this.replayId===e&&(this.seqNo++,this.batchStartUrl=qu.info.currentUrl()),this._onBatchSent(),n({status:0,httpStatusCode:t.status,responseBody:r,retryAfter:t.headers.get("Retry-After")})}.bind(this),o=this._mixpanel.get_api_host&&this._mixpanel.get_api_host("record")||this.getConfig("api_host");p.fetch(o+"/"+this.getConfig("api_routes").record+"?"+new URLSearchParams(t),{method:"POST",headers:{Authorization:"Basic "+btoa(this.getConfig("token")+":"),"Content-Type":"application/octet-stream"},body:r}).then(function(e){e.json().then(function(t){i(e,t)}).catch(function(e){n({error:e})})}).catch(function(e){n({error:e,httpStatusCode:0})})},zd.prototype._flushEvents=vd(function(e,t,r){var n=e.length;if(n>0){for(var i=this.replayId,o=1/0,s=-1/0,a=!1,c=0;c<n;c++)o=Math.min(o,e[c].timestamp),s=Math.max(s,e[c].timestamp),e[c].type===Ac.FullSnapshot&&(a=!0);if(0===this.seqNo){if(!a)return r({error:"First batch does not contain a full snapshot. Aborting recording."}),void this.stopRecording(!0);this.replayStartTime=o}else this.replayStartTime||(this.reportError("Replay start time not set but seqNo is not 0. Using current batch start time as a fallback."),this.replayStartTime=o);var l=s-this.replayStartTime,u={$current_url:this.batchStartUrl,$lib_version:xu.LIB_VERSION,batch_start_time:o/1e3,mp_lib:"web",replay_id:i,replay_length_ms:l,replay_start_time:this.replayStartTime/1e3,replay_start_url:this.replayStartUrl,seq:this.seqNo},d=JSON.stringify(e);if(Object.assign(u,this.getUserIdInfo()),function(e,t,r){if(!p.CompressionStream)return!1;var n=qu.info.browser(e,t,r),i=qu.info.browserVersion(e,t,r);return!(("Safari"===n||"Mobile Safari"===n)&&i>=16.4&&i<16.6)}(ju,Ou.vendor,Tu)){var h=new Blob([d],{type:"application/json"}).stream().pipeThrough(new Ld("gzip"));new Response(h).blob().then(function(e){u.format="gzip",this._sendRequest(i,u,e,r)}.bind(this))}else u.format="body",this._sendRequest(i,u,d,r)}}),zd.prototype.reportError=function(e,t){Fd.error.apply(Fd.error,arguments);try{t||e instanceof Error||(e=new Error(e)),this.getConfig("error_reporter")(e,t)}catch(r){Fd.error(r)}},zd.prototype.getDurationMs=function(){return null===this.replayStartTime?0:null===this.lastEventTimestamp?(new Date).getTime()-this.replayStartTime:this.lastEventTimestamp-this.replayStartTime},zd.prototype._getRecordMinMs=function(){var e=this.getConfig("record_min_ms");return e>ku?(Fd.critical("record_min_ms cannot be greater than 8000ms. Capping value."),ku):e};var qd=function(e){this.idb=new pd(dd),this.errorReporter=e.errorReporter,this.mixpanelInstance=e.mixpanelInstance,this.sharedLockStorage=e.sharedLockStorage};qd.prototype.isPersistenceEnabled=function(){return!this.mixpanelInstance.get_config("disable_persistence")},qd.prototype.handleError=function(e){this.errorReporter("IndexedDB error: ",e)},qd.prototype.setActiveRecording=function(e){if(!this.isPersistenceEnabled())return lu.resolve();var t=e.tabId;return t?this.idb.init().then(function(){return this.idb.setItem(t,e)}.bind(this)).catch(this.handleError.bind(this)):(console.warn("No tab ID is set, cannot persist recording metadata."),lu.resolve())},qd.prototype.getActiveRecording=function(){return this.isPersistenceEnabled()?this.idb.init().then(function(){return this.idb.getItem(this.mixpanelInstance.get_tab_id())}.bind(this)).then(function(e){return Dd(e)?null:e}.bind(this)).catch(this.handleError.bind(this)):lu.resolve(null)},qd.prototype.clearActiveRecording=function(){return this.isPersistenceEnabled()?this.markActiveRecordingExpired():this.deleteActiveRecording()},qd.prototype.markActiveRecordingExpired=function(){return this.getActiveRecording().then(function(e){if(e)return e.maxExpires=0,this.setActiveRecording(e)}.bind(this)).catch(this.handleError.bind(this))},qd.prototype.deleteActiveRecording=function(){return this.idb.isInitialized()?this.idb.removeItem(this.mixpanelInstance.get_tab_id()).catch(this.handleError.bind(this)):lu.resolve()},qd.prototype.flushInactiveRecordings=function(){return this.isPersistenceEnabled()?this.idb.init().then(function(){return this.idb.getAll()}.bind(this)).then(function(e){var t=e.filter(function(e){return Dd(e)}).map(function(e){return zd.deserialize(e,{mixpanelInstance:this.mixpanelInstance,sharedLockStorage:this.sharedLockStorage}).unloadPersistedData().then(function(){return this.idb.removeItem(e.tabId)}.bind(this)).catch(this.handleError.bind(this))}.bind(this));return lu.all(t)}.bind(this)).catch(this.handleError.bind(this)):lu.resolve([])};var $d=Wu("recorder"),Gd=function(e,t,r){this.mixpanelInstance=e,this.rrwebRecord=t||Tl,this.sharedLockStorage=r,this.recordingRegistry=new qd({mixpanelInstance:this.mixpanelInstance,errorReporter:$d.error,sharedLockStorage:r}),this._flushInactivePromise=this.recordingRegistry.flushInactiveRecordings(),this.activeRecording=null,this.stopRecordingInProgress=!1};Gd.prototype.startRecording=function(e){if(e=e||{},!this.activeRecording||this.activeRecording.isRrwebStopped()){var t=function(){$d.log("Idle timeout reached, restarting recording."),this.resetRecording()}.bind(this),r=function(){$d.log("Max recording length reached, stopping recording."),this.resetRecording()}.bind(this),n=function(){this.recordingRegistry.setActiveRecording(this.activeRecording.serialize()),this.__flushPromise=this.activeRecording.batcher._flushPromise}.bind(this),i={mixpanelInstance:this.mixpanelInstance,onBatchSent:n,onIdleTimeout:t,onMaxLengthReached:r,replayId:qu.UUID(),rrwebRecord:this.rrwebRecord,sharedLockStorage:this.sharedLockStorage};return e.activeSerializedRecording?this.activeRecording=zd.deserialize(e.activeSerializedRecording,i):this.activeRecording=new zd(i),this.activeRecording.startRecording(e.shouldStopBatcher),this.recordingRegistry.setActiveRecording(this.activeRecording.serialize())}$d.log("Recording already in progress, skipping startRecording.")},Gd.prototype.stopRecording=function(){return this.stopRecordingInProgress=!0,this._stopCurrentRecording(!1,!0).then(function(){return this.recordingRegistry.clearActiveRecording()}.bind(this)).then(function(){this.stopRecordingInProgress=!1}.bind(this))},Gd.prototype.pauseRecording=function(){return this._stopCurrentRecording(!1)},Gd.prototype._stopCurrentRecording=function(e,t){if(this.activeRecording){var r=this.activeRecording.stopRecording(e);return t&&(this.activeRecording=null),r}return lu.resolve()},Gd.prototype.resumeRecording=function(e){return this.activeRecording&&this.activeRecording.isRrwebStopped()?(this.activeRecording.startRecording(!1),lu.resolve(null)):this.recordingRegistry.getActiveRecording().then(function(t){return t&&!this.stopRecordingInProgress?this.startRecording({activeSerializedRecording:t}):e?this.startRecording({shouldStopBatcher:!1}):($d.log("No resumable recording found."),null)}.bind(this))},Gd.prototype.resetRecording=function(){this.stopRecording(),this.startRecording({shouldStopBatcher:!0})},Gd.prototype.getActiveReplayId=function(){return this.activeRecording&&!this.activeRecording.isRrwebStopped()?this.activeRecording.replayId:null},Object.defineProperty(Gd.prototype,"replayId",{get:function(){return this.getActiveReplayId()}}),p.__mp_recorder=Gd;var Wd="change",Vd="click",Hd="hashchange",Yd="load",Zd="mp_locationchange",Kd="popstate",Jd="scrollend",Xd="scroll",Qd="submit",eh="visibilitychange",th=["clientX","clientY","offsetX","offsetY","pageX","pageY","screenX","screenY","x","y"],rh=["mp-include"],nh=["mp-no-track"],ih=nh.concat(["mp-sensitive"]),oh=["aria-label","aria-labelledby","aria-describedby","href","name","role","title","type"],sh={button:!0,checkbox:!0,combobox:!0,grid:!0,link:!0,listbox:!0,menu:!0,menubar:!0,menuitem:!0,menuitemcheckbox:!0,menuitemradio:!0,navigation:!0,option:!0,radio:!0,radiogroup:!0,searchbox:!0,slider:!0,spinbutton:!0,switch:!0,tab:!0,tablist:!0,textbox:!0,tree:!0,treegrid:!0,treeitem:!0},ah={base:!0,head:!0,html:!0,link:!0,meta:!0,script:!0,style:!0,title:!0,br:!0,hr:!0,wbr:!0,noscript:!0,picture:!0,source:!0,template:!0,track:!0},ch={article:!0,div:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,p:!0,section:!0,span:!0},lh=["onclick","onmousedown","onmouseup","onpointerdown","onpointerup","ontouchend","ontouchstart"],uh=Wu("autocapture");function dh(e){for(var t={},r=hh(e).split(" "),n=0;n<r.length;n++){var i=r[n];i&&(t[i]=!0)}return t}function hh(e){switch(typeof e.className){case"string":return e.className;case"object":return e.className.baseVal||e.getAttribute("class")||"";default:return""}}function ph(e){if(e.previousElementSibling)return e.previousElementSibling;do{e=e.previousSibling}while(e&&!bh(e));return e}function fh(e,t,r,n,i,o){var s={$classes:hh(e).split(" "),$tag_name:e.tagName.toLowerCase()},a=e.id;a&&(s.$id=a),_h(e,t,i,o)&&qu.each(oh.concat(n),function(t){if(e.hasAttribute(t)&&!r[t]){var n=e.getAttribute(t);kh(n)&&(s["$attr-"+t]=n)}});for(var c=1,l=1,u=e;u=ph(u);)c++,u.tagName===e.tagName&&l++;return s.$nth_child=c,s.$nth_of_type=l,s}function mh(e,t){var r=t.allowElementCallback,n=t.allowSelectors||[],i=t.blockAttrs||[],o=t.blockElementCallback,s=t.blockSelectors||[],a=t.captureTextContent||!1,c=t.captureExtraAttrs||[],l=t.capturedForHeatMap||!1,u={};qu.each(i,function(e){u[e]=!0});var d=null,h=void 0===e.target?e.srcElement:e.target;if(xh(h)&&(h=h.parentNode),function(e,t){if(!e||wh(e,"html")||!bh(e))return!1;switch(e.tagName.toLowerCase()){case"form":return t.type===Qd;case"input":return-1===["button","submit"].indexOf(e.getAttribute("type"))?t.type===Wd:t.type===Vd;case"select":case"textarea":return t.type===Wd;default:return t.type===Vd}}(h,e)&&yh(h,e,r,n)&&!vh(h,e,o,s)){for(var f=[h],m=h;m.parentNode&&!wh(m,"body");)f.push(m.parentNode),m=m.parentNode;var g,y=[],v=!1;if(qu.each(f,function(t){var i=_h(t,e,r,n);u.href||"a"!==t.tagName.toLowerCase()||(g=t.getAttribute("href"),g=i&&kh(g)&&g),vh(t,e,o,s)&&(v=!0),y.push(fh(t,e,u,c,r,n))},this),!v){var b=Mu.documentElement;if(d={$event_type:e.type,$host:p.location.host,$pathname:p.location.pathname,$elements:y,$el_attr__href:g,$viewportHeight:Math.max(b.clientHeight,p.innerHeight||0),$viewportWidth:Math.max(b.clientWidth,p.innerWidth||0),$pageHeight:Mu.body.offsetHeight||0,$pageWidth:Mu.body.offsetWidth||0},qu.each(c,function(e){if(!u[e]&&h.hasAttribute(e)){var t=h.getAttribute(e);kh(t)&&(d["$el_attr__"+e]=t)}}),a&&(w=gh(h,e,r,n))&&w.length&&(d.$el_text=w),e.type===Vd&&(qu.each(th,function(t){t in e&&(d["$"+t]=e[t])}),l&&(d.$captured_for_heatmap=!0),h=function(e){for(var t=e.target,r=e.composedPath(),n=0;n<r.length;n++){var i=r[n];if(wh(i,"a")||wh(i,"button")||wh(i,"input")||wh(i,"select")||i.getAttribute&&"button"===i.getAttribute("role")){t=i;break}if(i===t)break}return t}(e)),a){var w=gh(h,e,r,n);w&&w.length&&(d.$el_text=w)}if(h){if(!yh(h,e,r,n)||vh(h,e,o,s))return null;var x=fh(h,e,u,c,r,n);d.$target=x,d.$el_classes=x.$classes,qu.extend(d,qu.strip_empty_properties({$el_id:x.$id,$el_tag_name:x.$tag_name}))}}}return d}function gh(e,t,r,n){var i="";return _h(e,t,r,n)&&e.childNodes&&e.childNodes.length&&qu.each(e.childNodes,function(e){xh(e)&&e.textContent&&(i+=qu.trim(e.textContent).split(/(\s+)/).filter(kh).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),qu.trim(i)}function yh(e,t,r,n){if(r)try{if(!r(e,t))return!1}catch(Hy){return uh.critical("Error while checking element in allowElementCallback",Hy),!1}if(!n.length)return!0;for(var i=0;i<n.length;i++){var o=n[i];try{if(e.matches(o))return!0}catch(Hy){uh.critical("Error while checking selector: "+o,Hy)}}return!1}function vh(e,t,r,n){var i;if(r)try{if(r(e,t))return!0}catch(Hy){return uh.critical("Error while checking element in blockElementCallback",Hy),!0}if(n&&n.length)for(i=0;i<n.length;i++){var o=n[i];try{if(e.matches(o))return!0}catch(Hy){uh.critical("Error while checking selector: "+o,Hy)}}var s=dh(e);for(i=0;i<nh.length;i++)if(s[nh[i]])return!0;return!1}function bh(e){return e&&1===e.nodeType}function wh(e,t){return e&&e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function xh(e){return e&&3===e.nodeType}function _h(e,t,r,n){var i;if(!yh(e,t,r,n))return!1;for(var o=e;o.parentNode&&!wh(o,"body");o=o.parentNode){var s=dh(o);for(i=0;i<ih.length;i++)if(s[ih[i]])return!1}var a=dh(e);for(i=0;i<rh.length;i++)if(a[rh[i]])return!0;if(wh(e,"input")||wh(e,"select")||wh(e,"textarea")||"true"===e.getAttribute("contenteditable"))return!1;var c=e.type||"";if("string"==typeof c)switch(c.toLowerCase()){case"hidden":case"password":return!1}var l=e.name||e.id||"";if("string"==typeof l){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(l.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function kh(e){if(null===e||qu.isUndefined(e))return!1;if("string"==typeof e){e=qu.trim(e);if(/^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((e||"").replace(/[- ]/g,"")))return!1;if(/(^\d{3}-?\d{2}-?\d{4}$)/.test(e))return!1}return!0}function Sh(e){var t="onscrollend"in p,r=Vu(e),n=Jd;if(!t){var i=null;r=Vu(function(){clearTimeout(i),i=setTimeout(e,100)}),n=Xd}return{listener:r,eventType:n}}function Ch(e){var t=e.tagName.toLowerCase();return"button"===t||"input"===t||"select"===t||"textarea"===t||"details"===t||"dialog"===t||(!!e.isContentEditable||(!!(e.onclick||e.onmousedown||e.onmouseup||e.ontouchstart||e.ontouchend)||(!!function(e){for(var t=0;t<lh.length;t++)if(e.hasAttribute(lh[t]))return!0;return!1}(e)||(!!function(e){var t=e.getAttribute("role");if(!t)return!1;var r=t.trim().split(/\s+/)[0].toLowerCase();return sh[r]}(e)||(!("a"!==t||!e.hasAttribute("href"))||!!e.hasAttribute("tabindex"))))))}function Ih(e){if(!e||!e.tagName)return!0;var t=e.tagName.toLowerCase();if(ah[t])return!0;if(Ch(e))return!1;for(var r=e.parentElement,n=0;r&&n<5;){if(Ch(r))return!1;if(r.getRootNode&&r.getRootNode()!==Mu){var i=r.getRootNode();if(i.host&&Ch(i.host))return!1}r=r.parentElement,n++}return!!ch[t]}function Eh(e){return"composedPath"in e?e.composedPath():[]}function Nh(e){var t=Eh(e);return t&&t.length>0?t[0]:e.target||e.srcElement}function Ah(){this.clicks=[]}function Ph(e,t){this.changeCallback=e||function(){},this.observerConfig=t,this.observedShadowRoots=null,this.shadowObservers=[]}Ah.prototype.isRageClick=function(e,t){var r=(t=t||{}).threshold_px||30,n=t.timeout_ms||1e3,i=t.click_count||4;if(t.interactive_elements_only||false){var o=Nh(e);if(!o||Ih(o))return!1}var s=Date.now(),a=e.pageX,c=e.pageY,l=this.clicks[this.clicks.length-1];if(l&&s-l.timestamp<n&&Math.sqrt(Math.pow(a-l.x,2)+Math.pow(c-l.y,2))<r){if(this.clicks.push({x:a,y:c,timestamp:s}),this.clicks.length>=i)return this.clicks=[],!0}else this.clicks=[{x:a,y:c,timestamp:s}];return!1},Ph.prototype.getEventTarget=function(e){if(this.observedShadowRoots)return Nh(e)},Ph.prototype.observeFromEvent=function(e){if(this.observedShadowRoots)for(var t=Eh(e),r=0;r<t.length;r++){var n=t[r];n&&n.shadowRoot&&this.observeShadowRoot(n.shadowRoot)}},Ph.prototype.observeShadowRoot=function(e){if(this.observedShadowRoots&&!this.observedShadowRoots.has(e)){var t=this;try{this.observedShadowRoots.add(e);var r=new window.MutationObserver(function(){t.changeCallback()});r.observe(e,this.observerConfig),this.shadowObservers.push(r)}catch(n){uh.critical("Error while observing shadow root",n)}}},Ph.prototype.start=function(){this.observedShadowRoots||("undefined"!=typeof WeakSet?this.observedShadowRoots=new WeakSet:uh.critical("Shadow DOM observation unavailable: WeakSet not supported"))},Ph.prototype.stop=function(){if(this.observedShadowRoots){for(var e=0;e<this.shadowObservers.length;e++)try{this.shadowObservers[e].disconnect()}catch(t){uh.critical("Error while disconnecting shadow DOM observer",t)}this.shadowObservers=[],this.observedShadowRoots=null}};var Oh=[Wd,"input",Qd,"select","toggle"],Mh=[Jd],Th=[Hd],Rh={characterData:!0,childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","hidden","checked","selected","value","display","visibility"]};function jh(e){this.eventListeners=[],this.mutationObserver=null,this.shadowDOMObserver=null,this.isTracking=!1,this.lastChangeEventTimestamp=0,this.pendingClicks=[],this.onDeadClickCallback=e,this.processingActive=!1,this.processingTimeout=null}jh.prototype.addClick=function(e){var t=this.shadowDOMObserver&&this.shadowDOMObserver.getEventTarget(e);return t||(t=e.target||e.srcElement),!(!t||Ih(t))&&(this.shadowDOMObserver&&this.shadowDOMObserver.observeFromEvent(e),this.pendingClicks.push({element:t,event:e,timestamp:Date.now()}),!0)},jh.prototype.trackClick=function(e,t){if(!this.isTracking)return!1;var r=this.addClick(e);return r&&this.triggerProcessing(t),r},jh.prototype.getDeadClicks=function(e){if(0===this.pendingClicks.length)return[];var t=e.timeout_ms,r=Date.now(),n=this.pendingClicks.slice();this.pendingClicks=[];for(var i=[],o=0;o<n.length;o++){var s=n[o];r-s.timestamp>=t?this.hasChangesAfter(s.timestamp)||i.push(s):this.pendingClicks.push(s)}return i},jh.prototype.hasChangesAfter=function(e){return this.lastChangeEventTimestamp>=e-100},jh.prototype.recordChangeEvent=function(){this.lastChangeEventTimestamp=Date.now()},jh.prototype.triggerProcessing=function(e){this.processingActive||(this.processingActive=!0,this.processRecursively(e))},jh.prototype.processRecursively=function(e){if(this.isTracking&&this.onDeadClickCallback){var t=e.timeout_ms,r=this;this.processingTimeout=setTimeout(function(){if(r.processingActive){for(var t=r.getDeadClicks(e),n=0;n<t.length;n++)r.onDeadClickCallback(t[n].event);r.pendingClicks.length>0?r.processRecursively(e):r.processingActive=!1}},t)}else this.processingActive=!1},jh.prototype.startTracking=function(){if(!this.isTracking){this.isTracking=!0;var e=this;Oh.forEach(function(t){var r=function(){e.recordChangeEvent()};document.addEventListener(t,r,{capture:!0,passive:!0}),e.eventListeners.push({target:document,event:t,handler:r,options:{capture:!0,passive:!0}})}),Th.forEach(function(t){var r=function(){e.recordChangeEvent()};window.addEventListener(t,r),e.eventListeners.push({target:window,event:t,handler:r})}),Mh.forEach(function(t){var r=function(){e.recordChangeEvent()};window.addEventListener(t,r,{passive:!0}),e.eventListeners.push({target:window,event:t,handler:r,options:{passive:!0}})});var t=function(){e.recordChangeEvent()};if(document.addEventListener("selectionchange",t),e.eventListeners.push({target:document,event:"selectionchange",handler:t}),window.MutationObserver)try{this.mutationObserver=new window.MutationObserver(function(){e.recordChangeEvent()}),this.mutationObserver.observe(document.body||document.documentElement,Rh)}catch(r){uh.critical("Error while setting up mutation observer",r)}if(window.customElements)try{this.shadowDOMObserver=new Ph(function(){e.recordChangeEvent()},Rh),this.shadowDOMObserver.start()}catch(r){uh.critical("Error while setting up shadow DOM observer",r),this.shadowDOMObserver=null}}},jh.prototype.stopTracking=function(){if(this.isTracking){this.isTracking=!1,this.pendingClicks=[],this.lastChangeEventTimestamp=0,this.processingActive=!1,this.processingTimeout&&(clearTimeout(this.processingTimeout),this.processingTimeout=null);for(var e=0;e<this.eventListeners.length;e++){var t=this.eventListeners[e];try{t.target.removeEventListener(t.event,t.handler,t.options)}catch(r){uh.critical("Error while removing event listener",r)}}if(this.eventListeners=[],this.mutationObserver){try{this.mutationObserver.disconnect()}catch(r){uh.critical("Error while disconnecting mutation observer",r)}this.mutationObserver=null}if(this.shadowDOMObserver){try{this.shadowDOMObserver.stop()}catch(r){uh.critical("Error while stopping shadow DOM observer",r)}this.shadowDOMObserver=null}}};var Dh="autocapture",Fh="full-url",Lh="allow_selectors",Uh="allow_url_regexes",Bh="block_attrs",zh="block_element_callback",qh="block_selectors",$h="block_url_regexes",Gh="capture_extra_attrs",Wh="capture_text_content",Vh="scroll_capture_all",Hh="scroll_depth_percent_checkpoints",Yh="click",Zh="dead_click",Kh="input",Jh="pageview",Xh="rage_click",Qh="scroll",ep="page_leave",tp="submit",rp={};rp[Lh]=[],rp[Uh]=[],rp[Bh]=[],rp[zh]=null,rp[qh]=[],rp[$h]=[],rp[Gh]=[],rp[Wh]=!1,rp[Vh]=!1,rp[Hh]=[25,50,75,100],rp[Yh]=!0,rp[Zh]=!0,rp[Kh]=!0,rp[Jh]=Fh,rp[Xh]=!0,rp[Qh]=!0,rp[ep]=!1,rp[tp]=!0;var np={$mp_autocapture:!0},ip="$mp_click",op="$mp_dead_click",sp="$mp_rage_click",ap=function(e){this.mp=e,this.maxScrollViewDepth=0,this.hasTrackedScrollSession=!1,this.previousScrollHeight=0};ap.prototype.init=function(){!function(){try{return!!Mu.createElement("div").matches}catch(Hy){return!1}}()?uh.critical("Autocapture unavailable: missing required DOM APIs"):(this.initPageListeners(),this.initPageviewTracking(),this.initClickTracking(),this.initDeadClickTracking(),this.initInputTracking(),this.initScrollTracking(),this.initSubmitTracking(),this.initRageClickTracking(),this.initPageLeaveTracking())},ap.prototype.getFullConfig=function(){var e=this.mp.get_config(Dh);return e?qu.isObject(e)?qu.extend({},rp,e):rp:{}},ap.prototype.getConfig=function(e){return this.getFullConfig()[e]},ap.prototype.currentUrlBlocked=function(){var e,t=qu.info.currentUrl(),r=this.getConfig(Uh)||[];if(r.length){var n=!1;for(e=0;e<r.length;e++){var i=r[e];try{if(t.match(i)){n=!0;break}}catch(Hy){return uh.critical("Error while checking block URL regex: "+i,Hy),!0}}if(!n)return!0}var o=this.getConfig($h)||[];if(!o||!o.length)return!1;for(e=0;e<o.length;e++)try{if(t.match(o[e]))return!0}catch(Hy){return uh.critical("Error while checking block URL regex: "+o[e],Hy),!0}return!1},ap.prototype.pageviewTrackingConfig=function(){return this.mp.get_config(Dh)?this.getConfig(Jh):this.mp.get_config("track_pageview")},ap.prototype.trackDomEvent=function(e,t){if(!this.currentUrlBlocked()){var r=this.mp.is_recording_heatmap_data()&&(t===ip&&!this.getConfig(Yh)||t===sp&&!this._getClickTrackingConfig(Xh)||t===op&&!this._getClickTrackingConfig(Zh)),n=mh(e,{allowElementCallback:this.getConfig("allow_element_callback"),allowSelectors:this.getConfig(Lh),blockAttrs:this.getConfig(Bh),blockElementCallback:this.getConfig(zh),blockSelectors:this.getConfig(qh),captureExtraAttrs:this.getConfig(Gh),captureTextContent:this.getConfig(Wh),capturedForHeatMap:r});n&&(qu.extend(n,np),this.mp.track(t,n))}},ap.prototype.initPageListeners=function(){if(p.removeEventListener(Kd,this.listenerPopstate),p.removeEventListener(Hd,this.listenerHashchange),this.pageviewTrackingConfig()||this.getConfig(ep)||this.mp.get_config("record_heatmap_data")){this.listenerPopstate=function(){p.dispatchEvent(new Event(Zd))},this.listenerHashchange=function(){p.dispatchEvent(new Event(Zd))},p.addEventListener(Kd,this.listenerPopstate),p.addEventListener(Hd,this.listenerHashchange);var e=p.history.pushState;"function"==typeof e&&(p.history.pushState=function(t,r,n){e.call(p.history,t,r,n),p.dispatchEvent(new Event(Zd))});var t=p.history.replaceState;"function"==typeof t&&(p.history.replaceState=function(e,r,n){t.call(p.history,e,r,n),p.dispatchEvent(new Event(Zd))})}},ap.prototype._getClickTrackingConfig=function(e){var t=this.getConfig(e);return t?!0===t?{}:"object"==typeof t?t:{}:null},ap.prototype._trackPageLeave=function(e,t,r){if(!this.hasTrackedScrollSession&&(this.getConfig(ep)||this.mp.is_recording_heatmap_data())){this.hasTrackedScrollSession=!0;var n=Math.max(Mu.documentElement.clientHeight,p.innerHeight||0),i=Math.round(Math.max(this.maxScrollViewDepth-n,0)/(r-n)*100),o=Math.round(n/r*100);r<=n&&(i=100,o=100);var s=qu.extend({$max_scroll_view_depth:this.maxScrollViewDepth,$max_scroll_percentage:i,$fold_line_percentage:o,$scroll_height:r,$event_type:e.type,$current_url:t||qu.info.currentUrl(),$viewportHeight:n,$viewportWidth:Math.max(Mu.documentElement.clientWidth,p.innerWidth||0),$captured_for_heatmap:this.mp.is_recording_heatmap_data()},np);this.mp.track("$mp_page_leave",s,{transport:"sendBeacon"})}},ap.prototype._initScrollDepthTracking=function(){if(p.removeEventListener(Xd,this.listenerScrollDepth),p.removeEventListener(Jd,this.listenerScrollDepth),this.mp.get_config("record_heatmap_data")){uh.log("Initializing scroll depth tracking"),this.maxScrollViewDepth=Math.max(Mu.documentElement.clientHeight,p.innerHeight||0);var e=Sh(function(){if(!this.currentUrlBlocked()){var e=Math.max(Mu.documentElement.clientHeight,p.innerHeight||0)+p.scrollY;e>this.maxScrollViewDepth&&(this.maxScrollViewDepth=e),this.previousScrollHeight=Mu.body.scrollHeight}}.bind(this));this.listenerScrollDepth=e.listener,p.addEventListener(e.eventType,this.listenerScrollDepth)}},ap.prototype.initClickTracking=function(){p.removeEventListener(Vd,this.listenerClick),(this.getConfig(Yh)||this.mp.get_config("record_heatmap_data"))&&(uh.log("Initializing click tracking"),this.listenerClick=function(e){(this.getConfig(Yh)||this.mp.is_recording_heatmap_data())&&this.trackDomEvent(e,ip)}.bind(this),p.addEventListener(Vd,this.listenerClick))},ap.prototype.initDeadClickTracking=function(){this._getClickTrackingConfig(Zh)||this.mp.get_config("record_heatmap_data")?(uh.log("Initializing dead click tracking"),this._deadClickTracker||(this._deadClickTracker=new jh(function(e){this.trackDomEvent(e,op)}.bind(this)),this._deadClickTracker.startTracking()),this.listenerDeadClick||(this.listenerDeadClick=function(e){var t=this._getClickTrackingConfig(Zh);if((t||this.mp.is_recording_heatmap_data())&&!this.currentUrlBlocked()){var r=t||{};r.timeout_ms||(r.timeout_ms=500),this._deadClickTracker.trackClick(e,r)}}.bind(this),p.addEventListener(Vd,this.listenerDeadClick))):this.stopDeadClickTracking()},ap.prototype.initInputTracking=function(){p.removeEventListener(Wd,this.listenerChange),this.getConfig(Kh)&&(uh.log("Initializing input tracking"),this.listenerChange=function(e){this.getConfig(Kh)&&this.trackDomEvent(e,"$mp_input_change")}.bind(this),p.addEventListener(Wd,this.listenerChange))},ap.prototype.initPageviewTracking=function(){if(p.removeEventListener(Zd,this.listenerLocationchange),this.pageviewTrackingConfig()){uh.log("Initializing pageview tracking");var e="",t=!1;this.currentUrlBlocked()||(t=this.mp.track_pageview(np)),t&&(e=qu.info.currentUrl()),this.listenerLocationchange=Vu(function(){if(!this.currentUrlBlocked()){var t=qu.info.currentUrl(),r=!1,n=t.split("#")[0].split("?")[0]!==e.split("#")[0].split("?")[0],i=this.pageviewTrackingConfig();if(i===Fh?r=t!==e:"url-with-path-and-query-string"===i?r=t.split("#")[0]!==e.split("#")[0]:"url-with-path"===i&&(r=n),r)this.mp.track_pageview(np)&&(e=t),n&&(this.lastScrollCheckpoint=0,uh.log("Path change: re-initializing scroll depth checkpoints"))}}.bind(this)),p.addEventListener(Zd,this.listenerLocationchange)}},ap.prototype.initRageClickTracking=function(){p.removeEventListener(Vd,this.listenerRageClick),(this._getClickTrackingConfig(Xh)||this.mp.get_config("record_heatmap_data"))&&(uh.log("Initializing rage click tracking"),this._rageClickTracker||(this._rageClickTracker=new Ah),this.listenerRageClick=function(e){var t=this._getClickTrackingConfig(Xh);(t||this.mp.is_recording_heatmap_data())&&(this.currentUrlBlocked()||this._rageClickTracker.isRageClick(e,t)&&this.trackDomEvent(e,sp))}.bind(this),p.addEventListener(Vd,this.listenerRageClick))},ap.prototype.initScrollTracking=function(){if(p.removeEventListener(Jd,this.listenerScroll),p.removeEventListener(Xd,this.listenerScroll),this.getConfig(Qh)){uh.log("Initializing scroll tracking"),this.lastScrollCheckpoint=0;var e=Sh(function(){if(this.getConfig(Qh)&&!this.currentUrlBlocked()){var e=this.getConfig(Vh),t=(this.getConfig(Hh)||[]).slice().sort(function(e,t){return e-t}),r=p.scrollY,n=qu.extend({$scroll_top:r},np);try{var i=Mu.body.scrollHeight,o=Math.round(r/(i-p.innerHeight)*100);if(n.$scroll_height=i,n.$scroll_percentage=o,o>this.lastScrollCheckpoint)for(var s=0;s<t.length;s++){var a=t[s];o>=a&&this.lastScrollCheckpoint<a&&(n.$scroll_checkpoint=a,this.lastScrollCheckpoint=a,e=!0)}}catch(Hy){uh.critical("Error while calculating scroll percentage",Hy)}e&&this.mp.track("$mp_scroll",n)}}.bind(this));this.listenerScroll=e.listener,p.addEventListener(e.eventType,this.listenerScroll)}},ap.prototype.initSubmitTracking=function(){p.removeEventListener(Qd,this.listenerSubmit),this.getConfig(tp)&&(uh.log("Initializing submit tracking"),this.listenerSubmit=function(e){this.getConfig(tp)&&this.trackDomEvent(e,"$mp_submit")}.bind(this),p.addEventListener(Qd,this.listenerSubmit))},ap.prototype.initPageLeaveTracking=function(){if(Mu.removeEventListener(eh,this.listenerPageLeaveVisibilitychange),p.removeEventListener(Zd,this.listenerPageLeaveLocationchange),p.removeEventListener(Yd,this.listenerPageLoad),this.getConfig(ep)||this.mp.get_config("record_heatmap_data")){uh.log("Initializing page visibility tracking."),this._initScrollDepthTracking();var e=qu.info.currentUrl();this.listenerPageLoad=function(){this.previousScrollHeight=Mu.body.scrollHeight}.bind(this),p.addEventListener(Yd,this.listenerPageLoad),this.listenerPageLeaveLocationchange=Vu(function(t){if(!this.currentUrlBlocked()){var r=qu.info.currentUrl();r!==e&&(this._trackPageLeave(t,e,this.previousScrollHeight),e=r,this.maxScrollViewDepth=Math.max(Mu.documentElement.clientHeight,p.innerHeight||0),this.previousScrollHeight=Mu.body.scrollHeight,this.hasTrackedScrollSession=!1)}}.bind(this)),p.addEventListener(Zd,this.listenerPageLeaveLocationchange),this.listenerPageLeaveVisibilitychange=function(t){Mu.hidden&&this._trackPageLeave(t,e,this.previousScrollHeight)}.bind(this),Mu.addEventListener(eh,this.listenerPageLeaveVisibilitychange)}},ap.prototype.stopDeadClickTracking=function(){this.listenerDeadClick&&(p.removeEventListener(Vd,this.listenerDeadClick),this.listenerDeadClick=null),this._deadClickTracker&&(this._deadClickTracker.stopTracking(),this._deadClickTracker=null)},Hu(ap);var cp=Wu("flags"),lp="flags",up="context",dp={};dp[up]={};var hp=function(e){this.fetch=p.fetch,this.getFullApiRoute=e.getFullApiRoute,this.getMpConfig=e.getConfigFunc,this.setMpConfig=e.setConfigFunc,this.getMpProperty=e.getPropertyFunc,this.track=e.trackingFunc};hp.prototype.init=function(){this.minApisSupported()?(this.flags=null,this.fetchFlags(),this.trackedFeatures=new Set):cp.critical("Feature Flags unavailable: missing minimum required APIs")},hp.prototype.getFullConfig=function(){var e=this.getMpConfig(lp);return e?qu.isObject(e)?qu.extend({},dp,e):dp:{}},hp.prototype.getConfig=function(e){return this.getFullConfig()[e]},hp.prototype.isSystemEnabled=function(){return!!this.getMpConfig(lp)},hp.prototype.updateContext=function(e,t){if(!this.isSystemEnabled())return cp.critical("Feature Flags not enabled, cannot update context"),Promise.resolve();var r=this.getMpConfig(lp);qu.isObject(r)||(r={});var n=t&&t.replace?{}:this.getConfig(up);return r[up]=qu.extend({},n,e),this.setMpConfig(lp,r),this.fetchFlags()},hp.prototype.areFlagsReady=function(){return this.isSystemEnabled()||cp.error("Feature Flags not enabled"),!!this.flags},hp.prototype.fetchFlags=function(){if(!this.isSystemEnabled())return Promise.resolve();var e=this.getMpProperty("distinct_id"),t=this.getMpProperty("$device_id"),r="00-"+qu.UUID().replace(/-/g,"")+"-"+qu.UUID().replace(/-/g,"").substring(0,16)+"-01";cp.log("Fetching flags for distinct ID: "+e);var n=qu.extend({distinct_id:e,device_id:t},this.getConfig(up)),i=new URLSearchParams;i.set("context",JSON.stringify(n)),i.set("token",this.getMpConfig("token")),i.set("mp_lib","web"),i.set("$lib_version",xu.LIB_VERSION);var o=this.getFullApiRoute()+"?"+i.toString();return this._fetchInProgressStartTime=Date.now(),this.fetchPromise=this.fetch.call(p,o,{method:"GET",headers:{Authorization:"Basic "+btoa(this.getMpConfig("token")+":"),traceparent:r}}).then(function(e){return this.markFetchComplete(),e.json().then(function(e){var t=e.flags;if(!t)throw new Error("No flags in API response");var n=new Map;qu.each(t,function(e,t){n.set(t,{key:e.variant_key,value:e.variant_value,experiment_id:e.experiment_id,is_experiment_active:e.is_experiment_active,is_qa_tester:e.is_qa_tester})}),this.flags=n,this._traceparent=r}.bind(this)).catch(function(e){this.markFetchComplete(),cp.error(e)}.bind(this))}.bind(this)).catch(function(e){this.markFetchComplete(),cp.error(e)}.bind(this)),this.fetchPromise},hp.prototype.markFetchComplete=function(){this._fetchInProgressStartTime?(this._fetchStartTime=this._fetchInProgressStartTime,this._fetchCompleteTime=Date.now(),this._fetchLatency=this._fetchCompleteTime-this._fetchStartTime,this._fetchInProgressStartTime=null):cp.error("Fetch in progress started time not set, cannot mark fetch complete")},hp.prototype.getVariant=function(e,t){return this.fetchPromise?this.fetchPromise.then(function(){return this.getVariantSync(e,t)}.bind(this)).catch(function(e){return cp.error(e),t}):new Promise(function(e){cp.critical("Feature Flags not initialized"),e(t)})},hp.prototype.getVariantSync=function(e,t){if(!this.areFlagsReady())return cp.log("Flags not loaded yet"),t;var r=this.flags.get(e);return r?(this.trackFeatureCheck(e,r),r):(cp.log('No flag found: "'+e+'"'),t)},hp.prototype.getVariantValue=function(e,t){return this.getVariant(e,{value:t}).then(function(e){return e.value}).catch(function(e){return cp.error(e),t})},hp.prototype.getFeatureData=function(e,t){return cp.critical("mixpanel.flags.get_feature_data() is deprecated and will be removed in a future release. Use mixpanel.flags.get_variant_value() instead."),this.getVariantValue(e,t)},hp.prototype.getVariantValueSync=function(e,t){return this.getVariantSync(e,{value:t}).value},hp.prototype.isEnabled=function(e,t){return this.getVariantValue(e).then(function(){return this.isEnabledSync(e,t)}.bind(this)).catch(function(e){return cp.error(e),t})},hp.prototype.isEnabledSync=function(e,t){t=t||!1;var r=this.getVariantValueSync(e,t);return!0!==r&&!1!==r&&(cp.error('Feature flag "'+e+'" value: '+r+" is not a boolean; returning fallback value: "+t),r=t),r},hp.prototype.trackFeatureCheck=function(e,t){if(!this.trackedFeatures.has(e)){this.trackedFeatures.add(e);var r={"Experiment name":e,"Variant name":t.key,$experiment_type:"feature_flag","Variant fetch start time":new Date(this._fetchStartTime).toISOString(),"Variant fetch complete time":new Date(this._fetchCompleteTime).toISOString(),"Variant fetch latency (ms)":this._fetchLatency,"Variant fetch traceparent":this._traceparent};"undefined"!==t.experiment_id&&(r.$experiment_id=t.experiment_id),"undefined"!==t.is_experiment_active&&(r.$is_experiment_active=t.is_experiment_active),"undefined"!==t.is_qa_tester&&(r.$is_qa_tester=t.is_qa_tester),this.track("$experiment_started",r)}},hp.prototype.minApisSupported=function(){return!!this.fetch&&"undefined"!=typeof Promise&&"undefined"!=typeof Map&&"undefined"!=typeof Set},Hu(hp),hp.prototype.are_flags_ready=hp.prototype.areFlagsReady,hp.prototype.get_variant=hp.prototype.getVariant,hp.prototype.get_variant_sync=hp.prototype.getVariantSync,hp.prototype.get_variant_value=hp.prototype.getVariantValue,hp.prototype.get_variant_value_sync=hp.prototype.getVariantValueSync,hp.prototype.is_enabled=hp.prototype.isEnabled,hp.prototype.is_enabled_sync=hp.prototype.isEnabledSync,hp.prototype.update_context=hp.prototype.updateContext,hp.prototype.get_feature_data=hp.prototype.getFeatureData;var pp=function(){};pp.prototype.create_properties=function(){},pp.prototype.event_handler=function(){},pp.prototype.after_track_handler=function(){},pp.prototype.init=function(e){return this.mp=e,this},pp.prototype.track=function(e,t,r,n){var i=this,o=qu.dom_query(e);if(0!==o.length)return qu.each(o,function(e){qu.register_event(e,this.override_event,function(e){var o={},s=i.create_properties(r,this),a=i.mp.get_config("track_links_timeout");i.event_handler(e,this,o),window.setTimeout(i.track_callback(n,s,o,!0),a),i.mp.track(t,s,i.track_callback(n,s,o))})},this),!0;$u.error("The DOM query ("+e+") returned 0 elements")},pp.prototype.track_callback=function(e,t,r,n){n=n||!1;var i=this;return function(){r.callback_fired||(r.callback_fired=!0,e&&!1===e(n,t)||i.after_track_handler(t,r,n))}},pp.prototype.create_properties=function(e,t){return"function"==typeof e?e(t):qu.extend({},e)};var fp=function(){this.override_event="click"};qu.inherit(fp,pp),fp.prototype.create_properties=function(e,t){var r=fp.superclass.create_properties.apply(this,arguments);return t.href&&(r.url=t.href),r},fp.prototype.event_handler=function(e,t,r){r.new_tab=2===e.which||e.metaKey||e.ctrlKey||"_blank"===t.target,r.href=t.href,r.new_tab||e.preventDefault()},fp.prototype.after_track_handler=function(e,t){t.new_tab||setTimeout(function(){window.location=t.href},0)};var mp=function(){this.override_event="submit"};qu.inherit(mp,pp),mp.prototype.event_handler=function(e,t,r){r.element=t,e.preventDefault()},mp.prototype.after_track_handler=function(e,t){setTimeout(function(){t.element.submit()},0)};var gp="$set",yp="$set_once",vp="$unset",bp="$add",wp="$append",xp="$union",_p="$remove",kp={set_action:function(e,t){var r={},n={};return qu.isObject(e)?qu.each(e,function(e,t){this._is_reserved_property(t)||(n[t]=e)},this):n[e]=t,r[gp]=n,r},unset_action:function(e){var t={},r=[];return qu.isArray(e)||(e=[e]),qu.each(e,function(e){this._is_reserved_property(e)||r.push(e)},this),t[vp]=r,t},set_once_action:function(e,t){var r={},n={};return qu.isObject(e)?qu.each(e,function(e,t){this._is_reserved_property(t)||(n[t]=e)},this):n[e]=t,r[yp]=n,r},union_action:function(e,t){var r={},n={};return qu.isObject(e)?qu.each(e,function(e,t){this._is_reserved_property(t)||(n[t]=qu.isArray(e)?e:[e])},this):n[e]=qu.isArray(t)?t:[t],r[xp]=n,r},append_action:function(e,t){var r={},n={};return qu.isObject(e)?qu.each(e,function(e,t){this._is_reserved_property(t)||(n[t]=e)},this):n[e]=t,r[wp]=n,r},remove_action:function(e,t){var r={},n={};return qu.isObject(e)?qu.each(e,function(e,t){this._is_reserved_property(t)||(n[t]=e)},this):n[e]=t,r[_p]=n,r},delete_action:function(){var e={$delete:""};return e}},Sp=function(){};qu.extend(Sp.prototype,kp),Sp.prototype._init=function(e,t,r){this._mixpanel=e,this._group_key=t,this._group_id=r},Sp.prototype.set=wd(function(e,t,r){var n=this.set_action(e,t);return qu.isObject(e)&&(r=t),this._send_request(n,r)}),Sp.prototype.set_once=wd(function(e,t,r){var n=this.set_once_action(e,t);return qu.isObject(e)&&(r=t),this._send_request(n,r)}),Sp.prototype.unset=wd(function(e,t){var r=this.unset_action(e);return this._send_request(r,t)}),Sp.prototype.union=wd(function(e,t,r){qu.isObject(e)&&(r=t);var n=this.union_action(e,t);return this._send_request(n,r)}),Sp.prototype.delete=wd(function(e){var t=this.delete_action();return this._send_request(t,e)}),Sp.prototype.remove=wd(function(e,t,r){var n=this.remove_action(e,t);return this._send_request(n,r)}),Sp.prototype._send_request=function(e,t){e.$group_key=this._group_key,e.$group_id=this._group_id,e.$token=this._get_config("token");var r=qu.encodeDates(e);return this._mixpanel._track_or_batch({type:"groups",data:r,endpoint:this._mixpanel.get_api_host("groups")+"/"+this._get_config("api_routes").groups,batcher:this._mixpanel.request_batchers.groups},t)},Sp.prototype._is_reserved_property=function(e){return"$group_key"===e||"$group_id"===e},Sp.prototype._get_config=function(e){return this._mixpanel.get_config(e)},Sp.prototype.toString=function(){return this._mixpanel.toString()+".group."+this._group_key+"."+this._group_id},Sp.prototype.remove=Sp.prototype.remove,Sp.prototype.set=Sp.prototype.set,Sp.prototype.set_once=Sp.prototype.set_once,Sp.prototype.union=Sp.prototype.union,Sp.prototype.unset=Sp.prototype.unset,Sp.prototype.toString=Sp.prototype.toString;var Cp=function(){};qu.extend(Cp.prototype,kp),Cp.prototype._init=function(e){this._mixpanel=e},Cp.prototype.set=bd(function(e,t,r){var n=this.set_action(e,t);return qu.isObject(e)&&(r=t),this._get_config("save_referrer")&&this._mixpanel.persistence.update_referrer_info(document.referrer),n[gp]=qu.extend({},qu.info.people_properties(),n[gp]),this._send_request(n,r)}),Cp.prototype.set_once=bd(function(e,t,r){var n=this.set_once_action(e,t);return qu.isObject(e)&&(r=t),this._send_request(n,r)}),Cp.prototype.unset=bd(function(e,t){var r=this.unset_action(e);return this._send_request(r,t)}),Cp.prototype.increment=bd(function(e,t,r){var n={},i={};return qu.isObject(e)?(qu.each(e,function(e,t){if(!this._is_reserved_property(t)){if(isNaN(parseFloat(e)))return void $u.error("Invalid increment value passed to mixpanel.people.increment - must be a number");i[t]=e}},this),r=t):(qu.isUndefined(t)&&(t=1),i[e]=t),n[bp]=i,this._send_request(n,r)}),Cp.prototype.append=bd(function(e,t,r){qu.isObject(e)&&(r=t);var n=this.append_action(e,t);return this._send_request(n,r)}),Cp.prototype.remove=bd(function(e,t,r){qu.isObject(e)&&(r=t);var n=this.remove_action(e,t);return this._send_request(n,r)}),Cp.prototype.union=bd(function(e,t,r){qu.isObject(e)&&(r=t);var n=this.union_action(e,t);return this._send_request(n,r)}),Cp.prototype.track_charge=bd(function(){$u.error("mixpanel.people.track_charge() is deprecated and no longer has any effect.")}),Cp.prototype.clear_charges=function(e){return this.set("$transactions",[],e)},Cp.prototype.delete_user=function(){if(this._identify_called()){var e={$delete:this._mixpanel.get_distinct_id()};return this._send_request(e)}$u.error("mixpanel.people.delete_user() requires you to call identify() first")},Cp.prototype.toString=function(){return this._mixpanel.toString()+".people"},Cp.prototype._send_request=function(e,t){e.$token=this._get_config("token"),e.$distinct_id=this._mixpanel.get_distinct_id();var r=this._mixpanel.get_property("$device_id"),n=this._mixpanel.get_property("$user_id"),i=this._mixpanel.get_property("$had_persisted_distinct_id");r&&(e.$device_id=r),n&&(e.$user_id=n),i&&(e.$had_persisted_distinct_id=i);var o=qu.encodeDates(e);return this._identify_called()?this._mixpanel._track_or_batch({type:"people",data:o,endpoint:this._mixpanel.get_api_host("people")+"/"+this._get_config("api_routes").engage,batcher:this._mixpanel.request_batchers.people},t):(this._enqueue(e),qu.isUndefined(t)||(this._get_config("verbose")?t({status:-1,error:null}):t(-1)),qu.truncate(o,255))},Cp.prototype._get_config=function(e){return this._mixpanel.get_config(e)},Cp.prototype._identify_called=function(){return!0===this._mixpanel._flags.identify_called},Cp.prototype._enqueue=function(e){gp in e?this._mixpanel.persistence._add_to_people_queue(gp,e):yp in e?this._mixpanel.persistence._add_to_people_queue(yp,e):vp in e?this._mixpanel.persistence._add_to_people_queue(vp,e):bp in e?this._mixpanel.persistence._add_to_people_queue(bp,e):wp in e?this._mixpanel.persistence._add_to_people_queue(wp,e):_p in e?this._mixpanel.persistence._add_to_people_queue(_p,e):xp in e?this._mixpanel.persistence._add_to_people_queue(xp,e):$u.error("Invalid call to _enqueue():",e)},Cp.prototype._flush_one_queue=function(e,t,r,n){var i=this,o=qu.extend({},this._mixpanel.persistence.load_queue(e)),s=o;qu.isUndefined(o)||!qu.isObject(o)||qu.isEmptyObject(o)||(i._mixpanel.persistence._pop_from_people_queue(e,o),i._mixpanel.persistence.save(),n&&(s=n(o)),t.call(i,s,function(t,n){0===t&&i._mixpanel.persistence._add_to_people_queue(e,o),qu.isUndefined(r)||r(t,n)}))},Cp.prototype._flush=function(e,t,r,n,i,o,s){var a=this;this._flush_one_queue(gp,this.set,e),this._flush_one_queue(yp,this.set_once,n),this._flush_one_queue(vp,this.unset,o,function(e){return qu.keys(e)}),this._flush_one_queue(bp,this.increment,t),this._flush_one_queue(xp,this.union,i);var c=this._mixpanel.persistence.load_queue(wp);if(!qu.isUndefined(c)&&qu.isArray(c)&&c.length)for(var l,u=function(e,t){0===e&&a._mixpanel.persistence._add_to_people_queue(wp,l),qu.isUndefined(r)||r(e,t)},d=c.length-1;d>=0;d--)c=this._mixpanel.persistence.load_queue(wp),l=c.pop(),a._mixpanel.persistence.save(),qu.isEmptyObject(l)||a.append(l,u);var h=this._mixpanel.persistence.load_queue(_p);if(!qu.isUndefined(h)&&qu.isArray(h)&&h.length)for(var p,f=function(e,t){0===e&&a._mixpanel.persistence._add_to_people_queue(_p,p),qu.isUndefined(s)||s(e,t)},m=h.length-1;m>=0;m--)h=this._mixpanel.persistence.load_queue(_p),p=h.pop(),a._mixpanel.persistence.save(),qu.isEmptyObject(p)||a.remove(p,f)},Cp.prototype._is_reserved_property=function(e){return"$distinct_id"===e||"$token"===e||"$device_id"===e||"$user_id"===e||"$had_persisted_distinct_id"===e},Cp.prototype.set=Cp.prototype.set,Cp.prototype.set_once=Cp.prototype.set_once,Cp.prototype.unset=Cp.prototype.unset,Cp.prototype.increment=Cp.prototype.increment,Cp.prototype.append=Cp.prototype.append,Cp.prototype.remove=Cp.prototype.remove,Cp.prototype.union=Cp.prototype.union,Cp.prototype.track_charge=Cp.prototype.track_charge,Cp.prototype.clear_charges=Cp.prototype.clear_charges,Cp.prototype.delete_user=Cp.prototype.delete_user,Cp.prototype.toString=Cp.prototype.toString;var Ip,Ep="__mps",Np="__mpso",Ap="__mpus",Pp="__mpa",Op="__mpap",Mp="__mpr",Tp="__mpu",Rp="$people_distinct_id",jp="__alias",Dp="__timers",Fp=[Ep,Np,Ap,Pp,Op,Mp,Tp,Rp,jp,Dp],Lp=function(e){this.props={},this.campaign_params_saved=!1,e.persistence_name?this.name="mp_"+e.persistence_name:this.name="mp_"+e.token+"_mixpanel";var t=e.persistence;"cookie"!==t&&"localStorage"!==t&&($u.critical("Unknown persistence type "+t+"; falling back to cookie"),t=e.persistence="cookie"),"localStorage"===t&&qu.localStorage.is_supported()?this.storage=qu.localStorage:this.storage=qu.cookie,this.load(),this.update_config(e),this.upgrade(),this.save()};Lp.prototype.properties=function(){var e={};return this.load(),qu.each(this.props,function(t,r){qu.include(Fp,r)||(e[r]=t)}),e},Lp.prototype.load=function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=qu.extend({},e))}},Lp.prototype.upgrade=function(){var e,t;this.storage===qu.localStorage?(e=qu.cookie.parse(this.name),qu.cookie.remove(this.name),qu.cookie.remove(this.name,!0),e&&this.register_once(e)):this.storage===qu.cookie&&(t=qu.localStorage.parse(this.name),qu.localStorage.remove(this.name),t&&this.register_once(t))},Lp.prototype.save=function(){this.disabled||this.storage.set(this.name,cd(this.props),this.expire_days,this.cross_subdomain,this.secure,this.cross_site,this.cookie_domain)},Lp.prototype.load_prop=function(e){return this.load(),this.props[e]},Lp.prototype.remove=function(){this.storage.remove(this.name,!1,this.cookie_domain),this.storage.remove(this.name,!0,this.cookie_domain)},Lp.prototype.clear=function(){this.remove(),this.props={}},Lp.prototype.register_once=function(e,t,r){return!!qu.isObject(e)&&(void 0===t&&(t="None"),this.expire_days=void 0===r?this.default_expiry:r,this.load(),qu.each(e,function(e,r){this.props.hasOwnProperty(r)&&this.props[r]!==t||(this.props[r]=e)},this),this.save(),!0)},Lp.prototype.register=function(e,t){return!!qu.isObject(e)&&(this.expire_days=void 0===t?this.default_expiry:t,this.load(),qu.extend(this.props,e),this.save(),!0)},Lp.prototype.unregister=function(e){this.load(),e in this.props&&(delete this.props[e],this.save())},Lp.prototype.update_search_keyword=function(e){this.register(qu.info.searchInfo(e))},Lp.prototype.update_referrer_info=function(e){this.register_once({$initial_referrer:e||"$direct",$initial_referring_domain:qu.info.referringDomain(e)||"$direct"},"")},Lp.prototype.get_referrer_info=function(){return qu.strip_empty_properties({$initial_referrer:this.props.$initial_referrer,$initial_referring_domain:this.props.$initial_referring_domain})},Lp.prototype.update_config=function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cookie_domain(e.cookie_domain),this.set_cross_site(e.cross_site_cookie),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)},Lp.prototype.set_disabled=function(e){this.disabled=e,this.disabled?this.remove():this.save()},Lp.prototype.set_cookie_domain=function(e){e!==this.cookie_domain&&(this.remove(),this.cookie_domain=e,this.save())},Lp.prototype.set_cross_site=function(e){e!==this.cross_site&&(this.cross_site=e,this.remove(),this.save())},Lp.prototype.set_cross_subdomain=function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())},Lp.prototype.get_cross_subdomain=function(){return this.cross_subdomain},Lp.prototype.set_secure=function(e){e!==this.secure&&(this.secure=!!e,this.remove(),this.save())},Lp.prototype._add_to_people_queue=function(e,t){var r=this._get_queue_key(e),n=t[e],i=this._get_or_create_queue(gp),o=this._get_or_create_queue(yp),s=this._get_or_create_queue(vp),a=this._get_or_create_queue(bp),c=this._get_or_create_queue(xp),l=this._get_or_create_queue(_p,[]),u=this._get_or_create_queue(wp,[]);r===Ep?(qu.extend(i,n),this._pop_from_people_queue(bp,n),this._pop_from_people_queue(xp,n),this._pop_from_people_queue(vp,n)):r===Np?(qu.each(n,function(e,t){t in o||(o[t]=e)}),this._pop_from_people_queue(vp,n)):r===Ap?qu.each(n,function(e){qu.each([i,o,a,c],function(t){e in t&&delete t[e]}),qu.each(u,function(t){e in t&&delete t[e]}),s[e]=!0}):r===Pp?(qu.each(n,function(e,t){t in i?i[t]+=e:(t in a||(a[t]=0),a[t]+=e)},this),this._pop_from_people_queue(vp,n)):r===Tp?(qu.each(n,function(e,t){qu.isArray(e)&&(t in c||(c[t]=[]),qu.each(e,function(e){qu.include(c[t],e)||c[t].push(e)}))}),this._pop_from_people_queue(vp,n)):r===Mp?(l.push(n),this._pop_from_people_queue(wp,n)):r===Op&&(u.push(n),this._pop_from_people_queue(vp,n)),$u.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):"),$u.log(t),this.save()},Lp.prototype._pop_from_people_queue=function(e,t){var r=this.props[this._get_queue_key(e)];qu.isUndefined(r)||qu.each(t,function(t,n){e===wp||e===_p?qu.each(r,function(e){e[n]===t&&delete e[n]}):delete r[n]},this)},Lp.prototype.load_queue=function(e){return this.load_prop(this._get_queue_key(e))},Lp.prototype._get_queue_key=function(e){return e===gp?Ep:e===yp?Np:e===vp?Ap:e===bp?Pp:e===wp?Op:e===_p?Mp:e===xp?Tp:void $u.error("Invalid queue:",e)},Lp.prototype._get_or_create_queue=function(e,t){var r=this._get_queue_key(e);return t=qu.isUndefined(t)?{}:t,this.props[r]||(this.props[r]=t)},Lp.prototype.set_event_timer=function(e,t){var r=this.load_prop(Dp)||{};r[e]=t,this.props[Dp]=r,this.save()},Lp.prototype.remove_event_timer=function(e){var t=(this.load_prop(Dp)||{})[e];return qu.isUndefined(t)||(delete this.props[Dp][e],this.save()),t};var Up,Bp=function(e,t){throw new Error(e+" not available in this build.")},zp=function(e){return e},qp="mixpanel",$p="base64",Gp="$device:",Wp=p.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,Vp=!Wp&&-1===ju.indexOf("MSIE")&&-1===ju.indexOf("Mozilla"),Hp=null;Ou.sendBeacon&&(Hp=function(){return Ou.sendBeacon.apply(Ou,arguments)});var Yp={track:"track/",engage:"engage/",groups:"groups/",record:"record/",flags:"flags/"},Zp={api_host:"https://api-js.mixpanel.com",api_hosts:{},api_routes:Yp,api_extra_query_params:{},api_method:"POST",api_transport:"XHR",api_payload_format:$p,app_host:"https://mixpanel.com",autocapture:!1,cdn:"https://cdn.mxpnl.com",cross_site_cookie:!1,cross_subdomain_cookie:!0,error_reporter:ad,flags:!1,persistence:"cookie",persistence_name:"",cookie_domain:"",cookie_name:"",loaded:ad,mp_loader:null,track_marketing:!0,track_pageview:!1,skip_first_touch_marketing:!1,store_google:!0,stop_utm_persistence:!1,save_referrer:!0,test:!1,verbose:!1,img:!1,debug:!1,track_links_timeout:300,cookie_expiration:365,upgrade:!1,disable_persistence:!1,disable_cookie:!1,secure_cookie:!1,ip:!0,opt_out_tracking_by_default:!1,opt_out_persistence_by_default:!1,opt_out_tracking_persistence_type:"localStorage",opt_out_tracking_cookie_prefix:null,property_blacklist:[],xhr_headers:{},ignore_dnt:!1,batch_requests:!0,batch_size:50,batch_flush_interval_ms:5e3,batch_request_timeout_ms:9e4,batch_autostart:!0,hooks:{},record_block_class:new RegExp("^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$"),record_block_selector:"img, video, audio",record_canvas:!1,record_collect_fonts:!1,record_console:!0,record_heatmap_data:!1,record_idle_timeout_ms:18e5,record_mask_text_class:new RegExp("^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$"),record_mask_text_selector:"*",record_max_ms:_u,record_min_ms:0,record_sessions_percent:0,recorder_src:"https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"},Kp=!1,Jp=function(){},Xp=function(e,t,r){var n,i=r===qp?Up:Up[r];if(i&&0===Ip)n=i;else{if(i&&!qu.isArray(i))return void $u.error("You have already initialized "+r);n=new Jp}if(n._cached_groups={},n._init(e,t,r),n.people=new Cp,n.people._init(n),!n.get_config("skip_first_touch_marketing")){var o=qu.info.campaignParams(null),s={},a=!1;qu.each(o,function(e,t){s["initial_"+t]=e,e&&(a=!0)}),a&&n.people.set_once(s)}return xu.DEBUG=xu.DEBUG||n.get_config("debug"),!qu.isUndefined(i)&&qu.isArray(i)&&(n._execute_array.call(n.people,i.people),n._execute_array(i)),n};Jp.prototype.init=function(e,t,r){if(qu.isUndefined(r))this.report_error("You must name your new library: init(token, config, name)");else{if(r!==qp){var n=Xp(e,t,r);return Up[r]=n,n._loaded(),n}this.report_error("You must initialize the main mixpanel object right after you include the Mixpanel js snippet")}},Jp.prototype._init=function(e,t,r){t=t||{},this.__loaded=!0,this.config={};var n={};"api_payload_format"in t||(t.api_host||Zp.api_host).match(/\.mixpanel\.com/)&&(n.api_payload_format="json");if(this.set_config(qu.extend({},Zp,n,t,{name:r,token:e,callback_fn:(r===qp?r:qp+"."+r)+"._jsc"})),this._jsc=ad,this.__dom_loaded_queue=[],this.__request_queue=[],this.__disabled_events=[],this._flags={disable_all_events:!1,identify_called:!1},this.request_batchers={},this._batch_requests=this.get_config("batch_requests"),this._batch_requests)if(qu.localStorage.is_supported(!0)&&Wp){if(this.init_batchers(),Hp&&p.addEventListener){var i=qu.bind(function(){this.request_batchers.events.stopped||this.request_batchers.events.flush({unloading:!0})},this);p.addEventListener("pagehide",function(e){e.persisted&&i()}),p.addEventListener("visibilitychange",function(){"hidden"===Mu.visibilityState&&i()})}}else this._batch_requests=!1,$u.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support"),qu.each(this.get_batcher_configs(),function(e){$u.log("Clearing batch queue "+e.queue_key),qu.localStorage.remove(e.queue_key)});this.persistence=this.cookie=new Lp(this.config),this.unpersisted_superprops={},this._gdpr_init();var o=qu.UUID();this.get_distinct_id()||this.register_once({distinct_id:Gp+o,$device_id:o},""),this.flags=new hp({getFullApiRoute:qu.bind(function(){return this.get_api_host("flags")+"/"+this.get_config("api_routes").flags},this),getConfigFunc:qu.bind(this.get_config,this),setConfigFunc:qu.bind(this.set_config,this),getPropertyFunc:qu.bind(this.get_property,this),trackingFunc:qu.bind(this.track,this)}),this.flags.init(),this.flags=this.flags,this.autocapture=new ap(this),this.autocapture.init(),this._init_tab_id(),this._check_and_start_session_recording()},Jp.prototype._init_tab_id=function(){if(this.get_config("disable_persistence"))$u.log("Tab ID initialization skipped due to disable_persistence config");else if(qu.sessionStorage.is_supported())try{var e=this.get_config("name")+"_"+this.get_config("token"),t="mp_tab_id_"+e,r="mp_gen_new_tab_id_"+e;!qu.sessionStorage.get(r)&&qu.sessionStorage.get(t)||qu.sessionStorage.set(t,"$tab-"+qu.UUID()),qu.sessionStorage.set(r,"1"),this.tab_id=qu.sessionStorage.get(t),p.addEventListener("beforeunload",function(){qu.sessionStorage.remove(r)})}catch(Hy){this.report_error("Error initializing tab id",Hy)}else this.report_error("Session storage is not supported, cannot keep track of unique tab ID.")},Jp.prototype.get_tab_id=function(){return this.tab_id||null},Jp.prototype._should_load_recorder=function(){if(this.get_config("disable_persistence"))return $u.log("Load recorder check skipped due to disable_persistence config"),Promise.resolve(!1);var e=new pd(dd),t=this.get_tab_id();return e.init().then(function(){return e.getAll()}).then(function(e){for(var r=0;r<e.length;r++)if(Dd(e[r])||e[r].tabId===t)return!0;return!1}).catch(qu.bind(function(e){this.report_error("Error checking recording registry",e)},this))},Jp.prototype._check_and_start_session_recording=vd(function(e){if(p.MutationObserver){var t=qu.bind(function(e){var t=qu.bind(function(){this._recorder=this._recorder||new p.__mp_recorder(this),this._recorder.resumeRecording(e)},this);qu.isUndefined(p.__mp_recorder)?Bp(this.get_config("recorder_src"),t):t()},this),r=this.get_config("record_sessions_percent")>0&&100*Math.random()<=this.get_config("record_sessions_percent");e||r?t(!0):this._should_load_recorder().then(function(e){e&&t(!1)})}else $u.critical("Browser does not support MutationObserver; skipping session recording")}),Jp.prototype.start_session_recording=function(){this._check_and_start_session_recording(!0)},Jp.prototype.stop_session_recording=function(){return this._recorder?this._recorder.stopRecording():Promise.resolve()},Jp.prototype.pause_session_recording=function(){return this._recorder?this._recorder.pauseRecording():Promise.resolve()},Jp.prototype.resume_session_recording=function(){return this._recorder?this._recorder.resumeRecording():Promise.resolve()},Jp.prototype.is_recording_heatmap_data=function(){return this._get_session_replay_id()&&this.get_config("record_heatmap_data")},Jp.prototype.get_session_recording_properties=function(){var e={},t=this._get_session_replay_id();return t&&(e.$mp_replay_id=t),e},Jp.prototype.get_session_replay_url=function(){var e=null,t=this._get_session_replay_id();t&&(e="https://mixpanel.com/projects/replay-redirect?"+qu.HTTPBuildQuery({replay_id:t,distinct_id:this.get_distinct_id(),token:this.get_config("token")}));return e},Jp.prototype._get_session_replay_id=function(){var e=null;return this._recorder&&(e=this._recorder.replayId),e||null},Jp.prototype.__get_recorder=function(){return this._recorder},Jp.prototype._loaded=function(){if(this.get_config("loaded")(this),this._set_default_superprops(),this.people.set_once(this.persistence.get_referrer_info()),this.get_config("store_google")&&this.get_config("stop_utm_persistence")){var e=qu.info.campaignParams(null);qu.each(e,function(e,t){this.unregister(t)}.bind(this))}},Jp.prototype._set_default_superprops=function(){this.persistence.update_search_keyword(Mu.referrer),this.get_config("store_google")&&!this.get_config("stop_utm_persistence")&&this.register(qu.info.campaignParams()),this.get_config("save_referrer")&&this.persistence.update_referrer_info(Mu.referrer)},Jp.prototype._dom_loaded=function(){qu.each(this.__dom_loaded_queue,function(e){this._track_dom.apply(this,e)},this),this.has_opted_out_tracking()||qu.each(this.__request_queue,function(e){this._send_request.apply(this,e)},this),delete this.__dom_loaded_queue,delete this.__request_queue},Jp.prototype._track_dom=function(e,t){if(this.get_config("img"))return this.report_error("You can't use DOM tracking functions with img = true."),!1;if(!Kp)return this.__dom_loaded_queue.push([e,t]),!1;var r=(new e).init(this);return r.track.apply(r,t)},Jp.prototype._prepare_callback=function(e,t){if(qu.isUndefined(e))return null;if(Wp){return function(r){e(r,t)}}var r=this._jsc,n=""+Math.floor(1e8*Math.random()),i=this.get_config("callback_fn")+"["+n+"]";return r[n]=function(i){delete r[n],e(i,t)},i},Jp.prototype._send_request=function(e,t,r,n){var i=!0;if(Vp)return this.__request_queue.push(arguments),i;var o={method:this.get_config("api_method"),transport:this.get_config("api_transport"),verbose:this.get_config("verbose")},s=null;n||!qu.isFunction(r)&&"string"!=typeof r||(n=r,r=null),r=qu.extend(o,r||{}),Wp||(r.method="GET");var a="POST"===r.method,c=Hp&&a&&"sendbeacon"===r.transport.toLowerCase(),l=r.verbose;t.verbose&&(l=!0),this.get_config("test")&&(t.test=1),l&&(t.verbose=1),this.get_config("img")&&(t.img=1),Wp||(n?t.callback=n:(l||this.get_config("test"))&&(t.callback="(function(){})")),t.ip=this.get_config("ip")?1:0,t._=(new Date).getTime().toString(),a&&(s="data="+encodeURIComponent(t.data),delete t.data),qu.extend(t,this.get_config("api_extra_query_params")),e+="?"+qu.HTTPBuildQuery(t);var u=this;if("img"in t){var d=Mu.createElement("img");d.src=e,Mu.body.appendChild(d)}else if(c){try{i=Hp(e,s)}catch(y){u.report_error(y),i=!1}try{n&&n(i?1:0)}catch(y){u.report_error(y)}}else if(Wp)try{var h=new XMLHttpRequest;h.open(r.method,e,!0);var p=this.get_config("xhr_headers");if(a&&(p["Content-Type"]="application/x-www-form-urlencoded"),qu.each(p,function(e,t){h.setRequestHeader(t,e)}),r.timeout_ms&&void 0!==h.timeout){h.timeout=r.timeout_ms;var f=(new Date).getTime()}h.withCredentials=!0,h.onreadystatechange=function(){var e;if(4===h.readyState)if(200===h.status){if(n)if(l){var t;try{t=qu.JSONDecode(h.responseText)}catch(y){if(u.report_error(y),!r.ignore_json_errors)return;t=h.responseText}n(t)}else n(Number(h.responseText))}else if(e=h.timeout&&!h.status&&(new Date).getTime()-f>=h.timeout?"timeout":"Bad HTTP status: "+h.status+" "+h.statusText,u.report_error(e),n)if(l){var i=h.responseHeaders||{};n({status:0,httpStatusCode:h.status,error:e,retryAfter:i["Retry-After"]})}else n(0)},h.send(s)}catch(y){u.report_error(y),i=!1}else{var m=Mu.createElement("script");m.type="text/javascript",m.async=!0,m.defer=!0,m.src=e;var g=Mu.getElementsByTagName("script")[0];g.parentNode.insertBefore(m,g)}return i},Jp.prototype._execute_array=function(e){var t,r=[],n=[],i=[];qu.each(e,function(e){e&&(t=e[0],qu.isArray(t)?i.push(e):"function"==typeof e?e.call(this):qu.isArray(e)&&"alias"===t?r.push(e):qu.isArray(e)&&-1!==t.indexOf("track")&&"function"==typeof this[t]?i.push(e):n.push(e))},this);var o=function(e,t){qu.each(e,function(e){if(qu.isArray(e[0])){var r=t;qu.each(e,function(e){r=r[e[0]].apply(r,e.slice(1))})}else this[e[0]].apply(this,e.slice(1))},t)};o(r,this),o(n,this),o(i,this)},Jp.prototype.are_batchers_initialized=function(){return!!this.request_batchers.events},Jp.prototype.get_batcher_configs=function(){var e="__mpq_"+this.get_config("token");return this._batcher_configs=this._batcher_configs||{events:{type:"events",api_name:"track",queue_key:e+"_ev"},people:{type:"people",api_name:"engage",queue_key:e+"_pp"},groups:{type:"groups",api_name:"groups",queue_key:e+"_gr"}},this._batcher_configs},Jp.prototype.init_batchers=function(){if(!this.are_batchers_initialized()){var e=qu.bind(function(e){return new jd(e.queue_key,{libConfig:this.config,errorReporter:this.get_config("error_reporter"),sendRequestFunc:qu.bind(function(t,r,n){var i=this.get_config("api_routes");this._send_request(this.get_api_host(e.api_name)+"/"+i[e.api_name],this._encode_data_for_request(t),r,this._prepare_callback(n,t))},this),beforeSendHook:qu.bind(function(t){return this._run_hook("before_send_"+e.type,t)},this),stopAllBatchingFunc:qu.bind(this.stop_batch_senders,this),usePersistence:!0})},this),t=this.get_batcher_configs();this.request_batchers={events:e(t.events),people:e(t.people),groups:e(t.groups)}}this.get_config("batch_autostart")&&this.start_batch_senders()},Jp.prototype.start_batch_senders=function(){this._batchers_were_started=!0,this.are_batchers_initialized()&&(this._batch_requests=!0,qu.each(this.request_batchers,function(e){e.start()}))},Jp.prototype.stop_batch_senders=function(){this._batch_requests=!1,qu.each(this.request_batchers,function(e){e.stop(),e.clear()})},Jp.prototype.push=function(e){this._execute_array([e])},Jp.prototype.disable=function(e){void 0===e?this._flags.disable_all_events=!0:this.__disabled_events=this.__disabled_events.concat(e)},Jp.prototype._encode_data_for_request=function(e){var t=cd(e);return this.get_config("api_payload_format")===$p&&(t=qu.base64Encode(t)),{data:t}},Jp.prototype._track_or_batch=function(e,t){var r=qu.truncate(e.data,255),n=e.endpoint,i=e.batcher,o=e.should_send_immediately,s=e.send_request_options||{};t=t||ad;var a=!0,c=qu.bind(function(){return s.skip_hooks||(r=this._run_hook("before_send_"+e.type,r)),r?($u.log("MIXPANEL REQUEST:"),$u.log(r),this._send_request(n,this._encode_data_for_request(r),s,this._prepare_callback(t,r))):null},this);return this._batch_requests&&!o?i.enqueue(r).then(function(e){e?t(1,r):c()}):a=c(),a&&r},Jp.prototype.track=vd(function(e,t,r,n){n||"function"!=typeof r||(n=r,r=null);var i=(r=r||{}).transport;i&&(r.transport=i);var o=r.send_immediately;if("function"!=typeof n&&(n=ad),qu.isUndefined(e))this.report_error("No event name provided to mixpanel.track");else{if(!this._event_is_disabled(e)){(t=qu.extend({},t)).token=this.get_config("token");var s=this.persistence.remove_event_timer(e);if(!qu.isUndefined(s)){var a=(new Date).getTime()-s;t.$duration=parseFloat((a/1e3).toFixed(3))}this._set_default_superprops();var c=this.get_config("track_marketing")?qu.info.marketingParams():{};t=qu.extend({},qu.info.properties({mp_loader:this.get_config("mp_loader")}),c,this.persistence.properties(),this.unpersisted_superprops,this.get_session_recording_properties(),t);var l=this.get_config("property_blacklist");qu.isArray(l)?qu.each(l,function(e){delete t[e]}):this.report_error("Invalid value for property_blacklist config: "+l);var u={event:e,properties:t};return this._track_or_batch({type:"events",data:u,endpoint:this.get_api_host("events")+"/"+this.get_config("api_routes").track,batcher:this.request_batchers.events,should_send_immediately:o,send_request_options:r},n)}n(0)}}),Jp.prototype.set_group=vd(function(e,t,r){qu.isArray(t)||(t=[t]);var n={};return n[e]=t,this.register(n),this.people.set(e,t,r)}),Jp.prototype.add_group=vd(function(e,t,r){var n=this.get_property(e),i={};return void 0===n?(i[e]=[t],this.register(i)):-1===n.indexOf(t)&&(n.push(t),i[e]=n,this.register(i)),this.people.union(e,t,r)}),Jp.prototype.remove_group=vd(function(e,t,r){var n=this.get_property(e);if(void 0!==n){var i=n.indexOf(t);i>-1&&(n.splice(i,1),this.register({group_key:n})),0===n.length&&this.unregister(e)}return this.people.remove(e,t,r)}),Jp.prototype.track_with_groups=vd(function(e,t,r,n){var i=qu.extend({},t||{});return qu.each(r,function(e,t){null!=e&&(i[t]=e)}),this.track(e,i,n)}),Jp.prototype._create_map_key=function(e,t){return e+"_"+JSON.stringify(t)},Jp.prototype._remove_group_from_cache=function(e,t){delete this._cached_groups[this._create_map_key(e,t)]},Jp.prototype.get_group=function(e,t){var r=this._create_map_key(e,t),n=this._cached_groups[r];return void 0!==n&&n._group_key===e&&n._group_id===t||((n=new Sp)._init(this,e,t),this._cached_groups[r]=n),n},Jp.prototype.track_pageview=vd(function(e,t){"object"!=typeof e&&(e={});var r=(t=t||{}).event_name||"$mp_web_page_view",n=qu.extend(qu.info.mpPageViewProperties(),qu.info.campaignParams(),qu.info.clickParams()),i=qu.extend({},n,e);return this.track(r,i)}),Jp.prototype.track_links=function(){return this._track_dom.call(this,fp,arguments)},Jp.prototype.track_forms=function(){return this._track_dom.call(this,mp,arguments)},Jp.prototype.time_event=function(e){qu.isUndefined(e)?this.report_error("No event name provided to mixpanel.time_event"):this._event_is_disabled(e)||this.persistence.set_event_timer(e,(new Date).getTime())};var Qp={persistent:!0},ef=function(e){var t;return t=qu.isObject(e)?e:qu.isUndefined(e)?{}:{days:e},qu.extend({},Qp,t)};Jp.prototype.register=function(e,t){var r=ef(t);r.persistent?this.persistence.register(e,r.days):qu.extend(this.unpersisted_superprops,e)},Jp.prototype.register_once=function(e,t,r){var n=ef(r);n.persistent?this.persistence.register_once(e,t,n.days):(void 0===t&&(t="None"),qu.each(e,function(e,r){this.unpersisted_superprops.hasOwnProperty(r)&&this.unpersisted_superprops[r]!==t||(this.unpersisted_superprops[r]=e)},this))},Jp.prototype.unregister=function(e,t){(t=ef(t)).persistent?this.persistence.unregister(e):delete this.unpersisted_superprops[e]},Jp.prototype._register_single=function(e,t){var r={};r[e]=t,this.register(r)},Jp.prototype.identify=function(e,t,r,n,i,o,s,a){var c=this.get_distinct_id();if(e&&c!==e){if("string"==typeof e&&0===e.indexOf(Gp))return this.report_error("distinct_id cannot have $device: prefix"),-1;this.register({$user_id:e})}if(!this.get_property("$device_id")){var l=c;this.register_once({$had_persisted_distinct_id:!0,$device_id:l},"")}e!==c&&e!==this.get_property(jp)&&(this.unregister(jp),this.register({distinct_id:e})),this._flags.identify_called=!0,this.people._flush(t,r,n,i,o,s,a),e!==c&&this.track("$identify",{distinct_id:e,$anon_distinct_id:c},{skip_hooks:!0}),e!==c&&this.flags.fetchFlags()},Jp.prototype.reset=function(){this.stop_session_recording(),this.persistence.clear(),this._flags.identify_called=!1;var e=qu.UUID();this.register_once({distinct_id:Gp+e,$device_id:e},""),this._check_and_start_session_recording()},Jp.prototype.get_distinct_id=function(){return this.get_property("distinct_id")},Jp.prototype.alias=function(e,t){if(e===this.get_property(Rp))return this.report_error("Attempting to create alias for existing People user - aborting."),-2;var r=this;return qu.isUndefined(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(jp,e),this.track("$create_alias",{alias:e,distinct_id:t},{skip_hooks:!0},function(){r.identify(e)})):(this.report_error("alias matches current distinct_id - skipping api call."),this.identify(e),-1)},Jp.prototype.name_tag=function(e){this._register_single("mp_name_tag",e)},Jp.prototype.set_config=function(e){qu.isObject(e)&&(qu.extend(this.config,e),e.batch_size&&qu.each(this.request_batchers,function(e){e.resetBatchSize()}),this.get_config("persistence_name")||(this.config.persistence_name=this.config.cookie_name),this.get_config("disable_persistence")||(this.config.disable_persistence=this.config.disable_cookie),this.persistence&&this.persistence.update_config(this.config),xu.DEBUG=xu.DEBUG||this.get_config("debug"),("autocapture"in e||"record_heatmap_data"in e)&&this.autocapture&&this.autocapture.init())},Jp.prototype.get_config=function(e){return this.config[e]},Jp.prototype._run_hook=function(e){var t=(this.config.hooks[e]||zp).apply(this,Eu.call(arguments,1));return void 0===t&&(this.report_error(e+" hook did not return a value"),t=null),t},Jp.prototype.get_property=function(e){return this.persistence.load_prop([e])},Jp.prototype.get_api_host=function(e){return this.get_config("api_hosts")[e]||this.get_config("api_host")},Jp.prototype.toString=function(){var e=this.get_config("name");return e!==qp&&(e=qp+"."+e),e},Jp.prototype._event_is_disabled=function(e){return qu.isBlockedUA(ju)||this._flags.disable_all_events||qu.include(this.__disabled_events,e)},Jp.prototype._gdpr_init=function(){"localStorage"===this.get_config("opt_out_tracking_persistence_type")&&qu.localStorage.is_supported()&&(!this.has_opted_in_tracking()&&this.has_opted_in_tracking({persistence_type:"cookie"})&&this.opt_in_tracking({enable_persistence:!1}),!this.has_opted_out_tracking()&&this.has_opted_out_tracking({persistence_type:"cookie"})&&this.opt_out_tracking({clear_persistence:!1}),this.clear_opt_in_out_tracking({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_tracking()?this._gdpr_update_persistence({clear_persistence:!0}):this.has_opted_in_tracking()||!this.get_config("opt_out_tracking_by_default")&&!qu.cookie.get("mp_optout")||(qu.cookie.remove("mp_optout"),this.opt_out_tracking({clear_persistence:this.get_config("opt_out_persistence_by_default")}))},Jp.prototype._gdpr_update_persistence=function(e){var t;if(e&&e.clear_persistence)t=!0;else{if(!e||!e.enable_persistence)return;t=!1}this.get_config("disable_persistence")||this.persistence.disabled===t||this.persistence.set_disabled(t),t?(this.stop_batch_senders(),this.stop_session_recording()):this._batchers_were_started&&this.start_batch_senders()},Jp.prototype._gdpr_call_func=function(e,t){return t=qu.extend({track:qu.bind(this.track,this),persistence_type:this.get_config("opt_out_tracking_persistence_type"),cookie_prefix:this.get_config("opt_out_tracking_cookie_prefix"),cookie_expiration:this.get_config("cookie_expiration"),cross_site_cookie:this.get_config("cross_site_cookie"),cross_subdomain_cookie:this.get_config("cross_subdomain_cookie"),cookie_domain:this.get_config("cookie_domain"),secure_cookie:this.get_config("secure_cookie"),ignore_dnt:this.get_config("ignore_dnt")},t),qu.localStorage.is_supported()||(t.persistence_type="cookie"),e(this.get_config("token"),{track:t.track,trackEventName:t.track_event_name,trackProperties:t.track_properties,persistenceType:t.persistence_type,persistencePrefix:t.cookie_prefix,cookieDomain:t.cookie_domain,cookieExpiration:t.cookie_expiration,crossSiteCookie:t.cross_site_cookie,crossSubdomainCookie:t.cross_subdomain_cookie,secureCookie:t.secure_cookie,ignoreDnt:t.ignore_dnt})},Jp.prototype.opt_in_tracking=function(e){e=qu.extend({enable_persistence:!0},e),this._gdpr_call_func(fd,e),this._gdpr_update_persistence(e)},Jp.prototype.opt_out_tracking=function(e){(e=qu.extend({clear_persistence:!0,delete_user:!0},e)).delete_user&&this.people&&this.people._identify_called()&&(this.people.delete_user(),this.people.clear_charges()),this._gdpr_call_func(md,e),this._gdpr_update_persistence(e)},Jp.prototype.has_opted_in_tracking=function(e){return this._gdpr_call_func(gd,e)},Jp.prototype.has_opted_out_tracking=function(e){return this._gdpr_call_func(yd,e)},Jp.prototype.clear_opt_in_out_tracking=function(e){e=qu.extend({enable_persistence:!0},e),this._gdpr_call_func(xd,e),this._gdpr_update_persistence(e)},Jp.prototype.report_error=function(e,t){$u.error.apply($u.error,arguments);try{t||e instanceof Error||(e=new Error(e)),this.get_config("error_reporter")(e,t)}catch(r){$u.error(r)}},Jp.prototype.init=Jp.prototype.init,Jp.prototype.reset=Jp.prototype.reset,Jp.prototype.disable=Jp.prototype.disable,Jp.prototype.time_event=Jp.prototype.time_event,Jp.prototype.track=Jp.prototype.track,Jp.prototype.track_links=Jp.prototype.track_links,Jp.prototype.track_forms=Jp.prototype.track_forms,Jp.prototype.track_pageview=Jp.prototype.track_pageview,Jp.prototype.register=Jp.prototype.register,Jp.prototype.register_once=Jp.prototype.register_once,Jp.prototype.unregister=Jp.prototype.unregister,Jp.prototype.identify=Jp.prototype.identify,Jp.prototype.alias=Jp.prototype.alias,Jp.prototype.name_tag=Jp.prototype.name_tag,Jp.prototype.set_config=Jp.prototype.set_config,Jp.prototype.get_config=Jp.prototype.get_config,Jp.prototype.get_api_host=Jp.prototype.get_api_host,Jp.prototype.get_property=Jp.prototype.get_property,Jp.prototype.get_distinct_id=Jp.prototype.get_distinct_id,Jp.prototype.toString=Jp.prototype.toString,Jp.prototype.opt_out_tracking=Jp.prototype.opt_out_tracking,Jp.prototype.opt_in_tracking=Jp.prototype.opt_in_tracking,Jp.prototype.has_opted_out_tracking=Jp.prototype.has_opted_out_tracking,Jp.prototype.has_opted_in_tracking=Jp.prototype.has_opted_in_tracking,Jp.prototype.clear_opt_in_out_tracking=Jp.prototype.clear_opt_in_out_tracking,Jp.prototype.get_group=Jp.prototype.get_group,Jp.prototype.set_group=Jp.prototype.set_group,Jp.prototype.add_group=Jp.prototype.add_group,Jp.prototype.remove_group=Jp.prototype.remove_group,Jp.prototype.track_with_groups=Jp.prototype.track_with_groups,Jp.prototype.start_batch_senders=Jp.prototype.start_batch_senders,Jp.prototype.stop_batch_senders=Jp.prototype.stop_batch_senders,Jp.prototype.start_session_recording=Jp.prototype.start_session_recording,Jp.prototype.stop_session_recording=Jp.prototype.stop_session_recording,Jp.prototype.pause_session_recording=Jp.prototype.pause_session_recording,Jp.prototype.resume_session_recording=Jp.prototype.resume_session_recording,Jp.prototype.get_session_recording_properties=Jp.prototype.get_session_recording_properties,Jp.prototype.get_session_replay_url=Jp.prototype.get_session_replay_url,Jp.prototype.get_tab_id=Jp.prototype.get_tab_id,Jp.prototype.DEFAULT_API_ROUTES=Yp,Jp.prototype.__get_recorder=Jp.prototype.__get_recorder,Lp.prototype.properties=Lp.prototype.properties,Lp.prototype.update_search_keyword=Lp.prototype.update_search_keyword,Lp.prototype.update_referrer_info=Lp.prototype.update_referrer_info,Lp.prototype.get_cross_subdomain=Lp.prototype.get_cross_subdomain,Lp.prototype.clear=Lp.prototype.clear;var tf={},rf=function(){Up.init=function(e,t,r){if(r)return Up[r]||(Up[r]=tf[r]=Xp(e,t,r),Up[r]._loaded()),Up[r];var n=Up;tf[qp]?n=tf[qp]:e&&((n=Xp(e,t,qp))._loaded(),tf[qp]=n),Up=n,1===Ip&&(p[qp]=Up),qu.each(tf,function(e,t){t!==qp&&(Up[t]=e)}),Up._=qu}};var nf=(Bp=function(e,t){t()},Ip=0,Up=new Jp,rf(),Up.init(),function(){function e(){e.done||(e.done=!0,Kp=!0,Vp=!1,qu.each(tf,function(e){e._dom_loaded()}))}if(Mu.addEventListener)"complete"===Mu.readyState?e():Mu.addEventListener("DOMContentLoaded",e,!1);else if(Mu.attachEvent){Mu.attachEvent("onreadystatechange",e);var t=!1;try{t=null===p.frameElement}catch(r){}Mu.documentElement.doScroll&&t&&function t(){try{Mu.documentElement.doScroll("left")}catch(r){return void setTimeout(t,1)}e()}()}qu.register_event(p,"load",e,!0)}(),Up);let of=!1;const sf=()=>{of||(nf.init("c9fdb235976ef567b15bcb07bad264f3",{debug:!1,track_pageview:!1,persistence:"localStorage"}),of=!0)},af={init:()=>{sf()},track:(e,t={})=>{of||sf(),nf.track(e,{source:"coinley-sdk",...t,timestamp:(new Date).toISOString()})},trackModalOpened:(e,t)=>{af.track("SDK Modal Opened",{merchant_name:e,amount:t})},trackModalClosed:(e="user_closed")=>{af.track("SDK Modal Closed",{reason:e})},trackNetworkSelected:(e,t)=>{af.track("Network Selected",{network:e,merchant_name:t})},trackTokenSelected:(e,t,r)=>{af.track("Token Selected",{token:e,network:t,merchant_name:r})},trackWalletConnectStarted:e=>{af.track("Wallet Connect Started",{wallet_type:e})},trackWalletConnected:(e,t,r)=>{af.track("Wallet Connected",{wallet_type:e,wallet_address:(null==t?void 0:t.slice(0,10))+"...",network:r})},trackWalletConnectionFailed:(e,t)=>{af.track("Wallet Connection Failed",{wallet_type:e,error:(null==t?void 0:t.message)||t})},trackWalletDisconnected:()=>{af.track("Wallet Disconnected")},trackPaymentCreated:(e,t,r,n)=>{af.track("Payment Created",{payment_id:e,amount:t,network:r,token:n})},trackPaymentApprovalStarted:(e,t)=>{af.track("Payment Approval Started",{payment_id:e,amount:t})},trackPaymentApproved:(e,t)=>{af.track("Payment Approved",{payment_id:e,amount:t})},trackPaymentExecutionStarted:(e,t)=>{af.track("Payment Execution Started",{payment_id:e,amount:t})},trackPaymentSuccess:(e,t,r,n,i)=>{af.track("Payment Success",{payment_id:e,amount:t,network:r,token:n,transaction_hash:i})},trackPaymentFailed:(e,t,r,n,i)=>{af.track("Payment Failed",{payment_id:e,amount:t,network:r,token:n,error:(null==i?void 0:i.message)||i})},trackPaymentCancelled:(e,t)=>{af.track("Payment Cancelled",{payment_id:e,stage:t})},trackError:(e,t,r={})=>{af.track("SDK Error",{error_type:e,error_message:t,...r})},trackNetworkSwitchRequested:(e,t)=>{af.track("Network Switch Requested",{from_network:e,to_network:t})},trackNetworkSwitchSuccess:e=>{af.track("Network Switch Success",{network:e})},trackNetworkSwitchFailed:(e,t)=>{af.track("Network Switch Failed",{network:e,error:(null==t?void 0:t.message)||t})}},cf="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABxCAYAAAAj+QZ8AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAzrSURBVHgB7V3dcRs5Em4MtXWPq41gZ1+v7mwrgh3rArAUgagITNcFYDmAK9ERSBuBfQGsxY3Aku26V/MiOO7j1nqAQwMgRQ4xQONnhqOfr8q2TA4H1HzoRqO70c1g4JhUH/dhNKqgrhfT2cEMOoQaqxidyx+P5J8F8PpYjnkNPYLBgPGq+vxSFOJM/rhvXpp39ZAkGaUk40r+WK69jKT8JMdbQE8oYKDAByTJmMItGQj10OR7zyA3itFr2CQD1NhFMYYeMVhCHA8C1co7pV4yYXL4aSz/GVvfFFBBjxguIcCeOt4szYxOhiG2/V7M+T2yY7iEMOaTgIl8mBWkoth7Cduqah2u97JjuIQIUXqvYWlSohZyUEaDE/88/M+P0BMGrLIIYFAZ/R+HTGovJ+42IRqvYxZ485kKBob7QEgZZZoWoyMgrg//+vDX/0JPuA+ESLCXEApG/kxvm0LEkK2secDVZYjFpRZzIWibSyHm0COGSwjnYWoiyOIqjujXskcJUWCBqgItLuriPipOgAombqBH7EEGTKovUvz/xIdxnc8Rx8IdiHpxn7ouCVJXGnPIBD1h9p5BIU6kS6ZkBXt//uvf365fk0SIcvJJv5LUL6Wcdvq1w09z+c9MeknfSHLmEAteX8t7B30EBHsBHkLkPSsI+h482bOs3froERAT+UdLMcPlSch91M0P0w9Pz5bXpqksRcaW6Yj/H8v3vkpyLvRuOBzGxd6F2voZwpBEyKT6XMln8dF4BCzfjW2oz2hCjAu89FxmiPkctyNmMWprdOS5J11dSQsrVgXjxJAT8lyqp2aMpTnGxv1TJCRgdyzO5Jf7Giwtgv8GwWhfH5T0hK0fUQu6UeUf8UfvxY1Jl0LIHMJQBksL5zMIhXCqpLDAFpNrYSAwymnIKEkf4PUv6/+NJsQs2BHirKTlHUVaTAw9cB1xqaQijJDACYGTzUQ5adAqcbb+UuI+RPwCcTgyodjSe6UQ/4ZAtLrLi4DYhn5Y5DVscvjlguLK3xyDvWm+lEYI5+8hHiWJFMEvIRA1/3ZgfYMV9OgfYzPKZWrxfv5JLtx8DCFQhD+5bL6cRIgSN+IXb4GXlCi1VbQEt0IWdA40yRztXaG5DaEQ/Nj2crrrpP72BtJAkJRg1bhlAZr9Cc0y1LPXK/1KTYVZbcsB3rapw2RC1AwW0WvJEktS7A8sWDWyH61jkD/ul3q1xwhVUwj0HnN+1vZ2Huei4Ghvp/qwSumxfWd7I4NqRND3TdLt43rbmO7+PYYNgj93bTazEKIG4PUppELHyM+t76WrRhoEzFw+uMk/Ph0FW1O3N3/l8+9lc7/Lgd6jboR0TF5VNyeW++eQEj8EtKpf7SmGC4i78VvpRPTuUfLGQ1A3CpHkjEOIgk2ti3zXUtJiiq6gc38DXEar+15LMkgqLishSnWhOZce9tyX68mF5f4pUjL3XmHZqC1hVGkJocBnIdcN6uXZI4ZKR2obO22Rx/VE6esG6m+n/nsLW/jX/Rnp5GuTDpP7Fb6IGzJCPMadhHCVjc1rnBVppAg4b5rCinBeHzs/x7fd9uqhuNz59TfrPY3qDA8f3JIxD/lYZzH1TKRgztXEcu8ZWiztH6vtD17wlt23w/qxH1NwI5IMNRx0iDyk2POntMUiLDpftIeOOZ9ufxd5fYv1Y6RjDCFIIAPRywkq9YuxQvp8WAkxkKS2HWdT+VgFpvWw7zG24Dv2Jq8/kv6nl3rH7L4eQ9AQQojcw4BQJ7yiJ2AvhCAMKe+CQqgrKBs+bmecAIxyAlldKUk7g0R4s070ovpdadJ8DL6TM+DPoHizEeGDyeHNmZwHYYukiDA3E0HMGUAsD4fOIAP2LF/EnKtjGAqtQG2EOCzTfDT0/+UM0jFhte8QN+rnur526U+cRXIMuZ8oLgJUWG/nM9bg3wBqFXWalO7UwEplbeYORexGN+6qSLp26Wijws7ktf4sQvQvXT0hb65ywOw92twk0oSG0+mvfhd9KBQhLUeCc2EOjsQ5EjFc/vIul0YHUBOUFR8bUrxQ/jpprXV1VFoTcvgJ3d5H0D0uncRgEvSoeCGlqzIvL1xmaddYfScFft114QIEM9LxFfrFZXKq6T0FbgzT1os4YEbjR2lx9W7KDh3M1Pf4H+wKHVgqdxmFdpknx8TjgRkb1BytBwDtyxIq6N6J1UBEKd0Z7+ARmhDj0k53l6dAiGd6F/+wsfL2rjyzPR9y3ARhk3jPseF+V6RguHF3a0rZZxmLIaLV26uca9o7W0Kf4PUP0x4Lhg0NXve78ukI8boXYnbgsxoayPEQRQz6m27dGnmRGGm7LwgOUK38OwxO4oJNFjxuDldIihiazdwzGT+p1NkLnQlOdcUsVFY75+/7cNrdFWQP4Zq0nRI0MeiW2SSIq4yQxaM0POJOoCsJ0VJSjMqtC3g9x5j8dPa35Bzg+4hkQnSlAv7MxOCpiQGIOeQowXHPEEWIJkFgXZEx5ImnPAasDOj7kJxJEHagg/PgIe/SEbS8rGYlm26Aaw5meRzDA4ZTQizF8LvHA/dlWSVEp+aMLgTryE3iwKj4y/ew22DZTmHJXFQLNkbvdpH8ADX/43d4wNiIh7yqvpyY+k47IUPi8qEv6itCMP4hivC6IlnhOR/+EKAIMalAO04y8J/hfgjQEhJQdrsb7C5ddGjQi7oOPMFuICXjkYwVstTtjYKOEGJQarY6FKR8YsvSSgx37rOHpsZM9vvNNKqgfRxWKf2mqDCOW0G7ZTedfnjyCnYAU8zyRE6Mt31NDL2GpFWGo0IdLcA2dMCLmar8o01sXL9cZvaktSBN1xjt4bgTU4P4nFATOBnLzMWZ/YhxFqwRIc1q9FchEWFV2CZ9PIwtbJapnaiM/Rx9rxy4zVzUJ0hPM2UuGrVUP5fqRpXSZrB3Ysqnxh0M6rmfoML2uXZdaC22MDQBVueiOV+H8Y4K/Lv2hfkjg03YSYDPmuXrjMqZQBouJbnpNbkCoc612/Zo6oDrt+Pca4s/UW4zaWEdc/zLWexL9bHdu4qrS7gFJyE4VojbBR2o1IfpMHqyt4LtrHBABwdJrYTcdmhQ43iDXJbrvQ+05QDoGvLtpTqpddLNqV7xe8s46x0arMVqNrB1vf+w0KoOWGtYgJ3nWleyE2LUlK2NRRpsprmNdKHWvrbvZkvCsBZLa0JLkcsSxRLq6aTklxAsZ5RnzbiFpUa6+eXLrWtdSeGjkf29tmJpDZgKRI66kumkZCUkqXyqC42yfqZlats47VahcL5H2vipIjjOMoOq2UBkocyMhFD7ykahGSfRRcVaH177oR9nf13/+rMEVp9zF/scx5KST0K0Ps+PRh3dqKJiZLCXJCmhFfscx6ivLIS06vMcEFbp6Ar7VCkxxT49ZzLD15RkQjz6PA1aOmabY/mlo713LaV7KE1KEF2Qki4hHn2eBNEoX95Pu+39EL8ZlRRbtW4bkggxMzbOWeiFtZhl5f+YY7FVmfeUodkLCACFFFOt27sdSO1jWEEX0oH7jkb9QrNPKP0fdvaunQMFuh9iBQEgkLJP8QqkEcI6OOjfVprbsQPfgLt3Ldn5qI7pBSKAlNZJnEZI7h25uidvO/xJU428fdNmnI5zICEupL1GSpvqbO2Tgkjt9JlXXalSftsHQI36II7lXSeorvL92OjgihSA99YLVJ8Uu+XVU6dPAlx1FQty//OFNzbBxW9ARYTaWgKlUYYLjtsdkuLMRng8IUWLoy4UusL0gbPIJSt+Btq9CA87oPuzYLRxHdDGSUudep1EsYF4QqgmpAuqYICq3tD6kIL619JapdIJoXWf9kJ5iTHJo7nYW0pSpaislLDlQkXZrp74S2mMlGlNA6FVqmlb4b1uDVkMl7XFvlFpadMzkNILN/QX0xDq5O0BOeRJlY6QVqkhXaiLIgshCCRlevV0DJvZPUjGaow0sxe73VDThjQRz0lSsQ7q+hEyOYKaDjN6u1Yi5GJ/KScFtoc9bVqWGc6pOytTL1Lrmci4AlZM9etxDseU7pzB98WGXldPD6AnJCdbm9k+lsScgSpEY2qb6JomQR0Umghqlwr1DEKAXagpnoY+6oStIVv2uyFmDnlB1d/hR+GwCzUbUVw/+6E5XynotOVROogLKrWz8yZQgkkP2ZwM7gXDJoTSkJ7Y2bkJPeNpxT5r/sdP0BMGLiHMX6FUQHy7V+oxjFxeCcpQMGQwRljQ48+29NZfNwADlxAvLpOzz/vqQk3E3SYkw7n2oUnJsAkRwmEFiXzn/gYkJQOXEGFP51Eue07zhREwJCkZupVldxYWLH/VB1cXat5fdaJhE8JriwUl3nTRrk4T3Bbdq1NCDUEYNCFm87Z8SAtzUukMOoK94bHo7Yw6orMjbTmxDOD05U/SBz2l2wab3ncgjS78H0eagrHjdQciAAAAAElFTkSuQmCC",lf="YWG990wOlIikc1tU7-WWTepfU8d1f4dp",uf="qtIcCe_-8t4rIWktnWJm0",df=o.createConfig({chains:[s.mainnet,s.bsc,s.polygon,s.arbitrum,s.optimism,s.avalanche,s.celo,s.base],connectors:[a.injected(),a.metaMask({dappMetadata:{name:"Coinley Payment",icon:cf}}),a.coinbaseWallet({appName:"Coinley Payment",appLogoUrl:cf})],transports:{[s.mainnet.id]:o.fallback([o.http(`https://eth-mainnet.g.alchemy.com/v2/${lf}`,{timeout:1e4,retryCount:1}),o.http(`https://eth-mainnet.g.alchemy.com/v2/${uf}`,{timeout:1e4,retryCount:1}),o.http("https://cloudflare-eth.com",{timeout:1e4,retryCount:1}),o.http("https://eth.llamarpc.com",{timeout:1e4,retryCount:1}),o.http("https://ethereum.publicnode.com",{timeout:1e4,retryCount:1})]),[s.bsc.id]:o.fallback([o.http(`https://bnb-mainnet.g.alchemy.com/v2/${lf}`,{timeout:1e4,retryCount:1}),o.http(`https://bnb-mainnet.g.alchemy.com/v2/${uf}`,{timeout:1e4,retryCount:1}),o.http("https://bsc-dataseed.bnbchain.org",{timeout:1e4,retryCount:1}),o.http("https://bsc-dataseed-public.bnbchain.org",{timeout:1e4,retryCount:1}),o.http("https://bsc.nodereal.io",{timeout:1e4,retryCount:1})]),[s.polygon.id]:o.fallback([o.http(`https://polygon-mainnet.g.alchemy.com/v2/${lf}`,{timeout:1e4,retryCount:1}),o.http(`https://polygon-mainnet.g.alchemy.com/v2/${uf}`,{timeout:1e4,retryCount:1}),o.http("https://polygon.llamarpc.com",{timeout:1e4,retryCount:1}),o.http("https://polygon-rpc.com",{timeout:1e4,retryCount:1}),o.http("https://polygon.drpc.org",{timeout:1e4,retryCount:1})]),[s.arbitrum.id]:o.fallback([o.http(`https://arb-mainnet.g.alchemy.com/v2/${lf}`,{timeout:1e4,retryCount:1}),o.http(`https://arb-mainnet.g.alchemy.com/v2/${uf}`,{timeout:1e4,retryCount:1}),o.http("https://arb1.arbitrum.io/rpc",{timeout:1e4,retryCount:1}),o.http("https://arbitrum.llamarpc.com",{timeout:1e4,retryCount:1})]),[s.optimism.id]:o.fallback([o.http(`https://opt-mainnet.g.alchemy.com/v2/${lf}`,{timeout:1e4,retryCount:1}),o.http(`https://opt-mainnet.g.alchemy.com/v2/${uf}`,{timeout:1e4,retryCount:1}),o.http("https://mainnet.optimism.io",{timeout:1e4,retryCount:1}),o.http("https://optimism.llamarpc.com",{timeout:1e4,retryCount:1})]),[s.avalanche.id]:o.fallback([o.http(`https://avax-mainnet.g.alchemy.com/v2/${lf}`,{timeout:1e4,retryCount:1}),o.http(`https://avax-mainnet.g.alchemy.com/v2/${uf}`,{timeout:1e4,retryCount:1}),o.http("https://api.avax.network/ext/bc/C/rpc",{timeout:1e4,retryCount:1}),o.http("https://avalanche.public-rpc.com",{timeout:1e4,retryCount:1})]),[s.celo.id]:o.fallback([o.http(`https://celo-mainnet.g.alchemy.com/v2/${lf}`,{timeout:1e4,retryCount:1}),o.http(`https://celo-mainnet.g.alchemy.com/v2/${uf}`,{timeout:1e4,retryCount:1}),o.http("https://forno.celo.org",{timeout:1e4,retryCount:1}),o.http("https://celo.drpc.org",{timeout:1e4,retryCount:1})]),[s.base.id]:o.fallback([o.http(`https://base-mainnet.g.alchemy.com/v2/${lf}`,{timeout:1e4,retryCount:1}),o.http(`https://base-mainnet.g.alchemy.com/v2/${uf}`,{timeout:1e4,retryCount:1}),o.http("https://mainnet.base.org",{timeout:1e4,retryCount:1}),o.http("https://base.llamarpc.com",{timeout:1e4,retryCount:1}),o.http("https://base.meowrpc.com",{timeout:1e4,retryCount:1})])}});let hf=class{constructor(e,t,r=null){this.baseURL=e.endsWith("/")?e.slice(0,-1):e,t&&t.startsWith("pk_")?(this.publicKey=t,this.apiKey=null,this.apiSecret=null):(this.publicKey=null,this.apiKey=t,this.apiSecret=r)}async request(e,t={}){const r=`${this.baseURL}${e}`,n={"Content-Type":"application/json",...t.headers};this.publicKey?n["X-Public-Key"]=this.publicKey:(n["X-API-Key"]=this.apiKey,n["X-API-Secret"]=this.apiSecret);const i=t.timeout||6e4,o=new AbortController,s=setTimeout(()=>o.abort(),i);try{const e=await fetch(r,{...t,headers:n,signal:o.signal});if(clearTimeout(s),!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.error||`HTTP ${e.status}`)}return e.json()}catch(gu){if(clearTimeout(s),"AbortError"===gu.name)throw new Error(`Request timeout after ${i/1e3}s: ${e}`);throw gu}}async getNetworks(){try{return await this.request("/api/networks")}catch(gu){return{networks:[{id:"1",name:"Ethereum",shortName:"ethereum",chainId:"0x1",type:"ethereum"},{id:"56",name:"BSC",shortName:"bsc",chainId:"0x38",type:"bsc"},{id:"137",name:"Polygon",shortName:"polygon",chainId:"0x89",type:"polygon"},{id:"42161",name:"Arbitrum",shortName:"arbitrum",chainId:"0xa4b1",type:"arbitrum"},{id:"10",name:"Optimism",shortName:"optimism",chainId:"0xa",type:"optimism"},{id:"43114",name:"Avalanche",shortName:"avalanche",chainId:"0xa86a",type:"avalanche"}]}}}async getTokens(){try{return await this.request("/api/networks/stablecoins")}catch(gu){return{stablecoins:[{id:"1",name:"Tether USD",symbol:"USDT",contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"2",name:"USD Coin",symbol:"USDC",contractAddress:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"3",name:"Tether USD",symbol:"USDT",contractAddress:"0x55d398326f99059fF775485246999027B3197955",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"4",name:"USD Coin",symbol:"USDC",contractAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"5",name:"Tether USD",symbol:"USDT",contractAddress:"0xc2132D05D31c914a87c6611C10748AEb04B58e8F",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"6",name:"USD Coin",symbol:"USDC",contractAddress:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"7",name:"Tether USD",symbol:"USDT",contractAddress:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"8",name:"USD Coin",symbol:"USDC",contractAddress:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"9",name:"Tether USD",symbol:"USDT",contractAddress:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"10",name:"USD Coin",symbol:"USDC",contractAddress:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"11",name:"Tether USD",symbol:"USDT",contractAddress:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"12",name:"USD Coin",symbol:"USDC",contractAddress:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"13",name:"Tether USD",symbol:"USDT",contractAddress:"0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"14",name:"USD Coin",symbol:"USDC",contractAddress:"0xcebA9300f2b948710d2653dD7B07f33A8B32118C",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"15",name:"Tether USD",symbol:"USDT",contractAddress:"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}},{id:"16",name:"USD Coin",symbol:"USDC",contractAddress:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}}]}}}async createPayment(e){return await this.request("/api/payments/create",{method:"POST",body:JSON.stringify(e)})}async verifyQRPayment(e){return await this.request("/api/payments/verify-qr",{method:"POST",body:JSON.stringify({paymentId:e})})}async checkPaymentStatus(e){return await this.request(`/api/payments/status/${e}`)}async getContractInfo(e){try{const t=await this.request(`/api/payments/contract/${e}`);if(!t.success)throw new Error("Contract not supported on this network");return t.contractInfo}catch(gu){throw new Error(gu.message||"Failed to get contract information")}}async processPayment(e,t,r,n){try{return await this.request("/api/payments/process",{method:"POST",body:JSON.stringify({paymentId:e,transactionHash:t,network:r,senderAddress:n}),timeout:9e4})}catch(gu){throw gu}}async failPayment(e,t="Payment cancelled by user"){return await this.request("/api/payments/fail",{method:"POST",body:JSON.stringify({paymentId:e,reason:t,status:"failed"})})}};const pf={ethereum:1,bsc:56,polygon:137,arbitrum:42161,optimism:10,avalanche:43114,celo:42220,base:8453},ff=e=>"number"==typeof e?e:"string"==typeof e?e.startsWith("0x")?parseInt(e,16):parseInt(e,10):1,mf=e=>pf[e]||1;function gf(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const yf="2.41.2";let vf={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${yf}`};class bf extends Error{constructor(e,t={}){var r;const n=t.cause instanceof bf?t.cause.details:(null==(i=t.cause)?void 0:i.message)?t.cause.message:t.details;var i;const o=t.cause instanceof bf&&t.cause.docsPath||t.docsPath,s=null==(r=vf.getDocsUrl)?void 0:r.call(vf,{...t,docsPath:o});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...vf.version?[`Version: ${vf.version}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=o,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=yf}walk(e){return wf(this,e)}}function wf(e,t){return(null==t?void 0:t(e))?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?wf(e.cause,t):t?null:e}class xf extends bf{constructor({max:e,min:t,signed:r,size:n,value:i}){super(`Number "${i}" is not in safe ${n?`${8*n}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class _f extends bf{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function kf(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function Sf(e){return kf(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function Cf(e,{dir:t="left"}={}){let r="string"==typeof e?e.replace("0x",""):e,n=0;for(let i=0;i<r.length-1&&"0"===r["left"===t?i:r.length-i-1].toString();i++)n++;return r="left"===t?r.slice(n):r.slice(0,r.length-n),"string"==typeof e?(1===r.length&&"right"===t&&(r=`${r}0`),`0x${r.length%2==1?`0${r}`:r}`):r}class If extends bf{constructor({offset:e,position:t,size:r}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class Ef extends bf{constructor({size:e,targetSize:t,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function Nf(e,{dir:t,size:r=32}={}){return"string"==typeof e?function(e,{dir:t,size:r=32}={}){if(null===r)return e;const n=e.replace("0x","");if(n.length>2*r)throw new Ef({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n["right"===t?"padEnd":"padStart"](2*r,"0")}`}(e,{dir:t,size:r}):function(e,{dir:t,size:r=32}={}){if(null===r)return e;if(e.length>r)throw new Ef({size:e.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let i=0;i<r;i++){const o="right"===t;n[o?i:r-i-1]=e[o?i:e.length-i-1]}return n}(e,{dir:t,size:r})}const Af=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Pf(e,t={}){return"number"==typeof e||"bigint"==typeof e?Mf(e,t):"string"==typeof e?function(e,t={}){const r=Tf.encode(e);return Of(r,t)}(e,t):"boolean"==typeof e?function(e,t={}){const r=`0x${Number(e)}`;if("number"==typeof t.size)return Bf(r,{size:t.size}),Nf(r,{size:t.size});return r}(e,t):Of(e,t)}function Of(e,t={}){let r="";for(let i=0;i<e.length;i++)r+=Af[e[i]];const n=`0x${r}`;return"number"==typeof t.size?(Bf(n,{size:t.size}),Nf(n,{dir:"right",size:t.size})):n}function Mf(e,t={}){const{signed:r,size:n}=t,i=BigInt(e);let o;n?o=r?(1n<<8n*BigInt(n)-1n)-1n:2n**(8n*BigInt(n))-1n:"number"==typeof e&&(o=BigInt(Number.MAX_SAFE_INTEGER));const s="bigint"==typeof o&&r?-o-1n:0;if(o&&i>o||i<s){const t="bigint"==typeof e?"n":"";throw new xf({max:o?`${o}${t}`:void 0,min:`${s}${t}`,signed:r,size:n,value:`${e}${t}`})}const a=`0x${(r&&i<0?(1n<<BigInt(8*n))+BigInt(i):i).toString(16)}`;return n?Nf(a,{size:n}):a}const Tf=new TextEncoder;const Rf=new TextEncoder;function jf(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const r=Mf(e,t);return Lf(r)}(e,t):"boolean"==typeof e?function(e,t={}){const r=new Uint8Array(1);if(r[0]=Number(e),"number"==typeof t.size)return Bf(r,{size:t.size}),Nf(r,{size:t.size});return r}(e,t):kf(e)?Lf(e,t):Uf(e,t)}const Df={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ff(e){return e>=Df.zero&&e<=Df.nine?e-Df.zero:e>=Df.A&&e<=Df.F?e-(Df.A-10):e>=Df.a&&e<=Df.f?e-(Df.a-10):void 0}function Lf(e,t={}){let r=e;t.size&&(Bf(r,{size:t.size}),r=Nf(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,o=new Uint8Array(i);for(let s=0,a=0;s<i;s++){const e=Ff(n.charCodeAt(a++)),t=Ff(n.charCodeAt(a++));if(void 0===e||void 0===t)throw new bf(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);o[s]=16*e+t}return o}function Uf(e,t={}){const r=Rf.encode(e);return"number"==typeof t.size?(Bf(r,{size:t.size}),Nf(r,{dir:"right",size:t.size})):r}function Bf(e,{size:t}){if(Sf(e)>t)throw new _f({givenSize:Sf(e),maxSize:t})}function zf(e,t={}){const{signed:r}=t;t.size&&Bf(e,{size:t.size});const n=BigInt(e);if(!r)return n;const i=(e.length-2)/2;return n<=(1n<<8n*BigInt(i)-1n)-1n?n:n-BigInt(`0x${"f".padStart(2*i,"f")}`)-1n}function qf(e,t={}){return Number(zf(e,t))}function $f(e,t){return({exclude:r,format:n})=>({exclude:r,format:(e,i)=>{const o=t(e,i);if(r)for(const t of r)delete o[t];return{...o,...n(e,i)}},type:e})}const Gf={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Wf(e,t){const r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?qf(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?qf(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Gf[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(r.authorizationList=e.authorizationList.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))),r.yParity=(()=>{if(e.yParity)return Number(e.yParity);if("bigint"==typeof r.v){if(0n===r.v||27n===r.v)return 0;if(1n===r.v||28n===r.v)return 1;if(r.v>=35n)return r.v%2n==0n?1:0}})(),"legacy"===r.type&&(delete r.accessList,delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas,delete r.yParity),"eip2930"===r.type&&(delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas),"eip1559"===r.type&&delete r.maxFeePerBlobGas,r}const Vf=$f("transaction",Wf);function Hf(e,t){const r=(e.transactions??[]).map(e=>"string"==typeof e?e:Wf(e));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:r,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const Yf=$f("block",Hf);const Zf={"0x0":"reverted","0x1":"success"};function Kf(e,t){const r={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(e=>function(e,{args:t,eventName:r}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...r?{args:t,eventName:r}:{}}}(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?qf(e.transactionIndex):null,status:e.status?Zf[e.status]:null,type:e.type?Gf[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}const Jf=$f("transactionReceipt",Kf),Xf={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Qf(e,t){const r={};return void 0!==e.authorizationList&&(r.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?Mf(BigInt(e.r)):e.r,s:e.s?Mf(BigInt(e.s)):e.s,chainId:Mf(e.chainId),nonce:Mf(e.nonce),...void 0!==e.yParity?{yParity:Mf(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:Mf(e.v)}:{}}))),void 0!==e.accessList&&(r.accessList=e.accessList),void 0!==e.blobVersionedHashes&&(r.blobVersionedHashes=e.blobVersionedHashes),void 0!==e.blobs&&("string"!=typeof e.blobs[0]?r.blobs=e.blobs.map(e=>Of(e)):r.blobs=e.blobs),void 0!==e.data&&(r.data=e.data),e.account&&(r.from=e.account.address),void 0!==e.from&&(r.from=e.from),void 0!==e.gas&&(r.gas=Mf(e.gas)),void 0!==e.gasPrice&&(r.gasPrice=Mf(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(r.maxFeePerBlobGas=Mf(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(r.maxFeePerGas=Mf(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=Mf(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(r.nonce=Mf(e.nonce)),void 0!==e.to&&(r.to=e.to),void 0!==e.type&&(r.type=Xf[e.type]),void 0!==e.value&&(r.value=Mf(e.value)),r}const em=$f("transactionRequest",Qf);const tm=2n**256n-1n;function rm(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}class nm extends bf{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class im extends bf{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class om extends bf{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const sm={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new om({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new im({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new nm({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new nm({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function am(e,{recursiveReadLimit:t=8192}={}){const r=Object.create(sm);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}function cm(e,t="hex"){const r=lm(e),n=am(new Uint8Array(r.length));return r.encode(n),"hex"===t?Of(n.bytes):n.bytes}function lm(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),r=um(t);return{length:t<=55?1+t:1+r+t,encode(n){t<=55?n.pushByte(192+t):(n.pushByte(247+r),1===r?n.pushUint8(t):2===r?n.pushUint16(t):3===r?n.pushUint24(t):n.pushUint32(t));for(const{encode:t}of e)t(n)}}}(e.map(e=>lm(e))):function(e){const t="string"==typeof e?Lf(e):e,r=um(t.length),n=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length;return{length:n,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+r),1===r?e.pushUint8(t.length):2===r?e.pushUint16(t.length):3===r?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function um(e){if(e<256)return 1;if(e<65536)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new bf("Length is too large.")}const dm={ether:-9,wei:9};function hm(e,t="wei"){return function(e,t){let r=e.toString();const n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(t,"0");let[i,o]=[r.slice(0,r.length-t),r.slice(r.length-t)];return o=o.replace(/(0+)$/,""),`${n?"-":""}${i||"0"}${o?`.${o}`:""}`}(e,dm[t])}function pm(e){const t=Object.entries(e).map(([e,t])=>void 0===t||!1===t?null:[e,t]).filter(Boolean),r=t.reduce((e,[t])=>Math.max(e,t.length),0);return t.map(([e,t])=>` ${`${e}:`.padEnd(r+1)} ${t}`).join("\n")}class fm extends bf{constructor({v:e}){super(`Invalid \`v\` value "${e}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class mm extends bf{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",pm(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class gm extends bf{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${Math.floor((e.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}function ym(e){const{kzg:t}=e,r=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),n="string"==typeof e.blobs[0]?e.blobs.map(e=>Lf(e)):e.blobs,i=[];for(const o of n)i.push(Uint8Array.from(t.blobToKzgCommitment(o)));return"bytes"===r?i:i.map(e=>Of(e))}function vm(e){const{kzg:t}=e,r=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),n="string"==typeof e.blobs[0]?e.blobs.map(e=>Lf(e)):e.blobs,i="string"==typeof e.commitments[0]?e.commitments.map(e=>Lf(e)):e.commitments,o=[];for(let s=0;s<n.length;s++){const e=n[s],r=i[s];o.push(Uint8Array.from(t.computeBlobKzgProof(e,r)))}return"bytes"===r?o:o.map(e=>Of(e))}
|
|
2
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function bm(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function wm(e,...t){if(!((r=e)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function xm(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _m(e,t){wm(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function km(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Sm(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Cm(e,t){return e<<32-t|e>>>t}function Im(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Em=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=Im(e[t]);return e};function Nm(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),wm(e),e}class Am{}function Pm(e){const t=t=>e().update(Nm(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Om(e,t,r){return e&t^~e&r}function Mm(e,t,r){return e&t^e&r^t&r}class Tm extends Am{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Sm(this.buffer)}update(e){xm(this),wm(e=Nm(e));const{view:t,buffer:r,blockLen:n}=this,i=e.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s===n){const t=Sm(e);for(;n<=i-o;o+=n)this.process(t,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){xm(this),_m(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;t[o++]=128,km(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(r,0),o=0);for(let u=o;u<n;u++)t[u]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,l=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+l,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=Sm(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=i,e.length=n,e.pos=s,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const Rm=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),jm=BigInt(2**32-1),Dm=BigInt(32);function Fm(e,t=!1){return t?{h:Number(e&jm),l:Number(e>>Dm&jm)}:{h:0|Number(e>>Dm&jm),l:0|Number(e&jm)}}const Lm=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Um=new Uint32Array(64);class Bm extends Tm{constructor(e=32){super(64,e,8,!1),this.A=0|Rm[0],this.B=0|Rm[1],this.C=0|Rm[2],this.D=0|Rm[3],this.E=0|Rm[4],this.F=0|Rm[5],this.G=0|Rm[6],this.H=0|Rm[7]}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let u=0;u<16;u++,t+=4)Um[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const e=Um[u-15],t=Um[u-2],r=Cm(e,7)^Cm(e,18)^e>>>3,n=Cm(t,17)^Cm(t,19)^t>>>10;Um[u]=n+Um[u-7]+r+Um[u-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:c,H:l}=this;for(let u=0;u<64;u++){const e=l+(Cm(s,6)^Cm(s,11)^Cm(s,25))+Om(s,a,c)+Lm[u]+Um[u]|0,t=(Cm(r,2)^Cm(r,13)^Cm(r,22))+Mm(r,n,i)|0;l=c,c=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+t|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,n,i,o,s,a,c,l)}roundClean(){km(Um)}destroy(){this.set(0,0,0,0,0,0,0,0),km(this.buffer)}}const zm=Pm(()=>new Bm);function qm(e){const{commitment:t,version:r=1}=e,n=e.to??("string"==typeof t?"hex":"bytes"),i=function(e){return zm(kf(e,{strict:!1})?jf(e):e)}(t);return i.set([r],0),"bytes"===n?i:Of(i)}const $m=4096,Gm=131072,Wm=761855;class Vm extends bf{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class Hm extends bf{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class Ym extends bf{constructor({hash:e,size:t}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`],name:"InvalidVersionedHashSizeError"})}}class Zm extends bf{constructor({hash:e,version:t}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:["Expected: 1",`Received: ${t}`],name:"InvalidVersionedHashVersionError"})}}function Km(e){const{data:t,kzg:r,to:n}=e,i=e.blobs??function(e){const t=e.to??("string"==typeof e.data?"hex":"bytes"),r="string"==typeof e.data?Lf(e.data):e.data,n=Sf(r);if(!n)throw new Hm;if(n>Wm)throw new Vm({maxSize:Wm,size:n});const i=[];let o=!0,s=0;for(;o;){const e=am(new Uint8Array(Gm));let t=0;for(;t<$m;){const n=r.slice(s,s+31);if(e.pushByte(0),e.pushBytes(n),n.length<31){e.pushByte(128),o=!1;break}t++,s+=31}i.push(e)}return"bytes"===t?i.map(e=>e.bytes):i.map(e=>Of(e.bytes))}({data:t,to:n}),o=e.commitments??ym({blobs:i,kzg:r,to:n}),s=e.proofs??vm({blobs:i,commitments:o,kzg:r,to:n}),a=[];for(let c=0;c<i.length;c++)a.push({blob:i[c],commitment:o[c],proof:s[c]});return a}class Jm extends bf{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class Xm extends bf{constructor({chainId:e}){super("number"==typeof e?`Chain ID "${e}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}class Qm extends bf{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${hm(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Qm,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class eg extends bf{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${hm(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${hm(r)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(eg,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class tg extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const rg=BigInt(0),ng=BigInt(1),ig=BigInt(2),og=BigInt(7),sg=BigInt(256),ag=BigInt(113),cg=[],lg=[],ug=[];for(let Yy=0,Zy=ng,Ky=1,Jy=0;Yy<24;Yy++){[Ky,Jy]=[Jy,(2*Ky+3*Jy)%5],cg.push(2*(5*Jy+Ky)),lg.push((Yy+1)*(Yy+2)/2%64);let e=rg;for(let t=0;t<7;t++)Zy=(Zy<<ng^(Zy>>og)*ag)%sg,Zy&ig&&(e^=ng<<(ng<<BigInt(t))-ng);ug.push(e)}const dg=function(e,t=!1){const r=e.length;let n=new Uint32Array(r),i=new Uint32Array(r);for(let o=0;o<r;o++){const{h:r,l:s}=Fm(e[o],t);[n[o],i[o]]=[r,s]}return[n,i]}(ug,!0),hg=dg[0],pg=dg[1],fg=(e,t,r)=>r>32?((e,t,r)=>t<<r-32|e>>>64-r)(e,t,r):((e,t,r)=>e<<r|t>>>32-r)(e,t,r),mg=(e,t,r)=>r>32?((e,t,r)=>e<<r-32|t>>>64-r)(e,t,r):((e,t,r)=>t<<r|e>>>32-r)(e,t,r);class gg extends Am{constructor(e,t,r,n=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,bm(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");var o;this.state=new Uint8Array(200),this.state32=(o=this.state,new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)))}clone(){return this._cloneInto()}keccak(){Em(this.state32),function(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let n=0;n<10;n++)r[n]=e[n]^e[n+10]^e[n+20]^e[n+30]^e[n+40];for(let n=0;n<10;n+=2){const t=(n+8)%10,i=(n+2)%10,o=r[i],s=r[i+1],a=fg(o,s,1)^r[t],c=mg(o,s,1)^r[t+1];for(let r=0;r<50;r+=10)e[n+r]^=a,e[n+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){const n=lg[r],o=fg(t,i,n),s=mg(t,i,n),a=cg[r];t=e[a],i=e[a+1],e[a]=o,e[a+1]=s}for(let n=0;n<50;n+=10){for(let t=0;t<10;t++)r[t]=e[n+t];for(let t=0;t<10;t++)e[n+t]^=~r[(t+2)%10]&r[(t+4)%10]}e[0]^=hg[n],e[1]^=pg[n]}km(r)}(this.state32,this.rounds),Em(this.state32),this.posOut=0,this.pos=0}update(e){xm(this),wm(e=Nm(e));const{blockLen:t,state:r}=this,n=e.length;for(let i=0;i<n;){const o=Math.min(t-this.pos,n-i);for(let t=0;t<o;t++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:n}=this;e[r]^=t,128&t&&r===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){xm(this,!1),wm(e),this.finish();const t=this.state,{blockLen:r}=this;for(let n=0,i=e.length;n<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return bm(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(_m(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,km(this.state)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return e||(e=new gg(t,r,n,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}const yg=(()=>{return e=1,t=136,r=32,Pm(()=>new gg(t,e,r));var e,t,r})();const vg=new tg(8192);function bg(e,t){if(vg.has(`${e}.${t}`))return vg.get(`${e}.${t}`);const r=e.substring(2).toLowerCase(),n=function(e){return yg(kf(e,{strict:!1})?jf(e):e)}(Uf(r)),i=r.split("");for(let s=0;s<40;s+=2)n[s>>1]>>4>=8&&i[s]&&(i[s]=i[s].toUpperCase()),(15&n[s>>1])>=8&&i[s+1]&&(i[s+1]=i[s+1].toUpperCase());const o=`0x${i.join("")}`;return vg.set(`${e}.${t}`,o),o}const wg=/^0x[a-fA-F0-9]{40}$/,xg=new tg(8192);function _g(e,t){const{strict:r=!0}=t??{},n=`${e}.${r}`;if(xg.has(n))return xg.get(n);const i=!(!wg.test(e)||e.toLowerCase()!==e&&r&&bg(e)!==e);return xg.set(n,i),i}function kg(e,t,r,{strict:n}={}){return kf(e,{strict:!1})?function(e,t,r,{strict:n}={}){const i=`0x${e.replace("0x","").slice(2*t,2*r)}`;n&&Sg(i,t,r);return i}(e,t,r,{strict:n}):function(e,t,r,{strict:n}={}){const i=e.slice(t,r);n&&Sg(i,t,r);return i}(e,t,r,{strict:n})}function Sg(e,t,r){if(Sf(e)!==r-t)throw new If({offset:r,position:"end",size:Sf(e)})}function Cg(e){const{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:i}=e;if(t<=0)throw new Xm({chainId:t});if(i&&!_g(i))throw new Jm({address:i});if(n&&n>tm)throw new Qm({maxFeePerGas:n});if(r&&n&&r>n)throw new eg({maxFeePerGas:n,maxPriorityFeePerGas:r})}function Ig(e){if(!e||0===e.length)return[];const t=[];for(let r=0;r<e.length;r++){const{address:n,storageKeys:i}=e[r];for(let e=0;e<i.length;e++)if(i[e].length-2!=64)throw new gm({storageKey:i[e]});if(!_g(n,{strict:!1}))throw new Jm({address:n});t.push([n,i])}return t}function Eg(e,t){const r=function(e){if(e.type)return e.type;if(void 0!==e.authorizationList)return"eip7702";if(void 0!==e.blobs||void 0!==e.blobVersionedHashes||void 0!==e.maxFeePerBlobGas||void 0!==e.sidecars)return"eip4844";if(void 0!==e.maxFeePerGas||void 0!==e.maxPriorityFeePerGas)return"eip1559";if(void 0!==e.gasPrice)return void 0!==e.accessList?"eip2930":"legacy";throw new mm({transaction:e})}(e);return"eip1559"===r?function(e,t){const{chainId:r,gas:n,nonce:i,to:o,value:s,maxFeePerGas:a,maxPriorityFeePerGas:c,accessList:l,data:u}=e;Cg(e);const d=Ig(l),h=[Mf(r),i?Mf(i):"0x",c?Mf(c):"0x",a?Mf(a):"0x",n?Mf(n):"0x",o??"0x",s?Mf(s):"0x",u??"0x",d,...Ng(e,t)];return rm(["0x02",cm(h)])}(e,t):"eip2930"===r?function(e,t){const{chainId:r,gas:n,data:i,nonce:o,to:s,value:a,accessList:c,gasPrice:l}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:o}=e;if(t<=0)throw new Xm({chainId:t});if(o&&!_g(o))throw new Jm({address:o});if(r||i)throw new bf("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>tm)throw new Qm({maxFeePerGas:n})}(e);const u=Ig(c),d=[Mf(r),o?Mf(o):"0x",l?Mf(l):"0x",n?Mf(n):"0x",s??"0x",a?Mf(a):"0x",i??"0x",u,...Ng(e,t)];return rm(["0x01",cm(d)])}(e,t):"eip4844"===r?function(e,t){const{chainId:r,gas:n,nonce:i,to:o,value:s,maxFeePerBlobGas:a,maxFeePerGas:c,maxPriorityFeePerGas:l,accessList:u,data:d}=e;!function(e){const{blobVersionedHashes:t}=e;if(t){if(0===t.length)throw new Hm;for(const e of t){const t=Sf(e),r=qf(kg(e,0,1));if(32!==t)throw new Ym({hash:e,size:t});if(1!==r)throw new Zm({hash:e,version:r})}}Cg(e)}(e);let h=e.blobVersionedHashes,p=e.sidecars;if(e.blobs&&(void 0===h||void 0===p)){const t="string"==typeof e.blobs[0]?e.blobs:e.blobs.map(e=>Of(e)),r=e.kzg,n=ym({blobs:t,kzg:r});if(void 0===h&&(h=function(e){const{commitments:t,version:r}=e,n=e.to??("string"==typeof t[0]?"hex":"bytes"),i=[];for(const o of t)i.push(qm({commitment:o,to:n,version:r}));return i}({commitments:n})),void 0===p){p=Km({blobs:t,commitments:n,proofs:vm({blobs:t,commitments:n,kzg:r})})}}const f=Ig(u),m=[Mf(r),i?Mf(i):"0x",l?Mf(l):"0x",c?Mf(c):"0x",n?Mf(n):"0x",o??"0x",s?Mf(s):"0x",d??"0x",f,a?Mf(a):"0x",h??[],...Ng(e,t)],g=[],y=[],v=[];if(p)for(let b=0;b<p.length;b++){const{blob:e,commitment:t,proof:r}=p[b];g.push(e),y.push(t),v.push(r)}return rm(["0x03",cm(p?[m,g,y,v]:m)])}(e,t):"eip7702"===r?function(e,t){const{authorizationList:r,chainId:n,gas:i,nonce:o,to:s,value:a,maxFeePerGas:c,maxPriorityFeePerGas:l,accessList:u,data:d}=e;!function(e){const{authorizationList:t}=e;if(t)for(const r of t){const{chainId:e}=r,t=r.address;if(!_g(t))throw new Jm({address:t});if(e<0)throw new Xm({chainId:e})}Cg(e)}(e);const h=Ig(u),p=function(e){if(!e||0===e.length)return[];const t=[];for(const r of e){const{chainId:e,nonce:n,...i}=r,o=r.address;t.push([e?Pf(e):"0x",o,n?Pf(n):"0x",...Ng({},i)])}return t}(r);return rm(["0x04",cm([Mf(n),o?Mf(o):"0x",l?Mf(l):"0x",c?Mf(c):"0x",i?Mf(i):"0x",s??"0x",a?Mf(a):"0x",d??"0x",h,p,...Ng(e,t)])])}(e,t):function(e,t){const{chainId:r=0,gas:n,data:i,nonce:o,to:s,value:a,gasPrice:c}=e;!function(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:o}=e;if(o&&!_g(o))throw new Jm({address:o});if(void 0!==t&&t<=0)throw new Xm({chainId:t});if(r||i)throw new bf("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>tm)throw new Qm({maxFeePerGas:n})}(e);let l=[o?Mf(o):"0x",c?Mf(c):"0x",n?Mf(n):"0x",s??"0x",a?Mf(a):"0x",i??"0x"];if(t){const e=(()=>{if(t.v>=35n){return(t.v-35n)/2n>0?t.v:27n+(35n===t.v?0n:1n)}if(r>0)return BigInt(2*r)+BigInt(35n+t.v-27n);const e=27n+(27n===t.v?0n:1n);if(t.v!==e)throw new fm({v:t.v});return e})(),n=Cf(t.r),i=Cf(t.s);l=[...l,Mf(e),"0x00"===n?"0x":n,"0x00"===i?"0x":i]}else r>0&&(l=[...l,Mf(r),"0x","0x"]);return cm(l)}(e,t)}function Ng(e,t){const r=t??e,{v:n,yParity:i}=r;if(void 0===r.r)return[];if(void 0===r.s)return[];if(void 0===n&&void 0===i)return[];const o=Cf(r.r),s=Cf(r.s);return["number"==typeof i?i?Mf(1):"0x":0n===n?"0x":1n===n?Mf(1):27n===n?"0x":Mf(1),"0x00"===o?"0x":o,"0x00"===s?"0x":s]}const Ag={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};function Pg(e,t){return function(e){return"deposit"===e.type||void 0!==e.sourceHash}(e)?function(e){!function(e){const{from:t,to:r}=e;if(t&&!_g(t))throw new Jm({address:t});if(r&&!_g(r))throw new Jm({address:r})}(e);const{sourceHash:t,data:r,from:n,gas:i,isSystemTx:o,mint:s,to:a,value:c}=e,l=[t,n,a??"0x",s?Pf(s):"0x",c?Pf(c):"0x",i?Pf(i):"0x",o?"0x1":"0x",r??"0x"];return rm(["0x7e",cm(l)])}(e):Eg(e,t)}const Og={blockTime:2e3,contracts:Ag,formatters:{block:Yf({format(e){var t;return{transactions:null==(t=e.transactions)?void 0:t.map(e=>{if("string"==typeof e)return e;const t=Wf(e);return"0x7e"===t.typeHex&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?zf(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}),stateRoot:e.stateRoot}}}),transaction:Vf({format(e){const t={};return"0x7e"===e.type&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?zf(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Jf({format:e=>({l1GasPrice:e.l1GasPrice?zf(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?zf(e.l1GasUsed):null,l1Fee:e.l1Fee?zf(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null})})},serializers:{transaction:Pg}},Mg=gf({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:250,rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),Tg=gf({id:43114,name:"Avalanche",blockTime:1700,nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{default:{name:"SnowTrace",url:"https://snowtrace.io",apiUrl:"https://api.snowtrace.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:11907934}}}),Rg=1,jg=gf({...Og,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...Og.contracts,disputeGameFactory:{[Rg]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[Rg]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[Rg]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[Rg]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:1}),Dg=gf({id:56,name:"BNB Smart Chain",blockTime:750,nativeCurrency:{decimals:18,name:"BNB",symbol:"BNB"},rpcUrls:{default:{http:["https://56.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com",apiUrl:"https://api.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15921452}}}),Fg={estimateFeesPerGas:async e=>{var t;if(!(null==(t=e.request)?void 0:t.feeCurrency))return null;const[r,n]=await Promise.all([Lg(e.client,e.request.feeCurrency),Ug(e.client,e.request.feeCurrency)]);return{maxFeePerGas:e.multiply(r-n)+n,maxPriorityFeePerGas:n}}};async function Lg(e,t){const r=await e.request({method:"eth_gasPrice",params:[t]});return BigInt(r)}async function Ug(e,t){const r=await e.request({method:"eth_maxPriorityFeePerGas",params:[t]});return BigInt(r)}function Bg(e){return 0===e||0n===e||null==e||"0"===e||""===e||"string"==typeof e&&("0x"===Cf(e).toLowerCase()||"0x00"===Cf(e).toLowerCase())}function zg(e){return!Bg(e)}function qg(e){return"cip64"===e.type||function(e){return void 0!==e.maxFeePerGas&&void 0!==e.maxPriorityFeePerGas}(e)&&zg(e.feeCurrency)}const $g={transaction:function(e,t){return qg(e)?function(e,t){!function(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:o,feeCurrency:s}=e;if(t<=0)throw new Xm({chainId:t});if(o&&!_g(o))throw new Jm({address:o});if(n)throw new bf("`gasPrice` is not a valid CIP-64 Transaction attribute.");if(zg(i)&&i>Gg)throw new Qm({maxFeePerGas:i});if(zg(r)&&zg(i)&&r>i)throw new eg({maxFeePerGas:i,maxPriorityFeePerGas:r});if(zg(s)&&!_g(s))throw new bf("`feeCurrency` MUST be a token address for CIP-64 transactions.");if(Bg(s))throw new bf("`feeCurrency` must be provided for CIP-64 transactions.")}(e);const{chainId:r,gas:n,nonce:i,to:o,value:s,maxFeePerGas:a,maxPriorityFeePerGas:c,accessList:l,feeCurrency:u,data:d}=e,h=[Pf(r),i?Pf(i):"0x",c?Pf(c):"0x",a?Pf(a):"0x",n?Pf(n):"0x",o??"0x",s?Pf(s):"0x",d??"0x",Ig(l),u,...Ng(e,t)];return rm(["0x7b",cm(h)])}(e,t):Pg(e,t)}};const Gg=tm;const Wg=gf({...{blockTime:1e3,contracts:Ag,formatters:{block:Yf({format(e){var t;return{transactions:null==(t=e.transactions)?void 0:t.map(e=>{if("string"==typeof e)return e;return{...Wf(e),...e.gatewayFee?{gatewayFee:zf(e.gatewayFee),gatewayFeeRecipient:e.gatewayFeeRecipient}:{},feeCurrency:e.feeCurrency}})}}}),transaction:Vf({format(e){if("0x7e"===e.type)return{isSystemTx:e.isSystemTx,mint:e.mint?zf(e.mint):void 0,sourceHash:e.sourceHash,type:"deposit"};const t={feeCurrency:e.feeCurrency};return"0x7b"===e.type?t.type="cip64":("0x7c"===e.type&&(t.type="cip42"),t.gatewayFee=e.gatewayFee?zf(e.gatewayFee):null,t.gatewayFeeRecipient=e.gatewayFeeRecipient),t}}),transactionRequest:em({format(e){const t={};return e.feeCurrency&&(t.feeCurrency=e.feeCurrency),qg(e)&&(t.type="0x7b"),t}})},serializers:$g,fees:Fg},id:42220,name:"Celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://celoscan.io",apiUrl:"https://api.celoscan.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:13112599}},testnet:!1}),Vg=gf({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),Hg=1,Yg=gf({...Og,id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimism Explorer",url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io/api"}},contracts:{...Og.contracts,disputeGameFactory:{[Hg]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[Hg]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[Hg]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[Hg]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId:1}),Zg=gf({id:137,name:"Polygon",blockTime:2e3,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}}),Kg=(e,t,r=!1)=>{if(!e||"string"!=typeof e)throw new Error(`Missing ${t} address`);if(!e.startsWith("0x"))throw new Error(`Invalid ${t} address format: must start with 0x`);if(42!==e.length)throw new Error(`Invalid ${t} address length: expected 42 characters, got ${e.length}`);if("0x0000000000000000000000000000000000000000"===e&&!r)throw new Error(`Invalid ${t} address: cannot be zero address`)},Jg=e=>{const t=(e=>{Kg(e.token,"token"),Kg(e.recipient1,"recipient1"),Kg(e.recipient2,"recipient2");const t=0n===BigInt(e.recipient3Percentage||0);if(Kg(e.recipient3,"recipient3",t),!e.paymentId||"string"!=typeof e.paymentId||0===e.paymentId.length)throw new Error("Invalid payment ID: must be a non-empty string");let r,n,i,o;try{r=BigInt(e.amount||0),n=BigInt(e.recipient1Percentage||0),i=BigInt(e.recipient2Percentage||0),o=BigInt(e.recipient3Percentage||0)}catch(a){throw new Error("Invalid numeric values: cannot convert to BigInt")}if(r<=0n)throw new Error(`Invalid amount: ${e.amount} (must be greater than 0)`);const s=n+i+o;if(10000n!==s)throw new Error(`Invalid percentages: total is ${s} but must equal 10000 basis points (100%). Individual: ${n}, ${i}, ${o}`);return{amount:r,percentage1:n,percentage2:i,percentage3:o}})(e);return{token:e.token,amount:t.amount,paymentId:e.paymentId,recipient1:e.recipient1,recipient2:e.recipient2,recipient3:e.recipient3,recipient1Percentage:t.percentage1,recipient2Percentage:t.percentage2,recipient3Percentage:t.percentage3}},Xg=[{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"}],Qg=[{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],ey=e=>{var t,r;const n=(null==(t=null==e?void 0:e.message)?void 0:t.toLowerCase())||(null==(r=null==e?void 0:e.toString())?void 0:r.toLowerCase())||"",i=(null==e?void 0:e.code)||(null==e?void 0:e.reason)||"";return n.includes("user rejected")||n.includes("user denied")||n.includes("user cancelled")||n.includes("rejected by user")||4001===i||"ACTION_REJECTED"===i?{type:"user_rejected",title:"Transaction Cancelled",message:"You cancelled the transaction. No charges were made.",suggestion:'Click "Pay Now" to try again when you\'re ready.'}:n.includes("insufficient funds")||n.includes("insufficient balance")||n.includes("insufficient eth")||n.includes("insufficient matic")||n.includes("insufficient bnb")||-32e3===i?{type:"insufficient_funds",title:"Insufficient Funds",message:"You don't have enough tokens or gas fees in your wallet.",suggestion:"Add more funds to your wallet and try again."}:n.includes("network error")||n.includes("rpc error")||n.includes("connection failed")||n.includes("timeout")||n.includes("request failed")?{type:"network_error",title:"Network Error",message:"Unable to connect to the blockchain network.",suggestion:"Check your internet connection and try again."}:n.includes("wrong network")||n.includes("unsupported network")||n.includes("chain mismatch")||4902===i?{type:"wrong_network",title:"Wrong Network",message:"Please switch to the correct network in your wallet.",suggestion:"Your wallet should prompt you to switch networks."}:n.includes("wallet not connected")||n.includes("no provider")||n.includes("wallet disconnected")||4900===i?{type:"wallet_disconnected",title:"Wallet Disconnected",message:"Your wallet is not connected.",suggestion:"Please reconnect your wallet and try again."}:n.includes("gas estimation failed")||n.includes("execution reverted")||n.includes("out of gas")?{type:"gas_error",title:"Transaction Failed",message:"The transaction couldn't be processed.",suggestion:"This might be a temporary issue. Please try again."}:n.includes("approve")&&n.includes("failed")?{type:"approval_failed",title:"Token Approval Failed",message:"Failed to approve token spending.",suggestion:"Please try the approval step again."}:n.includes("transaction failed")||n.includes("revert")||n.includes("contract call failed")?{type:"transaction_failed",title:"Transaction Failed",message:"The blockchain transaction was unsuccessful.",suggestion:"Please check your wallet and try again."}:n.includes("popup")||n.includes("blocked")?{type:"popup_blocked",title:"Wallet Popup Blocked",message:"Your browser blocked the wallet popup.",suggestion:"Please allow popups for this site and try again."}:n.includes("rate limit")||n.includes("too many requests")?{type:"rate_limited",title:"Too Many Requests",message:"Please wait a moment before trying again.",suggestion:"Wait 30 seconds and retry your transaction."}:n.includes("payment not yet confirmed")||n.includes("not yet confirmed on-chain")||n.includes("payment not found on-chain")||n.includes("please complete the payment")?{type:"payment_pending",title:"Payment Pending",message:"Your payment is still being confirmed on the blockchain.",suggestion:"Please wait a moment and try again, or check if your transaction completed successfully."}:n.includes("deep link")||n.includes("app not installed")||n.includes("wallet app")?{type:"mobile_wallet_error",title:"Wallet App Issue",message:"Unable to open or connect to your wallet app.",suggestion:"Make sure your wallet app is installed and try again."}:{type:"unknown_error",title:"Something Went Wrong",message:"An unexpected error occurred.",suggestion:"Please try again or contact support if the problem persists."}},ty=(e,t="")=>({timestamp:(new Date).toISOString(),context:t,userFriendly:ey(e),technical:{message:(null==e?void 0:e.message)||"Unknown error",code:null==e?void 0:e.code,reason:null==e?void 0:e.reason,stack:null==e?void 0:e.stack,name:null==e?void 0:e.name}}),ry=async(e,t)=>{try{const r=await o.estimateFeesPerGas(e,{chainId:t}),n=120n,i=100n;return{maxFeePerGas:r.maxFeePerGas?r.maxFeePerGas*n/i:void 0,maxPriorityFeePerGas:r.maxPriorityFeePerGas?r.maxPriorityFeePerGas*n/i:void 0}}catch(gu){return{}}},ny="YWG990wOlIikc1tU7-WWTepfU8d1f4dp",iy=(e,t,i,s,a,l)=>{const[u,d]=r.useState("idle"),[h,p]=r.useState(""),[f,m]=r.useState(null),{data:g,isPending:y,error:v,sendTransaction:b}=n.useSendTransaction(),{isLoading:w,isSuccess:x}=n.useWaitForTransactionReceipt({hash:g}),_=async()=>{var e,t,r,n,i,s,c;try{d("splitPayment");const h=window.coinleyPendingSplitPayment;if(!h)throw new Error("Missing split payment data");const{contractCall:p,selectedToken:f,paymentData:g,selectedNetwork:y}=h,v=y.chainId||10,b=await a.getContractInfo(v),{abi:w}=b,x=Jg(p.params),_=ff(v),k=1===_,S=k||43114===_;try{const{request:e}=await o.simulateContract(df,{address:p.contractAddress,abi:w,functionName:"splitPayment",args:[x]})}catch(l){const i=l.data||(null==(e=l.cause)?void 0:e.data);i&&("string"==typeof i&&i.startsWith("0x08c379a0")||"string"==typeof i&&i.startsWith("0x4e487b71"));l.reason||(null==(t=l.cause)?void 0:t.reason)||(null==(r=l.cause)?void 0:r.shortMessage)||(null==(n=l.data)||n.message);if(!S){const{userFriendlyMessage:e}=(e=>{if(!e.message)return{revertReason:"Transaction will revert",userFriendlyMessage:"Transaction simulation failed"};const t=e.message.toLowerCase();return t.includes("abi encoding params/values length mismatch")?{revertReason:"Smart contract parameter mismatch. This is likely a technical issue.",userFriendlyMessage:"Technical error: Contract parameters mismatch. Please try again or contact support."}:t.includes("payment id already used")?{revertReason:"This payment ID has already been used.",userFriendlyMessage:"This payment has already been processed. Please check your transaction history."}:t.includes("percentages must equal 100")?{revertReason:"Payment split percentages are incorrect.",userFriendlyMessage:"Internal error: Payment split configuration is invalid. Please contact support."}:t.includes("token transfer failed")||t.includes("transfer amount exceeds")?{revertReason:"Insufficient token balance or approval.",userFriendlyMessage:"Insufficient balance or token approval. Please check your wallet balance."}:t.includes("amount must be greater than 0")?{revertReason:"Payment amount is invalid.",userFriendlyMessage:"Invalid payment amount. Please try again."}:t.includes("invalid recipient")||t.includes("zero address")?{revertReason:"One of the payment recipients has an invalid address.",userFriendlyMessage:"Payment configuration error: Invalid recipient address. Please contact support."}:t.includes("insufficient gas")||t.includes("out of gas")?{revertReason:"Insufficient gas for transaction.",userFriendlyMessage:"Not enough gas to process transaction. Please increase gas limit or check ETH balance."}:t.includes("nonce")?{revertReason:"Transaction nonce conflict.",userFriendlyMessage:"Transaction ordering conflict. Please try again in a moment."}:{revertReason:e.message,userFriendlyMessage:`Transaction simulation failed: ${e.message.substring(0,100)}${e.message.length>100?"...":""}`}})(l);throw new Error(e)}}const C=await ry(df,v),I="arbitrum"===y.shortName,E=I?2:0;let N;for(let e=0;e<=E;e++)try{if(e>0){const t=2e3*e;await new Promise(e=>setTimeout(e,t))}N=await o.writeContract(df,{address:p.contractAddress,abi:w,functionName:"splitPayment",args:[x],...C});break}catch(u){const t=(null==(i=u.message)?void 0:i.includes("Internal JSON-RPC error"))||(null==(s=u.message)?void 0:s.includes("-32603"))||(null==(c=u.message)?void 0:c.includes("nonce"));if(e===E||!t&&!I)throw u}return m(N),d("processing"),window.coinleyPendingSplitPayment=null,N}catch(gu){ty(gu,"split_payment_transaction");const t=ey(gu);throw p(t),d("error"),gu}},k=async r=>{try{if(d("processing"),!a||!a.processPayment)throw new Error("API instance not available or missing processPayment method");await new Promise(e=>setTimeout(e,8e3));const n=await a.processPayment(e.id,r,i.shortName,s);return d("success"),af.trackPaymentSuccess(e.id,e.amount,null==i?void 0:i.shortName,null==t?void 0:t.symbol,r),n}catch(gu){ty(gu,"final_payment_processing");const n=ey(gu);throw p(n),d("error"),af.trackPaymentFailed(null==e?void 0:e.id,null==e?void 0:e.amount,null==i?void 0:i.shortName,null==t?void 0:t.symbol,n),gu}};return{transactionStep:u,transactionError:h,currentTransactionHash:f,txPending:y,isConfirming:w,isConfirmed:x,executePaymentTransaction:async()=>{var r,n;if(!s||!(null==e?void 0:e.contractCall))throw new Error("Missing wallet connection or payment data");const a=e.contractCall;if(!a.contractAddress)throw new Error("PaymentSplitter contract data missing from payment response");if((null==l?void 0:l.ensureCorrectNetwork)&&i){if(!(await l.ensureCorrectNetwork(i)))throw new Error("Network verification failed. Please ensure you are on the correct network.")}if(!t.contractAddress)throw new Error("Native token transactions not yet supported with PaymentSplitter. Please use ERC-20 tokens.");{const l=t.decimals||6,b=a.approvalAmount||Math.floor(e.totalAmount*Math.pow(10,l));try{let e,r="unknown";try{e=await o.readContract(df,{address:a.tokenAddress,abi:Qg,functionName:"balanceOf",args:[s]}),r="wallet-rpc"}catch(u){const t=(null==i?void 0:i.chainId)||(null==i?void 0:i.id);if(!t)throw u;{const n=(e=>{const t={1:Vg,56:Dg,137:Zg,42161:Mg,10:Yg,43114:Tg,42220:Wg,8453:jg}[e],r={1:[`https://eth-mainnet.g.alchemy.com/v2/${ny}`,"https://cloudflare-eth.com","https://eth.llamarpc.com","https://ethereum.publicnode.com"],56:[`https://bnb-mainnet.g.alchemy.com/v2/${ny}`,"https://bsc-dataseed.bnbchain.org","https://bsc-dataseed-public.bnbchain.org","https://bsc.nodereal.io"],137:[`https://polygon-mainnet.g.alchemy.com/v2/${ny}`,"https://polygon.llamarpc.com","https://polygon-rpc.com","https://polygon.drpc.org"],42161:[`https://arb-mainnet.g.alchemy.com/v2/${ny}`,"https://arb1.arbitrum.io/rpc","https://arbitrum.llamarpc.com"],10:[`https://opt-mainnet.g.alchemy.com/v2/${ny}`,"https://mainnet.optimism.io","https://optimism.llamarpc.com"],43114:[`https://avax-mainnet.g.alchemy.com/v2/${ny}`,"https://api.avax.network/ext/bc/C/rpc","https://avalanche.public-rpc.com"],42220:[`https://celo-mainnet.g.alchemy.com/v2/${ny}`,"https://forno.celo.org","https://celo.drpc.org"],8453:[`https://base-mainnet.g.alchemy.com/v2/${ny}`,"https://mainnet.base.org","https://base.llamarpc.com","https://base.meowrpc.com"]}[e];if(!t||!r)return null;const n=r.map(e=>c.http(e,{timeout:1e4,retryCount:1}));return c.createPublicClient({chain:t,transport:c.fallback(n)})})(ff(t));if(!n)throw u;try{e=await n.readContract({address:a.tokenAddress,abi:Qg,functionName:"balanceOf",args:[s]}),r="fallback-rpc"}catch(h){throw u}}}const n=BigInt(b);if(e<n){const r=`Insufficient ${t.symbol} balance. You have ${(Number(e)/Math.pow(10,l)).toFixed(6)} ${t.symbol} but need ${(Number(n)/Math.pow(10,l)).toFixed(6)} ${t.symbol}`;throw new Error(r)}}catch(f){if(f.message.includes("Insufficient"))throw f}d("approve"),window.coinleyPendingSplitPayment={contractCall:a,selectedToken:t,paymentData:e,selectedNetwork:i};try{const e="0xdac17f958d2ee523a2206206994597c13d831ec7"===a.tokenAddress.toLowerCase()||"USDT"===t.symbol.toUpperCase();let r,n=c.erc20Abi;e&&(n=Xg);try{r=BigInt(b)}catch(g){throw new Error(`Invalid amount value: ${b}`)}let l=0n,u=0;const h=3;for(;u<h;)try{l=await o.readContract(df,{address:a.tokenAddress,abi:c.erc20Abi,functionName:"allowance",args:[s,a.contractAddress]});break}catch(y){u++,u<h?await new Promise(e=>setTimeout(e,2e3)):l=0n}if(l>=r){d("splitPayment");const e=await _();return e&&await k(e),e}if(e&&l>0n){const e=await ry(df,i.chainId),t=await o.writeContract(df,{address:a.tokenAddress,abi:c.erc20Abi,functionName:"approve",args:[a.contractAddress,0n],...e});await o.waitForTransactionReceipt(df,{hash:t,confirmations:1,timeout:12e4})}const p=await ry(df,i.chainId),f=await o.writeContract(df,{address:a.tokenAddress,abi:c.erc20Abi,functionName:"approve",args:[a.contractAddress,r],...p});m(f);await o.waitForTransactionReceipt(df,{hash:f,confirmations:1,timeout:12e4});await new Promise(e=>setTimeout(e,3e3));let w=0;const x=3;let S=!1;for(;w<x&&!S;){try{if(await o.readContract(df,{address:a.tokenAddress,abi:c.erc20Abi,functionName:"allowance",args:[s,a.contractAddress]})>=r){S=!0;break}w<x-1&&await new Promise(e=>setTimeout(e,2e3))}catch(v){w<x-1&&await new Promise(e=>setTimeout(e,2e3))}w++}const C=await _();return C&&await k(C),C}catch(gu){ty(gu,"approve_transaction");const t=ey(gu);if(p(t),d("idle"),(null==(r=gu.message)?void 0:r.includes("User rejected"))||(null==(n=gu.message)?void 0:n.includes("User denied"))||4001===gu.code)throw new Error("Transaction was cancelled by user");throw new Error(`Approve failed: ${gu.message}`)}}},executeSplitPayment:_,processFinalPayment:k,resetTransaction:()=>{d("idle"),p(""),m(null),window.coinleyPendingSplitPayment=null},setTransactionError:p,setTransactionStep:d}},oy=({options:e=[],value:n,onChange:i,placeholder:o,renderOption:s,getOptionKey:a,getOptionValue:c,getSearchableText:u,disabled:d=!1})=>{const[h,p]=r.useState(!1),[f,m]=r.useState(""),[g,y]=r.useState({top:0,left:0,width:400,maxHeight:450}),v=r.useRef(null),b=r.useRef(null),w=e.filter(e=>(u?u(e):"").toLowerCase().includes(f.toLowerCase())),x=e.find(e=>c(e)===n),_=()=>{if(b.current){const e=window.innerWidth,t=window.innerHeight,r=Math.min(400,e-40),n=Math.min(450,t-100);y({top:t/2-n/2,left:e/2-r/2,width:r,maxHeight:n})}};r.useEffect(()=>{const e=e=>{v.current&&!v.current.contains(e.target)&&b.current&&!b.current.contains(e.target)&&(p(!1),m(""))},t=()=>{h&&_()};if(h){_();const r=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${r}px`,document.body.style.width="100%",document.addEventListener("mousedown",e),window.addEventListener("resize",t)}return()=>{if(h){const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",window.scrollTo(0,-1*parseInt(e||"0"))}document.removeEventListener("mousedown",e),window.removeEventListener("resize",t)}},[h]);const k=h&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-30 transition-opacity",style:{zIndex:999998},onClick:()=>{p(!1),m("")}}),t.jsxs("div",{ref:v,className:"fixed bg-white border-2 border-gray-200 rounded-3xl shadow-2xl overflow-hidden",style:{top:g.top,left:g.left,width:g.width,maxHeight:g.maxHeight,zIndex:999999,transform:"translateZ(0)",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05)"},children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 bg-gradient-to-r from-[#7042D2]/10 to-purple-50",children:[t.jsx("h3",{className:"text-lg font-semibold text-[#7042D2]",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:o||"Select Option"}),t.jsx("button",{onClick:()=>{p(!1),m("")},className:"text-gray-500 hover:text-gray-700 transition-colors p-1 rounded-full hover:bg-gray-100",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"p-4 border-b border-gray-200 bg-gray-50",children:t.jsx("input",{type:"text",placeholder:"Search networks and tokens...",value:f,onChange:e=>m(e.target.value),className:"w-full p-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-[#7042D2]/20 focus:border-[#7042D2] text-sm",style:{fontFamily:"Bricolage Grotesque, sans-serif"},autoFocus:!0})}),t.jsx("div",{className:"overflow-y-auto custom-scrollbar",style:{maxHeight:(g.maxHeight||450)-180+"px",minHeight:"200px"},children:0===w.length?t.jsxs("div",{className:"p-8 text-gray-500 text-center",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[t.jsx("div",{className:"text-4xl mb-3",children:"๐"}),t.jsx("div",{className:"text-lg mb-2",children:"No options found"}),t.jsx("div",{className:"text-sm text-gray-400",children:"Try a different search term"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-4 py-3 bg-gray-50 border-b border-gray-100 text-sm text-gray-600",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[t.jsx("span",{className:"font-semibold",children:w.length})," option",1!==w.length?"s":""," available"]}),t.jsx("div",{className:"p-2",children:w.map(e=>t.jsx("button",{type:"button",onClick:()=>{i(c(e)),p(!1),m("")},className:"w-full p-4 text-left hover:bg-[#7042D2]/10 transition-all duration-200 rounded-xl mb-2 last:mb-0 "+(c(e)===n?"bg-[#7042D2]/20 text-[#7042D2] border-2 border-[#7042D2]/30":"text-gray-800 border-2 border-transparent hover:border-[#7042D2]/20"),style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:s(e)},a(e)))})]})}),t.jsx("div",{className:"p-3 bg-gradient-to-r from-gray-50 to-gray-100 border-t border-gray-200 text-center",children:t.jsx("div",{className:"text-xs text-gray-500",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:w.length>5?"โ๏ธ Scroll to see more options":"โจ Select your preferred option"})})]})]});return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative",children:t.jsx("button",{ref:b,type:"button",onClick:()=>{d||(h||_(),p(!h))},disabled:d,className:`w-full p-4 border-2 rounded-2xl bg-gradient-to-r from-white to-gray-50 text-left focus:outline-none focus:ring-3 focus:ring-[#7042D2]/20 focus:border-[#7042D2] transition-all duration-300 ease-out shadow-lg hover:shadow-xl ${d?"opacity-50 cursor-not-allowed":"hover:border-[#7042D2]/50 cursor-pointer"} ${h?"border-[#7042D2] ring-3 ring-[#7042D2]/20":"border-gray-200"}`,style:{minHeight:"60px",fontFamily:"Bricolage Grotesque, sans-serif",fontSize:"16px",fontWeight:"500"},children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("div",{className:"flex items-center space-x-3",children:x?s(x):t.jsx("span",{className:"text-gray-500",children:o})}),t.jsx("div",{className:"transform transition-transform duration-200 "+(h?"rotate-180":""),children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-[#7042D2]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})})}),"undefined"!=typeof document&&document.body&&l.createPortal(k,document.body),t.jsx("style",{jsx:!0,children:"\n .custom-scrollbar {\n scrollbar-width: thin;\n scrollbar-color: #7042D2 #f1f1f1;\n }\n .custom-scrollbar::-webkit-scrollbar {\n width: 12px;\n }\n .custom-scrollbar::-webkit-scrollbar-track {\n background: #f8f9fa;\n border-radius: 10px;\n margin: 4px;\n }\n .custom-scrollbar::-webkit-scrollbar-thumb {\n background: linear-gradient(180deg, #7042D2 0%, #5b34b1 100%);\n border-radius: 10px;\n border: 2px solid #f8f9fa;\n }\n .custom-scrollbar::-webkit-scrollbar-thumb:hover {\n background: linear-gradient(180deg, #5b34b1 0%, #4c2a93 100%);\n }\n .custom-scrollbar::-webkit-scrollbar-corner {\n background: #f8f9fa;\n }\n "})]})},sy=({currentStep:e,targetStep:n,children:i,className:o="",duration:s=300})=>{const[a,c]=r.useState(e===n),[l,u]=r.useState(e===n);return r.useEffect(()=>{e===n?(u(!0),setTimeout(()=>c(!0),10)):(c(!1),setTimeout(()=>u(!1),s))},[e,n,s]),l?t.jsx("div",{className:`\n transition-all duration-300 ease-out\n ${a?"transform translate-y-0 opacity-100":"transform translate-y-full opacity-0"}\n ${o}\n `,style:{transitionDuration:`${s}ms`},children:i}):null},ay=({status:e,message:n,theme:i="light",payment:o=null,transactionHash:s=null,selectedPaymentMethod:a=null,selectedNetwork:c=null,merchantName:l="Merchant",onClose:u=null})=>{const[d,h]=r.useState(!1),[p,f]=r.useState(0);r.useEffect(()=>{if("processing"===e){const e=setInterval(()=>{f(e=>e>=90?e:e+15*Math.random())},500);return()=>clearInterval(e)}},[e]);const m=async()=>{if(s)try{await navigator.clipboard.writeText(s),h(!0),setTimeout(()=>h(!1),2e3)}catch(Hy){}},g=()=>{switch(e){case"processing":return t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-[#7042D2] border-blue-500/20"}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"w-6 h-6 bg-[#7042D2] rounded-full animate-pulse"})})]});case"success":return t.jsx("div",{className:"rounded-full h-16 w-16 bg-green-500 flex items-center justify-center animate-bounce",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return t.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}};return"processing"===e?t.jsxs("div",{className:"flex flex-col items-center justify-center py-6 px-4",children:[t.jsx("div",{className:"mb-6",children:g()}),t.jsx("h3",{className:"text-xl font-bold mb-3 text-gray-900",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Processing Payment"}),t.jsx("p",{className:"text-center text-gray-600 mb-6",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Your transaction has been sent to the blockchain and is being processed..."}),t.jsxs("div",{className:"w-full max-w-xs mb-4",children:[t.jsx("div",{className:"bg-gray-200 rounded-full h-3",children:t.jsx("div",{className:"bg-[#7042D2] h-3 rounded-full transition-all duration-500 ease-out",style:{width:`${p}%`}})}),t.jsxs("div",{className:"text-center mt-2 text-sm text-gray-500",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Processing... ",Math.round(p),"%"]})]}),t.jsxs("div",{className:"text-center space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),t.jsx("span",{className:"text-sm text-gray-600",children:"Transaction submitted"})]}),t.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 bg-yellow-500 rounded-full animate-pulse"}),t.jsx("span",{className:"text-sm text-gray-600",children:"Confirming on blockchain..."})]}),t.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[t.jsx("div",{className:"w-2 h-2 bg-gray-300 rounded-full"}),t.jsx("span",{className:"text-sm text-gray-400",children:"Finalizing payment..."})]})]}),t.jsx("div",{className:"mt-6 p-3 bg-blue-50 rounded-lg border border-blue-200",children:t.jsx("p",{className:"text-xs text-blue-800 text-center",children:"Please don't close this window. This usually takes 10-30 seconds."})})]}):"success"===e?t.jsxs("div",{className:"flex flex-col items-center justify-center py-6 px-4",children:[t.jsx("div",{className:"mb-6",children:g()}),t.jsx("h3",{className:"text-2xl font-bold mb-3 text-gray-900",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Payment Successful!"}),o&&a&&t.jsxs("p",{className:"text-center max-w-[235px] mb-6 text-gray-600",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Your payment of ",t.jsxs("span",{className:"text-[#7042D2] font-semibold",children:[o.totalAmount||o.amount," ",a.currency]})," has been completed."]}),s&&t.jsxs("div",{className:"w-full mb-6 px-4",children:[t.jsx("p",{className:"text-sm font-medium mb-2 text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Transaction Details"}),t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors bg-gray-50 border-gray-200 hover:bg-gray-100 mb-3",onClick:m,children:[t.jsx("span",{className:"font-mono text-sm text-gray-700",children:(y=s,y?y.length<=16?y:`${y.slice(0,8)}...${y.slice(-8)}`:"")}),t.jsxs("div",{className:"flex items-center",children:[d?t.jsx("span",{className:"text-green-500 text-xs font-medium mr-2",children:"Copied!"}):null,t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})]}),(()=>{const e=((e,t)=>{if(!e||!t)return null;const r="string"==typeof t?t:t.shortName||t.name;return{ethereum:`https://etherscan.io/tx/${e}`,bsc:`https://bscscan.com/tx/${e}`,polygon:`https://polygonscan.com/tx/${e}`,arbitrum:`https://arbiscan.io/tx/${e}`,optimism:`https://optimistic.etherscan.io/tx/${e}`,avalanche:`https://snowtrace.io/tx/${e}`,celo:`https://celoscan.io/tx/${e}`,base:`https://basescan.org/tx/${e}`}[null==r?void 0:r.toLowerCase()]||null})(s,c),r=(e=>{if(!e)return"Explorer";const t="string"==typeof e?e:e.shortName||e.name;return{ethereum:"Etherscan",bsc:"BscScan",polygon:"PolygonScan",arbitrum:"Arbiscan",optimism:"Optimistic Etherscan",avalanche:"SnowTrace",celo:"CeloScan",base:"BaseScan"}[null==t?void 0:t.toLowerCase()]||"Explorer"})(c);return c&&e&&t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full p-3 rounded-lg border border-[#7042D2] bg-white hover:bg-purple-50 transition-colors group",children:[t.jsxs("span",{className:"text-sm font-medium text-[#7042D2]",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["View on ",r]}),t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2] group-hover:translate-x-1 transition-transform",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})})()]}),u&&t.jsx("button",{onClick:u,className:"w-full py-3 px-4 bg-[#7042D2] text-white font-semibold rounded-2xl text-lg shadow-md hover:bg-[#5b34b1] transition-colors",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Close"})]}):t.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[t.jsx("div",{className:"mb-4",children:g()}),t.jsx("h3",{className:"text-xl font-bold mb-2 text-gray-900",children:"processing"===e?"Processing Payment":"error"===e?"Payment Failed":"Unknown Status"}),t.jsx("p",{className:"text-center text-gray-600",children:n})]});var y},cy={bitcoin:1,ethereum:1027,bsc:1839,polygon:3890,cardano:2010,avalanche:5805,fantom:3513,arbitrum:11841,optimism:11840,USDT:825,USDC:3408,BUSD:4687,DAI:4943,FRAX:6952,TUSD:2563,USDP:5992,USDD:5994,FDUSD:26081,PYUSD:28295,WBTC:3717,LINK:1975,UNI:7083,AAVE:7278,COMP:5692,YFI:5864,MKR:1518,SUSHI:6758,CRV:6538,SNX:2586,UMA:5617,BAL:5728,MANA:1966,SAND:6210,APE:18876,LDO:8e3,GRT:6719,ENS:13855,RPL:2943,SHIB:5994,MATIC:3890,BNB:1839,ADA:2010,SOL:5426,DOT:6636,AVAX:5805,TRX:1958,ALGO:4030,FTM:3513,ARB:11841,OP:11840,"1INCH":8104,DYDX:11156,ICP:8916,FIL:2280,CAKE:7186,RUNE:4157,ALPHA:7232,BNT:1727,KNC:1982,ZRX:1896,REN:2539,LRC:1934,WETH:2396,WMATIC:3890,WBNB:1839,UST:7129,USTC:7129,LUSD:8115,MIM:9681,FEI:8642,TRIBE:8741,RAI:8525,SUSD:2927},ly={ethereum:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",bsc:"https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png",polygon:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png",arbitrum:"https://s2.coinmarketcap.com/static/img/coins/64x64/11841.png",avalanche:"https://s2.coinmarketcap.com/static/img/coins/64x64/5805.png",celo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5567.png",optimism:"https://s2.coinmarketcap.com/static/img/coins/64x64/11840.png",base:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",eth:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",bnb:"https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png",trx:"https://s2.coinmarketcap.com/static/img/coins/64x64/1958.png",algo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",sol:"https://s2.coinmarketcap.com/static/img/coins/64x64/5426.png",matic:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png",arb:"https://s2.coinmarketcap.com/static/img/coins/64x64/11841.png",avax:"https://s2.coinmarketcap.com/static/img/coins/64x64/5805.png",op:"https://s2.coinmarketcap.com/static/img/coins/64x64/11840.png"},uy={metamask:"https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Fox.svg",coinbase:"https://avatars.githubusercontent.com/u/18060234?s=280&v=4",rabby:"https://rabby.io/logo-128.png",zerion:"https://app.zerion.io/favicon-32x32.png",phantom:"https://phantom.app/favicons/apple-touch-icon.png",trust:"https://trustwallet.com/favicon-196x196.png",okx:"https://static.okx.com/cdn/assets/imgs/248/58E63FEA47A2B7D7.png",binance:"https://bin.bnbstatic.com/static/images/common/favicon.ico",cryptocom:"https://crypto.com/favicon.ico",hot:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiNGRjZBNkEiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMmg0djhoLTR2LTJoMnYtNGgtMnYtMnptNiAwaDJ2MmgtdjdoLTJ2LTIiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg==",backpack:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiMwMEQ0QUEiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMGg4djJoLTJ2NmgtdjhoLTZWMTB6bTIgMnY0aDJWMTJ6IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4=","1inch":"https://1inch.io/favicon.svg",default:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiM2MzY2RjEiIHN0cm9rZT0iI0Y5RkFGQiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMmgxMnY4SDEweiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxLjUiIHJ4PSIxIi8+CjxjaXJjbGUgY3g9IjE4IiBjeT0iMTYiIHI9IjEiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg=="},dy=e=>(e=>{if(!e)return null;const t=cy[e.toUpperCase()];return t?`https://s2.coinmarketcap.com/static/img/coins/64x64/${t}.png`:null})(e),hy=(e,t)=>{const r=e.toLowerCase(),n=t.toLowerCase();for(const[i,o]of Object.entries(uy))if(r.includes(i)||n.includes(i))return o;return uy.default},py=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),fy=e=>{switch(e){case"trust":return window.ethereum&&!0===window.ethereum.isTrust;case"metaMask":return window.ethereum&&!0===window.ethereum.isMetaMask;case"injected":return window.ethereum&&!window.ethereum.isMetaMask&&!window.ethereum.isCoinbaseWallet;default:return!1}},my=(e,t)=>{if(!t)return[];if(!["ethereum","bsc","polygon","arbitrum","optimism","avalanche","celo","base"].includes(t.shortName))return[];return[...(e||[]).map(e=>(e=>({type:e.id,name:e.name,icon:hy(e.name,e.id),description:`Connect using ${e.name}`,isInstalled:!0,connector:e,isWagmi:!0}))(e)),...py()?[{type:"trust",name:"Trust Wallet",icon:"๐ก๏ธ",description:"Multi-chain wallet with transaction deep links",isInstalled:!1,connector:null,isWagmi:!1,mobileOnly:!0,hasTransactionDeepLinks:!0}]:[]]},gy=(e,t,r,n,i="metamask",o=null)=>{if(!e)return null;try{const t="https://paymentscreen.vercel.app",n=new URLSearchParams,o=(null==e?void 0:e.id)||(null==e?void 0:e.splitterPaymentId);if(!o)return null;n.set("paymentId",o),n.set("preferredWallet",i),n.set("isMobile","true");const s=`${t}?${n.toString()}`;let a;switch(i){case"metamask":a=`https://metamask.app.link/dapp/${s.replace("https://","")}`;break;case"trust":const e=(null==r?void 0:r.chainId)||1;a=`https://link.trustwallet.com/open_url?coin_id=${(e=>{const t="string"==typeof e&&e.startsWith("0x")?parseInt(e,16):parseInt(e);return[1,56,137,42161,10,43114,42220,8453].includes(t)?60:{}[t]||60})(e)}&url=${encodeURIComponent(s)}`;break;case"coinbase":a=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(s)}`;break;default:a=s}return a}catch(gu){return null}},yy=(e,t)=>{if(!t)return null;try{switch(e){case"metamask":return t.includes("metamask.app.link")?t:`https://metamask.app.link/dapp/${t.replace("https://","")}`;case"trust":return t.includes("link.trustwallet.com")?t:`https://link.trustwallet.com/open_url?coin_id=60&url=${encodeURIComponent(t)}`;case"coinbase":return t.includes("go.cb-w.com")?t:`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(t)}`;default:return t}}catch(gu){return t}},vy=Object.freeze(Object.defineProperty({__proto__:null,generateMobilePaymentDeepLink:yy,generateQRPaymentURI:gy},Symbol.toStringTag,{value:"Module"})),by=({walletAddress:e,amount:n,currency:i,network:o,theme:s="light",paymentData:a=null,onPaymentDetected:c=null,config:l=null,selectedToken:d=null,selectedNetwork:h=null,preferredWallet:p="metamask",compact:f=!1})=>{const[m,g]=r.useState(""),[y,v]=r.useState(""),[b,w]=r.useState(!0),[x,_]=r.useState(!1),[k,S]=r.useState(!1),C=r.useRef(null);return r.useEffect(()=>{(async()=>{if(null==a?void 0:a.id){w(!0);try{if(!d||!d.contractAddress)throw new Error("Cannot generate QR code: Token contract address required");if(!h||!h.chainId)throw new Error("Cannot generate QR code: Network chain ID required");const e=gy(a,0,h,0,p);if(e.includes("metamask.app.link")||e.includes("link.trustwallet.com")||e.includes("go.cb-w.com"),!e)throw new Error("Failed to generate Coinley payment URL");g(e);const t=py(),r=await u.toDataURL(e,{width:f?140:t?350:280,margin:2,errorCorrectionLevel:"M",color:{dark:"dark"===s?"#FFFFFF":"#000000",light:"dark"===s?"#000000":"#FFFFFF"}});v(r),w(!1)}catch(gu){w(!1)}}else w(!1)})()},[a,n,i,o,s,d,h,l,p]),r.useEffect(()=>()=>{C.current&&clearInterval(C.current)},[]),t.jsx("div",{className:"flex flex-col items-center",children:t.jsxs("div",{className:"flex gap-3 items-start w-full mb-2",children:[t.jsx("div",{className:"p-1.5 rounded-lg bg-white shadow-sm border flex-shrink-0",children:b?t.jsx("div",{className:"flex items-center justify-center",style:{width:140,height:140},children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-purple-600 mx-auto mb-1"}),t.jsx("div",{className:"text-xs text-gray-600",children:"Generating..."})]})}):y?t.jsx("img",{src:y,alt:"Payment QR Code",className:"rounded-lg",style:{width:140,height:140}}):t.jsx("div",{className:"flex items-center justify-center bg-gray-100 rounded-lg",style:{width:140,height:140},children:t.jsxs("div",{className:"text-center p-2",children:[t.jsx("div",{className:"text-lg mb-1",children:"โ ๏ธ"}),t.jsx("div",{className:"text-xs text-gray-600",children:(null==a?void 0:a.id)?"QR Failed":"Payment not created"})]})})}),t.jsxs("div",{className:"flex-1 flex flex-col justify-center",children:[t.jsxs("div",{className:"p-2 bg-gray-50 rounded-lg mb-2",children:[t.jsxs("div",{className:"flex justify-between items-center mb-1",children:[t.jsx("span",{className:"text-xs font-medium text-gray-600",children:"Amount:"}),t.jsxs("span",{className:"text-sm font-bold text-[#7042D2]",children:[n," ",i]})]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),t.jsx("span",{className:"text-xs font-medium text-gray-700",children:o})]})]}),k?t.jsxs("div",{className:"flex items-center justify-center text-xs font-semibold text-green-600 p-1.5 bg-green-50 rounded-lg",children:[t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Payment Received!"]}):t.jsx("div",{className:"p-1.5 rounded-lg bg-blue-50 border border-blue-200",children:t.jsx("p",{className:"text-xs text-blue-700 text-center leading-tight",children:"๐ฑ Scan with phone camera"})})]})]})})},wy=({selectedNetwork:e,onWalletSelect:i,onConnect:o,connectedWallet:s,loading:a,paymentData:c=null,selectedToken:l=null,api:u=null})=>{const[d,h]=r.useState(null),{connectors:p}=n.useConnect(),{isConnected:f,address:m}=n.useAccount(),g=my(p,e),y=async(t,r)=>{if(py())if(c)try{const{generateQRPaymentURI:n,generateMobilePaymentDeepLink:i}=await Promise.resolve().then(()=>vy),o=n(c,l,e,(null==u?void 0:u.config)||{},r);if(!o)throw new Error("Failed to generate payment URL");const s=i(r,o);if(!s)throw new Error(`Failed to generate ${t.name} deep link`);window.location.href=s}catch(gu){alert(`Failed to open ${t.name}: ${gu.message}`)}else alert("Please create a payment first before selecting a mobile wallet.");else alert(`Please install ${t.name} mobile app or use the browser extension if available.`)};return e?0===g.length?t.jsxs("div",{className:"text-center p-4",children:[t.jsxs("p",{className:"text-gray-500 mb-4",children:["No compatible wallets found for ",e.name]}),t.jsx("div",{className:"p-3 bg-amber-50 rounded-lg border border-amber-200",children:t.jsxs("div",{className:"text-sm text-amber-800",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[t.jsx("div",{className:"font-medium mb-2",children:"Install a compatible wallet:"}),t.jsxs("div",{className:"space-y-1 text-xs",children:[t.jsxs("div",{children:["โข ",t.jsx("a",{href:"https://metamask.io/download/",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-900",children:"Install MetaMask Wallet"})]}),t.jsxs("div",{children:["โข ",t.jsx("a",{href:"https://www.coinbase.com/wallet",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-900",children:"Install Coinbase Wallet"})]})]})]})})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Select Wallet for ",e.name]}),t.jsx(oy,{options:g,value:(null==s?void 0:s.walletType)||d||"",onChange:async e=>{h(e);const t=g.find(t=>t.type===e);t&&(i(e),t.isWagmi&&t.connector?await o(t.connector):t.isWagmi||await y(t,e))},placeholder:"Choose your wallet...",renderOption:e=>{var r,n;return t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsxs("div",{className:"w-8 h-8 flex items-center justify-center",children:[e.icon.startsWith("http")||e.icon.startsWith("data:")?t.jsx("img",{src:e.icon,alt:e.name,className:"w-6 h-6 rounded-full object-contain",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="block"}}):t.jsx("div",{className:"text-2xl",children:e.icon}),t.jsx("div",{className:"text-xl",style:{display:"none"},children:"๐"})]}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"font-semibold text-gray-800 flex items-center",children:[e.name,fy(e.type)&&t.jsx("span",{className:"ml-2 px-2 py-1 bg-blue-100 text-blue-700 text-xs rounded-full",children:"DETECTED"}),(null==s?void 0:s.walletType)===e.type&&t.jsx("span",{className:"ml-2 px-2 py-1 bg-green-100 text-green-700 text-xs rounded-full",children:"CONNECTED"})]}),t.jsx("div",{className:"text-sm text-gray-500",children:(null==s?void 0:s.walletType)===e.type?`Connected โข ${null==(r=s.account)?void 0:r.slice(0,6)}...${null==(n=s.account)?void 0:n.slice(-4)}`:e.description})]}),a&&d===e.type&&t.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-[#7042D2]"})]})},getOptionKey:e=>e.type,getOptionValue:e=>e.type,getSearchableText:e=>`${e.name} ${e.description}`,disabled:a})]}):t.jsx("div",{className:"text-center p-4",children:t.jsx("p",{className:"text-gray-500",children:"Please select a network first"})})},xy=(()=>{if("undefined"!=typeof process&&process.env)return!1;if("undefined"!=typeof window){const e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e||e.includes("192.168.")}return!1})()||(()=>{if("undefined"!=typeof window){const e=new URLSearchParams(window.location.search);return"true"===e.get("debug")||"true"===e.get("debugMode")}return!1})(),_y=({paymentData:e,selectedToken:n,selectedNetwork:i,config:o,onPaymentStarted:s=()=>{},onError:a=()=>{}})=>{var c,l;const[u,d]=r.useState(null),[h,p]=r.useState(!1),[f,m]=r.useState([]),[g,y]=r.useState(!1),[v,b]=r.useState(0);r.useEffect(()=>{var t,r,o;(null==e?void 0:e.id)&&(null==n?void 0:n.contractAddress)&&(null==i?void 0:i.chainId)&&((null==(t=null==e?void 0:e.contractCall)?void 0:t.contractAddress)||(null==e?void 0:e.contractAddress))?w("success","โ
Payment data complete",{paymentId:e.id,tokenContract:n.contractAddress,chainId:i.chainId,paymentContract:(null==(o=null==e?void 0:e.contractCall)?void 0:o.contractAddress)||(null==e?void 0:e.contractAddress)}):(w("debug","โณ Waiting for complete payment data",{hasPaymentId:!!(null==e?void 0:e.id),hasTokenContract:!!(null==n?void 0:n.contractAddress),hasChainId:!!(null==i?void 0:i.chainId),hasPaymentContract:!(!(null==(r=null==e?void 0:e.contractCall)?void 0:r.contractAddress)&&!(null==e?void 0:e.contractAddress)),checkCount:v}),b(e=>e+1))},[e,n,i,v]);const w=(e,t,r=null)=>{const n=(new Date).toLocaleTimeString(),i={id:Date.now()+Math.random(),type:e,message:t,data:r,timestamp:n};xy&&(m(e=>[...e,i].slice(-20)),e.toUpperCase())},x=[{id:"metamask",name:"MetaMask",icon:"๐ฆ",description:"Connect with MetaMask mobile"},{id:"trust",name:"Trust Wallet",icon:"๐ก๏ธ",description:"Connect with Trust Wallet"},{id:"coinbase",name:"Coinbase Wallet",icon:"๐",description:"Connect with Coinbase Wallet"}];if(!e)return t.jsx("div",{className:"p-4 bg-amber-50 rounded-lg border border-amber-200",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-amber-800 font-medium mb-2",children:"โ ๏ธ Payment Required"}),t.jsx("div",{className:"text-sm text-amber-700",children:"Please create a payment before selecting a wallet"})]})});const _=(null==e?void 0:e.id)&&(null==n?void 0:n.contractAddress)&&(null==i?void 0:i.chainId)&&((null==(c=null==e?void 0:e.contractCall)?void 0:c.contractAddress)||(null==e?void 0:e.contractAddress));return t.jsx("div",{className:"space-y-4",children:_?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Select Mobile Wallet"}),t.jsx(oy,{options:x,value:u||"",onChange:async t=>{const r=x.find(e=>e.id===t);if(r){d(t),p(!0);try{if(w("info",`๐ Mobile wallet selected: ${r.name}`),!e)throw new Error("Payment data not available. Please create payment first.");w("debug","๐ Payment Data Check",{hasPaymentData:!!e,hasSelectedToken:!!n,hasSelectedNetwork:!!i,hasConfig:!!o,paymentId:(null==e?void 0:e.id)||(null==e?void 0:e.splitterPaymentId),tokenAddress:null==n?void 0:n.contractAddress,networkChainId:null==i?void 0:i.chainId,amount:(null==e?void 0:e.totalAmount)||(null==e?void 0:e.amount)||(null==o?void 0:o.amount)});const a=gy(e,0,i,0,t);if(!a)throw new Error("Failed to generate payment URL");w("success","๐ฑ Generated payment URL",{url:a,length:a.length});const c=yy(t,a);if(!c)throw new Error(`Failed to generate ${r.name} deep link`);w("success",`๐ Deep link generated for ${r.name}`,{deepLink:c}),s({walletType:t,walletName:r.name,paymentUrl:a,deepLink:c}),setTimeout(()=>{w("info",`๐ฑ Opening ${r.name}...`),window.location.href=c},500)}catch(gu){w("error","โ Mobile wallet connection failed",{error:gu.message,walletId:t,hasPaymentData:!!e,hasSelectedToken:!!n,hasSelectedNetwork:!!i}),a(gu.message),p(!1),d(null)}}},placeholder:"Choose your wallet...",renderOption:e=>t.jsxs("div",{className:"flex items-center space-x-3",children:[t.jsx("div",{className:"w-8 h-8 flex items-center justify-center",children:t.jsx("div",{className:"text-2xl",children:e.icon})}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"font-semibold text-gray-800",children:[e.name,u===e.id&&h&&t.jsx("span",{className:"ml-2 px-2 py-1 bg-blue-100 text-blue-700 text-xs rounded-full animate-pulse",children:"Opening..."})]}),t.jsx("div",{className:"text-sm text-gray-500",children:e.description})]})]}),getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.description}`,disabled:h}),t.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"Select a wallet to open it with your payment details"})]}),h&&u&&t.jsx("div",{className:"p-3 bg-blue-50 border border-blue-200 rounded-lg animate-pulse",children:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-blue-600 border-t-transparent"}),t.jsxs("div",{className:"text-sm text-blue-700",children:["Opening ",null==(l=x.find(e=>e.id===u))?void 0:l.name,"..."]})]})}),t.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[t.jsxs("div",{className:"flex justify-between items-center text-sm",children:[t.jsx("span",{className:"text-gray-600",children:"Amount:"}),t.jsxs("span",{className:"font-semibold text-gray-800",children:[e.totalAmount," ",(null==n?void 0:n.symbol)||"USDC"]})]}),t.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[t.jsx("span",{className:"text-gray-600",children:"Network:"}),t.jsx("span",{className:"text-gray-800",children:(null==i?void 0:i.name)||"Ethereum"})]})]}),t.jsx("div",{className:"p-3 bg-purple-50 border border-purple-200 rounded-lg",children:t.jsxs("div",{className:"text-xs text-purple-700",children:[t.jsx("div",{className:"font-medium mb-1",children:"๐ฑ Mobile Payment"}),t.jsx("div",{children:"Your selected wallet app will open with payment details pre-filled"})]})}),xy&&t.jsxs("div",{className:"mt-4",children:[t.jsxs("button",{onClick:()=>y(!g),className:"w-full text-xs py-2 px-3 bg-gray-100 text-gray-600 rounded-lg hover:bg-gray-200 transition-colors",children:[g?"๐ฝ Hide Debug Info":"๐ง Show Debug Info"," (",f.length," logs)"]}),g&&t.jsxs("div",{className:"mt-2 p-3 bg-gray-900 text-green-400 rounded-lg text-xs font-mono max-h-80 overflow-y-auto",children:[t.jsx("div",{className:"text-white mb-2 font-bold",children:"๐ฑ Mobile Debug Panel"}),0===f.length?t.jsx("div",{className:"text-gray-400",children:"No debug logs yet. Try selecting a wallet..."}):f.map(e=>t.jsxs("div",{className:"mb-3 pb-2 border-b border-gray-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"px-2 py-1 rounded text-xs font-bold "+("error"===e.type?"bg-red-600 text-white":"success"===e.type?"bg-green-600 text-white":"debug"===e.type?"bg-blue-600 text-white":"bg-gray-600 text-white"),children:e.type.toUpperCase()}),t.jsx("span",{className:"text-gray-400",children:e.timestamp})]}),t.jsx("div",{className:"text-yellow-300 mb-1",children:e.message}),e.data&&t.jsx("div",{className:"text-gray-300 text-xs",children:t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-blue-300 hover:text-blue-200",children:"๐ Data"}),t.jsx("pre",{className:"mt-1 p-2 bg-gray-800 rounded overflow-x-auto whitespace-pre-wrap",children:JSON.stringify(e.data,null,2)})]})})]},e.id)),t.jsx("button",{onClick:()=>m([]),className:"mt-2 px-3 py-1 bg-red-600 text-white rounded text-xs hover:bg-red-700",children:"Clear Logs"})]})]})]}):t.jsx("div",{className:"p-4 bg-amber-50 rounded-lg border border-amber-200",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-amber-800 font-medium mb-2",children:"โณ Preparing Payment..."}),t.jsx("div",{className:"text-sm text-amber-700",children:"Payment is being prepared. Please wait a moment..."}),t.jsx("div",{className:"mt-3",children:t.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-amber-600 border-t-transparent mx-auto"})})]})})})},ky=({error:e,onRetry:r,onDismiss:n,context:i="payment",className:o=""})=>{if(!e)return null;const s=ey(e),a=(e=>{switch(e){case"user_rejected":return"info";case"insufficient_funds":case"wrong_network":case"wallet_disconnected":case"payment_pending":return"warning";case"network_error":case"gas_error":case"rate_limited":return"error";default:return"critical"}})(s.type),c=(e=>{switch(e){case"user_rejected":default:return"Try Again";case"insufficient_funds":return"Add Funds & Retry";case"wrong_network":return"Switch Network & Retry";case"wallet_disconnected":return"Reconnect Wallet";case"payment_pending":return"Check Again";case"network_error":case"rate_limited":return"Retry";case"popup_blocked":return"Allow Popups & Retry";case"mobile_wallet_error":return"Open Wallet App"}})(s.type),l={info:{container:"bg-blue-50 border-blue-200",title:"text-blue-800",message:"text-blue-700",icon:"โน๏ธ",button:"bg-blue-600 hover:bg-blue-700"},warning:{container:"bg-amber-50 border-amber-200",title:"text-amber-800",message:"text-amber-700",icon:"โ ๏ธ",button:"bg-amber-600 hover:bg-amber-700"},error:{container:"bg-red-50 border-red-200",title:"text-red-800",message:"text-red-700",icon:"โ",button:"bg-red-600 hover:bg-red-700"},critical:{container:"bg-red-50 border-red-300",title:"text-red-900",message:"text-red-800",icon:"๐จ",button:"bg-red-700 hover:bg-red-800"}},u=l[a]||l.error;return t.jsxs("div",{className:`p-4 border rounded-lg ${u.container} ${o}`,children:[t.jsxs("div",{className:"flex items-start space-x-3",children:[t.jsx("div",{className:"flex-shrink-0 text-xl",children:u.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:`font-semibold ${u.title} mb-1`,children:s.title}),t.jsx("div",{className:`text-sm ${u.message} mb-2`,children:s.message}),s.suggestion&&t.jsxs("div",{className:`text-xs ${u.message} opacity-90`,children:["๐ก ",s.suggestion]})]}),n&&t.jsx("button",{onClick:n,className:"flex-shrink-0 text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Dismiss error",children:t.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),r&&t.jsxs("div",{className:"mt-3 flex justify-end space-x-2",children:[n&&"info"===a&&t.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs text-gray-600 hover:text-gray-800 transition-colors",children:"Cancel"}),t.jsx("button",{onClick:r,className:`px-4 py-2 text-sm font-medium text-white rounded-md transition-colors ${u.button}`,children:c})]}),!1]})},Sy="method",Cy="confirm",Iy="processing",Ey="success",Ny="wallet",Ay="qr",Py="Bricolage Grotesque, sans-serif",Oy=new i.QueryClient,My=({publicKey:e,apiKey:i,apiSecret:s,apiUrl:a,config:c,onSuccess:l,onError:u,onClose:d,isOpen:h,theme:p="light"})=>{const f=((e,t,n)=>{const[i,o]=r.useState("method"),[s,a]=r.useState([]),[c,l]=r.useState([]),[u,d]=r.useState(null),[h,p]=r.useState(null),[f,m]=r.useState(null),[g,y]=r.useState(null),[v,b]=r.useState(!1),[w,x]=r.useState(""),[_,k]=r.useState(!1),[S,C]=r.useState("Processing transaction..."),[I,E]=r.useState("wallet"),[N,A]=r.useState(null),P=r.useRef(new hf(e,t,n));return{currentStep:i,networks:s,tokens:c,selectedNetwork:u,selectedToken:h,paymentMethod:f,paymentData:g,loading:v,error:w,processing:_,processingMessage:S,paymentType:I,actualTransactionHash:N,setCurrentStep:o,setSelectedNetwork:d,setSelectedToken:p,setPaymentMethod:m,setError:x,setProcessing:k,setProcessingMessage:C,setPaymentType:E,setActualTransactionHash:A,loadData:async()=>{var e,t;try{b(!0),x("");const[r,n]=await Promise.all([P.current.getNetworks(),P.current.getTokens()]),i=(null==(e=r.networks)?void 0:e.reduce((e,t)=>{if("solana"===t.shortName||"tron"===t.shortName||"algorand"===t.shortName)return e;if(!t.chainId||null===t.chainId)return e;const r=`${t.chainId}-${t.shortName}`;return e.some(e=>`${e.chainId}-${e.shortName}`===r)||e.push(t),e},[]))||[],o=(null==(t=n.stablecoins)?void 0:t.reduce((e,t)=>{var r,n,i;if("USDC"!==t.symbol&&"USDT"!==t.symbol)return e;if("solana"===(null==(r=t.Network)?void 0:r.shortName)||"tron"===(null==(n=t.Network)?void 0:n.shortName)||"algorand"===(null==(i=t.Network)?void 0:i.shortName))return e;const o=`${t.symbol}-${t.networkId}`;return e.some(e=>`${e.symbol}-${e.networkId}`===o)||e.push(t),e},[]))||[];a(i),l(o)}catch(Hy){x("Failed to load payment options. Using fallback data.")}finally{b(!1)}},createPayment:async e=>{var t;try{b(!0),x("");const r={amount:e.amount,currency:h.symbol,network:u.shortName,customerEmail:e.customerEmail,callbackUrl:e.callbackUrl,metadata:{...e.metadata,merchantWalletAddresses:e.merchantWalletAddresses,paymentMethod:f,selectedNetwork:u.shortName,selectedToken:h.symbol,wagmiEnabled:!0}},n=await P.current.createPayment(r);y(n.payment),af.trackPaymentCreated(null==(t=n.payment)?void 0:t.id,e.amount,u.shortName,h.symbol),o("confirm")}catch(Hy){x(Hy.message),af.trackError("payment_creation_failed",Hy.message,{amount:e.amount,network:null==u?void 0:u.shortName,token:null==h?void 0:h.symbol})}finally{b(!1)}},failPayment:async(e="Payment cancelled by user")=>{if(null==g?void 0:g.id)try{await P.current.failPayment(g.id,e)}catch(t){}},resetState:()=>{o("method"),d(null),p(null),m(null),y(null),x(""),k(!1),A(null),E("wallet")},resetTransactionState:()=>{x(""),k(!1),A(null),o("confirm")},api:P.current}})(a,e||i,e?null:s),m=(()=>{const[e,t]=r.useState(null),[i,s]=r.useState(null),[a,c]=r.useState(""),{connect:l,connectors:u}=n.useConnect(),{isConnected:d,address:h,chain:p}=n.useAccount(),{switchChain:f}=n.useSwitchChain();return r.useEffect(()=>{s(d&&h?{account:h,chainId:null==p?void 0:p.id,walletType:e}:null)},[d,h,p,e]),{selectedWalletType:e,connectedWallet:i,connectionError:a,isConnected:d,address:h,chain:p,connectors:u,handleWalletSelection:e=>{t(e),c("")},connectWallet:async(e,t=null)=>{var r,n,i;if(!e)return c("Please select a wallet first"),!1;try{if(c(""),await l({connector:e}),t){const a=mf(t.shortName),l=(null==(r=e.name)?void 0:r.toLowerCase())||"",u=l.includes("zerion")||l.includes("trust")||l.includes("rabby")?5e3:500;await new Promise(e=>setTimeout(e,u));const d=o.getAccount(df).chainId;if(a&&d!==a)try{await f({chainId:a}),await new Promise(e=>setTimeout(e,1e3))}catch(s){return 4001===s.code||(null==(n=s.message)?void 0:n.includes("User rejected"))?c("Network switch was cancelled by user"):(null==(i=s.message)?void 0:i.includes("Unrecognized chain ID"))?c(`${t.name} network is not added to your wallet. Please add it manually.`):c(`Failed to switch to ${t.name}. Please switch manually in your wallet.`),!1}}return!0}catch(Hy){return 4001===Hy.code||Hy.message.includes("User rejected")||Hy.message.includes("rejected")?c("User cancelled the connection request"):c(`Failed to connect to ${e.name}. Please try again.`),!1}},disconnectWallet:()=>{s(null),t(null),c("")},switchChain:f,ensureCorrectNetwork:async e=>{var t,r;if(!e)return!0;try{const i=mf(e.shortName),s=o.getAccount(df).chainId;if(i&&s!==i)try{return await f({chainId:i}),await new Promise(e=>setTimeout(e,1e3)),!0}catch(n){return 4001===n.code||(null==(t=n.message)?void 0:t.includes("User rejected"))?c("Network switch was cancelled. Please switch to the correct network in your wallet."):(null==(r=n.message)?void 0:r.includes("Unrecognized chain ID"))?c(`${e.name} network is not added to your wallet. Please add it manually.`):c(`Failed to switch to ${e.name}. Please switch manually in your wallet.`),!1}return!0}catch(O){return c("Failed to verify network. Please check your wallet connection."),!1}},clearError:()=>{c("")},setSelectedWalletType:t,connect:l}})(),[g,y]=r.useState("metamask"),[v,b]=r.useState(!1),[w,x]=r.useState(()=>!("undefined"==typeof window||!window.sessionStorage)&&"true"===sessionStorage.getItem("coinley_mobile_payment_started")),[_,k]=r.useState(!1);r.useEffect(()=>{b(py())},[]);const{currentStep:S,networks:C,tokens:I,selectedNetwork:E,selectedToken:N,paymentData:A,loading:P,error:O,paymentType:M,loadData:T,createPayment:R,failPayment:j,resetState:D,setSelectedNetwork:F,setSelectedToken:L,setPaymentType:U,setCurrentStep:B,setError:z}=f,{connectedWallet:q,address:$,connectWallet:G,handleWalletSelection:W}=m,V=iy(A,N,E,$,f.api,m),{executePaymentTransaction:H,processFinalPayment:Y,transactionStep:Z,transactionError:K,currentTransactionHash:J}=V;r.useEffect(()=>{S===Ey&&"undefined"!=typeof window&&window.sessionStorage&&sessionStorage.removeItem("coinley_mobile_payment_started")},[S]),r.useEffect(()=>{if(h){T(),D(),af.trackModalOpened(null==c?void 0:c.merchantName,null==c?void 0:c.amount);const e=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${e}px`,document.body.style.width="100%",document.body.style.overflow="hidden"}else{const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,-1*parseInt(e||"0"))}return()=>{if(h){const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,-1*parseInt(e||"0"))}}},[h]),r.useEffect(()=>{if("processing"===Z||"approve"===Z||"splitPayment"===Z){const e=setTimeout(()=>{z("Transaction timed out. Please try again."),B(Cy),V.resetTransaction()},12e4);return()=>clearTimeout(e)}},[Z]);const X=async()=>{af.trackModalClosed("user_cancelled"),await j(),d()};return h?t.jsxs("div",{className:"fixed inset-0 z-50",children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:X,"aria-hidden":"true"}),t.jsx("div",{className:"fixed inset-0 flex items-center justify-center p-4",style:{zIndex:51},children:t.jsxs("div",{className:"relative pt-4 w-full max-w-md max-h-[90vh] mx-auto shadow-xl bg-gray-100 rounded-3xl flex flex-col overflow-hidden",style:{zIndex:52},children:[t.jsxs("div",{className:"flex-shrink-0 bg-white flex justify-between items-center mb-3 mr-3 ml-3 py-3 px-2 rounded-full",children:[t.jsxs("div",{className:"flex-1 flex items-center gap-2 px-4",children:[t.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center",children:t.jsx("img",{src:cf,alt:"Coinley"})}),t.jsx("span",{className:"text-base font-semibold text-gray-800",style:{fontFamily:Py},children:"Payment Details"})]}),S!==Ey&&S!==Iy&&t.jsx("button",{onClick:X,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),c&&S!==Ey&&t.jsx("div",{className:"flex-shrink-0 mb-3 px-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-xs text-gray-600",children:"Total Amount"}),t.jsxs("div",{className:"text-3xl font-bold text-[#7042D2] mt-1 leading-tight tracking-tight",style:{fontFamily:Py},children:["$",(Q=c.amount,parseFloat(Q).toFixed(2))]}),t.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"No additional fees"}),t.jsx("div",{className:"text-xs text-gray-600 mt-2",children:"Payment to:"}),t.jsxs("div",{className:"text-sm font-semibold mt-0.5 flex gap-1.5 items-center justify-center",style:{fontFamily:Py},children:[t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("path",{d:"M15.3 7.50065L15.8 10.0007H4.2L4.7 7.50065H15.3ZM16.6667 3.33398H3.33333V5.00065H16.6667V3.33398ZM16.6667 5.83398H3.33333L2.5 10.0007V11.6673H3.33333V16.6673H11.6667V11.6673H15V16.6673H16.6667V11.6673H17.5V10.0007L16.6667 5.83398ZM5 15.0007V11.6673H10V15.0007H5Z",fill:"#7042D2"})}),c.merchantName||"Merchant"]})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-contain",children:[t.jsx(sy,{currentStep:S,targetStep:Sy,children:t.jsxs("div",{className:"pb-4 pt-3 px-5 bg-white rounded-t-2xl",children:[t.jsx("h3",{className:"font-semibold text-center mb-3 text-sm",style:{fontFamily:Py},children:"Choose Payment Method"}),t.jsxs("div",{className:"space-y-3 mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:Py},children:"Select Network"}),t.jsx(oy,{options:C,value:(null==E?void 0:E.id)||"",onChange:e=>{const t=C.find(t=>t.id===e);F(t),L(null),af.trackNetworkSelected(null==t?void 0:t.name,null==c?void 0:c.merchantName)},placeholder:"Choose your network...",renderOption:e=>{var r,n;const i="object"==typeof(o=e)&&(null==o?void 0:o.logo)?o.logo:"object"==typeof o&&(null==o?void 0:o.shortName)?ly[o.shortName.toLowerCase()]:"string"==typeof o?ly[o.toLowerCase()]:null;var o;return t.jsxs("div",{className:"flex items-center space-x-3",children:[i?t.jsx("img",{src:i,alt:e.name,className:"w-8 h-8 rounded-full",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="flex"}}):null,t.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center",style:{display:i?"none":"flex"},children:t.jsx("span",{className:"text-xs font-bold text-gray-600",children:null==(r=e.shortName)?void 0:r.slice(0,2).toUpperCase()})}),t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold text-gray-800",children:e.name}),t.jsx("div",{className:"text-sm text-gray-500",children:null==(n=e.shortName)?void 0:n.toUpperCase()})]})]})},getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.shortName}`,disabled:P})]}),E&&t.jsxs("div",{className:"space-y-3 mb-4",children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:Py},children:"Select Token"}),t.jsx(oy,{options:I.filter(e=>{var t;return(null==(t=e.Network)?void 0:t.shortName)===(null==E?void 0:E.shortName)||e.networkId===(null==E?void 0:E.id)}),value:(null==N?void 0:N.id)||"",onChange:e=>{const t=I.filter(e=>{var t;return(null==(t=e.Network)?void 0:t.shortName)===(null==E?void 0:E.shortName)||e.networkId===(null==E?void 0:E.id)}).find(t=>t.id===e);L(t),af.trackTokenSelected(null==t?void 0:t.symbol,null==E?void 0:E.name,null==c?void 0:c.merchantName)},placeholder:"Choose your token...",renderOption:e=>{var r,n;const i=dy(e.symbol);return t.jsxs("div",{className:"flex items-center space-x-3",children:[i?t.jsx("img",{src:i,alt:e.symbol,className:"w-8 h-8 rounded-full",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="flex"}}):null,t.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center",style:{display:i?"none":"flex"},children:t.jsx("span",{className:"text-xs font-bold text-gray-600",children:null==(r=e.symbol)?void 0:r.slice(0,2)})}),t.jsxs("div",{children:[t.jsxs("div",{className:"font-semibold text-gray-800",children:[e.name," (",e.symbol,")"]}),t.jsxs("div",{className:"text-sm text-gray-500",children:[(null==(n=e.Network)?void 0:n.name)||"Unknown Network",e.isStablecoin&&t.jsx("span",{className:"ml-2 text-green-600",children:"โข Stablecoin"})]})]})]})},getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.symbol}`,disabled:P})]}),E&&N&&t.jsx("button",{onClick:()=>R(c),disabled:P,className:"w-full bg-[#7042D2] text-white py-4 px-4 rounded-xl hover:bg-[#5b34b1] disabled:opacity-50 font-semibold transition-all duration-200 shadow-lg hover:shadow-xl",style:{fontFamily:Py},children:P?"Creating Payment...":"Continue"})]})}),t.jsx(sy,{currentStep:S,targetStep:Cy,children:E&&N&&A&&t.jsxs("div",{className:"pb-4 pt-4 px-4 bg-white rounded-t-2xl",children:[!v&&t.jsx("div",{className:"mb-4",children:t.jsxs("div",{className:"flex border-b border-gray-200",children:[t.jsx("button",{onClick:()=>U(Ny),className:"py-3 px-6 text-sm font-semibold transition-all duration-200 "+(M===Ny?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),style:{fontFamily:Py},children:"Connect Wallet"}),t.jsx("button",{onClick:()=>U(Ay),className:"py-3 px-6 text-sm font-semibold transition-all duration-200 "+(M===Ay?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),style:{fontFamily:Py},children:"QR Code"})]})}),v?t.jsx(_y,{paymentData:A,selectedToken:N,selectedNetwork:E,config:c,onPaymentStarted:e=>{x(!0),"undefined"!=typeof window&&window.sessionStorage&&sessionStorage.setItem("coinley_mobile_payment_started","true"),e.walletName},onError:e=>{z(e)}}):M===Ny?t.jsx(wy,{selectedNetwork:E,onWalletSelect:W,onConnect:async e=>{await G(e,E)},connectedWallet:q,loading:P}):null,M===Ay&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"text-xs font-medium text-gray-600 mb-1.5 text-center",style:{fontFamily:Py},children:"Optimize QR for:"}),t.jsx("div",{className:"flex gap-1.5 justify-center flex-wrap",children:[{id:"metamask",name:"MetaMask",icon:"๐ฆ"},{id:"trust",name:"Trust",icon:"๐ก๏ธ"},{id:"coinbase",name:"Coinbase",icon:"๐"}].map(e=>t.jsxs("button",{onClick:()=>y(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all duration-200 "+(g===e.id?"bg-[#7042D2] text-white shadow-md":"bg-gray-100 text-gray-700 hover:bg-gray-200"),style:{fontFamily:Py},children:[t.jsx("span",{className:"text-sm",children:e.icon}),t.jsx("span",{children:e.name})]},e.id))})]}),t.jsx(by,{amount:(null==A?void 0:A.totalAmount)||(null==A?void 0:A.amount)||(null==c?void 0:c.amount),currency:null==N?void 0:N.symbol,network:null==E?void 0:E.shortName,theme:p,paymentData:A,config:c,selectedToken:N,selectedNetwork:E,preferredWallet:g,compact:!0})]}),(O||K)&&t.jsx("div",{className:"mt-4",children:t.jsx(ky,{error:K||O,onRetry:()=>{z(""),V.resetTransaction(),"error"===Z&&q&&H()},onDismiss:()=>{z(""),V.resetTransaction()},context:"payment"})}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-4",children:[t.jsx("button",{type:"button",onClick:()=>B(Sy),className:"w-full py-2.5 px-3 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-semibold rounded-xl transition-all duration-200 text-sm",style:{fontFamily:Py},children:"Back"}),t.jsx("button",{type:"button",onClick:async()=>{var e,t,r,n,i,o,s,a,c,u;if(v&&w){if(!(null==A?void 0:A.id))return void z("Payment ID not found. Please refresh and try again.");try{k(!0),B(Iy),z("");const i=await f.api.checkPaymentStatus(A.id);if("completed"===(null==(e=i.payment)?void 0:e.status))B(Ey),l&&l({paymentId:A.id,transactionHash:i.payment.transactionHash,paymentDetails:i.payment});else if("pending"===(null==(t=i.payment)?void 0:t.status)){const e=await f.api.verifyQRPayment(A.id);if(e.success&&e.verified)B(Ey),l&&l({paymentId:A.id,transactionHash:null==(r=e.onChainData)?void 0:r.transactionHash,paymentDetails:e.payment});else{const t=e.message||"Payment not yet confirmed on blockchain";z(`${t}. Please complete the payment in your wallet and try again.`),B(Cy)}}else"failed"===(null==(n=i.payment)?void 0:n.status)?(z("Payment failed. Please try creating a new payment."),B(Cy)):(z("Payment not found. Please verify the payment ID and try again."),B(Cy))}catch(d){z(`Verification failed: ${d.message}. Please ensure payment was completed and try again.`),B(Cy)}finally{k(!1)}}else if(M!==Ay){if(q&&$)try{B(Iy),z("");const e=await H();e&&(z(""),V.setTransactionError(""),B(Ey),l&&l({paymentId:A.id,transactionHash:e,paymentDetails:A}))}catch(d){B(Cy),(null==(c=d.message)?void 0:c.includes("User rejected"))||(null==(u=d.message)?void 0:u.includes("User denied"))||4001===d.code||"ACTION_REJECTED"===d.code?z("Transaction was cancelled by user. Please try again."):z(d.message||"Transaction failed. Please try again."),V.resetTransaction()}}else{if(!(null==A?void 0:A.id))return void z("Payment ID not found. Please refresh and try again.");try{B(Iy),z("");const e=await f.api.checkPaymentStatus(A.id);if("completed"===(null==(i=e.payment)?void 0:i.status))B(Ey),l&&l({paymentId:A.id,transactionHash:e.payment.transactionHash,paymentDetails:e.payment});else if("pending"===(null==(o=e.payment)?void 0:o.status)){const e=await f.api.verifyQRPayment(A.id);if(e.success&&e.verified)B(Ey),l&&l({paymentId:A.id,transactionHash:null==(s=e.onChainData)?void 0:s.transactionHash,paymentDetails:e.payment});else{const t=e.message||"Payment not yet confirmed on blockchain";z(`${t}. Please complete the payment and try again.`),B(Cy)}}else"failed"===(null==(a=e.payment)?void 0:a.status)?(z("Payment failed. Please try creating a new payment."),B(Cy)):(z("Payment not found. Please verify the payment ID and try again."),B(Cy))}catch(d){z(`Verification failed: ${d.message}. Please ensure payment was completed and try again.`),B(Cy)}}},className:"bg-green-600 text-white w-full py-2.5 px-3 font-semibold rounded-xl hover:bg-green-700 transition-all duration-200 shadow-lg hover:shadow-xl disabled:opacity-50 text-sm",disabled:M===Ny&&!q&&!v||v&&!w||"processing"===Z||_,style:{fontFamily:Py},children:_?"Verifying...":"processing"===Z?"Processing...":v&&w?"I Have Paid":v?"Select Wallet":M===Ay?"I Have Paid":"Pay Now"})]})]})}),t.jsx(sy,{currentStep:S,targetStep:Iy,children:t.jsx(ay,{status:"processing",message:"approve"===Z?"Approving token spending...":"splitPayment"===Z?"Processing payment split...":J?"Confirming transaction on blockchain...":"Processing your payment...",theme:p,transactionHash:J,selectedNetwork:E})}),t.jsx(sy,{currentStep:S,targetStep:Ey,children:t.jsx(ay,{status:"success",message:"Payment completed successfully!",theme:p,payment:A,transactionHash:J||(null==A?void 0:A.transactionHash),selectedPaymentMethod:N,selectedNetwork:E,merchantName:(null==c?void 0:c.merchantName)||"Merchant",onClose:d})}),(O||K)&&t.jsxs("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg mx-6 mb-4",children:[t.jsx("p",{className:"text-red-800 text-sm",children:O||K}),t.jsx("button",{onClick:()=>{z(""),V.setTransactionError("")},className:"mt-2 text-red-600 hover:text-red-800 text-xs underline",children:"Dismiss"})]})]}),S!==Ey&&t.jsxs("div",{className:"text-center text-xs text-gray-500 flex items-center justify-center gap-1 py-6 bg-white rounded-b-3xl",style:{fontFamily:Py},children:[t.jsxs("p",{children:["Powered by ",t.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Coinley"})," - Multi-Wallet Support"]}),t.jsxs("svg",{className:"inline w-4 h-4 text-green-500 ml-1",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}),t.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})})]}):null;var Q},Ty=e=>t.jsx(n.WagmiProvider,{config:df,children:t.jsx(i.QueryClientProvider,{client:Oy,children:t.jsx(My,{...e})})}),Ry=r.createContext(null),jy=r.forwardRef(({customerEmail:e="",merchantName:t="",onSuccess:n,onError:i,onClose:o,theme:s="light",autoOpen:a=!1,testMode:c=!1,debug:l=!1,merchantWalletAddresses:u={}},d)=>{const h=r.useContext(Ry);if(!h)throw new Error("CoinleyCheckout must be used within a CoinleyProvider");const{openPayment:p,closePayment:f}=h,m=t=>{try{if(!t.amount||t.amount<=0)throw new Error("Amount must be greater than 0");const r={...t,customerEmail:t.customerEmail||e,merchantWalletAddresses:{...u,...t.merchantWalletAddresses},metadata:{...t.metadata,testMode:c,checkoutVersion:"1.0.0"}};p(r,{onSuccess:n,onError:i,onClose:o})}catch(gu){i&&i(gu)}},g=()=>{f()};return r.useImperativeHandle(d,()=>({open:m,close:g})),null});jy.displayName="CoinleyCheckout";const Dy={ethereum:Vg,bsc:Dg,polygon:Zg,arbitrum:Mg,optimism:Yg,avalanche:Tg},Fy=[{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],type:"function"}];const Ly=new class{constructor(){this.clients=new Map}getClient(e){if(!this.clients.has(e)){const t=Dy[e];if(!t)throw new Error(`Unsupported network: ${e}`);const r=c.createPublicClient({chain:t,transport:c.http()});this.clients.set(e,r)}return this.clients.get(e)}async checkNativeBalance(e,t){try{const r=this.getClient(t),n=await r.getBalance({address:e}),i=c.formatUnits(n,18);return{balance:parseFloat(i),balanceWei:n.toString(),symbol:this.getNativeTokenSymbol(t),decimals:18}}catch(gu){throw new Error(`Failed to check native balance: ${gu.message}`)}}async checkTokenBalance(e,t,r){try{const n=this.getClient(r),i=c.getContract({address:t,abi:Fy,client:n}),[o,s,a]=await Promise.all([i.read.balanceOf([e]),i.read.decimals().catch(()=>18),i.read.symbol().catch(()=>"TOKEN")]);return{balance:parseFloat(c.formatUnits(o,s)),balanceWei:o.toString(),symbol:a,decimals:s,tokenAddress:t}}catch(gu){throw new Error(`Failed to check token balance: ${gu.message}`)}}async validateBalance(e,t,r,n,i=!0){try{let o,s=null;o=t.contractAddress?await this.checkTokenBalance(e,t.contractAddress,n):await this.checkNativeBalance(e,n),t.contractAddress&&i&&(s=await this.checkNativeBalance(e,n));const a=o.balance>=r,c=a?0:r-o.balance;let l=0,u=!0,d=0;if(i)if(l=this.estimateGasFee(n,!!t.contractAddress),t.contractAddress)u=s.balance>=l,d=u?0:l-s.balance;else{const e=r+l;u=o.balance>=e,d=u?0:e-o.balance}const h={isValid:a&&u,tokenBalance:o,nativeBalance:s,requiredAmount:r,estimatedGasFee:l,hasEnoughTokens:a,hasEnoughForGas:u,tokenShortfall:c,gasShortfall:d,errors:[]};if(a||h.errors.push(`Insufficient ${t.symbol} balance. Need ${r} ${t.symbol}, have ${o.balance.toFixed(6)} ${t.symbol}`),!u){const e=(null==s?void 0:s.symbol)||this.getNativeTokenSymbol(n);t.contractAddress?h.errors.push(`Insufficient ${e} for gas fees. Need ~${l.toFixed(6)} ${e}, have ${s.balance.toFixed(6)} ${e}`):h.errors.push(`Insufficient ${e} for payment + gas. Need ${(r+l).toFixed(6)} ${e} total, have ${o.balance.toFixed(6)} ${e}`)}return h}catch(gu){return{isValid:!1,errors:[`Failed to check balance: ${gu.message}`],tokenBalance:null,nativeBalance:null}}}estimateGasFee(e,t=!1){return{ethereum:t?.001:5e-4,bsc:t?5e-4:3e-4,polygon:t?.01:.005,arbitrum:t?3e-4:2e-4,optimism:t?3e-4:2e-4,avalanche:t?.001:5e-4}[e]||.001}getNativeTokenSymbol(e){return{ethereum:"ETH",bsc:"BNB",polygon:"MATIC",arbitrum:"ETH",optimism:"ETH",avalanche:"AVAX"}[e]||"ETH"}async getBalance(e,t,r){return t.contractAddress?await this.checkTokenBalance(e,t.contractAddress,r):await this.checkNativeBalance(e,r)}formatBalance(e,t,r=6){return null==e?"Unknown":0===e?`0 ${t}`:e<.001?`${e.toFixed(8)} ${t}`:e<1?`${e.toFixed(6)} ${t}`:`${e.toFixed(4)} ${t}`}async checkMultipleBalances(e,t,r){try{const n=t.map(t=>this.getBalance(e,t,r).catch(e=>({error:e.message,symbol:t.symbol,balance:0})));return await Promise.all(n)}catch(gu){throw gu}}};class Uy{constructor(e,t,r){this.baseURL=e.endsWith("/")?e.slice(0,-1):e,this.apiKey=t,this.apiSecret=r}async request(e,t={}){const r=`${this.baseURL}${e}`,n={"Content-Type":"application/json","X-API-Key":this.apiKey,"X-API-Secret":this.apiSecret,...t.headers},i=await fetch(r,{...t,headers:n});if(!i.ok){const e=await i.json().catch(()=>({}));throw new Error(e.error||`HTTP ${i.status}`)}return i.json()}async getNetworks(){try{return await this.request("/api/networks")}catch(gu){return{networks:[{id:"1",name:"Ethereum",shortName:"ethereum",chainId:"0x1",type:"ethereum"},{id:"56",name:"BSC",shortName:"bsc",chainId:"0x38",type:"bsc"},{id:"137",name:"Polygon",shortName:"polygon",chainId:"0x89",type:"polygon"},{id:"42161",name:"Arbitrum",shortName:"arbitrum",chainId:"0xa4b1",type:"arbitrum"},{id:"10",name:"Optimism",shortName:"optimism",chainId:"0xa",type:"optimism"},{id:"43114",name:"Avalanche",shortName:"avalanche",chainId:"0xa86a",type:"avalanche"},{id:"42220",name:"Celo",shortName:"celo",chainId:"0xa4ec",type:"celo"},{id:"8453",name:"Base",shortName:"base",chainId:"0x2105",type:"base"}]}}}async getTokens(){try{return await this.request("/api/networks/stablecoins")}catch(gu){return{stablecoins:[{id:"1",name:"Tether USD",symbol:"USDT",contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"2",name:"USD Coin",symbol:"USDC",contractAddress:"0xA0b86a33E641a3FA62e50A9da1CE0647a2bFBC5A",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"3",name:"Binance USD",symbol:"BUSD",contractAddress:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"4",name:"USD Coin",symbol:"USDC",contractAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"5",name:"USD Coin",symbol:"USDC",contractAddress:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"6",name:"Tether USD",symbol:"USDT",contractAddress:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"7",name:"Tether USD",symbol:"USDT",contractAddress:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"8",name:"USD Coin",symbol:"USDC",contractAddress:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"9",name:"Tether USD",symbol:"USDT",contractAddress:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"10",name:"USD Coin",symbol:"USDC",contractAddress:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"11",name:"Tether USD",symbol:"USDT",contractAddress:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"12",name:"USD Coin",symbol:"USDC",contractAddress:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"13",name:"Tether USD",symbol:"USDT",contractAddress:"0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"14",name:"USD Coin",symbol:"USDC",contractAddress:"0xcebA9300f2b948710d2653dD7B07f33A8B32118C",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"15",name:"Tether USD",symbol:"USDT",contractAddress:"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}},{id:"16",name:"USD Coin",symbol:"USDC",contractAddress:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}}]}}}async createPayment(e){return await this.request("/api/payments/create",{method:"POST",body:JSON.stringify(e)})}async updatePaymentStatus(e,t,r=null){return await this.request(`/api/payments/${e}/status`,{method:"PUT",body:JSON.stringify({status:t,transactionHash:r})})}}class By{constructor(e={}){if(!e.publicKey&&!e.apiKey)throw new Error("CoinleyVanilla: publicKey or apiKey is required");if(!e.publicKey&&!e.apiSecret)throw new Error("CoinleyVanilla: apiSecret is required when using apiKey");if(!e.apiUrl)throw new Error("CoinleyVanilla: apiUrl is required");this.config={publicKey:e.publicKey||null,apiKey:e.apiKey||null,apiSecret:e.apiSecret||null,apiUrl:e.apiUrl.replace(/\/$/,""),theme:e.theme||"light",debug:e.debug||!1,...e},this.isOpen=!1,this.root=null,this.container=null,this.callbacks={},this.currentPayment=null,this.config.debug}open(e,t={}){if(!this.isOpen)try{this._validatePaymentConfig(e),this.callbacks=t,this.currentPayment=e,this._createContainer(),this.root=h.createRoot(this.container),this.isOpen=!0,this.root.render(r.createElement(Ty,{publicKey:this.config.publicKey,apiKey:this.config.apiKey,apiSecret:this.config.apiSecret,apiUrl:this.config.apiUrl,isOpen:!0,theme:this.config.theme,config:{amount:e.amount,customerEmail:e.customerEmail,merchantName:e.merchantName||"Merchant",callbackUrl:e.callbackUrl||this._getDefaultCallbackUrl(),merchantWalletAddresses:e.merchantWalletAddresses||{},preferredNetwork:e.preferredNetwork,preferredCurrency:e.preferredCurrency,metadata:{...e.metadata,source:"vanilla-sdk",sdkVersion:"2.0.0",timestamp:(new Date).toISOString()}},onSuccess:this._handleSuccess.bind(this),onError:this._handleError.bind(this),onClose:this._handleClose.bind(this)})),this.config.debug}catch(gu){t.onError&&t.onError(gu.message||"Failed to open payment modal")}}close(){this.isOpen&&(this._cleanup(),this.config.debug)}isPaymentOpen(){return this.isOpen}updateConfig(e){this.config={...this.config,...e},this.config.debug}getConfig(){return{...this.config}}getCurrentPayment(){return this.currentPayment?{...this.currentPayment}:null}_validatePaymentConfig(e){if(!e)throw new Error("Payment configuration is required");if(!e.amount||"number"!=typeof e.amount||e.amount<=0)throw new Error("Valid amount (number > 0) is required");if(!e.customerEmail||"string"!=typeof e.customerEmail)throw new Error("Customer email is required");if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.customerEmail))throw new Error("Invalid email format");if(e.merchantWalletAddresses){if("object"!=typeof e.merchantWalletAddresses)throw new Error("merchantWalletAddresses must be an object");Object.keys(e.merchantWalletAddresses).length}}_createContainer(){this.container||(this.container=document.createElement("div"),this.container.id="coinley-payment-container",this.container.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 999999;\n ",document.body.appendChild(this.container))}_getDefaultCallbackUrl(){return"undefined"!=typeof window?`${window.location.origin}/api/webhooks/coinley`:""}_handleSuccess(e,t,r){this.config.debug,this.callbacks.onSuccess&&this.callbacks.onSuccess(e,t,r)}_handleError(e){this.config.debug,this.callbacks.onError&&this.callbacks.onError(e)}_handleClose(){this._cleanup(),this.callbacks.onClose&&this.callbacks.onClose()}_cleanup(){if(this.isOpen=!1,this.root){try{this.root.unmount()}catch(gu){}this.root=null}this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null),this.currentPayment=null}}function zy(){document.querySelectorAll('script[src*="coinley-vanilla"]').forEach(e=>{const t=e.getAttribute("data-public-key"),r=e.getAttribute("data-api-key"),n=e.getAttribute("data-api-secret"),i=e.getAttribute("data-api-url"),o=e.getAttribute("data-theme")||"light",s=e.hasAttribute("data-debug");if((t||r&&n)&&i)try{window.coinley=new By({publicKey:t,apiKey:r,apiSecret:n,apiUrl:i,theme:o,debug:s})}catch(gu){}})}"undefined"!=typeof window&&(window.CoinleyVanilla=By,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",zy):zy());class qy{constructor(e="https://paymentscreen.vercel.app/"){this.basePaymentUrl=e.endsWith("/")?e:e+"/"}generatePaymentURL(e){const{merchant:t,amount:r,productAmount:n,platformFee:i,networkFee:o,token:s="USDC",network:a="Ethereum Mainnet",merchantAddress:c}=e;if(!t)throw new Error("Merchant name is required");if(!r)throw new Error("Amount is required");if(!c)throw new Error("Merchant address (smart contract) is required");const l=n||.95*r,u=i||.03*r,d=o||.02*r,h=new URLSearchParams({merchant:t,amount:r.toString(),productAmount:l.toString(),platformFee:u.toString(),networkFee:d.toString(),token:s,network:a,merchantAddress:c});return this.basePaymentUrl+"?"+h.toString()}async generateQRCode(e,t={}){const{width:r=300,margin:n=2,colorDark:i="#7c3aed",colorLight:o="#ffffff"}=t;try{const t=this.generatePaymentURL(e);return{qrCodeDataURL:await u.toDataURL(t,{width:r,margin:n,color:{dark:i,light:o}}),paymentURL:t,paymentData:{...e,qrCodeUrl:t}}}catch(gu){throw new Error(`Failed to generate QR code: ${gu.message}`)}}async generateQRCodeToCanvas(e,t,r={}){const{width:n=300,margin:i=2,colorDark:o="#7c3aed",colorLight:s="#ffffff"}=r;try{const r=this.generatePaymentURL(e);return await u.toCanvas(t,r,{width:n,margin:i,color:{dark:o,light:s}}),r}catch(gu){throw new Error(`Failed to generate QR code to canvas: ${gu.message}`)}}validatePaymentData(e){const t=[],r=[];e.merchant||t.push("Merchant name is required"),(!e.amount||e.amount<=0)&&t.push("Valid amount is required"),e.merchantAddress||t.push("Merchant address (smart contract) is required"),e.merchantAddress&&!/^0x[a-fA-F0-9]{40}$/.test(e.merchantAddress)&&t.push("Invalid Ethereum address format for merchantAddress"),e.amount>1e4&&r.push("Large payment amount detected");return(e.platformFee||0)+(e.networkFee||0)>.1*e.amount&&r.push("High fees detected (>10% of total amount)"),{isValid:0===t.length,errors:t,warnings:r}}async createPaymentQR(e){const{merchantName:t,amount:r,productAmount:n,platformFee:i,networkFee:o,token:s,network:a,merchantWalletAddresses:c,selectedNetwork:l="ethereum",...u}=e,d={merchant:t||"Coinley Merchant",amount:r,productAmount:n,platformFee:i,networkFee:o,token:s||"USDC",network:a||"Ethereum Mainnet",merchantAddress:(null==c?void 0:c[l])||(null==c?void 0:c.ethereum)||(null==c?void 0:c.splitPaymentContract),...u},h=this.validatePaymentData(d);if(!h.isValid)throw new Error(`Payment validation failed: ${h.errors.join(", ")}`);return{...await this.generateQRCode(d),validation:h,instructions:{userAction:"Scan this QR code with your mobile wallet to pay",expectedFlow:"QR Scan โ Payment Screen โ Wallet Connect โ Split Payment โ Confirmation",supportedWallets:["MetaMask","Trust Wallet","Coinbase Wallet","WalletConnect compatible wallets"]}}}}const $y=new qy,Gy={formatAmount:(e,t=2)=>e.toFixed(t),truncateAddress:(e,t=6,r=4)=>e?e.length<=t+r?e:`${e.slice(0,t)}...${e.slice(-r)}`:"",isValidAddress:(e,t)=>{if(!e)return!1;switch(t.toLowerCase()){case"ethereum":case"bsc":case"polygon":return/^0x[a-fA-F0-9]{40}$/.test(e);case"tron":return/^T[a-zA-Z0-9]{33}$/.test(e);case"solana":return/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e);default:return e.length>0}},copyToClipboard:async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}};class Wy extends Error{constructor(e,t){super(e),this.name="CoinleyError",this.code=t}}const Vy={react:'\nimport { CoinleyProvider, CoinleyCheckout } from \'coinley-test\';\n\n// New recommended way - using publicKey only\n<CoinleyProvider\n publicKey="pk_your-public-key"\n apiUrl="https://api.coinley.io"\n>\n <CoinleyCheckout\n ref={checkoutRef}\n onSuccess={(paymentId, txHash, details) => console.log(\'Success!\')}\n onError={(error) => console.error(\'Error:\', error)}\n onClose={() => console.log(\'Closed\')}\n />\n</CoinleyProvider>\n\n// Legacy way (still supported) - using apiKey + apiSecret\n<CoinleyProvider\n apiKey="your-api-key"\n apiSecret="your-api-secret"\n apiUrl="https://api.coinley.io"\n>\n ...\n</CoinleyProvider>\n ',vanilla:'\n\x3c!-- Include via CDN --\x3e\n<script src="https://unpkg.com/coinley-test@latest/vanilla"><\/script>\n<link rel="stylesheet" href="https://unpkg.com/coinley-test@latest/vanilla/style.css">\n\n<script>\n// New recommended way - using publicKey only\nconst coinley = new CoinleyVanilla({\n publicKey: "pk_your-public-key",\n apiUrl: "https://api.coinley.io",\n theme: "light"\n});\n\n// Legacy way (still supported)\nconst coinleyLegacy = new CoinleyVanilla({\n apiKey: "your-api-key",\n apiSecret: "your-api-secret",\n apiUrl: "https://api.coinley.io",\n theme: "light"\n});\n\n// Use in checkout\ncoinley.open({\n amount: 100,\n customerEmail: "customer@example.com",\n merchantName: "Your Store",\n merchantWalletAddresses: {\n ethereum: "0x...",\n bsc: "0x..."\n }\n}, {\n onSuccess: (paymentId, txHash, details) => console.log(\'Success!\'),\n onError: (error) => console.error(\'Error:\', error),\n onClose: () => console.log(\'Closed\')\n});\n<\/script>\n '};e.CoinleyCheckout=jy,e.CoinleyError=Wy,e.CoinleyProvider=({publicKey:e,apiKey:n,apiSecret:i,apiUrl:o,theme:s="light",debug:a=!1,children:c})=>{const[l,u]=r.useState(!1),[d,h]=r.useState(null),[p,f]=r.useState({}),[m,g]=r.useState(""),y=()=>{u(!1),h(null),p.onClose&&p.onClose()},v={openPayment:(e,t)=>{h(e),t&&f(t),u(!0)},closePayment:y};return t.jsxs(Ry.Provider,{value:v,children:[c,l&&d&&t.jsx(Ty,{publicKey:e,apiKey:n,apiSecret:i,apiUrl:o,isOpen:l,config:d,theme:s,debug:a,merchantName:m,onSuccess:p.onSuccess,onError:p.onError,onClose:y})]})},e.CoinleyVanilla=By,e.DEFAULT_CONFIG={theme:"light",debug:!1,testMode:!1,autoOpen:!1},e.EnhancedSimpleCoinleyPayment=Ty,e.PaymentAPI=class{constructor(e,t,r=null){t&&t.startsWith("pk_")?(this.publicKey=t,this.apiKey=null,this.apiSecret=null):(this.publicKey=null,this.apiKey=t,this.apiSecret=r),this.api=d.create({baseURL:e.endsWith("/")?e.slice(0,-1):e,timeout:3e4,headers:{"Content-Type":"application/json"}}),this.api.interceptors.request.use(e=>{if(this.publicKey)e.headers["x-public-key"]=this.publicKey;else{e.headers["x-api-key"]=this.apiKey,e.headers["x-api-secret"]=this.apiSecret;const t=this.generateMerchantToken();t&&(e.headers.Authorization=`Bearer ${t}`)}return e},e=>Promise.reject(e)),this.api.interceptors.response.use(e=>e,e=>{var t,r,n;if(401===(null==(t=e.response)?void 0:t.status))throw new Error("Authentication failed. Please check your API credentials.");if(404===(null==(r=e.response)?void 0:r.status))throw new Error("API endpoint not found. Please check your API URL.");if((null==(n=e.response)?void 0:n.status)>=500)throw new Error("Server error. Please try again later.");throw e})}generateMerchantToken(){try{const e=`${this.apiKey}:${this.apiSecret}`;return btoa(e)}catch(gu){return null}}async request(e,t={}){var r,n;try{return(await this.api({url:e,method:t.method||"GET",data:t.data||t.body?JSON.parse(t.body||"{}"):void 0,...t})).data}catch(gu){if(null==(n=null==(r=gu.response)?void 0:r.data)?void 0:n.error)throw new Error(gu.response.data.error);throw new Error(gu.message||"Request failed")}}async createPayment(e){var t,r;try{return(await this.api.post("/api/payments/create",e)).data}catch(gu){if(null==(r=null==(t=gu.response)?void 0:t.data)?void 0:r.error)throw new Error(gu.response.data.error);throw new Error(gu.message||"Failed to create payment")}}async getPayment(e){var t,r;try{return(await this.api.get(`/api/payments/${e}`)).data}catch(gu){if(null==(r=null==(t=gu.response)?void 0:t.data)?void 0:r.error)throw new Error(gu.response.data.error);throw new Error(gu.message||"Failed to get payment details")}}async getNetworks(){try{return(await this.api.get("/api/networks")).data}catch(gu){return{networks:[{id:"ethereum",name:"Ethereum",shortName:"ethereum",chainId:1,type:"ethereum",explorerUrl:"https://etherscan.io",isTestnet:!1},{id:"bsc",name:"Binance Smart Chain",shortName:"bsc",chainId:56,type:"bsc",explorerUrl:"https://bscscan.com",isTestnet:!1},{id:"polygon",name:"Polygon",shortName:"polygon",chainId:137,type:"ethereum",explorerUrl:"https://polygonscan.com",isTestnet:!1}]}}}async getStablecoins(){try{return(await this.api.get("/api/networks/stablecoins")).data}catch(gu){return{stablecoins:[{id:"usdt-eth",name:"Tether USD",symbol:"USDT",contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,isStablecoin:!0,networkId:"ethereum",Network:{id:"ethereum",name:"Ethereum",shortName:"ethereum",type:"ethereum"}},{id:"usdc-eth",name:"USD Coin",symbol:"USDC",contractAddress:"0xA0b86a33E6441d81d0B93bF9EE0f74ca32F7e6f6",decimals:6,isStablecoin:!0,networkId:"ethereum",Network:{id:"ethereum",name:"Ethereum",shortName:"ethereum",type:"ethereum"}}]}}}async verifyQRPayment(e){var t,r;try{return(await this.api.post("/api/payments/verify-qr",{paymentId:e})).data}catch(gu){if(null==(r=null==(t=gu.response)?void 0:t.data)?void 0:r.error)throw new Error(gu.response.data.error);throw new Error(gu.message||"Failed to verify payment")}}async processPayment(e,t,r,n){var i;try{return(await this.api.post("/api/payments/process",{paymentId:e,transactionHash:t,network:r,senderAddress:n})).data}catch(gu){if(null==(i=gu.response)?void 0:i.data){const t=gu.response.data,r=t.error||t.message||"Payment processing failed",n=new Error(r);throw n.isAlreadyCompleted=t.isAlreadyCompleted||!1,n.verificationAttempts=t.verificationAttempts||0,n.statusCode=gu.response.status,n.originalData=t,n}throw new Error(gu.message||"Failed to process PaymentSplitter transaction")}}async getContractInfo(e){var t,r;try{return(await this.api.get(`/api/payments/contract/${e}`)).data.contractInfo}catch(gu){if(null==(r=null==(t=gu.response)?void 0:t.data)?void 0:r.error)throw new Error(gu.response.data.error);throw new Error(gu.message||"Failed to get contract information")}}async getPaymentSplitterStatus(e){var t,r;try{return(await this.api.get(`/api/payments/splitter-status/${e}`)).data.paymentSplitterStatus}catch(gu){if(null==(r=null==(t=gu.response)?void 0:t.data)?void 0:r.error)throw new Error(gu.response.data.error);throw new Error(gu.message||"Failed to get PaymentSplitter status")}}async checkPaymentSplitterHealth(){try{return(await this.api.get("/api/payments/health")).data.paymentSplitterHealth}catch(gu){return{error:gu.message}}}async healthCheck(){try{return 200===(await this.api.get("/api/health")).status}catch(gu){return!1}}},e.PaymentQRGenerator=qy,e.QRCodePayment=({apiKey:e,apiSecret:n,apiUrl:i,config:o,onSuccess:s,onError:a,onClose:c,isOpen:l,theme:d="light",mode:h="splitpayment",splitPaymentUrl:p="https://paymentscreen.vercel.app/"})=>{var f;const[m,g]=r.useState("network"),[y,v]=r.useState([]),[b,w]=r.useState([]),[x,_]=r.useState(null),[k,S]=r.useState(null),[C,I]=r.useState(null),[E,N]=r.useState(!1),[A,P]=r.useState(""),[O,M]=r.useState(""),[T,R]=r.useState(""),[j,D]=r.useState(""),[F,L]=r.useState(!1),[U,B]=r.useState(""),[z,q]=r.useState(!1),[$,G]=r.useState(null),W=r.useRef(new Uy(i,e,n)),V=r.useRef(null);r.useEffect(()=>(l&&(Y(),H()),()=>{V.current&&clearInterval(V.current)}),[l]);const H=()=>{g("network"),_(null),S(null),I(null),P(""),M(""),R(""),D(""),L(!1),B(""),q(!1),G(null),V.current&&clearInterval(V.current)},Y=async()=>{try{N(!0),P("");const[e,t]=await Promise.all([W.current.getNetworks(),W.current.getTokens()]);v(e.networks||[]),w(t.stablecoins||[])}catch(Hy){P("Failed to load payment options.")}finally{N(!1)}},Z=async e=>{if(!k||!x||!C)return!1;try{const t=await Ly.validateBalance(e,k,C.totalAmount,x.shortName,!0);return G(t),!!t.isValid||(P(`Insufficient balance: ${t.errors.join(", ")}`),!1)}catch(t){return P(`Failed to check balance: ${t.message}`),!1}};if(!l)return null;const K="dark"===d;return t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:t.jsxs("div",{className:"rounded-lg shadow-xl max-w-md w-full mx-4 "+(K?"bg-gray-900 text-white":"bg-white text-gray-900"),children:[t.jsxs("div",{className:"p-4 border-b flex justify-between items-center "+(K?"border-gray-700":"border-gray-200"),children:[t.jsxs("div",{className:"text-center flex-1",children:[t.jsx("h2",{className:"text-lg font-semibold",children:"splitpayment"===h?"Split Payment QR":"QR Code Payment"}),o.amount&&t.jsxs("p",{className:"text-2xl font-bold text-purple-600",children:["$",o.amount.toFixed(2)]}),t.jsx("p",{className:"text-xs text-blue-600",children:"splitpayment"===h?"๐ฑ Scan to redirect to payment screen":"๐ฑ Scan with mobile wallet"})]}),t.jsx("button",{onClick:c,className:"ml-4 text-gray-500 hover:text-gray-700 "+(K?"hover:text-gray-300":""),children:"โ"})]}),t.jsxs("div",{className:"p-4 min-h-[400px]",children:[A&&t.jsxs("div",{className:"mb-4 p-3 bg-red-100 text-red-700 rounded border border-red-200",children:[A,t.jsx("button",{onClick:()=>P(""),className:"ml-2 text-red-500 hover:text-red-700",children:"โ"})]}),"network"===m&&t.jsxs("div",{className:"space-y-4",children:[t.jsx("h3",{className:"font-medium text-center",children:"Select Network"}),t.jsx("div",{className:"space-y-2",children:y.map(e=>{var r;const n=null==(r=o.merchantWalletAddresses)?void 0:r[e.shortName];return t.jsxs("button",{onClick:()=>{_(e),g("token")},disabled:!n,className:"w-full p-3 border rounded-lg text-left transition-colors "+(n?"hover:border-purple-500 "+(K?"border-gray-600 hover:bg-gray-800":"border-gray-200 hover:bg-gray-50"):"opacity-50 cursor-not-allowed "+(K?"border-gray-700":"border-gray-100")),children:[t.jsx("div",{className:"font-medium",children:e.name}),t.jsxs("div",{className:"text-sm "+(K?"text-gray-400":"text-gray-500"),children:[e.shortName.toUpperCase(),!n&&" (No merchant address configured)"]})]},e.id)})})]}),"token"===m&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx("button",{onClick:()=>g("network"),className:""+(K?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),children:"โ"}),t.jsxs("h3",{className:"font-medium",children:["Select Token on ",null==x?void 0:x.name]})]}),t.jsx("div",{className:"space-y-2",children:b.filter(e=>{var t;return(null==(t=e.Network)?void 0:t.shortName)===(null==x?void 0:x.shortName)}).map(e=>t.jsxs("button",{onClick:()=>{S(e),(async e=>{var t,r;try{N(!0),P("");const n={amount:o.amount,currency:e.symbol,network:x.shortName,customerEmail:o.customerEmail,callbackUrl:o.callbackUrl,metadata:{...o.metadata,merchantWalletAddresses:o.merchantWalletAddresses,paymentMethod:"split_payment_qr",selectedNetwork:x.shortName,selectedToken:e.symbol}},i=await W.current.createPayment(n);I(i.payment);const s=(null==(t=o.merchantWalletAddresses)?void 0:t.splitPaymentContract)||(null==(r=o.merchantWalletAddresses)?void 0:r[x.shortName]);if(!s)throw new Error("Split payment contract address not found in config");const a=new URLSearchParams({merchant:o.merchantName||"Coinley Merchant",amount:i.payment.totalAmount.toString(),productAmount:(.95*i.payment.totalAmount).toFixed(2),platformFee:(.03*i.payment.totalAmount).toFixed(2),networkFee:(.02*i.payment.totalAmount).toFixed(2),token:e.symbol,network:x.name,merchantAddress:s,paymentId:i.payment.id}),c=p+"?"+a.toString();M(c);const l=await u.toDataURL(c,{width:256,margin:2,color:{dark:"#7c3aed",light:"#ffffff"}});R(l),g("scan")}catch(n){P(n.message||"Failed to generate split payment QR code")}finally{N(!1)}})(e)},disabled:E,className:"w-full p-3 border rounded-lg hover:border-purple-500 text-left transition-colors disabled:opacity-50 "+(K?"border-gray-600 hover:bg-gray-800":"border-gray-200 hover:bg-gray-50"),children:[t.jsx("div",{className:"font-medium",children:e.name}),t.jsx("div",{className:"text-sm "+(K?"text-gray-400":"text-gray-500"),children:e.symbol})]},e.id))})]}),"scan"===m&&t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"text-center",children:[t.jsx("h3",{className:"font-medium mb-4",children:"splitpayment"===h?"Scan QR Code to Open Payment Screen":"Scan QR Code with Mobile Wallet"}),T?t.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[t.jsx("div",{className:"p-4 rounded-lg "+(K?"bg-gray-800":"bg-gray-50"),children:t.jsx("img",{src:T,alt:"Payment QR Code",className:"mx-auto",style:{width:"200px",height:"200px"}})}),t.jsxs("div",{className:"text-sm space-y-1 "+(K?"text-gray-300":"text-gray-600"),children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Amount:"}),t.jsxs("span",{className:"font-medium",children:[null==C?void 0:C.totalAmount," ",null==k?void 0:k.symbol]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Network:"}),t.jsx("span",{className:"font-medium",children:null==x?void 0:x.name})]}),"splitpayment"===h&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Merchant:"}),t.jsx("span",{className:"font-medium",children:o.merchantName||"Coinley Merchant"})]})]}),t.jsx("div",{className:"p-3 rounded-lg text-xs "+(K?"bg-blue-900 text-blue-200":"bg-blue-50 text-blue-600"),children:"splitpayment"===h?t.jsxs(t.Fragment,{children:["๐ฑ Scan this QR code with your mobile wallet to open the payment screen.",t.jsx("br",{}),"The payment screen will auto-connect your wallet and execute the split payment."]}):"๐ฑ Open your mobile wallet and scan this QR code to connect and pay"}),"splitpayment"===h?t.jsx("button",{onClick:()=>window.open(O,"_blank"),className:"w-full bg-purple-600 text-white py-2 px-4 rounded hover:bg-purple-700 text-sm",children:"๐ Test Payment Screen (Opens in new tab)"}):t.jsx("button",{onClick:async()=>{try{N(!0),P("");const e="0x742d35Cc6634C0532925a3b8D9a5C7C47C77E4";B(e),L(!0),await Z(e),g("confirm")}catch(e){P("Failed to simulate wallet connection")}finally{N(!1)}},disabled:E,className:"w-full bg-gray-600 text-white py-2 px-4 rounded hover:bg-gray-700 disabled:opacity-50 text-sm",children:E?"Connecting...":"๐งช Simulate Wallet Scan (Test)"})]}):t.jsxs("div",{className:"flex items-center justify-center py-8",children:[t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-purple-600"}),t.jsx("span",{className:"ml-2",children:"Generating QR Code..."})]})]})}),"confirm"===m&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4",children:t.jsx("span",{className:"text-2xl",children:"๐ฑ"})}),t.jsx("h3",{className:"font-medium",children:"Mobile Wallet Connected"}),t.jsx("p",{className:"text-sm mt-2 "+(K?"text-gray-300":"text-gray-600"),children:"Ready to complete payment"})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"p-3 bg-green-50 rounded-lg border border-green-200",children:[t.jsx("p",{className:"text-green-600 text-sm font-medium",children:"โ
Wallet Connected"}),t.jsxs("p",{className:"font-mono text-xs text-green-700 mt-1",children:[null==U?void 0:U.slice(0,6),"...",null==U?void 0:U.slice(-4)]})]}),$&&t.jsx("div",{className:"p-3 rounded-lg border "+($.isValid?"bg-green-50 border-green-200":"bg-red-50 border-red-200"),children:t.jsxs("div",{className:"space-y-2 text-sm",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Required:"}),t.jsxs("span",{className:"font-medium",children:[null==C?void 0:C.totalAmount," ",null==k?void 0:k.symbol]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Your Balance:"}),t.jsx("span",{className:"font-medium "+($.hasEnoughTokens?"text-green-600":"text-red-600"),children:Ly.formatBalance(null==(f=$.tokenBalance)?void 0:f.balance,null==k?void 0:k.symbol)})]}),$.nativeBalance&&t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{children:"Gas Balance:"}),t.jsx("span",{className:"font-medium "+($.hasEnoughForGas?"text-green-600":"text-red-600"),children:Ly.formatBalance($.nativeBalance.balance,$.nativeBalance.symbol)})]})]})}),t.jsx("button",{onClick:async()=>{try{q(!0),P("");const e=`0x${Math.random().toString(16).substring(2,66)}`;await new Promise(e=>setTimeout(e,3e3)),g("success"),null==s||s(C.id,e,{network:x.name,token:k.symbol,amount:C.totalAmount,method:"qr_code",walletAddress:U})}catch(e){P("Transaction confirmation failed")}finally{q(!1)}},disabled:z||!(null==$?void 0:$.isValid),className:"w-full bg-green-600 text-white py-3 px-4 rounded-lg hover:bg-green-700 disabled:opacity-50 font-medium",children:z?"Processing Payment...":(null==$?void 0:$.isValid)?`Confirm Payment of ${null==C?void 0:C.totalAmount} ${null==k?void 0:k.symbol}`:"Insufficient Balance"})]})]}),"success"===m&&t.jsxs("div",{className:"text-center space-y-4",children:[t.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto",children:t.jsx("span",{className:"text-2xl",children:"โ
"})}),t.jsx("h3",{className:"font-medium text-green-600",children:"Payment Successful!"}),t.jsx("p",{className:"text-sm "+(K?"text-gray-300":"text-gray-600"),children:"Transaction completed via QR code scan"}),t.jsx("button",{onClick:c,className:"w-full bg-green-600 text-white py-3 px-4 rounded-lg hover:bg-green-700 font-medium",children:"Close"})]}),E&&"scan"!==m&&"confirm"!==m&&t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-purple-600"})})]})]})})},e.SimpleCoinleyProvider=({children:e,...t})=>e,e.ThemeProvider=({initialTheme:e="light",children:n})=>{const[i,o]=r.useState(e);return r.useEffect(()=>{document.documentElement.setAttribute("data-coinley-theme",i)},[i]),t.jsx("div",{className:`coinley-theme-${i}`,children:n})},e.USAGE_EXAMPLES=Vy,e.VERSION="0.0.26",e.generatePaymentQR=(e,t)=>$y.generateQRCode(e,t),e.generatePaymentURL=e=>$y.generatePaymentURL(e),e.paymentQR=$y,e.sdkAnalytics=af,e.useCoinley=()=>{const e=r.useContext(Ry);if(!e)throw new Error("useCoinley must be used within a CoinleyProvider");return e},e.utils=Gy,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
3
3
|
//# sourceMappingURL=index.umd.js.map
|