multicoyn-sdk 0.1.6 → 0.1.7

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/README.md CHANGED
@@ -44,21 +44,49 @@ function App() {
44
44
  ### 2. Use the Payment Button
45
45
 
46
46
  ```tsx
47
- import { MulticoynButton } from 'multicoyn-sdk';
47
+ import { MulticoynButton, type PaymentConfig } from 'multicoyn-sdk';
48
48
 
49
49
  function YourComponent() {
50
+ const handlePaymentComplete = (result) => {
51
+ console.log('Payment success:', result.transactionId);
52
+ };
53
+
54
+ const handlePaymentError = (error) => {
55
+ console.error('Payment error:', error.message);
56
+ };
57
+
50
58
  return (
51
59
  <MulticoynButton
52
- amount="100"
53
- currency="USD"
54
- recipientAddress="0x..."
55
- onSuccess={(txHash) => console.log('Payment success:', txHash)}
56
- onError={(error) => console.error('Payment error:', error)}
60
+ totalAmount={100}
61
+ merchantAddress="0x..."
62
+ items={[
63
+ { name: "Product 1", price: 50 },
64
+ { name: "Product 2", price: 50 }
65
+ ]}
66
+ currency="USD" // or "IDR" - automatically determines settlement currency
67
+ onPaymentComplete={handlePaymentComplete}
68
+ onPaymentError={handlePaymentError}
57
69
  />
58
70
  );
59
71
  }
60
72
  ```
61
73
 
74
+ #### Advanced Usage with Smart Contract Interaction
75
+
76
+ ```tsx
77
+ <MulticoynButton
78
+ totalAmount={100}
79
+ merchantAddress="0x..."
80
+ items={[{ name: "NFT Mint", price: 100 }]}
81
+ currency="USD" // or "IDR" - automatically determines settlement currency
82
+ // Optional: Execute custom contract call after payment
83
+ target="0xNFTContractAddress"
84
+ callData="0x..." // encoded function call
85
+ onPaymentComplete={handlePaymentComplete}
86
+ onPaymentError={handlePaymentError}
87
+ />
88
+ ```
89
+
62
90
  ### 3. Access Payment Configuration
63
91
 
64
92
  ```tsx
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BfUc8rJl.cjs");function k(r){const{abi:n,data:a}=r,o=e.slice(a,0,4),t=n.find(s=>s.type==="function"&&o===e.toFunctionSelector(e.formatAbiItem(s)));if(!t)throw new e.AbiFunctionSignatureNotFoundError(o,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:t.name,args:"inputs"in t&&t.inputs&&t.inputs.length>0?e.decodeAbiParameters(t.inputs,e.slice(a,4)):void 0}}const h="/docs/contract/encodeErrorResult";function y(r){const{abi:n,errorName:a,args:o}=r;let t=n[0];if(a){const f=e.getAbiItem({abi:n,args:o,name:a});if(!f)throw new e.AbiErrorNotFoundError(a,{docsPath:h});t=f}if(t.type!=="error")throw new e.AbiErrorNotFoundError(void 0,{docsPath:h});const s=e.formatAbiItem(t),c=e.toFunctionSelector(s);let i="0x";if(o&&o.length>0){if(!t.inputs)throw new e.AbiErrorInputsNotFoundError(t.name,{docsPath:h});i=e.encodeAbiParameters(t.inputs,o)}return e.concatHex([c,i])}const m="/docs/contract/encodeFunctionResult";function L(r){const{abi:n,functionName:a,result:o}=r;let t=n[0];if(a){const c=e.getAbiItem({abi:n,name:a});if(!c)throw new e.AbiFunctionNotFoundError(a,{docsPath:m});t=c}if(t.type!=="function")throw new e.AbiFunctionNotFoundError(void 0,{docsPath:m});if(!t.outputs)throw new e.AbiFunctionOutputsNotFoundError(t.name,{docsPath:m});const s=(()=>{if(t.outputs.length===0)return[];if(t.outputs.length===1)return[o];if(Array.isArray(o))return o;throw new e.InvalidArrayError(o)})();return e.encodeAbiParameters(t.outputs,s)}const b="x-batch-gateway:true";async function g(r){const{data:n,ccipRequest:a}=r,{args:[o]}=k({abi:e.batchGatewayAbi,data:n}),t=[],s=[];return await Promise.all(o.map(async(c,i)=>{try{s[i]=c.urls.includes(b)?await g({data:c.data,ccipRequest:a}):await a(c),t[i]=!1}catch(f){t[i]=!0,s[i]=F(f)}})),L({abi:e.batchGatewayAbi,functionName:"query",result:[t,s]})}function F(r){return r.name==="HttpRequestError"&&r.status?y({abi:e.batchGatewayAbi,errorName:"HttpError",args:[r.status,r.shortMessage]}):y({abi:[e.solidityError],errorName:"Error",args:["shortMessage"in r?r.shortMessage:r.message]})}function O(r,n){if(!e.isAddress(r,{strict:!1}))throw new e.InvalidAddressError({address:r});if(!e.isAddress(n,{strict:!1}))throw new e.InvalidAddressError({address:n});return r.toLowerCase()===n.toLowerCase()}class P extends e.BaseError{constructor({callbackSelector:n,cause:a,data:o,extraData:t,sender:s,urls:c}){super(a.shortMessage||"An error occurred while fetching for an offchain result.",{cause:a,metaMessages:[...a.metaMessages||[],a.metaMessages?.length?"":[],"Offchain Gateway Call:",c&&[" Gateway URL(s):",...c.map(i=>` ${e.getUrl(i)}`)],` Sender: ${s}`,` Data: ${o}`,` Callback selector: ${n}`,` Extra data: ${t}`].flat(),name:"OffchainLookupError"})}}class S extends e.BaseError{constructor({result:n,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${e.getUrl(a)}`,`Response: ${e.stringify(n)}`],name:"OffchainLookupResponseMalformedError"})}}class x extends e.BaseError{constructor({sender:n,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${n}`],name:"OffchainLookupSenderMismatchError"})}}const M="0x556f1830",E={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function N(r,{blockNumber:n,blockTag:a,data:o,to:t}){const{args:s}=e.decodeErrorResult({data:o,abi:[E]}),[c,i,f,u,d]=s,{ccipRead:l}=r,w=l&&typeof l?.request=="function"?l.request:A;try{if(!O(t,c))throw new x({sender:c,to:t});const p=i.includes(b)?await g({data:f,ccipRequest:w}):await w({data:f,sender:c,urls:i}),{data:R}=await e.call(r,{blockNumber:n,blockTag:a,data:e.concat([u,e.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[p,d])]),to:t});return R}catch(p){throw new P({callbackSelector:u,cause:p,data:o,extraData:d,sender:c,urls:i})}}async function A({data:r,sender:n,urls:a}){let o=new Error("An unknown error occurred.");for(let t=0;t<a.length;t++){const s=a[t],c=s.includes("{data}")?"GET":"POST",i=c==="POST"?{data:r,sender:n}:void 0,f=c==="POST"?{"Content-Type":"application/json"}:{};try{const u=await fetch(s.replace("{sender}",n.toLowerCase()).replace("{data}",r),{body:JSON.stringify(i),headers:f,method:c});let d;if(u.headers.get("Content-Type")?.startsWith("application/json")?d=(await u.json()).data:d=await u.text(),!u.ok){o=new e.HttpRequestError({body:i,details:d?.error?e.stringify(d.error):u.statusText,headers:u.headers,status:u.status,url:s});continue}if(!e.isHex(d)){o=new S({result:d,url:s});continue}return d}catch(u){o=new e.HttpRequestError({body:i,details:u.message,url:s})}}throw o}exports.ccipRequest=A;exports.offchainLookup=N;exports.offchainLookupAbiItem=E;exports.offchainLookupSignature=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-54Nnnds1.cjs");function k(r){const{abi:n,data:a}=r,o=e.slice(a,0,4),t=n.find(s=>s.type==="function"&&o===e.toFunctionSelector(e.formatAbiItem(s)));if(!t)throw new e.AbiFunctionSignatureNotFoundError(o,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:t.name,args:"inputs"in t&&t.inputs&&t.inputs.length>0?e.decodeAbiParameters(t.inputs,e.slice(a,4)):void 0}}const h="/docs/contract/encodeErrorResult";function y(r){const{abi:n,errorName:a,args:o}=r;let t=n[0];if(a){const f=e.getAbiItem({abi:n,args:o,name:a});if(!f)throw new e.AbiErrorNotFoundError(a,{docsPath:h});t=f}if(t.type!=="error")throw new e.AbiErrorNotFoundError(void 0,{docsPath:h});const s=e.formatAbiItem(t),c=e.toFunctionSelector(s);let i="0x";if(o&&o.length>0){if(!t.inputs)throw new e.AbiErrorInputsNotFoundError(t.name,{docsPath:h});i=e.encodeAbiParameters(t.inputs,o)}return e.concatHex([c,i])}const m="/docs/contract/encodeFunctionResult";function L(r){const{abi:n,functionName:a,result:o}=r;let t=n[0];if(a){const c=e.getAbiItem({abi:n,name:a});if(!c)throw new e.AbiFunctionNotFoundError(a,{docsPath:m});t=c}if(t.type!=="function")throw new e.AbiFunctionNotFoundError(void 0,{docsPath:m});if(!t.outputs)throw new e.AbiFunctionOutputsNotFoundError(t.name,{docsPath:m});const s=(()=>{if(t.outputs.length===0)return[];if(t.outputs.length===1)return[o];if(Array.isArray(o))return o;throw new e.InvalidArrayError(o)})();return e.encodeAbiParameters(t.outputs,s)}const b="x-batch-gateway:true";async function g(r){const{data:n,ccipRequest:a}=r,{args:[o]}=k({abi:e.batchGatewayAbi,data:n}),t=[],s=[];return await Promise.all(o.map(async(c,i)=>{try{s[i]=c.urls.includes(b)?await g({data:c.data,ccipRequest:a}):await a(c),t[i]=!1}catch(f){t[i]=!0,s[i]=F(f)}})),L({abi:e.batchGatewayAbi,functionName:"query",result:[t,s]})}function F(r){return r.name==="HttpRequestError"&&r.status?y({abi:e.batchGatewayAbi,errorName:"HttpError",args:[r.status,r.shortMessage]}):y({abi:[e.solidityError],errorName:"Error",args:["shortMessage"in r?r.shortMessage:r.message]})}function O(r,n){if(!e.isAddress(r,{strict:!1}))throw new e.InvalidAddressError({address:r});if(!e.isAddress(n,{strict:!1}))throw new e.InvalidAddressError({address:n});return r.toLowerCase()===n.toLowerCase()}class P extends e.BaseError{constructor({callbackSelector:n,cause:a,data:o,extraData:t,sender:s,urls:c}){super(a.shortMessage||"An error occurred while fetching for an offchain result.",{cause:a,metaMessages:[...a.metaMessages||[],a.metaMessages?.length?"":[],"Offchain Gateway Call:",c&&[" Gateway URL(s):",...c.map(i=>` ${e.getUrl(i)}`)],` Sender: ${s}`,` Data: ${o}`,` Callback selector: ${n}`,` Extra data: ${t}`].flat(),name:"OffchainLookupError"})}}class S extends e.BaseError{constructor({result:n,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${e.getUrl(a)}`,`Response: ${e.stringify(n)}`],name:"OffchainLookupResponseMalformedError"})}}class x extends e.BaseError{constructor({sender:n,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${n}`],name:"OffchainLookupSenderMismatchError"})}}const M="0x556f1830",E={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function N(r,{blockNumber:n,blockTag:a,data:o,to:t}){const{args:s}=e.decodeErrorResult({data:o,abi:[E]}),[c,i,f,u,d]=s,{ccipRead:l}=r,w=l&&typeof l?.request=="function"?l.request:A;try{if(!O(t,c))throw new x({sender:c,to:t});const p=i.includes(b)?await g({data:f,ccipRequest:w}):await w({data:f,sender:c,urls:i}),{data:R}=await e.call(r,{blockNumber:n,blockTag:a,data:e.concat([u,e.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[p,d])]),to:t});return R}catch(p){throw new P({callbackSelector:u,cause:p,data:o,extraData:d,sender:c,urls:i})}}async function A({data:r,sender:n,urls:a}){let o=new Error("An unknown error occurred.");for(let t=0;t<a.length;t++){const s=a[t],c=s.includes("{data}")?"GET":"POST",i=c==="POST"?{data:r,sender:n}:void 0,f=c==="POST"?{"Content-Type":"application/json"}:{};try{const u=await fetch(s.replace("{sender}",n.toLowerCase()).replace("{data}",r),{body:JSON.stringify(i),headers:f,method:c});let d;if(u.headers.get("Content-Type")?.startsWith("application/json")?d=(await u.json()).data:d=await u.text(),!u.ok){o=new e.HttpRequestError({body:i,details:d?.error?e.stringify(d.error):u.statusText,headers:u.headers,status:u.status,url:s});continue}if(!e.isHex(d)){o=new S({result:d,url:s});continue}return d}catch(u){o=new e.HttpRequestError({body:i,details:u.message,url:s})}}throw o}exports.ccipRequest=A;exports.offchainLookup=N;exports.offchainLookupAbiItem=E;exports.offchainLookupSignature=M;
@@ -1,4 +1,4 @@
1
- import { s as b, t as x, f as F, A as I, d as C, g as M, a as E, b as D, e as w, c as G, h as A, i as T, I as H, j as m, k as v, l as R, m as k, B as y, n as N, o as P, p as j, q as B, r as U, H as L, u as _ } from "./index-D8LL3fRQ.js";
1
+ import { s as b, t as x, f as F, A as I, d as C, g as M, a as E, b as D, e as w, c as G, h as A, i as T, I as H, j as m, k as v, l as R, m as k, B as y, n as N, o as P, p as j, q as B, r as U, H as L, u as _ } from "./index-w8B8C2nn.js";
2
2
  function J(e) {
3
3
  const { abi: s, data: a } = e, r = b(a, 0, 4), t = s.find((n) => n.type === "function" && r === x(F(n)));
4
4
  if (!t)
@@ -1,16 +1,2 @@
1
- import type { PaymentItem, PaymentResult } from "./types";
2
- interface MulticoynButtonProps {
3
- totalAmount: number;
4
- merchantAddress: `0x${string}`;
5
- currency?: string;
6
- items: PaymentItem[];
7
- settleInIDR?: boolean;
8
- target?: `0x${string}`;
9
- callData?: `0x${string}`;
10
- onPaymentComplete?: (result: PaymentResult) => void;
11
- onPaymentError?: (error: Error) => void;
12
- className?: string;
13
- children?: React.ReactNode;
14
- }
15
- export declare function MulticoynButton({ totalAmount, merchantAddress, currency, items, settleInIDR, target, callData, onPaymentComplete, onPaymentError, className, children, }: MulticoynButtonProps): import("react/jsx-runtime").JSX.Element;
16
- export {};
1
+ import type { MulticoynButtonProps } from "./types";
2
+ export declare function MulticoynButton({ merchantAddress, items, config, onPaymentComplete, onPaymentError, className, children, }: MulticoynButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -11,6 +11,7 @@ interface PaymentModalProps {
11
11
  transactionHash?: string;
12
12
  isProcessing?: boolean;
13
13
  isSuccess?: boolean;
14
+ conversionRate?: number;
14
15
  }
15
- export declare function PaymentModal({ isOpen, onClose, totalAmount, currency, items, tokens: initialTokens, onPaymentSubmit, fee, transactionHash, isProcessing: externalIsProcessing, isSuccess: externalIsSuccess, }: PaymentModalProps): import("react").ReactPortal | null;
16
+ export declare function PaymentModal({ isOpen, onClose, totalAmount, currency, items, tokens: initialTokens, onPaymentSubmit, fee, transactionHash, isProcessing: externalIsProcessing, isSuccess: externalIsSuccess, conversionRate, }: PaymentModalProps): import("react").ReactPortal | null;
16
17
  export {};
@@ -2,6 +2,7 @@ import type { PaymentItem } from "./types";
2
2
  interface PaymentSummaryProps {
3
3
  items: PaymentItem[];
4
4
  fee?: number;
5
+ currency?: string;
5
6
  }
6
- export declare function PaymentSummary({ items, fee }: PaymentSummaryProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function PaymentSummary({ items, fee, currency }: PaymentSummaryProps): import("react/jsx-runtime").JSX.Element;
7
8
  export {};
@@ -3,6 +3,9 @@ interface TokenSliderProps {
3
3
  token: Token;
4
4
  onChange: (percentage: number) => void;
5
5
  totalAmount: number;
6
+ displayAmount?: number;
7
+ currency?: string;
8
+ disabled?: boolean;
6
9
  }
7
- export declare function TokenSlider({ token, onChange, totalAmount, }: TokenSliderProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function TokenSlider({ token, onChange, totalAmount, displayAmount, currency, disabled, }: TokenSliderProps): import("react/jsx-runtime").JSX.Element;
8
11
  export {};
@@ -16,15 +16,15 @@ export interface PaymentItem {
16
16
  name: string;
17
17
  price: number;
18
18
  }
19
- export interface MulticoynButtonProps {
20
- totalAmount: number;
21
- currency?: string;
22
- items: PaymentItem[];
23
- tokens?: Token[];
24
- merchantAddress: string;
25
- settleInIDR?: boolean;
19
+ export interface PaymentConfig {
20
+ currency?: "USD" | "IDR";
26
21
  target?: `0x${string}`;
27
22
  callData?: `0x${string}`;
23
+ }
24
+ export interface MulticoynButtonProps {
25
+ merchantAddress: `0x${string}`;
26
+ items: PaymentItem[];
27
+ config?: PaymentConfig;
28
28
  onPaymentComplete?: (result: PaymentResult) => void;
29
29
  onPaymentError?: (error: Error) => void;
30
30
  className?: string;
@@ -0,0 +1,34 @@
1
+ "use strict";const c=require("react/jsx-runtime"),I=require("react"),A=require("wagmi"),Er=require("react-dom"),fe=require("viem"),Qt=require("@tanstack/react-query"),qt=require("@rainbow-me/rainbowkit");function Pr({size:e=26,className:t=""}){return c.jsx("svg",{width:e,height:e,viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:c.jsx("path",{d:"M6.5 6.5L19.5 19.5M6.5 19.5L19.5 6.5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Sr({size:e=16,className:t=""}){return c.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[c.jsx("path",{d:"M7.33333 12.6667C10.2789 12.6667 12.6667 10.2789 12.6667 7.33333C12.6667 4.38781 10.2789 2 7.33333 2C4.38781 2 2 4.38781 2 7.33333C2 10.2789 4.38781 12.6667 7.33333 12.6667Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M14 14L11.1 11.1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ar({size:e=16,className:t=""}){return c.jsxs("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[c.jsx("path",{d:"M8 14.6667C11.6819 14.6667 14.6667 11.6819 14.6667 8C14.6667 4.3181 11.6819 1.33333 8 1.33333C4.3181 1.33333 1.33333 4.3181 1.33333 8C1.33333 11.6819 4.3181 14.6667 8 14.6667Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M8 10.6667V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M8 5.33333H8.00667",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}function $r({size:e=134,className:t=""}){return c.jsxs("svg",{width:e,height:e,viewBox:"0 0 134 132",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[c.jsx("circle",{cx:"67",cy:"66",r:"55",fill:"#5EEAD4",fillOpacity:"0.2"}),c.jsx("circle",{cx:"67",cy:"66",r:"45",fill:"#5EEAD4",fillOpacity:"0.3"}),c.jsx("rect",{x:"35",y:"30",width:"45",height:"72",rx:"4",fill:"#14B8A6"}),c.jsx("rect",{x:"38",y:"35",width:"39",height:"55",rx:"2",fill:"#0D9488"}),c.jsxs("g",{className:"animate-pulse",children:[c.jsx("rect",{x:"55",y:"50",width:"50",height:"32",rx:"3",fill:"#1E293B"}),c.jsx("rect",{x:"60",y:"56",width:"20",height:"3",rx:"1",fill:"#475569"}),c.jsx("rect",{x:"60",y:"62",width:"30",height:"2",rx:"1",fill:"#475569"}),c.jsx("rect",{x:"60",y:"68",width:"15",height:"2",rx:"1",fill:"#475569"})]}),c.jsx("ellipse",{cx:"95",cy:"85",rx:"12",ry:"8",fill:"#FCD9BD"}),c.jsx("rect",{x:"88",y:"78",width:"8",height:"20",rx:"4",fill:"#FCD9BD"}),c.jsx("circle",{cx:"20",cy:"25",r:"8",fill:"#FCD34D"}),c.jsx("text",{x:"20",y:"29",textAnchor:"middle",fontSize:"10",fill:"#92400E",children:"$"}),c.jsx("circle",{cx:"115",cy:"35",r:"6",fill:"#FCD34D"}),c.jsx("text",{x:"115",y:"38",textAnchor:"middle",fontSize:"8",fill:"#92400E",children:"$"}),c.jsx("circle",{cx:"110",cy:"20",r:"5",fill:"#FCD34D",fillOpacity:"0.6"})]})}function Cr({size:e=95,className:t=""}){return c.jsxs("svg",{width:e*2.1,height:e,viewBox:"0 0 200 95",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[c.jsx("circle",{cx:"30",cy:"20",r:"3",fill:"#FCD34D"}),c.jsx("circle",{cx:"170",cy:"25",r:"4",fill:"#5EEAD4"}),c.jsx("circle",{cx:"25",cy:"70",r:"2",fill:"#A78BFA"}),c.jsx("circle",{cx:"175",cy:"65",r:"3",fill:"#F472B6"}),c.jsx("circle",{cx:"50",cy:"85",r:"2",fill:"#60A5FA"}),c.jsx("circle",{cx:"150",cy:"80",r:"2",fill:"#FCD34D"}),c.jsx("path",{d:"M45 30L46 33L49 33L47 35L48 38L45 36L42 38L43 35L41 33L44 33Z",fill:"#FCD34D"}),c.jsx("path",{d:"M160 45L161 47L163 47L161.5 48.5L162 51L160 49.5L158 51L158.5 48.5L157 47L159 47Z",fill:"#FCD34D"}),c.jsx("circle",{cx:"100",cy:"47",r:"35",fill:"url(#successGradient)"}),c.jsx("circle",{cx:"100",cy:"47",r:"30",fill:"#22C55E"}),c.jsx("path",{d:"M85 47L95 57L115 37",stroke:"white",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("circle",{cx:"100",cy:"47",r:"38",stroke:"#22C55E",strokeWidth:"2",strokeOpacity:"0.3"}),c.jsx("circle",{cx:"100",cy:"47",r:"42",stroke:"#22C55E",strokeWidth:"1",strokeOpacity:"0.2"}),c.jsx("defs",{children:c.jsxs("linearGradient",{id:"successGradient",x1:"65",y1:"12",x2:"135",y2:"82",gradientUnits:"userSpaceOnUse",children:[c.jsx("stop",{stopColor:"#4ADE80"}),c.jsx("stop",{offset:"1",stopColor:"#16A34A"})]})})]})}const jr=30,Ir=.003,Nr=5,en=8,tn=10**en,Rr=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),B={ETH:{symbol:"ETH",decimals:18,name:"Ether"},USDC:{symbol:"USDC",decimals:6,name:"USD Coin"},USDT:{symbol:"USDT",decimals:6,name:"Tether USD"},DAI:{symbol:"DAI",decimals:18,name:"Dai Stablecoin"},WBTC:{symbol:"WBTC",decimals:8,name:"Wrapped Bitcoin"},IDRX:{symbol:"IDRX",decimals:18,name:"Indonesian Rupiah"}};function Tt(e){if(!e)return"USDT";switch(e.toUpperCase()){case"IDR":return"IDRX";case"USD":return"USDT";default:return e.toUpperCase()}}function he(e,t=2){const n=e.toFixed(t),[r,s]=n.split("."),i=r.replace(/\B(?=(\d{3})+(?!\d))/g,",");return s?`${i}.${s}`:i}function kr({token:e,onChange:t,totalAmount:n,displayAmount:r,currency:s,disabled:i=!1}){const a=h=>{t(Number(h.target.value))},o=n*e.percentage/100,u=e.priceUSD>0?o/e.priceUSD:0,d=u<=e.amount,l=e.priceUSD>0,b=Tt(s),y=(r??n)*e.percentage/100;return c.jsxs("div",{className:"flex items-center gap-1.5 w-full",children:[c.jsxs("div",{className:"flex items-center gap-3 w-35",children:[c.jsxs("div",{className:"relative size-[30px]",children:[c.jsx("div",{className:`size-[30px] rounded-full bg-dark-4 overflow-hidden flex items-center justify-center ${l?"":"opacity-50"}`,children:e.tokenIcon?c.jsx("img",{src:e.tokenIcon,alt:e.name,className:"size-full object-cover"}):c.jsx("span",{className:"text-xs font-semibold text-white",children:e.symbol.slice(0,2)})}),c.jsx("div",{className:"absolute right-[-2px] bottom-[-2px] size-[12px] rounded-full bg-dark-3 border border-dark-2 overflow-hidden flex items-center justify-center",children:e.chainIcon?c.jsx("img",{src:e.chainIcon,alt:e.chain,className:"size-full object-cover"}):c.jsx("span",{className:"text-[6px] font-semibold text-white",children:e.chain.slice(0,1)})})]}),c.jsxs("div",{className:"flex flex-col gap-1 text-xs text-white",children:[c.jsx("span",{className:"font-semibold",children:e.name}),c.jsxs("span",{className:"font-normal opacity-75",children:[e.amount.toFixed(4)," ",e.symbol]}),c.jsx("span",{className:`text-[10px] ${l?"text-white/50":"text-yellow-500"}`,children:l?`$${e.priceUSD.toFixed(2)}/${e.symbol}`:"Price loading..."})]})]}),c.jsxs("div",{className:`flex-1 relative h-1.5 ${i?"opacity-50":""}`,children:[c.jsx("div",{className:"absolute inset-0 bg-white/40 rounded-full"}),c.jsx("div",{className:"absolute left-0 top-0 h-full bg-secondary rounded-full transition-all",style:{width:`${e.percentage}%`}}),c.jsx("input",{type:"range",min:"0",max:"100",value:e.percentage,onChange:a,className:`absolute inset-0 w-full h-full opacity-0 ${i?"cursor-not-allowed":"cursor-pointer"}`,disabled:i||e.amount===0||!l})]}),c.jsxs("div",{className:"flex flex-col items-end gap-0.5 min-w-25",children:[c.jsxs("span",{className:"text-xs font-semibold text-white",children:[e.percentage,"% = ",he(y)," ",b]}),e.percentage>0&&c.jsxs("span",{className:`text-[10px] ${d?"text-white/60":"text-red-500"}`,children:[he(u,4)," ",e.symbol,!d&&" ⚠️"]})]})]})}function nn({items:e,fee:t=.3,currency:n}){const s=e.reduce((a,o)=>a+o.price,0)+t,i=Tt(n);return c.jsxs("div",{className:"bg-dark-4 rounded-md p-3 flex flex-col gap-3 w-full",children:[c.jsx("p",{className:"font-medium text-base text-white",children:"Payment Summary"}),e.map((a,o)=>c.jsxs("div",{className:"flex items-center justify-between text-xs text-white",children:[c.jsx("span",{className:"flex-1",children:a.name}),c.jsxs("span",{className:"text-right",children:[he(a.price)," ",i]})]},o)),c.jsxs("div",{className:"flex items-center justify-between text-xs text-white",children:[c.jsx("span",{className:"flex-1",children:"Fee"}),c.jsxs("span",{className:"text-right",children:[he(t)," ",i]})]}),c.jsx("div",{className:"h-px bg-white/20"}),c.jsxs("div",{className:"flex items-center justify-between text-white",children:[c.jsx("span",{className:"text-xs",children:"Total Payment"}),c.jsxs("span",{className:"text-base font-semibold text-right",children:[he(s)," ",i]})]})]})}const D={PAYMENT_ROUTER:"0x73Dbc7447E3B097cFc8b08ee7896a9D27D67e2B4",TOKEN_REGISTRY:"0x1d2C6dfB2f127d6F3c14859c9E54cbc27bd7FcCE"},T={NATIVE:"0x0000000000000000000000000000000000000000",USDC:"0x0Ff0aED4862e168086FD8BC38a4c27cE1830228b",USDT:"0xBc63b0cf19b757c2a6Ef646027f8CeA7Af2c3e7F",DAI:"0xd2aAa24D5C305B7968e955A89F0bf4E7776E7078",WBTC:"0x1BEC7ec7F995B9bcd93F411B2cE7d289C6b05f03",IDRX:"0x39B9205cDC53114c0B0F22F04C1215A13197b4d9"},Mr=JSON.parse('[{"inputs":[{"internalType":"address","name":"_tokenRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CashbackSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"CollectedTokensWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"EmergencyPoolWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"merchant","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MerchantSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"newMinimum","type":"uint256"}],"name":"MinimumPoolBalanceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"paymentId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"merchant","type":"address"},{"indexed":true,"internalType":"address","name":"payer","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalPaidUSD","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"productPriceUSD","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeUSD","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"excessUSD","type":"uint256"},{"indexed":false,"internalType":"bool","name":"settleInIDR","type":"bool"},{"indexed":false,"internalType":"uint256","name":"settlementAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cashbackAmount","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bool","name":"externalCallSuccess","type":"bool"}],"name":"PaymentExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SettlementPoolFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"idrx","type":"address"},{"indexed":true,"internalType":"address","name":"usdt","type":"address"}],"name":"SettlementTokensUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"FEE_BASIS_POINTS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IDRX_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_CASHBACK_USD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NATIVE_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDT_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"calculateTotalValue","outputs":[{"internalType":"uint256","name":"totalUSD","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"calculateUSDValue","outputs":[{"internalType":"uint256","name":"usdValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"collectedBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyWithdrawPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"fundSettlementPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getCollectedBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"paymentId","type":"bytes32"}],"name":"getPayment","outputs":[{"components":[{"internalType":"address","name":"merchant","type":"address"},{"internalType":"address","name":"payer","type":"address"},{"internalType":"uint256","name":"totalPaidUSD","type":"uint256"},{"internalType":"uint256","name":"productPriceUSD","type":"uint256"},{"internalType":"uint256","name":"feeUSD","type":"uint256"},{"internalType":"uint256","name":"excessUSD","type":"uint256"},{"internalType":"bool","name":"settleInIDR","type":"bool"},{"internalType":"uint256","name":"settlementAmount","type":"uint256"},{"internalType":"uint256","name":"cashbackAmount","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct IPaymentRouter.Payment","name":"payment","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getSettlementPoolBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minimumPoolBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"merchantAddress","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"productPriceUSD","type":"uint256"},{"internalType":"bool","name":"settleInIDR","type":"bool"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"name":"pay","outputs":[{"internalType":"bytes32","name":"paymentId","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"minimum","type":"uint256"}],"name":"setMinimumPoolBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_idrx","type":"address"},{"internalType":"address","name":"_usdt","type":"address"}],"name":"setSettlementTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"settlementPools","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenRegistry","outputs":[{"internalType":"contract ITokenRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"expectedUSD","type":"uint256"}],"name":"validatePayment","outputs":[{"internalType":"bool","name":"valid","type":"bool"},{"internalType":"uint256","name":"actualUSD","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawCollectedTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]'),Dr=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessControlBadConfirmation",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"bytes32",name:"neededRole",type:"bytes32"}],name:"AccessControlUnauthorizedAccount",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"previousAdminRole",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"newAdminRole",type:"bytes32"}],name:"RoleAdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleGranted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleRevoked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"token",type:"address"},{indexed:!1,internalType:"bool",name:"enabled",type:"bool"}],name:"TokenEnabled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"token",type:"address"},{indexed:!0,internalType:"address",name:"priceFeed",type:"address"}],name:"TokenRegistered",type:"event"},{inputs:[],name:"ADMIN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"DEFAULT_ADMIN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"MAX_PRICE_STALENESS",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"NATIVE_TOKEN",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRegisteredTokenCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getRegisteredTokens",outputs:[{internalType:"address[]",name:"",type:"address[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"}],name:"getRoleAdmin",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"}],name:"getTokenConfig",outputs:[{components:[{internalType:"bool",name:"enabled",type:"bool"},{internalType:"address",name:"priceFeed",type:"address"},{internalType:"uint8",name:"decimals",type:"uint8"},{internalType:"uint256",name:"minPaymentAmount",type:"uint256"}],internalType:"struct ITokenRegistry.TokenConfig",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"}],name:"getTokenPriceUSD",outputs:[{internalType:"uint256",name:"price",type:"uint256"},{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"grantRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"hasRole",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"}],name:"isTokenEnabled",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"priceFeed",type:"address"},{internalType:"uint8",name:"decimals",type:"uint8"},{internalType:"uint256",name:"minPaymentAmount",type:"uint256"}],name:"registerToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"callerConfirmation",type:"address"}],name:"renounceRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"revokeRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"bool",name:"enabled",type:"bool"}],name:"setTokenEnabled",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"address",name:"priceFeed",type:"address"}],name:"updatePriceFeed",outputs:[],stateMutability:"nonpayable",type:"function"}],Or=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"faucet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],Oe=Mr,Y=Dr,ee=Or;function ze(){const{writeContract:e,data:t,isPending:n,error:r}=A.useWriteContract(),{isLoading:s,isSuccess:i}=A.useWaitForTransactionReceipt({hash:t});return{registerToken:(m,x,P,R)=>{e({address:D.TOKEN_REGISTRY,abi:Y,functionName:"registerToken",args:[m,x,P,R]})},setTokenEnabled:(m,x)=>{e({address:D.TOKEN_REGISTRY,abi:Y,functionName:"setTokenEnabled",args:[m,x]})},updatePriceFeed:(m,x)=>{e({address:D.TOKEN_REGISTRY,abi:Y,functionName:"updatePriceFeed",args:[m,x]})},setMinPaymentAmount:(m,x)=>{e({address:D.TOKEN_REGISTRY,abi:Y,functionName:"setMinPaymentAmount",args:[m,x]})},grantRole:(m,x)=>{e({address:D.TOKEN_REGISTRY,abi:Y,functionName:"grantRole",args:[m,x]})},revokeRole:(m,x)=>{e({address:D.TOKEN_REGISTRY,abi:Y,functionName:"revokeRole",args:[m,x]})},useGetTokenConfig:m=>A.useReadContract({address:D.TOKEN_REGISTRY,abi:Y,functionName:"getTokenConfig",args:[m]}),useGetTokenPrice:m=>A.useReadContract({address:D.TOKEN_REGISTRY,abi:Y,functionName:"getTokenPriceUSD",args:[m]}),useGetRegisteredTokens:()=>A.useReadContract({address:D.TOKEN_REGISTRY,abi:Y,functionName:"getRegisteredTokens"}),useGetRegisteredTokenCount:()=>A.useReadContract({address:D.TOKEN_REGISTRY,abi:Y,functionName:"getRegisteredTokenCount"}),useIsTokenEnabled:m=>A.useReadContract({address:D.TOKEN_REGISTRY,abi:Y,functionName:"isTokenEnabled",args:[m]}),useHasRole:(m,x)=>A.useReadContract({address:D.TOKEN_REGISTRY,abi:Y,functionName:"hasRole",args:[m,x]}),hash:t,isPending:n,isConfirming:s,isConfirmed:i,error:r}}const Br=1e8;function Ur({isOpen:e,onClose:t,totalAmount:n,currency:r="USD",items:s,tokens:i,onPaymentSubmit:a,fee:o=.003,transactionHash:u,isProcessing:d,isSuccess:l,conversionRate:b=1}){const p=ze(),{data:y}=p.useGetTokenPrice(T.NATIVE),{data:h}=p.useGetTokenPrice(T.USDC),{data:v}=p.useGetTokenPrice(T.USDT),{data:E}=p.useGetTokenPrice(T.DAI),{data:w}=p.useGetTokenPrice(T.WBTC),[m,x]=I.useState([]),[P,R]=I.useState(""),[O,X]=I.useState(!0),[J,H]=I.useState("form"),[Q,F]=I.useState(0),[de,$]=I.useState(""),[L,M]=I.useState([]),[z,V]=I.useState("Preparing payment..."),ne=I.useMemo(()=>JSON.stringify(i.map(g=>({id:g.id,amount:g.amount,priceUSD:g.priceUSD}))),[i]),k=g=>{if(!g)return 0;if(Array.isArray(g)&&g.length>=1){const S=g[0];if(typeof S=="bigint")return Number(S)/Br}return 0};I.useEffect(()=>{if(e&&i.length>0){const g=i.map(S=>{let N=S.priceUSD;return S.address===T.NATIVE&&y?N=k(y):S.address===T.USDC&&h?N=k(h):S.address===T.USDT&&v?N=k(v):S.address===T.DAI&&E?N=k(E):S.address===T.WBTC&&w&&(N=k(w)),{...S,priceUSD:N}});if(O){g.forEach(C=>{C.percentage=0});const S=n+o*n,N=g.filter(C=>(C.address===T.USDC||C.address===T.USDT||C.address===T.DAI)&&C.amount>0&&C.priceUSD>0),G=g.filter(C=>C.address!==T.USDC&&C.address!==T.USDT&&C.address!==T.DAI&&C.amount>0&&C.priceUSD>0),ve=N.reduce((C,K)=>C+K.amount*K.priceUSD,0);if(N.length>0&&ve>=S){const C=Math.floor(100/N.length),K=100-C*N.length;N.forEach((De,me)=>{De.percentage=C+(me===0?K:0)})}else if(N.length>0){const C=ve/S*100,K=Math.floor(C/N.length);N.forEach(le=>{le.percentage=K});const me=100-N.reduce((le,Qe)=>le+Qe.percentage,0);if(G.length>0&&me>0){const le=Math.floor(me/G.length),Qe=me-le*G.length;G.forEach((Tr,vr)=>{Tr.percentage=le+(vr===0?Qe:0)})}}else{const C=g.filter(K=>K.amount>0&&K.priceUSD>0);if(C.length>0){const K=Math.floor(100/C.length),De=100-K*C.length;C.forEach((me,le)=>{me.percentage=K+(le===0?De:0)})}}}x(g)}},[e,ne,y,h,v,E,w,O]),I.useEffect(()=>{e||(H("form"),F(0),$(""))},[e]),I.useEffect(()=>{l&&u?(F(100),$(u),H("success"),V("Payment completed!")):d&&(F(80),V("Confirming transaction..."))},[l,d,u]);const W=m.reduce((g,S)=>g+S.percentage,0),be=Tt(r),q=r==="IDR"?1/b:1,fr=s.map(g=>({...g,price:g.price})),Mt=o*n,Ye=n+Mt,pr=Mt*q,Ze=Ye*q,Xe=m.some(g=>g.percentage===0?!1:!g.priceUSD||g.priceUSD<=0),Je=m.some(g=>{if(g.percentage===0)return!1;const S=Ye*g.percentage/100;return(g.priceUSD>0?S/g.priceUSD:0)>g.amount}),yr=(g,S)=>{x(N=>N.map(G=>G.id===g?{...G,percentage:S}:G))},br=()=>{if(!O){const g=m.filter(G=>G.amount>0&&G.priceUSD>0),S=Math.floor(100/g.length),N=100-S*g.length;x(G=>G.map((ve,C)=>({...ve,percentage:ve.amount>0&&ve.priceUSD>0?S+(C===0?N:0):0})))}X(!O)},mr=m.filter(g=>g.amount>0&&(g.name.toLowerCase().includes(P.toLowerCase())||g.symbol.toLowerCase().includes(P.toLowerCase())||g.chain.toLowerCase().includes(P.toLowerCase()))),hr=async()=>{H("processing"),F(10),V("Checking token approvals...");const g=m.filter(S=>S.percentage>0&&S.address!==T.NATIVE);g.length>0&&(V(`Requesting approval for ${g.length} token(s)...`),M(g.map(S=>S.symbol))),F(30),V("Processing payment..."),a(m),F(60)},gr=()=>{t()},xr=()=>new Date().toLocaleDateString("en-US",{day:"numeric",month:"long",year:"numeric"});if(!e)return null;const wr=c.jsxs("div",{className:"multicoyn-sdk fixed inset-0 z-[9999] flex items-center justify-center",children:[c.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:J==="form"?t:void 0}),J==="processing"&&c.jsxs("div",{className:"relative bg-dark-2 border border-border rounded-xl p-4 flex flex-col gap-5 items-center justify-center w-[400px] min-h-[280px] mx-4 animate-slide-in-right",children:[c.jsx($r,{size:134}),c.jsxs("div",{className:"flex flex-col gap-3 items-center w-[300px]",children:[c.jsxs("div",{className:"relative w-[234px] h-1.5",children:[c.jsx("div",{className:"absolute inset-0 bg-dark-4 rounded-full"}),c.jsx("div",{className:"absolute left-0 top-0 h-full bg-secondary rounded-full transition-all duration-300",style:{width:`${Math.min(Q,100)}%`}})]}),c.jsx("p",{className:"text-sm text-white text-center",children:z}),L.length>0&&c.jsxs("div",{className:"text-xs text-white/60 text-center",children:["Approving: ",L.join(", ")]})]})]}),J==="success"&&c.jsxs("div",{className:"relative bg-dark-2 border border-border rounded-xl p-4 flex flex-col gap-8 items-start w-[380px] mx-4 animate-slide-in-right",children:[c.jsxs("div",{className:"flex flex-col gap-6 items-center w-full",children:[c.jsx(Cr,{size:95}),c.jsx("div",{className:"flex flex-col items-center justify-center w-full",children:c.jsxs("div",{className:"flex flex-col gap-1 items-center text-white",children:[c.jsx("p",{className:"text-lg font-semibold",children:"Payment Success"}),c.jsx("p",{className:"text-sm",children:"Your payment has been successfully done."})]})}),c.jsx("div",{className:"bg-dark-4 border border-white/10 rounded-lg py-3 px-0 w-[348px] flex flex-col items-center",children:c.jsxs("div",{className:"flex flex-col gap-2 w-[318px]",children:[c.jsx("p",{className:"text-xs text-white",children:"Order Details:"}),c.jsxs("div",{className:"flex items-center gap-8 text-sm text-white w-full",children:[c.jsx("span",{className:"w-[85px]",children:"Item"}),c.jsx("span",{className:"flex-1 text-right",children:s[0]?.name||"Item"})]}),c.jsxs("div",{className:"flex items-center gap-8 text-white w-full",children:[c.jsx("span",{className:"text-sm w-[106px]",children:"Total Payment"}),c.jsxs("span",{className:"flex-1 text-base font-semibold text-right",children:[he(Ze)," ",be]})]})]})})]}),c.jsx("div",{className:"h-px w-[320px] bg-white/20"}),c.jsxs("div",{className:"flex flex-col gap-2 items-center justify-center w-full text-xs text-white px-5",children:[c.jsx("p",{children:xr()}),de&&c.jsx("a",{href:`https://sepolia-blockscout.lisk.com/tx/${de}`,target:"_blank",rel:"noopener noreferrer",className:"text-cyan hover:underline",children:"View Transaction"})]}),c.jsx("button",{onClick:gr,className:"w-full h-[42px] bg-secondary hover:bg-secondary/90 rounded-lg flex items-center justify-center text-sm font-semibold text-white transition-all",children:"Back to Home"})]}),J==="form"&&c.jsxs("div",{className:"relative bg-dark-2 border border-border rounded-xl p-4 flex flex-col gap-5 max-w-[1000px] w-full mx-4 max-h-[90vh] overflow-y-auto animate-slide-in-right",children:[c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsxs("div",{className:"flex-1 flex flex-col gap-1",children:[c.jsx("h2",{className:"text-xl text-white font-normal",children:"Complete Payment"}),c.jsx("p",{className:"text-base text-white/70",children:"Choose how you want to pay (supports multi-token for wallets)"})]}),c.jsx("button",{onClick:t,className:"text-white/60 hover:text-white transition-colors",children:c.jsx(Pr,{size:26})})]}),c.jsxs("div",{className:"flex gap-5 flex-col lg:flex-row",children:[c.jsxs("div",{className:"flex-1 flex flex-col gap-5",children:[c.jsxs("div",{className:"bg-dark-4 rounded-md p-4 flex items-center gap-5",children:[c.jsx("span",{className:"text-base text-white/60 w-[340px]",children:"Total Required"}),c.jsxs("span",{className:"text-xl font-bold text-white text-right flex-1",children:[he(Ze)," ",be]})]}),c.jsxs("div",{className:"flex items-center gap-5",children:[c.jsx("span",{className:"text-base text-white flex-1",children:"Use your tokens"}),c.jsxs("div",{className:"bg-dark-4 rounded-md px-3 py-2 flex items-center gap-2",children:[c.jsx(Sr,{size:16,className:"text-white/60"}),c.jsx("input",{type:"text",placeholder:"Search token or chain..",value:P,onChange:g=>R(g.target.value),className:"bg-transparent border-none outline-none text-base text-white/60 placeholder:text-white/60"})]})]}),c.jsxs("div",{className:"bg-dark-3 rounded-md p-3 flex flex-col gap-4",children:[c.jsxs("div",{className:"flex items-center gap-6",children:[c.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[c.jsx(Ar,{size:16,className:"text-white/60"}),c.jsx("span",{className:"text-sm italic text-white",children:"Set the coins amount until 100%"}),c.jsxs("span",{className:`bg-dark-4 rounded-full px-2 py-1 text-xs font-semibold ${W===100?"text-cyan":"text-warning"}`,children:[W,"/100%"]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm text-white",children:"Auto Optimize"}),c.jsx("button",{onClick:br,className:`w-7 h-4 rounded-full relative transition-colors ${O?"bg-cyan":"bg-white/40"}`,children:c.jsx("div",{className:`absolute top-0.5 size-3 rounded-full bg-white transition-transform ${O?"translate-x-3.5":"translate-x-0.5"}`})})]})]}),mr.map(g=>c.jsx(kr,{token:g,totalAmount:Ye,displayAmount:Ze,currency:r,onChange:S=>yr(g.id,S),disabled:O},g.id))]})]}),c.jsx("div",{className:"w-full lg:w-[320px]",children:c.jsx(nn,{items:fr,fee:pr,currency:r})})]}),c.jsx("button",{onClick:hr,disabled:W!==100||Je||Xe,className:`w-full lg:w-[620px] h-[42px] rounded-lg flex items-center justify-center text-sm font-semibold text-white transition-all ${W===100&&!Je&&!Xe?"bg-secondary hover:bg-secondary/90":"bg-secondary/50 cursor-not-allowed"}`,children:Xe?"Price data unavailable - Please wait":Je?"Insufficient Balance":W!==100?`Complete to 100% (${W}%)`:"Pay with MultiCoyn"})]})]});return Er.createPortal(wr,document.body)}function Fr(){const[e,t]=I.useState(!1),[n,r]=I.useState("form");return{isOpen:e,view:n,open:()=>{t(!0),r("form")},close:()=>{t(!1),setTimeout(()=>r("form"),300)},showProcessing:()=>r("processing"),showSuccess:()=>r("success"),showForm:()=>r("form")}}const Dt=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"}],Lr=[{name:"query",type:"function",stateMutability:"view",inputs:[{type:"tuple[]",name:"queries",components:[{type:"address",name:"sender"},{type:"string[]",name:"urls"},{type:"bytes",name:"data"}]}],outputs:[{type:"bool[]",name:"failures"},{type:"bytes[]",name:"responses"}]},{name:"HttpError",type:"error",inputs:[{type:"uint16",name:"status"},{type:"string",name:"message"}]}];function xe(e,{includeName:t=!1}={}){if(e.type!=="function"&&e.type!=="event"&&e.type!=="error")throw new qr(e.type);return`${e.name}(${vt(e.inputs,{includeName:t})})`}function vt(e,{includeName:t=!1}={}){return e?e.map(n=>zr(n,{includeName:t})).join(t?", ":","):""}function zr(e,{includeName:t}){return e.type.startsWith("tuple")?`(${vt(e.components,{includeName:t})})${e.type.slice(5)}`:e.type+(t&&e.name?` ${e.name}`:"")}function Se(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function U(e){return Se(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const rn="2.43.5";let qe={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${rn}`},f=class at extends Error{constructor(t,n={}){const r=n.cause instanceof at?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof at&&n.cause.docsPath||n.docsPath,i=qe.getDocsUrl?.({...n,docsPath:s}),a=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...qe.version?[`Version: ${qe.version}`]:[]].join(`
2
+ `);super(a,n.cause?{cause:n.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=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=rn}walk(t){return sn(this,t)}};function sn(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?sn(e.cause,t):t?null:e}class _r extends f{constructor({docsPath:t}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join(`
3
+ `),{docsPath:t,name:"AbiConstructorNotFoundError"})}}class Ot extends f{constructor({docsPath:t}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join(`
4
+ `),{docsPath:t,name:"AbiConstructorParamsNotFoundError"})}}class Gr extends f{constructor({data:t,params:n,size:r}){super([`Data size of ${r} bytes is too small for given parameters.`].join(`
5
+ `),{metaMessages:[`Params: (${vt(n,{includeName:!0})})`,`Data: ${t} (${r} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t,this.params=n,this.size=r}}class Et extends f{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class Hr extends f{constructor({expectedLength:t,givenLength:n,type:r}){super([`ABI encoding array length mismatch for type ${r}.`,`Expected length: ${t}`,`Given length: ${n}`].join(`
6
+ `),{name:"AbiEncodingArrayLengthMismatchError"})}}class Vr extends f{constructor({expectedSize:t,value:n}){super(`Size of bytes "${n}" (bytes${U(n)}) does not match expected size (bytes${t}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class Wr extends f{constructor({expectedLength:t,givenLength:n}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${t}`,`Given length (values): ${n}`].join(`
7
+ `),{name:"AbiEncodingLengthMismatchError"})}}class Kr extends f{constructor(t,{docsPath:n}){super([`Arguments (\`args\`) were provided to "${t}", but "${t}" on the ABI does not contain any parameters (\`inputs\`).`,"Cannot encode error result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the inputs exist on it."].join(`
8
+ `),{docsPath:n,name:"AbiErrorInputsNotFoundError"})}}class Yr extends f{constructor(t,{docsPath:n}={}){super([`Error ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join(`
9
+ `),{docsPath:n,name:"AbiErrorNotFoundError"})}}class an extends f{constructor(t,{docsPath:n}){super([`Encoded error signature "${t}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${t}.`].join(`
10
+ `),{docsPath:n,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=t}}class Ne extends f{constructor(t,{docsPath:n}={}){super([`Function ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(`
11
+ `),{docsPath:n,name:"AbiFunctionNotFoundError"})}}class on extends f{constructor(t,{docsPath:n}){super([`Function "${t}" does not contain any \`outputs\` on ABI.`,"Cannot decode function result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the function exists on it."].join(`
12
+ `),{docsPath:n,name:"AbiFunctionOutputsNotFoundError"})}}class Zr extends f{constructor(t,{docsPath:n}){super([`Encoded function signature "${t}" not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it.",`You can look up the signature here: https://openchain.xyz/signatures?query=${t}.`].join(`
13
+ `),{docsPath:n,name:"AbiFunctionSignatureNotFoundError"})}}class Xr extends f{constructor(t,n){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${t.type}\` in \`${xe(t.abiItem)}\`, and`,`\`${n.type}\` in \`${xe(n.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class Jr extends f{constructor(t,{docsPath:n}){super([`Type "${t}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
14
+ `),{docsPath:n,name:"InvalidAbiEncodingType"})}}class Qr extends f{constructor(t,{docsPath:n}){super([`Type "${t}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(`
15
+ `),{docsPath:n,name:"InvalidAbiDecodingType"})}}class cn extends f{constructor(t){super([`Value "${t}" is not a valid array.`].join(`
16
+ `),{name:"InvalidArrayError"})}}class qr extends f{constructor(t){super([`"${t}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(`
17
+ `),{name:"InvalidDefinitionTypeError"})}}class Re extends f{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class un extends f{constructor({offset:t,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}let dn=class extends f{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}};class Bt extends f{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} is expected to be ${n} ${r} long, but is ${t} ${r} long.`,{name:"InvalidBytesLengthError"})}}function Ae(e,{dir:t,size:n=32}={}){return typeof e=="string"?pe(e,{dir:t,size:n}):es(e,{dir:t,size:n})}function pe(e,{dir:t,size:n=32}={}){if(n===null)return e;const r=e.replace("0x","");if(r.length>n*2)throw new dn({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function es(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new dn({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=t==="right";r[i?s:n-s-1]=e[i?s:e.length-s-1]}return r}let ln=class extends f{constructor({max:t,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}};class ts extends f{constructor(t){super(`Bytes value "${t}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class ns extends f{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function Pt(e,{dir:t="left"}={}){let n=typeof e=="string"?e.replace("0x",""):e,r=0;for(let s=0;s<n.length-1&&n[t==="left"?s:n.length-s-1].toString()==="0";s++)r++;return n=t==="left"?n.slice(r):n.slice(0,n.length-r),typeof e=="string"?(n.length===1&&t==="right"&&(n=`${n}0`),`0x${n.length%2===1?`0${n}`:n}`):n}function re(e,{size:t}){if(U(e)>t)throw new ns({givenSize:U(e),maxSize:t})}function fn(e,t={}){const{signed:n}=t;t.size&&re(e,{size:t.size});const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,i=(1n<<BigInt(s)*8n-1n)-1n;return r<=i?r:r-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function rs(e,t={}){return Number(fn(e,t))}const ss=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function is(e,t={}){return typeof e=="number"||typeof e=="bigint"?j(e,t):typeof e=="string"?yn(e,t):typeof e=="boolean"?pn(e,t):ce(e,t)}function pn(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(re(n,{size:t.size}),Ae(n,{size:t.size})):n}function ce(e,t={}){let n="";for(let s=0;s<e.length;s++)n+=ss[e[s]];const r=`0x${n}`;return typeof t.size=="number"?(re(r,{size:t.size}),Ae(r,{dir:"right",size:t.size})):r}function j(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<a){const u=typeof e=="bigint"?"n":"";throw new ln({max:i?`${i}${u}`:void 0,min:`${a}${u}`,signed:n,size:r,value:`${e}${u}`})}const o=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?Ae(o,{size:r}):o}const as=new TextEncoder;function yn(e,t={}){const n=as.encode(e);return ce(n,t)}const os=new TextEncoder;function bn(e,t={}){return typeof e=="number"||typeof e=="bigint"?us(e,t):typeof e=="boolean"?cs(e,t):Se(e)?St(e,t):mn(e,t)}function cs(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(re(n,{size:t.size}),Ae(n,{size:t.size})):n}const se={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ut(e){if(e>=se.zero&&e<=se.nine)return e-se.zero;if(e>=se.A&&e<=se.F)return e-(se.A-10);if(e>=se.a&&e<=se.f)return e-(se.a-10)}function St(e,t={}){let n=e;t.size&&(re(n,{size:t.size}),n=Ae(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let a=0,o=0;a<s;a++){const u=Ut(r.charCodeAt(o++)),d=Ut(r.charCodeAt(o++));if(u===void 0||d===void 0)throw new f(`Invalid byte sequence ("${r[o-2]}${r[o-1]}" in "${r}").`);i[a]=u*16+d}return i}function us(e,t){const n=j(e,t);return St(n)}function mn(e,t={}){const n=os.encode(e);return typeof t.size=="number"?(re(n,{size:t.size}),Ae(n,{dir:"right",size:t.size})):n}const Be=BigInt(2**32-1),Ft=BigInt(32);function ds(e,t=!1){return t?{h:Number(e&Be),l:Number(e>>Ft&Be)}:{h:Number(e>>Ft&Be)|0,l:Number(e&Be)|0}}function ls(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:a,l:o}=ds(e[i],t);[r[i],s[i]]=[a,o]}return[r,s]}const fs=(e,t,n)=>e<<n|t>>>32-n,ps=(e,t,n)=>t<<n|e>>>32-n,ys=(e,t,n)=>t<<n-32|e>>>64-n,bs=(e,t,n)=>e<<n-32|t>>>64-n;function ms(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Lt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ue(e,...t){if(!ms(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function zt(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 hs(e,t){Ue(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function gs(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function hn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const xs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ws(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ts(e){for(let t=0;t<e.length;t++)e[t]=ws(e[t]);return e}const _t=xs?e=>e:Ts;function vs(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function gn(e){return typeof e=="string"&&(e=vs(e)),Ue(e),e}class Es{}function Ps(e){const t=r=>e().update(gn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const Ss=BigInt(0),Ce=BigInt(1),As=BigInt(2),$s=BigInt(7),Cs=BigInt(256),js=BigInt(113),xn=[],wn=[],Tn=[];for(let e=0,t=Ce,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],xn.push(2*(5*r+n)),wn.push((e+1)*(e+2)/2%64);let s=Ss;for(let i=0;i<7;i++)t=(t<<Ce^(t>>$s)*js)%Cs,t&As&&(s^=Ce<<(Ce<<BigInt(i))-Ce);Tn.push(s)}const vn=ls(Tn,!0),Is=vn[0],Ns=vn[1],Gt=(e,t,n)=>n>32?ys(e,t,n):fs(e,t,n),Ht=(e,t,n)=>n>32?bs(e,t,n):ps(e,t,n);function Rs(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let a=0;a<10;a++)n[a]=e[a]^e[a+10]^e[a+20]^e[a+30]^e[a+40];for(let a=0;a<10;a+=2){const o=(a+8)%10,u=(a+2)%10,d=n[u],l=n[u+1],b=Gt(d,l,1)^n[o],p=Ht(d,l,1)^n[o+1];for(let y=0;y<50;y+=10)e[a+y]^=b,e[a+y+1]^=p}let s=e[2],i=e[3];for(let a=0;a<24;a++){const o=wn[a],u=Gt(s,i,o),d=Ht(s,i,o),l=xn[a];s=e[l],i=e[l+1],e[l]=u,e[l+1]=d}for(let a=0;a<50;a+=10){for(let o=0;o<10;o++)n[o]=e[a+o];for(let o=0;o<10;o++)e[a+o]^=~n[(o+2)%10]&n[(o+4)%10]}e[0]^=Is[r],e[1]^=Ns[r]}hn(n)}class At extends Es{constructor(t,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,Lt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=gs(this.state)}clone(){return this._cloneInto()}keccak(){_t(this.state32),Rs(this.state32,this.rounds),_t(this.state32),this.posOut=0,this.pos=0}update(t){zt(this),t=gn(t),Ue(t);const{blockLen:n,state:r}=this,s=t.length;for(let i=0;i<s;){const a=Math.min(n-this.pos,s-i);for(let o=0;o<a;o++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:s}=this;t[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){zt(this,!1),Ue(t),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=t.length;s<i;){this.posOut>=r&&this.keccak();const a=Math.min(r-this.posOut,i-s);t.set(n.subarray(this.posOut,this.posOut+a),s),this.posOut+=a,s+=a}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Lt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(hs(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,hn(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:a}=this;return t||(t=new At(n,r,s,a,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=s,t.enableXOF=a,t.destroyed=this.destroyed,t}}const ks=(e,t,n)=>Ps(()=>new At(t,e,n)),Ms=ks(1,136,256/8);function En(e,t){const n=t||"hex",r=Ms(Se(e,{strict:!1})?bn(e):e);return n==="bytes"?r:is(r)}class Pn extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const Ds=/^0x[a-fA-F0-9]{40}$/,et=new Pn(8192);function ye(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(et.has(r))return et.get(r);const s=Ds.test(e)?e.toLowerCase()===e?!0:n?Sn(e)===e:!0:!1;return et.set(r,s),s}const tt=new Pn(8192);function Sn(e,t){if(tt.has(`${e}.${t}`))return tt.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=En(mn(n),"bytes"),s=n.split("");for(let a=0;a<40;a+=2)r[a>>1]>>4>=8&&s[a]&&(s[a]=s[a].toUpperCase()),(r[a>>1]&15)>=8&&s[a+1]&&(s[a+1]=s[a+1].toUpperCase());const i=`0x${s.join("")}`;return tt.set(`${e}.${t}`,i),i}class Vt extends f{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class Os extends f{constructor({length:t,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}}class Bs extends f{constructor({count:t,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}const Us={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 Bs({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Os({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Vt({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 Vt({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,e&255),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 Fs(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(Us);return n.bytes=e,n.dataView=new DataView(e.buffer??e,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function ke(e,t,n,{strict:r}={}){return Se(e,{strict:!1})?Ls(e,t,n,{strict:r}):Cn(e,t,n,{strict:r})}function An(e,t){if(typeof t=="number"&&t>0&&t>U(e)-1)throw new un({offset:t,position:"start",size:U(e)})}function $n(e,t,n){if(typeof t=="number"&&typeof n=="number"&&U(e)!==n-t)throw new un({offset:n,position:"end",size:U(e)})}function Cn(e,t,n,{strict:r}={}){An(e,t);const s=e.slice(t,n);return r&&$n(s,t,n),s}function Ls(e,t,n,{strict:r}={}){An(e,t);const s=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return r&&$n(s,t,n),s}function zs(e,t={}){typeof t.size<"u"&&re(e,{size:t.size});const n=ce(e,t);return fn(n,t)}function _s(e,t={}){let n=e;if(typeof t.size<"u"&&(re(n,{size:t.size}),n=Pt(n)),n.length>1||n[0]>1)throw new ts(n);return!!n[0]}function oe(e,t={}){typeof t.size<"u"&&re(e,{size:t.size});const n=ce(e,t);return rs(n,t)}function Gs(e,t={}){let n=e;return typeof t.size<"u"&&(re(n,{size:t.size}),n=Pt(n,{dir:"right"})),new TextDecoder().decode(n)}function we(e){return typeof e[0]=="string"?_e(e):Hs(e)}function Hs(e){let t=0;for(const s of e)t+=s.length;const n=new Uint8Array(t);let r=0;for(const s of e)n.set(s,r),r+=s.length;return n}function _e(e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}const Vs=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function $t(e,t){if(e.length!==t.length)throw new Wr({expectedLength:e.length,givenLength:t.length});const n=Ws({params:e,values:t}),r=jt(n);return r.length===0?"0x":r}function Ws({params:e,values:t}){const n=[];for(let r=0;r<e.length;r++)n.push(Ct({param:e[r],value:t[r]}));return n}function Ct({param:e,value:t}){const n=It(e.type);if(n){const[r,s]=n;return Ys(t,{length:r,param:{...e,type:s}})}if(e.type==="tuple")return qs(t,{param:e});if(e.type==="address")return Ks(t);if(e.type==="bool")return Xs(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const r=e.type.startsWith("int"),[,,s="256"]=Vs.exec(e.type)??[];return Js(t,{signed:r,size:Number(s)})}if(e.type.startsWith("bytes"))return Zs(t,{param:e});if(e.type==="string")return Qs(t);throw new Jr(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function jt(e){let t=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?t+=32:t+=U(o)}const n=[],r=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:a,encoded:o}=e[i];a?(n.push(j(t+s,{size:32})),r.push(o),s+=U(o)):n.push(o)}return we([...n,...r])}function Ks(e){if(!ye(e))throw new Re({address:e});return{dynamic:!1,encoded:pe(e.toLowerCase())}}function Ys(e,{length:t,param:n}){const r=t===null;if(!Array.isArray(e))throw new cn(e);if(!r&&e.length!==t)throw new Hr({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let s=!1;const i=[];for(let a=0;a<e.length;a++){const o=Ct({param:n,value:e[a]});o.dynamic&&(s=!0),i.push(o)}if(r||s){const a=jt(i);if(r){const o=j(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?we([o,a]):o}}if(s)return{dynamic:!0,encoded:a}}return{dynamic:!1,encoded:we(i.map(({encoded:a})=>a))}}function Zs(e,{param:t}){const[,n]=t.type.split("bytes"),r=U(e);if(!n){let s=e;return r%32!==0&&(s=pe(s,{dir:"right",size:Math.ceil((e.length-2)/2/32)*32})),{dynamic:!0,encoded:we([pe(j(r,{size:32})),s])}}if(r!==Number.parseInt(n,10))throw new Vr({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:pe(e,{dir:"right"})}}function Xs(e){if(typeof e!="boolean")throw new f(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:pe(pn(e))}}function Js(e,{signed:t,size:n=256}){if(typeof n=="number"){const r=2n**(BigInt(n)-(t?1n:0n))-1n,s=t?-r-1n:0n;if(e>r||e<s)throw new ln({max:r.toString(),min:s.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:j(e,{size:32,signed:t})}}function Qs(e){const t=yn(e),n=Math.ceil(U(t)/32),r=[];for(let s=0;s<n;s++)r.push(pe(ke(t,s*32,(s+1)*32),{dir:"right"}));return{dynamic:!0,encoded:we([pe(j(U(t),{size:32})),...r])}}function qs(e,{param:t}){let n=!1;const r=[];for(let s=0;s<t.components.length;s++){const i=t.components[s],a=Array.isArray(e)?s:i.name,o=Ct({param:i,value:e[a]});r.push(o),o.dynamic&&(n=!0)}return{dynamic:n,encoded:n?jt(r):we(r.map(({encoded:s})=>s))}}function It(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Nt(e,t){const n=typeof t=="string"?St(t):t,r=Fs(n);if(U(n)===0&&e.length>0)throw new Et;if(U(t)&&U(t)<32)throw new Gr({data:typeof t=="string"?t:ce(t),params:e,size:U(t)});let s=0;const i=[];for(let a=0;a<e.length;++a){const o=e[a];r.setPosition(s);const[u,d]=Pe(r,o,{staticPosition:0});s+=d,i.push(u)}return i}function Pe(e,t,{staticPosition:n}){const r=It(t.type);if(r){const[s,i]=r;return ti(e,{...t,type:i},{length:s,staticPosition:n})}if(t.type==="tuple")return ii(e,t,{staticPosition:n});if(t.type==="address")return ei(e);if(t.type==="bool")return ni(e);if(t.type.startsWith("bytes"))return ri(e,t,{staticPosition:n});if(t.type.startsWith("uint")||t.type.startsWith("int"))return si(e,t);if(t.type==="string")return ai(e,{staticPosition:n});throw new Qr(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Wt=32,ot=32;function ei(e){const t=e.readBytes(32);return[Sn(ce(Cn(t,-20))),32]}function ti(e,t,{length:n,staticPosition:r}){if(!n){const a=oe(e.readBytes(ot)),o=r+a,u=o+Wt;e.setPosition(o);const d=oe(e.readBytes(Wt)),l=Me(t);let b=0;const p=[];for(let y=0;y<d;++y){e.setPosition(u+(l?y*32:b));const[h,v]=Pe(e,t,{staticPosition:u});b+=v,p.push(h)}return e.setPosition(r+32),[p,32]}if(Me(t)){const a=oe(e.readBytes(ot)),o=r+a,u=[];for(let d=0;d<n;++d){e.setPosition(o+d*32);const[l]=Pe(e,t,{staticPosition:o});u.push(l)}return e.setPosition(r+32),[u,32]}let s=0;const i=[];for(let a=0;a<n;++a){const[o,u]=Pe(e,t,{staticPosition:r+s});s+=u,i.push(o)}return[i,s]}function ni(e){return[_s(e.readBytes(32),{size:32}),32]}function ri(e,t,{staticPosition:n}){const[r,s]=t.type.split("bytes");if(!s){const a=oe(e.readBytes(32));e.setPosition(n+a);const o=oe(e.readBytes(32));if(o===0)return e.setPosition(n+32),["0x",32];const u=e.readBytes(o);return e.setPosition(n+32),[ce(u),32]}return[ce(e.readBytes(Number.parseInt(s,10),32)),32]}function si(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256",10),s=e.readBytes(32);return[r>48?zs(s,{signed:n}):oe(s,{signed:n}),32]}function ii(e,t,{staticPosition:n}){const r=t.components.length===0||t.components.some(({name:a})=>!a),s=r?[]:{};let i=0;if(Me(t)){const a=oe(e.readBytes(ot)),o=n+a;for(let u=0;u<t.components.length;++u){const d=t.components[u];e.setPosition(o+i);const[l,b]=Pe(e,d,{staticPosition:o});i+=b,s[r?u:d?.name]=l}return e.setPosition(n+32),[s,32]}for(let a=0;a<t.components.length;++a){const o=t.components[a],[u,d]=Pe(e,o,{staticPosition:n});s[r?a:o?.name]=u,i+=d}return[s,i]}function ai(e,{staticPosition:t}){const n=oe(e.readBytes(32)),r=t+n;e.setPosition(r);const s=oe(e.readBytes(32));if(s===0)return e.setPosition(t+32),["",32];const i=e.readBytes(s,32),a=Gs(Pt(i));return e.setPosition(t+32),[a,32]}function Me(e){const{type:t}=e;if(t==="string"||t==="bytes"||t.endsWith("[]"))return!0;if(t==="tuple")return e.components?.some(Me);const n=It(e.type);return!!(n&&Me({...e,type:n[1]}))}const oi=e=>En(bn(e));function ci(e){return oi(e)}const ui="1.2.3";let Z=class ct extends Error{constructor(t,n={}){const r=n.cause instanceof ct?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof ct&&n.cause.docsPath||n.docsPath,i=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...r?[`Details: ${r}`]:[],`Version: abitype@${ui}`].join(`
18
+ `);super(i),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,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.shortMessage=t}};function ue(e,t){return e.exec(t)?.groups}const jn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,In=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,Nn=/^\(.+?\).*?$/,Kt=/^tuple(?<array>(\[(\d*)\])*)$/;function ut(e){let t=e.type;if(Kt.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let s=0;s<n;s++){const i=e.components[s];t+=ut(i),s<n-1&&(t+=", ")}const r=ue(Kt,e.type);return t+=`)${r?.array||""}`,ut({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function je(e){let t="";const n=e.length;for(let r=0;r<n;r++){const s=e[r];t+=ut(s),r!==n-1&&(t+=", ")}return t}function di(e){return e.type==="function"?`function ${e.name}(${je(e.inputs)})${e.stateMutability&&e.stateMutability!=="nonpayable"?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${je(e.outputs)})`:""}`:e.type==="event"?`event ${e.name}(${je(e.inputs)})`:e.type==="error"?`error ${e.name}(${je(e.inputs)})`:e.type==="constructor"?`constructor(${je(e.inputs)})${e.stateMutability==="payable"?" payable":""}`:e.type==="fallback"?`fallback() external${e.stateMutability==="payable"?" payable":""}`:"receive() external payable"}const Rn=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function li(e){return Rn.test(e)}function fi(e){return ue(Rn,e)}const kn=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function pi(e){return kn.test(e)}function yi(e){return ue(kn,e)}const Mn=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;function bi(e){return Mn.test(e)}function mi(e){return ue(Mn,e)}const Dn=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function On(e){return Dn.test(e)}function hi(e){return ue(Dn,e)}const Bn=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function gi(e){return Bn.test(e)}function xi(e){return ue(Bn,e)}const Un=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function wi(e){return Un.test(e)}function Ti(e){return ue(Un,e)}const vi=/^receive\(\) external payable$/;function Ei(e){return vi.test(e)}const Pi=new Set(["indexed"]),dt=new Set(["calldata","memory","storage"]);class Si extends Z{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class Ai extends Z{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class $i extends Z{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class Ci extends Z{constructor({param:t,name:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${n}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class ji extends Z{constructor({param:t,type:n,modifier:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${r}" not allowed${n?` in "${n}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class Ii extends Z{constructor({param:t,type:n,modifier:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${r}" not allowed${n?` in "${n}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${r}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class Ni extends Z{constructor({abiParameter:t}){super("Invalid ABI parameter.",{details:JSON.stringify(t,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class $e extends Z{constructor({signature:t,type:n}){super(`Invalid ${n} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Ri extends Z{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class ki extends Z{constructor({signature:t}){super("Invalid struct signature.",{details:t,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class Mi extends Z{constructor({type:t}){super("Circular reference detected.",{metaMessages:[`Struct "${t}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class Di extends Z{constructor({current:t,depth:n}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${n>0?"opening":"closing"} parentheses.`],details:`Depth "${n}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function Oi(e,t,n){let r="";if(n)for(const s of Object.entries(n)){if(!s)continue;let i="";for(const a of s[1])i+=`[${a.type}${a.name?`:${a.name}`:""}]`;r+=`(${s[0]}{${i}})`}return t?`${t}:${e}${r}`:`${e}${r}`}const nt=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function Bi(e,t={}){if(bi(e))return Ui(e,t);if(pi(e))return Fi(e,t);if(li(e))return Li(e,t);if(gi(e))return zi(e,t);if(wi(e))return _i(e);if(Ei(e))return{type:"receive",stateMutability:"payable"};throw new Ri({signature:e})}function Ui(e,t={}){const n=mi(e);if(!n)throw new $e({signature:e,type:"function"});const r=te(n.parameters),s=[],i=r.length;for(let o=0;o<i;o++)s.push(Te(r[o],{modifiers:dt,structs:t,type:"function"}));const a=[];if(n.returns){const o=te(n.returns),u=o.length;for(let d=0;d<u;d++)a.push(Te(o[d],{modifiers:dt,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:s,outputs:a}}function Fi(e,t={}){const n=yi(e);if(!n)throw new $e({signature:e,type:"event"});const r=te(n.parameters),s=[],i=r.length;for(let a=0;a<i;a++)s.push(Te(r[a],{modifiers:Pi,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:s}}function Li(e,t={}){const n=fi(e);if(!n)throw new $e({signature:e,type:"error"});const r=te(n.parameters),s=[],i=r.length;for(let a=0;a<i;a++)s.push(Te(r[a],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:s}}function zi(e,t={}){const n=xi(e);if(!n)throw new $e({signature:e,type:"constructor"});const r=te(n.parameters),s=[],i=r.length;for(let a=0;a<i;a++)s.push(Te(r[a],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:s}}function _i(e){const t=Ti(e);if(!t)throw new $e({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}const Gi=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Hi=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Vi=/^u?int$/;function Te(e,t){const n=Oi(e,t?.type,t?.structs);if(nt.has(n))return nt.get(n);const r=Nn.test(e),s=ue(r?Hi:Gi,e);if(!s)throw new $i({param:e});if(s.name&&Ki(s.name))throw new Ci({param:e,name:s.name});const i=s.name?{name:s.name}:{},a=s.modifier==="indexed"?{indexed:!0}:{},o=t?.structs??{};let u,d={};if(r){u="tuple";const b=te(s.type),p=[],y=b.length;for(let h=0;h<y;h++)p.push(Te(b[h],{structs:o}));d={components:p}}else if(s.type in o)u="tuple",d={components:o[s.type]};else if(Vi.test(s.type))u=`${s.type}256`;else if(s.type==="address payable")u="address";else if(u=s.type,t?.type!=="struct"&&!Fn(u))throw new Ai({type:u});if(s.modifier){if(!t?.modifiers?.has?.(s.modifier))throw new ji({param:e,type:t?.type,modifier:s.modifier});if(dt.has(s.modifier)&&!Yi(u,!!s.array))throw new Ii({param:e,type:t?.type,modifier:s.modifier})}const l={type:`${u}${s.array??""}`,...i,...a,...d};return nt.set(n,l),l}function te(e,t=[],n="",r=0){const s=e.trim().length;for(let i=0;i<s;i++){const a=e[i],o=e.slice(i+1);switch(a){case",":return r===0?te(o,[...t,n.trim()]):te(o,t,`${n}${a}`,r);case"(":return te(o,t,`${n}${a}`,r+1);case")":return te(o,t,`${n}${a}`,r-1);default:return te(o,t,`${n}${a}`,r)}}if(n==="")return t;if(r!==0)throw new Di({current:n,depth:r});return t.push(n.trim()),t}function Fn(e){return e==="address"||e==="bool"||e==="function"||e==="string"||jn.test(e)||In.test(e)}const Wi=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function Ki(e){return e==="address"||e==="bool"||e==="function"||e==="string"||e==="tuple"||jn.test(e)||In.test(e)||Wi.test(e)}function Yi(e,t){return t||e==="bytes"||e==="string"||e==="tuple"}function Zi(e){const t={},n=e.length;for(let a=0;a<n;a++){const o=e[a];if(!On(o))continue;const u=hi(o);if(!u)throw new $e({signature:o,type:"struct"});const d=u.properties.split(";"),l=[],b=d.length;for(let p=0;p<b;p++){const h=d[p].trim();if(!h)continue;const v=Te(h,{type:"struct"});l.push(v)}if(!l.length)throw new ki({signature:o});t[u.name]=l}const r={},s=Object.entries(t),i=s.length;for(let a=0;a<i;a++){const[o,u]=s[a];r[o]=Ln(u,t)}return r}const Xi=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function Ln(e=[],t={},n=new Set){const r=[],s=e.length;for(let i=0;i<s;i++){const a=e[i];if(Nn.test(a.type))r.push(a);else{const u=ue(Xi,a.type);if(!u?.type)throw new Ni({abiParameter:a});const{array:d,type:l}=u;if(l in t){if(n.has(l))throw new Mi({type:l});r.push({...a,type:`tuple${d??""}`,components:Ln(t[l],t,new Set([...n,l]))})}else if(Fn(l))r.push(a);else throw new Si({type:l})}}return r}function zn(e){const t=Zi(e),n=[],r=e.length;for(let s=0;s<r;s++){const i=e[s];On(i)||n.push(Bi(i,t))}return n}function Ji(e){let t=!0,n="",r=0,s="",i=!1;for(let a=0;a<e.length;a++){const o=e[a];if(["(",")",","].includes(o)&&(t=!0),o==="("&&r++,o===")"&&r--,!!t){if(r===0){if(o===" "&&["event","function",""].includes(s))s="";else if(s+=o,o===")"){i=!0;break}continue}if(o===" "){e[a-1]!==","&&n!==","&&n!==",("&&(n="",t=!1);continue}s+=o,n+=o}}if(!i)throw new f("Unable to normalize signature.");return s}const Qi=e=>{const t=typeof e=="string"?e:di(e);return Ji(t)};function _n(e){return ci(Qi(e))}const qi=_n,Ge=e=>ke(_n(e),0,4);function He(e){const{abi:t,args:n=[],name:r}=e,s=Se(r,{strict:!1}),i=t.filter(o=>s?o.type==="function"?Ge(o)===r:o.type==="event"?qi(o)===r:!1:"name"in o&&o.name===r);if(i.length===0)return;if(i.length===1)return i[0];let a;for(const o of i){if(!("inputs"in o))continue;if(!n||n.length===0){if(!o.inputs||o.inputs.length===0)return o;continue}if(!o.inputs||o.inputs.length===0||o.inputs.length!==n.length)continue;if(n.every((d,l)=>{const b="inputs"in o&&o.inputs[l];return b?lt(d,b):!1})){if(a&&"inputs"in a&&a.inputs){const d=Gn(o.inputs,a.inputs,n);if(d)throw new Xr({abiItem:o,type:d[0]},{abiItem:a,type:d[1]})}a=o}}return a||i[0]}function lt(e,t){const n=typeof e,r=t.type;switch(r){case"address":return ye(e,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in t?Object.values(t.components).every((s,i)=>n==="object"&&lt(Object.values(e)[i],s)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||e instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(e)&&e.every(s=>lt(s,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Gn(e,t,n){for(const r in e){const s=e[r],i=t[r];if(s.type==="tuple"&&i.type==="tuple"&&"components"in s&&"components"in i)return Gn(s.components,i.components,n[r]);const a=[s.type,i.type];if(a.includes("address")&&a.includes("bytes20")?!0:a.includes("address")&&a.includes("string")?ye(n[r],{strict:!1}):a.includes("address")&&a.includes("bytes")?ye(n[r],{strict:!1}):!1)return a}}const rt="/docs/contract/decodeFunctionResult";function Hn(e){const{abi:t,args:n,functionName:r,data:s}=e;let i=t[0];if(r){const o=He({abi:t,args:n,name:r});if(!o)throw new Ne(r,{docsPath:rt});i=o}if(i.type!=="function")throw new Ne(void 0,{docsPath:rt});if(!i.outputs)throw new on(i.name,{docsPath:rt});const a=Nt(i.outputs,s);if(a&&a.length>1)return a;if(a&&a.length===1)return a[0]}const Yt="/docs/contract/encodeFunctionData";function ea(e){const{abi:t,args:n,functionName:r}=e;let s=t[0];if(r){const i=He({abi:t,args:n,name:r});if(!i)throw new Ne(r,{docsPath:Yt});s=i}if(s.type!=="function")throw new Ne(void 0,{docsPath:Yt});return{abi:[s],functionName:Ge(xe(s))}}function Vn(e){const{args:t}=e,{abi:n,functionName:r}=e.abi.length===1&&e.functionName?.startsWith("0x")?e:ea(e),s=n[0],i=r,a="inputs"in s&&s.inputs?$t(s.inputs,t??[]):void 0;return _e([i,a??"0x"])}class ft extends f{constructor({blockNumber:t,chain:n,contract:r}){super(`Chain "${n.name}" does not support contract "${r.name}".`,{metaMessages:["This could be due to any of the following:",...t&&r.blockCreated&&r.blockCreated>t?[`- The contract "${r.name}" was not deployed until block ${r.blockCreated} (current block ${t}).`]:[`- The chain does not have the contract "${r.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class Wn extends f{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}function ta({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new ft({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new ft({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function Rt(e){return typeof e=="string"?{address:e,type:"json-rpc"}:e}const na={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},Kn={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},ra={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};function Yn(e){const{abi:t,data:n}=e,r=ke(n,0,4);if(r==="0x")throw new Et;const i=[...t||[],Kn,ra].find(a=>a.type==="error"&&r===Ge(xe(a)));if(!i)throw new an(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:i,args:"inputs"in i&&i.inputs&&i.inputs.length>0?Nt(i.inputs,ke(n,4)):void 0,errorName:i.name}}const Ve=(e,t,n)=>JSON.stringify(e,(r,s)=>typeof s=="bigint"?s.toString():s,n);function Zn({abiItem:e,args:t,includeFunctionName:n=!0,includeName:r=!1}){if("name"in e&&"inputs"in e&&e.inputs)return`${n?e.name:""}(${e.inputs.map((s,i)=>`${r&&s.name?`${s.name}: `:""}${typeof t[i]=="object"?Ve(t[i]):t[i]}`).join(", ")})`}const sa={gwei:9,wei:18},ia={ether:-9,wei:9};function Xn(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[s,i]=[n.slice(0,n.length-t),n.slice(n.length-t)];return i=i.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${i?`.${i}`:""}`}function aa(e,t="wei"){return Xn(e,sa[t])}function ge(e,t="wei"){return Xn(e,ia[t])}class oa extends f{constructor({address:t}){super(`State for account "${t}" is set multiple times.`,{name:"AccountStateConflictError"})}}class ca extends f{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Zt(e){return e.reduce((t,{slot:n,value:r})=>`${t} ${n}: ${r}
19
+ `,"")}function ua(e){return e.reduce((t,{address:n,...r})=>{let s=`${t} ${n}:
20
+ `;return r.nonce&&(s+=` nonce: ${r.nonce}
21
+ `),r.balance&&(s+=` balance: ${r.balance}
22
+ `),r.code&&(s+=` code: ${r.code}
23
+ `),r.state&&(s+=` state:
24
+ `,s+=Zt(r.state)),r.stateDiff&&(s+=` stateDiff:
25
+ `,s+=Zt(r.stateDiff)),s},` State Override:
26
+ `).slice(0,-1)}function Jn(e){const t=Object.entries(e).map(([r,s])=>s===void 0||s===!1?null:[r,s]).filter(Boolean),n=t.reduce((r,[s])=>Math.max(r,s.length),0);return t.map(([r,s])=>` ${`${r}:`.padEnd(n+1)} ${s}`).join(`
27
+ `)}const da=e=>e,kt=e=>e;class la extends f{constructor(t,{account:n,docsPath:r,chain:s,data:i,gas:a,gasPrice:o,maxFeePerGas:u,maxPriorityFeePerGas:d,nonce:l,to:b,value:p,stateOverride:y}){const h=n?Rt(n):void 0;let v=Jn({from:h?.address,to:b,value:typeof p<"u"&&`${aa(p)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:a,gasPrice:typeof o<"u"&&`${ge(o)} gwei`,maxFeePerGas:typeof u<"u"&&`${ge(u)} gwei`,maxPriorityFeePerGas:typeof d<"u"&&`${ge(d)} gwei`,nonce:l});y&&(v+=`
28
+ ${ua(y)}`),super(t.shortMessage,{cause:t,docsPath:r,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Raw Call Arguments:",v].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class fa extends f{constructor(t,{abi:n,args:r,contractAddress:s,docsPath:i,functionName:a,sender:o}){const u=He({abi:n,args:r,name:a}),d=u?Zn({abiItem:u,args:r,includeFunctionName:!1,includeName:!1}):void 0,l=u?xe(u,{includeName:!0}):void 0,b=Jn({address:s&&da(s),function:l,args:d&&d!=="()"&&`${[...Array(a?.length??0).keys()].map(()=>" ").join("")}${d}`,sender:o});super(t.shortMessage||`An unknown error occurred while executing the contract function "${a}".`,{cause:t,docsPath:i,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],b&&"Contract Call:",b].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=n,this.args=r,this.cause=t,this.contractAddress=s,this.functionName=a,this.sender=o}}class pa extends f{constructor({abi:t,data:n,functionName:r,message:s}){let i,a,o,u;if(n&&n!=="0x")try{a=Yn({abi:t,data:n});const{abiItem:l,errorName:b,args:p}=a;if(b==="Error")u=p[0];else if(b==="Panic"){const[y]=p;u=na[y]}else{const y=l?xe(l,{includeName:!0}):void 0,h=l&&p?Zn({abiItem:l,args:p,includeFunctionName:!1,includeName:!1}):void 0;o=[y?`Error: ${y}`:"",h&&h!=="()"?` ${[...Array(b?.length??0).keys()].map(()=>" ").join("")}${h}`:""]}}catch(l){i=l}else s&&(u=s);let d;i instanceof an&&(d=i.signature,o=[`Unable to decode signature "${d}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${d}.`]),super(u&&u!=="execution reverted"||d?[`The contract function "${r}" reverted with the following ${d?"signature":"reason"}:`,u||d].join(`
29
+ `):`The contract function "${r}" reverted.`,{cause:i,metaMessages:o,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=a,this.raw=n,this.reason=u,this.signature=d}}class ya extends f{constructor({functionName:t}){super(`The contract function "${t}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${t}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class ba extends f{constructor({factory:t}){super(`Deployment for counterfactual contract call failed${t?` for factory "${t}".`:""}`,{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class Qn extends f{constructor({data:t,message:n}){super(n||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t}}function ma(e,t,n){const r=e[t.name];if(typeof r=="function")return r;const s=e[n];return typeof s=="function"?s:i=>t(e,i)}class ha extends f{constructor({body:t,cause:n,details:r,headers:s,status:i,url:a}){super("HTTP request failed.",{cause:n,details:r,metaMessages:[i&&`Status: ${i}`,`URL: ${kt(a)}`,t&&`Request body: ${Ve(t)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=t,this.headers=s,this.status=i,this.url=a}}class qn extends f{constructor({body:t,error:n,url:r}){super("RPC Request failed.",{cause:n,details:n.message,metaMessages:[`URL: ${kt(r)}`,`Request body: ${Ve(t)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n.code,this.data=n.data,this.url=r}}const ga=-1;class er extends f{constructor(t,{code:n,docsPath:r,metaMessages:s,name:i,shortMessage:a}){super(a,{cause:t,docsPath:r,metaMessages:s||t?.metaMessages,name:i||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=i||t.name,this.code=t instanceof qn?t.code:n??ga}}class We extends er{constructor(t){super(t,{code:We.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(We,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Ke extends er{constructor(t){super(t,{code:Ke.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
30
+ `)})}}Object.defineProperty(Ke,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});const xa=3;function wa(e,{abi:t,address:n,args:r,docsPath:s,functionName:i,sender:a}){const o=e instanceof Qn?e:e instanceof f?e.walk(h=>"data"in h)||e.walk():{},{code:u,data:d,details:l,message:b,shortMessage:p}=o,y=e instanceof Et?new ya({functionName:i}):[xa,We.code].includes(u)&&(d||l||b||p)||u===Ke.code&&l==="execution reverted"&&d?new pa({abi:t,data:typeof d=="object"?d.data:d,functionName:i,message:o instanceof qn?l:p??b}):e;return new fa(y,{abi:t,args:r,contractAddress:n,docsPath:s,functionName:i,sender:a})}const Ta="0.1.1";function va(){return Ta}class _ extends Error{static setStaticOptions(t){_.prototype.docsOrigin=t.docsOrigin,_.prototype.showVersion=t.showVersion,_.prototype.version=t.version}constructor(t,n={}){const r=(()=>{if(n.cause instanceof _){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:n.cause?.message?n.cause.message:n.details})(),s=n.cause instanceof _&&n.cause.docsPath||n.docsPath,i=n.docsOrigin??_.prototype.docsOrigin,a=`${i}${s??""}`,o=!!(n.version??_.prototype.showVersion),u=n.version??_.prototype.version,d=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||s||o?["",r?`Details: ${r}`:void 0,s?`See: ${a}`:void 0,o?`Version: ${u}`:void 0]:[]].filter(l=>typeof l=="string").join(`
31
+ `);super(d,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsOrigin",{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,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showVersion",{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,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.cause=n.cause,this.details=r,this.docs=a,this.docsOrigin=i,this.docsPath=s,this.shortMessage=t,this.showVersion=o,this.version=u}walk(t){return tr(this,t)}}Object.defineProperty(_,"defaultStaticOptions",{enumerable:!0,configurable:!0,writable:!0,value:{docsOrigin:"https://oxlib.sh",showVersion:!1,version:`ox@${va()}`}});_.setStaticOptions(_.defaultStaticOptions);function tr(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?tr(e.cause,t):t?null:e}function Ea(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const s=e.replace("0x","");if(s.length>r*2)throw new Aa({size:Math.ceil(s.length/2),targetSize:r,type:"Hex"});return`0x${s[n==="right"?"padEnd":"padStart"](r*2,"0")}`}function ae(e,t={}){const{signed:n,size:r}=t,s=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const a=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<a){const d=typeof e=="bigint"?"n":"";throw new Sa({max:i?`${i}${d}`:void 0,min:`${a}${d}`,signed:n,size:r,value:`${e}${d}`})}const u=`0x${(n&&s<0?BigInt.asUintN(r*8,BigInt(s)):s).toString(16)}`;return r?Pa(u,r):u}function Pa(e,t){return Ea(e,{dir:"left",size:t})}class Sa extends _{constructor({max:t,min:n,signed:r,size:s,value:i}){super(`Number \`${i}\` is not in safe${s?` ${s*8}-bit`:""}${r?" signed":" unsigned"} integer range ${t?`(\`${n}\` to \`${t}\`)`:`(above \`${n}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class Aa extends _{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function $a(e){return{address:e.address,amount:ae(e.amount),index:ae(e.index),validatorIndex:ae(e.validatorIndex)}}function Ca(e){return{...typeof e.baseFeePerGas=="bigint"&&{baseFeePerGas:ae(e.baseFeePerGas)},...typeof e.blobBaseFee=="bigint"&&{blobBaseFee:ae(e.blobBaseFee)},...typeof e.feeRecipient=="string"&&{feeRecipient:e.feeRecipient},...typeof e.gasLimit=="bigint"&&{gasLimit:ae(e.gasLimit)},...typeof e.number=="bigint"&&{number:ae(e.number)},...typeof e.prevRandao=="bigint"&&{prevRandao:ae(e.prevRandao)},...typeof e.time=="bigint"&&{time:ae(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map($a)}}}const ja="0x82ad56cb",Ia="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",Na="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",Ra="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033",st="/docs/contract/encodeDeployData";function nr(e){const{abi:t,args:n,bytecode:r}=e;if(!n||n.length===0)return r;const s=t.find(a=>"type"in a&&a.type==="constructor");if(!s)throw new _r({docsPath:st});if(!("inputs"in s))throw new Ot({docsPath:st});if(!s.inputs||s.inputs.length===0)throw new Ot({docsPath:st});const i=$t(s.inputs,n);return _e([r,i])}class Ee extends f{constructor({cause:t,message:n}={}){const r=n?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${r?`with reason: ${r}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}}Object.defineProperty(Ee,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(Ee,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class Fe extends f{constructor({cause:t,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${ge(n)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(Fe,"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 pt extends f{constructor({cause:t,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${ge(n)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}}Object.defineProperty(pt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class yt extends f{constructor({cause:t,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}}Object.defineProperty(yt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class bt extends f{constructor({cause:t,nonce:n}={}){super([`Nonce provided for the transaction ${n?`(${n}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
32
+ `),{cause:t,name:"NonceTooLowError"})}}Object.defineProperty(bt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class mt extends f{constructor({cause:t,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}}Object.defineProperty(mt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class ht extends f{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
33
+ `),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(ht,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class gt extends f{constructor({cause:t,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(gt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class xt extends f{constructor({cause:t,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(xt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class wt extends f{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(wt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Le extends f{constructor({cause:t,maxPriorityFeePerGas:n,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${n?` = ${ge(n)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${ge(r)} gwei`:""}).`].join(`
34
+ `),{cause:t,name:"TipAboveFeeCapError"})}}Object.defineProperty(Le,"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 rr extends f{constructor({cause:t}){super(`An error occurred while executing: ${t?.shortMessage}`,{cause:t,name:"UnknownNodeError"})}}function ka(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof f?e.walk(s=>s?.code===Ee.code):e;return r instanceof f?new Ee({cause:e,message:r.details}):Ee.nodeMessage.test(n)?new Ee({cause:e,message:e.details}):Fe.nodeMessage.test(n)?new Fe({cause:e,maxFeePerGas:t?.maxFeePerGas}):pt.nodeMessage.test(n)?new pt({cause:e,maxFeePerGas:t?.maxFeePerGas}):yt.nodeMessage.test(n)?new yt({cause:e,nonce:t?.nonce}):bt.nodeMessage.test(n)?new bt({cause:e,nonce:t?.nonce}):mt.nodeMessage.test(n)?new mt({cause:e,nonce:t?.nonce}):ht.nodeMessage.test(n)?new ht({cause:e}):gt.nodeMessage.test(n)?new gt({cause:e,gas:t?.gas}):xt.nodeMessage.test(n)?new xt({cause:e,gas:t?.gas}):wt.nodeMessage.test(n)?new wt({cause:e}):Le.nodeMessage.test(n)?new Le({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new rr({cause:e})}function Ma(e,{docsPath:t,...n}){const r=(()=>{const s=ka(e,n);return s instanceof rr?e:s})();return new la(r,{docsPath:t,...n})}function Da(e,{format:t}){if(!t)return{};const n={};function r(i){const a=Object.keys(i);for(const o of a)o in e&&(n[o]=e[o]),i[o]&&typeof i[o]=="object"&&!Array.isArray(i[o])&&r(i[o])}const s=t(e||{});return r(s),n}const Oa={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Ba(e,t){const n={};return typeof e.authorizationList<"u"&&(n.authorizationList=Ua(e.authorizationList)),typeof e.accessList<"u"&&(n.accessList=e.accessList),typeof e.blobVersionedHashes<"u"&&(n.blobVersionedHashes=e.blobVersionedHashes),typeof e.blobs<"u"&&(typeof e.blobs[0]!="string"?n.blobs=e.blobs.map(r=>ce(r)):n.blobs=e.blobs),typeof e.data<"u"&&(n.data=e.data),e.account&&(n.from=e.account.address),typeof e.from<"u"&&(n.from=e.from),typeof e.gas<"u"&&(n.gas=j(e.gas)),typeof e.gasPrice<"u"&&(n.gasPrice=j(e.gasPrice)),typeof e.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=j(e.maxFeePerBlobGas)),typeof e.maxFeePerGas<"u"&&(n.maxFeePerGas=j(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=j(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(n.nonce=j(e.nonce)),typeof e.to<"u"&&(n.to=e.to),typeof e.type<"u"&&(n.type=Oa[e.type]),typeof e.value<"u"&&(n.value=j(e.value)),n}function Ua(e){return e.map(t=>({address:t.address,r:t.r?j(BigInt(t.r)):t.r,s:t.s?j(BigInt(t.s)):t.s,chainId:j(t.chainId),nonce:j(t.nonce),...typeof t.yParity<"u"?{yParity:j(t.yParity)}:{},...typeof t.v<"u"&&typeof t.yParity>"u"?{v:j(t.v)}:{}}))}function Fa(){let e=()=>{},t=()=>{};return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}const it=new Map;function La({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:s}){const i=async()=>{const l=u();a();const b=l.map(({args:p})=>p);b.length!==0&&e(b).then(p=>{s&&Array.isArray(p)&&p.sort(s);for(let y=0;y<l.length;y++){const{resolve:h}=l[y];h?.([p[y],p])}}).catch(p=>{for(let y=0;y<l.length;y++){const{reject:h}=l[y];h?.(p)}})},a=()=>it.delete(t),o=()=>u().map(({args:l})=>l),u=()=>it.get(t)||[],d=l=>it.set(t,[...u(),l]);return{flush:a,async schedule(l){const{promise:b,resolve:p,reject:y}=Fa();return n?.([...o(),l])&&i(),u().length>0?(d({args:l,resolve:p,reject:y}),b):(d({args:l,resolve:p,reject:y}),setTimeout(i,r),b)}}}function Xt(e){if(!(!e||e.length===0))return e.reduce((t,{slot:n,value:r})=>{if(n.length!==66)throw new Bt({size:n.length,targetSize:66,type:"hex"});if(r.length!==66)throw new Bt({size:r.length,targetSize:66,type:"hex"});return t[n]=r,t},{})}function za(e){const{balance:t,nonce:n,state:r,stateDiff:s,code:i}=e,a={};if(i!==void 0&&(a.code=i),t!==void 0&&(a.balance=j(t)),n!==void 0&&(a.nonce=j(n)),r!==void 0&&(a.state=Xt(r)),s!==void 0){if(a.state)throw new ca;a.stateDiff=Xt(s)}return a}function _a(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!ye(n,{strict:!1}))throw new Re({address:n});if(t[n])throw new oa({address:n});t[n]=za(r)}return t}const Ga=2n**256n-1n;function Ha(e){const{account:t,maxFeePerGas:n,maxPriorityFeePerGas:r,to:s}=e,i=t?Rt(t):void 0;if(i&&!ye(i.address))throw new Re({address:i.address});if(s&&!ye(s))throw new Re({address:s});if(n&&n>Ga)throw new Fe({maxFeePerGas:n});if(r&&n&&r>n)throw new Le({maxFeePerGas:n,maxPriorityFeePerGas:r})}async function sr(e,t){const{account:n=e.account,authorizationList:r,batch:s=!!e.batch?.multicall,blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",accessList:o,blobs:u,blockOverrides:d,code:l,data:b,factory:p,factoryData:y,gas:h,gasPrice:v,maxFeePerBlobGas:E,maxFeePerGas:w,maxPriorityFeePerGas:m,nonce:x,to:P,value:R,stateOverride:O,...X}=t,J=n?Rt(n):void 0;if(l&&(p||y))throw new f("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(l&&P)throw new f("Cannot provide both `code` & `to` as parameters.");const H=l&&b,Q=p&&y&&P&&b,F=H||Q,de=H?ir({code:l,data:b}):Q?Ka({data:b,factory:p,factoryData:y,to:P}):b;try{Ha(t);const L=(typeof i=="bigint"?j(i):void 0)||a,M=d?Ca(d):void 0,z=_a(O),V=e.chain?.formatters?.transactionRequest?.format,k=(V||Ba)({...Da(X,{format:V}),accessList:o,account:J,authorizationList:r,blobs:u,data:de,gas:h,gasPrice:v,maxFeePerBlobGas:E,maxFeePerGas:w,maxPriorityFeePerGas:m,nonce:x,to:F?void 0:P,value:R},"call");if(s&&Va({request:k})&&!z&&!M)try{return await Wa(e,{...k,blockNumber:i,blockTag:a})}catch(q){if(!(q instanceof Wn)&&!(q instanceof ft))throw q}const W=(()=>{const q=[k,L];return z&&M?[...q,z,M]:z?[...q,z]:M?[...q,{},M]:q})(),be=await e.request({method:"eth_call",params:W});return be==="0x"?{data:void 0}:{data:be}}catch($){const L=Ya($),{offchainLookup:M,offchainLookupSignature:z}=await Promise.resolve().then(()=>require("./ccip-DKvRoXP4.cjs"));if(e.ccipRead!==!1&&L?.slice(0,10)===z&&P)return{data:await M(e,{data:L,to:P})};throw F&&L?.slice(0,10)==="0x101bb98d"?new ba({factory:p}):Ma($,{...t,account:J,chain:e.chain})}}function Va({request:e}){const{data:t,to:n,...r}=e;return!(!t||t.startsWith(ja)||!n||Object.values(r).filter(s=>typeof s<"u").length>0)}async function Wa(e,t){const{batchSize:n=1024,deployless:r=!1,wait:s=0}=typeof e.batch?.multicall=="object"?e.batch.multicall:{},{blockNumber:i,blockTag:a=e.experimental_blockTag??"latest",data:o,to:u}=t,d=(()=>{if(r)return null;if(t.multicallAddress)return t.multicallAddress;if(e.chain)return ta({blockNumber:i,chain:e.chain,contract:"multicall3"});throw new Wn})(),b=(typeof i=="bigint"?j(i):void 0)||a,{schedule:p}=La({id:`${e.uid}.${b}`,wait:s,shouldSplitBatch(v){return v.reduce((w,{data:m})=>w+(m.length-2),0)>n*2},fn:async v=>{const E=v.map(x=>({allowFailure:!0,callData:x.data,target:x.to})),w=Vn({abi:Dt,args:[E],functionName:"aggregate3"}),m=await e.request({method:"eth_call",params:[{...d===null?{data:ir({code:Ra,data:w})}:{to:d,data:w}},b]});return Hn({abi:Dt,args:[E],functionName:"aggregate3",data:m||"0x"})}}),[{returnData:y,success:h}]=await p({data:o,to:u});if(!h)throw new Qn({data:y});return y==="0x"?{data:void 0}:{data:y}}function ir(e){const{code:t,data:n}=e;return nr({abi:zn(["constructor(bytes, bytes)"]),bytecode:Ia,args:[t,n]})}function Ka(e){const{data:t,factory:n,factoryData:r,to:s}=e;return nr({abi:zn(["constructor(address, bytes, address, bytes)"]),bytecode:Na,args:[s,t,n,r]})}function Ya(e){if(!(e instanceof f))return;const t=e.walk();return typeof t?.data=="object"?t.data?.data:t.data}async function Za(e,t){const{abi:n,address:r,args:s,functionName:i,...a}=t,o=Vn({abi:n,args:s,functionName:i});try{const{data:u}=await ma(e,sr,"call")({...a,data:o,to:r});return Hn({abi:n,args:s,functionName:i,data:u||"0x"})}catch(u){throw wa(u,{abi:n,address:r,args:s,docsPath:"/docs/contract/readContract",functionName:i})}}function Xa(e,t,n){const r=e[t.name];if(typeof r=="function")return r;const s=e[n];return typeof s=="function"?s:i=>t(e,i)}function Ja(e,t){const{chainId:n,...r}=t,s=e.getClient({chainId:n});return Xa(s,Za,"readContract")(r)}function ar(){const{address:e}=A.useAccount(),t=A.useConfig(),{writeContractAsync:n,data:r,isPending:s,error:i}=A.useWriteContract(),{isLoading:a,isSuccess:o}=A.useWaitForTransactionReceipt({hash:r}),u=()=>A.useReadContract({address:D.PAYMENT_ROUTER,abi:Oe,functionName:"tokenRegistry"}),d=()=>A.useReadContract({address:D.PAYMENT_ROUTER,abi:Oe,functionName:"feePercentage"}),l=()=>A.useReadContract({address:D.PAYMENT_ROUTER,abi:Oe,functionName:"paused"}),b=async(h,v)=>{try{return await Ja(t,{address:h,abi:ee,functionName:"allowance",args:[v,D.PAYMENT_ROUTER]})}catch(E){return console.error("Error checking allowance:",E),BigInt(0)}},p=async(h,v)=>{if(!e)throw new Error("Wallet not connected");if(h==="0x0000000000000000000000000000000000000000")return null;try{return await b(h,e)>=v?(console.log(`Sufficient allowance for ${h}, skipping approval`),null):(console.log(`Requesting infinite approval for ${h}`),await n({address:h,abi:ee,functionName:"approve",args:[D.PAYMENT_ROUTER,fe.maxUint256]}))}catch(E){throw console.error(`Error in approveToken for ${h}:`,E),E}};return{executePayment:async({merchantAddress:h,tokens:v,totalAmountUSD:E,settleInIDR:w,target:m,callData:x})=>{if(!e)throw new Error("Wallet not connected");const P=v.filter($=>$.percentage>0),R=[],O=[];let X=BigInt(0);const J=E*.003,H=E+J;for(const $ of P){if(!$.priceUSD||$.priceUSD<=0)throw new Error(`Invalid price for ${$.symbol}. Price data may not be available yet. Please wait a moment and try again.`);const M=H*$.percentage/100/$.priceUSD;if(!isFinite(M)||M<=0)throw new Error(`Invalid amount calculated for ${$.symbol}`);const z=Math.min($.decimals+2,18),V=M.toFixed(z);let ne=fe.parseUnits(V,$.decimals);ne=ne+BigInt(1),$.address==="0x0000000000000000000000000000000000000000"?(X=ne,R.push($.address),O.push(ne)):(R.push($.address),O.push(ne))}for(let $=0;$<P.length;$++){const L=P[$];if(L.address!=="0x0000000000000000000000000000000000000000")try{await p(L.address,O[$])&&console.log(`Approved infinite allowance for ${L.symbol}`)}catch(M){throw new Error(`Failed to approve ${L.symbol}: ${M}`)}}const Q=BigInt(Math.floor(E*tn)),F=m||"0x0000000000000000000000000000000000000000",de=x||"0x";return await n({address:D.PAYMENT_ROUTER,abi:Oe,functionName:"pay",args:[h,R,O,Q,w,F,de],value:X})},useTokenRegistry:u,useFeePercentage:d,usePaused:l,hash:r,isPending:s,isConfirming:a,isConfirmed:o,error:i}}function Ie(e){const{address:t}=A.useAccount(),{writeContract:n,data:r,isPending:s,error:i}=A.useWriteContract(),{isLoading:a,isSuccess:o}=A.useWaitForTransactionReceipt({hash:r});return{transfer:(w,m)=>{n({address:e,abi:ee,functionName:"transfer",args:[w,m]})},approve:(w,m)=>{n({address:e,abi:ee,functionName:"approve",args:[w,m]})},transferFrom:(w,m,x)=>{n({address:e,abi:ee,functionName:"transferFrom",args:[w,m,x]})},useName:()=>A.useReadContract({address:e,abi:ee,functionName:"name"}),useSymbol:()=>A.useReadContract({address:e,abi:ee,functionName:"symbol"}),useDecimals:()=>A.useReadContract({address:e,abi:ee,functionName:"decimals"}),useTotalSupply:()=>A.useReadContract({address:e,abi:ee,functionName:"totalSupply"}),useBalanceOf:w=>{const m=w||t;return A.useReadContract({address:e,abi:ee,functionName:"balanceOf",args:m?[m]:void 0,query:{enabled:!!m}})},useAllowance:(w,m)=>A.useReadContract({address:e,abi:ee,functionName:"allowance",args:w&&m?[w,m]:void 0,query:{enabled:!!(w&&m)}}),hash:r,isPending:s,isConfirming:a,isConfirmed:o,error:i}}function or(){const{address:e}=A.useAccount(),{data:t,isLoading:n}=A.useBalance({address:e}),r=Ie(T.USDC),s=Ie(T.USDT),i=Ie(T.DAI),a=Ie(T.WBTC),{data:o,isLoading:u}=r.useBalanceOf(e),{data:d,isLoading:l}=s.useBalanceOf(e),{data:b,isLoading:p}=i.useBalanceOf(e),{data:y,isLoading:h}=a.useBalanceOf(e);return{balances:{ETH:t?parseFloat(fe.formatUnits(t.value,18)):0,USDC:o?parseFloat(fe.formatUnits(o,6)):0,USDT:d?parseFloat(fe.formatUnits(d,6)):0,DAI:b?parseFloat(fe.formatUnits(b,18)):0,WBTC:y?parseFloat(fe.formatUnits(y,8)):0},isLoading:!e||n||u||l||p||h}}function cr(){const e=ze(),{data:t,isLoading:n,error:r}=e.useGetTokenPrice(T.NATIVE),{data:s,isLoading:i,error:a}=e.useGetTokenPrice(T.USDC),{data:o,isLoading:u,error:d}=e.useGetTokenPrice(T.USDT),{data:l,isLoading:b,error:p}=e.useGetTokenPrice(T.DAI),{data:y,isLoading:h,error:v}=e.useGetTokenPrice(T.WBTC),E=1e8,w=x=>{if(!x)return 0;try{if(Array.isArray(x)&&x.length>=1){const P=x[0];if(typeof P=="bigint")return Number(P)/E;if(typeof P=="number")return P/E;if(typeof P=="string")return Number(P)/E}return typeof x=="bigint"?Number(x)/E:typeof x=="number"?x/E:0}catch(P){return console.error("Error converting price:",P),0}};r&&console.error("ETH price error:",r),a&&console.error("USDC price error:",a),d&&console.error("USDT price error:",d),p&&console.error("DAI price error:",p),v&&console.error("WBTC price error:",v);const m={ETH:w(t),USDC:w(s)||1,USDT:w(o)||1,DAI:w(l)||1,WBTC:w(y)};return console.log("Converted prices:",m),{prices:m,isLoading:n||i||u||b||h,errors:{ETH:r,USDC:a,USDT:d,DAI:p,WBTC:v}}}class ie extends Error{code;details;constructor(t,n,r){super(t),this.name="PaymentError",this.code=n,this.details=r}}function Jt(e){if(e instanceof Error){if(e.message.includes("User rejected")||e.message.includes("User denied"))return new ie("Transaction cancelled by user","USER_REJECTED",e);if(e.message.includes("Failed to approve"))return new ie(e.message,"APPROVAL_FAILED",e);if(e.message.includes("insufficient funds"))return new ie("Insufficient funds for gas","INSUFFICIENT_FUNDS",e);if(e.message.includes("Wallet not connected"))return new ie("Please connect your wallet","WALLET_NOT_CONNECTED",e);if(e.message.includes("network"))return new ie("Network error. Please check your connection","NETWORK_ERROR",e);if(e.message.includes("insufficient payment")||e.message.includes("PaymentRouter: insufficient"))return new ie("Payment amount is insufficient. This may be due to price fluctuation. Please try again.","INSUFFICIENT_PAYMENT",e);if(e.message.includes("execution reverted"))return new ie("Transaction failed. Please try again","CONTRACT_ERROR",e);if(e.message)return new ie(e.message,"ERROR",e)}return new ie("An unknown error occurred. Please try again","UNKNOWN",e)}const Qa=1e8,qa=e=>e.reduce((t,n)=>t+n.price,0);function eo({merchantAddress:e,items:t,config:n,onPaymentComplete:r,onPaymentError:s,className:i="",children:a}){const{isConnected:o}=A.useAccount(),{connect:u,connectors:d}=A.useConnect(),l=n?.currency??"USD",b=n?.target,p=n?.callData,y=qa(t),[h,v]=I.useState(!1),[E,w]=I.useState([]),m=ze(),{balances:x,isLoading:P}=or(),{prices:R,isLoading:O}=cr(),{data:X}=m.useGetTokenPrice(T.IDRX),{executePayment:J,isConfirmed:H,hash:Q,error:F,isPending:de,isConfirming:$}=ar(),M=(()=>{if(!X)return 1/15600;if(Array.isArray(X)&&X.length>=1){const k=X[0];if(typeof k=="bigint")return Number(k)/Qa}return 1/15600})(),z=l==="IDR"?y*M:y,V=()=>{o?v(!0):u({connector:d[0]})},ne=async k=>{try{await J({merchantAddress:e,tokens:k,totalAmountUSD:z,settleInIDR:l==="IDR",target:b,callData:p})}catch(W){const be=Jt(W);s?.(be)}};return I.useEffect(()=>{if(!P&&!O){const k=[{id:"eth",name:B.ETH.name,symbol:B.ETH.symbol,amount:x.ETH,chain:"Lisk Sepolia",percentage:0,address:T.NATIVE,decimals:B.ETH.decimals,priceUSD:R.ETH},{id:"usdc",name:B.USDC.name,symbol:B.USDC.symbol,amount:x.USDC,chain:"Lisk Sepolia",percentage:0,address:T.USDC,decimals:B.USDC.decimals,priceUSD:R.USDC},{id:"usdt",name:B.USDT.name,symbol:B.USDT.symbol,amount:x.USDT,chain:"Lisk Sepolia",percentage:0,address:T.USDT,decimals:B.USDT.decimals,priceUSD:R.USDT},{id:"dai",name:B.DAI.name,symbol:B.DAI.symbol,amount:x.DAI,chain:"Lisk Sepolia",percentage:0,address:T.DAI,decimals:B.DAI.decimals,priceUSD:R.DAI},{id:"wbtc",name:B.WBTC.name,symbol:B.WBTC.symbol,amount:x.WBTC,chain:"Lisk Sepolia",percentage:0,address:T.WBTC,decimals:B.WBTC.decimals,priceUSD:R.WBTC}];w(k)}},[x.ETH,x.USDC,x.USDT,x.DAI,x.WBTC,R.ETH,R.USDC,R.USDT,R.DAI,R.WBTC,P,O]),I.useEffect(()=>{if(H&&Q){const k={success:!0,transactionId:Q,tokens:E.filter(W=>W.percentage>0)};r?.(k)}},[H,Q]),I.useEffect(()=>{if(F){const k=Jt(F);s?.(k)}},[F]),c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:V,disabled:P||O,className:`bg-secondary hover:bg-secondary/90 text-white font-semibold py-3 px-6 rounded-lg transition-all disabled:opacity-50 disabled:cursor-not-allowed ${i}`,children:a||(o?"Pay with MultiCoyn":"Connect Wallet to Pay")}),o&&c.jsx(Ur,{isOpen:h,onClose:()=>v(!1),totalAmount:z,currency:l,items:t,tokens:E,onPaymentSubmit:ne,transactionHash:Q,isProcessing:de||$,isSuccess:H,conversionRate:M})]})}const ur=fe.defineChain({id:4202,name:"Lisk Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.sepolia-api.lisk.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-blockscout.lisk.com"}},testnet:!0}),dr=qt.getDefaultConfig({appName:"MultiCoyn Payment SDK",projectId:"YOUR_PROJECT_ID_HERE",chains:[ur],ssr:!1}),to=new Qt.QueryClient;function no({children:e}){return c.jsx(A.WagmiProvider,{config:dr,children:c.jsx(Qt.QueryClientProvider,{client:to,children:c.jsx(qt.RainbowKitProvider,{children:e})})})}const lr=I.createContext(void 0);function ro({children:e,initialConfig:t={}}){const[n,r]=I.useState(t),s=i=>{r(a=>({...a,...i}))};return c.jsx(lr.Provider,{value:{config:n,updateConfig:s},children:e})}function so(){const e=I.useContext(lr);if(!e)throw new Error("usePaymentConfig must be used within PaymentProvider");return e}exports.AbiErrorInputsNotFoundError=Kr;exports.AbiErrorNotFoundError=Yr;exports.AbiFunctionNotFoundError=Ne;exports.AbiFunctionOutputsNotFoundError=on;exports.AbiFunctionSignatureNotFoundError=Zr;exports.BaseError=f;exports.CONTRACTS=D;exports.FEE_BASIS_POINTS=jr;exports.FEE_PERCENTAGE=Ir;exports.HttpRequestError=ha;exports.InvalidAddressError=Re;exports.InvalidArrayError=cn;exports.MAX_TOKENS_PER_PAYMENT=Nr;exports.MAX_UINT256=Rr;exports.MulticoynButton=eo;exports.PaymentProvider=ro;exports.PaymentSummary=nn;exports.TOKENS=T;exports.TOKEN_METADATA=B;exports.USD_DECIMALS=en;exports.USD_SCALE=tn;exports.Web3Provider=no;exports.batchGatewayAbi=Lr;exports.call=sr;exports.concat=we;exports.concatHex=_e;exports.decodeAbiParameters=Nt;exports.decodeErrorResult=Yn;exports.encodeAbiParameters=$t;exports.formatAbiItem=xe;exports.getAbiItem=He;exports.getUrl=kt;exports.isAddress=ye;exports.isHex=Se;exports.liskSepolia=ur;exports.slice=ke;exports.solidityError=Kn;exports.stringify=Ve;exports.toFunctionSelector=Ge;exports.useERC20=Ie;exports.useMultiTokenBalances=or;exports.useMultiTokenPrices=cr;exports.usePaymentConfig=so;exports.usePaymentModal=Fr;exports.usePaymentRouter=ar;exports.useTokenRegistry=ze;exports.wagmiConfig=dr;