coinley-test 0.36.102 → 0.37.102

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.
@@ -37,7 +37,7 @@ const nk=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
37
37
  *
38
38
  * This source code is licensed under the MIT license found in the
39
39
  * LICENSE file in the root directory of this source tree.
40
- */var wC="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},EC=vC.useSyncExternalStore,_C=bC.useRef,xC=bC.useEffect,kC=bC.useMemo,SC=bC.useDebugValue;sC.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=_C(null);if(null===o.current){var s={hasValue:!1,value:null};o.current=s}else s=o.current;o=kC(function(){function e(e){if(!c){if(c=!0,o=e,e=r(e),void 0!==i&&s.hasValue){var t=s.value;if(i(t,e))return a=t}return a=e}if(t=a,wC(o,e))return t;var n=r(e);return void 0!==i&&i(t,n)?(o=e,t):(o=e,a=n)}var o,a,c=!1,l=void 0===n?null:n;return[function(){return e(t())},null===l?void 0:function(){return e(l())}]},[t,n,r,i]);var a=EC(e,o[0],o[1]);return xC(function(){s.hasValue=!0,s.value=a},[a]),SC(a),a},oC.exports=sC;var CC=oC.exports;const IC=e=>"object"==typeof e&&!Array.isArray(e);function AC(e={}){const t=iC(e);return function(e,t,n=t,r=qS){const i=yt.useRef([]),o=CC.useSyncExternalStoreWithSelector(e,t,n,e=>e,(e,t)=>{if(IC(e)&&IC(t)&&i.current.length){for(const n of i.current)if(!r(e[n],t[n]))return!1;return!0}return r(e,t)});return yt.useMemo(()=>{if(IC(o)){const e={...o};let t={};for(const[n,r]of Object.entries(e))t={...t,[n]:{configurable:!1,enumerable:!0,get:()=>(i.current.includes(n)||i.current.push(n),r)}};return Object.defineProperties(e,t),e}return o},[o])}(e=>function(e,t){const{onChange:n}=t;return e.subscribe(()=>zS(e),n,{equalityFn(e,t){const{connector:n,...r}=e,{connector:i,...o}=t;return qS(r,o)&&(null==n?void 0:n.id)===(null==i?void 0:i.id)&&(null==n?void 0:n.uid)===(null==i?void 0:i.uid)}})}(t,{onChange:e}),()=>zS(t))}var PC=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},MC={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},OC=new(n=class{constructor(){Ae(this,e,MC),Ae(this,t,!1)}setTimeoutProvider(t){Pe(this,e,t)}setTimeout(t,n){return Ie(this,e).setTimeout(t,n)}clearTimeout(t){Ie(this,e).clearTimeout(t)}setInterval(t,n){return Ie(this,e).setInterval(t,n)}clearInterval(t){Ie(this,e).clearInterval(t)}},e=new WeakMap,t=new WeakMap,n);var TC="undefined"==typeof window||"Deno"in globalThis;function RC(){}function NC(e){return"number"==typeof e&&e>=0&&e!==1/0}function LC(e,t){return Math.max(e+(t||0)-Date.now(),0)}function BC(e,t){return"function"==typeof e?e(t):e}function jC(e,t){return"function"==typeof e?e(t):e}function DC(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:s,stale:a}=e;if(s)if(r){if(t.queryHash!==FC(s,t.options))return!1}else if(!zC(t.queryKey,s))return!1;if("all"!==n){const e=t.isActive();if("active"===n&&!e)return!1;if("inactive"===n&&e)return!1}return("boolean"!=typeof a||t.isStale()===a)&&((!i||i===t.state.fetchStatus)&&!(o&&!o(t)))}function UC(e,t){const{exact:n,status:r,predicate:i,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if($C(t.options.mutationKey)!==$C(o))return!1}else if(!zC(t.options.mutationKey,o))return!1}return(!r||t.state.status===r)&&!(i&&!i(t))}function FC(e,t){return((null==t?void 0:t.queryKeyHashFn)||$C)(e)}function $C(e){return JSON.stringify(e,(e,t)=>GC(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function zC(e,t){return e===t||typeof e==typeof t&&(!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every(n=>zC(e[n],t[n])))}var HC=Object.prototype.hasOwnProperty;function qC(e,t){if(e===t)return e;const n=KC(e)&&KC(t);if(!(n||GC(e)&&GC(t)))return t;const r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),o=i.length,s=n?new Array(o):{};let a=0;for(let c=0;c<o;c++){const o=n?c:i[c],l=e[o],u=t[o];if(l===u){s[o]=l,(n?c<r:HC.call(e,o))&&a++;continue}if(null===l||null===u||"object"!=typeof l||"object"!=typeof u){s[o]=u;continue}const d=qC(l,u);s[o]=d,d===l&&a++}return r===o&&a===r?e:s}function WC(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function KC(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function GC(e){if(!VC(e))return!1;const t=e.constructor;if(void 0===t)return!0;const n=t.prototype;return!!VC(n)&&(!!n.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype)}function VC(e){return"[object Object]"===Object.prototype.toString.call(e)}function ZC(e,t,n){return"function"==typeof n.structuralSharing?n.structuralSharing(e,t):!1!==n.structuralSharing?qC(e,t):t}function YC(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function JC(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var QC=Symbol();function XC(e,t){return!e.queryFn&&(null==t?void 0:t.initialPromise)?()=>t.initialPromise:e.queryFn&&e.queryFn!==QC?e.queryFn:()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`))}function eI(e,t){return"function"==typeof e?e(...t):!!e}var tI=new(s=class extends PC{constructor(){super(),Ae(this,r),Ae(this,i),Ae(this,o),Pe(this,o,e=>{if(!TC&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}})}onSubscribe(){Ie(this,i)||this.setEventListener(Ie(this,o))}onUnsubscribe(){var e;this.hasListeners()||(null==(e=Ie(this,i))||e.call(this),Pe(this,i,void 0))}setEventListener(e){var t;Pe(this,o,e),null==(t=Ie(this,i))||t.call(this),Pe(this,i,e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()}))}setFocused(e){Ie(this,r)!==e&&(Pe(this,r,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){var e;return"boolean"==typeof Ie(this,r)?Ie(this,r):"hidden"!==(null==(e=globalThis.document)?void 0:e.visibilityState)}},r=new WeakMap,i=new WeakMap,o=new WeakMap,s);function nI(){let e,t;const n=new Promise((n,r)=>{e=n,t=r});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.status="pending",n.catch(()=>{}),n.resolve=t=>{r({status:"fulfilled",value:t}),e(t)},n.reject=e=>{r({status:"rejected",reason:e}),t(e)},n}var rI=function(e){setTimeout(e,0)};var iI=function(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=rI;const o=r=>{t?e.push(r):i(()=>{n(r)})};return{batch:o=>{let s;t++;try{s=o()}finally{t--,t||(()=>{const t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})})()}return s},batchCalls:e=>(...t)=>{o(()=>{e(...t)})},schedule:o,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}(),oI=new(u=class extends PC{constructor(){super(),Ae(this,a,!0),Ae(this,c),Ae(this,l),Pe(this,l,e=>{if(!TC&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}})}onSubscribe(){Ie(this,c)||this.setEventListener(Ie(this,l))}onUnsubscribe(){var e;this.hasListeners()||(null==(e=Ie(this,c))||e.call(this),Pe(this,c,void 0))}setEventListener(e){var t;Pe(this,l,e),null==(t=Ie(this,c))||t.call(this),Pe(this,c,e(this.setOnline.bind(this)))}setOnline(e){Ie(this,a)!==e&&(Pe(this,a,e),this.listeners.forEach(t=>{t(e)}))}isOnline(){return Ie(this,a)}},a=new WeakMap,c=new WeakMap,l=new WeakMap,u);function sI(e){return Math.min(1e3*2**e,3e4)}function aI(e){return"online"!==(e??"online")||oI.isOnline()}var cI=class extends Error{constructor(e){super("CancelledError"),this.revert=null==e?void 0:e.revert,this.silent=null==e?void 0:e.silent}};function lI(e){let t,n=!1,r=0;const i=nI(),o=()=>"pending"!==i.status,s=()=>tI.isFocused()&&("always"===e.networkMode||oI.isOnline())&&e.canRun(),a=()=>aI(e.networkMode)&&e.canRun(),c=e=>{o()||(null==t||t(),i.resolve(e))},l=e=>{o()||(null==t||t(),i.reject(e))},u=()=>new Promise(n=>{var r;t=e=>{(o()||s())&&n(e)},null==(r=e.onPause)||r.call(e)}).then(()=>{var n;t=void 0,o()||null==(n=e.onContinue)||n.call(e)}),d=()=>{if(o())return;let t;const i=0===r?e.initialPromise:void 0;try{t=i??e.fn()}catch(a){t=Promise.reject(a)}Promise.resolve(t).then(c).catch(t=>{var i;if(o())return;const a=e.retry??(TC?0:3),c=e.retryDelay??sI,h="function"==typeof c?c(r,t):c,f=!0===a||"number"==typeof a&&r<a||"function"==typeof a&&a(r,t);var p;!n&&f?(r++,null==(i=e.onFail)||i.call(e,r,t),(p=h,new Promise(e=>{OC.setTimeout(e,p)})).then(()=>s()?void 0:u()).then(()=>{n?l(t):d()})):l(t)})};return{promise:i,status:()=>i.status,cancel:t=>{var n;if(!o()){const r=new cI(t);l(r),null==(n=e.onCancel)||n.call(e,r)}},continue:()=>(null==t||t(),i),cancelRetry:()=>{n=!0},continueRetry:()=>{n=!1},canStart:a,start:()=>(a()?d():u().then(d),i)}}var uI=(h=class{constructor(){Ae(this,d)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),NC(this.gcTime)&&Pe(this,d,OC.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(TC?1/0:3e5))}clearGcTimeout(){Ie(this,d)&&(OC.clearTimeout(Ie(this,d)),Pe(this,d,void 0))}},d=new WeakMap,h),dI=(_=class extends uI{constructor(e){super(),Ae(this,w),Ae(this,f),Ae(this,p),Ae(this,m),Ae(this,g),Ae(this,y),Ae(this,b),Ae(this,v),Pe(this,v,!1),Pe(this,b,e.defaultOptions),this.setOptions(e.options),this.observers=[],Pe(this,g,e.client),Pe(this,m,Ie(this,g).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,Pe(this,f,pI(this.options)),this.state=e.state??Ie(this,f),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return null==(e=Ie(this,y))?void 0:e.promise}setOptions(e){if(this.options={...Ie(this,b),...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){const e=pI(this.options);void 0!==e.data&&(this.setState(fI(e.data,e.dataUpdatedAt)),Pe(this,f,e))}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||Ie(this,m).remove(this)}setData(e,t){const n=ZC(this.state.data,e,this.options);return Me(this,w,E).call(this,{data:n,type:"success",dataUpdatedAt:null==t?void 0:t.updatedAt,manual:null==t?void 0:t.manual}),n}setState(e,t){Me(this,w,E).call(this,{type:"setState",state:e,setStateOptions:t})}cancel(e){var t,n;const r=null==(t=Ie(this,y))?void 0:t.promise;return null==(n=Ie(this,y))||n.cancel(e),r?r.then(RC).catch(RC):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Ie(this,f))}isActive(){return this.observers.some(e=>!1!==jC(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===QC||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===BC(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!LC(this.state.dataUpdatedAt,e))}onFocus(){var e;const t=this.observers.find(e=>e.shouldFetchOnWindowFocus());null==t||t.refetch({cancelRefetch:!1}),null==(e=Ie(this,y))||e.continue()}onOnline(){var e;const t=this.observers.find(e=>e.shouldFetchOnReconnect());null==t||t.refetch({cancelRefetch:!1}),null==(e=Ie(this,y))||e.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),Ie(this,m).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(Ie(this,y)&&(Ie(this,v)?Ie(this,y).cancel({revert:!0}):Ie(this,y).cancelRetry()),this.scheduleGc()),Ie(this,m).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Me(this,w,E).call(this,{type:"invalidate"})}async fetch(e,t){var n,r,i,o,s,a,c,l,u,d,h,f;if("idle"!==this.state.fetchStatus&&"rejected"!==(null==(n=Ie(this,y))?void 0:n.status()))if(void 0!==this.state.data&&(null==t?void 0:t.cancelRefetch))this.cancel({silent:!0});else if(Ie(this,y))return Ie(this,y).continueRetry(),Ie(this,y).promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}const b=new AbortController,_=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(Pe(this,v,!0),b.signal)})},x=()=>{const e=XC(this.options,t),n=(()=>{const e={client:Ie(this,g),queryKey:this.queryKey,meta:this.meta};return _(e),e})();return Pe(this,v,!1),this.options.persister?this.options.persister(e,n,this):e(n)},k=(()=>{const e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:Ie(this,g),state:this.state,fetchFn:x};return _(e),e})();null==(r=this.options.behavior)||r.onFetch(k,this),Pe(this,p,this.state),"idle"!==this.state.fetchStatus&&this.state.fetchMeta===(null==(i=k.fetchOptions)?void 0:i.meta)||Me(this,w,E).call(this,{type:"fetch",meta:null==(o=k.fetchOptions)?void 0:o.meta}),Pe(this,y,lI({initialPromise:null==t?void 0:t.initialPromise,fn:k.fetchFn,onCancel:e=>{e instanceof cI&&e.revert&&this.setState({...Ie(this,p),fetchStatus:"idle"}),b.abort()},onFail:(e,t)=>{Me(this,w,E).call(this,{type:"failed",failureCount:e,error:t})},onPause:()=>{Me(this,w,E).call(this,{type:"pause"})},onContinue:()=>{Me(this,w,E).call(this,{type:"continue"})},retry:k.options.retry,retryDelay:k.options.retryDelay,networkMode:k.options.networkMode,canRun:()=>!0}));try{const e=await Ie(this,y).start();if(void 0===e)throw new Error(`${this.queryHash} data is undefined`);return this.setData(e),null==(a=(s=Ie(this,m).config).onSuccess)||a.call(s,e,this),null==(l=(c=Ie(this,m).config).onSettled)||l.call(c,e,this.state.error,this),e}catch(S){if(S instanceof cI){if(S.silent)return Ie(this,y).promise;if(S.revert){if(void 0===this.state.data)throw S;return this.state.data}}throw Me(this,w,E).call(this,{type:"error",error:S}),null==(d=(u=Ie(this,m).config).onError)||d.call(u,S,this),null==(f=(h=Ie(this,m).config).onSettled)||f.call(h,this.state.data,S,this),S}finally{this.scheduleGc()}}},f=new WeakMap,p=new WeakMap,m=new WeakMap,g=new WeakMap,y=new WeakMap,b=new WeakMap,v=new WeakMap,w=new WeakSet,E=function(e){this.state=(t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...hI(t.data,this.options),fetchMeta:e.meta??null};case"success":const n={...t,...fI(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return Pe(this,p,e.manual?n:void 0),n;case"error":const r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),iI.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),Ie(this,m).notify({query:this,type:"updated",action:e})})},_);function hI(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:aI(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function fI(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function pI(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,n=void 0!==t,r=n?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var mI=(V=class extends PC{constructor(e,t){super(),Ae(this,D),Ae(this,x),Ae(this,k),Ae(this,S),Ae(this,C),Ae(this,I),Ae(this,A),Ae(this,P),Ae(this,M),Ae(this,O),Ae(this,T),Ae(this,R),Ae(this,N),Ae(this,L),Ae(this,B),Ae(this,j,new Set),this.options=t,Pe(this,x,e),Pe(this,M,null),Pe(this,P,nI()),this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(Ie(this,k).addObserver(this),gI(Ie(this,k),this.options)?Me(this,D,U).call(this):this.updateResult(),Me(this,D,H).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return yI(Ie(this,k),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return yI(Ie(this,k),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Me(this,D,q).call(this),Me(this,D,W).call(this),Ie(this,k).removeObserver(this)}setOptions(e){const t=this.options,n=Ie(this,k);if(this.options=Ie(this,x).defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof jC(this.options.enabled,Ie(this,k)))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Me(this,D,K).call(this),Ie(this,k).setOptions(this.options),t._defaulted&&!WC(this.options,t)&&Ie(this,x).getQueryCache().notify({type:"observerOptionsUpdated",query:Ie(this,k),observer:this});const r=this.hasListeners();r&&bI(Ie(this,k),n,this.options,t)&&Me(this,D,U).call(this),this.updateResult(),!r||Ie(this,k)===n&&jC(this.options.enabled,Ie(this,k))===jC(t.enabled,Ie(this,k))&&BC(this.options.staleTime,Ie(this,k))===BC(t.staleTime,Ie(this,k))||Me(this,D,F).call(this);const i=Me(this,D,$).call(this);!r||Ie(this,k)===n&&jC(this.options.enabled,Ie(this,k))===jC(t.enabled,Ie(this,k))&&i===Ie(this,B)||Me(this,D,z).call(this,i)}getOptimisticResult(e){const t=Ie(this,x).getQueryCache().build(Ie(this,x),e),n=this.createResult(t,e);return function(e,t){if(!WC(e.getCurrentResult(),t))return!0;return!1}(this,n)&&(Pe(this,C,n),Pe(this,A,this.options),Pe(this,I,Ie(this,k).state)),n}getCurrentResult(){return Ie(this,C)}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),null==t||t(n),"promise"===n&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==Ie(this,P).status||Ie(this,P).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,n))})}trackProp(e){Ie(this,j).add(e)}getCurrentQuery(){return Ie(this,k)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=Ie(this,x).defaultQueryOptions(e),n=Ie(this,x).getQueryCache().build(Ie(this,x),t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return Me(this,D,U).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),Ie(this,C)))}createResult(e,t){var n;const r=Ie(this,k),i=this.options,o=Ie(this,C),s=Ie(this,I),a=Ie(this,A),c=e!==r?e.state:Ie(this,S),{state:l}=e;let u,d={...l},h=!1;if(t._optimisticResults){const n=this.hasListeners(),o=!n&&gI(e,t),s=n&&bI(e,r,t,i);(o||s)&&(d={...d,...hI(l.data,e.options)}),"isRestoring"===t._optimisticResults&&(d.fetchStatus="idle")}let{error:f,errorUpdatedAt:p,status:m}=d;u=d.data;let g=!1;if(void 0!==t.placeholderData&&void 0===u&&"pending"===m){let e;(null==o?void 0:o.isPlaceholderData)&&t.placeholderData===(null==a?void 0:a.placeholderData)?(e=o.data,g=!0):e="function"==typeof t.placeholderData?t.placeholderData(null==(n=Ie(this,R))?void 0:n.state.data,Ie(this,R)):t.placeholderData,void 0!==e&&(m="success",u=ZC(null==o?void 0:o.data,e,t),h=!0)}if(t.select&&void 0!==u&&!g)if(o&&u===(null==s?void 0:s.data)&&t.select===Ie(this,O))u=Ie(this,T);else try{Pe(this,O,t.select),u=t.select(u),u=ZC(null==o?void 0:o.data,u,t),Pe(this,T,u),Pe(this,M,null)}catch(x){Pe(this,M,x)}Ie(this,M)&&(f=Ie(this,M),u=Ie(this,T),p=Date.now(),m="error");const y="fetching"===d.fetchStatus,b="pending"===m,v="error"===m,w=b&&y,E=void 0!==u,_={status:m,fetchStatus:d.fetchStatus,isPending:b,isSuccess:"success"===m,isError:v,isInitialLoading:w,isLoading:w,data:u,dataUpdatedAt:d.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!b,isLoadingError:v&&!E,isPaused:"paused"===d.fetchStatus,isPlaceholderData:h,isRefetchError:v&&E,isStale:vI(e,t),refetch:this.refetch,promise:Ie(this,P),isEnabled:!1!==jC(t.enabled,e)};if(this.options.experimental_prefetchInRender){const t=e=>{"error"===_.status?e.reject(_.error):void 0!==_.data&&e.resolve(_.data)},n=()=>{const e=Pe(this,P,_.promise=nI());t(e)},i=Ie(this,P);switch(i.status){case"pending":e.queryHash===r.queryHash&&t(i);break;case"fulfilled":"error"!==_.status&&_.data===i.value||n();break;case"rejected":"error"===_.status&&_.error===i.reason||n()}}return _}updateResult(){const e=Ie(this,C),t=this.createResult(Ie(this,k),this.options);if(Pe(this,I,Ie(this,k).state),Pe(this,A,this.options),void 0!==Ie(this,I).data&&Pe(this,R,Ie(this,k)),WC(t,e))return;Pe(this,C,t);Me(this,D,G).call(this,{listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,n="function"==typeof t?t():t;if("all"===n||!n&&!Ie(this,j).size)return!0;const r=new Set(n??Ie(this,j));return this.options.throwOnError&&r.add("error"),Object.keys(Ie(this,C)).some(t=>{const n=t;return Ie(this,C)[n]!==e[n]&&r.has(n)})})()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Me(this,D,H).call(this)}},x=new WeakMap,k=new WeakMap,S=new WeakMap,C=new WeakMap,I=new WeakMap,A=new WeakMap,P=new WeakMap,M=new WeakMap,O=new WeakMap,T=new WeakMap,R=new WeakMap,N=new WeakMap,L=new WeakMap,B=new WeakMap,j=new WeakMap,D=new WeakSet,U=function(e){Me(this,D,K).call(this);let t=Ie(this,k).fetch(this.options,e);return(null==e?void 0:e.throwOnError)||(t=t.catch(RC)),t},F=function(){Me(this,D,q).call(this);const e=BC(this.options.staleTime,Ie(this,k));if(TC||Ie(this,C).isStale||!NC(e))return;const t=LC(Ie(this,C).dataUpdatedAt,e)+1;Pe(this,N,OC.setTimeout(()=>{Ie(this,C).isStale||this.updateResult()},t))},$=function(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(Ie(this,k)):this.options.refetchInterval)??!1},z=function(e){Me(this,D,W).call(this),Pe(this,B,e),!TC&&!1!==jC(this.options.enabled,Ie(this,k))&&NC(Ie(this,B))&&0!==Ie(this,B)&&Pe(this,L,OC.setInterval(()=>{(this.options.refetchIntervalInBackground||tI.isFocused())&&Me(this,D,U).call(this)},Ie(this,B)))},H=function(){Me(this,D,F).call(this),Me(this,D,z).call(this,Me(this,D,$).call(this))},q=function(){Ie(this,N)&&(OC.clearTimeout(Ie(this,N)),Pe(this,N,void 0))},W=function(){Ie(this,L)&&(OC.clearInterval(Ie(this,L)),Pe(this,L,void 0))},K=function(){const e=Ie(this,x).getQueryCache().build(Ie(this,x),this.options);if(e===Ie(this,k))return;const t=Ie(this,k);Pe(this,k,e),Pe(this,S,e.state),this.hasListeners()&&(null==t||t.removeObserver(this),e.addObserver(this))},G=function(e){iI.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(Ie(this,C))}),Ie(this,x).getQueryCache().notify({query:Ie(this,k),type:"observerResultsUpdated"})})},V);function gI(e,t){return function(e,t){return!1!==jC(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===t.retryOnMount)}(e,t)||void 0!==e.state.data&&yI(e,t,t.refetchOnMount)}function yI(e,t,n){if(!1!==jC(t.enabled,e)&&"static"!==BC(t.staleTime,e)){const r="function"==typeof n?n(e):n;return"always"===r||!1!==r&&vI(e,t)}return!1}function bI(e,t,n,r){return(e!==t||!1===jC(r.enabled,e))&&(!n.suspense||"error"!==e.state.status)&&vI(e,n)}function vI(e,t){return!1!==jC(t.enabled,e)&&e.isStaleByTime(BC(t.staleTime,e))}function wI(e){return{onFetch:(t,n)=>{var r,i,o,s,a;const c=t.options,l=null==(o=null==(i=null==(r=t.fetchOptions)?void 0:r.meta)?void 0:i.fetchMore)?void 0:o.direction,u=(null==(s=t.state.data)?void 0:s.pages)||[],d=(null==(a=t.state.data)?void 0:a.pageParams)||[];let h={pages:[],pageParams:[]},f=0;const p=async()=>{let n=!1;const r=XC(t.options,t.fetchOptions),i=async(e,i,o)=>{if(n)return Promise.reject();if(null==i&&e.pages.length)return Promise.resolve(e);const s=(()=>{const e={client:t.client,queryKey:t.queryKey,pageParam:i,direction:o?"backward":"forward",meta:t.options.meta};var r;return r=e,Object.defineProperty(r,"signal",{enumerable:!0,get:()=>(t.signal.aborted?n=!0:t.signal.addEventListener("abort",()=>{n=!0}),t.signal)}),e})(),a=await r(s),{maxPages:c}=t.options,l=o?JC:YC;return{pages:l(e.pages,a,c),pageParams:l(e.pageParams,i,c)}};if(l&&u.length){const e="backward"===l,t={pages:u,pageParams:d},n=(e?_I:EI)(c,t);h=await i(t,n,e)}else{const t=e??u.length;do{const e=0===f?d[0]??c.initialPageParam:EI(c,h);if(f>0&&null==e)break;h=await i(h,e),f++}while(f<t)}return h};t.options.persister?t.fetchFn=()=>{var e,r;return null==(r=(e=t.options).persister)?void 0:r.call(e,p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=p}}}function EI(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function _I(e,{pages:t,pageParams:n}){var r;return t.length>0?null==(r=e.getPreviousPageParam)?void 0:r.call(e,t[0],t,n[0],n):void 0}var xI=(te=class extends uI{constructor(e){super(),Ae(this,X),Ae(this,Z),Ae(this,Y),Ae(this,J),Ae(this,Q),Pe(this,Z,e.client),this.mutationId=e.mutationId,Pe(this,J,e.mutationCache),Pe(this,Y,[]),this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){Ie(this,Y).includes(e)||(Ie(this,Y).push(e),this.clearGcTimeout(),Ie(this,J).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){Pe(this,Y,Ie(this,Y).filter(t=>t!==e)),this.scheduleGc(),Ie(this,J).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){Ie(this,Y).length||("pending"===this.state.status?this.scheduleGc():Ie(this,J).remove(this))}continue(){var e;return(null==(e=Ie(this,Q))?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var t,n,r,i,o,s,a,c,l,u,d,h,f,p,m,g,y,b,v,w;const E=()=>{Me(this,X,ee).call(this,{type:"continue"})},_={client:Ie(this,Z),meta:this.options.meta,mutationKey:this.options.mutationKey};Pe(this,Q,lI({fn:()=>this.options.mutationFn?this.options.mutationFn(e,_):Promise.reject(new Error("No mutationFn found")),onFail:(e,t)=>{Me(this,X,ee).call(this,{type:"failed",failureCount:e,error:t})},onPause:()=>{Me(this,X,ee).call(this,{type:"pause"})},onContinue:E,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Ie(this,J).canRun(this)}));const x="pending"===this.state.status,k=!Ie(this,Q).canStart();try{if(x)E();else{Me(this,X,ee).call(this,{type:"pending",variables:e,isPaused:k}),await(null==(n=(t=Ie(this,J).config).onMutate)?void 0:n.call(t,e,this,_));const o=await(null==(i=(r=this.options).onMutate)?void 0:i.call(r,e,_));o!==this.state.context&&Me(this,X,ee).call(this,{type:"pending",context:o,variables:e,isPaused:k})}const f=await Ie(this,Q).start();return await(null==(s=(o=Ie(this,J).config).onSuccess)?void 0:s.call(o,f,e,this.state.context,this,_)),await(null==(c=(a=this.options).onSuccess)?void 0:c.call(a,f,e,this.state.context,_)),await(null==(u=(l=Ie(this,J).config).onSettled)?void 0:u.call(l,f,null,this.state.variables,this.state.context,this,_)),await(null==(h=(d=this.options).onSettled)?void 0:h.call(d,f,null,e,this.state.context,_)),Me(this,X,ee).call(this,{type:"success",data:f}),f}catch(S){try{throw await(null==(p=(f=Ie(this,J).config).onError)?void 0:p.call(f,S,e,this.state.context,this,_)),await(null==(g=(m=this.options).onError)?void 0:g.call(m,S,e,this.state.context,_)),await(null==(b=(y=Ie(this,J).config).onSettled)?void 0:b.call(y,void 0,S,this.state.variables,this.state.context,this,_)),await(null==(w=(v=this.options).onSettled)?void 0:w.call(v,void 0,S,e,this.state.context,_)),S}finally{Me(this,X,ee).call(this,{type:"error",error:S})}}finally{Ie(this,J).runNext(this)}}},Z=new WeakMap,Y=new WeakMap,J=new WeakMap,Q=new WeakMap,X=new WeakSet,ee=function(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),iI.batch(()=>{Ie(this,Y).forEach(t=>{t.onMutationUpdate(e)}),Ie(this,J).notify({mutation:this,type:"updated",action:e})})},te);var kI=(oe=class extends PC{constructor(e={}){super(),Ae(this,ne),Ae(this,re),Ae(this,ie),this.config=e,Pe(this,ne,new Set),Pe(this,re,new Map),Pe(this,ie,0)}build(e,t,n){const r=new xI({client:e,mutationCache:this,mutationId:++Oe(this,ie)._,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){Ie(this,ne).add(e);const t=SI(e);if("string"==typeof t){const n=Ie(this,re).get(t);n?n.push(e):Ie(this,re).set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(Ie(this,ne).delete(e)){const t=SI(e);if("string"==typeof t){const n=Ie(this,re).get(t);if(n)if(n.length>1){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}else n[0]===e&&Ie(this,re).delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=SI(e);if("string"==typeof t){const n=Ie(this,re).get(t),r=null==n?void 0:n.find(e=>"pending"===e.state.status);return!r||r===e}return!0}runNext(e){var t;const n=SI(e);if("string"==typeof n){const r=null==(t=Ie(this,re).get(n))?void 0:t.find(t=>t!==e&&t.state.isPaused);return(null==r?void 0:r.continue())??Promise.resolve()}return Promise.resolve()}clear(){iI.batch(()=>{Ie(this,ne).forEach(e=>{this.notify({type:"removed",mutation:e})}),Ie(this,ne).clear(),Ie(this,re).clear()})}getAll(){return Array.from(Ie(this,ne))}find(e){const t={exact:!0,...e};return this.getAll().find(e=>UC(t,e))}findAll(e={}){return this.getAll().filter(t=>UC(e,t))}notify(e){iI.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(e=>e.state.isPaused);return iI.batch(()=>Promise.all(e.map(e=>e.continue().catch(RC))))}},ne=new WeakMap,re=new WeakMap,ie=new WeakMap,oe);function SI(e){var t;return null==(t=e.options.scope)?void 0:t.id}var CI=(fe=class extends PC{constructor(e,t){super(),Ae(this,ue),Ae(this,se),Ae(this,ae),Ae(this,ce),Ae(this,le),Pe(this,se,e),this.setOptions(t),this.bindMethods(),Me(this,ue,de).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var t;const n=this.options;this.options=Ie(this,se).defaultMutationOptions(e),WC(this.options,n)||Ie(this,se).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Ie(this,ce),observer:this}),(null==n?void 0:n.mutationKey)&&this.options.mutationKey&&$C(n.mutationKey)!==$C(this.options.mutationKey)?this.reset():"pending"===(null==(t=Ie(this,ce))?void 0:t.state.status)&&Ie(this,ce).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||null==(e=Ie(this,ce))||e.removeObserver(this)}onMutationUpdate(e){Me(this,ue,de).call(this),Me(this,ue,he).call(this,e)}getCurrentResult(){return Ie(this,ae)}reset(){var e;null==(e=Ie(this,ce))||e.removeObserver(this),Pe(this,ce,void 0),Me(this,ue,de).call(this),Me(this,ue,he).call(this)}mutate(e,t){var n;return Pe(this,le,t),null==(n=Ie(this,ce))||n.removeObserver(this),Pe(this,ce,Ie(this,se).getMutationCache().build(Ie(this,se),this.options)),Ie(this,ce).addObserver(this),Ie(this,ce).execute(e)}},se=new WeakMap,ae=new WeakMap,ce=new WeakMap,le=new WeakMap,ue=new WeakSet,de=function(){var e;const t=(null==(e=Ie(this,ce))?void 0:e.state)??{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0};Pe(this,ae,{...t,isPending:"pending"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset})},he=function(e){iI.batch(()=>{var t,n,r,i,o,s,a,c;if(Ie(this,le)&&this.hasListeners()){const l=Ie(this,ae).variables,u=Ie(this,ae).context,d={client:Ie(this,se),meta:this.options.meta,mutationKey:this.options.mutationKey};"success"===(null==e?void 0:e.type)?(null==(n=(t=Ie(this,le)).onSuccess)||n.call(t,e.data,l,u,d),null==(i=(r=Ie(this,le)).onSettled)||i.call(r,e.data,null,l,u,d)):"error"===(null==e?void 0:e.type)&&(null==(s=(o=Ie(this,le)).onError)||s.call(o,e.error,l,u,d),null==(c=(a=Ie(this,le)).onSettled)||c.call(a,void 0,e.error,l,u,d))}this.listeners.forEach(e=>{e(Ie(this,ae))})})},fe),II=(me=class extends PC{constructor(e={}){super(),Ae(this,pe),this.config=e,Pe(this,pe,new Map)}build(e,t,n){const r=t.queryKey,i=t.queryHash??FC(r,t);let o=this.get(i);return o||(o=new dI({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(o)),o}add(e){Ie(this,pe).has(e.queryHash)||(Ie(this,pe).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=Ie(this,pe).get(e.queryHash);t&&(e.destroy(),t===e&&Ie(this,pe).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){iI.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return Ie(this,pe).get(e)}getAll(){return[...Ie(this,pe).values()]}find(e){const t={exact:!0,...e};return this.getAll().find(e=>DC(t,e))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(t=>DC(e,t)):t}notify(e){iI.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){iI.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){iI.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},pe=new WeakMap,me),AI=(ke=class{constructor(e={}){Ae(this,ge),Ae(this,ye),Ae(this,be),Ae(this,ve),Ae(this,we),Ae(this,Ee),Ae(this,_e),Ae(this,xe),Pe(this,ge,e.queryCache||new II),Pe(this,ye,e.mutationCache||new kI),Pe(this,be,e.defaultOptions||{}),Pe(this,ve,new Map),Pe(this,we,new Map),Pe(this,Ee,0)}mount(){Oe(this,Ee)._++,1===Ie(this,Ee)&&(Pe(this,_e,tI.subscribe(async e=>{e&&(await this.resumePausedMutations(),Ie(this,ge).onFocus())})),Pe(this,xe,oI.subscribe(async e=>{e&&(await this.resumePausedMutations(),Ie(this,ge).onOnline())})))}unmount(){var e,t;Oe(this,Ee)._--,0===Ie(this,Ee)&&(null==(e=Ie(this,_e))||e.call(this),Pe(this,_e,void 0),null==(t=Ie(this,xe))||t.call(this),Pe(this,xe,void 0))}isFetching(e){return Ie(this,ge).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return Ie(this,ye).findAll({...e,status:"pending"}).length}getQueryData(e){var t;const n=this.defaultQueryOptions({queryKey:e});return null==(t=Ie(this,ge).get(n.queryHash))?void 0:t.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=Ie(this,ge).build(this,t),r=n.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(BC(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return Ie(this,ge).findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=Ie(this,ge).get(r.queryHash),o=function(e,t){return"function"==typeof e?e(t):e}(t,null==i?void 0:i.state.data);if(void 0!==o)return Ie(this,ge).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return iI.batch(()=>Ie(this,ge).findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){var t;const n=this.defaultQueryOptions({queryKey:e});return null==(t=Ie(this,ge).get(n.queryHash))?void 0:t.state}removeQueries(e){const t=Ie(this,ge);iI.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){const n=Ie(this,ge);return iI.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=iI.batch(()=>Ie(this,ge).findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(RC).catch(RC)}invalidateQueries(e,t={}){return iI.batch(()=>(Ie(this,ge).findAll(e).forEach(e=>{e.invalidate()}),"none"===(null==e?void 0:e.refetchType)?Promise.resolve():this.refetchQueries({...e,type:(null==e?void 0:e.refetchType)??(null==e?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=iI.batch(()=>Ie(this,ge).findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(RC)),"paused"===e.state.fetchStatus?Promise.resolve():t}));return Promise.all(r).then(RC)}fetchQuery(e){const t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);const n=Ie(this,ge).build(this,t);return n.isStaleByTime(BC(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(RC).catch(RC)}fetchInfiniteQuery(e){return e.behavior=wI(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(RC).catch(RC)}ensureInfiniteQueryData(e){return e.behavior=wI(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return oI.isOnline()?Ie(this,ye).resumePausedMutations():Promise.resolve()}getQueryCache(){return Ie(this,ge)}getMutationCache(){return Ie(this,ye)}getDefaultOptions(){return Ie(this,be)}setDefaultOptions(e){Pe(this,be,e)}setQueryDefaults(e,t){Ie(this,ve).set($C(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...Ie(this,ve).values()],n={};return t.forEach(t=>{zC(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){Ie(this,we).set($C(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...Ie(this,we).values()],n={};return t.forEach(t=>{zC(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...Ie(this,be).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=FC(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===QC&&(t.enabled=!1),t}defaultMutationOptions(e){return(null==e?void 0:e._defaulted)?e:{...Ie(this,be).mutations,...(null==e?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){Ie(this,ge).clear(),Ie(this,ye).clear()}},ge=new WeakMap,ye=new WeakMap,be=new WeakMap,ve=new WeakMap,we=new WeakMap,Ee=new WeakMap,_e=new WeakMap,xe=new WeakMap,ke);function PI(e){return JSON.stringify(e,(e,t)=>function(e){if(!MI(e))return!1;const t=e.constructor;if(void 0===t)return!0;const n=t.prototype;return!!MI(n)&&!!n.hasOwnProperty("isPrototypeOf")}(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):"bigint"==typeof t?t.toString():t)}function MI(e){return"[object Object]"===Object.prototype.toString.call(e)}function OI(e){const{_defaulted:t,behavior:n,gcTime:r,initialData:i,initialDataUpdatedAt:o,maxPages:s,meta:a,networkMode:c,queryFn:l,queryHash:u,queryKey:d,queryKeyHashFn:h,retry:f,retryDelay:p,structuralSharing:m,getPreviousPageParam:g,getNextPageParam:y,initialPageParam:b,_optimisticResults:v,enabled:w,notifyOnChangeProps:E,placeholderData:_,refetchInterval:x,refetchIntervalInBackground:k,refetchOnMount:S,refetchOnReconnect:C,refetchOnWindowFocus:I,retryOnMount:A,select:P,staleTime:M,suspense:O,throwOnError:T,config:R,connector:N,query:L,...B}=e;return B}function TI(e){return{mutationFn:t=>async function(e,t){var n;let r;if(r="function"==typeof t.connector?e._internal.connectors.setup(t.connector):t.connector,r.uid===e.state.current)throw new _S;try{e.setState(e=>({...e,status:"connecting"})),r.emitter.emit("message",{type:"connecting"});const{connector:i,...o}=t,s=await r.connect(o);return r.emitter.off("connect",e._internal.events.connect),r.emitter.on("change",e._internal.events.change),r.emitter.on("disconnect",e._internal.events.disconnect),await(null==(n=e.storage)?void 0:n.setItem("recentConnectorId",r.id)),e.setState(e=>({...e,connections:new Map(e.connections).set(r.uid,{accounts:o.withCapabilities?s.accounts.map(e=>"object"==typeof e?e.address:e):s.accounts,chainId:s.chainId,connector:r}),current:r.uid,status:"connected"})),{accounts:o.withCapabilities?s.accounts.map(e=>"object"==typeof e?e:{address:e,capabilities:{}}):s.accounts,chainId:s.chainId}}catch(i){throw e.setState(e=>({...e,status:e.current?"connected":"disconnected"})),i}}(e,t),mutationKey:["connect"]}}function RI(e){return{mutationFn:t=>async function(e,t){var n;const{addEthereumChainParameter:r,chainId:i}=t,o=e.state.connections.get((null==(n=t.connector)?void 0:n.uid)??e.state.current);if(o){const e=o.connector;if(!e.switchChain)throw new JS({connector:e});return await e.switchChain({addEthereumChainParameter:r,chainId:i})}const s=e.chains.find(e=>e.id===i);if(!s)throw new ES;return e.setState(e=>({...e,chainId:i})),s}(e,t),mutationKey:["switchChain"]}}function NI(e,t={}){return{async queryFn({queryKey:n}){const{hash:r,...i}=n[1];if(!r)throw new Error("hash is required");return async function(e,t){const{chainId:n,timeout:r=0,...i}=t,o=e.getClient({chainId:n}),s=gS(o,iS,"waitForTransactionReceipt"),a=await s({...i,timeout:r});if("reverted"===a.status){const e=gS(o,Ik,"getTransaction"),{from:t,...n}=await e({hash:a.transactionHash}),r=gS(o,dw,"call"),i=await r({...n,account:t,data:n.input,gasPrice:"eip1559"!==n.type?n.gasPrice:void 0,maxFeePerGas:"eip1559"===n.type?n.maxFeePerGas:void 0,maxPriorityFeePerGas:"eip1559"===n.type?n.maxPriorityFeePerGas:void 0}),s=(null==i?void 0:i.data)?Hf(`0x${i.data.substring(138)}`):"unknown reason";throw new Error(s)}return{...a,chainId:o.chain.id}}(e,{...i,onReplaced:t.onReplaced,hash:r})},queryKey:LI(t)}}function LI(e={}){const{onReplaced:t,...n}=e;return["waitForTransactionReceipt",OI(n)]}var BI=yt.createContext(void 0),jI=e=>{const t=yt.useContext(BI);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},DI=({client:e,children:t})=>(yt.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),Dh.jsx(BI.Provider,{value:e,children:t})),UI=yt.createContext(!1);UI.Provider;var FI=yt.createContext(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),$I=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function zI(e,t,n){var r,i,o,s,a;const c=yt.useContext(UI),l=yt.useContext(FI),u=jI(),d=u.defaultQueryOptions(e);null==(i=null==(r=u.getDefaultOptions().queries)?void 0:r._experimental_beforeQuery)||i.call(r,d),d._optimisticResults=c?"isRestoring":"optimistic",(e=>{if(e.suspense){const t=1e3,n=e=>"static"===e?e:Math.max(e??t,t),r=e.staleTime;e.staleTime="function"==typeof r?(...e)=>n(r(...e)):n(r),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,t))}})(d),((e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))})(d,l),(e=>{yt.useEffect(()=>{e.clearReset()},[e])})(l);const h=!u.getQueryCache().get(d.queryHash),[f]=yt.useState(()=>new t(u,d)),p=f.getOptimisticResult(d),m=!c&&!1!==e.subscribed;if(yt.useSyncExternalStore(yt.useCallback(e=>{const t=m?f.subscribe(iI.batchCalls(e)):RC;return f.updateResult(),t},[f,m]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),yt.useEffect(()=>{f.setOptions(d)},[d,f]),((e,t)=>(null==e?void 0:e.suspense)&&t.isPending)(d,p))throw $I(d,f,l);if((({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&void 0===e.data||eI(n,[e.error,r])))({result:p,errorResetBoundary:l,throwOnError:d.throwOnError,query:u.getQueryCache().get(d.queryHash),suspense:d.suspense}))throw p.error;if(null==(s=null==(o=u.getDefaultOptions().queries)?void 0:o._experimental_afterQuery)||s.call(o,d,p),d.experimental_prefetchInRender&&!TC&&((e,t)=>e.isLoading&&e.isFetching&&!t)(p,c)){const e=h?$I(d,f,l):null==(a=u.getQueryCache().get(d.queryHash))?void 0:a.promise;null==e||e.catch(RC).finally(()=>{f.updateResult()})}return d.notifyOnChangeProps?p:f.trackResult(p)}function HI(e,t){const n=jI(),[r]=yt.useState(()=>new CI(n,e));yt.useEffect(()=>{r.setOptions(e)},[r,e]);const i=yt.useSyncExternalStore(yt.useCallback(e=>r.subscribe(iI.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=yt.useCallback((e,t)=>{r.mutate(e,t).catch(RC)},[r]);if(i.error&&eI(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}function qI(e){const t=zI({...e,queryKeyHashFn:PI},mI);return t.queryKey=e.queryKey,t}function WI(e={}){const t=iC(e);return yt.useSyncExternalStore(e=>function(e,t){const{onChange:n}=t;return e._internal.chains.subscribe((e,t)=>{n(e,t)})}(t,{onChange:e}),()=>KS(t),()=>KS(t))}function KI(e={}){const t=iC(e);return yt.useSyncExternalStore(e=>function(e,t){const{onChange:n}=t;return e._internal.connectors.subscribe((e,t)=>{n(Object.values(e),t)})}(t,{onChange:e}),()=>VS(t),()=>VS(t))}function GI(e={}){const{mutation:t}=e,n=iC(e),r=TI(n),{mutate:i,mutateAsync:o,...s}=HI({...t,...r});return yt.useEffect(()=>n.subscribe(({status:e})=>e,(e,t)=>{"connected"===t&&"disconnected"===e&&s.reset()}),[n,s.reset]),{...s,connect:i,connectAsync:o,connectors:KI({config:n})}}function VI(e={}){const{mutation:t}=e,n=function(e){return{mutationFn:t=>YS(e,t),mutationKey:["sendTransaction"]}}(iC(e)),{mutate:r,mutateAsync:i,...o}=HI({...t,...n});return{...o,sendTransaction:r,sendTransactionAsync:i}}function ZI(e={}){const{hash:t,query:n={}}=e,r=iC(e),i=function(e={}){const t=iC(e);return yt.useSyncExternalStore(e=>function(e,t){const{onChange:n}=t;return e.subscribe(e=>e.chainId,n)}(t,{onChange:e}),()=>HS(t),()=>HS(t))}({config:r}),o=NI(r,{...e,chainId:e.chainId??i}),s=Boolean(t&&(n.enabled??!0));return qI({...n,...o,enabled:s})}function YI(e,t,n){const r=e[t.name];if("function"==typeof r)return r;const i=e[n];return"function"==typeof i?i:n=>t(e,n)}const JI="2.19.0";var QI,XI,eA=function(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)};let tA=class e extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return`@wagmi/core@${JI}`}constructor(t,n={}){var r;super(),QI.add(this),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:"WagmiCoreError"});const i=n.cause instanceof e?n.cause.details:(null==(r=n.cause)?void 0:r.message)?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath;this.message=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...o?[`Docs: ${this.docsBaseUrl}${o}.html${n.docsSlug?`#${n.docsSlug}`:""}`]:[],...i?[`Details: ${i}`]:[],`Version: ${this.version}`].join("\n"),n.cause&&(this.cause=n.cause),this.details=i,this.docsPath=o,this.metaMessages=n.metaMessages,this.shortMessage=t}walk(e){return eA(this,QI,"m",XI).call(this,this,e)}};QI=new WeakSet,XI=function e(t,n){return(null==n?void 0:n(t))?t:t.cause?eA(this,QI,"m",e).call(this,t.cause,n):t};class nA extends tA{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class rA extends tA{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class iA extends tA{constructor({address:e,connector:t}){super(`Account "${e}" not found for connector "${t.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class oA extends tA{constructor({connectionChainId:e,connectorChainId:t}){super(`The current chain of the connector (id: ${t}) does not match the connection's chain (id: ${e}).`,{metaMessages:[`Current Chain ID: ${t}`,`Expected Chain ID: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class sA extends tA{constructor({connector:e}){super(`Connector "${e.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function aA(e,t={}){let n;if(t.connector){const{connector:r}=t;if("reconnecting"===e.state.status&&!r.getAccounts&&!r.getChainId)throw new sA({connector:r});const[i,o]=await Promise.all([r.getAccounts().catch(e=>{if(null===t.account)return[];throw e}),r.getChainId()]);n={accounts:i,chainId:o,connector:r}}else n=e.state.connections.get(e.state.current);if(!n)throw new rA;const r=t.chainId??n.chainId,i=await n.connector.getChainId();if(i!==n.chainId)throw new oA({connectionChainId:n.chainId,connectorChainId:i});const o=n.connector;if(o.getClient)return o.getClient({chainId:r});const s=Og(t.account??n.accounts[0]);if(s&&(s.address=Hp(s.address)),t.account&&!n.accounts.some(e=>e.toLowerCase()===s.address.toLowerCase()))throw new iA({address:s.address,connector:o});const a=e.chains.find(e=>e.id===r),c=await n.connector.getProvider({chainId:r});return MS({account:s,chain:a,name:"Connector Client",transport:e=>jS(c)({...e,retryCount:0})})}async function cA(e,t={}){const{chainId:n,formatUnits:r="gwei",...i}=t,o=e.getClient({chainId:n}),s=YI(o,rE,"estimateFeesPerGas"),{gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l}=await s({...i,chain:o.chain}),u=function(e){return"number"==typeof e?e:"wei"===e?0:Math.abs(Fg[e])}(r);return{formatted:{gasPrice:a?$g(a,u):void 0,maxFeePerGas:c?$g(c,u):void 0,maxPriorityFeePerGas:l?$g(l,u):void 0},gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l}}function lA(e){const t=e.state.current,n=e.state.connections.get(t),r=null==n?void 0:n.accounts,i=null==r?void 0:r[0],o=e.chains.find(e=>e.id===(null==n?void 0:n.chainId)),s=e.state.status;switch(s){case"connected":return{address:i,addresses:r,chain:o,chainId:null==n?void 0:n.chainId,connector:null==n?void 0:n.connector,isConnected:!0,isConnecting:!1,isDisconnected:!1,isReconnecting:!1,status:s};case"reconnecting":return{address:i,addresses:r,chain:o,chainId:null==n?void 0:n.chainId,connector:null==n?void 0:n.connector,isConnected:!!i,isConnecting:!1,isDisconnected:!1,isReconnecting:!0,status:s};case"connecting":return{address:i,addresses:r,chain:o,chainId:null==n?void 0:n.chainId,connector:null==n?void 0:n.connector,isConnected:!1,isConnecting:!0,isDisconnected:!1,isReconnecting:!1,status:s};case"disconnected":return{address:void 0,addresses:void 0,chain:void 0,chainId:void 0,connector:void 0,isConnected:!1,isConnecting:!1,isDisconnected:!0,isReconnecting:!1,status:s}}}function uA(e,t){const{chainId:n,...r}=t;return YI(e.getClient({chainId:n}),fw,"readContract")(r)}class dA extends tA{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}async function hA(e,t){const{chainId:n,timeout:r=0,...i}=t,o=e.getClient({chainId:n}),s=YI(o,iS,"waitForTransactionReceipt"),a=await s({...i,timeout:r});if("reverted"===a.status){const e=YI(o,Ik,"getTransaction"),t=await e({hash:a.transactionHash}),n=YI(o,dw,"call"),r=await n({...t,data:t.input,gasPrice:"eip1559"!==t.type?t.gasPrice:void 0,maxFeePerGas:"eip1559"===t.type?t.maxFeePerGas:void 0,maxPriorityFeePerGas:"eip1559"===t.type?t.maxPriorityFeePerGas:void 0}),i=(null==r?void 0:r.data)?Hf(`0x${r.data.substring(138)}`):"unknown reason";throw new Error(i)}return{...a,chainId:o.chain.id}}async function fA(e,t){const{account:n,chainId:r,connector:i,...o}=t;let s;s="object"==typeof n&&"local"===(null==n?void 0:n.type)?e.getClient({chainId:r}):await aA(e,{account:n??void 0,chainId:r,connector:i});const a=YI(s,mS,"writeContract");return await a({...o,...n?{account:n}:{},chain:r?{id:r}:null})}function pA(e={}){const{shimDisconnect:t=!0,unstable_shimAsyncInject:n}=e;function r(){const t=e.target;if("function"==typeof t){const e=t();if(e)return e}return"object"==typeof t?t:"string"==typeof t?{...mA[t]??{id:t,name:`${t[0].toUpperCase()}${t.slice(1)}`,provider:`is${t[0].toUpperCase()}${t.slice(1)}`}}:{id:"injected",name:"Injected",provider:e=>null==e?void 0:e.ethereum}}let i,o,s,a;return c=>({get icon(){return r().icon},get id(){return r().id},get name(){return r().name},get supportsSimulation(){return!0},type:pA.type,async setup(){const t=await this.getProvider();(null==t?void 0:t.on)&&e.target&&(s||(s=this.onConnect.bind(this),t.on("connect",s)),i||(i=this.onAccountsChanged.bind(this),t.on("accountsChanged",i)))},async connect({chainId:n,isReconnecting:r}={}){var l,u,d,h,f,p;const m=await this.getProvider();if(!m)throw new dA;let g=[];if(r)g=await this.getAccounts().catch(()=>[]);else if(t)try{if(g=null==(h=null==(d=null==(u=null==(l=(await m.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0])?void 0:l.caveats)?void 0:u[0])?void 0:d.value)?void 0:h.map(e=>Hp(e)),g.length>0){g=await this.getAccounts()}}catch(y){const e=y;if(e.code===Uy.code)throw new Uy(e);if(e.code===Ny.code)throw e}try{if(!(null==g?void 0:g.length)&&!r){g=(await m.request({method:"eth_requestAccounts"})).map(e=>Hp(e))}s&&(m.removeListener("connect",s),s=void 0),i||(i=this.onAccountsChanged.bind(this),m.on("accountsChanged",i)),o||(o=this.onChainChanged.bind(this),m.on("chainChanged",o)),a||(a=this.onDisconnect.bind(this),m.on("disconnect",a));let l=await this.getChainId();if(n&&l!==n){const e=await this.switchChain({chainId:n}).catch(e=>{if(e.code===Uy.code)throw e;return{id:l}});l=(null==e?void 0:e.id)??l}return t&&await(null==(f=c.storage)?void 0:f.removeItem(`${this.id}.disconnected`)),e.target||await(null==(p=c.storage)?void 0:p.setItem("injected.connected",!0)),{accounts:g,chainId:l}}catch(y){const e=y;if(e.code===Uy.code)throw new Uy(e);if(e.code===Ny.code)throw new Ny(e);throw e}},async disconnect(){var n,r;const i=await this.getProvider();if(!i)throw new dA;o&&(i.removeListener("chainChanged",o),o=void 0),a&&(i.removeListener("disconnect",a),a=void 0),s||(s=this.onConnect.bind(this),i.on("connect",s));try{await g_(()=>i.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}t&&await(null==(n=c.storage)?void 0:n.setItem(`${this.id}.disconnected`,!0)),e.target||await(null==(r=c.storage)?void 0:r.removeItem("injected.connected"))},async getAccounts(){const e=await this.getProvider();if(!e)throw new dA;return(await e.request({method:"eth_accounts"})).map(e=>Hp(e))},async getChainId(){const e=await this.getProvider();if(!e)throw new dA;const t=await e.request({method:"eth_chainId"});return Number(t)},async getProvider(){if("undefined"==typeof window)return;let e;const t=r();return e="function"==typeof t.provider?t.provider(window):"string"==typeof t.provider?gA(window,t.provider):t.provider,e&&!e.removeListener&&("off"in e&&"function"==typeof e.off?e.removeListener=e.off:e.removeListener=()=>{}),e},async isAuthorized(){var r,i;try{if(t&&await(null==(r=c.storage)?void 0:r.getItem(`${this.id}.disconnected`)))return!1;if(!e.target){if(!(await(null==(i=c.storage)?void 0:i.getItem("injected.connected"))))return!1}if(!(await this.getProvider())){if(void 0!==n&&!1!==n){const e=async()=>{"undefined"!=typeof window&&window.removeEventListener("ethereum#initialized",e);return!!(await this.getProvider())},t="number"==typeof n?n:1e3;if(await Promise.race([..."undefined"!=typeof window?[new Promise(t=>window.addEventListener("ethereum#initialized",()=>t(e()),{once:!0}))]:[],new Promise(n=>setTimeout(()=>n(e()),t))]))return!0}throw new dA}return!!(await r_(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:e,chainId:t}){var n,r,i,o;const s=await this.getProvider();if(!s)throw new dA;const a=c.chains.find(e=>e.id===t);if(!a)throw new qy(new nA);const l=new Promise(e=>{const n=r=>{"chainId"in r&&r.chainId===t&&(c.emitter.off("change",n),e())};c.emitter.on("change",n)});try{return await Promise.all([s.request({method:"wallet_switchEthereumChain",params:[{chainId:Vf(t)}]}).then(async()=>{await this.getChainId()===t&&c.emitter.emit("change",{chainId:t})}),l]),a}catch(u){const h=u;if(4902===h.code||4902===(null==(r=null==(n=null==h?void 0:h.data)?void 0:n.originalError)?void 0:r.code))try{const{default:n,...r}=a.blockExplorers??{};let u,d;(null==e?void 0:e.blockExplorerUrls)?u=e.blockExplorerUrls:n&&(u=[n.url,...Object.values(r).map(e=>e.url)]),d=(null==(i=null==e?void 0:e.rpcUrls)?void 0:i.length)?e.rpcUrls:[(null==(o=a.rpcUrls.default)?void 0:o.http[0])??""];const h={blockExplorerUrls:u,chainId:Vf(t),chainName:(null==e?void 0:e.chainName)??a.name,iconUrls:null==e?void 0:e.iconUrls,nativeCurrency:(null==e?void 0:e.nativeCurrency)??a.nativeCurrency,rpcUrls:d};return await Promise.all([s.request({method:"wallet_addEthereumChain",params:[h]}).then(async()=>{if(await this.getChainId()!==t)throw new Uy(new Error("User rejected switch after adding network."));c.emitter.emit("change",{chainId:t})}),l]),a}catch(d){throw new Uy(d)}if(h.code===Uy.code)throw new Uy(h);throw new qy(h)}},async onAccountsChanged(e){var n;if(0===e.length)this.onDisconnect();else if(c.emitter.listenerCount("connect")){const e=(await this.getChainId()).toString();this.onConnect({chainId:e}),t&&await(null==(n=c.storage)?void 0:n.removeItem(`${this.id}.disconnected`))}else c.emitter.emit("change",{accounts:e.map(e=>Hp(e))})},onChainChanged(e){const t=Number(e);c.emitter.emit("change",{chainId:t})},async onConnect(e){const t=await this.getAccounts();if(0===t.length)return;const n=Number(e.chainId);c.emitter.emit("connect",{accounts:t,chainId:n});const r=await this.getProvider();r&&(s&&(r.removeListener("connect",s),s=void 0),i||(i=this.onAccountsChanged.bind(this),r.on("accountsChanged",i)),o||(o=this.onChainChanged.bind(this),r.on("chainChanged",o)),a||(a=this.onDisconnect.bind(this),r.on("disconnect",a)))},async onDisconnect(e){const t=await this.getProvider();e&&1013===e.code&&t&&(await this.getAccounts()).length||(c.emitter.emit("disconnect"),t&&(o&&(t.removeListener("chainChanged",o),o=void 0),a&&(t.removeListener("disconnect",a),a=void 0),s||(s=this.onConnect.bind(this),t.on("connect",s))))}})}pA.type="injected";const mA={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider:e=>(null==e?void 0:e.coinbaseWalletExtension)?e.coinbaseWalletExtension:gA(e,"isCoinbaseWallet")},metaMask:{id:"metaMask",name:"MetaMask",provider:e=>gA(e,e=>{if(!e.isMetaMask)return!1;if(e.isBraveWallet&&!e._events&&!e._state)return!1;const t=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPhantom","isPortal","isRabby","isTokenPocket","isTokenary","isUniswapWallet","isZerion"];for(const n of t)if(e[n])return!1;return!0})},phantom:{id:"phantom",name:"Phantom",provider(e){var t,n;return(null==(t=null==e?void 0:e.phantom)?void 0:t.ethereum)?null==(n=e.phantom)?void 0:n.ethereum:gA(e,"isPhantom")}}};function gA(e,t){function n(e){return"function"==typeof t?t(e):"string"!=typeof t||e[t]}const r=e.ethereum;return(null==r?void 0:r.providers)?r.providers.find(e=>n(e)):r&&n(r)?r:void 0}function yA(){const e=new Set;let t=[];const n=()=>function(e){if("undefined"==typeof window)return;const t=t=>e(t.detail);return window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new CustomEvent("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",t)}(n=>{t.some(({info:e})=>e.uuid===n.info.uuid)||(t=[...t,n],e.forEach(e=>e(t,{added:[n]})))});let r=n();return{_listeners:()=>e,clear(){e.forEach(e=>e([],{removed:[...t]})),t=[]},destroy(){this.clear(),e.clear(),null==r||r()},findProvider:({rdns:e})=>t.find(t=>t.info.rdns===e),getProviders:()=>t,reset(){this.clear(),null==r||r(),r=n()},subscribe:(n,{emitImmediately:r}={})=>(e.add(n),r&&n(t,{added:t}),()=>e.delete(n))}}const bA=e=>(t,n,r)=>{const i=r.subscribe;r.subscribe=(e,t,n)=>{let o=e;if(t){const i=(null==n?void 0:n.equalityFn)||Object.is;let s=e(r.getState());o=n=>{const r=e(n);if(!i(s,r)){const e=s;t(s=r,e)}},(null==n?void 0:n.fireImmediately)&&t(s,s)}return i(o)};return e(t,n,r)};function vA(e,t){let n;try{n=e()}catch(r){return}return{getItem:e=>{var t;const r=e=>null===e?null:JSON.parse(e,void 0),i=null!=(t=n.getItem(e))?t:null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,t)=>n.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>n.removeItem(e)}}const wA=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then:e=>wA(e)(n),catch(e){return this}}}catch(n){return{then(e){return this},catch:e=>wA(e)(n)}}},EA=(e,t)=>(n,r,i)=>{let o={storage:vA(()=>localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},s=!1;const a=new Set,c=new Set;let l=o.storage;if(!l)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...e)},r,i);const u=()=>{const e=o.partialize({...r()});return l.setItem(o.name,{state:e,version:o.version})},d=i.setState;i.setState=(e,t)=>{d(e,t),u()};const h=e((...e)=>{n(...e),u()},r,i);let f;i.getInitialState=()=>h;const p=()=>{var e,t;if(!l)return;s=!1,a.forEach(e=>{var t;return e(null!=(t=r())?t:h)});const i=(null==(t=o.onRehydrateStorage)?void 0:t.call(o,null!=(e=r())?e:h))||void 0;return wA(l.getItem.bind(l))(o.name).then(e=>{if(e){if("number"!=typeof e.version||e.version===o.version)return[!1,e.state];if(o.migrate)return[!0,o.migrate(e.state,e.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;const[i,s]=e;if(f=o.merge(s,null!=(t=r())?t:h),n(f,!0),i)return u()}).then(()=>{null==i||i(f,void 0),f=r(),s=!0,c.forEach(e=>e(f))}).catch(e=>{null==i||i(void 0,e)})};return i.persist={setOptions:e=>{o={...o,...e},e.storage&&(l=e.storage)},clearStorage:()=>{null==l||l.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>p(),hasHydrated:()=>s,onHydrate:e=>(a.add(e),()=>{a.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},o.skipHydration||p(),f||h},_A=e=>{let t;const n=new Set,r=(e,r)=>{const i="function"==typeof e?e(t):e;if(!Object.is(i,t)){const e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>s,subscribe:e=>(n.add(e),()=>n.delete(e))},s=t=e(r,i,o);return o},xA=e=>e?_A(e):_A;var kA={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i<o;i++)s[i]=r[i].fn;return s},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,i,o,s){var a=n?n+e:e;if(!this._events[a])return!1;var c,l,u=this._events[a],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,i),!0;case 5:return u.fn.call(u.context,t,r,i,o),!0;case 6:return u.fn.call(u.context,t,r,i,o,s),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var h,f=u.length;for(l=0;l<f;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];u[l].fn.apply(u[l].context,c)}}return!0},a.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,i){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||s(this,o);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||i&&!a[c].once||r&&a[c].context!==r)&&l.push(a[c]);l.length?this._events[o]=1===l.length?l[0]:l:s(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a}(kA);const SA=Re(kA.exports),CA=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:SA,default:SA},Symbol.toStringTag,{value:"Module"}));let IA=class{constructor(e){Object.defineProperty(this,"uid",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_emitter",{enumerable:!0,configurable:!0,writable:!0,value:new SA})}on(e,t){this._emitter.on(e,t)}once(e,t){this._emitter.once(e,t)}off(e,t){this._emitter.off(e,t)}emit(e,...t){const n=t[0];this._emitter.emit(e,{uid:this.uid,...n})}listenerCount(e){return this._emitter.listenerCount(e)}};function AA(e,t){return JSON.parse(e,(e,n)=>{let r=n;return"bigint"===(null==r?void 0:r.__type)&&(r=BigInt(r.value)),"Map"===(null==r?void 0:r.__type)&&(r=new Map(r.value)),(null==t?void 0:t(e,r))??r})}function PA(e,t){return e.slice(0,t).join(".")||"."}function MA(e,t){const{length:n}=e;for(let r=0;r<n;++r)if(e[r]===t)return r+1;return 0}function OA(e,t,n,r){return JSON.stringify(e,function(e,t){const n="function"==typeof e,r="function"==typeof t,i=[],o=[];return function(s,a){if("object"==typeof a)if(i.length){const e=MA(i,this);0===e?i[i.length]=this:(i.splice(e),o.splice(e)),o[o.length]=s;const n=MA(i,a);if(0!==n)return r?t.call(this,s,a,PA(o,n)):`[ref=${PA(o,n)}]`}else i[0]=a,o[0]=s;return n?e.call(this,s,a):a}}((e,n)=>{let r=n;return"bigint"==typeof r&&(r={__type:"bigint",value:n.toString()}),r instanceof Map&&(r={__type:"Map",value:Array.from(n.entries())}),(null==t?void 0:t(e,r))??r},r),n??void 0)}function TA(e){const{deserialize:t=AA,key:n="wagmi",serialize:r=OA,storage:i=RA}=e;function o(e){return e instanceof Promise?e.then(e=>e).catch(()=>null):e}return{...i,key:n,async getItem(e,r){const s=i.getItem(`${n}.${e}`),a=await o(s);return a?t(a)??null:r??null},async setItem(e,t){const s=`${n}.${e}`;null===t?await o(i.removeItem(s)):await o(i.setItem(s,r(t)))},async removeItem(e){await o(i.removeItem(`${n}.${e}`))}}}const RA={getItem:()=>null,setItem:()=>{},removeItem:()=>{}};function NA(){const e="undefined"!=typeof window&&window.localStorage?window.localStorage:RA;return{getItem:t=>e.getItem(t),removeItem(t){e.removeItem(t)},setItem(t,n){try{e.setItem(t,n)}catch{}}}}let LA,BA=256;function jA(e,t){return DS(e,t)}function DA(e){var t,n,r;const{chain:i}=e,o=i.rpcUrls.default.http[0];if(!e.transports)return[o];const s=null==(n=null==(t=e.transports)?void 0:t[i.id])?void 0:n.call(t,{chain:i});return((null==(r=null==s?void 0:s.value)?void 0:r.transports)||[s]).map(({value:e})=>(null==e?void 0:e.url)||o)}const UA={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};function FA(e,t){return function(e){return"deposit"===e.type||void 0!==e.sourceHash}(e)?function(e){!function(e){const{from:t,to:n}=e;if(t&&!Fp(t))throw new Pf({address:t});if(n&&!Fp(n))throw new Pf({address:n})}(e);const{sourceHash:t,data:n,from:r,gas:i,isSystemTx:o,mint:s,to:a,value:c}=e;return im(["0x7e",Uw([t,r,a??"0x",s?Wf(s):"0x",c?Wf(c):"0x",i?Wf(i):"0x",o?"0x1":"0x",n??"0x"])])}(e):XE(e,t)}const $A={blockTime:2e3,contracts:UA,formatters:{block:Xw({format(e){var t;return{transactions:null==(t=e.transactions)?void 0:t.map(e=>{if("string"==typeof e)return e;const t=Yw(e);return"0x7e"===t.typeHex&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?$f(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}),stateRoot:e.stateRoot}}}),transaction:Jw({format(e){const t={};return"0x7e"===e.type&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?$f(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:p_({format:e=>({l1GasPrice:e.l1GasPrice?$f(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?$f(e.l1GasUsed):null,l1Fee:e.l1Fee?$f(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null})})},serializers:{transaction:FA}},zA=d_({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:250,rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),HA=d_({id:43114,name:"Avalanche",blockTime:1700,nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{default:{name:"SnowTrace",url:"https://snowtrace.io",apiUrl:"https://api.snowtrace.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:11907934}}}),qA=1,WA=d_({...$A,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...$A.contracts,disputeGameFactory:{[qA]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[qA]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[qA]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[qA]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:1}),KA=d_({id:56,name:"BNB Smart Chain",blockTime:750,nativeCurrency:{decimals:18,name:"BNB",symbol:"BNB"},rpcUrls:{default:{http:["https://56.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com",apiUrl:"https://api.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15921452}}}),GA={estimateFeesPerGas:async e=>{var t;if(!(null==(t=e.request)?void 0:t.feeCurrency))return null;const[n,r]=await Promise.all([VA(e.client,e.request.feeCurrency),ZA(e.client,e.request.feeCurrency)]);return{maxFeePerGas:e.multiply(n-r)+r,maxPriorityFeePerGas:r}}};async function VA(e,t){const n=await e.request({method:"eth_gasPrice",params:[t]});return BigInt(n)}async function ZA(e,t){const n=await e.request({method:"eth_maxPriorityFeePerGas",params:[t]});return BigInt(n)}function YA(e){return 0===e||0n===e||null==e||"0"===e||""===e||"string"==typeof e&&("0x"===Uf(e).toLowerCase()||"0x00"===Uf(e).toLowerCase())}function JA(e){return!YA(e)}function QA(e){return"cip64"===e.type||function(e){return void 0!==e.maxFeePerGas&&void 0!==e.maxPriorityFeePerGas}(e)&&JA(e.feeCurrency)}const XA={transaction:function(e,t){return QA(e)?function(e,t){!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:i,to:o,feeCurrency:s}=e;if(t<=0)throw new Pg({chainId:t});if(o&&!Fp(o))throw new Pf({address:o});if(r)throw new tf("`gasPrice` is not a valid CIP-64 Transaction attribute.");if(JA(i)&&i>eP)throw new Uv({maxFeePerGas:i});if(JA(n)&&JA(i)&&n>i)throw new Vv({maxFeePerGas:i,maxPriorityFeePerGas:n});if(JA(s)&&!Fp(s))throw new tf("`feeCurrency` MUST be a token address for CIP-64 transactions.");if(YA(s))throw new tf("`feeCurrency` must be provided for CIP-64 transactions.")}(e);const{chainId:n,gas:r,nonce:i,to:o,value:s,maxFeePerGas:a,maxPriorityFeePerGas:c,accessList:l,feeCurrency:u,data:d}=e,h=[Wf(n),i?Wf(i):"0x",c?Wf(c):"0x",a?Wf(a):"0x",r?Wf(r):"0x",o??"0x",s?Wf(s):"0x",d??"0x",QE(l),u,...e_(e,t)];return im(["0x7b",Uw(h)])}(e,t):FA(e,t)}};const eP=lw;const tP=d_({...{blockTime:1e3,contracts:UA,formatters:{block:Xw({format(e){var t;return{transactions:null==(t=e.transactions)?void 0:t.map(e=>{if("string"==typeof e)return e;return{...Yw(e),...e.gatewayFee?{gatewayFee:$f(e.gatewayFee),gatewayFeeRecipient:e.gatewayFeeRecipient}:{},feeCurrency:e.feeCurrency}})}}}),transaction:Jw({format(e){if("0x7e"===e.type)return{isSystemTx:e.isSystemTx,mint:e.mint?$f(e.mint):void 0,sourceHash:e.sourceHash,type:"deposit"};const t={feeCurrency:e.feeCurrency};return"0x7b"===e.type?t.type="cip64":("0x7c"===e.type&&(t.type="cip42"),t.gatewayFee=e.gatewayFee?$f(e.gatewayFee):null,t.gatewayFeeRecipient=e.gatewayFeeRecipient),t}}),transactionRequest:nw({format(e){const t={};return e.feeCurrency&&(t.feeCurrency=e.feeCurrency),QA(e)&&(t.type="0x7b"),t}})},serializers:XA,fees:GA},id:42220,name:"Celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://celoscan.io",apiUrl:"https://api.celoscan.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:13112599}},testnet:!1}),nP=d_({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),rP=1,iP=d_({...$A,id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimism Explorer",url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io/api"}},contracts:{...$A.contracts,disputeGameFactory:{[rP]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[rP]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[rP]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[rP]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId:1}),oP=d_({id:137,name:"Polygon",blockTime:2e3,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}});function sP(e={}){return"3"===e.version||e.headlessMode?function(e){const t=!1;let n,r,i,o,s;return a=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",rdns:"com.coinbase.wallet",type:sP.type,async connect({chainId:e}={}){try{const t=await this.getProvider(),n=(await t.request({method:"eth_requestAccounts"})).map(e=>Hp(e));i||(i=this.onAccountsChanged.bind(this),t.on("accountsChanged",i)),o||(o=this.onChainChanged.bind(this),t.on("chainChanged",o)),s||(s=this.onDisconnect.bind(this),t.on("disconnect",s));let r=await this.getChainId();if(e&&r!==e){const t=await this.switchChain({chainId:e}).catch(e=>{if(e.code===Uy.code)throw e;return{id:r}});r=(null==t?void 0:t.id)??r}return{accounts:n,chainId:r}}catch(t){if(/(user closed modal|accounts received is empty|user denied account)/i.test(t.message))throw new Uy(t);throw t}},async disconnect(){const e=await this.getProvider();i&&(e.removeListener("accountsChanged",i),i=void 0),o&&(e.removeListener("chainChanged",o),o=void 0),s&&(e.removeListener("disconnect",s),s=void 0),e.disconnect(),e.close()},async getAccounts(){const e=await this.getProvider();return(await e.request({method:"eth_accounts"})).map(e=>Hp(e))},async getChainId(){const e=await this.getProvider(),t=await e.request({method:"eth_chainId"});return Number(t)},async getProvider(){var i;if(!r){const o=await(async()=>{const{default:e}=await Promise.resolve().then(()=>C4);return"function"!=typeof e&&"function"==typeof e.default?e.default:e})();n=new o({...e,reloadOnDisconnect:t});const s=null==(i=n.walletExtension)?void 0:i.getChainId(),c=a.chains.find(t=>e.chainId?t.id===e.chainId:t.id===s)||a.chains[0],l=e.chainId||(null==c?void 0:c.id),u=e.jsonRpcUrl||(null==c?void 0:c.rpcUrls.default.http[0]);r=n.makeWeb3Provider(u,l)}return r},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:e,chainId:t}){var n,r,i,o;const s=a.chains.find(e=>e.id===t);if(!s)throw new qy(new nA);const c=await this.getProvider();try{return await c.request({method:"wallet_switchEthereumChain",params:[{chainId:Vf(s.id)}]}),s}catch(l){if(4902===l.code)try{let a,l;a=(null==e?void 0:e.blockExplorerUrls)?e.blockExplorerUrls:(null==(n=s.blockExplorers)?void 0:n.default.url)?[null==(r=s.blockExplorers)?void 0:r.default.url]:[],l=(null==(i=null==e?void 0:e.rpcUrls)?void 0:i.length)?e.rpcUrls:[(null==(o=s.rpcUrls.default)?void 0:o.http[0])??""];const u={blockExplorerUrls:a,chainId:Vf(t),chainName:(null==e?void 0:e.chainName)??s.name,iconUrls:null==e?void 0:e.iconUrls,nativeCurrency:(null==e?void 0:e.nativeCurrency)??s.nativeCurrency,rpcUrls:l};return await c.request({method:"wallet_addEthereumChain",params:[u]}),s}catch(u){throw new Uy(u)}throw new qy(l)}},onAccountsChanged(e){0===e.length?this.onDisconnect():a.emitter.emit("change",{accounts:e.map(e=>Hp(e))})},onChainChanged(e){const t=Number(e);a.emitter.emit("change",{chainId:t})},async onDisconnect(e){a.emitter.emit("disconnect");const t=await this.getProvider();i&&(t.removeListener("accountsChanged",i),i=void 0),o&&(t.removeListener("chainChanged",o),o=void 0),s&&(t.removeListener("disconnect",s),s=void 0)}})}(e):function(e){let t,n,r,i;return o=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",rdns:"com.coinbase.wallet",type:sP.type,async connect({chainId:e,...t}={}){try{const o=await this.getProvider(),s=(await o.request({method:"eth_requestAccounts",params:"instantOnboarding"in t&&t.instantOnboarding?[{onboarding:"instant"}]:[]})).map(e=>Hp(e));n||(n=this.onAccountsChanged.bind(this),o.on("accountsChanged",n)),r||(r=this.onChainChanged.bind(this),o.on("chainChanged",r)),i||(i=this.onDisconnect.bind(this),o.on("disconnect",i));let a=await this.getChainId();if(e&&a!==e){const t=await this.switchChain({chainId:e}).catch(e=>{if(e.code===Uy.code)throw e;return{id:a}});a=(null==t?void 0:t.id)??a}return{accounts:s,chainId:a}}catch(o){if(/(user closed modal|accounts received is empty|user denied account|request rejected)/i.test(o.message))throw new Uy(o);throw o}},async disconnect(){var e;const t=await this.getProvider();n&&(t.removeListener("accountsChanged",n),n=void 0),r&&(t.removeListener("chainChanged",r),r=void 0),i&&(t.removeListener("disconnect",i),i=void 0),t.disconnect(),null==(e=t.close)||e.call(t)},async getAccounts(){const e=await this.getProvider();return(await e.request({method:"eth_accounts"})).map(e=>Hp(e))},async getChainId(){const e=await this.getProvider(),t=await e.request({method:"eth_chainId"});return Number(t)},async getProvider(){if(!t){const r="string"==typeof e.preference?{options:e.preference}:{...e.preference,options:(null==(n=e.preference)?void 0:n.options)??"all"},{createCoinbaseWalletSDK:i}=await Promise.resolve().then(()=>cH),s=i({...e,appChainIds:o.chains.map(e=>e.id),preference:r});t=s.getProvider()}var n;return t},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:e,chainId:t}){var n,r,i,s;const a=o.chains.find(e=>e.id===t);if(!a)throw new qy(new nA);const c=await this.getProvider();try{return await c.request({method:"wallet_switchEthereumChain",params:[{chainId:Vf(a.id)}]}),a}catch(l){if(4902===l.code)try{let o,l;o=(null==e?void 0:e.blockExplorerUrls)?e.blockExplorerUrls:(null==(n=a.blockExplorers)?void 0:n.default.url)?[null==(r=a.blockExplorers)?void 0:r.default.url]:[],l=(null==(i=null==e?void 0:e.rpcUrls)?void 0:i.length)?e.rpcUrls:[(null==(s=a.rpcUrls.default)?void 0:s.http[0])??""];const u={blockExplorerUrls:o,chainId:Vf(t),chainName:(null==e?void 0:e.chainName)??a.name,iconUrls:null==e?void 0:e.iconUrls,nativeCurrency:(null==e?void 0:e.nativeCurrency)??a.nativeCurrency,rpcUrls:l};return await c.request({method:"wallet_addEthereumChain",params:[u]}),a}catch(u){throw new Uy(u)}throw new qy(l)}},onAccountsChanged(e){0===e.length?this.onDisconnect():o.emitter.emit("change",{accounts:e.map(e=>Hp(e))})},onChainChanged(e){const t=Number(e);o.emitter.emit("change",{chainId:t})},async onDisconnect(e){o.emitter.emit("disconnect");const t=await this.getProvider();n&&(t.removeListener("accountsChanged",n),n=void 0),r&&(t.removeListener("chainChanged",r),r=void 0),i&&(t.removeListener("disconnect",i),i=void 0)}})}(e)}function aP(e={}){let t,n,r,i,o,s,a,c;return l=>({id:"metaMaskSDK",name:"MetaMask",rdns:["io.metamask","io.metamask.mobile"],type:aP.type,async setup(){const e=await this.getProvider();(null==e?void 0:e.on)&&(s||(s=this.onConnect.bind(this),e.on("connect",s)),i||(i=this.onAccountsChanged.bind(this),e.on("accountsChanged",i)))},async connect({chainId:n,isReconnecting:r}={}){const l=await this.getProvider();a||(a=this.onDisplayUri,l.on("display_uri",a));let u=[];r&&(u=await this.getAccounts().catch(()=>[]));try{let r,d;if(!(null==u?void 0:u.length))if(e.connectAndSign||e.connectWith)e.connectAndSign?r=await t.connectAndSign({msg:e.connectAndSign}):e.connectWith&&(d=await t.connectWith({method:e.connectWith.method,params:e.connectWith.params})),u=await this.getAccounts();else{u=(await t.connect()).map(e=>Hp(e))}let h=await this.getChainId();if(n&&h!==n){const e=await this.switchChain({chainId:n}).catch(e=>{if(e.code===Uy.code)throw e;return{id:h}});h=(null==e?void 0:e.id)??h}return a&&(l.removeListener("display_uri",a),a=void 0),r?l.emit("connectAndSign",{accounts:u,chainId:h,signResponse:r}):d&&l.emit("connectWith",{accounts:u,chainId:h,connectWithResponse:d}),s&&(l.removeListener("connect",s),s=void 0),i||(i=this.onAccountsChanged.bind(this),l.on("accountsChanged",i)),o||(o=this.onChainChanged.bind(this),l.on("chainChanged",o)),c||(c=this.onDisconnect.bind(this),l.on("disconnect",c)),{accounts:u,chainId:h}}catch(d){const e=d;if(e.code===Uy.code)throw new Uy(e);if(e.code===Ny.code)throw new Ny(e);throw e}},async disconnect(){const e=await this.getProvider();o&&(e.removeListener("chainChanged",o),o=void 0),c&&(e.removeListener("disconnect",c),c=void 0),s||(s=this.onConnect.bind(this),e.on("connect",s)),await t.terminate()},async getAccounts(){const e=await this.getProvider();return(await e.request({method:"eth_accounts"})).map(e=>Hp(e))},async getChainId(){const e=await this.getProvider(),t=e.getChainId()||await(null==e?void 0:e.request({method:"eth_chainId"}));return Number(t)},getProvider:async()=>(n||(r||(r=async function(){var n,r,i,o,s;const a=await(async()=>{const{default:e}=await Promise.resolve().then(()=>Dfe);return"function"!=typeof e&&"function"==typeof e.default?e.default:e})(),c={};for(const e of l.chains)c[Vf(e.id)]=null==(n=DA({chain:e,transports:l.transports}))?void 0:n[0];t=new a({_source:"wagmi",forceDeleteProvider:!1,forceInjectProvider:!1,injectProvider:!1,...e,readonlyRPCMap:c,dappMetadata:{...e.dappMetadata,name:(null==(r=e.dappMetadata)?void 0:r.name)?null==(i=e.dappMetadata)?void 0:i.name:"wagmi",url:(null==(o=e.dappMetadata)?void 0:o.url)?null==(s=e.dappMetadata)?void 0:s.url:"undefined"!=typeof window?window.location.origin:"https://wagmi.sh"},useDeeplink:e.useDeeplink??!0});const u=await t.init(),d=(null==u?void 0:u.activeProvider)?u.activeProvider:t.getProvider();if(!d)throw new dA;return d}()),n=await r),n),async isAuthorized(){try{const e=200;return!!(await r_(()=>g_(()=>this.getAccounts(),{timeout:e}),{delay:e+1,retryCount:3})).length}catch{return!1}},async switchChain({addEthereumChainParameter:e,chainId:t}){var n,r;const i=await this.getProvider(),o=l.chains.find(e=>e.id===t);if(!o)throw new qy(new nA);try{return await i.request({method:"wallet_switchEthereumChain",params:[{chainId:Vf(t)}]}),await c(),await u(t),o}catch(d){const l=d;if(l.code===Uy.code)throw new Uy(l);if(4902===l.code||4902===(null==(r=null==(n=null==l?void 0:l.data)?void 0:n.originalError)?void 0:r.code))try{return await i.request({method:"wallet_addEthereumChain",params:[{blockExplorerUrls:(()=>{const{default:t,...n}=o.blockExplorers??{};return(null==e?void 0:e.blockExplorerUrls)?e.blockExplorerUrls:t?[t.url,...Object.values(n).map(e=>e.url)]:void 0})(),chainId:Vf(t),chainName:(null==e?void 0:e.chainName)??o.name,iconUrls:null==e?void 0:e.iconUrls,nativeCurrency:(null==e?void 0:e.nativeCurrency)??o.nativeCurrency,rpcUrls:(null==(s=null==e?void 0:e.rpcUrls)?void 0:s.length)?e.rpcUrls:[(null==(a=o.rpcUrls.default)?void 0:a.http[0])??""]}]}),await c(),await u(t),o}catch(h){const e=h;if(e.code===Uy.code)throw new Uy(e);throw new qy(e)}throw new qy(l)}var s,a;async function c(){await r_(async()=>{const e=zf(await i.request({method:"eth_chainId"}));if(e!==t)throw new Error("User rejected switch after adding network.");return e},{delay:50,retryCount:20})}async function u(e){await new Promise(t=>{const n=r=>{"chainId"in r&&r.chainId===e&&(l.emitter.off("change",n),t())};l.emitter.on("change",n),l.emitter.emit("change",{chainId:e})})}},async onAccountsChanged(e){if(0===e.length){if(!t.isExtensionActive())return;this.onDisconnect()}else if(l.emitter.listenerCount("connect")){const e=(await this.getChainId()).toString();this.onConnect({chainId:e})}else l.emitter.emit("change",{accounts:e.map(e=>Hp(e))})},onChainChanged(e){const t=Number(e);l.emitter.emit("change",{chainId:t})},async onConnect(e){const t=await this.getAccounts();if(0===t.length)return;const n=Number(e.chainId);l.emitter.emit("connect",{accounts:t,chainId:n});const r=await this.getProvider();s&&(r.removeListener("connect",s),s=void 0),i||(i=this.onAccountsChanged.bind(this),r.on("accountsChanged",i)),o||(o=this.onChainChanged.bind(this),r.on("chainChanged",o)),c||(c=this.onDisconnect.bind(this),r.on("disconnect",c))},async onDisconnect(e){const t=await this.getProvider();e&&1013===e.code&&t&&(await this.getAccounts()).length||(l.emitter.emit("disconnect"),o&&(t.removeListener("chainChanged",o),o=void 0),c&&(t.removeListener("disconnect",c),c=void 0),s||(s=this.onConnect.bind(this),t.on("connect",s)))},onDisplayUri(e){l.emitter.emit("message",{type:"display_uri",data:e})}})}sP.type="coinbaseWallet",aP.type="metaMask";const cP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABxCAYAAAAj+QZ8AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAzrSURBVHgB7V3dcRs5Em4MtXWPq41gZ1+v7mwrgh3rArAUgagITNcFYDmAK9ERSBuBfQGsxY3Aku26V/MiOO7j1nqAQwMgRQ4xQONnhqOfr8q2TA4H1HzoRqO70c1g4JhUH/dhNKqgrhfT2cEMOoQaqxidyx+P5J8F8PpYjnkNPYLBgPGq+vxSFOJM/rhvXpp39ZAkGaUk40r+WK69jKT8JMdbQE8oYKDAByTJmMItGQj10OR7zyA3itFr2CQD1NhFMYYeMVhCHA8C1co7pV4yYXL4aSz/GVvfFFBBjxguIcCeOt4szYxOhiG2/V7M+T2yY7iEMOaTgIl8mBWkoth7Cduqah2u97JjuIQIUXqvYWlSohZyUEaDE/88/M+P0BMGrLIIYFAZ/R+HTGovJ+42IRqvYxZ485kKBob7QEgZZZoWoyMgrg//+vDX/0JPuA+ESLCXEApG/kxvm0LEkK2secDVZYjFpRZzIWibSyHm0COGSwjnYWoiyOIqjujXskcJUWCBqgItLuriPipOgAombqBH7EEGTKovUvz/xIdxnc8Rx8IdiHpxn7ouCVJXGnPIBD1h9p5BIU6kS6ZkBXt//uvf365fk0SIcvJJv5LUL6Wcdvq1w09z+c9MeknfSHLmEAteX8t7B30EBHsBHkLkPSsI+h482bOs3froERAT+UdLMcPlSch91M0P0w9Pz5bXpqksRcaW6Yj/H8v3vkpyLvRuOBzGxd6F2voZwpBEyKT6XMln8dF4BCzfjW2oz2hCjAu89FxmiPkctyNmMWprdOS5J11dSQsrVgXjxJAT8lyqp2aMpTnGxv1TJCRgdyzO5Jf7Giwtgv8GwWhfH5T0hK0fUQu6UeUf8UfvxY1Jl0LIHMJQBksL5zMIhXCqpLDAFpNrYSAwymnIKEkf4PUv6/+NJsQs2BHirKTlHUVaTAw9cB1xqaQijJDACYGTzUQ5adAqcbb+UuI+RPwCcTgyodjSe6UQ/4ZAtLrLi4DYhn5Y5DVscvjlguLK3xyDvWm+lEYI5+8hHiWJFMEvIRA1/3ZgfYMV9OgfYzPKZWrxfv5JLtx8DCFQhD+5bL6cRIgSN+IXb4GXlCi1VbQEt0IWdA40yRztXaG5DaEQ/Nj2crrrpP72BtJAkJRg1bhlAZr9Cc0y1LPXK/1KTYVZbcsB3rapw2RC1AwW0WvJEktS7A8sWDWyH61jkD/ul3q1xwhVUwj0HnN+1vZ2Huei4Ghvp/qwSumxfWd7I4NqRND3TdLt43rbmO7+PYYNgj93bTazEKIG4PUppELHyM+t76WrRhoEzFw+uMk/Ph0FW1O3N3/l8+9lc7/Lgd6jboR0TF5VNyeW++eQEj8EtKpf7SmGC4i78VvpRPTuUfLGQ1A3CpHkjEOIgk2ti3zXUtJiiq6gc38DXEar+15LMkgqLishSnWhOZce9tyX68mF5f4pUjL3XmHZqC1hVGkJocBnIdcN6uXZI4ZKR2obO22Rx/VE6esG6m+n/nsLW/jX/Rnp5GuTDpP7Fb6IGzJCPMadhHCVjc1rnBVppAg4b5rCinBeHzs/x7fd9uqhuNz59TfrPY3qDA8f3JIxD/lYZzH1TKRgztXEcu8ZWiztH6vtD17wlt23w/qxH1NwI5IMNRx0iDyk2POntMUiLDpftIeOOZ9ufxd5fYv1Y6RjDCFIIAPRywkq9YuxQvp8WAkxkKS2HWdT+VgFpvWw7zG24Dv2Jq8/kv6nl3rH7L4eQ9AQQojcw4BQJ7yiJ2AvhCAMKe+CQqgrKBs+bmecAIxyAlldKUk7g0R4s070ovpdadJ8DL6TM+DPoHizEeGDyeHNmZwHYYukiDA3E0HMGUAsD4fOIAP2LF/EnKtjGAqtQG2EOCzTfDT0/+UM0jFhte8QN+rnur526U+cRXIMuZ8oLgJUWG/nM9bg3wBqFXWalO7UwEplbeYORexGN+6qSLp26Wijws7ktf4sQvQvXT0hb65ywOw92twk0oSG0+mvfhd9KBQhLUeCc2EOjsQ5EjFc/vIul0YHUBOUFR8bUrxQ/jpprXV1VFoTcvgJ3d5H0D0uncRgEvSoeCGlqzIvL1xmaddYfScFft114QIEM9LxFfrFZXKq6T0FbgzT1os4YEbjR2lx9W7KDh3M1Pf4H+wKHVgqdxmFdpknx8TjgRkb1BytBwDtyxIq6N6J1UBEKd0Z7+ARmhDj0k53l6dAiGd6F/+wsfL2rjyzPR9y3ARhk3jPseF+V6RguHF3a0rZZxmLIaLV26uca9o7W0Kf4PUP0x4Lhg0NXve78ukI8boXYnbgsxoayPEQRQz6m27dGnmRGGm7LwgOUK38OwxO4oJNFjxuDldIihiazdwzGT+p1NkLnQlOdcUsVFY75+/7cNrdFWQP4Zq0nRI0MeiW2SSIq4yQxaM0POJOoCsJ0VJSjMqtC3g9x5j8dPa35Bzg+4hkQnSlAv7MxOCpiQGIOeQowXHPEEWIJkFgXZEx5ImnPAasDOj7kJxJEHagg/PgIe/SEbS8rGYlm26Aaw5meRzDA4ZTQizF8LvHA/dlWSVEp+aMLgTryE3iwKj4y/ew22DZTmHJXFQLNkbvdpH8ADX/43d4wNiIh7yqvpyY+k47IUPi8qEv6itCMP4hivC6IlnhOR/+EKAIMalAO04y8J/hfgjQEhJQdrsb7C5ddGjQi7oOPMFuICXjkYwVstTtjYKOEGJQarY6FKR8YsvSSgx37rOHpsZM9vvNNKqgfRxWKf2mqDCOW0G7ZTedfnjyCnYAU8zyRE6Mt31NDL2GpFWGo0IdLcA2dMCLmar8o01sXL9cZvaktSBN1xjt4bgTU4P4nFATOBnLzMWZ/YhxFqwRIc1q9FchEWFV2CZ9PIwtbJapnaiM/Rx9rxy4zVzUJ0hPM2UuGrVUP5fqRpXSZrB3Ysqnxh0M6rmfoML2uXZdaC22MDQBVueiOV+H8Y4K/Lv2hfkjg03YSYDPmuXrjMqZQBouJbnpNbkCoc612/Zo6oDrt+Pca4s/UW4zaWEdc/zLWexL9bHdu4qrS7gFJyE4VojbBR2o1IfpMHqyt4LtrHBABwdJrYTcdmhQ43iDXJbrvQ+05QDoGvLtpTqpddLNqV7xe8s46x0arMVqNrB1vf+w0KoOWGtYgJ3nWleyE2LUlK2NRRpsprmNdKHWvrbvZkvCsBZLa0JLkcsSxRLq6aTklxAsZ5RnzbiFpUa6+eXLrWtdSeGjkf29tmJpDZgKRI66kumkZCUkqXyqC42yfqZlats47VahcL5H2vipIjjOMoOq2UBkocyMhFD7ykahGSfRRcVaH177oR9nf13/+rMEVp9zF/scx5KST0K0Ps+PRh3dqKJiZLCXJCmhFfscx6ivLIS06vMcEFbp6Ar7VCkxxT49ZzLD15RkQjz6PA1aOmabY/mlo713LaV7KE1KEF2Qki4hHn2eBNEoX95Pu+39EL8ZlRRbtW4bkggxMzbOWeiFtZhl5f+YY7FVmfeUodkLCACFFFOt27sdSO1jWEEX0oH7jkb9QrNPKP0fdvaunQMFuh9iBQEgkLJP8QqkEcI6OOjfVprbsQPfgLt3Ldn5qI7pBSKAlNZJnEZI7h25uidvO/xJU428fdNmnI5zICEupL1GSpvqbO2Tgkjt9JlXXalSftsHQI36II7lXSeorvL92OjgihSA99YLVJ8Uu+XVU6dPAlx1FQty//OFNzbBxW9ARYTaWgKlUYYLjtsdkuLMRng8IUWLoy4UusL0gbPIJSt+Btq9CA87oPuzYLRxHdDGSUudep1EsYF4QqgmpAuqYICq3tD6kIL619JapdIJoXWf9kJ5iTHJo7nYW0pSpaislLDlQkXZrp74S2mMlGlNA6FVqmlb4b1uDVkMl7XFvlFpadMzkNILN/QX0xDq5O0BOeRJlY6QVqkhXaiLIgshCCRlevV0DJvZPUjGaow0sxe73VDThjQRz0lSsQ7q+hEyOYKaDjN6u1Yi5GJ/KScFtoc9bVqWGc6pOytTL1Lrmci4AlZM9etxDseU7pzB98WGXldPD6AnJCdbm9k+lsScgSpEY2qb6JomQR0Umghqlwr1DEKAXagpnoY+6oStIVv2uyFmDnlB1d/hR+GwCzUbUVw/+6E5XynotOVROogLKrWz8yZQgkkP2ZwM7gXDJoTSkJ7Y2bkJPeNpxT5r/sdP0BMGLiHMX6FUQHy7V+oxjFxeCcpQMGQwRljQ48+29NZfNwADlxAvLpOzz/vqQk3E3SYkw7n2oUnJsAkRwmEFiXzn/gYkJQOXEGFP51Eue07zhREwJCkZupVldxYWLH/VB1cXat5fdaJhE8JriwUl3nTRrk4T3Bbdq1NCDUEYNCFm87Z8SAtzUukMOoK94bHo7Yw6orMjbTmxDOD05U/SBz2l2wab3ncgjS78H0eagrHjdQciAAAAAElFTkSuQmCC",lP="YWG990wOlIikc1tU7-WWTepfU8d1f4dp",uP="qtIcCe_-8t4rIWktnWJm0",dP=function(e){const{multiInjectedProviderDiscovery:t=!0,storage:n=TA({storage:NA()}),syncConnectedChain:r=!0,ssr:i=!1,...o}=e,s="undefined"!=typeof window&&t?yA():void 0,a=xA(()=>o.chains),c=xA(()=>{const e=[],t=new Set;for(const n of o.connectors??[]){const r=l(n);if(e.push(r),!i&&r.rdns){const e="string"==typeof r.rdns?[r.rdns]:r.rdns;for(const n of e)t.add(n)}}if(!i&&s){const n=s.getProviders();for(const r of n)t.has(r.info.rdns)||e.push(l(u(r)))}return e});function l(e){var t;const r=(i=function(e=11){if(!LA||BA+e>512){LA="",BA=0;for(let e=0;e<256;e++)LA+=(256+256*Math.random()|0).toString(16).substring(1)}return LA.substring(BA,BA+++e)}(),new IA(i));var i;const s={...e({emitter:r,chains:a.getState(),storage:n,transports:o.transports}),emitter:r,uid:r.uid};return r.on("connect",b),null==(t=s.setup)||t.call(s),s}function u(e){const{info:t}=e,n=e.provider;return pA({target:{...t,id:t.rdns,provider:n}})}const d=new Map;function h(){return{chainId:a.getState()[0].id,connections:new Map,current:null,status:"disconnected"}}let f;const p="0.0.0-canary-";f=JI.startsWith(p)?Number.parseInt(JI.replace(p,"")):Number.parseInt(JI.split(".")[0]??"0");const m=xA(bA(n?EA(h,{migrate(e,t){if(t===f)return e;const n=h(),r=g(e,n.chainId);return{...n,chainId:r}},name:"store",partialize:e=>({connections:{__type:"Map",value:Array.from(e.connections.entries()).map(([e,t])=>{const{id:n,name:r,type:i,uid:o}=t.connector,s={id:n,name:r,type:i,uid:o};return[e,{...t,connector:s}]})},chainId:e.chainId,current:e.current}),merge(e,t){"object"==typeof e&&e&&"status"in e&&delete e.status;const n=g(e,t.chainId);return{...t,...e,chainId:n}},skipHydration:i,storage:n,version:f}):h));function g(e,t){return e&&"object"==typeof e&&"chainId"in e&&"number"==typeof e.chainId&&a.getState().some(t=>t.id===e.chainId)?e.chainId:t}function y(e){m.setState(t=>{const n=t.connections.get(e.uid);return n?{...t,connections:new Map(t.connections).set(e.uid,{accounts:e.accounts??n.accounts,chainId:e.chainId??n.chainId,connector:n.connector})}:t})}function b(e){"connecting"!==m.getState().status&&"reconnecting"!==m.getState().status&&m.setState(t=>{const n=c.getState().find(t=>t.uid===e.uid);return n?(n.emitter.listenerCount("connect")&&n.emitter.off("connect",y),n.emitter.listenerCount("change")||n.emitter.on("change",y),n.emitter.listenerCount("disconnect")||n.emitter.on("disconnect",v),{...t,connections:new Map(t.connections).set(e.uid,{accounts:e.accounts,chainId:e.chainId,connector:n}),current:e.uid,status:"connected"}):t})}function v(e){m.setState(t=>{const n=t.connections.get(e.uid);if(n){const e=n.connector;e.emitter.listenerCount("change")&&n.connector.emitter.off("change",y),e.emitter.listenerCount("disconnect")&&n.connector.emitter.off("disconnect",v),e.emitter.listenerCount("connect")||n.connector.emitter.on("connect",b)}if(t.connections.delete(e.uid),0===t.connections.size)return{...t,connections:new Map,current:null,status:"disconnected"};const r=t.connections.values().next().value;return{...t,connections:new Map(t.connections),current:r.connector.uid}})}return m.setState(h()),r&&m.subscribe(({connections:e,current:t})=>{var n;return t?null==(n=e.get(t))?void 0:n.chainId:void 0},e=>{if(a.getState().some(t=>t.id===e))return m.setState(t=>({...t,chainId:e??t.chainId}))}),null==s||s.subscribe(e=>{const t=new Set,r=new Set;for(const n of c.getState())if(t.add(n.id),n.rdns){const e="string"==typeof n.rdns?[n.rdns]:n.rdns;for(const t of e)r.add(t)}const i=[];for(const n of e){if(r.has(n.info.rdns))continue;const e=l(u(n));t.has(e.id)||i.push(e)}n&&!m.persist.hasHydrated()||c.setState(e=>[...e,...i],!0)}),{get chains(){return a.getState()},get connectors(){return c.getState()},storage:n,getClient:function(e={}){const t=e.chainId??m.getState().chainId,n=a.getState().find(e=>e.id===t);if(e.chainId&&!n)throw new nA;{const e=d.get(m.getState().chainId);if(e&&!n)return e;if(!n)throw new nA}{const e=d.get(t);if(e)return e}let r;if(o.client)r=o.client({chain:n});else{const e=n.id,t=a.getState().map(e=>e.id),i={},s=Object.entries(o);for(const[n,r]of s)if("chains"!==n&&"client"!==n&&"connectors"!==n&&"transports"!==n)if("object"==typeof r)if(e in r)i[n]=r[e];else{if(t.some(e=>e in r))continue;i[n]=r}else i[n]=r;r=MS({...i,chain:n,batch:i.batch??{multicall:!0},transport:t=>o.transports[e]({...t,connectors:c})})}return d.set(t,r),r},get state(){return m.getState()},setState(e){let t;t="function"==typeof e?e(m.getState()):e;const n=h();"object"!=typeof t&&(t=n);Object.keys(n).some(e=>!(e in t))&&(t=n),m.setState(t,!0)},subscribe:(e,t,n)=>m.subscribe(e,t,n?{...n,fireImmediately:n.emitImmediately}:void 0),_internal:{mipd:s,store:m,ssr:Boolean(i),syncConnectedChain:r,transports:o.transports,chains:{setState(e){const t="function"==typeof e?e(a.getState()):e;if(0!==t.length)return a.setState(t,!0)},subscribe:e=>a.subscribe(e)},connectors:{providerDetailToConnector:u,setup:l,setState:e=>c.setState("function"==typeof e?e(c.getState()):e,!0),subscribe:e=>c.subscribe(e)},events:{change:y,connect:b,disconnect:v}}}}({chains:[nP,KA,oP,zA,iP,HA,tP,WA],connectors:[pA(),aP({dappMetadata:{name:"Coinley Payment",icon:cP}}),sP({appName:"Coinley Payment",appLogoUrl:cP})],transports:{[nP.id]:jA([$S(`https://eth-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://eth-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://cloudflare-eth.com",{timeout:1e4,retryCount:1}),$S("https://eth.llamarpc.com",{timeout:1e4,retryCount:1}),$S("https://ethereum.publicnode.com",{timeout:1e4,retryCount:1})]),[KA.id]:jA([$S(`https://bnb-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://bnb-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://bsc-dataseed.bnbchain.org",{timeout:1e4,retryCount:1}),$S("https://bsc-dataseed-public.bnbchain.org",{timeout:1e4,retryCount:1}),$S("https://bsc.nodereal.io",{timeout:1e4,retryCount:1})]),[oP.id]:jA([$S(`https://polygon-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://polygon-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://polygon.llamarpc.com",{timeout:1e4,retryCount:1}),$S("https://polygon-rpc.com",{timeout:1e4,retryCount:1}),$S("https://polygon.drpc.org",{timeout:1e4,retryCount:1})]),[zA.id]:jA([$S(`https://arb-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://arb-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://arb1.arbitrum.io/rpc",{timeout:1e4,retryCount:1}),$S("https://arbitrum.llamarpc.com",{timeout:1e4,retryCount:1})]),[iP.id]:jA([$S(`https://opt-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://opt-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://mainnet.optimism.io",{timeout:1e4,retryCount:1}),$S("https://optimism.llamarpc.com",{timeout:1e4,retryCount:1})]),[HA.id]:jA([$S(`https://avax-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://avax-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://api.avax.network/ext/bc/C/rpc",{timeout:1e4,retryCount:1}),$S("https://avalanche.public-rpc.com",{timeout:1e4,retryCount:1})]),[tP.id]:jA([$S(`https://celo-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://celo-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://forno.celo.org",{timeout:1e4,retryCount:1}),$S("https://celo.drpc.org",{timeout:1e4,retryCount:1})]),[WA.id]:jA([$S(`https://base-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://base-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://mainnet.base.org",{timeout:1e4,retryCount:1}),$S("https://base.llamarpc.com",{timeout:1e4,retryCount:1}),$S("https://base.meowrpc.com",{timeout:1e4,retryCount:1})])}});class hP{constructor(e,t,n=null){this.baseURL=e.endsWith("/")?e.slice(0,-1):e,t&&t.startsWith("pk_")?(this.publicKey=t,this.apiKey=null,this.apiSecret=null):(this.publicKey=null,this.apiKey=t,this.apiSecret=n)}async request(e,t={}){const n=`${this.baseURL}${e}`,r={"Content-Type":"application/json",...t.headers};this.publicKey?r["X-Public-Key"]=this.publicKey:(r["X-API-Key"]=this.apiKey,r["X-API-Secret"]=this.apiSecret);const i=t.timeout||6e4,o=new AbortController,s=setTimeout(()=>o.abort(),i);try{const e=await fetch(n,{...t,headers:r,signal:o.signal});if(clearTimeout(s),!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.error||`HTTP ${e.status}`)}return e.json()}catch(a){if(clearTimeout(s),"AbortError"===a.name)throw new Error(`Request timeout after ${i/1e3}s: ${e}`);throw a}}async getNetworks(){try{return await this.request("/api/networks")}catch(e){return console.error("Failed to fetch networks:",e),{networks:[{id:"1",name:"Ethereum",shortName:"ethereum",chainId:"0x1",type:"ethereum"},{id:"56",name:"BSC",shortName:"bsc",chainId:"0x38",type:"bsc"},{id:"137",name:"Polygon",shortName:"polygon",chainId:"0x89",type:"polygon"},{id:"42161",name:"Arbitrum",shortName:"arbitrum",chainId:"0xa4b1",type:"arbitrum"},{id:"10",name:"Optimism",shortName:"optimism",chainId:"0xa",type:"optimism"},{id:"43114",name:"Avalanche",shortName:"avalanche",chainId:"0xa86a",type:"avalanche"}]}}}async getTokens(){try{return await this.request("/api/networks/stablecoins")}catch(e){return console.error("Failed to fetch tokens:",e),{stablecoins:[{id:"1",name:"Tether USD",symbol:"USDT",contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"2",name:"USD Coin",symbol:"USDC",contractAddress:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"3",name:"Tether USD",symbol:"USDT",contractAddress:"0x55d398326f99059fF775485246999027B3197955",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"4",name:"USD Coin",symbol:"USDC",contractAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"5",name:"Tether USD",symbol:"USDT",contractAddress:"0xc2132D05D31c914a87c6611C10748AEb04B58e8F",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"6",name:"USD Coin",symbol:"USDC",contractAddress:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"7",name:"Tether USD",symbol:"USDT",contractAddress:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"8",name:"USD Coin",symbol:"USDC",contractAddress:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"9",name:"Tether USD",symbol:"USDT",contractAddress:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"10",name:"USD Coin",symbol:"USDC",contractAddress:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"11",name:"Tether USD",symbol:"USDT",contractAddress:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"12",name:"USD Coin",symbol:"USDC",contractAddress:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"13",name:"Tether USD",symbol:"USDT",contractAddress:"0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"14",name:"USD Coin",symbol:"USDC",contractAddress:"0xcebA9300f2b948710d2653dD7B07f33A8B32118C",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"15",name:"Tether USD",symbol:"USDT",contractAddress:"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}},{id:"16",name:"USD Coin",symbol:"USDC",contractAddress:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}}]}}}async createPayment(e){return await this.request("/api/payments/create",{method:"POST",body:JSON.stringify(e)})}async verifyQRPayment(e){return await this.request("/api/payments/verify-qr",{method:"POST",body:JSON.stringify({paymentId:e})})}async checkPaymentStatus(e){return await this.request(`/api/payments/status/${e}`)}async getContractInfo(e){try{const t=await this.request(`/api/payments/contract/${e}`);if(!t.success)throw new Error("Contract not supported on this network");return t.contractInfo}catch(t){throw console.error("❌ Failed to get contract info:",t),new Error(t.message||"Failed to get contract information")}}async processPayment(e,t,n,r){try{return await this.request("/api/payments/process",{method:"POST",body:JSON.stringify({paymentId:e,transactionHash:t,network:n,senderAddress:r}),timeout:9e4})}catch(i){throw console.error("❌ [API] processPayment failed:",{error:i.message,name:i.name,stack:i.stack}),i}}async failPayment(e,t="Payment cancelled by user"){return await this.request("/api/payments/fail",{method:"POST",body:JSON.stringify({paymentId:e,reason:t,status:"failed"})})}}const fP={ethereum:1,bsc:56,polygon:137,arbitrum:42161,optimism:10,avalanche:43114,celo:42220,base:8453},pP=e=>"number"==typeof e?e:"string"==typeof e?e.startsWith("0x")?parseInt(e,16):parseInt(e,10):1,mP=e=>fP[e]||1,gP=()=>{const[e,t]=yt.useState(null),[n,r]=yt.useState(null),[i,o]=yt.useState(""),{connect:s,connectors:a}=GI(),{isConnected:c,address:l,chain:u}=AC(),{switchChain:d}=function(e={}){const{mutation:t}=e,n=iC(e),r=RI(n),{mutate:i,mutateAsync:o,...s}=HI({...t,...r});return{...s,chains:WI({config:n}),switchChain:i,switchChainAsync:o}}();yt.useEffect(()=>{r(c&&l?{account:l,chainId:null==u?void 0:u.id,walletType:e}:null)},[c,l,u,e]);return{selectedWalletType:e,connectedWallet:n,connectionError:i,isConnected:c,address:l,chain:u,connectors:a,handleWalletSelection:e=>{t(e),o("")},connectWallet:async(e,t=null)=>{var n,r,i;if(!e)return o("Please select a wallet first"),!1;try{if(o(""),await s({connector:e}),t){const s=mP(t.shortName),c=(null==(n=e.name)?void 0:n.toLowerCase())||"",l=c.includes("zerion")||c.includes("trust")||c.includes("rabby")?5e3:500;await new Promise(e=>setTimeout(e,l));const u=lA(dP).chainId;if(s&&u!==s)try{await d({chainId:s}),await new Promise(e=>setTimeout(e,1e3))}catch(a){return console.error("❌ Network switch failed:",a),4001===a.code||(null==(r=a.message)?void 0:r.includes("User rejected"))?o("Network switch was cancelled by user"):(null==(i=a.message)?void 0:i.includes("Unrecognized chain ID"))?o(`${t.name} network is not added to your wallet. Please add it manually.`):o(`Failed to switch to ${t.name}. Please switch manually in your wallet.`),!1}}return!0}catch(c){return console.error(`${e.name} wallet connection failed:`,c),4001===c.code||c.message.includes("User rejected")||c.message.includes("rejected")?o("User cancelled the connection request"):o(`Failed to connect to ${e.name}. Please try again.`),!1}},disconnectWallet:()=>{r(null),t(null),o("")},switchChain:d,ensureCorrectNetwork:async e=>{var t,n;if(!e)return console.warn("⚠️ No network specified for verification"),!0;try{const i=mP(e.shortName),s=lA(dP).chainId;if(i&&s!==i)try{return await d({chainId:i}),await new Promise(e=>setTimeout(e,1e3)),!0}catch(r){return console.error("❌ Network switch failed:",r),4001===r.code||(null==(t=r.message)?void 0:t.includes("User rejected"))?o("Network switch was cancelled. Please switch to the correct network in your wallet."):(null==(n=r.message)?void 0:n.includes("Unrecognized chain ID"))?o(`${e.name} network is not added to your wallet. Please add it manually.`):o(`Failed to switch to ${e.name}. Please switch manually in your wallet.`),!1}return!0}catch(i){return console.error("❌ Network verification failed:",i),o("Failed to verify network. Please check your wallet connection."),!1}},clearError:()=>{o("")},setSelectedWalletType:t,connect:s}},yP=(e,t,n=!1)=>{if(!e||"string"!=typeof e)throw new Error(`Missing ${t} address`);if(!e.startsWith("0x"))throw new Error(`Invalid ${t} address format: must start with 0x`);if(42!==e.length)throw new Error(`Invalid ${t} address length: expected 42 characters, got ${e.length}`);if("0x0000000000000000000000000000000000000000"===e&&!n)throw new Error(`Invalid ${t} address: cannot be zero address`)},bP=e=>{const t=(e=>{yP(e.token,"token"),yP(e.recipient1,"recipient1"),yP(e.recipient2,"recipient2");const t=0n===BigInt(e.recipient3Percentage||0);if(yP(e.recipient3,"recipient3",t),!e.paymentId||"string"!=typeof e.paymentId||0===e.paymentId.length)throw new Error("Invalid payment ID: must be a non-empty string");let n,r,i,o;try{n=BigInt(e.amount||0),r=BigInt(e.recipient1Percentage||0),i=BigInt(e.recipient2Percentage||0),o=BigInt(e.recipient3Percentage||0)}catch(a){throw new Error("Invalid numeric values: cannot convert to BigInt")}if(n<=0n)throw new Error(`Invalid amount: ${e.amount} (must be greater than 0)`);const s=r+i+o;if(10000n!==s)throw new Error(`Invalid percentages: total is ${s} but must equal 10000 basis points (100%). Individual: ${r}, ${i}, ${o}`);return{amount:n,percentage1:r,percentage2:i,percentage3:o}})(e);return{token:e.token,amount:t.amount,paymentId:e.paymentId,recipient1:e.recipient1,recipient2:e.recipient2,recipient3:e.recipient3,recipient1Percentage:t.percentage1,recipient2Percentage:t.percentage2,recipient3Percentage:t.percentage3}},vP=[{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"}],wP=[{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],EP=e=>{var t,n;const r=(null==(t=null==e?void 0:e.message)?void 0:t.toLowerCase())||(null==(n=null==e?void 0:e.toString())?void 0:n.toLowerCase())||"",i=(null==e?void 0:e.code)||(null==e?void 0:e.reason)||"";return r.includes("user rejected")||r.includes("user denied")||r.includes("user cancelled")||r.includes("rejected by user")||4001===i||"ACTION_REJECTED"===i?{type:"user_rejected",title:"Transaction Cancelled",message:"You cancelled the transaction. No charges were made.",suggestion:'Click "Pay Now" to try again when you\'re ready.'}:r.includes("insufficient funds")||r.includes("insufficient balance")||r.includes("insufficient eth")||r.includes("insufficient matic")||r.includes("insufficient bnb")||-32e3===i?{type:"insufficient_funds",title:"Insufficient Funds",message:"You don't have enough tokens or gas fees in your wallet.",suggestion:"Add more funds to your wallet and try again."}:r.includes("network error")||r.includes("rpc error")||r.includes("connection failed")||r.includes("timeout")||r.includes("request failed")?{type:"network_error",title:"Network Error",message:"Unable to connect to the blockchain network.",suggestion:"Check your internet connection and try again."}:r.includes("wrong network")||r.includes("unsupported network")||r.includes("chain mismatch")||4902===i?{type:"wrong_network",title:"Wrong Network",message:"Please switch to the correct network in your wallet.",suggestion:"Your wallet should prompt you to switch networks."}:r.includes("wallet not connected")||r.includes("no provider")||r.includes("wallet disconnected")||4900===i?{type:"wallet_disconnected",title:"Wallet Disconnected",message:"Your wallet is not connected.",suggestion:"Please reconnect your wallet and try again."}:r.includes("gas estimation failed")||r.includes("execution reverted")||r.includes("out of gas")?{type:"gas_error",title:"Transaction Failed",message:"The transaction couldn't be processed.",suggestion:"This might be a temporary issue. Please try again."}:r.includes("approve")&&r.includes("failed")?{type:"approval_failed",title:"Token Approval Failed",message:"Failed to approve token spending.",suggestion:"Please try the approval step again."}:r.includes("transaction failed")||r.includes("revert")||r.includes("contract call failed")?{type:"transaction_failed",title:"Transaction Failed",message:"The blockchain transaction was unsuccessful.",suggestion:"Please check your wallet and try again."}:r.includes("popup")||r.includes("blocked")?{type:"popup_blocked",title:"Wallet Popup Blocked",message:"Your browser blocked the wallet popup.",suggestion:"Please allow popups for this site and try again."}:r.includes("rate limit")||r.includes("too many requests")?{type:"rate_limited",title:"Too Many Requests",message:"Please wait a moment before trying again.",suggestion:"Wait 30 seconds and retry your transaction."}:r.includes("payment not yet confirmed")||r.includes("not yet confirmed on-chain")||r.includes("payment not found on-chain")||r.includes("please complete the payment")?{type:"payment_pending",title:"Payment Pending",message:"Your payment is still being confirmed on the blockchain.",suggestion:"Please wait a moment and try again, or check if your transaction completed successfully."}:r.includes("deep link")||r.includes("app not installed")||r.includes("wallet app")?{type:"mobile_wallet_error",title:"Wallet App Issue",message:"Unable to open or connect to your wallet app.",suggestion:"Make sure your wallet app is installed and try again."}:{type:"unknown_error",title:"Something Went Wrong",message:"An unexpected error occurred.",suggestion:"Please try again or contact support if the problem persists."}},_P=(e,t="")=>({timestamp:(new Date).toISOString(),context:t,userFriendly:EP(e),technical:{message:(null==e?void 0:e.message)||"Unknown error",code:null==e?void 0:e.code,reason:null==e?void 0:e.reason,stack:null==e?void 0:e.stack,name:null==e?void 0:e.name}});["✅ 3s RPC propagation delay after approval (Coinbase Wallet fix)","✅ Allowance verification loop (3 attempts, 2s intervals)","✅ Avalanche simulation bypass (JSON-RPC error workaround)","✅ Ethereum simulation bypass (stale RPC state workaround)","✅ 120s transaction timeout (was 60s)","✅ 20% gas price buffer (FIXED: proper estimateFeesPerGas import)","✅ Balance check fallback RPC (Alchemy primary, 3+ public fallbacks)","✅ USDT reset handling","⚡ Alchemy RPCs: ALL 8 CHAINS (ETH, BSC, MATIC, ARB, OP, AVAX, CELO, BASE) - 99.9% uptime",'✅ 8s backend sync delay (prevents "payment not found" RPC indexing lag)',"🆕 Base network support (Chain ID 8453, Contract: 0x6D827e60d0dC279cAa09f026d1641ECDb5704753)"].forEach(e=>{});const xP=async(e,t)=>{try{const n=await cA(e,{chainId:t}),r=120n,i=100n;return{maxFeePerGas:n.maxFeePerGas?n.maxFeePerGas*r/i:void 0,maxPriorityFeePerGas:n.maxPriorityFeePerGas?n.maxPriorityFeePerGas*r/i:void 0}}catch(n){return console.warn("⚠️ Could not estimate gas with buffer, using default:",n.message),{}}},kP="YWG990wOlIikc1tU7-WWTepfU8d1f4dp",SP=(e,t,n,r,i,o)=>{const[s,a]=yt.useState("idle"),[c,l]=yt.useState(""),[u,d]=yt.useState(null),{data:h,isPending:f}=VI(),{isLoading:p,isSuccess:m}=ZI({hash:h}),g=async()=>{var e,t,n,r,o,s,c;try{a("splitPayment");const l=window.coinleyPendingSplitPayment;if(!l)throw new Error("Missing split payment data");const{contractCall:f,selectedToken:p,paymentData:m,selectedNetwork:g}=l,y=g.chainId||10,b=await i.getContractInfo(y),{abi:v}=b,w=bP(f.params),E=pP(y),_=1===E,x=_||43114===E;try{const{request:e}=await async function(e,t){const{abi:n,chainId:r,connector:i,...o}=t;let s;s=t.account?t.account:(await aA(e,{chainId:r,connector:i})).account;const a=e.getClient({chainId:r}),c=YI(a,Wk,"simulateContract"),{result:l,request:u}=await c({...o,abi:n,account:s});return{chainId:a.chain.id,result:l,request:{...u,chainId:r}}}(dP,{address:f.contractAddress,abi:v,functionName:"splitPayment",args:[w]})}catch(u){console.error("❌ Transaction simulation failed:",u),console.error("🔍 Simulation Error Details:",{message:u.message,cause:u.cause,data:u.data,reason:u.reason,code:u.code,details:u.details,shortMessage:u.shortMessage,metaMessages:u.metaMessages,name:u.name});const i=u.data||(null==(e=u.cause)?void 0:e.data);i&&(console.error("🔍 Raw Error Data (hex):",i),"string"==typeof i&&i.startsWith("0x08c379a0")?console.error("🔍 Error type: Error(string) - contract has custom revert message"):"string"==typeof i&&i.startsWith("0x4e487b71")?console.error("🔍 Error type: Panic - likely assert() failure or array bounds"):i&&console.error("🔍 Error type: Custom error or unknown revert"));const o=u.reason||(null==(t=u.cause)?void 0:t.reason)||(null==(n=u.cause)?void 0:n.shortMessage)||(null==(r=u.data)?void 0:r.message)||"Unknown revert reason (contract may use require() without message)";if(console.error("🔍 Contract Revert Reason:",o),console.error("🔍 Failed Contract Call:",{contract:f.contractAddress,function:"splitPayment",paymentId:w.paymentId,amount:w.amount.toString(),token:w.token}),!x){const{userFriendlyMessage:e}=(e=>{if(!e.message)return{revertReason:"Transaction will revert",userFriendlyMessage:"Transaction simulation failed"};const t=e.message.toLowerCase();return t.includes("abi encoding params/values length mismatch")?{revertReason:"Smart contract parameter mismatch. This is likely a technical issue.",userFriendlyMessage:"Technical error: Contract parameters mismatch. Please try again or contact support."}:t.includes("payment id already used")?{revertReason:"This payment ID has already been used.",userFriendlyMessage:"This payment has already been processed. Please check your transaction history."}:t.includes("percentages must equal 100")?{revertReason:"Payment split percentages are incorrect.",userFriendlyMessage:"Internal error: Payment split configuration is invalid. Please contact support."}:t.includes("token transfer failed")||t.includes("transfer amount exceeds")?{revertReason:"Insufficient token balance or approval.",userFriendlyMessage:"Insufficient balance or token approval. Please check your wallet balance."}:t.includes("amount must be greater than 0")?{revertReason:"Payment amount is invalid.",userFriendlyMessage:"Invalid payment amount. Please try again."}:t.includes("invalid recipient")||t.includes("zero address")?{revertReason:"One of the payment recipients has an invalid address.",userFriendlyMessage:"Payment configuration error: Invalid recipient address. Please contact support."}:t.includes("insufficient gas")||t.includes("out of gas")?{revertReason:"Insufficient gas for transaction.",userFriendlyMessage:"Not enough gas to process transaction. Please increase gas limit or check ETH balance."}:t.includes("nonce")?{revertReason:"Transaction nonce conflict.",userFriendlyMessage:"Transaction ordering conflict. Please try again in a moment."}:{revertReason:e.message,userFriendlyMessage:`Transaction simulation failed: ${e.message.substring(0,100)}${e.message.length>100?"...":""}`}})(u);throw new Error(e)}{const e=_?"ETHEREUM":"AVALANCHE",t=_?"Stale RPC state, gas estimation quirks, contract has 100% Etherscan success rate":"JSON-RPC errors during simulation (common with Avalanche RPCs), but transactions succeed on-chain";console.warn(`⚠️ [${e}] Simulation failed but proceeding anyway`),console.warn(`⚠️ [${e}] The wallet will catch any actual errors`),console.warn(`⚠️ [${e}] Reason: ${t}`),console.warn("📤 Sending transaction to wallet for real validation...")}}const k=await xP(dP,y),S="arbitrum"===g.shortName,C=S?2:0;let I;for(let e=0;e<=C;e++)try{if(e>0){const t=2e3*e;await new Promise(e=>setTimeout(e,t))}I=await fA(dP,{address:f.contractAddress,abi:v,functionName:"splitPayment",args:[w],...k});break}catch(h){const t=(null==(o=h.message)?void 0:o.includes("Internal JSON-RPC error"))||(null==(s=h.message)?void 0:s.includes("-32603"))||(null==(c=h.message)?void 0:c.includes("nonce"));if(e===C||!t&&!S)throw h}return d(I),a("processing"),window.coinleyPendingSplitPayment=null,I}catch(f){console.error("❌ Step 2 (SplitPayment) failed:",f);const e=_P(f,"split_payment_transaction");console.error("🔍 Detailed error log:",e);const t=EP(f);throw l(t),a("error"),f}},y=async t=>{try{if(a("processing"),!i||!i.processPayment)throw new Error("API instance not available or missing processPayment method");await new Promise(e=>setTimeout(e,8e3));const o=await i.processPayment(e.id,t,n.shortName,r);return a("success"),o}catch(o){console.error("❌ Final payment processing failed:",o);const e=_P(o,"final_payment_processing");console.error("🔍 Detailed error log:",e);const t=EP(o);throw l(t),a("error"),o}};return{transactionStep:s,transactionError:c,currentTransactionHash:u,txPending:f,isConfirming:p,isConfirmed:m,executePaymentTransaction:async()=>{var i,s,c,u;if(!r||!(null==e?void 0:e.contractCall))throw new Error("Missing wallet connection or payment data");const h=e.contractCall;if(!h.contractAddress)throw new Error("PaymentSplitter contract data missing from payment response");if((null==o?void 0:o.ensureCorrectNetwork)&&n){if(!(await o.ensureCorrectNetwork(n)))throw console.error("❌ Network verification failed - transaction aborted"),new Error("Network verification failed. Please ensure you are on the correct network.")}if(!t.contractAddress)throw new Error("Native token transactions not yet supported with PaymentSplitter. Please use ERC-20 tokens.");{const o=t.decimals||6,_=h.approvalAmount||Math.floor(e.totalAmount*Math.pow(10,o));try{let e,a="unknown";try{e=await uA(dP,{address:h.tokenAddress,abi:wP,functionName:"balanceOf",args:[r]}),a="wallet-rpc"}catch(f){console.warn("⚠️ Balance check via wallet RPC failed:",{error:f.message,isEmptyData:(null==(i=f.message)?void 0:i.includes("returned no data"))||(null==(s=f.message)?void 0:s.includes("0x")),wallet:"Using wallet-controlled RPC"});const t=(null==n?void 0:n.chainId)||(null==n?void 0:n.id);if(!t)throw console.error("❌ No chainId available for fallback RPC"),f;{const n=pP(t),i=(e=>{const t={1:nP,56:KA,137:oP,42161:zA,10:iP,43114:HA,42220:tP,8453:WA}[e],n={1:[`https://eth-mainnet.g.alchemy.com/v2/${kP}`,"https://cloudflare-eth.com","https://eth.llamarpc.com","https://ethereum.publicnode.com"],56:[`https://bnb-mainnet.g.alchemy.com/v2/${kP}`,"https://bsc-dataseed.bnbchain.org","https://bsc-dataseed-public.bnbchain.org","https://bsc.nodereal.io"],137:[`https://polygon-mainnet.g.alchemy.com/v2/${kP}`,"https://polygon.llamarpc.com","https://polygon-rpc.com","https://polygon.drpc.org"],42161:[`https://arb-mainnet.g.alchemy.com/v2/${kP}`,"https://arb1.arbitrum.io/rpc","https://arbitrum.llamarpc.com"],10:[`https://opt-mainnet.g.alchemy.com/v2/${kP}`,"https://mainnet.optimism.io","https://optimism.llamarpc.com"],43114:[`https://avax-mainnet.g.alchemy.com/v2/${kP}`,"https://api.avax.network/ext/bc/C/rpc","https://avalanche.public-rpc.com"],42220:[`https://celo-mainnet.g.alchemy.com/v2/${kP}`,"https://forno.celo.org","https://celo.drpc.org"],8453:[`https://base-mainnet.g.alchemy.com/v2/${kP}`,"https://mainnet.base.org","https://base.llamarpc.com","https://base.meowrpc.com"]}[e];return t&&n?LS({chain:t,transport:DS(n.map(e=>$S(e,{timeout:1e4,retryCount:1})))}):null})(n);if(!i)throw console.error("❌ No fallback RPC client available for chain",n),f;try{e=await i.readContract({address:h.tokenAddress,abi:wP,functionName:"balanceOf",args:[r]}),a="fallback-rpc"}catch(p){throw console.error("❌ Balance check via fallback RPC also failed:",p.message),f}}}const c=BigInt(_);if(e<c){const n=`Insufficient ${t.symbol} balance. You have ${(Number(e)/Math.pow(10,o)).toFixed(6)} ${t.symbol} but need ${(Number(c)/Math.pow(10,o)).toFixed(6)} ${t.symbol}`;throw new Error(n)}}catch(m){if(console.error("Balance check failed:",m),m.message.includes("Insufficient"))throw m;console.warn("⚠️ Continuing despite balance check failure - transaction will be validated by wallet")}a("approve"),window.coinleyPendingSplitPayment={contractCall:h,selectedToken:t,paymentData:e,selectedNetwork:n};try{const e="0xdac17f958d2ee523a2206206994597c13d831ec7"===h.tokenAddress.toLowerCase()||"USDT"===t.symbol.toUpperCase();let i,o=Vh;e&&(o=vP);try{i=BigInt(_)}catch(b){throw console.error("❌ Failed to convert amount to BigInt:",{amount:_,amountType:typeof _,error:b.message}),new Error(`Invalid amount value: ${_}`)}let s=0n,c=0;const l=3;for(;c<l;)try{s=await uA(dP,{address:h.tokenAddress,abi:Vh,functionName:"allowance",args:[r,h.contractAddress]});break}catch(v){c++,c<l?(console.warn(`⚠️ Allowance check attempt ${c} failed, retrying in 2s...`,v.message),await new Promise(e=>setTimeout(e,2e3))):(console.warn("⚠️ Could not check allowance after 3 attempts, assuming 0 allowance:",v.message),s=0n)}if(s>=i){a("splitPayment");const e=await g();return e&&await y(e),e}if(e&&s>0n){const e=await xP(dP,n.chainId),t=await fA(dP,{address:h.tokenAddress,abi:Vh,functionName:"approve",args:[h.contractAddress,0n],...e});await hA(dP,{hash:t,confirmations:1,timeout:12e4})}const u=await xP(dP,n.chainId),f=await fA(dP,{address:h.tokenAddress,abi:Vh,functionName:"approve",args:[h.contractAddress,i],...u});d(f);await hA(dP,{hash:f,confirmations:1,timeout:12e4});await new Promise(e=>setTimeout(e,3e3));let p=0;const m=3;let E=!1;for(;p<m&&!E;){try{if(await uA(dP,{address:h.tokenAddress,abi:Vh,functionName:"allowance",args:[r,h.contractAddress]})>=i){E=!0;break}p<m-1&&await new Promise(e=>setTimeout(e,2e3))}catch(w){console.warn(`⚠️ Allowance verification attempt ${p+1} failed:`,w.message),p<m-1&&await new Promise(e=>setTimeout(e,2e3))}p++}E||(console.warn("⚠️ Could not verify allowance after 3 attempts, proceeding anyway"),console.warn("⚠️ Transaction will fail if allowance has not propagated"));const x=await g();return x&&await y(x),x}catch(E){console.error("❌ ERC20 Approve failed:",E);const e=_P(E,"approve_transaction");console.error("🔍 Detailed error log:",e);const t=EP(E);if(l(t),a("idle"),(null==(c=E.message)?void 0:c.includes("User rejected"))||(null==(u=E.message)?void 0:u.includes("User denied"))||4001===E.code)throw new Error("Transaction was cancelled by user");throw new Error(`Approve failed: ${E.message}`)}}},executeSplitPayment:g,processFinalPayment:y,resetTransaction:()=>{a("idle"),l(""),d(null),window.coinleyPendingSplitPayment=null},setTransactionError:l,setTransactionStep:a}},CP=({options:e=[],value:t,onChange:n,placeholder:r,renderOption:i,getOptionKey:o,getOptionValue:s,getSearchableText:a,disabled:c=!1})=>{const[l,u]=yt.useState(!1),[d,h]=yt.useState(""),[f,p]=yt.useState({top:0,left:0,width:400,maxHeight:450}),m=yt.useRef(null),g=yt.useRef(null),y=e.filter(e=>(a?a(e):"").toLowerCase().includes(d.toLowerCase())),b=e.find(e=>s(e)===t),v=()=>{if(g.current){const e=window.innerWidth,t=window.innerHeight,n=Math.min(400,e-40),r=Math.min(450,t-100);p({top:t/2-r/2,left:e/2-n/2,width:n,maxHeight:r})}};yt.useEffect(()=>{const e=e=>{m.current&&!m.current.contains(e.target)&&g.current&&!g.current.contains(e.target)&&(u(!1),h(""))},t=()=>{l&&v()};if(l){v();const n=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${n}px`,document.body.style.width="100%",document.addEventListener("mousedown",e),window.addEventListener("resize",t)}return()=>{if(l){const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",window.scrollTo(0,-1*parseInt(e||"0"))}document.removeEventListener("mousedown",e),window.removeEventListener("resize",t)}},[l]);const w=l&&Dh.jsxs(Dh.Fragment,{children:[Dh.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-30 transition-opacity",style:{zIndex:999998},onClick:()=>{u(!1),h("")}}),Dh.jsxs("div",{ref:m,className:"fixed bg-white border-2 border-gray-200 rounded-3xl shadow-2xl overflow-hidden",style:{top:f.top,left:f.left,width:f.width,maxHeight:f.maxHeight,zIndex:999999,transform:"translateZ(0)",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05)"},children:[Dh.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 bg-gradient-to-r from-[#7042D2]/10 to-purple-50",children:[Dh.jsx("h3",{className:"text-lg font-semibold text-[#7042D2]",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:r||"Select Option"}),Dh.jsx("button",{onClick:()=>{u(!1),h("")},className:"text-gray-500 hover:text-gray-700 transition-colors p-1 rounded-full hover:bg-gray-100",children:Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Dh.jsx("div",{className:"p-4 border-b border-gray-200 bg-gray-50",children:Dh.jsx("input",{type:"text",placeholder:"Search networks and tokens...",value:d,onChange:e=>h(e.target.value),className:"w-full p-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-[#7042D2]/20 focus:border-[#7042D2] text-sm",style:{fontFamily:"Bricolage Grotesque, sans-serif"},autoFocus:!0})}),Dh.jsx("div",{className:"overflow-y-auto custom-scrollbar",style:{maxHeight:(f.maxHeight||450)-180+"px",minHeight:"200px"},children:0===y.length?Dh.jsxs("div",{className:"p-8 text-gray-500 text-center",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[Dh.jsx("div",{className:"text-4xl mb-3",children:"🔍"}),Dh.jsx("div",{className:"text-lg mb-2",children:"No options found"}),Dh.jsx("div",{className:"text-sm text-gray-400",children:"Try a different search term"})]}):Dh.jsxs(Dh.Fragment,{children:[Dh.jsxs("div",{className:"px-4 py-3 bg-gray-50 border-b border-gray-100 text-sm text-gray-600",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[Dh.jsx("span",{className:"font-semibold",children:y.length})," option",1!==y.length?"s":""," available"]}),Dh.jsx("div",{className:"p-2",children:y.map(e=>Dh.jsx("button",{type:"button",onClick:()=>{n(s(e)),u(!1),h("")},className:"w-full p-4 text-left hover:bg-[#7042D2]/10 transition-all duration-200 rounded-xl mb-2 last:mb-0 "+(s(e)===t?"bg-[#7042D2]/20 text-[#7042D2] border-2 border-[#7042D2]/30":"text-gray-800 border-2 border-transparent hover:border-[#7042D2]/20"),style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:i(e)},o(e)))})]})}),Dh.jsx("div",{className:"p-3 bg-gradient-to-r from-gray-50 to-gray-100 border-t border-gray-200 text-center",children:Dh.jsx("div",{className:"text-xs text-gray-500",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:y.length>5?"↕️ Scroll to see more options":"✨ Select your preferred option"})})]})]});return Dh.jsxs(Dh.Fragment,{children:[Dh.jsx("div",{className:"relative",children:Dh.jsx("button",{ref:g,type:"button",onClick:()=>{c||(l||v(),u(!l))},disabled:c,className:`w-full p-4 border-2 rounded-2xl bg-gradient-to-r from-white to-gray-50 text-left focus:outline-none focus:ring-3 focus:ring-[#7042D2]/20 focus:border-[#7042D2] transition-all duration-300 ease-out shadow-lg hover:shadow-xl ${c?"opacity-50 cursor-not-allowed":"hover:border-[#7042D2]/50 cursor-pointer"} ${l?"border-[#7042D2] ring-3 ring-[#7042D2]/20":"border-gray-200"}`,style:{minHeight:"60px",fontFamily:"Bricolage Grotesque, sans-serif",fontSize:"16px",fontWeight:"500"},children:Dh.jsxs("div",{className:"flex items-center justify-between",children:[Dh.jsx("div",{className:"flex items-center space-x-3",children:b?i(b):Dh.jsx("span",{className:"text-gray-500",children:r})}),Dh.jsx("div",{className:"transform transition-transform duration-200 "+(l?"rotate-180":""),children:Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-[#7042D2]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})})}),"undefined"!=typeof document&&document.body&&Ch.createPortal(w,document.body),Dh.jsx("style",{jsx:!0,children:"\n .custom-scrollbar {\n scrollbar-width: thin;\n scrollbar-color: #7042D2 #f1f1f1;\n }\n .custom-scrollbar::-webkit-scrollbar {\n width: 12px;\n }\n .custom-scrollbar::-webkit-scrollbar-track {\n background: #f8f9fa;\n border-radius: 10px;\n margin: 4px;\n }\n .custom-scrollbar::-webkit-scrollbar-thumb {\n background: linear-gradient(180deg, #7042D2 0%, #5b34b1 100%);\n border-radius: 10px;\n border: 2px solid #f8f9fa;\n }\n .custom-scrollbar::-webkit-scrollbar-thumb:hover {\n background: linear-gradient(180deg, #5b34b1 0%, #4c2a93 100%);\n }\n .custom-scrollbar::-webkit-scrollbar-corner {\n background: #f8f9fa;\n }\n "})]})},IP=({currentStep:e,targetStep:t,children:n,className:r="",duration:i=300})=>{const[o,s]=yt.useState(e===t),[a,c]=yt.useState(e===t);return yt.useEffect(()=>{e===t?(c(!0),setTimeout(()=>s(!0),10)):(s(!1),setTimeout(()=>c(!1),i))},[e,t,i]),a?Dh.jsx("div",{className:`\n transition-all duration-300 ease-out\n ${o?"transform translate-y-0 opacity-100":"transform translate-y-full opacity-0"}\n ${r}\n `,style:{transitionDuration:`${i}ms`},children:n}):null},AP=({status:e,message:t,theme:n="light",payment:r=null,transactionHash:i=null,selectedPaymentMethod:o=null,selectedNetwork:s=null,merchantName:a="Merchant",onClose:c=null})=>{const[l,u]=yt.useState(!1),[d,h]=yt.useState(0);yt.useEffect(()=>{if("processing"===e){const e=setInterval(()=>{h(e=>e>=90?e:e+15*Math.random())},500);return()=>clearInterval(e)}},[e]);const f=async()=>{if(i)try{await navigator.clipboard.writeText(i),u(!0),setTimeout(()=>u(!1),2e3)}catch(e){console.error("Failed to copy transaction hash:",e)}},p=()=>{switch(e){case"processing":return Dh.jsxs("div",{className:"relative",children:[Dh.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-[#7042D2] border-blue-500/20"}),Dh.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:Dh.jsx("div",{className:"w-6 h-6 bg-[#7042D2] rounded-full animate-pulse"})})]});case"success":return Dh.jsx("div",{className:"rounded-full h-16 w-16 bg-green-500 flex items-center justify-center animate-bounce",children:Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Dh.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}};return"processing"===e?Dh.jsxs("div",{className:"flex flex-col items-center justify-center py-6 px-4",children:[Dh.jsx("div",{className:"mb-6",children:p()}),Dh.jsx("h3",{className:"text-xl font-bold mb-3 text-gray-900",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Processing Payment"}),Dh.jsx("p",{className:"text-center text-gray-600 mb-6",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Your transaction has been sent to the blockchain and is being processed..."}),Dh.jsxs("div",{className:"w-full max-w-xs mb-4",children:[Dh.jsx("div",{className:"bg-gray-200 rounded-full h-3",children:Dh.jsx("div",{className:"bg-[#7042D2] h-3 rounded-full transition-all duration-500 ease-out",style:{width:`${d}%`}})}),Dh.jsxs("div",{className:"text-center mt-2 text-sm text-gray-500",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Processing... ",Math.round(d),"%"]})]}),Dh.jsxs("div",{className:"text-center space-y-2",children:[Dh.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[Dh.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),Dh.jsx("span",{className:"text-sm text-gray-600",children:"Transaction submitted"})]}),Dh.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[Dh.jsx("div",{className:"w-2 h-2 bg-yellow-500 rounded-full animate-pulse"}),Dh.jsx("span",{className:"text-sm text-gray-600",children:"Confirming on blockchain..."})]}),Dh.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[Dh.jsx("div",{className:"w-2 h-2 bg-gray-300 rounded-full"}),Dh.jsx("span",{className:"text-sm text-gray-400",children:"Finalizing payment..."})]})]}),Dh.jsx("div",{className:"mt-6 p-3 bg-blue-50 rounded-lg border border-blue-200",children:Dh.jsx("p",{className:"text-xs text-blue-800 text-center",children:"Please don't close this window. This usually takes 10-30 seconds."})})]}):"success"===e?Dh.jsxs("div",{className:"flex flex-col items-center justify-center py-6 px-4",children:[Dh.jsx("div",{className:"mb-6",children:p()}),Dh.jsx("h3",{className:"text-2xl font-bold mb-3 text-gray-900",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Payment Successful!"}),r&&o&&Dh.jsxs("p",{className:"text-center max-w-[235px] mb-6 text-gray-600",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Your payment of ",Dh.jsxs("span",{className:"text-[#7042D2] font-semibold",children:[r.totalAmount||r.amount," ",o.currency]})," has been completed."]}),i&&Dh.jsxs("div",{className:"w-full mb-6 px-4",children:[Dh.jsx("p",{className:"text-sm font-medium mb-2 text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Transaction Details"}),Dh.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors bg-gray-50 border-gray-200 hover:bg-gray-100 mb-3",onClick:f,children:[Dh.jsx("span",{className:"font-mono text-sm text-gray-700",children:(m=i,m?m.length<=16?m:`${m.slice(0,8)}...${m.slice(-8)}`:"")}),Dh.jsxs("div",{className:"flex items-center",children:[l?Dh.jsx("span",{className:"text-green-500 text-xs font-medium mr-2",children:"Copied!"}):null,Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})]}),(()=>{const e=((e,t)=>{if(!e||!t)return null;const n="string"==typeof t?t:t.shortName||t.name;return{ethereum:`https://etherscan.io/tx/${e}`,bsc:`https://bscscan.com/tx/${e}`,polygon:`https://polygonscan.com/tx/${e}`,arbitrum:`https://arbiscan.io/tx/${e}`,optimism:`https://optimistic.etherscan.io/tx/${e}`,avalanche:`https://snowtrace.io/tx/${e}`,celo:`https://celoscan.io/tx/${e}`,base:`https://basescan.org/tx/${e}`}[null==n?void 0:n.toLowerCase()]||null})(i,s),t=(e=>{if(!e)return"Explorer";const t="string"==typeof e?e:e.shortName||e.name;return{ethereum:"Etherscan",bsc:"BscScan",polygon:"PolygonScan",arbitrum:"Arbiscan",optimism:"Optimistic Etherscan",avalanche:"SnowTrace",celo:"CeloScan",base:"BaseScan"}[null==t?void 0:t.toLowerCase()]||"Explorer"})(s);return s&&e&&Dh.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full p-3 rounded-lg border border-[#7042D2] bg-white hover:bg-purple-50 transition-colors group",children:[Dh.jsxs("span",{className:"text-sm font-medium text-[#7042D2]",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["View on ",t]}),Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2] group-hover:translate-x-1 transition-transform",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})})()]}),c&&Dh.jsx("button",{onClick:c,className:"w-full py-3 px-4 bg-[#7042D2] text-white font-semibold rounded-2xl text-lg shadow-md hover:bg-[#5b34b1] transition-colors",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Close"})]}):Dh.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Dh.jsx("div",{className:"mb-4",children:p()}),Dh.jsx("h3",{className:"text-xl font-bold mb-2 text-gray-900",children:"processing"===e?"Processing Payment":"error"===e?"Payment Failed":"Unknown Status"}),Dh.jsx("p",{className:"text-center text-gray-600",children:t})]});var m};var PP={},MP={},OP={};let TP;const RP=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];OP.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},OP.getSymbolTotalCodewords=function(e){return RP[e]},OP.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},OP.setToSJISFunction=function(e){if("function"!=typeof e)throw new Error('"toSJISFunc" is not a valid function.');TP=e},OP.isKanjiModeEnabled=function(){return void 0!==TP},OP.toSJIS=function(e){return TP(e)};var NP,LP={};function BP(){this.buffer=[],this.length=0}(NP=LP).L={bit:1},NP.M={bit:0},NP.Q={bit:3},NP.H={bit:2},NP.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},NP.from=function(e,t){if(NP.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return NP.L;case"m":case"medium":return NP.M;case"q":case"quartile":return NP.Q;case"h":case"high":return NP.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(n){return t}},BP.prototype={get:function(e){const t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(let n=0;n<t;n++)this.putBit(1==(e>>>t-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var jP=BP;function DP(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}DP.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},DP.prototype.get=function(e,t){return this.data[e*this.size+t]},DP.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},DP.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var UP=DP,FP={};!function(e){const t=OP.getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];const n=Math.floor(e/7)+2,r=t(e),i=145===r?26:2*Math.ceil((r-13)/(2*n-2)),o=[r-7];for(let t=1;t<n-1;t++)o[t]=o[t-1]-i;return o.push(6),o.reverse()},e.getPositions=function(t){const n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)0===e&&0===t||0===e&&t===i-1||e===i-1&&0===t||n.push([r[e],r[t]]);return n}}(FP);var $P={};const zP=OP.getSymbolSize;$P.getPositions=function(e){const t=zP(e);return[[0,0],[t-7,0],[0,t-7]]};var HP={};!function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t=3,n=3,r=40,i=10;function o(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){const n=e.size;let r=0,i=0,o=0,s=null,a=null;for(let c=0;c<n;c++){i=o=0,s=a=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===s?i++:(i>=5&&(r+=t+(i-5)),s=n,i=1),n=e.get(l,c),n===a?o++:(o>=5&&(r+=t+(o-5)),a=n,o=1)}i>=5&&(r+=t+(i-5)),o>=5&&(r+=t+(o-5))}return r},e.getPenaltyN2=function(e){const t=e.size;let r=0;for(let n=0;n<t-1;n++)for(let i=0;i<t-1;i++){const t=e.get(n,i)+e.get(n,i+1)+e.get(n+1,i)+e.get(n+1,i+1);4!==t&&0!==t||r++}return r*n},e.getPenaltyN3=function(e){const t=e.size;let n=0,i=0,o=0;for(let r=0;r<t;r++){i=o=0;for(let s=0;s<t;s++)i=i<<1&2047|e.get(r,s),s>=10&&(1488===i||93===i)&&n++,o=o<<1&2047|e.get(s,r),s>=10&&(1488===o||93===o)&&n++}return n*r},e.getPenaltyN4=function(e){let t=0;const n=e.data.length;for(let r=0;r<n;r++)t+=e.data[r];return Math.abs(Math.ceil(100*t/n/5)-10)*i},e.applyMask=function(e,t){const n=t.size;for(let r=0;r<n;r++)for(let i=0;i<n;i++)t.isReserved(i,r)||t.xor(i,r,o(e,i,r))},e.getBestMask=function(t,n){const r=Object.keys(e.Patterns).length;let i=0,o=1/0;for(let s=0;s<r;s++){n(s),e.applyMask(s,t);const r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(s,t),r<o&&(o=r,i=s)}return i}}(HP);var qP={};const WP=LP,KP=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],GP=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];qP.getBlocksCount=function(e,t){switch(t){case WP.L:return KP[4*(e-1)+0];case WP.M:return KP[4*(e-1)+1];case WP.Q:return KP[4*(e-1)+2];case WP.H:return KP[4*(e-1)+3];default:return}},qP.getTotalCodewordsCount=function(e,t){switch(t){case WP.L:return GP[4*(e-1)+0];case WP.M:return GP[4*(e-1)+1];case WP.Q:return GP[4*(e-1)+2];case WP.H:return GP[4*(e-1)+3];default:return}};var VP={},ZP={};const YP=new Uint8Array(512),JP=new Uint8Array(256);!function(){let e=1;for(let t=0;t<255;t++)YP[t]=e,JP[e]=t,e<<=1,256&e&&(e^=285);for(let t=255;t<512;t++)YP[t]=YP[t-255]}(),ZP.log=function(e){if(e<1)throw new Error("log("+e+")");return JP[e]},ZP.exp=function(e){return YP[e]},ZP.mul=function(e,t){return 0===e||0===t?0:YP[JP[e]+JP[t]]},function(e){const t=ZP;e.mul=function(e,n){const r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let o=0;o<n.length;o++)r[i+o]^=t.mul(e[i],n[o]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){const e=r[0];for(let o=0;o<n.length;o++)r[o]^=t.mul(n[o],e);let i=0;for(;i<r.length&&0===r[i];)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}}(VP);const QP=VP;function XP(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}XP.prototype.initialize=function(e){this.degree=e,this.genPoly=QP.generateECPolynomial(this.degree)},XP.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(e.length+this.degree);t.set(e);const n=QP.mod(t,this.genPoly),r=this.degree-n.length;if(r>0){const e=new Uint8Array(this.degree);return e.set(n,r),e}return n};var eM=XP,tM={},nM={},rM={isValid:function(e){return!isNaN(e)&&e>=1&&e<=40}},iM={};const oM="[0-9]+";let sM="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";sM=sM.replace(/u/g,"\\u");const aM="(?:(?![A-Z0-9 $%*+\\-./:]|"+sM+")(?:.|[\r\n]))+";iM.KANJI=new RegExp(sM,"g"),iM.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),iM.BYTE=new RegExp(aM,"g"),iM.NUMERIC=new RegExp(oM,"g"),iM.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const cM=new RegExp("^"+sM+"$"),lM=new RegExp("^"+oM+"$"),uM=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");iM.testKanji=function(e){return cM.test(e)},iM.testNumeric=function(e){return lM.test(e)},iM.testAlphanumeric=function(e){return uM.test(e)},function(e){const t=rM,n=iM;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,n){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(r){return n}}}(nM),function(e){const t=OP,n=qP,r=LP,i=nM,o=rM,s=t.getBCHDigit(7973);function a(e,t){return i.getCharCountIndicator(e,t)+4}function c(e,t){let n=0;return e.forEach(function(e){const r=a(e.mode,t);n+=r+e.getBitsLength()}),n}e.from=function(e,t){return o.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,s){if(!o.isValid(e))throw new Error("Invalid QR Code version");void 0===s&&(s=i.BYTE);const c=8*(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r));if(s===i.MIXED)return c;const l=c-a(s,e);switch(s){case i.NUMERIC:return Math.floor(l/10*3);case i.ALPHANUMERIC:return Math.floor(l/11*2);case i.KANJI:return Math.floor(l/13);case i.BYTE:default:return Math.floor(l/8)}},e.getBestVersionForData=function(t,n){let o;const s=r.from(n,r.M);if(Array.isArray(t)){if(t.length>1)return function(t,n){for(let r=1;r<=40;r++)if(c(t,r)<=e.getCapacity(r,n,i.MIXED))return r}(t,s);if(0===t.length)return 1;o=t[0]}else o=t;return function(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}(o.mode,o.getLength(),s)},e.getEncodedBits=function(e){if(!o.isValid(e)||e<7)throw new Error("Invalid QR Code version");let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=7973<<t.getBCHDigit(n)-s;return e<<12|n}}(tM);var dM={};const hM=OP,fM=hM.getBCHDigit(1335);dM.getEncodedBits=function(e,t){const n=e.bit<<3|t;let r=n<<10;for(;hM.getBCHDigit(r)-fM>=0;)r^=1335<<hM.getBCHDigit(r)-fM;return 21522^(n<<10|r)};var pM={};const mM=nM;function gM(e){this.mode=mM.NUMERIC,this.data=e.toString()}gM.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},gM.prototype.getLength=function(){return this.data.length},gM.prototype.getBitsLength=function(){return gM.getBitsLength(this.data.length)},gM.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);const i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,3*i+1))};var yM=gM;const bM=nM,vM=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function wM(e){this.mode=bM.ALPHANUMERIC,this.data=e}wM.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},wM.prototype.getLength=function(){return this.data.length},wM.prototype.getBitsLength=function(){return wM.getBitsLength(this.data.length)},wM.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*vM.indexOf(this.data[t]);n+=vM.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(vM.indexOf(this.data[t]),6)};var EM=wM;const _M=nM;function xM(e){this.mode=_M.BYTE,this.data="string"==typeof e?(new TextEncoder).encode(e):new Uint8Array(e)}xM.getBitsLength=function(e){return 8*e},xM.prototype.getLength=function(){return this.data.length},xM.prototype.getBitsLength=function(){return xM.getBitsLength(this.data.length)},xM.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var kM=xM;const SM=nM,CM=OP;function IM(e){this.mode=SM.KANJI,this.data=e}IM.getBitsLength=function(e){return 13*e},IM.prototype.getLength=function(){return this.data.length},IM.prototype.getBitsLength=function(){return IM.getBitsLength(this.data.length)},IM.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=CM.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}};var AM,PM=IM,MM={exports:{}};AM={single_source_shortest_paths:function(e,t,n){var r={},i={};i[t]=0;var o,s,a,c,l,u,d,h=AM.PriorityQueue.make();for(h.push(t,0);!h.empty();)for(a in s=(o=h.pop()).value,c=o.cost,l=e[s]||{})l.hasOwnProperty(a)&&(u=c+l[a],d=i[a],(void 0===i[a]||d>u)&&(i[a]=u,h.push(a,u),r[a]=s));if(void 0!==n&&void 0===i[n]){var f=["Could not find a path from ",t," to ",n,"."].join("");throw new Error(f)}return r},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,n){var r=AM.single_source_shortest_paths(e,t,n);return AM.extract_shortest_path_from_predecessor_list(r,n)},PriorityQueue:{make:function(e){var t,n=AM.PriorityQueue,r={};for(t in e=e||{},n)n.hasOwnProperty(t)&&(r[t]=n[t]);return r.queue=[],r.sorter=e.sorter||n.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}},MM.exports=AM;var OM=MM.exports;!function(e){const t=nM,n=yM,r=EM,i=kM,o=PM,s=iM,a=OP,c=OM;function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){const r=[];let i;for(;null!==(i=e.exec(n));)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){const n=u(s.NUMERIC,t.NUMERIC,e),r=u(s.ALPHANUMERIC,t.ALPHANUMERIC,e);let i,o;a.isKanjiModeEnabled()?(i=u(s.BYTE,t.BYTE,e),o=u(s.KANJI,t.KANJI,e)):(i=u(s.BYTE_KANJI,t.BYTE,e),o=[]);return n.concat(r,i,o).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function h(e,s){switch(s){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return o.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function f(e,s){let c;const l=t.getBestModeForData(e);if(c=t.from(s,l),c!==t.BYTE&&c.bit<l.bit)throw new Error('"'+e+'" cannot be encoded with mode '+t.toString(c)+".\n Suggested mode is: "+t.toString(l));switch(c!==t.KANJI||a.isKanjiModeEnabled()||(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new o(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(f(t,null)):t.data&&e.push(f(t.data,t.mode)),e},[])},e.fromString=function(n,r){const i=function(e){const n=[];for(let r=0;r<e.length;r++){const i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}(d(n,a.isKanjiModeEnabled())),o=function(e,n){const r={},i={start:{}};let o=["start"];for(let s=0;s<e.length;s++){const a=e[s],c=[];for(let e=0;e<a.length;e++){const l=a[e],u=""+s+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<o.length;e++){const s=o[e];r[s]&&r[s].node.mode===l.mode?(i[s][u]=h(r[s].lastCount+l.length,l.mode)-h(r[s].lastCount,l.mode),r[s].lastCount+=l.length):(r[s]&&(r[s].lastCount=l.length),i[s][u]=h(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}o=c}for(let t=0;t<o.length;t++)i[o[t]].end=0;return{map:i,table:r}}(i,r),s=c.find_path(o.map,"start","end"),u=[];for(let e=1;e<s.length-1;e++)u.push(o.table[s[e]].node);return e.fromArray(function(e){return e.reduce(function(e,t){const n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(u))},e.rawSplit=function(t){return e.fromArray(d(t,a.isKanjiModeEnabled()))}}(pM);const TM=OP,RM=LP,NM=jP,LM=UP,BM=FP,jM=$P,DM=HP,UM=qP,FM=eM,$M=tM,zM=dM,HM=nM,qM=pM;function WM(e,t,n){const r=e.size,i=zM.getEncodedBits(t,n);let o,s;for(o=0;o<15;o++)s=1==(i>>o&1),o<6?e.set(o,8,s,!0):o<8?e.set(o+1,8,s,!0):e.set(r-15+o,8,s,!0),o<8?e.set(8,r-o-1,s,!0):o<9?e.set(8,15-o-1+1,s,!0):e.set(8,15-o-1,s,!0);e.set(r-8,8,1,!0)}function KM(e,t,n){const r=new NM;n.forEach(function(t){r.put(t.mode.bit,4),r.put(t.getLength(),HM.getCharCountIndicator(t.mode,e)),t.write(r)});const i=8*(TM.getSymbolTotalCodewords(e)-UM.getTotalCodewordsCount(e,t));for(r.getLengthInBits()+4<=i&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);const o=(i-r.getLengthInBits())/8;for(let s=0;s<o;s++)r.put(s%2?17:236,8);return function(e,t,n){const r=TM.getSymbolTotalCodewords(t),i=UM.getTotalCodewordsCount(t,n),o=r-i,s=UM.getBlocksCount(t,n),a=r%s,c=s-a,l=Math.floor(r/s),u=Math.floor(o/s),d=u+1,h=l-u,f=new FM(h);let p=0;const m=new Array(s),g=new Array(s);let y=0;const b=new Uint8Array(e.buffer);for(let x=0;x<s;x++){const e=x<c?u:d;m[x]=b.slice(p,p+e),g[x]=f.encode(m[x]),p+=e,y=Math.max(y,e)}const v=new Uint8Array(r);let w,E,_=0;for(w=0;w<y;w++)for(E=0;E<s;E++)w<m[E].length&&(v[_++]=m[E][w]);for(w=0;w<h;w++)for(E=0;E<s;E++)v[_++]=g[E][w];return v}(r,e,t)}function GM(e,t,n,r){let i;if(Array.isArray(e))i=qM.fromArray(e);else{if("string"!=typeof e)throw new Error("Invalid data");{let r=t;if(!r){const t=qM.rawSplit(e);r=$M.getBestVersionForData(t,n)}i=qM.fromString(e,r||40)}}const o=$M.getBestVersionForData(i,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(t){if(t<o)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+o+".\n")}else t=o;const s=KM(t,n,i),a=TM.getSymbolSize(t),c=new LM(a);return function(e,t){const n=e.size,r=jM.getPositions(t);for(let i=0;i<r.length;i++){const t=r[i][0],o=r[i][1];for(let r=-1;r<=7;r++)if(!(t+r<=-1||n<=t+r))for(let i=-1;i<=7;i++)o+i<=-1||n<=o+i||(r>=0&&r<=6&&(0===i||6===i)||i>=0&&i<=6&&(0===r||6===r)||r>=2&&r<=4&&i>=2&&i<=4?e.set(t+r,o+i,!0,!0):e.set(t+r,o+i,!1,!0))}}(c,t),function(e){const t=e.size;for(let n=8;n<t-8;n++){const t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}(c),function(e,t){const n=BM.getPositions(t);for(let r=0;r<n.length;r++){const t=n[r][0],i=n[r][1];for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)-2===n||2===n||-2===r||2===r||0===n&&0===r?e.set(t+n,i+r,!0,!0):e.set(t+n,i+r,!1,!0)}}(c,t),WM(c,n,0),t>=7&&function(e,t){const n=e.size,r=$M.getEncodedBits(t);let i,o,s;for(let a=0;a<18;a++)i=Math.floor(a/3),o=a%3+n-8-3,s=1==(r>>a&1),e.set(i,o,s,!0),e.set(o,i,s,!0)}(c,t),function(e,t){const n=e.size;let r=-1,i=n-1,o=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,a-n)){let r=!1;s<t.length&&(r=1==(t[s]>>>o&1)),e.set(i,a-n,r),o--,-1===o&&(s++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}(c,s),isNaN(r)&&(r=DM.getBestMask(c,WM.bind(null,c,n))),DM.applyMask(r,c),WM(c,n,r),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}MP.create=function(e,t){if(void 0===e||""===e)throw new Error("No input text");let n,r,i=RM.M;return void 0!==t&&(i=RM.from(t.errorCorrectionLevel,RM.M),n=$M.from(t.version),r=DM.from(t.maskPattern),t.toSJISFunc&&TM.setToSJISFunction(t.toSJISFunc)),GM(e,n,i,r)};var VM={},ZM={};!function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");const n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});const n=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,n){const r=e.getScale(t,n);return Math.floor((t+2*n.margin)*r)},e.qrToImageData=function(t,n,r){const i=n.modules.size,o=n.modules.data,s=e.getScale(i,r),a=Math.floor((i+2*r.margin)*s),c=r.margin*s,l=[r.color.light,r.color.dark];for(let e=0;e<a;e++)for(let n=0;n<a;n++){let u=4*(e*a+n),d=r.color.light;if(e>=c&&n>=c&&e<a-c&&n<a-c){d=l[o[Math.floor((e-c)/s)*i+Math.floor((n-c)/s)]?1:0]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}}(ZM),function(e){const t=ZM;e.render=function(e,n,r){let i=r,o=n;void 0!==i||n&&n.getContext||(i=n,n=void 0),n||(o=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),i=t.getOptions(i);const s=t.getImageWidth(e.modules.size,i),a=o.getContext("2d"),c=a.createImageData(s,s);return t.qrToImageData(c.data,e,i),function(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=n,t.width=n,t.style.height=n+"px",t.style.width=n+"px"}(a,o,s),a.putImageData(c,0,0),o},e.renderToDataURL=function(t,n,r){let i=r;void 0!==i||n&&n.getContext||(i=n,n=void 0),i||(i={});const o=e.render(t,n,i),s=i.type||"image/png",a=i.rendererOpts||{};return o.toDataURL(s,a.quality)}}(VM);var YM={};const JM=ZM;function QM(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function XM(e,t,n){let r=e+t;return void 0!==n&&(r+=" "+n),r}YM.render=function(e,t,n){const r=JM.getOptions(t),i=e.modules.size,o=e.modules.data,s=i+2*r.margin,a=r.color.light.a?"<path "+QM(r.color.light,"fill")+' d="M0 0h'+s+"v"+s+'H0z"/>':"",c="<path "+QM(r.color.dark,"stroke")+' d="'+function(e,t,n){let r="",i=0,o=!1,s=0;for(let a=0;a<e.length;a++){const c=Math.floor(a%t),l=Math.floor(a/t);c||o||(o=!0),e[a]?(s++,a>0&&c>0&&e[a-1]||(r+=o?XM("M",c+n,.5+l+n):XM("m",i,0),i=0,o=!1),c+1<t&&e[a+1]||(r+=XM("h",s),s=0)):i++}return r}(o,i,r.margin)+'"/>',l='viewBox="0 0 '+s+" "+s+'"',u='<svg xmlns="http://www.w3.org/2000/svg" '+(r.width?'width="'+r.width+'" height="'+r.width+'" ':"")+l+' shape-rendering="crispEdges">'+a+c+"</svg>\n";return"function"==typeof n&&n(null,u),u};const eO=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},tO=MP,nO=VM,rO=YM;function iO(e,t,n,r,i){const o=[].slice.call(arguments,1),s=o.length,a="function"==typeof o[s-1];if(!a&&!eO())throw new Error("Callback required as last argument");if(!a){if(s<1)throw new Error("Too few arguments provided");return 1===s?(n=t,t=r=void 0):2!==s||t.getContext||(r=n,n=t,t=void 0),new Promise(function(i,o){try{const o=tO.create(n,r);i(e(o,t,r))}catch(s){o(s)}})}if(s<2)throw new Error("Too few arguments provided");2===s?(i=n,n=t,t=r=void 0):3===s&&(t.getContext&&void 0===i?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0));try{const o=tO.create(n,r);i(null,e(o,t,r))}catch(c){i(c)}}PP.create=tO.create,PP.toCanvas=iO.bind(null,nO.render),PP.toDataURL=iO.bind(null,nO.renderToDataURL),PP.toString=iO.bind(null,function(e,t,n){return rO.render(e,n)});const oO={bitcoin:1,ethereum:1027,bsc:1839,polygon:3890,cardano:2010,avalanche:5805,fantom:3513,arbitrum:11841,optimism:11840,USDT:825,USDC:3408,BUSD:4687,DAI:4943,FRAX:6952,TUSD:2563,USDP:5992,USDD:5994,FDUSD:26081,PYUSD:28295,WBTC:3717,LINK:1975,UNI:7083,AAVE:7278,COMP:5692,YFI:5864,MKR:1518,SUSHI:6758,CRV:6538,SNX:2586,UMA:5617,BAL:5728,MANA:1966,SAND:6210,APE:18876,LDO:8e3,GRT:6719,ENS:13855,RPL:2943,SHIB:5994,MATIC:3890,BNB:1839,ADA:2010,SOL:5426,DOT:6636,AVAX:5805,TRX:1958,ALGO:4030,FTM:3513,ARB:11841,OP:11840,"1INCH":8104,DYDX:11156,ICP:8916,FIL:2280,CAKE:7186,RUNE:4157,ALPHA:7232,BNT:1727,KNC:1982,ZRX:1896,REN:2539,LRC:1934,WETH:2396,WMATIC:3890,WBNB:1839,UST:7129,USTC:7129,LUSD:8115,MIM:9681,FEI:8642,TRIBE:8741,RAI:8525,SUSD:2927},sO={ethereum:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",bsc:"https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png",polygon:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png",arbitrum:"https://s2.coinmarketcap.com/static/img/coins/64x64/11841.png",avalanche:"https://s2.coinmarketcap.com/static/img/coins/64x64/5805.png",celo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5567.png",optimism:"https://s2.coinmarketcap.com/static/img/coins/64x64/11840.png",base:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",eth:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",bnb:"https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png",trx:"https://s2.coinmarketcap.com/static/img/coins/64x64/1958.png",algo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",sol:"https://s2.coinmarketcap.com/static/img/coins/64x64/5426.png",matic:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png",arb:"https://s2.coinmarketcap.com/static/img/coins/64x64/11841.png",avax:"https://s2.coinmarketcap.com/static/img/coins/64x64/5805.png",op:"https://s2.coinmarketcap.com/static/img/coins/64x64/11840.png"},aO={metamask:"https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Fox.svg",coinbase:"https://avatars.githubusercontent.com/u/18060234?s=280&v=4",rabby:"https://rabby.io/logo-128.png",zerion:"https://app.zerion.io/favicon-32x32.png",phantom:"https://phantom.app/favicons/apple-touch-icon.png",trust:"https://trustwallet.com/favicon-196x196.png",okx:"https://static.okx.com/cdn/assets/imgs/248/58E63FEA47A2B7D7.png",binance:"https://bin.bnbstatic.com/static/images/common/favicon.ico",cryptocom:"https://crypto.com/favicon.ico",hot:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiNGRjZBNkEiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMmg0djhoLTR2LTJoMnYtNGgtMnYtMnptNiAwaDJ2MmgtdjdoLTJ2LTIiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg==",backpack:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiMwMEQ0QUEiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMGg4djJoLTJ2NmgtdjhoLTZWMTB6bTIgMnY0aDJWMTJ6IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4=","1inch":"https://1inch.io/favicon.svg",default:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiM2MzY2RjEiIHN0cm9rZT0iI0Y5RkFGQiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMmgxMnY4SDEweiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxLjUiIHJ4PSIxIi8+CjxjaXJjbGUgY3g9IjE4IiBjeT0iMTYiIHI9IjEiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg=="},cO=e=>(e=>{if(!e)return null;const t=oO[e.toUpperCase()];return t?`https://s2.coinmarketcap.com/static/img/coins/64x64/${t}.png`:null})(e),lO=(e,t)=>{const n=e.toLowerCase(),r=t.toLowerCase();for(const[i,o]of Object.entries(aO))if(n.includes(i)||r.includes(i))return o;return aO.default},uO=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),dO=e=>{switch(e){case"trust":return window.ethereum&&!0===window.ethereum.isTrust;case"metaMask":return window.ethereum&&!0===window.ethereum.isMetaMask;case"injected":return window.ethereum&&!window.ethereum.isMetaMask&&!window.ethereum.isCoinbaseWallet;default:return!1}},hO=(e,t)=>{if(!t)return console.warn("⚠️ No network selected"),[];if(!["ethereum","bsc","polygon","arbitrum","optimism","avalanche","celo","base"].includes(t.shortName))return console.warn("⚠️ Network not in EVM list:",t.shortName),[];return[...(e||[]).map(e=>(e=>({type:e.id,name:e.name,icon:lO(e.name,e.id),description:`Connect using ${e.name}`,isInstalled:!0,connector:e,isWagmi:!0}))(e)),...uO()?[{type:"trust",name:"Trust Wallet",icon:"🛡️",description:"Multi-chain wallet with transaction deep links",isInstalled:!1,connector:null,isWagmi:!1,mobileOnly:!0,hasTransactionDeepLinks:!0}]:[]]},fO=(e,t,n,r,i="metamask",o=null)=>{if(!e)return null;try{const t="https://paymentscreen.vercel.app",r=new URLSearchParams,o=(null==e?void 0:e.id)||(null==e?void 0:e.splitterPaymentId);if(!o)return console.error("❌ Cannot generate QR: No payment ID"),null;r.set("paymentId",o),r.set("preferredWallet",i),r.set("isMobile","true");const s=`${t}?${r.toString()}`;let a;switch(i){case"metamask":a=`https://metamask.app.link/dapp/${s.replace("https://","")}`;break;case"trust":const e=(null==n?void 0:n.chainId)||1;a=`https://link.trustwallet.com/open_url?coin_id=${(e=>{const t="string"==typeof e&&e.startsWith("0x")?parseInt(e,16):parseInt(e);return[1,56,137,42161,10,43114,42220,8453].includes(t)?60:{}[t]||60})(e)}&url=${encodeURIComponent(s)}`;break;case"coinbase":a=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(s)}`;break;default:a=s}return a}catch(s){return console.error("❌ Error generating QR payment URI:",s),null}},pO=(e,t)=>{if(!t)return null;try{switch(e){case"metamask":return t.includes("metamask.app.link")?t:`https://metamask.app.link/dapp/${t.replace("https://","")}`;case"trust":return t.includes("link.trustwallet.com")?t:`https://link.trustwallet.com/open_url?coin_id=60&url=${encodeURIComponent(t)}`;case"coinbase":return t.includes("go.cb-w.com")?t:`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(t)}`;default:return t}}catch(n){return console.error(`❌ Error generating ${e} deep link:`,n),t}},mO=Object.freeze(Object.defineProperty({__proto__:null,generateMobilePaymentDeepLink:pO,generateQRPaymentURI:fO},Symbol.toStringTag,{value:"Module"})),gO=({walletAddress:e,amount:t,currency:n,network:r,theme:i="light",paymentData:o=null,onPaymentDetected:s=null,config:a=null,selectedToken:c=null,selectedNetwork:l=null,preferredWallet:u="metamask",compact:d=!1})=>{const[h,f]=yt.useState(""),[p,m]=yt.useState(""),[g,y]=yt.useState(!0),[b,v]=yt.useState(!1),[w,E]=yt.useState(!1),_=yt.useRef(null);return yt.useEffect(()=>{(async()=>{if(!(null==o?void 0:o.id))return console.warn("⚠️ No payment data provided for QR code"),void y(!1);y(!0);try{if(!c||!c.contractAddress)throw console.error("❌ QR Code Error: selectedToken missing or incomplete:",c),new Error("Cannot generate QR code: Token contract address required");if(!l||!l.chainId)throw console.error("❌ QR Code Error: selectedNetwork missing or incomplete:",l),new Error("Cannot generate QR code: Network chain ID required");const e=fO(o,0,l,0,u);if(e.includes("metamask.app.link")||e.includes("link.trustwallet.com")||e.includes("go.cb-w.com"),!e)throw new Error("Failed to generate Coinley payment URL");f(e);const t=uO(),n=await PP.toDataURL(e,{width:d?140:t?350:280,margin:2,errorCorrectionLevel:"M",color:{dark:"dark"===i?"#FFFFFF":"#000000",light:"dark"===i?"#000000":"#FFFFFF"}});m(n),y(!1)}catch(e){console.error("❌ Failed to generate QR code:",e),y(!1)}})()},[o,t,n,r,i,c,l,a,u]),yt.useEffect(()=>()=>{_.current&&clearInterval(_.current)},[]),Dh.jsx("div",{className:"flex flex-col items-center",children:Dh.jsxs("div",{className:"flex gap-3 items-start w-full mb-2",children:[Dh.jsx("div",{className:"p-1.5 rounded-lg bg-white shadow-sm border flex-shrink-0",children:g?Dh.jsx("div",{className:"flex items-center justify-center",style:{width:140,height:140},children:Dh.jsxs("div",{className:"text-center",children:[Dh.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-purple-600 mx-auto mb-1"}),Dh.jsx("div",{className:"text-xs text-gray-600",children:"Generating..."})]})}):p?Dh.jsx("img",{src:p,alt:"Payment QR Code",className:"rounded-lg",style:{width:140,height:140}}):Dh.jsx("div",{className:"flex items-center justify-center bg-gray-100 rounded-lg",style:{width:140,height:140},children:Dh.jsxs("div",{className:"text-center p-2",children:[Dh.jsx("div",{className:"text-lg mb-1",children:"⚠️"}),Dh.jsx("div",{className:"text-xs text-gray-600",children:(null==o?void 0:o.id)?"QR Failed":"Payment not created"})]})})}),Dh.jsxs("div",{className:"flex-1 flex flex-col justify-center",children:[Dh.jsxs("div",{className:"p-2 bg-gray-50 rounded-lg mb-2",children:[Dh.jsxs("div",{className:"flex justify-between items-center mb-1",children:[Dh.jsx("span",{className:"text-xs font-medium text-gray-600",children:"Amount:"}),Dh.jsxs("span",{className:"text-sm font-bold text-[#7042D2]",children:[t," ",n]})]}),Dh.jsxs("div",{className:"flex justify-between items-center",children:[Dh.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Dh.jsx("span",{className:"text-xs font-medium text-gray-700",children:r})]})]}),w?Dh.jsxs("div",{className:"flex items-center justify-center text-xs font-semibold text-green-600 p-1.5 bg-green-50 rounded-lg",children:[Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Payment Received!"]}):Dh.jsx("div",{className:"p-1.5 rounded-lg bg-blue-50 border border-blue-200",children:Dh.jsx("p",{className:"text-xs text-blue-700 text-center leading-tight",children:"📱 Scan with phone camera"})})]})]})})},yO=({selectedNetwork:e,onWalletSelect:t,onConnect:n,connectedWallet:r,loading:i,paymentData:o=null,selectedToken:s=null,api:a=null})=>{const[c,l]=yt.useState(null),{connectors:u}=GI(),{isConnected:d,address:h}=AC(),f=hO(u,e),p=async(t,n)=>{if(uO())if(o)try{const{generateQRPaymentURI:r,generateMobilePaymentDeepLink:i}=await Promise.resolve().then(()=>mO),c=r(o,s,e,(null==a?void 0:a.config)||{},n);if(!c)throw new Error("Failed to generate payment URL");const l=i(n,c);if(!l)throw new Error(`Failed to generate ${t.name} deep link`);window.location.href=l}catch(r){console.error("❌ Mobile wallet connection failed:",r),alert(`Failed to open ${t.name}: ${r.message}`)}else alert("Please create a payment first before selecting a mobile wallet.");else alert(`Please install ${t.name} mobile app or use the browser extension if available.`)};return e?0===f.length?Dh.jsxs("div",{className:"text-center p-4",children:[Dh.jsxs("p",{className:"text-gray-500 mb-4",children:["No compatible wallets found for ",e.name]}),Dh.jsx("div",{className:"p-3 bg-amber-50 rounded-lg border border-amber-200",children:Dh.jsxs("div",{className:"text-sm text-amber-800",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[Dh.jsx("div",{className:"font-medium mb-2",children:"Install a compatible wallet:"}),Dh.jsxs("div",{className:"space-y-1 text-xs",children:[Dh.jsxs("div",{children:["• ",Dh.jsx("a",{href:"https://metamask.io/download/",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-900",children:"Install MetaMask Wallet"})]}),Dh.jsxs("div",{children:["• ",Dh.jsx("a",{href:"https://www.coinbase.com/wallet",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-900",children:"Install Coinbase Wallet"})]})]})]})})]}):Dh.jsxs("div",{className:"space-y-4",children:[Dh.jsxs("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Select Wallet for ",e.name]}),Dh.jsx(CP,{options:f,value:(null==r?void 0:r.walletType)||c||"",onChange:async e=>{l(e);const r=f.find(t=>t.type===e);r&&(t(e),r.isWagmi&&r.connector?await n(r.connector):r.isWagmi||await p(r,e))},placeholder:"Choose your wallet...",renderOption:e=>{var t,n;return Dh.jsxs("div",{className:"flex items-center space-x-3",children:[Dh.jsxs("div",{className:"w-8 h-8 flex items-center justify-center",children:[e.icon.startsWith("http")||e.icon.startsWith("data:")?Dh.jsx("img",{src:e.icon,alt:e.name,className:"w-6 h-6 rounded-full object-contain",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="block"}}):Dh.jsx("div",{className:"text-2xl",children:e.icon}),Dh.jsx("div",{className:"text-xl",style:{display:"none"},children:"🔗"})]}),Dh.jsxs("div",{className:"flex-1",children:[Dh.jsxs("div",{className:"font-semibold text-gray-800 flex items-center",children:[e.name,dO(e.type)&&Dh.jsx("span",{className:"ml-2 px-2 py-1 bg-blue-100 text-blue-700 text-xs rounded-full",children:"DETECTED"}),(null==r?void 0:r.walletType)===e.type&&Dh.jsx("span",{className:"ml-2 px-2 py-1 bg-green-100 text-green-700 text-xs rounded-full",children:"CONNECTED"})]}),Dh.jsx("div",{className:"text-sm text-gray-500",children:(null==r?void 0:r.walletType)===e.type?`Connected • ${null==(t=r.account)?void 0:t.slice(0,6)}...${null==(n=r.account)?void 0:n.slice(-4)}`:e.description})]}),i&&c===e.type&&Dh.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-[#7042D2]"})]})},getOptionKey:e=>e.type,getOptionValue:e=>e.type,getSearchableText:e=>`${e.name} ${e.description}`,disabled:i})]}):Dh.jsx("div",{className:"text-center p-4",children:Dh.jsx("p",{className:"text-gray-500",children:"Please select a network first"})})},bO=(()=>{if("undefined"!=typeof process&&process.env)return!1;if("undefined"!=typeof window){const e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e||e.includes("192.168.")}return!1})()||(()=>{if("undefined"!=typeof window){const e=new URLSearchParams(window.location.search);return"true"===e.get("debug")||"true"===e.get("debugMode")}return!1})(),vO=({paymentData:e,selectedToken:t,selectedNetwork:n,config:r,onPaymentStarted:i=()=>{},onError:o=()=>{}})=>{var s,a;const[c,l]=yt.useState(null),[u,d]=yt.useState(!1),[h,f]=yt.useState([]),[p,m]=yt.useState(!1),[g,y]=yt.useState(0);yt.useEffect(()=>{var r,i,o;(null==e?void 0:e.id)&&(null==t?void 0:t.contractAddress)&&(null==n?void 0:n.chainId)&&((null==(r=null==e?void 0:e.contractCall)?void 0:r.contractAddress)||(null==e?void 0:e.contractAddress))?b("success","✅ Payment data complete",{paymentId:e.id,tokenContract:t.contractAddress,chainId:n.chainId,paymentContract:(null==(o=null==e?void 0:e.contractCall)?void 0:o.contractAddress)||(null==e?void 0:e.contractAddress)}):(b("debug","⏳ Waiting for complete payment data",{hasPaymentId:!!(null==e?void 0:e.id),hasTokenContract:!!(null==t?void 0:t.contractAddress),hasChainId:!!(null==n?void 0:n.chainId),hasPaymentContract:!(!(null==(i=null==e?void 0:e.contractCall)?void 0:i.contractAddress)&&!(null==e?void 0:e.contractAddress)),checkCount:g}),y(e=>e+1))},[e,t,n,g]);const b=(e,t,n=null)=>{const r=(new Date).toLocaleTimeString(),i={id:Date.now()+Math.random(),type:e,message:t,data:n,timestamp:r};bO&&(f(e=>[...e,i].slice(-20)),e.toUpperCase())},v=[{id:"metamask",name:"MetaMask",icon:"🦊",description:"Connect with MetaMask mobile"},{id:"trust",name:"Trust Wallet",icon:"🛡️",description:"Connect with Trust Wallet"},{id:"coinbase",name:"Coinbase Wallet",icon:"💙",description:"Connect with Coinbase Wallet"}];if(!e)return Dh.jsx("div",{className:"p-4 bg-amber-50 rounded-lg border border-amber-200",children:Dh.jsxs("div",{className:"text-center",children:[Dh.jsx("div",{className:"text-amber-800 font-medium mb-2",children:"⚠️ Payment Required"}),Dh.jsx("div",{className:"text-sm text-amber-700",children:"Please create a payment before selecting a wallet"})]})});const w=(null==e?void 0:e.id)&&(null==t?void 0:t.contractAddress)&&(null==n?void 0:n.chainId)&&((null==(s=null==e?void 0:e.contractCall)?void 0:s.contractAddress)||(null==e?void 0:e.contractAddress));return Dh.jsx("div",{className:"space-y-4",children:w?Dh.jsxs(Dh.Fragment,{children:[Dh.jsxs("div",{className:"space-y-2",children:[Dh.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Select Mobile Wallet"}),Dh.jsx(CP,{options:v,value:c||"",onChange:async s=>{const a=v.find(e=>e.id===s);if(a){l(s),d(!0);try{if(b("info",`🚀 Mobile wallet selected: ${a.name}`),!e)throw new Error("Payment data not available. Please create payment first.");b("debug","🔍 Payment Data Check",{hasPaymentData:!!e,hasSelectedToken:!!t,hasSelectedNetwork:!!n,hasConfig:!!r,paymentId:(null==e?void 0:e.id)||(null==e?void 0:e.splitterPaymentId),tokenAddress:null==t?void 0:t.contractAddress,networkChainId:null==n?void 0:n.chainId,amount:(null==e?void 0:e.totalAmount)||(null==e?void 0:e.amount)||(null==r?void 0:r.amount)});const o=fO(e,0,n,0,s);if(!o)throw new Error("Failed to generate payment URL");b("success","📱 Generated payment URL",{url:o,length:o.length});const c=pO(s,o);if(!c)throw new Error(`Failed to generate ${a.name} deep link`);b("success",`🔗 Deep link generated for ${a.name}`,{deepLink:c}),i({walletType:s,walletName:a.name,paymentUrl:o,deepLink:c}),setTimeout(()=>{b("info",`📱 Opening ${a.name}...`),window.location.href=c},500)}catch(c){b("error","❌ Mobile wallet connection failed",{error:c.message,walletId:s,hasPaymentData:!!e,hasSelectedToken:!!t,hasSelectedNetwork:!!n}),o(c.message),d(!1),l(null)}}},placeholder:"Choose your wallet...",renderOption:e=>Dh.jsxs("div",{className:"flex items-center space-x-3",children:[Dh.jsx("div",{className:"w-8 h-8 flex items-center justify-center",children:Dh.jsx("div",{className:"text-2xl",children:e.icon})}),Dh.jsxs("div",{className:"flex-1",children:[Dh.jsxs("div",{className:"font-semibold text-gray-800",children:[e.name,c===e.id&&u&&Dh.jsx("span",{className:"ml-2 px-2 py-1 bg-blue-100 text-blue-700 text-xs rounded-full animate-pulse",children:"Opening..."})]}),Dh.jsx("div",{className:"text-sm text-gray-500",children:e.description})]})]}),getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.description}`,disabled:u}),Dh.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"Select a wallet to open it with your payment details"})]}),u&&c&&Dh.jsx("div",{className:"p-3 bg-blue-50 border border-blue-200 rounded-lg animate-pulse",children:Dh.jsxs("div",{className:"flex items-center space-x-2",children:[Dh.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-blue-600 border-t-transparent"}),Dh.jsxs("div",{className:"text-sm text-blue-700",children:["Opening ",null==(a=v.find(e=>e.id===c))?void 0:a.name,"..."]})]})}),Dh.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[Dh.jsxs("div",{className:"flex justify-between items-center text-sm",children:[Dh.jsx("span",{className:"text-gray-600",children:"Amount:"}),Dh.jsxs("span",{className:"font-semibold text-gray-800",children:[e.totalAmount," ",(null==t?void 0:t.symbol)||"USDC"]})]}),Dh.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[Dh.jsx("span",{className:"text-gray-600",children:"Network:"}),Dh.jsx("span",{className:"text-gray-800",children:(null==n?void 0:n.name)||"Ethereum"})]})]}),Dh.jsx("div",{className:"p-3 bg-purple-50 border border-purple-200 rounded-lg",children:Dh.jsxs("div",{className:"text-xs text-purple-700",children:[Dh.jsx("div",{className:"font-medium mb-1",children:"📱 Mobile Payment"}),Dh.jsx("div",{children:"Your selected wallet app will open with payment details pre-filled"})]})}),bO&&Dh.jsxs("div",{className:"mt-4",children:[Dh.jsxs("button",{onClick:()=>m(!p),className:"w-full text-xs py-2 px-3 bg-gray-100 text-gray-600 rounded-lg hover:bg-gray-200 transition-colors",children:[p?"🔽 Hide Debug Info":"🔧 Show Debug Info"," (",h.length," logs)"]}),p&&Dh.jsxs("div",{className:"mt-2 p-3 bg-gray-900 text-green-400 rounded-lg text-xs font-mono max-h-80 overflow-y-auto",children:[Dh.jsx("div",{className:"text-white mb-2 font-bold",children:"📱 Mobile Debug Panel"}),0===h.length?Dh.jsx("div",{className:"text-gray-400",children:"No debug logs yet. Try selecting a wallet..."}):h.map(e=>Dh.jsxs("div",{className:"mb-3 pb-2 border-b border-gray-700",children:[Dh.jsxs("div",{className:"flex items-center justify-between mb-1",children:[Dh.jsx("span",{className:"px-2 py-1 rounded text-xs font-bold "+("error"===e.type?"bg-red-600 text-white":"success"===e.type?"bg-green-600 text-white":"debug"===e.type?"bg-blue-600 text-white":"bg-gray-600 text-white"),children:e.type.toUpperCase()}),Dh.jsx("span",{className:"text-gray-400",children:e.timestamp})]}),Dh.jsx("div",{className:"text-yellow-300 mb-1",children:e.message}),e.data&&Dh.jsx("div",{className:"text-gray-300 text-xs",children:Dh.jsxs("details",{children:[Dh.jsx("summary",{className:"cursor-pointer text-blue-300 hover:text-blue-200",children:"📊 Data"}),Dh.jsx("pre",{className:"mt-1 p-2 bg-gray-800 rounded overflow-x-auto whitespace-pre-wrap",children:JSON.stringify(e.data,null,2)})]})})]},e.id)),Dh.jsx("button",{onClick:()=>f([]),className:"mt-2 px-3 py-1 bg-red-600 text-white rounded text-xs hover:bg-red-700",children:"Clear Logs"})]})]})]}):Dh.jsx("div",{className:"p-4 bg-amber-50 rounded-lg border border-amber-200",children:Dh.jsxs("div",{className:"text-center",children:[Dh.jsx("div",{className:"text-amber-800 font-medium mb-2",children:"⏳ Preparing Payment..."}),Dh.jsx("div",{className:"text-sm text-amber-700",children:"Payment is being prepared. Please wait a moment..."}),Dh.jsx("div",{className:"mt-3",children:Dh.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-amber-600 border-t-transparent mx-auto"})})]})})})},wO=({error:e,onRetry:t,onDismiss:n,context:r="payment",className:i=""})=>{if(!e)return null;const o=EP(e),s=(e=>{switch(e){case"user_rejected":return"info";case"insufficient_funds":case"wrong_network":case"wallet_disconnected":case"payment_pending":return"warning";case"network_error":case"gas_error":case"rate_limited":return"error";default:return"critical"}})(o.type),a=(e=>{switch(e){case"user_rejected":default:return"Try Again";case"insufficient_funds":return"Add Funds & Retry";case"wrong_network":return"Switch Network & Retry";case"wallet_disconnected":return"Reconnect Wallet";case"payment_pending":return"Check Again";case"network_error":case"rate_limited":return"Retry";case"popup_blocked":return"Allow Popups & Retry";case"mobile_wallet_error":return"Open Wallet App"}})(o.type),c={info:{container:"bg-blue-50 border-blue-200",title:"text-blue-800",message:"text-blue-700",icon:"ℹ️",button:"bg-blue-600 hover:bg-blue-700"},warning:{container:"bg-amber-50 border-amber-200",title:"text-amber-800",message:"text-amber-700",icon:"⚠️",button:"bg-amber-600 hover:bg-amber-700"},error:{container:"bg-red-50 border-red-200",title:"text-red-800",message:"text-red-700",icon:"❌",button:"bg-red-600 hover:bg-red-700"},critical:{container:"bg-red-50 border-red-300",title:"text-red-900",message:"text-red-800",icon:"🚨",button:"bg-red-700 hover:bg-red-800"}},l=c[s]||c.error;return Dh.jsxs("div",{className:`p-4 border rounded-lg ${l.container} ${i}`,children:[Dh.jsxs("div",{className:"flex items-start space-x-3",children:[Dh.jsx("div",{className:"flex-shrink-0 text-xl",children:l.icon}),Dh.jsxs("div",{className:"flex-1 min-w-0",children:[Dh.jsx("div",{className:`font-semibold ${l.title} mb-1`,children:o.title}),Dh.jsx("div",{className:`text-sm ${l.message} mb-2`,children:o.message}),o.suggestion&&Dh.jsxs("div",{className:`text-xs ${l.message} opacity-90`,children:["💡 ",o.suggestion]})]}),n&&Dh.jsx("button",{onClick:n,className:"flex-shrink-0 text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Dismiss error",children:Dh.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:Dh.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),t&&Dh.jsxs("div",{className:"mt-3 flex justify-end space-x-2",children:[n&&"info"===s&&Dh.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs text-gray-600 hover:text-gray-800 transition-colors",children:"Cancel"}),Dh.jsx("button",{onClick:t,className:`px-4 py-2 text-sm font-medium text-white rounded-md transition-colors ${l.button}`,children:a})]}),!1]})},EO="method",_O="confirm",xO="processing",kO="success",SO="wallet",CO="qr",IO="Bricolage Grotesque, sans-serif",AO=new AI,PO=({publicKey:e,apiKey:t,apiSecret:n,apiUrl:r,config:i,onSuccess:o,onError:s,onClose:a,isOpen:c,theme:l="light"})=>{const u=((e,t,n)=>{const[r,i]=yt.useState("method"),[o,s]=yt.useState([]),[a,c]=yt.useState([]),[l,u]=yt.useState(null),[d,h]=yt.useState(null),[f,p]=yt.useState(null),[m,g]=yt.useState(null),[y,b]=yt.useState(!1),[v,w]=yt.useState(""),[E,_]=yt.useState(!1),[x,k]=yt.useState("Processing transaction..."),[S,C]=yt.useState("wallet"),[I,A]=yt.useState(null),P=yt.useRef(new hP(e,t,n));return{currentStep:r,networks:o,tokens:a,selectedNetwork:l,selectedToken:d,paymentMethod:f,paymentData:m,loading:y,error:v,processing:E,processingMessage:x,paymentType:S,actualTransactionHash:I,setCurrentStep:i,setSelectedNetwork:u,setSelectedToken:h,setPaymentMethod:p,setError:w,setProcessing:_,setProcessingMessage:k,setPaymentType:C,setActualTransactionHash:A,loadData:async()=>{var e,t;try{b(!0),w("");const[n,r]=await Promise.all([P.current.getNetworks(),P.current.getTokens()]),i=(null==(e=n.networks)?void 0:e.reduce((e,t)=>{if("solana"===t.shortName||"tron"===t.shortName||"algorand"===t.shortName)return e;if(!t.chainId||null===t.chainId)return e;const n=`${t.chainId}-${t.shortName}`;return e.some(e=>`${e.chainId}-${e.shortName}`===n)||e.push(t),e},[]))||[],o=(null==(t=r.stablecoins)?void 0:t.reduce((e,t)=>{var n,r,i;if("USDC"!==t.symbol&&"USDT"!==t.symbol)return e;if("solana"===(null==(n=t.Network)?void 0:n.shortName)||"tron"===(null==(r=t.Network)?void 0:r.shortName)||"algorand"===(null==(i=t.Network)?void 0:i.shortName))return e;const o=`${t.symbol}-${t.networkId}`;return e.some(e=>`${e.symbol}-${e.networkId}`===o)||e.push(t),e},[]))||[];s(i),c(o)}catch(n){console.error("Failed to load data:",n),w("Failed to load payment options. Using fallback data.")}finally{b(!1)}},createPayment:async e=>{try{b(!0),w("");const t={amount:e.amount,currency:d.symbol,network:l.shortName,customerEmail:e.customerEmail,callbackUrl:e.callbackUrl,metadata:{...e.metadata,merchantWalletAddresses:e.merchantWalletAddresses,paymentMethod:f,selectedNetwork:l.shortName,selectedToken:d.symbol,wagmiEnabled:!0}},n=await P.current.createPayment(t);g(n.payment),i("confirm")}catch(t){console.error("Payment creation failed:",t),w(t.message)}finally{b(!1)}},failPayment:async(e="Payment cancelled by user")=>{if(null==m?void 0:m.id)try{await P.current.failPayment(m.id,e)}catch(t){console.error("❌ Failed to notify backend of payment cancellation:",t)}},resetState:()=>{i("method"),u(null),h(null),p(null),g(null),w(""),_(!1),A(null),C("wallet")},resetTransactionState:()=>{w(""),_(!1),A(null),i("confirm")},api:P.current}})(r,e||t,e?null:n),d=gP(),[h,f]=yt.useState("metamask"),[p,m]=yt.useState(!1),[g,y]=yt.useState(()=>!("undefined"==typeof window||!window.sessionStorage)&&"true"===sessionStorage.getItem("coinley_mobile_payment_started")),[b,v]=yt.useState(!1);yt.useEffect(()=>{m(uO())},[]);const{currentStep:w,networks:E,tokens:_,selectedNetwork:x,selectedToken:k,paymentData:S,loading:C,error:I,paymentType:A,loadData:P,createPayment:M,failPayment:O,resetState:T,setSelectedNetwork:R,setSelectedToken:N,setPaymentType:L,setCurrentStep:B,setError:j}=u,{connectedWallet:D,address:U,connectWallet:F,handleWalletSelection:$}=d,z=SP(S,k,x,U,u.api,d),{executePaymentTransaction:H,processFinalPayment:q,transactionStep:W,transactionError:K,currentTransactionHash:G}=z;yt.useEffect(()=>{w===kO&&"undefined"!=typeof window&&window.sessionStorage&&sessionStorage.removeItem("coinley_mobile_payment_started")},[w]),yt.useEffect(()=>{if(c){P(),T();const e=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${e}px`,document.body.style.width="100%",document.body.style.overflow="hidden"}else{const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,-1*parseInt(e||"0"))}return()=>{if(c){const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,-1*parseInt(e||"0"))}}},[c]),yt.useEffect(()=>{if("processing"===W||"approve"===W||"splitPayment"===W){const e=setTimeout(()=>{console.warn("⚠️ Transaction timeout - resetting state"),j("Transaction timed out. Please try again."),B(_O),z.resetTransaction()},12e4);return()=>clearTimeout(e)}},[W]);const V=async()=>{await O(),a()};return c?Dh.jsxs("div",{className:"fixed inset-0 z-50",children:[Dh.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:V,"aria-hidden":"true"}),Dh.jsx("div",{className:"fixed inset-0 flex items-center justify-center p-4",style:{zIndex:51},children:Dh.jsxs("div",{className:"relative pt-4 w-full max-w-md max-h-[90vh] mx-auto shadow-xl bg-gray-100 rounded-3xl flex flex-col overflow-hidden",style:{zIndex:52},children:[Dh.jsxs("div",{className:"flex-shrink-0 bg-white flex justify-between items-center mb-3 mr-3 ml-3 py-3 px-2 rounded-full",children:[Dh.jsxs("div",{className:"flex-1 flex items-center gap-2 px-4",children:[Dh.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center",children:Dh.jsx("img",{src:cP,alt:"Coinley"})}),Dh.jsx("span",{className:"text-base font-semibold text-gray-800",style:{fontFamily:IO},children:"Payment Details"})]}),w!==kO&&w!==xO&&Dh.jsx("button",{onClick:V,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i&&w!==kO&&Dh.jsx("div",{className:"flex-shrink-0 mb-3 px-4",children:Dh.jsxs("div",{className:"text-center",children:[Dh.jsx("div",{className:"text-xs text-gray-600",children:"Total Amount"}),Dh.jsxs("div",{className:"text-3xl font-bold text-[#7042D2] mt-1 leading-tight tracking-tight",style:{fontFamily:IO},children:["$",(Z=i.amount,parseFloat(Z).toFixed(2))]}),Dh.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"No additional fees"}),Dh.jsx("div",{className:"text-xs text-gray-600 mt-2",children:"Payment to:"}),Dh.jsxs("div",{className:"text-sm font-semibold mt-0.5 flex gap-1.5 items-center justify-center",style:{fontFamily:IO},children:[Dh.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Dh.jsx("path",{d:"M15.3 7.50065L15.8 10.0007H4.2L4.7 7.50065H15.3ZM16.6667 3.33398H3.33333V5.00065H16.6667V3.33398ZM16.6667 5.83398H3.33333L2.5 10.0007V11.6673H3.33333V16.6673H11.6667V11.6673H15V16.6673H16.6667V11.6673H17.5V10.0007L16.6667 5.83398ZM5 15.0007V11.6673H10V15.0007H5Z",fill:"#7042D2"})}),i.merchantName||"Merchant"]})]})}),Dh.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-contain",children:[Dh.jsx(IP,{currentStep:w,targetStep:EO,children:Dh.jsxs("div",{className:"pb-4 pt-3 px-5 bg-white rounded-t-2xl",children:[Dh.jsx("h3",{className:"font-semibold text-center mb-3 text-sm",style:{fontFamily:IO},children:"Choose Payment Method"}),Dh.jsxs("div",{className:"space-y-3 mb-4",children:[Dh.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:IO},children:"Select Network"}),Dh.jsx(CP,{options:E,value:(null==x?void 0:x.id)||"",onChange:e=>{const t=E.find(t=>t.id===e);R(t),N(null)},placeholder:"Choose your network...",renderOption:e=>{var t,n;const r="object"==typeof(i=e)&&(null==i?void 0:i.logo)?i.logo:"object"==typeof i&&(null==i?void 0:i.shortName)?sO[i.shortName.toLowerCase()]:"string"==typeof i?sO[i.toLowerCase()]:null;var i;return Dh.jsxs("div",{className:"flex items-center space-x-3",children:[r?Dh.jsx("img",{src:r,alt:e.name,className:"w-8 h-8 rounded-full",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="flex"}}):null,Dh.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center",style:{display:r?"none":"flex"},children:Dh.jsx("span",{className:"text-xs font-bold text-gray-600",children:null==(t=e.shortName)?void 0:t.slice(0,2).toUpperCase()})}),Dh.jsxs("div",{children:[Dh.jsx("div",{className:"font-semibold text-gray-800",children:e.name}),Dh.jsx("div",{className:"text-sm text-gray-500",children:null==(n=e.shortName)?void 0:n.toUpperCase()})]})]})},getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.shortName}`,disabled:C})]}),x&&Dh.jsxs("div",{className:"space-y-3 mb-4",children:[Dh.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:IO},children:"Select Token"}),Dh.jsx(CP,{options:_.filter(e=>{var t;return(null==(t=e.Network)?void 0:t.shortName)===(null==x?void 0:x.shortName)||e.networkId===(null==x?void 0:x.id)}),value:(null==k?void 0:k.id)||"",onChange:e=>{const t=_.filter(e=>{var t;return(null==(t=e.Network)?void 0:t.shortName)===(null==x?void 0:x.shortName)||e.networkId===(null==x?void 0:x.id)}).find(t=>t.id===e);N(t)},placeholder:"Choose your token...",renderOption:e=>{var t,n;const r=cO(e.symbol);return Dh.jsxs("div",{className:"flex items-center space-x-3",children:[r?Dh.jsx("img",{src:r,alt:e.symbol,className:"w-8 h-8 rounded-full",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="flex"}}):null,Dh.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center",style:{display:r?"none":"flex"},children:Dh.jsx("span",{className:"text-xs font-bold text-gray-600",children:null==(t=e.symbol)?void 0:t.slice(0,2)})}),Dh.jsxs("div",{children:[Dh.jsxs("div",{className:"font-semibold text-gray-800",children:[e.name," (",e.symbol,")"]}),Dh.jsxs("div",{className:"text-sm text-gray-500",children:[(null==(n=e.Network)?void 0:n.name)||"Unknown Network",e.isStablecoin&&Dh.jsx("span",{className:"ml-2 text-green-600",children:"• Stablecoin"})]})]})]})},getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.symbol}`,disabled:C})]}),x&&k&&Dh.jsx("button",{onClick:()=>M(i),disabled:C,className:"w-full bg-[#7042D2] text-white py-4 px-4 rounded-xl hover:bg-[#5b34b1] disabled:opacity-50 font-semibold transition-all duration-200 shadow-lg hover:shadow-xl",style:{fontFamily:IO},children:C?"Creating Payment...":"Continue"})]})}),Dh.jsx(IP,{currentStep:w,targetStep:_O,children:x&&k&&S&&Dh.jsxs("div",{className:"pb-4 pt-4 px-4 bg-white rounded-t-2xl",children:[!p&&Dh.jsx("div",{className:"mb-4",children:Dh.jsxs("div",{className:"flex border-b border-gray-200",children:[Dh.jsx("button",{onClick:()=>L(SO),className:"py-3 px-6 text-sm font-semibold transition-all duration-200 "+(A===SO?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),style:{fontFamily:IO},children:"Connect Wallet"}),Dh.jsx("button",{onClick:()=>L(CO),className:"py-3 px-6 text-sm font-semibold transition-all duration-200 "+(A===CO?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),style:{fontFamily:IO},children:"QR Code"})]})}),p?Dh.jsx(vO,{paymentData:S,selectedToken:k,selectedNetwork:x,config:i,onPaymentStarted:e=>{y(!0),"undefined"!=typeof window&&window.sessionStorage&&sessionStorage.setItem("coinley_mobile_payment_started","true"),e.walletName},onError:e=>{console.error("❌ Mobile payment error:",e),j(e)}}):A===SO?Dh.jsx(yO,{selectedNetwork:x,onWalletSelect:$,onConnect:async e=>{await F(e,x)},connectedWallet:D,loading:C}):null,A===CO&&Dh.jsxs(Dh.Fragment,{children:[Dh.jsxs("div",{className:"mb-2",children:[Dh.jsx("div",{className:"text-xs font-medium text-gray-600 mb-1.5 text-center",style:{fontFamily:IO},children:"Optimize QR for:"}),Dh.jsx("div",{className:"flex gap-1.5 justify-center flex-wrap",children:[{id:"metamask",name:"MetaMask",icon:"🦊"},{id:"trust",name:"Trust",icon:"🛡️"},{id:"coinbase",name:"Coinbase",icon:"💙"}].map(e=>Dh.jsxs("button",{onClick:()=>f(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all duration-200 "+(h===e.id?"bg-[#7042D2] text-white shadow-md":"bg-gray-100 text-gray-700 hover:bg-gray-200"),style:{fontFamily:IO},children:[Dh.jsx("span",{className:"text-sm",children:e.icon}),Dh.jsx("span",{children:e.name})]},e.id))})]}),Dh.jsx(gO,{amount:(null==S?void 0:S.totalAmount)||(null==S?void 0:S.amount)||(null==i?void 0:i.amount),currency:null==k?void 0:k.symbol,network:null==x?void 0:x.shortName,theme:l,paymentData:S,config:i,selectedToken:k,selectedNetwork:x,preferredWallet:h,compact:!0})]}),(I||K)&&Dh.jsx("div",{className:"mt-4",children:Dh.jsx(wO,{error:K||I,onRetry:()=>{j(""),z.resetTransaction(),"error"===W&&D&&H()},onDismiss:()=>{j(""),z.resetTransaction()},context:"payment"})}),Dh.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-4",children:[Dh.jsx("button",{type:"button",onClick:()=>B(EO),className:"w-full py-2.5 px-3 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-semibold rounded-xl transition-all duration-200 text-sm",style:{fontFamily:IO},children:"Back"}),Dh.jsx("button",{type:"button",onClick:async()=>{var e,t,n,r,i,s,a,c,l,d;if(p&&g){if(!(null==S?void 0:S.id))return void j("Payment ID not found. Please refresh and try again.");try{v(!0),B(xO),j("");const i=await u.api.checkPaymentStatus(S.id);if("completed"===(null==(e=i.payment)?void 0:e.status))B(kO),o&&o({paymentId:S.id,transactionHash:i.payment.transactionHash,paymentDetails:i.payment});else if("pending"===(null==(t=i.payment)?void 0:t.status)){const e=await u.api.verifyQRPayment(S.id);if(e.success&&e.verified)B(kO),o&&o({paymentId:S.id,transactionHash:null==(n=e.onChainData)?void 0:n.transactionHash,paymentDetails:e.payment});else{const t=e.message||"Payment not yet confirmed on blockchain";j(`${t}. Please complete the payment in your wallet and try again.`),B(_O)}}else"failed"===(null==(r=i.payment)?void 0:r.status)?(j("Payment failed. Please try creating a new payment."),B(_O)):(j("Payment not found. Please verify the payment ID and try again."),B(_O))}catch(h){console.error("❌ Mobile payment verification failed:",h),j(`Verification failed: ${h.message}. Please ensure payment was completed and try again.`),B(_O)}finally{v(!1)}}else if(A!==CO){if(D&&U)try{B(xO),j("");const e=await H();e&&(j(""),z.setTransactionError(""),B(kO),o&&o({paymentId:S.id,transactionHash:e,paymentDetails:S}))}catch(h){console.error("Transaction failed:",h),B(_O),(null==(l=h.message)?void 0:l.includes("User rejected"))||(null==(d=h.message)?void 0:d.includes("User denied"))||4001===h.code||"ACTION_REJECTED"===h.code?j("Transaction was cancelled by user. Please try again."):j(h.message||"Transaction failed. Please try again."),z.resetTransaction()}}else{if(!(null==S?void 0:S.id))return void j("Payment ID not found. Please refresh and try again.");try{B(xO),j("");const e=await u.api.checkPaymentStatus(S.id);if("completed"===(null==(i=e.payment)?void 0:i.status))B(kO),o&&o({paymentId:S.id,transactionHash:e.payment.transactionHash,paymentDetails:e.payment});else if("pending"===(null==(s=e.payment)?void 0:s.status)){const e=await u.api.verifyQRPayment(S.id);if(e.success&&e.verified)B(kO),o&&o({paymentId:S.id,transactionHash:null==(a=e.onChainData)?void 0:a.transactionHash,paymentDetails:e.payment});else{const t=e.message||"Payment not yet confirmed on blockchain";j(`${t}. Please complete the payment and try again.`),B(_O)}}else"failed"===(null==(c=e.payment)?void 0:c.status)?(j("Payment failed. Please try creating a new payment."),B(_O)):(j("Payment not found. Please verify the payment ID and try again."),B(_O))}catch(h){console.error("❌ QR payment verification failed:",h),j(`Verification failed: ${h.message}. Please ensure payment was completed and try again.`),B(_O)}}},className:"bg-green-600 text-white w-full py-2.5 px-3 font-semibold rounded-xl hover:bg-green-700 transition-all duration-200 shadow-lg hover:shadow-xl disabled:opacity-50 text-sm",disabled:A===SO&&!D&&!p||p&&!g||"processing"===W||b,style:{fontFamily:IO},children:b?"Verifying...":"processing"===W?"Processing...":p&&g?"I Have Paid":p?"Select Wallet":A===CO?"I Have Paid":"Pay Now"})]})]})}),Dh.jsx(IP,{currentStep:w,targetStep:xO,children:Dh.jsx(AP,{status:"processing",message:"approve"===W?"Approving token spending...":"splitPayment"===W?"Processing payment split...":G?"Confirming transaction on blockchain...":"Processing your payment...",theme:l,transactionHash:G,selectedNetwork:x})}),Dh.jsx(IP,{currentStep:w,targetStep:kO,children:Dh.jsx(AP,{status:"success",message:"Payment completed successfully!",theme:l,payment:S,transactionHash:G||(null==S?void 0:S.transactionHash),selectedPaymentMethod:k,selectedNetwork:x,merchantName:(null==i?void 0:i.merchantName)||"Merchant",onClose:a})}),(I||K)&&Dh.jsxs("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg mx-6 mb-4",children:[Dh.jsx("p",{className:"text-red-800 text-sm",children:I||K}),Dh.jsx("button",{onClick:()=>{j(""),z.setTransactionError("")},className:"mt-2 text-red-600 hover:text-red-800 text-xs underline",children:"Dismiss"})]})]}),w!==kO&&Dh.jsxs("div",{className:"text-center text-xs text-gray-500 flex items-center justify-center gap-1 py-6 bg-white rounded-b-3xl",style:{fontFamily:IO},children:[Dh.jsxs("p",{children:["Powered by ",Dh.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Coinley"})," - Multi-Wallet Support"]}),Dh.jsxs("svg",{className:"inline w-4 h-4 text-green-500 ml-1",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[Dh.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}),Dh.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})})]}):null;var Z},MO=e=>Dh.jsx(tC,{config:dP,children:Dh.jsx(DI,{client:AO,children:Dh.jsx(PO,{...e})})});class OO{constructor(e={}){if(!e.apiKey)throw new Error("CoinleyVanilla: apiKey is required");if(!e.apiSecret)throw new Error("CoinleyVanilla: apiSecret is required");if(!e.apiUrl)throw new Error("CoinleyVanilla: apiUrl is required");this.config={apiKey:e.apiKey,apiSecret:e.apiSecret,apiUrl:e.apiUrl.replace(/\/$/,""),theme:e.theme||"light",debug:e.debug||!1,...e},this.isOpen=!1,this.root=null,this.container=null,this.callbacks={},this.currentPayment=null,this.config.debug}open(e,t={}){if(this.isOpen)console.warn("⚠️ CoinleyVanilla: Payment modal is already open");else try{this._validatePaymentConfig(e),this.callbacks=t,this.currentPayment=e,this._createContainer(),this.root=Ih(this.container),this.isOpen=!0,this.root.render(bt.createElement(MO,{apiKey:this.config.apiKey,apiSecret:this.config.apiSecret,apiUrl:this.config.apiUrl,isOpen:!0,theme:this.config.theme,config:{amount:e.amount,customerEmail:e.customerEmail,merchantName:e.merchantName||"Merchant",callbackUrl:e.callbackUrl||this._getDefaultCallbackUrl(),merchantWalletAddresses:e.merchantWalletAddresses||{},preferredNetwork:e.preferredNetwork,preferredCurrency:e.preferredCurrency,metadata:{...e.metadata,source:"vanilla-sdk",sdkVersion:"2.0.0",timestamp:(new Date).toISOString()}},onSuccess:this._handleSuccess.bind(this),onError:this._handleError.bind(this),onClose:this._handleClose.bind(this)})),this.config.debug}catch(n){console.error("❌ CoinleyVanilla: Failed to open payment modal",n),t.onError&&t.onError(n.message||"Failed to open payment modal")}}close(){this.isOpen&&(this._cleanup(),this.config.debug)}isPaymentOpen(){return this.isOpen}updateConfig(e){this.config={...this.config,...e},this.config.debug}getConfig(){return{...this.config}}getCurrentPayment(){return this.currentPayment?{...this.currentPayment}:null}_validatePaymentConfig(e){if(!e)throw new Error("Payment configuration is required");if(!e.amount||"number"!=typeof e.amount||e.amount<=0)throw new Error("Valid amount (number > 0) is required");if(!e.customerEmail||"string"!=typeof e.customerEmail)throw new Error("Customer email is required");if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.customerEmail))throw new Error("Invalid email format");if(e.merchantWalletAddresses){if("object"!=typeof e.merchantWalletAddresses)throw new Error("merchantWalletAddresses must be an object");0===Object.keys(e.merchantWalletAddresses).length&&console.warn("⚠️ CoinleyVanilla: No merchant wallet addresses provided. Networks will be fetched from backend.")}}_createContainer(){this.container||(this.container=document.createElement("div"),this.container.id="coinley-payment-container",this.container.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 999999;\n ",document.body.appendChild(this.container))}_getDefaultCallbackUrl(){return"undefined"!=typeof window?`${window.location.origin}/api/webhooks/coinley`:""}_handleSuccess(e,t,n){this.config.debug,this.callbacks.onSuccess&&this.callbacks.onSuccess(e,t,n)}_handleError(e){this.config.debug&&console.error("❌ CoinleyVanilla: Payment error",e),this.callbacks.onError&&this.callbacks.onError(e)}_handleClose(){this._cleanup(),this.callbacks.onClose&&this.callbacks.onClose()}_cleanup(){if(this.isOpen=!1,this.root){try{this.root.unmount()}catch(e){console.error("Error unmounting React root:",e)}this.root=null}this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null),this.currentPayment=null}}function TO(){document.querySelectorAll('script[src*="coinley-vanilla"]').forEach(e=>{const t=e.getAttribute("data-api-key"),n=e.getAttribute("data-api-secret"),r=e.getAttribute("data-api-url"),i=e.getAttribute("data-theme")||"light",o=e.hasAttribute("data-debug");if(t&&n&&r)try{window.coinley=new OO({apiKey:t,apiSecret:n,apiUrl:r,theme:i,debug:o})}catch(s){console.error("❌ Failed to auto-initialize Coinley SDK:",s)}})}function RO(e,t){let n;try{n=e()}catch(r){return}return{getItem:e=>{var t;const r=e=>null===e?null:JSON.parse(e,void 0),i=null!=(t=n.getItem(e))?t:null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,t)=>n.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>n.removeItem(e)}}"undefined"!=typeof window&&(window.CoinleyVanilla=OO,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",TO):TO());const NO=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then:e=>NO(e)(n),catch(e){return this}}}catch(n){return{then(e){return this},catch:e=>NO(e)(n)}}},LO=(e,t)=>(n,r,i)=>{let o={storage:RO(()=>localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},s=!1;const a=new Set,c=new Set;let l=o.storage;if(!l)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...e)},r,i);const u=()=>{const e=o.partialize({...r()});return l.setItem(o.name,{state:e,version:o.version})},d=i.setState;i.setState=(e,t)=>{d(e,t),u()};const h=e((...e)=>{n(...e),u()},r,i);let f;i.getInitialState=()=>h;const p=()=>{var e,t;if(!l)return;s=!1,a.forEach(e=>{var t;return e(null!=(t=r())?t:h)});const i=(null==(t=o.onRehydrateStorage)?void 0:t.call(o,null!=(e=r())?e:h))||void 0;return NO(l.getItem.bind(l))(o.name).then(e=>{if(e){if("number"!=typeof e.version||e.version===o.version)return[!1,e.state];if(o.migrate){const t=o.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;const[i,s]=e;if(f=o.merge(s,null!=(t=r())?t:h),n(f,!0),i)return u()}).then(()=>{null==i||i(f,void 0),f=r(),s=!0,c.forEach(e=>e(f))}).catch(e=>{null==i||i(void 0,e)})};return i.persist={setOptions:e=>{o={...o,...e},e.storage&&(l=e.storage)},clearStorage:()=>{null==l||l.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>p(),hasHydrated:()=>s,onHydrate:e=>(a.add(e),()=>{a.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},o.skipHydration||p(),f||h},BO=e=>{let t;const n=new Set,r=(e,r)=>{const i="function"==typeof e?e(t):e;if(!Object.is(i,t)){const e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>s,subscribe:e=>(n.add(e),()=>n.delete(e))},s=t=e(r,i,o);return o},jO=e=>e?BO(e):BO;var DO,UO,FO,$O,zO,HO,qO,WO,KO,GO,VO,ZO,YO={},JO=[],QO=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,XO=Array.isArray;function eT(e,t){for(var n in t)e[n]=t[n];return e}function tT(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function nT(e,t,n){var r,i,o,s={};for(o in t)"key"==o?r=t[o]:"ref"==o?i=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?DO.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===s[o]&&(s[o]=e.defaultProps[o]);return rT(e,s,r,i,null)}function rT(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==i?++FO:i,__i:-1,__u:0};return null==i&&null!=UO.vnode&&UO.vnode(o),o}function iT(e){return e.children}function oT(e,t){this.props=e,this.context=t}function sT(e,t){if(null==t)return e.__?sT(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?sT(e):null}function aT(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return aT(e)}}function cT(e){(!e.__d&&(e.__d=!0)&&zO.push(e)&&!lT.__r++||HO!==UO.debounceRendering)&&((HO=UO.debounceRendering)||qO)(lT)}function lT(){var e,t,n,r,i,o,s,a;for(zO.sort(WO);e=zO.shift();)e.__d&&(t=zO.length,r=void 0,o=(i=(n=e).__v).__e,s=[],a=[],n.__P&&((r=eT({},i)).__v=i.__v+1,UO.vnode&&UO.vnode(r),gT(n.__P,r,i,n.__n,n.__P.namespaceURI,32&i.__u?[o]:null,s,null==o?sT(i):o,!!(32&i.__u),a),r.__v=i.__v,r.__.__k[r.__i]=r,yT(s,r,a),r.__e!=o&&aT(r)),zO.length>t&&zO.sort(WO));lT.__r=0}function uT(e,t,n,r,i,o,s,a,c,l,u){var d,h,f,p,m,g=r&&r.__k||JO,y=t.length;for(n.__d=c,function(e,t,n){var r,i,o,s,a,c=t.length,l=n.length,u=l,d=0;for(e.__k=[],r=0;r<c;r++)null!=(i=t[r])&&"boolean"!=typeof i&&"function"!=typeof i?(s=r+d,(i=e.__k[r]="string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?rT(null,i,null,null,null):XO(i)?rT(iT,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?rT(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=e,i.__b=e.__b+1,o=null,-1!==(a=i.__i=hT(i,n,s,u))&&(u--,(o=n[a])&&(o.__u|=131072)),null==o||null===o.__v?(-1==a&&d--,"function"!=typeof i.type&&(i.__u|=65536)):a!==s&&(a==s-1?d--:a==s+1?d++:(a>s?d--:d++,i.__u|=65536))):i=e.__k[r]=null;if(u)for(r=0;r<l;r++)null!=(o=n[r])&&!(131072&o.__u)&&(o.__e==e.__d&&(e.__d=sT(o)),vT(o,o))}(n,t,g),c=n.__d,d=0;d<y;d++)null!=(f=n.__k[d])&&(h=-1===f.__i?YO:g[f.__i]||YO,f.__i=d,gT(e,f,h,i,o,s,a,c,l,u),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&bT(h.ref,null,f),u.push(f.ref,f.__c||p,f)),null==m&&null!=p&&(m=p),65536&f.__u||h.__k===f.__k?c=dT(f,c,e):"function"==typeof f.type&&void 0!==f.__d?c=f.__d:p&&(c=p.nextSibling),f.__d=void 0,f.__u&=-196609);n.__d=c,n.__e=m}function dT(e,t,n){var r,i;if("function"==typeof e.type){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=dT(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!n.contains(t)&&(t=sT(e)),n.insertBefore(e.__e,t||null),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8===t.nodeType);return t}function hT(e,t,n,r){var i=e.key,o=e.type,s=n-1,a=n+1,c=t[n];if(null===c||c&&i==c.key&&o===c.type&&!(131072&c.__u))return n;if(r>(null==c||131072&c.__u?0:1))for(;s>=0||a<t.length;){if(s>=0){if((c=t[s])&&!(131072&c.__u)&&i==c.key&&o===c.type)return s;s--}if(a<t.length){if((c=t[a])&&!(131072&c.__u)&&i==c.key&&o===c.type)return a;a++}}return-1}function fT(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||QO.test(t)?n:n+"px"}function pT(e,t,n,r,i){var o;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||fT(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||fT(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])o=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e||"onFocusOut"===t||"onFocusIn"===t?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n.u=r.u:(n.u=KO,e.addEventListener(t,o?VO:GO,o)):e.removeEventListener(t,o?VO:GO,o);else{if("http://www.w3.org/2000/svg"==i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(s){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function mT(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t.t)t.t=KO++;else if(t.t<n.u)return;return n(UO.event?UO.event(t):t)}}}function gT(e,t,n,r,i,o,s,a,c,l){var u,d,h,f,p,m,g,y,b,v,w,E,_,x,k,S,C=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(c=!!(32&n.__u),o=[a=t.__e=n.__e]),(u=UO.__b)&&u(t);e:if("function"==typeof C)try{if(y=t.props,b="prototype"in C&&C.prototype.render,v=(u=C.contextType)&&r[u.__c],w=u?v?v.props.value:u.__:r,n.__c?g=(d=t.__c=n.__c).__=d.__E:(b?t.__c=d=new C(y,w):(t.__c=d=new oT(y,w),d.constructor=C,d.render=wT),v&&v.sub(d),d.props=y,d.state||(d.state={}),d.context=w,d.__n=r,h=d.__d=!0,d.__h=[],d._sb=[]),b&&null==d.__s&&(d.__s=d.state),b&&null!=C.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=eT({},d.__s)),eT(d.__s,C.getDerivedStateFromProps(y,d.__s))),f=d.props,p=d.state,d.__v=t,h)b&&null==C.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),b&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(b&&null==C.getDerivedStateFromProps&&y!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(y,w),!d.__e&&(null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(y,d.__s,w)||t.__v===n.__v)){for(t.__v!==n.__v&&(d.props=y,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),E=0;E<d._sb.length;E++)d.__h.push(d._sb[E]);d._sb=[],d.__h.length&&s.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(y,d.__s,w),b&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(f,p,m)})}if(d.context=w,d.props=y,d.__P=e,d.__e=!1,_=UO.__r,x=0,b){for(d.state=d.__s,d.__d=!1,_&&_(t),u=d.render(d.props,d.state,d.context),k=0;k<d._sb.length;k++)d.__h.push(d._sb[k]);d._sb=[]}else do{d.__d=!1,_&&_(t),u=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++x<25);d.state=d.__s,null!=d.getChildContext&&(r=eT(eT({},r),d.getChildContext())),b&&!h&&null!=d.getSnapshotBeforeUpdate&&(m=d.getSnapshotBeforeUpdate(f,p)),uT(e,XO(S=null!=u&&u.type===iT&&null==u.key?u.props.children:u)?S:[S],t,n,r,i,o,s,a,c,l),d.base=t.__e,t.__u&=-161,d.__h.length&&s.push(d),g&&(d.__E=d.__=null)}catch(I){if(t.__v=null,c||null!=o){for(t.__u|=c?160:32;a&&8===a.nodeType&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,t.__e=a}else t.__e=n.__e,t.__k=n.__k;UO.__e(I,t,n)}else null==o&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=function(e,t,n,r,i,o,s,a,c){var l,u,d,h,f,p,m,g=n.props,y=t.props,b=t.type;if("svg"===b?i="http://www.w3.org/2000/svg":"math"===b?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=o)for(l=0;l<o.length;l++)if((f=o[l])&&"setAttribute"in f==!!b&&(b?f.localName===b:3===f.nodeType)){e=f,o[l]=null;break}if(null==e){if(null===b)return document.createTextNode(y);e=document.createElementNS(i,b,y.is&&y),a&&(UO.__m&&UO.__m(t,o),a=!1),o=null}if(null===b)g===y||a&&e.data===y||(e.data=y);else{if(o=o&&DO.call(e.childNodes),g=n.props||YO,!a&&null!=o)for(g={},l=0;l<e.attributes.length;l++)g[(f=e.attributes[l]).name]=f.value;for(l in g)if(f=g[l],"children"==l);else if("dangerouslySetInnerHTML"==l)d=f;else if(!(l in y)){if("value"==l&&"defaultValue"in y||"checked"==l&&"defaultChecked"in y)continue;pT(e,l,null,f,i)}for(l in y)f=y[l],"children"==l?h=f:"dangerouslySetInnerHTML"==l?u=f:"value"==l?p=f:"checked"==l?m=f:a&&"function"!=typeof f||g[l]===f||pT(e,l,f,g[l],i);if(u)a||d&&(u.__html===d.__html||u.__html===e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),uT(e,XO(h)?h:[h],t,n,r,"foreignObject"===b?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&sT(n,0),a,c),null!=o)for(l=o.length;l--;)tT(o[l]);a||(l="value","progress"===b&&null==p?e.removeAttribute("value"):void 0!==p&&(p!==e[l]||"progress"===b&&!p||"option"===b&&p!==g[l])&&pT(e,l,p,g[l],i),l="checked",void 0!==m&&m!==e[l]&&pT(e,l,m,g[l],i))}return e}(n.__e,t,n,r,i,o,s,c,l);(u=UO.diffed)&&u(t)}function yT(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)bT(n[r],n[++r],n[++r]);UO.__c&&UO.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(n){UO.__e(n,t.__v)}})}function bT(e,t,n){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==t||(e.__u=e(t))}else e.current=t}catch(i){UO.__e(i,n)}}function vT(e,t,n){var r,i;if(UO.unmount&&UO.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||bT(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){UO.__e(o,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&vT(r[i],t,n||"function"!=typeof e.type);n||tT(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function wT(e,t,n){return this.constructor(e,n)}function ET(e,t,n){var r,i,o,s;UO.__&&UO.__(e,t),i=(r="function"==typeof n)?null:n&&n.__k||t.__k,o=[],s=[],gT(t,e=(!r&&n||t).__k=nT(iT,null,[e]),i||YO,YO,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?DO.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,s),yT(o,e,s)}DO=JO.slice,UO={__e:function(e,t,n,r){for(var i,o,s;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(e)),s=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),s=i.__d),s)return i.__E=i}catch(a){e=a}throw e}},FO=0,$O=function(e){return null!=e&&null==e.constructor},oT.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=eT({},this.state),"function"==typeof e&&(e=e(eT({},n),this.props)),e&&eT(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),cT(this))},oT.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),cT(this))},oT.prototype.render=iT,zO=[],qO="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,WO=function(e,t){return e.__v.__b-t.__v.__b},lT.__r=0,KO=0,GO=mT(!1),VO=mT(!0),ZO=0;const _T=Object.freeze(Object.defineProperty({__proto__:null,Component:oT,Fragment:iT,cloneElement:function(e,t,n){var r,i,o,s,a=eT({},e.props);for(o in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)"key"==o?r=t[o]:"ref"==o?i=t[o]:a[o]=void 0===t[o]&&void 0!==s?s[o]:t[o];return arguments.length>2&&(a.children=arguments.length>3?DO.call(arguments,2):n),rT(e.type,a,r||e.key,i||e.ref,null)},createContext:function(e,t){var n={__c:t="__cC"+ZO++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var n,r;return this.getChildContext||(n=[],(r={})[t]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&n.some(function(e){e.__e=!0,cT(e)})},this.sub=function(e){n.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.splice(n.indexOf(e),1),t&&t.call(e)}}),e.children}};return n.Provider.__=n.Consumer.contextType=n},createElement:nT,createRef:function(){return{current:null}},h:nT,hydrate:function e(t,n){ET(t,n,e)},get isValidElement(){return $O},get options(){return UO},render:ET,toChildArray:function e(t,n){return n=n||[],null==t||"boolean"==typeof t||(XO(t)?t.some(function(t){e(t,n)}):n.push(t)),n}},Symbol.toStringTag,{value:"Module"}));function xT(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=xT(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function kT(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=xT(e))&&(r&&(r+=" "),r+=t);return r}const ST=Object.freeze(Object.defineProperty({__proto__:null,clsx:kT,default:kT},Symbol.toStringTag,{value:"Module"}));var CT,IT,AT,PT,MT=0,OT=[],TT=UO,RT=TT.__b,NT=TT.__r,LT=TT.diffed,BT=TT.__c,jT=TT.unmount,DT=TT.__;function UT(e,t){TT.__h&&TT.__h(IT,e,MT||t),MT=0;var n=IT.__H||(IT.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function FT(e){return MT=1,$T(JT,e)}function $T(e,t,n){var r=UT(CT++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):JT(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=IT,!IT.u)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!o||o.call(this,e,t,n);var s=!1;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}}),!(!s&&r.__c.props===e)&&(!o||o.call(this,e,t,n))};IT.u=!0;var o=IT.shouldComponentUpdate,s=IT.componentWillUpdate;IT.componentWillUpdate=function(e,t,n){if(this.__e){var r=o;o=void 0,i(e,t,n),o=r}s&&s.call(this,e,t,n)},IT.shouldComponentUpdate=i}return r.__N||r.__}function zT(e,t){var n=UT(CT++,3);!TT.__s&&YT(n.__H,t)&&(n.__=e,n.i=t,IT.__H.__h.push(n))}function HT(e,t){var n=UT(CT++,4);!TT.__s&&YT(n.__H,t)&&(n.__=e,n.i=t,IT.__h.push(n))}function qT(e,t){var n=UT(CT++,7);return YT(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function WT(){for(var e;e=OT.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(VT),e.__H.__h.forEach(ZT),e.__H.__h=[]}catch(Gle){e.__H.__h=[],TT.__e(Gle,e.__v)}}TT.__b=function(e){IT=null,RT&&RT(e)},TT.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),DT&&DT(e,t)},TT.__r=function(e){NT&&NT(e),CT=0;var t=(IT=e.__c).__H;t&&(AT===IT?(t.__h=[],IT.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.i=e.__N=void 0})):(t.__h.forEach(VT),t.__h.forEach(ZT),t.__h=[],CT=0)),AT=IT},TT.diffed=function(e){LT&&LT(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==OT.push(t)&&PT===TT.requestAnimationFrame||((PT=TT.requestAnimationFrame)||GT)(WT)),t.__H.__.forEach(function(e){e.i&&(e.__H=e.i),e.i=void 0})),AT=IT=null},TT.__c=function(e,t){t.some(function(e){try{e.__h.forEach(VT),e.__h=e.__h.filter(function(e){return!e.__||ZT(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],TT.__e(n,e.__v)}}),BT&&BT(e,t)},TT.unmount=function(e){jT&&jT(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{VT(e)}catch(n){t=n}}),n.__H=void 0,t&&TT.__e(t,n.__v))};var KT="function"==typeof requestAnimationFrame;function GT(e){var t,n=function(){clearTimeout(r),KT&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);KT&&(t=requestAnimationFrame(n))}function VT(e){var t=IT,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),IT=t}function ZT(e){var t=IT;e.__c=e.__(),IT=t}function YT(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function JT(e,t){return"function"==typeof t?t(e):t}const QT=Object.freeze(Object.defineProperty({__proto__:null,useCallback:function(e,t){return MT=8,qT(function(){return e},t)},useContext:function(e){var t=IT.context[e.__c],n=UT(CT++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(IT)),t.props.value):e.__},useDebugValue:function(e,t){TT.useDebugValue&&TT.useDebugValue(t?t(e):e)},useEffect:zT,useErrorBoundary:function(e){var t=UT(CT++,10),n=FT();return t.__=e,IT.componentDidCatch||(IT.componentDidCatch=function(e,r){t.__&&t.__(e,r),n[1](e)}),[n[0],function(){n[1](void 0)}]},useId:function(){var e=UT(CT++,11);if(!e.__){for(var t=IT.__v;null!==t&&!t.__m&&null!==t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__},useImperativeHandle:function(e,t,n){MT=6,HT(function(){return"function"==typeof e?(e(t()),function(){return e(null)}):e?(e.current=t(),function(){return e.current=null}):void 0},null==n?n:n.concat(e))},useLayoutEffect:HT,useMemo:qT,useReducer:$T,useRef:function(e){return MT=5,qT(function(){return{current:e}},[])},useState:FT},Symbol.toStringTag,{value:"Module"})),XT=[{inputs:[{name:"preOpGas",type:"uint256"},{name:"paid",type:"uint256"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"targetSuccess",type:"bool"},{name:"targetResult",type:"bytes"}],name:"ExecutionResult",type:"error"},{inputs:[{name:"opIndex",type:"uint256"},{name:"reason",type:"string"}],name:"FailedOp",type:"error"},{inputs:[{name:"sender",type:"address"}],name:"SenderAddressResult",type:"error"},{inputs:[{name:"aggregator",type:"address"}],name:"SignatureValidationFailed",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"}],name:"ValidationResult",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"},{components:[{name:"aggregator",type:"address"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"stakeInfo",type:"tuple"}],name:"aggregatorInfo",type:"tuple"}],name:"ValidationResultWithAggregation",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"factory",type:"address"},{indexed:!1,name:"paymaster",type:"address"}],name:"AccountDeployed",type:"event"},{anonymous:!1,inputs:[],name:"BeforeExecution",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalDeposit",type:"uint256"}],name:"Deposited",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"aggregator",type:"address"}],name:"SignatureAggregatorChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalStaked",type:"uint256"},{indexed:!1,name:"unstakeDelaySec",type:"uint256"}],name:"StakeLocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawTime",type:"uint256"}],name:"StakeUnlocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"StakeWithdrawn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!0,name:"paymaster",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"success",type:"bool"},{indexed:!1,name:"actualGasCost",type:"uint256"},{indexed:!1,name:"actualGasUsed",type:"uint256"}],name:"UserOperationEvent",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"revertReason",type:"bytes"}],name:"UserOperationRevertReason",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"Withdrawn",type:"event"},{inputs:[],name:"SIG_VALIDATION_FAILED",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"},{name:"sender",type:"address"},{name:"paymasterAndData",type:"bytes"}],name:"_validateSenderAndPaymaster",outputs:[],stateMutability:"view",type:"function"},{inputs:[{name:"unstakeDelaySec",type:"uint32"}],name:"addStake",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"depositTo",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"",type:"address"}],name:"deposits",outputs:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"getDepositInfo",outputs:[{components:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],name:"info",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{name:"sender",type:"address"},{name:"key",type:"uint192"}],name:"getNonce",outputs:[{name:"nonce",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"}],name:"getSenderAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOps",type:"tuple[]"},{name:"aggregator",type:"address"},{name:"signature",type:"bytes"}],name:"opsPerAggregator",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleAggregatedOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"ops",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"key",type:"uint192"}],name:"incrementNonce",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"callData",type:"bytes"},{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"paymaster",type:"address"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"}],name:"mUserOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"prefund",type:"uint256"},{name:"contextOffset",type:"uint256"},{name:"preOpGas",type:"uint256"}],name:"opInfo",type:"tuple"},{name:"context",type:"bytes"}],name:"innerHandleOp",outputs:[{name:"actualGasCost",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"",type:"address"},{name:"",type:"uint192"}],name:"nonceSequenceNumber",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"op",type:"tuple"},{name:"target",type:"address"},{name:"targetCallData",type:"bytes"}],name:"simulateHandleOp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"simulateValidation",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unlockStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"}],name:"withdrawStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"},{name:"withdrawAmount",type:"uint256"}],name:"withdrawTo",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}];function eR(e){const{authorization:t,factory:n,factoryData:r}=e;if("0x7702"===n||"0x7702000000000000000000000000000000000000"===n){if(!t)return"0x7702000000000000000000000000000000000000";return rm([t.address,r??"0x"])}return n?rm([n,r??"0x"]):"0x"}function tR(e){const{callGasLimit:t,callData:n,maxPriorityFeePerGas:r,maxFeePerGas:i,paymaster:o,paymasterData:s,paymasterPostOpGasLimit:a,paymasterVerificationGasLimit:c,sender:l,signature:u="0x",verificationGasLimit:d}=e;return{accountGasLimits:rm([Rf(Vf(d||0n),{size:16}),Rf(Vf(t||0n),{size:16})]),callData:n,initCode:eR(e),gasFees:rm([Rf(Vf(r||0n),{size:16}),Rf(Vf(i||0n),{size:16})]),nonce:e.nonce??0n,paymasterAndData:o?rm([o,Rf(Vf(c||0n),{size:16}),Rf(Vf(a||0n),{size:16}),s||"0x"]):"0x",preVerificationGas:e.preVerificationGas??0n,sender:l,signature:u}}const nR={PackedUserOperation:[{type:"address",name:"sender"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"bytes32",name:"accountGasLimits"},{type:"uint256",name:"preVerificationGas"},{type:"bytes32",name:"gasFees"},{type:"bytes",name:"paymasterAndData"}]};function rR(e){const{chainId:t,entryPointAddress:n,entryPointVersion:r}=e,i=e.userOperation,{authorization:o,callData:s="0x",callGasLimit:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,paymasterAndData:d="0x",preVerificationGas:h,sender:f,verificationGasLimit:p}=i;if("0.8"===r)return S_(function(e){const{chainId:t,entryPointAddress:n,userOperation:r}=e,i=tR(r);return{types:nR,primaryType:"PackedUserOperation",domain:{name:"ERC4337",version:"1",chainId:t,verifyingContract:n},message:i}}({chainId:t,entryPointAddress:n,userOperation:i}));const m=(()=>{var e,t;if("0.6"===r){const n=null==(e=i.initCode)?void 0:e.slice(0,42),r=null==(t=i.initCode)?void 0:t.slice(42),m=eR({authorization:o,factory:n,factoryData:r});return cm([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"bytes32"}],[f,u,Bp(m),Bp(s),a,p,h,c,l,Bp(d)])}if("0.7"===r){const e=tR(i);return cm([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[e.sender,e.nonce,Bp(e.initCode),Bp(e.callData),e.accountGasLimits,e.preVerificationGas,e.gasFees,Bp(e.paymasterAndData)])}throw new Error(`entryPointVersion "${r}" not supported.`)})();return Bp(cm([{type:"bytes32"},{type:"address"},{type:"uint256"}],[Bp(m),n,BigInt(t)]))}class iR extends tf{constructor({cause:e}){super("Smart Account is not deployed.",{cause:e,metaMessages:["This could arise when:","- No `factory`/`factoryData` or `initCode` properties are provided for Smart Account deployment.","- An incorrect `sender` address is provided."],name:"AccountNotDeployedError"})}}Object.defineProperty(iR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa20/});class oR extends tf{constructor({cause:e,data:t,message:n}={}){var r;const i=null==(r=null==n?void 0:n.replace("execution reverted: ",""))?void 0:r.replace("execution reverted","");super(`Execution reverted ${i?`with reason: ${i}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t}}Object.defineProperty(oR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32521}),Object.defineProperty(oR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class sR extends tf{constructor({cause:e}){super("Failed to send funds to beneficiary.",{cause:e,name:"FailedToSendToBeneficiaryError"})}}Object.defineProperty(sR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa91/});class aR extends tf{constructor({cause:e}){super("Gas value overflowed.",{cause:e,metaMessages:["This could arise when:","- one of the gas values exceeded 2**120 (uint120)"].filter(Boolean),name:"GasValuesOverflowError"})}}Object.defineProperty(aR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa94/});class cR extends tf{constructor({cause:e}){super("The `handleOps` function was called by the Bundler with a gas limit too low.",{cause:e,name:"HandleOpsOutOfGasError"})}}Object.defineProperty(cR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa95/});class lR extends tf{constructor({cause:e,factory:t,factoryData:n,initCode:r}){super("Failed to simulate deployment for Smart Account.",{cause:e,metaMessages:["This could arise when:","- Invalid `factory`/`factoryData` or `initCode` properties are present","- Smart Account deployment execution ran out of gas (low `verificationGasLimit` value)","- Smart Account deployment execution reverted with an error\n",t&&`factory: ${t}`,n&&`factoryData: ${n}`,r&&`initCode: ${r}`].filter(Boolean),name:"InitCodeFailedError"})}}Object.defineProperty(lR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa13/});class uR extends tf{constructor({cause:e,factory:t,factoryData:n,initCode:r}){super("Smart Account initialization implementation did not create an account.",{cause:e,metaMessages:["This could arise when:","- `factory`/`factoryData` or `initCode` properties are invalid","- Smart Account initialization implementation is incorrect\n",t&&`factory: ${t}`,n&&`factoryData: ${n}`,r&&`initCode: ${r}`].filter(Boolean),name:"InitCodeMustCreateSenderError"})}}Object.defineProperty(uR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa15/});class dR extends tf{constructor({cause:e,factory:t,factoryData:n,initCode:r,sender:i}){super("Smart Account initialization implementation does not return the expected sender.",{cause:e,metaMessages:["This could arise when:","Smart Account initialization implementation does not return a sender address\n",t&&`factory: ${t}`,n&&`factoryData: ${n}`,r&&`initCode: ${r}`,i&&`sender: ${i}`].filter(Boolean),name:"InitCodeMustReturnSenderError"})}}Object.defineProperty(dR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa14/});class hR extends tf{constructor({cause:e}){super("Smart Account does not have sufficient funds to execute the User Operation.",{cause:e,metaMessages:["This could arise when:","- the Smart Account does not have sufficient funds to cover the required prefund, or","- a Paymaster was not provided"].filter(Boolean),name:"InsufficientPrefundError"})}}Object.defineProperty(hR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa21/});class fR extends tf{constructor({cause:e}){super("Bundler attempted to call an invalid function on the EntryPoint.",{cause:e,name:"InternalCallOnlyError"})}}Object.defineProperty(fR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa92/});class pR extends tf{constructor({cause:e}){super("Bundler used an invalid aggregator for handling aggregated User Operations.",{cause:e,name:"InvalidAggregatorError"})}}Object.defineProperty(pR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa96/});class mR extends tf{constructor({cause:e,nonce:t}){super("Invalid Smart Account nonce used for User Operation.",{cause:e,metaMessages:[t&&`nonce: ${t}`].filter(Boolean),name:"InvalidAccountNonceError"})}}Object.defineProperty(mR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa25/});class gR extends tf{constructor({cause:e}){super("Bundler has not set a beneficiary address.",{cause:e,name:"InvalidBeneficiaryError"})}}Object.defineProperty(gR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa90/});class yR extends tf{constructor({cause:e}){super("Invalid fields set on User Operation.",{cause:e,name:"InvalidFieldsError"})}}Object.defineProperty(yR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class bR extends tf{constructor({cause:e,paymasterAndData:t}){super("Paymaster properties provided are invalid.",{cause:e,metaMessages:["This could arise when:","- the `paymasterAndData` property is of an incorrect length\n",t&&`paymasterAndData: ${t}`].filter(Boolean),name:"InvalidPaymasterAndDataError"})}}Object.defineProperty(bR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa93/});class vR extends tf{constructor({cause:e}){super("Paymaster deposit for the User Operation is too low.",{cause:e,metaMessages:["This could arise when:","- the Paymaster has deposited less than the expected amount via the `deposit` function"].filter(Boolean),name:"PaymasterDepositTooLowError"})}}Object.defineProperty(vR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32508}),Object.defineProperty(vR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa31/});class wR extends tf{constructor({cause:e}){super("The `validatePaymasterUserOp` function on the Paymaster reverted.",{cause:e,name:"PaymasterFunctionRevertedError"})}}Object.defineProperty(wR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa33/});class ER extends tf{constructor({cause:e}){super("The Paymaster contract has not been deployed.",{cause:e,name:"PaymasterNotDeployedError"})}}Object.defineProperty(ER,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa30/});class _R extends tf{constructor({cause:e}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:e,name:"PaymasterRateLimitError"})}}Object.defineProperty(_R,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32504});class xR extends tf{constructor({cause:e}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:e,name:"PaymasterStakeTooLowError"})}}Object.defineProperty(xR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32505});class kR extends tf{constructor({cause:e}){super("Paymaster `postOp` function reverted.",{cause:e,name:"PaymasterPostOpFunctionRevertedError"})}}Object.defineProperty(kR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa50/});class SR extends tf{constructor({cause:e,factory:t,factoryData:n,initCode:r}){super("Smart Account has already been deployed.",{cause:e,metaMessages:["Remove the following properties and try again:",t&&"`factory`",n&&"`factoryData`",r&&"`initCode`"].filter(Boolean),name:"SenderAlreadyConstructedError"})}}Object.defineProperty(SR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa10/});class CR extends tf{constructor({cause:e}){super("UserOperation rejected because account signature check failed (or paymaster signature, if the paymaster uses its data as signature).",{cause:e,name:"SignatureCheckFailedError"})}}Object.defineProperty(CR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32507});class IR extends tf{constructor({cause:e}){super("The `validateUserOp` function on the Smart Account reverted.",{cause:e,name:"SmartAccountFunctionRevertedError"})}}Object.defineProperty(IR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa23/});class AR extends tf{constructor({cause:e}){super("UserOperation rejected because account specified unsupported signature aggregator.",{cause:e,name:"UnsupportedSignatureAggregatorError"})}}Object.defineProperty(AR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32506});class PR extends tf{constructor({cause:e}){super("User Operation expired.",{cause:e,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validateUserOp` on the Smart Account are not satisfied"].filter(Boolean),name:"UserOperationExpiredError"})}}Object.defineProperty(PR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa22/});class MR extends tf{constructor({cause:e}){super("Paymaster for User Operation expired.",{cause:e,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validatePaymasterUserOp` on the Paymaster are not satisfied"].filter(Boolean),name:"UserOperationPaymasterExpiredError"})}}Object.defineProperty(MR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa32/});class OR extends tf{constructor({cause:e}){super("Signature provided for the User Operation is invalid.",{cause:e,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Smart Account"].filter(Boolean),name:"UserOperationSignatureError"})}}Object.defineProperty(OR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa24/});class TR extends tf{constructor({cause:e}){super("Signature provided for the User Operation is invalid.",{cause:e,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Paymaster"].filter(Boolean),name:"UserOperationPaymasterSignatureError"})}}Object.defineProperty(TR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa34/});class RR extends tf{constructor({cause:e}){super("User Operation rejected by EntryPoint's `simulateValidation` during account creation or validation.",{cause:e,name:"UserOperationRejectedByEntryPointError"})}}Object.defineProperty(RR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32500});class NR extends tf{constructor({cause:e}){super("User Operation rejected by Paymaster's `validatePaymasterUserOp`.",{cause:e,name:"UserOperationRejectedByPaymasterError"})}}Object.defineProperty(NR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32501});class LR extends tf{constructor({cause:e}){super("User Operation rejected with op code validation error.",{cause:e,name:"UserOperationRejectedByOpCodeError"})}}Object.defineProperty(LR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32502});class BR extends tf{constructor({cause:e}){super("UserOperation out of time-range: either wallet or paymaster returned a time-range, and it is already expired (or will expire soon).",{cause:e,name:"UserOperationOutOfTimeRangeError"})}}Object.defineProperty(BR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32503});class jR extends tf{constructor({cause:e}){super(`An error occurred while executing user operation: ${null==e?void 0:e.shortMessage}`,{cause:e,name:"UnknownBundlerError"})}}class DR extends tf{constructor({cause:e}){super("User Operation verification gas limit exceeded.",{cause:e,metaMessages:["This could arise when:","- the gas used for verification exceeded the `verificationGasLimit`"].filter(Boolean),name:"VerificationGasLimitExceededError"})}}Object.defineProperty(DR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa40/});class UR extends tf{constructor({cause:e}){super("User Operation verification gas limit is too low.",{cause:e,metaMessages:["This could arise when:","- the `verificationGasLimit` is too low to verify the User Operation"].filter(Boolean),name:"VerificationGasLimitTooLowError"})}}Object.defineProperty(UR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa41/});class FR extends tf{constructor(e,{callData:t,callGasLimit:n,docsPath:r,factory:i,factoryData:o,initCode:s,maxFeePerGas:a,maxPriorityFeePerGas:c,nonce:l,paymaster:u,paymasterAndData:d,paymasterData:h,paymasterPostOpGasLimit:f,paymasterVerificationGasLimit:p,preVerificationGas:m,sender:g,signature:y,verificationGasLimit:b}){const v=Gg({callData:t,callGasLimit:n,factory:i,factoryData:o,initCode:s,maxFeePerGas:void 0!==a&&`${Hg(a)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Hg(c)} gwei`,nonce:l,paymaster:u,paymasterAndData:d,paymasterData:h,paymasterPostOpGasLimit:f,paymasterVerificationGasLimit:p,preVerificationGas:m,sender:g,signature:y,verificationGasLimit:b});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",v].filter(Boolean),name:"UserOperationExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class $R extends tf{constructor({hash:e}){super(`User Operation receipt with hash "${e}" could not be found. The User Operation may not have been processed yet.`,{name:"UserOperationReceiptNotFoundError"})}}class zR extends tf{constructor({hash:e}){super(`User Operation with hash "${e}" could not be found.`,{name:"UserOperationNotFoundError"})}}class HR extends tf{constructor({hash:e}){super(`Timed out while waiting for User Operation with hash "${e}" to be confirmed.`,{name:"WaitForUserOperationReceiptTimeoutError"})}}const qR=[oR,yR,vR,_R,xR,CR,AR,BR,RR,NR,LR];function WR(e,{calls:t,docsPath:n,...r}){const i=(()=>{const n=function(e,t){const n=(e.details||"").toLowerCase();if(iR.message.test(n))return new iR({cause:e});if(sR.message.test(n))return new sR({cause:e});if(aR.message.test(n))return new aR({cause:e});if(cR.message.test(n))return new cR({cause:e});if(lR.message.test(n))return new lR({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(uR.message.test(n))return new uR({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(dR.message.test(n))return new dR({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode,sender:t.sender});if(hR.message.test(n))return new hR({cause:e});if(fR.message.test(n))return new fR({cause:e});if(mR.message.test(n))return new mR({cause:e,nonce:t.nonce});if(pR.message.test(n))return new pR({cause:e});if(gR.message.test(n))return new gR({cause:e});if(bR.message.test(n))return new bR({cause:e});if(vR.message.test(n))return new vR({cause:e});if(wR.message.test(n))return new wR({cause:e});if(ER.message.test(n))return new ER({cause:e});if(kR.message.test(n))return new kR({cause:e});if(IR.message.test(n))return new IR({cause:e});if(SR.message.test(n))return new SR({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(PR.message.test(n))return new PR({cause:e});if(MR.message.test(n))return new MR({cause:e});if(TR.message.test(n))return new TR({cause:e});if(OR.message.test(n))return new OR({cause:e});if(DR.message.test(n))return new DR({cause:e});if(UR.message.test(n))return new UR({cause:e});const r=e.walk(e=>qR.some(t=>t.code===e.code));if(r){if(r.code===oR.code)return new oR({cause:e,data:r.data,message:r.details});if(r.code===yR.code)return new yR({cause:e});if(r.code===vR.code)return new vR({cause:e});if(r.code===_R.code)return new _R({cause:e});if(r.code===xR.code)return new xR({cause:e});if(r.code===CR.code)return new CR({cause:e});if(r.code===AR.code)return new AR({cause:e});if(r.code===BR.code)return new BR({cause:e});if(r.code===RR.code)return new RR({cause:e});if(r.code===NR.code)return new NR({cause:e});if(r.code===LR.code)return new LR({cause:e})}return new jR({cause:e})}(e,r);if(t&&n instanceof oR){const e=function(e){let t;return e.walk(e=>{var n,r,i,o;const s=e;if("string"==typeof s.data||"string"==typeof(null==(n=s.data)?void 0:n.revertData)||!(s instanceof tf)&&"string"==typeof s.message){const e=null==(o=(i=(null==(r=s.data)?void 0:r.revertData)||s.data||s.message).match)?void 0:o.call(i,/(0x[A-Za-z0-9]*)/);if(e)return t=e[1],!0}return!1}),t}(n),r=null==t?void 0:t.filter(e=>e.abi);if(e&&r.length>0)return function(e){const{calls:t,revertData:n}=e,{abi:r,functionName:i,args:o,to:s}=(()=>{const e=null==t?void 0:t.filter(e=>Boolean(e.abi));if(1===e.length)return e[0];const r=e.filter(e=>{try{return Boolean(Lg({abi:e.abi,data:n}))}catch{return!1}});return 1===r.length?r[0]:{abi:[],functionName:e.reduce((e,t)=>`${e?`${e} | `:""}${t.functionName}`,""),args:void 0,to:void 0}})(),a="0x"===n?new sy({functionName:i}):new oy({abi:r,data:n,functionName:i});return new iy(a,{abi:r,args:o,contractAddress:s,functionName:i})}({calls:r,revertData:e})}return n})();return new FR(i,{docsPath:n,...r})}function KR(e){const t={};var n;return void 0!==e.callData&&(t.callData=e.callData),void 0!==e.callGasLimit&&(t.callGasLimit=Vf(e.callGasLimit)),void 0!==e.factory&&(t.factory=e.factory),void 0!==e.factoryData&&(t.factoryData=e.factoryData),void 0!==e.initCode&&(t.initCode=e.initCode),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=Vf(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=Vf(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=Vf(e.nonce)),void 0!==e.paymaster&&(t.paymaster=e.paymaster),void 0!==e.paymasterAndData&&(t.paymasterAndData=e.paymasterAndData||"0x"),void 0!==e.paymasterData&&(t.paymasterData=e.paymasterData),void 0!==e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=Vf(e.paymasterPostOpGasLimit)),void 0!==e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=Vf(e.paymasterVerificationGasLimit)),void 0!==e.preVerificationGas&&(t.preVerificationGas=Vf(e.preVerificationGas)),void 0!==e.sender&&(t.sender=e.sender),void 0!==e.signature&&(t.signature=e.signature),void 0!==e.verificationGasLimit&&(t.verificationGasLimit=Vf(e.verificationGasLimit)),void 0!==e.authorization&&(t.eip7702Auth={address:(n=e.authorization).address,chainId:Vf(n.chainId),nonce:Vf(n.nonce),r:n.r?Vf(BigInt(n.r),{size:32}):Rf("0x",{size:32}),s:n.s?Vf(BigInt(n.s),{size:32}):Rf("0x",{size:32}),yParity:n.yParity?Vf(n.yParity,{size:1}):Rf("0x",{size:32})}),t}async function GR(e,t){const{chainId:n,entryPointAddress:r,context:i,...o}=t,s=KR(o),{paymasterPostOpGasLimit:a,paymasterVerificationGasLimit:c,...l}=await e.request({method:"pm_getPaymasterData",params:[{...s,callGasLimit:s.callGasLimit??"0x0",verificationGasLimit:s.verificationGasLimit??"0x0",preVerificationGas:s.preVerificationGas??"0x0"},r,Vf(n),i]});return{...l,...a&&{paymasterPostOpGasLimit:$f(a)},...c&&{paymasterVerificationGasLimit:$f(c)}}}async function VR(e,t){const{chainId:n,entryPointAddress:r,context:i,...o}=t,s=KR(o),{paymasterPostOpGasLimit:a,paymasterVerificationGasLimit:c,...l}=await e.request({method:"pm_getPaymasterStubData",params:[{...s,callGasLimit:s.callGasLimit??"0x0",verificationGasLimit:s.verificationGasLimit??"0x0",preVerificationGas:s.preVerificationGas??"0x0"},r,Vf(n),i]});return{...l,...a&&{paymasterPostOpGasLimit:$f(a)},...c&&{paymasterVerificationGasLimit:$f(c)}}}const ZR=["factory","fees","gas","paymaster","nonce","signature","authorization"];async function YR(e,t){var n;const r=t,{account:i=e.account,parameters:o=ZR,stateOverride:s}=r;if(!i)throw new oS;const a=Og(i),c=e,l=r.paymaster??(null==c?void 0:c.paymaster),u="string"==typeof l?l:void 0,{getPaymasterStubData:d,getPaymasterData:h}=(()=>{if(!0===l)return{getPaymasterStubData:e=>Ey(c,VR,"getPaymasterStubData")(e),getPaymasterData:e=>Ey(c,GR,"getPaymasterData")(e)};if("object"==typeof l){const{getPaymasterStubData:e,getPaymasterData:t}=l;return{getPaymasterStubData:t&&e?e:t,getPaymasterData:t&&e?t:void 0}}return{getPaymasterStubData:void 0,getPaymasterData:void 0}})(),f=r.paymasterContext?r.paymasterContext:null==c?void 0:c.paymasterContext;let p={...r,paymaster:u,sender:a.address};const[m,g,y,b,v]=await Promise.all([(async()=>r.calls?a.encodeCalls(r.calls.map(e=>{const t=e;return t.abi?{data:kg(t),to:t.to,value:t.value}:t})):r.callData)(),(async()=>{if(!o.includes("factory"))return;if(r.initCode)return{initCode:r.initCode};if(r.factory&&r.factoryData)return{factory:r.factory,factoryData:r.factoryData};const{factory:e,factoryData:t}=await a.getFactoryArgs();return"0.6"===a.entryPoint.version?{initCode:e&&t?rm([e,t]):void 0}:{factory:e,factoryData:t}})(),(async()=>{var t;if(o.includes("fees")){if("bigint"==typeof r.maxFeePerGas&&"bigint"==typeof r.maxPriorityFeePerGas)return p;if(null==(t=null==c?void 0:c.userOperation)?void 0:t.estimateFeesPerGas){const e=await c.userOperation.estimateFeesPerGas({account:a,bundlerClient:c,userOperation:p});return{...p,...e}}try{const t=c.client??e,n=await Ey(t,rE,"estimateFeesPerGas")({chain:t.chain,type:"eip1559"});return{maxFeePerGas:"bigint"==typeof r.maxFeePerGas?r.maxFeePerGas:BigInt(2n*n.maxFeePerGas),maxPriorityFeePerGas:"bigint"==typeof r.maxPriorityFeePerGas?r.maxPriorityFeePerGas:BigInt(2n*n.maxPriorityFeePerGas)}}catch{return}}})(),(async()=>{if(o.includes("nonce"))return"bigint"==typeof r.nonce?r.nonce:a.getNonce()})(),(async()=>{if(o.includes("authorization")){if("object"==typeof r.authorization)return r.authorization;if(a.authorization&&!(await a.isDeployed())){const e=await async function(e,t){var n;const{account:r=e.account,chainId:i,nonce:o}=t;if(!r)throw new oS({docsPath:"/docs/eip7702/prepareAuthorization"});const s=Og(r),a=(()=>{if(t.executor)return"self"===t.executor?t.executor:Og(t.executor)})(),c={address:t.contractAddress??t.address,chainId:i,nonce:o};return void 0===c.chainId&&(c.chainId=(null==(n=e.chain)?void 0:n.id)??await Ey(e,AE,"getChainId")({})),void 0===c.nonce&&(c.nonce=await Ey(e,oE,"getTransactionCount")({address:s.address,blockTag:"pending"}),("self"===a||(null==a?void 0:a.address)&&DE(a.address,s.address))&&(c.nonce+=1)),c}(a.client,a.authorization);return{...e,r:"0xfffffffffffffffffffffffffffffff000000000000000000000000000000000",s:"0x7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",yParity:1}}}})()]);let w;async function E(){if(w)return w;if(e.chain)return e.chain.id;const t=await Ey(e,AE,"getChainId")({});return w=t,w}void 0!==m&&(p.callData=m),void 0!==g&&(p={...p,...g}),void 0!==y&&(p={...p,...y}),void 0!==b&&(p.nonce=b),void 0!==v&&(p.authorization=v),o.includes("signature")&&(void 0!==r.signature?p.signature=r.signature:p.signature=await a.getStubSignature(p)),"0.6"!==a.entryPoint.version||p.initCode||(p.initCode="0x");let _=!1;if(o.includes("paymaster")&&d&&!u&&!r.paymasterAndData){const{isFinal:e=!1,sponsor:t,...n}=await d({chainId:await E(),entryPointAddress:a.entryPoint.address,context:f,...p});_=e,p={...p,...n}}if("0.6"!==a.entryPoint.version||p.paymasterAndData||(p.paymasterAndData="0x"),o.includes("gas")){if(null==(n=a.userOperation)?void 0:n.estimateGas){const e=await a.userOperation.estimateGas(p);p={...p,...e}}if(void 0===p.callGasLimit||void 0===p.preVerificationGas||void 0===p.verificationGasLimit||p.paymaster&&void 0===p.paymasterPostOpGasLimit||p.paymaster&&void 0===p.paymasterVerificationGasLimit){const e=await Ey(c,JR,"estimateUserOperationGas")({account:a,callGasLimit:0n,preVerificationGas:0n,verificationGasLimit:0n,stateOverride:s,...p.paymaster?{paymasterPostOpGasLimit:0n,paymasterVerificationGasLimit:0n}:{},...p});p={...p,callGasLimit:p.callGasLimit??e.callGasLimit,preVerificationGas:p.preVerificationGas??e.preVerificationGas,verificationGasLimit:p.verificationGasLimit??e.verificationGasLimit,paymasterPostOpGasLimit:p.paymasterPostOpGasLimit??e.paymasterPostOpGasLimit,paymasterVerificationGasLimit:p.paymasterVerificationGasLimit??e.paymasterVerificationGasLimit}}}if(o.includes("paymaster")&&h&&!u&&!r.paymasterAndData&&!_){const e=await h({chainId:await E(),entryPointAddress:a.entryPoint.address,context:f,...p});p={...p,...e}}return delete p.calls,delete p.parameters,delete p.paymasterContext,"string"!=typeof p.paymaster&&delete p.paymaster,p}async function JR(e,t){var n;const{account:r=e.account,entryPointAddress:i,stateOverride:o}=t;if(!r&&!t.sender)throw new oS;const s=r?Og(r):void 0,a=cw(o),c=s?await Ey(e,YR,"prepareUserOperation")({...t,parameters:["authorization","factory","nonce","paymaster","signature"]}):t;try{const t=[KR(c),i??(null==(n=null==s?void 0:s.entryPoint)?void 0:n.address)];return function(e){const t={};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),t}(await e.request({method:"eth_estimateUserOperationGas",params:a?[...t,a]:[...t]}))}catch(l){const e=t.calls;throw WR(l,{...c,...e?{calls:e}:{}})}}function QR(e){const t={...e};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.maxFeePerGas&&(t.maxFeePerGas=BigInt(e.maxFeePerGas)),e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=BigInt(e.maxPriorityFeePerGas)),e.nonce&&(t.nonce=BigInt(e.nonce)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),t}async function XR(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationReceipt",params:[t]},{dedupe:!0});if(!n)throw new $R({hash:t});return function(e){const t={...e};return e.actualGasCost&&(t.actualGasCost=BigInt(e.actualGasCost)),e.actualGasUsed&&(t.actualGasUsed=BigInt(e.actualGasUsed)),e.logs&&(t.logs=e.logs.map(e=>HE(e))),e.receipt&&(t.receipt=f_(t.receipt)),t}(n)}function eN(e){return{estimateUserOperationGas:t=>JR(e,t),getChainId:()=>AE(e),getSupportedEntryPoints:()=>function(e){return e.request({method:"eth_supportedEntryPoints"})}(e),getUserOperation:t=>async function(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationByHash",params:[t]},{dedupe:!0});if(!n)throw new zR({hash:t});const{blockHash:r,blockNumber:i,entryPoint:o,transactionHash:s,userOperation:a}=n;return{blockHash:r,blockNumber:BigInt(i),entryPoint:o,transactionHash:s,userOperation:QR(a)}}(e,t),getUserOperationReceipt:t=>XR(e,t),prepareUserOperation:t=>YR(e,t),sendUserOperation:t=>async function(e,t){var n,r;const{account:i=e.account,entryPointAddress:o}=t;if(!i&&!t.sender)throw new oS;const s=i?Og(i):void 0,a=s?await Ey(e,YR,"prepareUserOperation")(t):t,c=t.signature||await(null==(n=null==s?void 0:s.signUserOperation)?void 0:n.call(s,a)),l=KR({...a,signature:c});try{return await e.request({method:"eth_sendUserOperation",params:[l,o??(null==(r=null==s?void 0:s.entryPoint)?void 0:r.address)]},{retryCount:0})}catch(u){const e=t.calls;throw WR(u,{...a,...e?{calls:e}:{},signature:c})}}(e,t),waitForUserOperationReceipt:t=>function(e,t){const{hash:n,pollingInterval:r=e.pollingInterval,retryCount:i,timeout:o=12e4}=t;let s=0;const a=Bg(["waitForUserOperationReceipt",e.uid,n]);return new Promise((t,c)=>{const l=tS(a,{resolve:t,reject:c},t=>{const a=e=>{u(),e(),l()},c=o?setTimeout(()=>a(()=>t.reject(new HR({hash:n}))),o):void 0,u=nS(async()=>{i&&s>=i&&(clearTimeout(c),a(()=>t.reject(new HR({hash:n}))));try{const r=await Ey(e,XR,"getUserOperationReceipt")({hash:n});a(()=>t.resolve(r))}catch(r){const e=r;"UserOperationReceiptNotFoundError"!==e.name&&a(()=>t.reject(e))}finally{clearTimeout(c)}s++},{emitOnBegin:!0,interval:r});return u})})}(e,t)}}function tN(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function nN(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=tN(n);return(e,n)=>r.then(r=>n(r.transaction(t,e).objectStore(t)))}let rN;function iN(){return rN||(rN=nN("keyval-store","keyval")),rN}const oN="4.3.6",sN="@coinbase/wallet-sdk",aN=jO(LO((...e)=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{chains:[]}),{keys:{}}),{account:{}}),{subAccount:void 0}),{spendPermissions:[]}),(()=>({config:{version:oN}}))(...e)),{subAccountConfig:{}}),{name:"cbwsdk.store",storage:RO(()=>localStorage),partialize:e=>({chains:e.chains,keys:e.keys,account:e.account,subAccount:e.subAccount,spendPermissions:e.spendPermissions,config:e.config})})),cN={get:()=>aN.getState().config,set:e=>{aN.setState(t=>({config:Object.assign(Object.assign({},t.config),e)}))}},lN={subAccounts:{get:()=>aN.getState().subAccount,set:e=>{aN.setState(t=>({subAccount:t.subAccount?Object.assign(Object.assign({},t.subAccount),e):Object.assign({address:e.address},e)}))},clear:()=>{aN.setState({subAccount:void 0})}},subAccountsConfig:{get:()=>aN.getState().subAccountConfig,set:e=>{aN.setState(t=>({subAccountConfig:Object.assign(Object.assign({},t.subAccountConfig),e)}))},clear:()=>{aN.setState({subAccountConfig:{}})}},spendPermissions:{get:()=>aN.getState().spendPermissions,set:e=>{aN.setState({spendPermissions:e})},clear:()=>{aN.setState({spendPermissions:[]})}},account:{get:()=>aN.getState().account,set:e=>{aN.setState(t=>({account:Object.assign(Object.assign({},t.account),e)}))},clear:()=>{aN.setState({account:{}})}},chains:{get:()=>aN.getState().chains,set:e=>{aN.setState({chains:e})},clear:()=>{aN.setState({chains:[]})}},keys:{get:e=>aN.getState().keys[e],set:(e,t)=>{aN.setState(n=>({keys:Object.assign(Object.assign({},n.keys),{[e]:t})}))},clear:()=>{aN.setState({keys:{}})}},config:cN},uN=Object.assign(Object.assign({},aN),lN),dN=()=>{var e,t,n;if("undefined"!=typeof window){const r=null!==(n=null!==(e=uN.config.get().deviceId)&&void 0!==e?e:null===(t=window.crypto)||void 0===t?void 0:t.randomUUID())&&void 0!==n?n:"";if(window.ClientAnalytics){const{init:e,identify:t,PlatformName:n}=window.ClientAnalytics;e({isProd:!0,amplitudeApiKey:"c66737ad47ec354ced777935b0af822e",platform:n.web,projectName:"base_account_sdk",showDebugLogging:!1,version:"1.0.0",apiEndpoint:"https://cca-lite.coinbase.com"}),t({deviceId:r}),uN.config.set({deviceId:r})}}},hN={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},fN={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902},pN={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},mN="Unspecified error message.";function gN(e,t=mN){if(e&&Number.isInteger(e)){const t=e.toString();if(wN(pN,t))return pN[t].message;if(bN(e))return"Unspecified server error."}return t}function yN(e,{shouldIncludeStack:t=!1}={}){const n={};if(e&&"object"==typeof e&&!Array.isArray(e)&&wN(e,"code")&&function(e){if(!Number.isInteger(e))return!1;const t=e.toString();return!!pN[t]||!!bN(e)}(e.code)){const t=e;n.code=t.code,t.message&&"string"==typeof t.message?(n.message=t.message,wN(t,"data")&&(n.data=t.data)):(n.message=gN(n.code),n.data={originalError:vN(e)})}else n.code=hN.internal,n.message=EN(e,"message")?e.message:mN,n.data={originalError:vN(e)};return t&&(n.stack=EN(e,"stack")?e.stack:void 0),n}function bN(e){return e>=-32099&&e<=-32e3}function vN(e){return e&&"object"==typeof e&&!Array.isArray(e)?Object.assign({},e):e}function wN(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function EN(e,t){return"object"==typeof e&&null!==e&&t in e&&"string"==typeof e[t]}const _N={parse:e=>kN(hN.parse,e),invalidRequest:e=>kN(hN.invalidRequest,e),invalidParams:e=>kN(hN.invalidParams,e),methodNotFound:e=>kN(hN.methodNotFound,e),internal:e=>kN(hN.internal,e),server:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return kN(t,e)},invalidInput:e=>kN(hN.invalidInput,e),resourceNotFound:e=>kN(hN.resourceNotFound,e),resourceUnavailable:e=>kN(hN.resourceUnavailable,e),transactionRejected:e=>kN(hN.transactionRejected,e),methodNotSupported:e=>kN(hN.methodNotSupported,e),limitExceeded:e=>kN(hN.limitExceeded,e)},xN={userRejectedRequest:e=>SN(fN.userRejectedRequest,e),unauthorized:e=>SN(fN.unauthorized,e),unsupportedMethod:e=>SN(fN.unsupportedMethod,e),disconnected:e=>SN(fN.disconnected,e),chainDisconnected:e=>SN(fN.chainDisconnected,e),unsupportedChain:e=>SN(fN.unsupportedChain,e),custom:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:n,data:r}=e;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new AN(t,n,r)}};function kN(e,t){const[n,r]=CN(t);return new IN(e,n||gN(e),r)}function SN(e,t){const[n,r]=CN(t);return new AN(e,n||gN(e),r)}function CN(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t||void 0,n]}}return[]}let IN=class extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a nonempty string.');super(t),this.code=e,void 0!==n&&(this.data=n)}},AN=class extends IN{constructor(e,t,n){if(!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,n)}};function PN(e){return"object"==typeof e&&null!==e&&"code"in e&&"data"in e&&-32090===e.code&&"object"==typeof e.data&&null!==e.data&&"type"in e.data&&"INSUFFICIENT_FUNDS"===e.data.type}function MN(e){return"object"==typeof e&&null!==e&&"details"in e}const ON=e=>e,TN=e=>e;function RN(e){return Math.floor(e)}var NN=["buffer","Buffer"];const LN=/^[0-9]*$/,BN=/^[a-f0-9]*$/;function jN(e){return DN(crypto.getRandomValues(new Uint8Array(e)))}function DN(e){return[...e].map(e=>e.toString(16).padStart(2,"0")).join("")}function UN(e){return new Uint8Array(e.match(/.{1,2}/g).map(e=>Number.parseInt(e,16)))}function FN(e,t=!1){const n=e.toString("hex");return ON(t?`0x${n}`:n)}function $N(e){return FN(JN(e),!0)}function zN(e){return TN(e.toString(10))}function HN(e){return ON(`0x${BigInt(e).toString(16)}`)}function qN(e){return e.startsWith("0x")||e.startsWith("0X")}function WN(e){return qN(e)?e.slice(2):e}function KN(e){return qN(e)?`0x${e.slice(2)}`:`0x${e}`}function GN(e){if("string"!=typeof e)return!1;const t=WN(e).toLowerCase();return BN.test(t)}function VN(e,t=!1){if("string"==typeof e){const n=WN(e).toLowerCase();if(BN.test(n))return ON(t?`0x${n}`:n)}throw _N.invalidParams(`"${String(e)}" is not a hexadecimal string`)}function ZN(e,t=!1){let n=VN(e,!1);return n.length%2==1&&(n=ON(`0${n}`)),t?ON(`0x${n}`):n}function YN(e){if("string"==typeof e){const t=WN(e).toLowerCase();if(GN(t)&&40===t.length)return KN(t)}throw _N.invalidParams(`Invalid Ethereum address: ${String(e)}`)}function JN(e){if(NN.isBuffer(e))return e;if("string"==typeof e){if(GN(e)){const t=ZN(e,!1);return NN.from(t,"hex")}return NN.from(e,"utf8")}throw _N.invalidParams(`Not binary data: ${String(e)}`)}function QN(e){if("number"==typeof e&&Number.isInteger(e))return RN(e);if("string"==typeof e){if(LN.test(e))return RN(Number(e));if(GN(e))return RN(Number(BigInt(ZN(e,!0))))}throw _N.invalidParams(`Not an integer: ${String(e)}`)}function XN(e){if(null!==e&&("bigint"==typeof e||function(e){if(null==e||"function"!=typeof e.constructor)return!1;const{constructor:t}=e;return"function"==typeof t.config&&"number"==typeof t.EUCLID}(e)))return BigInt(e.toString(10));if("number"==typeof e)return BigInt(QN(e));if("string"==typeof e){if(LN.test(e))return BigInt(e);if(GN(e))return BigInt(ZN(e,!0))}throw _N.invalidParams(`Not an integer: ${String(e)}`)}function eL(e){if("string"==typeof e)return JSON.parse(e);if("object"==typeof e)return e;throw _N.invalidParams(`Not a JSON string or an object: ${String(e)}`)}const{checkCrossOriginOpenerPolicy:tL,getCrossOriginOpenerPolicy:nL}=(()=>{let e;return{getCrossOriginOpenerPolicy:()=>void 0===e?"undefined":e,checkCrossOriginOpenerPolicy:async()=>{if("undefined"!=typeof window)try{const t=`${window.location.origin}${window.location.pathname}`,n=await fetch(t,{method:"HEAD"});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=n.headers.get("Cross-Origin-Opener-Policy");e=null!=r?r:"null","same-origin"===e&&console.error("Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app.\n\nPlease see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.")}catch(t){console.error("Error checking Cross-Origin-Opener-Policy:",t.message),e="error"}else e="non-browser-env"}}})();async function rL(e,t){const n=Object.assign(Object.assign({},e),{jsonrpc:"2.0",id:crypto.randomUUID()}),r=await window.fetch(t,{method:"POST",body:JSON.stringify(n),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":oN,"X-Cbw-Sdk-Platform":sN}}),{result:i,error:o}=await r.json();if(o)throw o;return i}function iL({metadata:e,preference:t}){var n,r;const{appName:i,appLogoUrl:o,appChainIds:s}=e;if("smartWalletOnly"!==t.options){const e=globalThis.coinbaseWalletExtension;if(e)return null===(n=e.setAppInfo)||void 0===n||n.call(e,i,o,s,t),e}const a=function(){var e,t;try{const n=globalThis;return null!==(e=n.ethereum)&&void 0!==e?e:null===(t=n.top)||void 0===t?void 0:t.ethereum}catch(n){return}}();if(null==a?void 0:a.isCoinbaseBrowser)return null===(r=a.setAppInfo)||void 0===r||r.call(a,i,o,s,t),a}function oL(e){if("function"!=typeof e)throw new Error("toAccount is not a function")}const sL="https://rpc.wallet.coinbase.com",aL="https://www.walletlink.org";var cL,lL,uL,dL,hL,fL;function pL(e,t,n){var r,i,o,s;window.ClientAnalytics&&(null===(r=window.ClientAnalytics)||void 0===r||r.logEvent(e,Object.assign(Object.assign({},t),{sdkVersion:oN,appName:null!==(o=null===(i=uN.config.get().metadata)||void 0===i?void 0:i.appName)&&void 0!==o?o:"",appOrigin:window.location.origin,appPreferredSigner:null===(s=uN.config.get().preference)||void 0===s?void 0:s.options}),n))}(lL=cL||(cL={})).unknown="unknown",lL.banner="banner",lL.button="button",lL.card="card",lL.chart="chart",lL.content_script="content_script",lL.dropdown="dropdown",lL.link="link",lL.page="page",lL.modal="modal",lL.table="table",lL.search_bar="search_bar",lL.service_worker="service_worker",lL.text="text",lL.text_input="text_input",lL.tray="tray",lL.checkbox="checkbox",lL.icon="icon",(dL=uL||(uL={})).unknown="unknown",dL.blur="blur",dL.click="click",dL.change="change",dL.dismiss="dismiss",dL.focus="focus",dL.hover="hover",dL.select="select",dL.measurement="measurement",dL.move="move",dL.process="process",dL.render="render",dL.scroll="scroll",dL.view="view",dL.search="search",dL.keyPress="keyPress",dL.error="error",(fL=hL||(hL={})).low="low",fL.high="high";const mL=({snackbarContext:e})=>{pL(`snackbar.${e}.shown`,{action:uL.render,componentType:cL.modal,snackbarContext:e},hL.high)},gL=({snackbarContext:e,snackbarAction:t})=>{pL(`snackbar.${e}.action_clicked`,{action:uL.click,componentType:cL.button,snackbarContext:e,snackbarAction:t},hL.high)},yL=(()=>'@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}')();function bL(){const e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode(yL)),document.documentElement.appendChild(e)}function vL(){try{return function(){try{return null!==window.frameElement}catch(e){return!1}}()&&window.top?window.top.location:window.location}catch(e){return window.location}}function wL(){var e,t;return null!==(t=null===(e=null===window||void 0===window?void 0:window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)&&void 0!==t&&t}const EL=(()=>".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}")();let _L=class{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=wL()}attach(e){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",e.appendChild(this.root),this.render()}presentItem(e){const t=this.nextItemKey++;return this.items.set(t,e),this.render(),()=>{this.items.delete(t),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&ET(nT("div",null,nT(xL,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([e,t])=>nT(kL,Object.assign({},t,{key:e}))))),this.root)}};const xL=e=>nT("div",{class:kT("-cbwsdk-snackbar-container")},nT("style",null,EL),nT("div",{class:"-cbwsdk-snackbar"},e.children)),kL=({autoExpand:e,message:t,menuItems:n})=>{const[r,i]=FT(!0),[o,s]=FT(null!=e&&e);zT(()=>{const e=[window.setTimeout(()=>{i(!1)},1),window.setTimeout(()=>{s(!0)},1e4)];return()=>{e.forEach(window.clearTimeout)}});return nT("div",{class:kT("-cbwsdk-snackbar-instance",r&&"-cbwsdk-snackbar-instance-hidden",o&&"-cbwsdk-snackbar-instance-expanded")},nT("div",{class:"-cbwsdk-snackbar-instance-header",onClick:()=>{s(!o)}},nT("img",{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",nT("div",{class:"-cbwsdk-snackbar-instance-header-message"},t),nT("div",{class:"-gear-container"},!o&&nT("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},nT("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),nT("img",{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=",class:"-gear-icon",title:"Expand"}))),n&&n.length>0&&nT("div",{class:"-cbwsdk-snackbar-instance-menu"},n.map((e,t)=>nT("div",{class:kT("-cbwsdk-snackbar-instance-menu-item",e.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:e.onClick,key:t},nT("svg",{width:e.svgWidth,height:e.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},nT("path",{"fill-rule":e.defaultFillRule,"clip-rule":e.defaultClipRule,d:e.path,fill:"#AAAAAA"})),nT("span",{class:kT("-cbwsdk-snackbar-instance-menu-item-info",e.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},e.info)))))},SL="M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z";let CL=class{constructor(){this.attached=!1,this.snackbar=new _L}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,t=document.createElement("div");t.className="-cbwsdk-css-reset",e.appendChild(t),this.snackbar.attach(t),this.attached=!0,bL()}showConnecting(e){let t;return t=e.isUnlinkedErrorState?{autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:{message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:SL,defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(t)}};const IL={isRed:!1,info:"Retry",svgWidth:"10",svgHeight:"11",path:SL,defaultFillRule:"evenodd",defaultClipRule:"evenodd"};let AL=null;function PL(e){const t=(window.innerWidth-420)/2+window.screenX,n=(window.innerHeight-700)/2+window.screenY;function r(){const r=`wallet_${crypto.randomUUID()}`,i=window.open(e,r,`width=420, height=700, left=${t}, top=${n}`);return null==i||i.focus(),i||null}!function(e){const t={sdkName:sN,sdkVersion:oN,origin:window.location.origin,coop:nL()};for(const[n,r]of Object.entries(t))e.searchParams.has(n)||e.searchParams.append(n,r.toString())}(e);let i=r();if(!i){const e=ML();return new Promise((t,n)=>{mL({snackbarContext:"popup_blocked"}),e.presentItem({autoExpand:!0,message:"Popup was blocked. Try again.",menuItems:[Object.assign(Object.assign({},IL),{onClick:()=>{gL({snackbarContext:"popup_blocked",snackbarAction:"confirm"}),i=r(),i?t(i):n(_N.internal("Popup window was blocked")),e.clear()}})]})})}return Promise.resolve(i)}function ML(){if(!AL){const e=document.createElement("div");e.className="-cbwsdk-css-reset",document.body.appendChild(e),AL=new _L,AL.attach(e)}return AL}class OL{constructor({url:e="https://keys.coinbase.com/connect",metadata:t,preference:n}){this.popup=null,this.listeners=new Map,this.postMessage=async e=>{(await this.waitForPopupLoaded()).postMessage(e,this.url.origin)},this.postRequestAndWaitForResponse=async e=>{const t=this.onMessage(({requestId:t})=>t===e.id);return this.postMessage(e),await t},this.onMessage=async e=>new Promise((t,n)=>{const r=n=>{if(n.origin!==this.url.origin)return;const i=n.data;e(i)&&(t(i),window.removeEventListener("message",r),this.listeners.delete(r))};window.addEventListener("message",r),this.listeners.set(r,{reject:n})}),this.disconnect=()=>{var e;(e=this.popup)&&!e.closed&&e.close(),this.popup=null,this.listeners.forEach(({reject:e},t)=>{e(xN.userRejectedRequest("Request rejected")),window.removeEventListener("message",t)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(pL("communicator.popup_setup.started",{action:uL.unknown,componentType:cL.unknown},hL.high),this.popup=await PL(this.url),this.onMessage(({event:e})=>"PopupUnload"===e).then(()=>{this.disconnect(),pL("communicator.popup_unload.received",{action:uL.unknown,componentType:cL.unknown},hL.high)}).catch(()=>{}),this.onMessage(({event:e})=>"PopupLoaded"===e).then(e=>{this.postMessage({requestId:e.id,data:{version:oN,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw _N.internal();return pL("communicator.popup_setup.completed",{action:uL.unknown,componentType:cL.unknown},hL.high),this.popup})),this.url=new URL(e),this.metadata=t,this.preference=n}}function TL(e){return void 0!==e.errorMessage}function RL(e){const t=yN(function(e){var t;if("string"==typeof e)return{message:e,code:hN.internal};if(TL(e)){const n=e.errorMessage,r=null!==(t=e.errorCode)&&void 0!==t?t:n.match(/(denied|rejected)/i)?fN.userRejectedRequest:void 0;return Object.assign(Object.assign({},e),{message:n,code:r,data:{method:e.method}})}return e}(e),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return n.searchParams.set("version",oN),n.searchParams.set("code",t.code.toString()),n.searchParams.set("message",t.message),Object.assign(Object.assign({},t),{docUrl:n.href})}class NL extends SA{}let LL=class e{constructor(e,t){this.scope=e,this.module=t}storeObject(e,t){this.setItem(e,JSON.stringify(t))}loadObject(e){const t=this.getItem(e);return t?JSON.parse(t):void 0}setItem(e,t){localStorage.setItem(this.scopedKey(e),t)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),t=[];for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);"string"==typeof r&&r.startsWith(e)&&t.push(r)}t.forEach(e=>localStorage.removeItem(e))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new e("CBWSDK").clear(),new e("walletlink").clear()}};const BL=jO(()=>({correlationIds:new Map})),jL=e=>BL.getState().correlationIds.get(e),DL=(e,t)=>{BL.setState(n=>{const r=new Map(n.correlationIds);return r.set(e,t),{correlationIds:r}})},UL=e=>{BL.setState(t=>{const n=new Map(t.correlationIds);return n.delete(e),{correlationIds:n}})},FL=()=>{BL.setState({correlationIds:new Map})},$L=e=>"message"in e&&"string"==typeof e.message?e.message:"",zL=jO(()=>({}));function HL(e){e.forEach(e=>{var t,n,r,i,o,s,a,c;if(!e.rpcUrl)return;const l=LS({chain:d_({id:e.id,rpcUrls:{default:{http:[e.rpcUrl]}},name:null!==(n=null===(t=e.nativeCurrency)||void 0===t?void 0:t.name)&&void 0!==n?n:"",nativeCurrency:{name:null!==(i=null===(r=e.nativeCurrency)||void 0===r?void 0:r.name)&&void 0!==i?i:"",symbol:null!==(s=null===(o=e.nativeCurrency)||void 0===o?void 0:o.symbol)&&void 0!==s?s:"",decimals:null!==(c=null===(a=e.nativeCurrency)||void 0===a?void 0:a.decimal)&&void 0!==c?c:18}}),transport:$S(e.rpcUrl)}),u=function(e){const{client:t,key:n="bundler",name:r="Bundler Client",paymaster:i,paymasterContext:o,transport:s,userOperation:a}=e;return Object.assign(MS({...e,chain:e.chain??(null==t?void 0:t.chain),key:n,name:r,transport:s,type:"bundlerClient"}),{client:t,paymaster:i,paymasterContext:o,userOperation:a}).extend(eN)}({client:l,transport:$S(e.rpcUrl)});zL.setState({[e.id]:{client:l,bundlerClient:u}})})}function qL(e){var t;return null===(t=zL.getState()[e])||void 0===t?void 0:t.client}function WL(e,t,n){if(null==e)throw null!=t?t:_N.invalidParams({message:"value must be present",data:e})}function KL(e,t){if(!Array.isArray(e))throw _N.invalidParams({message:null!=t?t:"value must be an array",data:e})}function GL(e){if("object"!=typeof e||null===e)throw _N.internal("sub account info is not an object");if(!("address"in e))throw _N.internal("sub account is invalid");if("address"in e&&"string"==typeof e.address&&!Fp(e.address))throw _N.internal("sub account address is invalid");if("factory"in e&&"string"==typeof e.factory&&!Fp(e.factory))throw _N.internal("sub account factory address is invalid");if("factoryData"in e&&"string"==typeof e.factoryData&&!Jh(e.factoryData))throw _N.internal("sub account factory data is invalid")}function VL(e){switch(e){case"public":return"spki";case"private":return"pkcs8"}}async function ZL(e,t){const n=VL(e),r=await crypto.subtle.exportKey(n,t);return DN(new Uint8Array(r))}async function YL(e,t){const n=VL(e),r=UN(t).buffer;return await crypto.subtle.importKey(n,new Uint8Array(r),{name:"ECDH",namedCurve:"P-256"},!0,"private"===e?["deriveKey"]:[])}async function JL(e,t){return async function(e,t){const n=crypto.getRandomValues(new Uint8Array(12));return{iv:n,cipherText:await crypto.subtle.encrypt({name:"AES-GCM",iv:n},e,(new TextEncoder).encode(t))}}(t,JSON.stringify(e,(e,t)=>{if(!(t instanceof Error))return t;const n=t;return Object.assign(Object.assign({},n.code?{code:n.code}:{}),{message:n.message})}))}async function QL(e,t){return JSON.parse(await async function(e,{iv:t,cipherText:n}){const r=await crypto.subtle.decrypt({name:"AES-GCM",iv:t},e,n);return(new TextDecoder).decode(r)}(t,e))}class XL extends Error{constructor(e,t={}){const n=(()=>{var e;if(t.cause instanceof XL){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return(null==(e=t.cause)?void 0:e.message)?t.cause.message:t.details})(),r=t.cause instanceof XL&&t.cause.docsPath||t.docsPath,i=`https://oxlib.sh${r??""}`;super([e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${i}`:void 0]:[]].filter(e=>"string"==typeof e).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{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,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:"ox@0.1.1"}),this.cause=t.cause,this.details=n,this.docs=i,this.docsPath=r,this.shortMessage=e}walk(e){return eB(this,e)}}function eB(e,t){return(null==t?void 0:t(e))?e:e&&"object"==typeof e&&"cause"in e&&e.cause?eB(e.cause,t):t?null:e}
40
+ */var wC="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},EC=vC.useSyncExternalStore,_C=bC.useRef,xC=bC.useEffect,kC=bC.useMemo,SC=bC.useDebugValue;sC.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=_C(null);if(null===o.current){var s={hasValue:!1,value:null};o.current=s}else s=o.current;o=kC(function(){function e(e){if(!c){if(c=!0,o=e,e=r(e),void 0!==i&&s.hasValue){var t=s.value;if(i(t,e))return a=t}return a=e}if(t=a,wC(o,e))return t;var n=r(e);return void 0!==i&&i(t,n)?(o=e,t):(o=e,a=n)}var o,a,c=!1,l=void 0===n?null:n;return[function(){return e(t())},null===l?void 0:function(){return e(l())}]},[t,n,r,i]);var a=EC(e,o[0],o[1]);return xC(function(){s.hasValue=!0,s.value=a},[a]),SC(a),a},oC.exports=sC;var CC=oC.exports;const IC=e=>"object"==typeof e&&!Array.isArray(e);function AC(e={}){const t=iC(e);return function(e,t,n=t,r=qS){const i=yt.useRef([]),o=CC.useSyncExternalStoreWithSelector(e,t,n,e=>e,(e,t)=>{if(IC(e)&&IC(t)&&i.current.length){for(const n of i.current)if(!r(e[n],t[n]))return!1;return!0}return r(e,t)});return yt.useMemo(()=>{if(IC(o)){const e={...o};let t={};for(const[n,r]of Object.entries(e))t={...t,[n]:{configurable:!1,enumerable:!0,get:()=>(i.current.includes(n)||i.current.push(n),r)}};return Object.defineProperties(e,t),e}return o},[o])}(e=>function(e,t){const{onChange:n}=t;return e.subscribe(()=>zS(e),n,{equalityFn(e,t){const{connector:n,...r}=e,{connector:i,...o}=t;return qS(r,o)&&(null==n?void 0:n.id)===(null==i?void 0:i.id)&&(null==n?void 0:n.uid)===(null==i?void 0:i.uid)}})}(t,{onChange:e}),()=>zS(t))}var PC=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},MC={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},OC=new(n=class{constructor(){Ae(this,e,MC),Ae(this,t,!1)}setTimeoutProvider(t){Pe(this,e,t)}setTimeout(t,n){return Ie(this,e).setTimeout(t,n)}clearTimeout(t){Ie(this,e).clearTimeout(t)}setInterval(t,n){return Ie(this,e).setInterval(t,n)}clearInterval(t){Ie(this,e).clearInterval(t)}},e=new WeakMap,t=new WeakMap,n);var TC="undefined"==typeof window||"Deno"in globalThis;function RC(){}function NC(e){return"number"==typeof e&&e>=0&&e!==1/0}function LC(e,t){return Math.max(e+(t||0)-Date.now(),0)}function BC(e,t){return"function"==typeof e?e(t):e}function jC(e,t){return"function"==typeof e?e(t):e}function DC(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:s,stale:a}=e;if(s)if(r){if(t.queryHash!==FC(s,t.options))return!1}else if(!zC(t.queryKey,s))return!1;if("all"!==n){const e=t.isActive();if("active"===n&&!e)return!1;if("inactive"===n&&e)return!1}return("boolean"!=typeof a||t.isStale()===a)&&((!i||i===t.state.fetchStatus)&&!(o&&!o(t)))}function UC(e,t){const{exact:n,status:r,predicate:i,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if($C(t.options.mutationKey)!==$C(o))return!1}else if(!zC(t.options.mutationKey,o))return!1}return(!r||t.state.status===r)&&!(i&&!i(t))}function FC(e,t){return((null==t?void 0:t.queryKeyHashFn)||$C)(e)}function $C(e){return JSON.stringify(e,(e,t)=>GC(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function zC(e,t){return e===t||typeof e==typeof t&&(!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every(n=>zC(e[n],t[n])))}var HC=Object.prototype.hasOwnProperty;function qC(e,t){if(e===t)return e;const n=KC(e)&&KC(t);if(!(n||GC(e)&&GC(t)))return t;const r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),o=i.length,s=n?new Array(o):{};let a=0;for(let c=0;c<o;c++){const o=n?c:i[c],l=e[o],u=t[o];if(l===u){s[o]=l,(n?c<r:HC.call(e,o))&&a++;continue}if(null===l||null===u||"object"!=typeof l||"object"!=typeof u){s[o]=u;continue}const d=qC(l,u);s[o]=d,d===l&&a++}return r===o&&a===r?e:s}function WC(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function KC(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function GC(e){if(!VC(e))return!1;const t=e.constructor;if(void 0===t)return!0;const n=t.prototype;return!!VC(n)&&(!!n.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype)}function VC(e){return"[object Object]"===Object.prototype.toString.call(e)}function ZC(e,t,n){return"function"==typeof n.structuralSharing?n.structuralSharing(e,t):!1!==n.structuralSharing?qC(e,t):t}function YC(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function JC(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var QC=Symbol();function XC(e,t){return!e.queryFn&&(null==t?void 0:t.initialPromise)?()=>t.initialPromise:e.queryFn&&e.queryFn!==QC?e.queryFn:()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`))}function eI(e,t){return"function"==typeof e?e(...t):!!e}var tI=new(s=class extends PC{constructor(){super(),Ae(this,r),Ae(this,i),Ae(this,o),Pe(this,o,e=>{if(!TC&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}})}onSubscribe(){Ie(this,i)||this.setEventListener(Ie(this,o))}onUnsubscribe(){var e;this.hasListeners()||(null==(e=Ie(this,i))||e.call(this),Pe(this,i,void 0))}setEventListener(e){var t;Pe(this,o,e),null==(t=Ie(this,i))||t.call(this),Pe(this,i,e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()}))}setFocused(e){Ie(this,r)!==e&&(Pe(this,r,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){var e;return"boolean"==typeof Ie(this,r)?Ie(this,r):"hidden"!==(null==(e=globalThis.document)?void 0:e.visibilityState)}},r=new WeakMap,i=new WeakMap,o=new WeakMap,s);function nI(){let e,t;const n=new Promise((n,r)=>{e=n,t=r});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.status="pending",n.catch(()=>{}),n.resolve=t=>{r({status:"fulfilled",value:t}),e(t)},n.reject=e=>{r({status:"rejected",reason:e}),t(e)},n}var rI=function(e){setTimeout(e,0)};var iI=function(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=rI;const o=r=>{t?e.push(r):i(()=>{n(r)})};return{batch:o=>{let s;t++;try{s=o()}finally{t--,t||(()=>{const t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})})()}return s},batchCalls:e=>(...t)=>{o(()=>{e(...t)})},schedule:o,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}(),oI=new(u=class extends PC{constructor(){super(),Ae(this,a,!0),Ae(this,c),Ae(this,l),Pe(this,l,e=>{if(!TC&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}})}onSubscribe(){Ie(this,c)||this.setEventListener(Ie(this,l))}onUnsubscribe(){var e;this.hasListeners()||(null==(e=Ie(this,c))||e.call(this),Pe(this,c,void 0))}setEventListener(e){var t;Pe(this,l,e),null==(t=Ie(this,c))||t.call(this),Pe(this,c,e(this.setOnline.bind(this)))}setOnline(e){Ie(this,a)!==e&&(Pe(this,a,e),this.listeners.forEach(t=>{t(e)}))}isOnline(){return Ie(this,a)}},a=new WeakMap,c=new WeakMap,l=new WeakMap,u);function sI(e){return Math.min(1e3*2**e,3e4)}function aI(e){return"online"!==(e??"online")||oI.isOnline()}var cI=class extends Error{constructor(e){super("CancelledError"),this.revert=null==e?void 0:e.revert,this.silent=null==e?void 0:e.silent}};function lI(e){let t,n=!1,r=0;const i=nI(),o=()=>"pending"!==i.status,s=()=>tI.isFocused()&&("always"===e.networkMode||oI.isOnline())&&e.canRun(),a=()=>aI(e.networkMode)&&e.canRun(),c=e=>{o()||(null==t||t(),i.resolve(e))},l=e=>{o()||(null==t||t(),i.reject(e))},u=()=>new Promise(n=>{var r;t=e=>{(o()||s())&&n(e)},null==(r=e.onPause)||r.call(e)}).then(()=>{var n;t=void 0,o()||null==(n=e.onContinue)||n.call(e)}),d=()=>{if(o())return;let t;const i=0===r?e.initialPromise:void 0;try{t=i??e.fn()}catch(a){t=Promise.reject(a)}Promise.resolve(t).then(c).catch(t=>{var i;if(o())return;const a=e.retry??(TC?0:3),c=e.retryDelay??sI,h="function"==typeof c?c(r,t):c,f=!0===a||"number"==typeof a&&r<a||"function"==typeof a&&a(r,t);var p;!n&&f?(r++,null==(i=e.onFail)||i.call(e,r,t),(p=h,new Promise(e=>{OC.setTimeout(e,p)})).then(()=>s()?void 0:u()).then(()=>{n?l(t):d()})):l(t)})};return{promise:i,status:()=>i.status,cancel:t=>{var n;if(!o()){const r=new cI(t);l(r),null==(n=e.onCancel)||n.call(e,r)}},continue:()=>(null==t||t(),i),cancelRetry:()=>{n=!0},continueRetry:()=>{n=!1},canStart:a,start:()=>(a()?d():u().then(d),i)}}var uI=(h=class{constructor(){Ae(this,d)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),NC(this.gcTime)&&Pe(this,d,OC.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(TC?1/0:3e5))}clearGcTimeout(){Ie(this,d)&&(OC.clearTimeout(Ie(this,d)),Pe(this,d,void 0))}},d=new WeakMap,h),dI=(_=class extends uI{constructor(e){super(),Ae(this,w),Ae(this,f),Ae(this,p),Ae(this,m),Ae(this,g),Ae(this,y),Ae(this,b),Ae(this,v),Pe(this,v,!1),Pe(this,b,e.defaultOptions),this.setOptions(e.options),this.observers=[],Pe(this,g,e.client),Pe(this,m,Ie(this,g).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,Pe(this,f,pI(this.options)),this.state=e.state??Ie(this,f),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return null==(e=Ie(this,y))?void 0:e.promise}setOptions(e){if(this.options={...Ie(this,b),...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){const e=pI(this.options);void 0!==e.data&&(this.setState(fI(e.data,e.dataUpdatedAt)),Pe(this,f,e))}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||Ie(this,m).remove(this)}setData(e,t){const n=ZC(this.state.data,e,this.options);return Me(this,w,E).call(this,{data:n,type:"success",dataUpdatedAt:null==t?void 0:t.updatedAt,manual:null==t?void 0:t.manual}),n}setState(e,t){Me(this,w,E).call(this,{type:"setState",state:e,setStateOptions:t})}cancel(e){var t,n;const r=null==(t=Ie(this,y))?void 0:t.promise;return null==(n=Ie(this,y))||n.cancel(e),r?r.then(RC).catch(RC):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Ie(this,f))}isActive(){return this.observers.some(e=>!1!==jC(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===QC||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===BC(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!LC(this.state.dataUpdatedAt,e))}onFocus(){var e;const t=this.observers.find(e=>e.shouldFetchOnWindowFocus());null==t||t.refetch({cancelRefetch:!1}),null==(e=Ie(this,y))||e.continue()}onOnline(){var e;const t=this.observers.find(e=>e.shouldFetchOnReconnect());null==t||t.refetch({cancelRefetch:!1}),null==(e=Ie(this,y))||e.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),Ie(this,m).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(Ie(this,y)&&(Ie(this,v)?Ie(this,y).cancel({revert:!0}):Ie(this,y).cancelRetry()),this.scheduleGc()),Ie(this,m).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Me(this,w,E).call(this,{type:"invalidate"})}async fetch(e,t){var n,r,i,o,s,a,c,l,u,d,h,f;if("idle"!==this.state.fetchStatus&&"rejected"!==(null==(n=Ie(this,y))?void 0:n.status()))if(void 0!==this.state.data&&(null==t?void 0:t.cancelRefetch))this.cancel({silent:!0});else if(Ie(this,y))return Ie(this,y).continueRetry(),Ie(this,y).promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}const b=new AbortController,_=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(Pe(this,v,!0),b.signal)})},x=()=>{const e=XC(this.options,t),n=(()=>{const e={client:Ie(this,g),queryKey:this.queryKey,meta:this.meta};return _(e),e})();return Pe(this,v,!1),this.options.persister?this.options.persister(e,n,this):e(n)},k=(()=>{const e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:Ie(this,g),state:this.state,fetchFn:x};return _(e),e})();null==(r=this.options.behavior)||r.onFetch(k,this),Pe(this,p,this.state),"idle"!==this.state.fetchStatus&&this.state.fetchMeta===(null==(i=k.fetchOptions)?void 0:i.meta)||Me(this,w,E).call(this,{type:"fetch",meta:null==(o=k.fetchOptions)?void 0:o.meta}),Pe(this,y,lI({initialPromise:null==t?void 0:t.initialPromise,fn:k.fetchFn,onCancel:e=>{e instanceof cI&&e.revert&&this.setState({...Ie(this,p),fetchStatus:"idle"}),b.abort()},onFail:(e,t)=>{Me(this,w,E).call(this,{type:"failed",failureCount:e,error:t})},onPause:()=>{Me(this,w,E).call(this,{type:"pause"})},onContinue:()=>{Me(this,w,E).call(this,{type:"continue"})},retry:k.options.retry,retryDelay:k.options.retryDelay,networkMode:k.options.networkMode,canRun:()=>!0}));try{const e=await Ie(this,y).start();if(void 0===e)throw new Error(`${this.queryHash} data is undefined`);return this.setData(e),null==(a=(s=Ie(this,m).config).onSuccess)||a.call(s,e,this),null==(l=(c=Ie(this,m).config).onSettled)||l.call(c,e,this.state.error,this),e}catch(S){if(S instanceof cI){if(S.silent)return Ie(this,y).promise;if(S.revert){if(void 0===this.state.data)throw S;return this.state.data}}throw Me(this,w,E).call(this,{type:"error",error:S}),null==(d=(u=Ie(this,m).config).onError)||d.call(u,S,this),null==(f=(h=Ie(this,m).config).onSettled)||f.call(h,this.state.data,S,this),S}finally{this.scheduleGc()}}},f=new WeakMap,p=new WeakMap,m=new WeakMap,g=new WeakMap,y=new WeakMap,b=new WeakMap,v=new WeakMap,w=new WeakSet,E=function(e){this.state=(t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...hI(t.data,this.options),fetchMeta:e.meta??null};case"success":const n={...t,...fI(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return Pe(this,p,e.manual?n:void 0),n;case"error":const r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),iI.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),Ie(this,m).notify({query:this,type:"updated",action:e})})},_);function hI(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:aI(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function fI(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function pI(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,n=void 0!==t,r=n?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var mI=(V=class extends PC{constructor(e,t){super(),Ae(this,D),Ae(this,x),Ae(this,k),Ae(this,S),Ae(this,C),Ae(this,I),Ae(this,A),Ae(this,P),Ae(this,M),Ae(this,O),Ae(this,T),Ae(this,R),Ae(this,N),Ae(this,L),Ae(this,B),Ae(this,j,new Set),this.options=t,Pe(this,x,e),Pe(this,M,null),Pe(this,P,nI()),this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(Ie(this,k).addObserver(this),gI(Ie(this,k),this.options)?Me(this,D,U).call(this):this.updateResult(),Me(this,D,H).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return yI(Ie(this,k),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return yI(Ie(this,k),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Me(this,D,q).call(this),Me(this,D,W).call(this),Ie(this,k).removeObserver(this)}setOptions(e){const t=this.options,n=Ie(this,k);if(this.options=Ie(this,x).defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof jC(this.options.enabled,Ie(this,k)))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Me(this,D,K).call(this),Ie(this,k).setOptions(this.options),t._defaulted&&!WC(this.options,t)&&Ie(this,x).getQueryCache().notify({type:"observerOptionsUpdated",query:Ie(this,k),observer:this});const r=this.hasListeners();r&&bI(Ie(this,k),n,this.options,t)&&Me(this,D,U).call(this),this.updateResult(),!r||Ie(this,k)===n&&jC(this.options.enabled,Ie(this,k))===jC(t.enabled,Ie(this,k))&&BC(this.options.staleTime,Ie(this,k))===BC(t.staleTime,Ie(this,k))||Me(this,D,F).call(this);const i=Me(this,D,$).call(this);!r||Ie(this,k)===n&&jC(this.options.enabled,Ie(this,k))===jC(t.enabled,Ie(this,k))&&i===Ie(this,B)||Me(this,D,z).call(this,i)}getOptimisticResult(e){const t=Ie(this,x).getQueryCache().build(Ie(this,x),e),n=this.createResult(t,e);return function(e,t){if(!WC(e.getCurrentResult(),t))return!0;return!1}(this,n)&&(Pe(this,C,n),Pe(this,A,this.options),Pe(this,I,Ie(this,k).state)),n}getCurrentResult(){return Ie(this,C)}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),null==t||t(n),"promise"===n&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==Ie(this,P).status||Ie(this,P).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,n))})}trackProp(e){Ie(this,j).add(e)}getCurrentQuery(){return Ie(this,k)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=Ie(this,x).defaultQueryOptions(e),n=Ie(this,x).getQueryCache().build(Ie(this,x),t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return Me(this,D,U).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),Ie(this,C)))}createResult(e,t){var n;const r=Ie(this,k),i=this.options,o=Ie(this,C),s=Ie(this,I),a=Ie(this,A),c=e!==r?e.state:Ie(this,S),{state:l}=e;let u,d={...l},h=!1;if(t._optimisticResults){const n=this.hasListeners(),o=!n&&gI(e,t),s=n&&bI(e,r,t,i);(o||s)&&(d={...d,...hI(l.data,e.options)}),"isRestoring"===t._optimisticResults&&(d.fetchStatus="idle")}let{error:f,errorUpdatedAt:p,status:m}=d;u=d.data;let g=!1;if(void 0!==t.placeholderData&&void 0===u&&"pending"===m){let e;(null==o?void 0:o.isPlaceholderData)&&t.placeholderData===(null==a?void 0:a.placeholderData)?(e=o.data,g=!0):e="function"==typeof t.placeholderData?t.placeholderData(null==(n=Ie(this,R))?void 0:n.state.data,Ie(this,R)):t.placeholderData,void 0!==e&&(m="success",u=ZC(null==o?void 0:o.data,e,t),h=!0)}if(t.select&&void 0!==u&&!g)if(o&&u===(null==s?void 0:s.data)&&t.select===Ie(this,O))u=Ie(this,T);else try{Pe(this,O,t.select),u=t.select(u),u=ZC(null==o?void 0:o.data,u,t),Pe(this,T,u),Pe(this,M,null)}catch(x){Pe(this,M,x)}Ie(this,M)&&(f=Ie(this,M),u=Ie(this,T),p=Date.now(),m="error");const y="fetching"===d.fetchStatus,b="pending"===m,v="error"===m,w=b&&y,E=void 0!==u,_={status:m,fetchStatus:d.fetchStatus,isPending:b,isSuccess:"success"===m,isError:v,isInitialLoading:w,isLoading:w,data:u,dataUpdatedAt:d.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!b,isLoadingError:v&&!E,isPaused:"paused"===d.fetchStatus,isPlaceholderData:h,isRefetchError:v&&E,isStale:vI(e,t),refetch:this.refetch,promise:Ie(this,P),isEnabled:!1!==jC(t.enabled,e)};if(this.options.experimental_prefetchInRender){const t=e=>{"error"===_.status?e.reject(_.error):void 0!==_.data&&e.resolve(_.data)},n=()=>{const e=Pe(this,P,_.promise=nI());t(e)},i=Ie(this,P);switch(i.status){case"pending":e.queryHash===r.queryHash&&t(i);break;case"fulfilled":"error"!==_.status&&_.data===i.value||n();break;case"rejected":"error"===_.status&&_.error===i.reason||n()}}return _}updateResult(){const e=Ie(this,C),t=this.createResult(Ie(this,k),this.options);if(Pe(this,I,Ie(this,k).state),Pe(this,A,this.options),void 0!==Ie(this,I).data&&Pe(this,R,Ie(this,k)),WC(t,e))return;Pe(this,C,t);Me(this,D,G).call(this,{listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,n="function"==typeof t?t():t;if("all"===n||!n&&!Ie(this,j).size)return!0;const r=new Set(n??Ie(this,j));return this.options.throwOnError&&r.add("error"),Object.keys(Ie(this,C)).some(t=>{const n=t;return Ie(this,C)[n]!==e[n]&&r.has(n)})})()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Me(this,D,H).call(this)}},x=new WeakMap,k=new WeakMap,S=new WeakMap,C=new WeakMap,I=new WeakMap,A=new WeakMap,P=new WeakMap,M=new WeakMap,O=new WeakMap,T=new WeakMap,R=new WeakMap,N=new WeakMap,L=new WeakMap,B=new WeakMap,j=new WeakMap,D=new WeakSet,U=function(e){Me(this,D,K).call(this);let t=Ie(this,k).fetch(this.options,e);return(null==e?void 0:e.throwOnError)||(t=t.catch(RC)),t},F=function(){Me(this,D,q).call(this);const e=BC(this.options.staleTime,Ie(this,k));if(TC||Ie(this,C).isStale||!NC(e))return;const t=LC(Ie(this,C).dataUpdatedAt,e)+1;Pe(this,N,OC.setTimeout(()=>{Ie(this,C).isStale||this.updateResult()},t))},$=function(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(Ie(this,k)):this.options.refetchInterval)??!1},z=function(e){Me(this,D,W).call(this),Pe(this,B,e),!TC&&!1!==jC(this.options.enabled,Ie(this,k))&&NC(Ie(this,B))&&0!==Ie(this,B)&&Pe(this,L,OC.setInterval(()=>{(this.options.refetchIntervalInBackground||tI.isFocused())&&Me(this,D,U).call(this)},Ie(this,B)))},H=function(){Me(this,D,F).call(this),Me(this,D,z).call(this,Me(this,D,$).call(this))},q=function(){Ie(this,N)&&(OC.clearTimeout(Ie(this,N)),Pe(this,N,void 0))},W=function(){Ie(this,L)&&(OC.clearInterval(Ie(this,L)),Pe(this,L,void 0))},K=function(){const e=Ie(this,x).getQueryCache().build(Ie(this,x),this.options);if(e===Ie(this,k))return;const t=Ie(this,k);Pe(this,k,e),Pe(this,S,e.state),this.hasListeners()&&(null==t||t.removeObserver(this),e.addObserver(this))},G=function(e){iI.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(Ie(this,C))}),Ie(this,x).getQueryCache().notify({query:Ie(this,k),type:"observerResultsUpdated"})})},V);function gI(e,t){return function(e,t){return!1!==jC(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===t.retryOnMount)}(e,t)||void 0!==e.state.data&&yI(e,t,t.refetchOnMount)}function yI(e,t,n){if(!1!==jC(t.enabled,e)&&"static"!==BC(t.staleTime,e)){const r="function"==typeof n?n(e):n;return"always"===r||!1!==r&&vI(e,t)}return!1}function bI(e,t,n,r){return(e!==t||!1===jC(r.enabled,e))&&(!n.suspense||"error"!==e.state.status)&&vI(e,n)}function vI(e,t){return!1!==jC(t.enabled,e)&&e.isStaleByTime(BC(t.staleTime,e))}function wI(e){return{onFetch:(t,n)=>{var r,i,o,s,a;const c=t.options,l=null==(o=null==(i=null==(r=t.fetchOptions)?void 0:r.meta)?void 0:i.fetchMore)?void 0:o.direction,u=(null==(s=t.state.data)?void 0:s.pages)||[],d=(null==(a=t.state.data)?void 0:a.pageParams)||[];let h={pages:[],pageParams:[]},f=0;const p=async()=>{let n=!1;const r=XC(t.options,t.fetchOptions),i=async(e,i,o)=>{if(n)return Promise.reject();if(null==i&&e.pages.length)return Promise.resolve(e);const s=(()=>{const e={client:t.client,queryKey:t.queryKey,pageParam:i,direction:o?"backward":"forward",meta:t.options.meta};var r;return r=e,Object.defineProperty(r,"signal",{enumerable:!0,get:()=>(t.signal.aborted?n=!0:t.signal.addEventListener("abort",()=>{n=!0}),t.signal)}),e})(),a=await r(s),{maxPages:c}=t.options,l=o?JC:YC;return{pages:l(e.pages,a,c),pageParams:l(e.pageParams,i,c)}};if(l&&u.length){const e="backward"===l,t={pages:u,pageParams:d},n=(e?_I:EI)(c,t);h=await i(t,n,e)}else{const t=e??u.length;do{const e=0===f?d[0]??c.initialPageParam:EI(c,h);if(f>0&&null==e)break;h=await i(h,e),f++}while(f<t)}return h};t.options.persister?t.fetchFn=()=>{var e,r;return null==(r=(e=t.options).persister)?void 0:r.call(e,p,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=p}}}function EI(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function _I(e,{pages:t,pageParams:n}){var r;return t.length>0?null==(r=e.getPreviousPageParam)?void 0:r.call(e,t[0],t,n[0],n):void 0}var xI=(te=class extends uI{constructor(e){super(),Ae(this,X),Ae(this,Z),Ae(this,Y),Ae(this,J),Ae(this,Q),Pe(this,Z,e.client),this.mutationId=e.mutationId,Pe(this,J,e.mutationCache),Pe(this,Y,[]),this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){Ie(this,Y).includes(e)||(Ie(this,Y).push(e),this.clearGcTimeout(),Ie(this,J).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){Pe(this,Y,Ie(this,Y).filter(t=>t!==e)),this.scheduleGc(),Ie(this,J).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){Ie(this,Y).length||("pending"===this.state.status?this.scheduleGc():Ie(this,J).remove(this))}continue(){var e;return(null==(e=Ie(this,Q))?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var t,n,r,i,o,s,a,c,l,u,d,h,f,p,m,g,y,b,v,w;const E=()=>{Me(this,X,ee).call(this,{type:"continue"})},_={client:Ie(this,Z),meta:this.options.meta,mutationKey:this.options.mutationKey};Pe(this,Q,lI({fn:()=>this.options.mutationFn?this.options.mutationFn(e,_):Promise.reject(new Error("No mutationFn found")),onFail:(e,t)=>{Me(this,X,ee).call(this,{type:"failed",failureCount:e,error:t})},onPause:()=>{Me(this,X,ee).call(this,{type:"pause"})},onContinue:E,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>Ie(this,J).canRun(this)}));const x="pending"===this.state.status,k=!Ie(this,Q).canStart();try{if(x)E();else{Me(this,X,ee).call(this,{type:"pending",variables:e,isPaused:k}),await(null==(n=(t=Ie(this,J).config).onMutate)?void 0:n.call(t,e,this,_));const o=await(null==(i=(r=this.options).onMutate)?void 0:i.call(r,e,_));o!==this.state.context&&Me(this,X,ee).call(this,{type:"pending",context:o,variables:e,isPaused:k})}const f=await Ie(this,Q).start();return await(null==(s=(o=Ie(this,J).config).onSuccess)?void 0:s.call(o,f,e,this.state.context,this,_)),await(null==(c=(a=this.options).onSuccess)?void 0:c.call(a,f,e,this.state.context,_)),await(null==(u=(l=Ie(this,J).config).onSettled)?void 0:u.call(l,f,null,this.state.variables,this.state.context,this,_)),await(null==(h=(d=this.options).onSettled)?void 0:h.call(d,f,null,e,this.state.context,_)),Me(this,X,ee).call(this,{type:"success",data:f}),f}catch(S){try{throw await(null==(p=(f=Ie(this,J).config).onError)?void 0:p.call(f,S,e,this.state.context,this,_)),await(null==(g=(m=this.options).onError)?void 0:g.call(m,S,e,this.state.context,_)),await(null==(b=(y=Ie(this,J).config).onSettled)?void 0:b.call(y,void 0,S,this.state.variables,this.state.context,this,_)),await(null==(w=(v=this.options).onSettled)?void 0:w.call(v,void 0,S,e,this.state.context,_)),S}finally{Me(this,X,ee).call(this,{type:"error",error:S})}}finally{Ie(this,J).runNext(this)}}},Z=new WeakMap,Y=new WeakMap,J=new WeakMap,Q=new WeakMap,X=new WeakSet,ee=function(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),iI.batch(()=>{Ie(this,Y).forEach(t=>{t.onMutationUpdate(e)}),Ie(this,J).notify({mutation:this,type:"updated",action:e})})},te);var kI=(oe=class extends PC{constructor(e={}){super(),Ae(this,ne),Ae(this,re),Ae(this,ie),this.config=e,Pe(this,ne,new Set),Pe(this,re,new Map),Pe(this,ie,0)}build(e,t,n){const r=new xI({client:e,mutationCache:this,mutationId:++Oe(this,ie)._,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){Ie(this,ne).add(e);const t=SI(e);if("string"==typeof t){const n=Ie(this,re).get(t);n?n.push(e):Ie(this,re).set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(Ie(this,ne).delete(e)){const t=SI(e);if("string"==typeof t){const n=Ie(this,re).get(t);if(n)if(n.length>1){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}else n[0]===e&&Ie(this,re).delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=SI(e);if("string"==typeof t){const n=Ie(this,re).get(t),r=null==n?void 0:n.find(e=>"pending"===e.state.status);return!r||r===e}return!0}runNext(e){var t;const n=SI(e);if("string"==typeof n){const r=null==(t=Ie(this,re).get(n))?void 0:t.find(t=>t!==e&&t.state.isPaused);return(null==r?void 0:r.continue())??Promise.resolve()}return Promise.resolve()}clear(){iI.batch(()=>{Ie(this,ne).forEach(e=>{this.notify({type:"removed",mutation:e})}),Ie(this,ne).clear(),Ie(this,re).clear()})}getAll(){return Array.from(Ie(this,ne))}find(e){const t={exact:!0,...e};return this.getAll().find(e=>UC(t,e))}findAll(e={}){return this.getAll().filter(t=>UC(e,t))}notify(e){iI.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(e=>e.state.isPaused);return iI.batch(()=>Promise.all(e.map(e=>e.continue().catch(RC))))}},ne=new WeakMap,re=new WeakMap,ie=new WeakMap,oe);function SI(e){var t;return null==(t=e.options.scope)?void 0:t.id}var CI=(fe=class extends PC{constructor(e,t){super(),Ae(this,ue),Ae(this,se),Ae(this,ae),Ae(this,ce),Ae(this,le),Pe(this,se,e),this.setOptions(t),this.bindMethods(),Me(this,ue,de).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var t;const n=this.options;this.options=Ie(this,se).defaultMutationOptions(e),WC(this.options,n)||Ie(this,se).getMutationCache().notify({type:"observerOptionsUpdated",mutation:Ie(this,ce),observer:this}),(null==n?void 0:n.mutationKey)&&this.options.mutationKey&&$C(n.mutationKey)!==$C(this.options.mutationKey)?this.reset():"pending"===(null==(t=Ie(this,ce))?void 0:t.state.status)&&Ie(this,ce).setOptions(this.options)}onUnsubscribe(){var e;this.hasListeners()||null==(e=Ie(this,ce))||e.removeObserver(this)}onMutationUpdate(e){Me(this,ue,de).call(this),Me(this,ue,he).call(this,e)}getCurrentResult(){return Ie(this,ae)}reset(){var e;null==(e=Ie(this,ce))||e.removeObserver(this),Pe(this,ce,void 0),Me(this,ue,de).call(this),Me(this,ue,he).call(this)}mutate(e,t){var n;return Pe(this,le,t),null==(n=Ie(this,ce))||n.removeObserver(this),Pe(this,ce,Ie(this,se).getMutationCache().build(Ie(this,se),this.options)),Ie(this,ce).addObserver(this),Ie(this,ce).execute(e)}},se=new WeakMap,ae=new WeakMap,ce=new WeakMap,le=new WeakMap,ue=new WeakSet,de=function(){var e;const t=(null==(e=Ie(this,ce))?void 0:e.state)??{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0};Pe(this,ae,{...t,isPending:"pending"===t.status,isSuccess:"success"===t.status,isError:"error"===t.status,isIdle:"idle"===t.status,mutate:this.mutate,reset:this.reset})},he=function(e){iI.batch(()=>{var t,n,r,i,o,s,a,c;if(Ie(this,le)&&this.hasListeners()){const l=Ie(this,ae).variables,u=Ie(this,ae).context,d={client:Ie(this,se),meta:this.options.meta,mutationKey:this.options.mutationKey};"success"===(null==e?void 0:e.type)?(null==(n=(t=Ie(this,le)).onSuccess)||n.call(t,e.data,l,u,d),null==(i=(r=Ie(this,le)).onSettled)||i.call(r,e.data,null,l,u,d)):"error"===(null==e?void 0:e.type)&&(null==(s=(o=Ie(this,le)).onError)||s.call(o,e.error,l,u,d),null==(c=(a=Ie(this,le)).onSettled)||c.call(a,void 0,e.error,l,u,d))}this.listeners.forEach(e=>{e(Ie(this,ae))})})},fe),II=(me=class extends PC{constructor(e={}){super(),Ae(this,pe),this.config=e,Pe(this,pe,new Map)}build(e,t,n){const r=t.queryKey,i=t.queryHash??FC(r,t);let o=this.get(i);return o||(o=new dI({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(o)),o}add(e){Ie(this,pe).has(e.queryHash)||(Ie(this,pe).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=Ie(this,pe).get(e.queryHash);t&&(e.destroy(),t===e&&Ie(this,pe).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){iI.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return Ie(this,pe).get(e)}getAll(){return[...Ie(this,pe).values()]}find(e){const t={exact:!0,...e};return this.getAll().find(e=>DC(t,e))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(t=>DC(e,t)):t}notify(e){iI.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){iI.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){iI.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},pe=new WeakMap,me),AI=(ke=class{constructor(e={}){Ae(this,ge),Ae(this,ye),Ae(this,be),Ae(this,ve),Ae(this,we),Ae(this,Ee),Ae(this,_e),Ae(this,xe),Pe(this,ge,e.queryCache||new II),Pe(this,ye,e.mutationCache||new kI),Pe(this,be,e.defaultOptions||{}),Pe(this,ve,new Map),Pe(this,we,new Map),Pe(this,Ee,0)}mount(){Oe(this,Ee)._++,1===Ie(this,Ee)&&(Pe(this,_e,tI.subscribe(async e=>{e&&(await this.resumePausedMutations(),Ie(this,ge).onFocus())})),Pe(this,xe,oI.subscribe(async e=>{e&&(await this.resumePausedMutations(),Ie(this,ge).onOnline())})))}unmount(){var e,t;Oe(this,Ee)._--,0===Ie(this,Ee)&&(null==(e=Ie(this,_e))||e.call(this),Pe(this,_e,void 0),null==(t=Ie(this,xe))||t.call(this),Pe(this,xe,void 0))}isFetching(e){return Ie(this,ge).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return Ie(this,ye).findAll({...e,status:"pending"}).length}getQueryData(e){var t;const n=this.defaultQueryOptions({queryKey:e});return null==(t=Ie(this,ge).get(n.queryHash))?void 0:t.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=Ie(this,ge).build(this,t),r=n.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(BC(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return Ie(this,ge).findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=Ie(this,ge).get(r.queryHash),o=function(e,t){return"function"==typeof e?e(t):e}(t,null==i?void 0:i.state.data);if(void 0!==o)return Ie(this,ge).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return iI.batch(()=>Ie(this,ge).findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){var t;const n=this.defaultQueryOptions({queryKey:e});return null==(t=Ie(this,ge).get(n.queryHash))?void 0:t.state}removeQueries(e){const t=Ie(this,ge);iI.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){const n=Ie(this,ge);return iI.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=iI.batch(()=>Ie(this,ge).findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(RC).catch(RC)}invalidateQueries(e,t={}){return iI.batch(()=>(Ie(this,ge).findAll(e).forEach(e=>{e.invalidate()}),"none"===(null==e?void 0:e.refetchType)?Promise.resolve():this.refetchQueries({...e,type:(null==e?void 0:e.refetchType)??(null==e?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=iI.batch(()=>Ie(this,ge).findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(RC)),"paused"===e.state.fetchStatus?Promise.resolve():t}));return Promise.all(r).then(RC)}fetchQuery(e){const t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);const n=Ie(this,ge).build(this,t);return n.isStaleByTime(BC(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(RC).catch(RC)}fetchInfiniteQuery(e){return e.behavior=wI(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(RC).catch(RC)}ensureInfiniteQueryData(e){return e.behavior=wI(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return oI.isOnline()?Ie(this,ye).resumePausedMutations():Promise.resolve()}getQueryCache(){return Ie(this,ge)}getMutationCache(){return Ie(this,ye)}getDefaultOptions(){return Ie(this,be)}setDefaultOptions(e){Pe(this,be,e)}setQueryDefaults(e,t){Ie(this,ve).set($C(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...Ie(this,ve).values()],n={};return t.forEach(t=>{zC(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){Ie(this,we).set($C(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...Ie(this,we).values()],n={};return t.forEach(t=>{zC(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...Ie(this,be).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=FC(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===QC&&(t.enabled=!1),t}defaultMutationOptions(e){return(null==e?void 0:e._defaulted)?e:{...Ie(this,be).mutations,...(null==e?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){Ie(this,ge).clear(),Ie(this,ye).clear()}},ge=new WeakMap,ye=new WeakMap,be=new WeakMap,ve=new WeakMap,we=new WeakMap,Ee=new WeakMap,_e=new WeakMap,xe=new WeakMap,ke);function PI(e){return JSON.stringify(e,(e,t)=>function(e){if(!MI(e))return!1;const t=e.constructor;if(void 0===t)return!0;const n=t.prototype;return!!MI(n)&&!!n.hasOwnProperty("isPrototypeOf")}(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):"bigint"==typeof t?t.toString():t)}function MI(e){return"[object Object]"===Object.prototype.toString.call(e)}function OI(e){const{_defaulted:t,behavior:n,gcTime:r,initialData:i,initialDataUpdatedAt:o,maxPages:s,meta:a,networkMode:c,queryFn:l,queryHash:u,queryKey:d,queryKeyHashFn:h,retry:f,retryDelay:p,structuralSharing:m,getPreviousPageParam:g,getNextPageParam:y,initialPageParam:b,_optimisticResults:v,enabled:w,notifyOnChangeProps:E,placeholderData:_,refetchInterval:x,refetchIntervalInBackground:k,refetchOnMount:S,refetchOnReconnect:C,refetchOnWindowFocus:I,retryOnMount:A,select:P,staleTime:M,suspense:O,throwOnError:T,config:R,connector:N,query:L,...B}=e;return B}function TI(e){return{mutationFn:t=>async function(e,t){var n;let r;if(r="function"==typeof t.connector?e._internal.connectors.setup(t.connector):t.connector,r.uid===e.state.current)throw new _S;try{e.setState(e=>({...e,status:"connecting"})),r.emitter.emit("message",{type:"connecting"});const{connector:i,...o}=t,s=await r.connect(o);return r.emitter.off("connect",e._internal.events.connect),r.emitter.on("change",e._internal.events.change),r.emitter.on("disconnect",e._internal.events.disconnect),await(null==(n=e.storage)?void 0:n.setItem("recentConnectorId",r.id)),e.setState(e=>({...e,connections:new Map(e.connections).set(r.uid,{accounts:o.withCapabilities?s.accounts.map(e=>"object"==typeof e?e.address:e):s.accounts,chainId:s.chainId,connector:r}),current:r.uid,status:"connected"})),{accounts:o.withCapabilities?s.accounts.map(e=>"object"==typeof e?e:{address:e,capabilities:{}}):s.accounts,chainId:s.chainId}}catch(i){throw e.setState(e=>({...e,status:e.current?"connected":"disconnected"})),i}}(e,t),mutationKey:["connect"]}}function RI(e){return{mutationFn:t=>async function(e,t){var n;const{addEthereumChainParameter:r,chainId:i}=t,o=e.state.connections.get((null==(n=t.connector)?void 0:n.uid)??e.state.current);if(o){const e=o.connector;if(!e.switchChain)throw new JS({connector:e});return await e.switchChain({addEthereumChainParameter:r,chainId:i})}const s=e.chains.find(e=>e.id===i);if(!s)throw new ES;return e.setState(e=>({...e,chainId:i})),s}(e,t),mutationKey:["switchChain"]}}function NI(e,t={}){return{async queryFn({queryKey:n}){const{hash:r,...i}=n[1];if(!r)throw new Error("hash is required");return async function(e,t){const{chainId:n,timeout:r=0,...i}=t,o=e.getClient({chainId:n}),s=gS(o,iS,"waitForTransactionReceipt"),a=await s({...i,timeout:r});if("reverted"===a.status){const e=gS(o,Ik,"getTransaction"),{from:t,...n}=await e({hash:a.transactionHash}),r=gS(o,dw,"call"),i=await r({...n,account:t,data:n.input,gasPrice:"eip1559"!==n.type?n.gasPrice:void 0,maxFeePerGas:"eip1559"===n.type?n.maxFeePerGas:void 0,maxPriorityFeePerGas:"eip1559"===n.type?n.maxPriorityFeePerGas:void 0}),s=(null==i?void 0:i.data)?Hf(`0x${i.data.substring(138)}`):"unknown reason";throw new Error(s)}return{...a,chainId:o.chain.id}}(e,{...i,onReplaced:t.onReplaced,hash:r})},queryKey:LI(t)}}function LI(e={}){const{onReplaced:t,...n}=e;return["waitForTransactionReceipt",OI(n)]}var BI=yt.createContext(void 0),jI=e=>{const t=yt.useContext(BI);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},DI=({client:e,children:t})=>(yt.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),Dh.jsx(BI.Provider,{value:e,children:t})),UI=yt.createContext(!1);UI.Provider;var FI=yt.createContext(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),$I=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function zI(e,t,n){var r,i,o,s,a;const c=yt.useContext(UI),l=yt.useContext(FI),u=jI(),d=u.defaultQueryOptions(e);null==(i=null==(r=u.getDefaultOptions().queries)?void 0:r._experimental_beforeQuery)||i.call(r,d),d._optimisticResults=c?"isRestoring":"optimistic",(e=>{if(e.suspense){const t=1e3,n=e=>"static"===e?e:Math.max(e??t,t),r=e.staleTime;e.staleTime="function"==typeof r?(...e)=>n(r(...e)):n(r),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,t))}})(d),((e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))})(d,l),(e=>{yt.useEffect(()=>{e.clearReset()},[e])})(l);const h=!u.getQueryCache().get(d.queryHash),[f]=yt.useState(()=>new t(u,d)),p=f.getOptimisticResult(d),m=!c&&!1!==e.subscribed;if(yt.useSyncExternalStore(yt.useCallback(e=>{const t=m?f.subscribe(iI.batchCalls(e)):RC;return f.updateResult(),t},[f,m]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),yt.useEffect(()=>{f.setOptions(d)},[d,f]),((e,t)=>(null==e?void 0:e.suspense)&&t.isPending)(d,p))throw $I(d,f,l);if((({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&void 0===e.data||eI(n,[e.error,r])))({result:p,errorResetBoundary:l,throwOnError:d.throwOnError,query:u.getQueryCache().get(d.queryHash),suspense:d.suspense}))throw p.error;if(null==(s=null==(o=u.getDefaultOptions().queries)?void 0:o._experimental_afterQuery)||s.call(o,d,p),d.experimental_prefetchInRender&&!TC&&((e,t)=>e.isLoading&&e.isFetching&&!t)(p,c)){const e=h?$I(d,f,l):null==(a=u.getQueryCache().get(d.queryHash))?void 0:a.promise;null==e||e.catch(RC).finally(()=>{f.updateResult()})}return d.notifyOnChangeProps?p:f.trackResult(p)}function HI(e,t){const n=jI(),[r]=yt.useState(()=>new CI(n,e));yt.useEffect(()=>{r.setOptions(e)},[r,e]);const i=yt.useSyncExternalStore(yt.useCallback(e=>r.subscribe(iI.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=yt.useCallback((e,t)=>{r.mutate(e,t).catch(RC)},[r]);if(i.error&&eI(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}function qI(e){const t=zI({...e,queryKeyHashFn:PI},mI);return t.queryKey=e.queryKey,t}function WI(e={}){const t=iC(e);return yt.useSyncExternalStore(e=>function(e,t){const{onChange:n}=t;return e._internal.chains.subscribe((e,t)=>{n(e,t)})}(t,{onChange:e}),()=>KS(t),()=>KS(t))}function KI(e={}){const t=iC(e);return yt.useSyncExternalStore(e=>function(e,t){const{onChange:n}=t;return e._internal.connectors.subscribe((e,t)=>{n(Object.values(e),t)})}(t,{onChange:e}),()=>VS(t),()=>VS(t))}function GI(e={}){const{mutation:t}=e,n=iC(e),r=TI(n),{mutate:i,mutateAsync:o,...s}=HI({...t,...r});return yt.useEffect(()=>n.subscribe(({status:e})=>e,(e,t)=>{"connected"===t&&"disconnected"===e&&s.reset()}),[n,s.reset]),{...s,connect:i,connectAsync:o,connectors:KI({config:n})}}function VI(e={}){const{mutation:t}=e,n=function(e){return{mutationFn:t=>YS(e,t),mutationKey:["sendTransaction"]}}(iC(e)),{mutate:r,mutateAsync:i,...o}=HI({...t,...n});return{...o,sendTransaction:r,sendTransactionAsync:i}}function ZI(e={}){const{hash:t,query:n={}}=e,r=iC(e),i=function(e={}){const t=iC(e);return yt.useSyncExternalStore(e=>function(e,t){const{onChange:n}=t;return e.subscribe(e=>e.chainId,n)}(t,{onChange:e}),()=>HS(t),()=>HS(t))}({config:r}),o=NI(r,{...e,chainId:e.chainId??i}),s=Boolean(t&&(n.enabled??!0));return qI({...n,...o,enabled:s})}function YI(e,t,n){const r=e[t.name];if("function"==typeof r)return r;const i=e[n];return"function"==typeof i?i:n=>t(e,n)}const JI="2.19.0";var QI,XI,eA=function(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)};let tA=class e extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return`@wagmi/core@${JI}`}constructor(t,n={}){var r;super(),QI.add(this),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:"WagmiCoreError"});const i=n.cause instanceof e?n.cause.details:(null==(r=n.cause)?void 0:r.message)?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath;this.message=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...o?[`Docs: ${this.docsBaseUrl}${o}.html${n.docsSlug?`#${n.docsSlug}`:""}`]:[],...i?[`Details: ${i}`]:[],`Version: ${this.version}`].join("\n"),n.cause&&(this.cause=n.cause),this.details=i,this.docsPath=o,this.metaMessages=n.metaMessages,this.shortMessage=t}walk(e){return eA(this,QI,"m",XI).call(this,this,e)}};QI=new WeakSet,XI=function e(t,n){return(null==n?void 0:n(t))?t:t.cause?eA(this,QI,"m",e).call(this,t.cause,n):t};class nA extends tA{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class rA extends tA{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class iA extends tA{constructor({address:e,connector:t}){super(`Account "${e}" not found for connector "${t.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class oA extends tA{constructor({connectionChainId:e,connectorChainId:t}){super(`The current chain of the connector (id: ${t}) does not match the connection's chain (id: ${e}).`,{metaMessages:[`Current Chain ID: ${t}`,`Expected Chain ID: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class sA extends tA{constructor({connector:e}){super(`Connector "${e.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function aA(e,t={}){let n;if(t.connector){const{connector:r}=t;if("reconnecting"===e.state.status&&!r.getAccounts&&!r.getChainId)throw new sA({connector:r});const[i,o]=await Promise.all([r.getAccounts().catch(e=>{if(null===t.account)return[];throw e}),r.getChainId()]);n={accounts:i,chainId:o,connector:r}}else n=e.state.connections.get(e.state.current);if(!n)throw new rA;const r=t.chainId??n.chainId,i=await n.connector.getChainId();if(i!==n.chainId)throw new oA({connectionChainId:n.chainId,connectorChainId:i});const o=n.connector;if(o.getClient)return o.getClient({chainId:r});const s=Og(t.account??n.accounts[0]);if(s&&(s.address=Hp(s.address)),t.account&&!n.accounts.some(e=>e.toLowerCase()===s.address.toLowerCase()))throw new iA({address:s.address,connector:o});const a=e.chains.find(e=>e.id===r),c=await n.connector.getProvider({chainId:r});return MS({account:s,chain:a,name:"Connector Client",transport:e=>jS(c)({...e,retryCount:0})})}async function cA(e,t={}){const{chainId:n,formatUnits:r="gwei",...i}=t,o=e.getClient({chainId:n}),s=YI(o,rE,"estimateFeesPerGas"),{gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l}=await s({...i,chain:o.chain}),u=function(e){return"number"==typeof e?e:"wei"===e?0:Math.abs(Fg[e])}(r);return{formatted:{gasPrice:a?$g(a,u):void 0,maxFeePerGas:c?$g(c,u):void 0,maxPriorityFeePerGas:l?$g(l,u):void 0},gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:l}}function lA(e){const t=e.state.current,n=e.state.connections.get(t),r=null==n?void 0:n.accounts,i=null==r?void 0:r[0],o=e.chains.find(e=>e.id===(null==n?void 0:n.chainId)),s=e.state.status;switch(s){case"connected":return{address:i,addresses:r,chain:o,chainId:null==n?void 0:n.chainId,connector:null==n?void 0:n.connector,isConnected:!0,isConnecting:!1,isDisconnected:!1,isReconnecting:!1,status:s};case"reconnecting":return{address:i,addresses:r,chain:o,chainId:null==n?void 0:n.chainId,connector:null==n?void 0:n.connector,isConnected:!!i,isConnecting:!1,isDisconnected:!1,isReconnecting:!0,status:s};case"connecting":return{address:i,addresses:r,chain:o,chainId:null==n?void 0:n.chainId,connector:null==n?void 0:n.connector,isConnected:!1,isConnecting:!0,isDisconnected:!1,isReconnecting:!1,status:s};case"disconnected":return{address:void 0,addresses:void 0,chain:void 0,chainId:void 0,connector:void 0,isConnected:!1,isConnecting:!1,isDisconnected:!0,isReconnecting:!1,status:s}}}function uA(e,t){const{chainId:n,...r}=t;return YI(e.getClient({chainId:n}),fw,"readContract")(r)}class dA extends tA{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}async function hA(e,t){const{chainId:n,timeout:r=0,...i}=t,o=e.getClient({chainId:n}),s=YI(o,iS,"waitForTransactionReceipt"),a=await s({...i,timeout:r});if("reverted"===a.status){const e=YI(o,Ik,"getTransaction"),t=await e({hash:a.transactionHash}),n=YI(o,dw,"call"),r=await n({...t,data:t.input,gasPrice:"eip1559"!==t.type?t.gasPrice:void 0,maxFeePerGas:"eip1559"===t.type?t.maxFeePerGas:void 0,maxPriorityFeePerGas:"eip1559"===t.type?t.maxPriorityFeePerGas:void 0}),i=(null==r?void 0:r.data)?Hf(`0x${r.data.substring(138)}`):"unknown reason";throw new Error(i)}return{...a,chainId:o.chain.id}}async function fA(e,t){const{account:n,chainId:r,connector:i,...o}=t;let s;s="object"==typeof n&&"local"===(null==n?void 0:n.type)?e.getClient({chainId:r}):await aA(e,{account:n??void 0,chainId:r,connector:i});const a=YI(s,mS,"writeContract");return await a({...o,...n?{account:n}:{},chain:r?{id:r}:null})}function pA(e={}){const{shimDisconnect:t=!0,unstable_shimAsyncInject:n}=e;function r(){const t=e.target;if("function"==typeof t){const e=t();if(e)return e}return"object"==typeof t?t:"string"==typeof t?{...mA[t]??{id:t,name:`${t[0].toUpperCase()}${t.slice(1)}`,provider:`is${t[0].toUpperCase()}${t.slice(1)}`}}:{id:"injected",name:"Injected",provider:e=>null==e?void 0:e.ethereum}}let i,o,s,a;return c=>({get icon(){return r().icon},get id(){return r().id},get name(){return r().name},get supportsSimulation(){return!0},type:pA.type,async setup(){const t=await this.getProvider();(null==t?void 0:t.on)&&e.target&&(s||(s=this.onConnect.bind(this),t.on("connect",s)),i||(i=this.onAccountsChanged.bind(this),t.on("accountsChanged",i)))},async connect({chainId:n,isReconnecting:r}={}){var l,u,d,h,f,p;const m=await this.getProvider();if(!m)throw new dA;let g=[];if(r)g=await this.getAccounts().catch(()=>[]);else if(t)try{if(g=null==(h=null==(d=null==(u=null==(l=(await m.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0])?void 0:l.caveats)?void 0:u[0])?void 0:d.value)?void 0:h.map(e=>Hp(e)),g.length>0){g=await this.getAccounts()}}catch(y){const e=y;if(e.code===Uy.code)throw new Uy(e);if(e.code===Ny.code)throw e}try{if(!(null==g?void 0:g.length)&&!r){g=(await m.request({method:"eth_requestAccounts"})).map(e=>Hp(e))}s&&(m.removeListener("connect",s),s=void 0),i||(i=this.onAccountsChanged.bind(this),m.on("accountsChanged",i)),o||(o=this.onChainChanged.bind(this),m.on("chainChanged",o)),a||(a=this.onDisconnect.bind(this),m.on("disconnect",a));let l=await this.getChainId();if(n&&l!==n){const e=await this.switchChain({chainId:n}).catch(e=>{if(e.code===Uy.code)throw e;return{id:l}});l=(null==e?void 0:e.id)??l}return t&&await(null==(f=c.storage)?void 0:f.removeItem(`${this.id}.disconnected`)),e.target||await(null==(p=c.storage)?void 0:p.setItem("injected.connected",!0)),{accounts:g,chainId:l}}catch(y){const e=y;if(e.code===Uy.code)throw new Uy(e);if(e.code===Ny.code)throw new Ny(e);throw e}},async disconnect(){var n,r;const i=await this.getProvider();if(!i)throw new dA;o&&(i.removeListener("chainChanged",o),o=void 0),a&&(i.removeListener("disconnect",a),a=void 0),s||(s=this.onConnect.bind(this),i.on("connect",s));try{await g_(()=>i.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}t&&await(null==(n=c.storage)?void 0:n.setItem(`${this.id}.disconnected`,!0)),e.target||await(null==(r=c.storage)?void 0:r.removeItem("injected.connected"))},async getAccounts(){const e=await this.getProvider();if(!e)throw new dA;return(await e.request({method:"eth_accounts"})).map(e=>Hp(e))},async getChainId(){const e=await this.getProvider();if(!e)throw new dA;const t=await e.request({method:"eth_chainId"});return Number(t)},async getProvider(){if("undefined"==typeof window)return;let e;const t=r();return e="function"==typeof t.provider?t.provider(window):"string"==typeof t.provider?gA(window,t.provider):t.provider,e&&!e.removeListener&&("off"in e&&"function"==typeof e.off?e.removeListener=e.off:e.removeListener=()=>{}),e},async isAuthorized(){var r,i;try{if(t&&await(null==(r=c.storage)?void 0:r.getItem(`${this.id}.disconnected`)))return!1;if(!e.target){if(!(await(null==(i=c.storage)?void 0:i.getItem("injected.connected"))))return!1}if(!(await this.getProvider())){if(void 0!==n&&!1!==n){const e=async()=>{"undefined"!=typeof window&&window.removeEventListener("ethereum#initialized",e);return!!(await this.getProvider())},t="number"==typeof n?n:1e3;if(await Promise.race([..."undefined"!=typeof window?[new Promise(t=>window.addEventListener("ethereum#initialized",()=>t(e()),{once:!0}))]:[],new Promise(n=>setTimeout(()=>n(e()),t))]))return!0}throw new dA}return!!(await r_(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:e,chainId:t}){var n,r,i,o;const s=await this.getProvider();if(!s)throw new dA;const a=c.chains.find(e=>e.id===t);if(!a)throw new qy(new nA);const l=new Promise(e=>{const n=r=>{"chainId"in r&&r.chainId===t&&(c.emitter.off("change",n),e())};c.emitter.on("change",n)});try{return await Promise.all([s.request({method:"wallet_switchEthereumChain",params:[{chainId:Vf(t)}]}).then(async()=>{await this.getChainId()===t&&c.emitter.emit("change",{chainId:t})}),l]),a}catch(u){const h=u;if(4902===h.code||4902===(null==(r=null==(n=null==h?void 0:h.data)?void 0:n.originalError)?void 0:r.code))try{const{default:n,...r}=a.blockExplorers??{};let u,d;(null==e?void 0:e.blockExplorerUrls)?u=e.blockExplorerUrls:n&&(u=[n.url,...Object.values(r).map(e=>e.url)]),d=(null==(i=null==e?void 0:e.rpcUrls)?void 0:i.length)?e.rpcUrls:[(null==(o=a.rpcUrls.default)?void 0:o.http[0])??""];const h={blockExplorerUrls:u,chainId:Vf(t),chainName:(null==e?void 0:e.chainName)??a.name,iconUrls:null==e?void 0:e.iconUrls,nativeCurrency:(null==e?void 0:e.nativeCurrency)??a.nativeCurrency,rpcUrls:d};return await Promise.all([s.request({method:"wallet_addEthereumChain",params:[h]}).then(async()=>{if(await this.getChainId()!==t)throw new Uy(new Error("User rejected switch after adding network."));c.emitter.emit("change",{chainId:t})}),l]),a}catch(d){throw new Uy(d)}if(h.code===Uy.code)throw new Uy(h);throw new qy(h)}},async onAccountsChanged(e){var n;if(0===e.length)this.onDisconnect();else if(c.emitter.listenerCount("connect")){const e=(await this.getChainId()).toString();this.onConnect({chainId:e}),t&&await(null==(n=c.storage)?void 0:n.removeItem(`${this.id}.disconnected`))}else c.emitter.emit("change",{accounts:e.map(e=>Hp(e))})},onChainChanged(e){const t=Number(e);c.emitter.emit("change",{chainId:t})},async onConnect(e){const t=await this.getAccounts();if(0===t.length)return;const n=Number(e.chainId);c.emitter.emit("connect",{accounts:t,chainId:n});const r=await this.getProvider();r&&(s&&(r.removeListener("connect",s),s=void 0),i||(i=this.onAccountsChanged.bind(this),r.on("accountsChanged",i)),o||(o=this.onChainChanged.bind(this),r.on("chainChanged",o)),a||(a=this.onDisconnect.bind(this),r.on("disconnect",a)))},async onDisconnect(e){const t=await this.getProvider();e&&1013===e.code&&t&&(await this.getAccounts()).length||(c.emitter.emit("disconnect"),t&&(o&&(t.removeListener("chainChanged",o),o=void 0),a&&(t.removeListener("disconnect",a),a=void 0),s||(s=this.onConnect.bind(this),t.on("connect",s))))}})}pA.type="injected";const mA={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider:e=>(null==e?void 0:e.coinbaseWalletExtension)?e.coinbaseWalletExtension:gA(e,"isCoinbaseWallet")},metaMask:{id:"metaMask",name:"MetaMask",provider:e=>gA(e,e=>{if(!e.isMetaMask)return!1;if(e.isBraveWallet&&!e._events&&!e._state)return!1;const t=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPhantom","isPortal","isRabby","isTokenPocket","isTokenary","isUniswapWallet","isZerion"];for(const n of t)if(e[n])return!1;return!0})},phantom:{id:"phantom",name:"Phantom",provider(e){var t,n;return(null==(t=null==e?void 0:e.phantom)?void 0:t.ethereum)?null==(n=e.phantom)?void 0:n.ethereum:gA(e,"isPhantom")}}};function gA(e,t){function n(e){return"function"==typeof t?t(e):"string"!=typeof t||e[t]}const r=e.ethereum;return(null==r?void 0:r.providers)?r.providers.find(e=>n(e)):r&&n(r)?r:void 0}function yA(){const e=new Set;let t=[];const n=()=>function(e){if("undefined"==typeof window)return;const t=t=>e(t.detail);return window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new CustomEvent("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",t)}(n=>{t.some(({info:e})=>e.uuid===n.info.uuid)||(t=[...t,n],e.forEach(e=>e(t,{added:[n]})))});let r=n();return{_listeners:()=>e,clear(){e.forEach(e=>e([],{removed:[...t]})),t=[]},destroy(){this.clear(),e.clear(),null==r||r()},findProvider:({rdns:e})=>t.find(t=>t.info.rdns===e),getProviders:()=>t,reset(){this.clear(),null==r||r(),r=n()},subscribe:(n,{emitImmediately:r}={})=>(e.add(n),r&&n(t,{added:t}),()=>e.delete(n))}}const bA=e=>(t,n,r)=>{const i=r.subscribe;r.subscribe=(e,t,n)=>{let o=e;if(t){const i=(null==n?void 0:n.equalityFn)||Object.is;let s=e(r.getState());o=n=>{const r=e(n);if(!i(s,r)){const e=s;t(s=r,e)}},(null==n?void 0:n.fireImmediately)&&t(s,s)}return i(o)};return e(t,n,r)};function vA(e,t){let n;try{n=e()}catch(r){return}return{getItem:e=>{var t;const r=e=>null===e?null:JSON.parse(e,void 0),i=null!=(t=n.getItem(e))?t:null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,t)=>n.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>n.removeItem(e)}}const wA=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then:e=>wA(e)(n),catch(e){return this}}}catch(n){return{then(e){return this},catch:e=>wA(e)(n)}}},EA=(e,t)=>(n,r,i)=>{let o={storage:vA(()=>localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},s=!1;const a=new Set,c=new Set;let l=o.storage;if(!l)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...e)},r,i);const u=()=>{const e=o.partialize({...r()});return l.setItem(o.name,{state:e,version:o.version})},d=i.setState;i.setState=(e,t)=>{d(e,t),u()};const h=e((...e)=>{n(...e),u()},r,i);let f;i.getInitialState=()=>h;const p=()=>{var e,t;if(!l)return;s=!1,a.forEach(e=>{var t;return e(null!=(t=r())?t:h)});const i=(null==(t=o.onRehydrateStorage)?void 0:t.call(o,null!=(e=r())?e:h))||void 0;return wA(l.getItem.bind(l))(o.name).then(e=>{if(e){if("number"!=typeof e.version||e.version===o.version)return[!1,e.state];if(o.migrate)return[!0,o.migrate(e.state,e.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;const[i,s]=e;if(f=o.merge(s,null!=(t=r())?t:h),n(f,!0),i)return u()}).then(()=>{null==i||i(f,void 0),f=r(),s=!0,c.forEach(e=>e(f))}).catch(e=>{null==i||i(void 0,e)})};return i.persist={setOptions:e=>{o={...o,...e},e.storage&&(l=e.storage)},clearStorage:()=>{null==l||l.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>p(),hasHydrated:()=>s,onHydrate:e=>(a.add(e),()=>{a.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},o.skipHydration||p(),f||h},_A=e=>{let t;const n=new Set,r=(e,r)=>{const i="function"==typeof e?e(t):e;if(!Object.is(i,t)){const e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>s,subscribe:e=>(n.add(e),()=>n.delete(e))},s=t=e(r,i,o);return o},xA=e=>e?_A(e):_A;var kA={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i<o;i++)s[i]=r[i].fn;return s},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,i,o,s){var a=n?n+e:e;if(!this._events[a])return!1;var c,l,u=this._events[a],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,i),!0;case 5:return u.fn.call(u.context,t,r,i,o),!0;case 6:return u.fn.call(u.context,t,r,i,o,s),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var h,f=u.length;for(l=0;l<f;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];u[l].fn.apply(u[l].context,c)}}return!0},a.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,i){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||s(this,o);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||i&&!a[c].once||r&&a[c].context!==r)&&l.push(a[c]);l.length?this._events[o]=1===l.length?l[0]:l:s(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a}(kA);const SA=Re(kA.exports),CA=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:SA,default:SA},Symbol.toStringTag,{value:"Module"}));let IA=class{constructor(e){Object.defineProperty(this,"uid",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_emitter",{enumerable:!0,configurable:!0,writable:!0,value:new SA})}on(e,t){this._emitter.on(e,t)}once(e,t){this._emitter.once(e,t)}off(e,t){this._emitter.off(e,t)}emit(e,...t){const n=t[0];this._emitter.emit(e,{uid:this.uid,...n})}listenerCount(e){return this._emitter.listenerCount(e)}};function AA(e,t){return JSON.parse(e,(e,n)=>{let r=n;return"bigint"===(null==r?void 0:r.__type)&&(r=BigInt(r.value)),"Map"===(null==r?void 0:r.__type)&&(r=new Map(r.value)),(null==t?void 0:t(e,r))??r})}function PA(e,t){return e.slice(0,t).join(".")||"."}function MA(e,t){const{length:n}=e;for(let r=0;r<n;++r)if(e[r]===t)return r+1;return 0}function OA(e,t,n,r){return JSON.stringify(e,function(e,t){const n="function"==typeof e,r="function"==typeof t,i=[],o=[];return function(s,a){if("object"==typeof a)if(i.length){const e=MA(i,this);0===e?i[i.length]=this:(i.splice(e),o.splice(e)),o[o.length]=s;const n=MA(i,a);if(0!==n)return r?t.call(this,s,a,PA(o,n)):`[ref=${PA(o,n)}]`}else i[0]=a,o[0]=s;return n?e.call(this,s,a):a}}((e,n)=>{let r=n;return"bigint"==typeof r&&(r={__type:"bigint",value:n.toString()}),r instanceof Map&&(r={__type:"Map",value:Array.from(n.entries())}),(null==t?void 0:t(e,r))??r},r),n??void 0)}function TA(e){const{deserialize:t=AA,key:n="wagmi",serialize:r=OA,storage:i=RA}=e;function o(e){return e instanceof Promise?e.then(e=>e).catch(()=>null):e}return{...i,key:n,async getItem(e,r){const s=i.getItem(`${n}.${e}`),a=await o(s);return a?t(a)??null:r??null},async setItem(e,t){const s=`${n}.${e}`;null===t?await o(i.removeItem(s)):await o(i.setItem(s,r(t)))},async removeItem(e){await o(i.removeItem(`${n}.${e}`))}}}const RA={getItem:()=>null,setItem:()=>{},removeItem:()=>{}};function NA(){const e="undefined"!=typeof window&&window.localStorage?window.localStorage:RA;return{getItem:t=>e.getItem(t),removeItem(t){e.removeItem(t)},setItem(t,n){try{e.setItem(t,n)}catch{}}}}let LA,BA=256;function jA(e,t){return DS(e,t)}function DA(e){var t,n,r;const{chain:i}=e,o=i.rpcUrls.default.http[0];if(!e.transports)return[o];const s=null==(n=null==(t=e.transports)?void 0:t[i.id])?void 0:n.call(t,{chain:i});return((null==(r=null==s?void 0:s.value)?void 0:r.transports)||[s]).map(({value:e})=>(null==e?void 0:e.url)||o)}const UA={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};function FA(e,t){return function(e){return"deposit"===e.type||void 0!==e.sourceHash}(e)?function(e){!function(e){const{from:t,to:n}=e;if(t&&!Fp(t))throw new Pf({address:t});if(n&&!Fp(n))throw new Pf({address:n})}(e);const{sourceHash:t,data:n,from:r,gas:i,isSystemTx:o,mint:s,to:a,value:c}=e;return im(["0x7e",Uw([t,r,a??"0x",s?Wf(s):"0x",c?Wf(c):"0x",i?Wf(i):"0x",o?"0x1":"0x",n??"0x"])])}(e):XE(e,t)}const $A={blockTime:2e3,contracts:UA,formatters:{block:Xw({format(e){var t;return{transactions:null==(t=e.transactions)?void 0:t.map(e=>{if("string"==typeof e)return e;const t=Yw(e);return"0x7e"===t.typeHex&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?$f(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}),stateRoot:e.stateRoot}}}),transaction:Jw({format(e){const t={};return"0x7e"===e.type&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?$f(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:p_({format:e=>({l1GasPrice:e.l1GasPrice?$f(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?$f(e.l1GasUsed):null,l1Fee:e.l1Fee?$f(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null})})},serializers:{transaction:FA}},zA=d_({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:250,rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),HA=d_({id:43114,name:"Avalanche",blockTime:1700,nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{default:{name:"SnowTrace",url:"https://snowtrace.io",apiUrl:"https://api.snowtrace.io"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:11907934}}}),qA=1,WA=d_({...$A,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...$A.contracts,disputeGameFactory:{[qA]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[qA]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[qA]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[qA]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:1}),KA=d_({id:56,name:"BNB Smart Chain",blockTime:750,nativeCurrency:{decimals:18,name:"BNB",symbol:"BNB"},rpcUrls:{default:{http:["https://56.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com",apiUrl:"https://api.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15921452}}}),GA={estimateFeesPerGas:async e=>{var t;if(!(null==(t=e.request)?void 0:t.feeCurrency))return null;const[n,r]=await Promise.all([VA(e.client,e.request.feeCurrency),ZA(e.client,e.request.feeCurrency)]);return{maxFeePerGas:e.multiply(n-r)+r,maxPriorityFeePerGas:r}}};async function VA(e,t){const n=await e.request({method:"eth_gasPrice",params:[t]});return BigInt(n)}async function ZA(e,t){const n=await e.request({method:"eth_maxPriorityFeePerGas",params:[t]});return BigInt(n)}function YA(e){return 0===e||0n===e||null==e||"0"===e||""===e||"string"==typeof e&&("0x"===Uf(e).toLowerCase()||"0x00"===Uf(e).toLowerCase())}function JA(e){return!YA(e)}function QA(e){return"cip64"===e.type||function(e){return void 0!==e.maxFeePerGas&&void 0!==e.maxPriorityFeePerGas}(e)&&JA(e.feeCurrency)}const XA={transaction:function(e,t){return QA(e)?function(e,t){!function(e){const{chainId:t,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:i,to:o,feeCurrency:s}=e;if(t<=0)throw new Pg({chainId:t});if(o&&!Fp(o))throw new Pf({address:o});if(r)throw new tf("`gasPrice` is not a valid CIP-64 Transaction attribute.");if(JA(i)&&i>eP)throw new Uv({maxFeePerGas:i});if(JA(n)&&JA(i)&&n>i)throw new Vv({maxFeePerGas:i,maxPriorityFeePerGas:n});if(JA(s)&&!Fp(s))throw new tf("`feeCurrency` MUST be a token address for CIP-64 transactions.");if(YA(s))throw new tf("`feeCurrency` must be provided for CIP-64 transactions.")}(e);const{chainId:n,gas:r,nonce:i,to:o,value:s,maxFeePerGas:a,maxPriorityFeePerGas:c,accessList:l,feeCurrency:u,data:d}=e,h=[Wf(n),i?Wf(i):"0x",c?Wf(c):"0x",a?Wf(a):"0x",r?Wf(r):"0x",o??"0x",s?Wf(s):"0x",d??"0x",QE(l),u,...e_(e,t)];return im(["0x7b",Uw(h)])}(e,t):FA(e,t)}};const eP=lw;const tP=d_({...{blockTime:1e3,contracts:UA,formatters:{block:Xw({format(e){var t;return{transactions:null==(t=e.transactions)?void 0:t.map(e=>{if("string"==typeof e)return e;return{...Yw(e),...e.gatewayFee?{gatewayFee:$f(e.gatewayFee),gatewayFeeRecipient:e.gatewayFeeRecipient}:{},feeCurrency:e.feeCurrency}})}}}),transaction:Jw({format(e){if("0x7e"===e.type)return{isSystemTx:e.isSystemTx,mint:e.mint?$f(e.mint):void 0,sourceHash:e.sourceHash,type:"deposit"};const t={feeCurrency:e.feeCurrency};return"0x7b"===e.type?t.type="cip64":("0x7c"===e.type&&(t.type="cip42"),t.gatewayFee=e.gatewayFee?$f(e.gatewayFee):null,t.gatewayFeeRecipient=e.gatewayFeeRecipient),t}}),transactionRequest:nw({format(e){const t={};return e.feeCurrency&&(t.feeCurrency=e.feeCurrency),QA(e)&&(t.type="0x7b"),t}})},serializers:XA,fees:GA},id:42220,name:"Celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://celoscan.io",apiUrl:"https://api.celoscan.io/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:13112599}},testnet:!1}),nP=d_({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),rP=1,iP=d_({...$A,id:10,name:"OP Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.optimism.io"]}},blockExplorers:{default:{name:"Optimism Explorer",url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io/api"}},contracts:{...$A.contracts,disputeGameFactory:{[rP]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[rP]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[rP]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[rP]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId:1}),oP=d_({id:137,name:"Polygon",blockTime:2e3,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-rpc.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}});function sP(e={}){return"3"===e.version||e.headlessMode?function(e){const t=!1;let n,r,i,o,s;return a=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",rdns:"com.coinbase.wallet",type:sP.type,async connect({chainId:e}={}){try{const t=await this.getProvider(),n=(await t.request({method:"eth_requestAccounts"})).map(e=>Hp(e));i||(i=this.onAccountsChanged.bind(this),t.on("accountsChanged",i)),o||(o=this.onChainChanged.bind(this),t.on("chainChanged",o)),s||(s=this.onDisconnect.bind(this),t.on("disconnect",s));let r=await this.getChainId();if(e&&r!==e){const t=await this.switchChain({chainId:e}).catch(e=>{if(e.code===Uy.code)throw e;return{id:r}});r=(null==t?void 0:t.id)??r}return{accounts:n,chainId:r}}catch(t){if(/(user closed modal|accounts received is empty|user denied account)/i.test(t.message))throw new Uy(t);throw t}},async disconnect(){const e=await this.getProvider();i&&(e.removeListener("accountsChanged",i),i=void 0),o&&(e.removeListener("chainChanged",o),o=void 0),s&&(e.removeListener("disconnect",s),s=void 0),e.disconnect(),e.close()},async getAccounts(){const e=await this.getProvider();return(await e.request({method:"eth_accounts"})).map(e=>Hp(e))},async getChainId(){const e=await this.getProvider(),t=await e.request({method:"eth_chainId"});return Number(t)},async getProvider(){var i;if(!r){const o=await(async()=>{const{default:e}=await Promise.resolve().then(()=>C4);return"function"!=typeof e&&"function"==typeof e.default?e.default:e})();n=new o({...e,reloadOnDisconnect:t});const s=null==(i=n.walletExtension)?void 0:i.getChainId(),c=a.chains.find(t=>e.chainId?t.id===e.chainId:t.id===s)||a.chains[0],l=e.chainId||(null==c?void 0:c.id),u=e.jsonRpcUrl||(null==c?void 0:c.rpcUrls.default.http[0]);r=n.makeWeb3Provider(u,l)}return r},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:e,chainId:t}){var n,r,i,o;const s=a.chains.find(e=>e.id===t);if(!s)throw new qy(new nA);const c=await this.getProvider();try{return await c.request({method:"wallet_switchEthereumChain",params:[{chainId:Vf(s.id)}]}),s}catch(l){if(4902===l.code)try{let a,l;a=(null==e?void 0:e.blockExplorerUrls)?e.blockExplorerUrls:(null==(n=s.blockExplorers)?void 0:n.default.url)?[null==(r=s.blockExplorers)?void 0:r.default.url]:[],l=(null==(i=null==e?void 0:e.rpcUrls)?void 0:i.length)?e.rpcUrls:[(null==(o=s.rpcUrls.default)?void 0:o.http[0])??""];const u={blockExplorerUrls:a,chainId:Vf(t),chainName:(null==e?void 0:e.chainName)??s.name,iconUrls:null==e?void 0:e.iconUrls,nativeCurrency:(null==e?void 0:e.nativeCurrency)??s.nativeCurrency,rpcUrls:l};return await c.request({method:"wallet_addEthereumChain",params:[u]}),s}catch(u){throw new Uy(u)}throw new qy(l)}},onAccountsChanged(e){0===e.length?this.onDisconnect():a.emitter.emit("change",{accounts:e.map(e=>Hp(e))})},onChainChanged(e){const t=Number(e);a.emitter.emit("change",{chainId:t})},async onDisconnect(e){a.emitter.emit("disconnect");const t=await this.getProvider();i&&(t.removeListener("accountsChanged",i),i=void 0),o&&(t.removeListener("chainChanged",o),o=void 0),s&&(t.removeListener("disconnect",s),s=void 0)}})}(e):function(e){let t,n,r,i;return o=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",rdns:"com.coinbase.wallet",type:sP.type,async connect({chainId:e,...t}={}){try{const o=await this.getProvider(),s=(await o.request({method:"eth_requestAccounts",params:"instantOnboarding"in t&&t.instantOnboarding?[{onboarding:"instant"}]:[]})).map(e=>Hp(e));n||(n=this.onAccountsChanged.bind(this),o.on("accountsChanged",n)),r||(r=this.onChainChanged.bind(this),o.on("chainChanged",r)),i||(i=this.onDisconnect.bind(this),o.on("disconnect",i));let a=await this.getChainId();if(e&&a!==e){const t=await this.switchChain({chainId:e}).catch(e=>{if(e.code===Uy.code)throw e;return{id:a}});a=(null==t?void 0:t.id)??a}return{accounts:s,chainId:a}}catch(o){if(/(user closed modal|accounts received is empty|user denied account|request rejected)/i.test(o.message))throw new Uy(o);throw o}},async disconnect(){var e;const t=await this.getProvider();n&&(t.removeListener("accountsChanged",n),n=void 0),r&&(t.removeListener("chainChanged",r),r=void 0),i&&(t.removeListener("disconnect",i),i=void 0),t.disconnect(),null==(e=t.close)||e.call(t)},async getAccounts(){const e=await this.getProvider();return(await e.request({method:"eth_accounts"})).map(e=>Hp(e))},async getChainId(){const e=await this.getProvider(),t=await e.request({method:"eth_chainId"});return Number(t)},async getProvider(){if(!t){const r="string"==typeof e.preference?{options:e.preference}:{...e.preference,options:(null==(n=e.preference)?void 0:n.options)??"all"},{createCoinbaseWalletSDK:i}=await Promise.resolve().then(()=>cH),s=i({...e,appChainIds:o.chains.map(e=>e.id),preference:r});t=s.getProvider()}var n;return t},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:e,chainId:t}){var n,r,i,s;const a=o.chains.find(e=>e.id===t);if(!a)throw new qy(new nA);const c=await this.getProvider();try{return await c.request({method:"wallet_switchEthereumChain",params:[{chainId:Vf(a.id)}]}),a}catch(l){if(4902===l.code)try{let o,l;o=(null==e?void 0:e.blockExplorerUrls)?e.blockExplorerUrls:(null==(n=a.blockExplorers)?void 0:n.default.url)?[null==(r=a.blockExplorers)?void 0:r.default.url]:[],l=(null==(i=null==e?void 0:e.rpcUrls)?void 0:i.length)?e.rpcUrls:[(null==(s=a.rpcUrls.default)?void 0:s.http[0])??""];const u={blockExplorerUrls:o,chainId:Vf(t),chainName:(null==e?void 0:e.chainName)??a.name,iconUrls:null==e?void 0:e.iconUrls,nativeCurrency:(null==e?void 0:e.nativeCurrency)??a.nativeCurrency,rpcUrls:l};return await c.request({method:"wallet_addEthereumChain",params:[u]}),a}catch(u){throw new Uy(u)}throw new qy(l)}},onAccountsChanged(e){0===e.length?this.onDisconnect():o.emitter.emit("change",{accounts:e.map(e=>Hp(e))})},onChainChanged(e){const t=Number(e);o.emitter.emit("change",{chainId:t})},async onDisconnect(e){o.emitter.emit("disconnect");const t=await this.getProvider();n&&(t.removeListener("accountsChanged",n),n=void 0),r&&(t.removeListener("chainChanged",r),r=void 0),i&&(t.removeListener("disconnect",i),i=void 0)}})}(e)}function aP(e={}){let t,n,r,i,o,s,a,c;return l=>({id:"metaMaskSDK",name:"MetaMask",rdns:["io.metamask","io.metamask.mobile"],type:aP.type,async setup(){const e=await this.getProvider();(null==e?void 0:e.on)&&(s||(s=this.onConnect.bind(this),e.on("connect",s)),i||(i=this.onAccountsChanged.bind(this),e.on("accountsChanged",i)))},async connect({chainId:n,isReconnecting:r}={}){const l=await this.getProvider();a||(a=this.onDisplayUri,l.on("display_uri",a));let u=[];r&&(u=await this.getAccounts().catch(()=>[]));try{let r,d;if(!(null==u?void 0:u.length))if(e.connectAndSign||e.connectWith)e.connectAndSign?r=await t.connectAndSign({msg:e.connectAndSign}):e.connectWith&&(d=await t.connectWith({method:e.connectWith.method,params:e.connectWith.params})),u=await this.getAccounts();else{u=(await t.connect()).map(e=>Hp(e))}let h=await this.getChainId();if(n&&h!==n){const e=await this.switchChain({chainId:n}).catch(e=>{if(e.code===Uy.code)throw e;return{id:h}});h=(null==e?void 0:e.id)??h}return a&&(l.removeListener("display_uri",a),a=void 0),r?l.emit("connectAndSign",{accounts:u,chainId:h,signResponse:r}):d&&l.emit("connectWith",{accounts:u,chainId:h,connectWithResponse:d}),s&&(l.removeListener("connect",s),s=void 0),i||(i=this.onAccountsChanged.bind(this),l.on("accountsChanged",i)),o||(o=this.onChainChanged.bind(this),l.on("chainChanged",o)),c||(c=this.onDisconnect.bind(this),l.on("disconnect",c)),{accounts:u,chainId:h}}catch(d){const e=d;if(e.code===Uy.code)throw new Uy(e);if(e.code===Ny.code)throw new Ny(e);throw e}},async disconnect(){const e=await this.getProvider();o&&(e.removeListener("chainChanged",o),o=void 0),c&&(e.removeListener("disconnect",c),c=void 0),s||(s=this.onConnect.bind(this),e.on("connect",s)),await t.terminate()},async getAccounts(){const e=await this.getProvider();return(await e.request({method:"eth_accounts"})).map(e=>Hp(e))},async getChainId(){const e=await this.getProvider(),t=e.getChainId()||await(null==e?void 0:e.request({method:"eth_chainId"}));return Number(t)},getProvider:async()=>(n||(r||(r=async function(){var n,r,i,o,s;const a=await(async()=>{const{default:e}=await Promise.resolve().then(()=>Dfe);return"function"!=typeof e&&"function"==typeof e.default?e.default:e})(),c={};for(const e of l.chains)c[Vf(e.id)]=null==(n=DA({chain:e,transports:l.transports}))?void 0:n[0];t=new a({_source:"wagmi",forceDeleteProvider:!1,forceInjectProvider:!1,injectProvider:!1,...e,readonlyRPCMap:c,dappMetadata:{...e.dappMetadata,name:(null==(r=e.dappMetadata)?void 0:r.name)?null==(i=e.dappMetadata)?void 0:i.name:"wagmi",url:(null==(o=e.dappMetadata)?void 0:o.url)?null==(s=e.dappMetadata)?void 0:s.url:"undefined"!=typeof window?window.location.origin:"https://wagmi.sh"},useDeeplink:e.useDeeplink??!0});const u=await t.init(),d=(null==u?void 0:u.activeProvider)?u.activeProvider:t.getProvider();if(!d)throw new dA;return d}()),n=await r),n),async isAuthorized(){try{const e=200;return!!(await r_(()=>g_(()=>this.getAccounts(),{timeout:e}),{delay:e+1,retryCount:3})).length}catch{return!1}},async switchChain({addEthereumChainParameter:e,chainId:t}){var n,r;const i=await this.getProvider(),o=l.chains.find(e=>e.id===t);if(!o)throw new qy(new nA);try{return await i.request({method:"wallet_switchEthereumChain",params:[{chainId:Vf(t)}]}),await c(),await u(t),o}catch(d){const l=d;if(l.code===Uy.code)throw new Uy(l);if(4902===l.code||4902===(null==(r=null==(n=null==l?void 0:l.data)?void 0:n.originalError)?void 0:r.code))try{return await i.request({method:"wallet_addEthereumChain",params:[{blockExplorerUrls:(()=>{const{default:t,...n}=o.blockExplorers??{};return(null==e?void 0:e.blockExplorerUrls)?e.blockExplorerUrls:t?[t.url,...Object.values(n).map(e=>e.url)]:void 0})(),chainId:Vf(t),chainName:(null==e?void 0:e.chainName)??o.name,iconUrls:null==e?void 0:e.iconUrls,nativeCurrency:(null==e?void 0:e.nativeCurrency)??o.nativeCurrency,rpcUrls:(null==(s=null==e?void 0:e.rpcUrls)?void 0:s.length)?e.rpcUrls:[(null==(a=o.rpcUrls.default)?void 0:a.http[0])??""]}]}),await c(),await u(t),o}catch(h){const e=h;if(e.code===Uy.code)throw new Uy(e);throw new qy(e)}throw new qy(l)}var s,a;async function c(){await r_(async()=>{const e=zf(await i.request({method:"eth_chainId"}));if(e!==t)throw new Error("User rejected switch after adding network.");return e},{delay:50,retryCount:20})}async function u(e){await new Promise(t=>{const n=r=>{"chainId"in r&&r.chainId===e&&(l.emitter.off("change",n),t())};l.emitter.on("change",n),l.emitter.emit("change",{chainId:e})})}},async onAccountsChanged(e){if(0===e.length){if(!t.isExtensionActive())return;this.onDisconnect()}else if(l.emitter.listenerCount("connect")){const e=(await this.getChainId()).toString();this.onConnect({chainId:e})}else l.emitter.emit("change",{accounts:e.map(e=>Hp(e))})},onChainChanged(e){const t=Number(e);l.emitter.emit("change",{chainId:t})},async onConnect(e){const t=await this.getAccounts();if(0===t.length)return;const n=Number(e.chainId);l.emitter.emit("connect",{accounts:t,chainId:n});const r=await this.getProvider();s&&(r.removeListener("connect",s),s=void 0),i||(i=this.onAccountsChanged.bind(this),r.on("accountsChanged",i)),o||(o=this.onChainChanged.bind(this),r.on("chainChanged",o)),c||(c=this.onDisconnect.bind(this),r.on("disconnect",c))},async onDisconnect(e){const t=await this.getProvider();e&&1013===e.code&&t&&(await this.getAccounts()).length||(l.emitter.emit("disconnect"),o&&(t.removeListener("chainChanged",o),o=void 0),c&&(t.removeListener("disconnect",c),c=void 0),s||(s=this.onConnect.bind(this),t.on("connect",s)))},onDisplayUri(e){l.emitter.emit("message",{type:"display_uri",data:e})}})}sP.type="coinbaseWallet",aP.type="metaMask";const cP="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABxCAYAAAAj+QZ8AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAzrSURBVHgB7V3dcRs5Em4MtXWPq41gZ1+v7mwrgh3rArAUgagITNcFYDmAK9ERSBuBfQGsxY3Aku26V/MiOO7j1nqAQwMgRQ4xQONnhqOfr8q2TA4H1HzoRqO70c1g4JhUH/dhNKqgrhfT2cEMOoQaqxidyx+P5J8F8PpYjnkNPYLBgPGq+vxSFOJM/rhvXpp39ZAkGaUk40r+WK69jKT8JMdbQE8oYKDAByTJmMItGQj10OR7zyA3itFr2CQD1NhFMYYeMVhCHA8C1co7pV4yYXL4aSz/GVvfFFBBjxguIcCeOt4szYxOhiG2/V7M+T2yY7iEMOaTgIl8mBWkoth7Cduqah2u97JjuIQIUXqvYWlSohZyUEaDE/88/M+P0BMGrLIIYFAZ/R+HTGovJ+42IRqvYxZ485kKBob7QEgZZZoWoyMgrg//+vDX/0JPuA+ESLCXEApG/kxvm0LEkK2secDVZYjFpRZzIWibSyHm0COGSwjnYWoiyOIqjujXskcJUWCBqgItLuriPipOgAombqBH7EEGTKovUvz/xIdxnc8Rx8IdiHpxn7ouCVJXGnPIBD1h9p5BIU6kS6ZkBXt//uvf365fk0SIcvJJv5LUL6Wcdvq1w09z+c9MeknfSHLmEAteX8t7B30EBHsBHkLkPSsI+h482bOs3froERAT+UdLMcPlSch91M0P0w9Pz5bXpqksRcaW6Yj/H8v3vkpyLvRuOBzGxd6F2voZwpBEyKT6XMln8dF4BCzfjW2oz2hCjAu89FxmiPkctyNmMWprdOS5J11dSQsrVgXjxJAT8lyqp2aMpTnGxv1TJCRgdyzO5Jf7Giwtgv8GwWhfH5T0hK0fUQu6UeUf8UfvxY1Jl0LIHMJQBksL5zMIhXCqpLDAFpNrYSAwymnIKEkf4PUv6/+NJsQs2BHirKTlHUVaTAw9cB1xqaQijJDACYGTzUQ5adAqcbb+UuI+RPwCcTgyodjSe6UQ/4ZAtLrLi4DYhn5Y5DVscvjlguLK3xyDvWm+lEYI5+8hHiWJFMEvIRA1/3ZgfYMV9OgfYzPKZWrxfv5JLtx8DCFQhD+5bL6cRIgSN+IXb4GXlCi1VbQEt0IWdA40yRztXaG5DaEQ/Nj2crrrpP72BtJAkJRg1bhlAZr9Cc0y1LPXK/1KTYVZbcsB3rapw2RC1AwW0WvJEktS7A8sWDWyH61jkD/ul3q1xwhVUwj0HnN+1vZ2Huei4Ghvp/qwSumxfWd7I4NqRND3TdLt43rbmO7+PYYNgj93bTazEKIG4PUppELHyM+t76WrRhoEzFw+uMk/Ph0FW1O3N3/l8+9lc7/Lgd6jboR0TF5VNyeW++eQEj8EtKpf7SmGC4i78VvpRPTuUfLGQ1A3CpHkjEOIgk2ti3zXUtJiiq6gc38DXEar+15LMkgqLishSnWhOZce9tyX68mF5f4pUjL3XmHZqC1hVGkJocBnIdcN6uXZI4ZKR2obO22Rx/VE6esG6m+n/nsLW/jX/Rnp5GuTDpP7Fb6IGzJCPMadhHCVjc1rnBVppAg4b5rCinBeHzs/x7fd9uqhuNz59TfrPY3qDA8f3JIxD/lYZzH1TKRgztXEcu8ZWiztH6vtD17wlt23w/qxH1NwI5IMNRx0iDyk2POntMUiLDpftIeOOZ9ufxd5fYv1Y6RjDCFIIAPRywkq9YuxQvp8WAkxkKS2HWdT+VgFpvWw7zG24Dv2Jq8/kv6nl3rH7L4eQ9AQQojcw4BQJ7yiJ2AvhCAMKe+CQqgrKBs+bmecAIxyAlldKUk7g0R4s070ovpdadJ8DL6TM+DPoHizEeGDyeHNmZwHYYukiDA3E0HMGUAsD4fOIAP2LF/EnKtjGAqtQG2EOCzTfDT0/+UM0jFhte8QN+rnur526U+cRXIMuZ8oLgJUWG/nM9bg3wBqFXWalO7UwEplbeYORexGN+6qSLp26Wijws7ktf4sQvQvXT0hb65ywOw92twk0oSG0+mvfhd9KBQhLUeCc2EOjsQ5EjFc/vIul0YHUBOUFR8bUrxQ/jpprXV1VFoTcvgJ3d5H0D0uncRgEvSoeCGlqzIvL1xmaddYfScFft114QIEM9LxFfrFZXKq6T0FbgzT1os4YEbjR2lx9W7KDh3M1Pf4H+wKHVgqdxmFdpknx8TjgRkb1BytBwDtyxIq6N6J1UBEKd0Z7+ARmhDj0k53l6dAiGd6F/+wsfL2rjyzPR9y3ARhk3jPseF+V6RguHF3a0rZZxmLIaLV26uca9o7W0Kf4PUP0x4Lhg0NXve78ukI8boXYnbgsxoayPEQRQz6m27dGnmRGGm7LwgOUK38OwxO4oJNFjxuDldIihiazdwzGT+p1NkLnQlOdcUsVFY75+/7cNrdFWQP4Zq0nRI0MeiW2SSIq4yQxaM0POJOoCsJ0VJSjMqtC3g9x5j8dPa35Bzg+4hkQnSlAv7MxOCpiQGIOeQowXHPEEWIJkFgXZEx5ImnPAasDOj7kJxJEHagg/PgIe/SEbS8rGYlm26Aaw5meRzDA4ZTQizF8LvHA/dlWSVEp+aMLgTryE3iwKj4y/ew22DZTmHJXFQLNkbvdpH8ADX/43d4wNiIh7yqvpyY+k47IUPi8qEv6itCMP4hivC6IlnhOR/+EKAIMalAO04y8J/hfgjQEhJQdrsb7C5ddGjQi7oOPMFuICXjkYwVstTtjYKOEGJQarY6FKR8YsvSSgx37rOHpsZM9vvNNKqgfRxWKf2mqDCOW0G7ZTedfnjyCnYAU8zyRE6Mt31NDL2GpFWGo0IdLcA2dMCLmar8o01sXL9cZvaktSBN1xjt4bgTU4P4nFATOBnLzMWZ/YhxFqwRIc1q9FchEWFV2CZ9PIwtbJapnaiM/Rx9rxy4zVzUJ0hPM2UuGrVUP5fqRpXSZrB3Ysqnxh0M6rmfoML2uXZdaC22MDQBVueiOV+H8Y4K/Lv2hfkjg03YSYDPmuXrjMqZQBouJbnpNbkCoc612/Zo6oDrt+Pca4s/UW4zaWEdc/zLWexL9bHdu4qrS7gFJyE4VojbBR2o1IfpMHqyt4LtrHBABwdJrYTcdmhQ43iDXJbrvQ+05QDoGvLtpTqpddLNqV7xe8s46x0arMVqNrB1vf+w0KoOWGtYgJ3nWleyE2LUlK2NRRpsprmNdKHWvrbvZkvCsBZLa0JLkcsSxRLq6aTklxAsZ5RnzbiFpUa6+eXLrWtdSeGjkf29tmJpDZgKRI66kumkZCUkqXyqC42yfqZlats47VahcL5H2vipIjjOMoOq2UBkocyMhFD7ykahGSfRRcVaH177oR9nf13/+rMEVp9zF/scx5KST0K0Ps+PRh3dqKJiZLCXJCmhFfscx6ivLIS06vMcEFbp6Ar7VCkxxT49ZzLD15RkQjz6PA1aOmabY/mlo713LaV7KE1KEF2Qki4hHn2eBNEoX95Pu+39EL8ZlRRbtW4bkggxMzbOWeiFtZhl5f+YY7FVmfeUodkLCACFFFOt27sdSO1jWEEX0oH7jkb9QrNPKP0fdvaunQMFuh9iBQEgkLJP8QqkEcI6OOjfVprbsQPfgLt3Ldn5qI7pBSKAlNZJnEZI7h25uidvO/xJU428fdNmnI5zICEupL1GSpvqbO2Tgkjt9JlXXalSftsHQI36II7lXSeorvL92OjgihSA99YLVJ8Uu+XVU6dPAlx1FQty//OFNzbBxW9ARYTaWgKlUYYLjtsdkuLMRng8IUWLoy4UusL0gbPIJSt+Btq9CA87oPuzYLRxHdDGSUudep1EsYF4QqgmpAuqYICq3tD6kIL619JapdIJoXWf9kJ5iTHJo7nYW0pSpaislLDlQkXZrp74S2mMlGlNA6FVqmlb4b1uDVkMl7XFvlFpadMzkNILN/QX0xDq5O0BOeRJlY6QVqkhXaiLIgshCCRlevV0DJvZPUjGaow0sxe73VDThjQRz0lSsQ7q+hEyOYKaDjN6u1Yi5GJ/KScFtoc9bVqWGc6pOytTL1Lrmci4AlZM9etxDseU7pzB98WGXldPD6AnJCdbm9k+lsScgSpEY2qb6JomQR0Umghqlwr1DEKAXagpnoY+6oStIVv2uyFmDnlB1d/hR+GwCzUbUVw/+6E5XynotOVROogLKrWz8yZQgkkP2ZwM7gXDJoTSkJ7Y2bkJPeNpxT5r/sdP0BMGLiHMX6FUQHy7V+oxjFxeCcpQMGQwRljQ48+29NZfNwADlxAvLpOzz/vqQk3E3SYkw7n2oUnJsAkRwmEFiXzn/gYkJQOXEGFP51Eue07zhREwJCkZupVldxYWLH/VB1cXat5fdaJhE8JriwUl3nTRrk4T3Bbdq1NCDUEYNCFm87Z8SAtzUukMOoK94bHo7Yw6orMjbTmxDOD05U/SBz2l2wab3ncgjS78H0eagrHjdQciAAAAAElFTkSuQmCC",lP="YWG990wOlIikc1tU7-WWTepfU8d1f4dp",uP="qtIcCe_-8t4rIWktnWJm0",dP=function(e){const{multiInjectedProviderDiscovery:t=!0,storage:n=TA({storage:NA()}),syncConnectedChain:r=!0,ssr:i=!1,...o}=e,s="undefined"!=typeof window&&t?yA():void 0,a=xA(()=>o.chains),c=xA(()=>{const e=[],t=new Set;for(const n of o.connectors??[]){const r=l(n);if(e.push(r),!i&&r.rdns){const e="string"==typeof r.rdns?[r.rdns]:r.rdns;for(const n of e)t.add(n)}}if(!i&&s){const n=s.getProviders();for(const r of n)t.has(r.info.rdns)||e.push(l(u(r)))}return e});function l(e){var t;const r=(i=function(e=11){if(!LA||BA+e>512){LA="",BA=0;for(let e=0;e<256;e++)LA+=(256+256*Math.random()|0).toString(16).substring(1)}return LA.substring(BA,BA+++e)}(),new IA(i));var i;const s={...e({emitter:r,chains:a.getState(),storage:n,transports:o.transports}),emitter:r,uid:r.uid};return r.on("connect",b),null==(t=s.setup)||t.call(s),s}function u(e){const{info:t}=e,n=e.provider;return pA({target:{...t,id:t.rdns,provider:n}})}const d=new Map;function h(){return{chainId:a.getState()[0].id,connections:new Map,current:null,status:"disconnected"}}let f;const p="0.0.0-canary-";f=JI.startsWith(p)?Number.parseInt(JI.replace(p,"")):Number.parseInt(JI.split(".")[0]??"0");const m=xA(bA(n?EA(h,{migrate(e,t){if(t===f)return e;const n=h(),r=g(e,n.chainId);return{...n,chainId:r}},name:"store",partialize:e=>({connections:{__type:"Map",value:Array.from(e.connections.entries()).map(([e,t])=>{const{id:n,name:r,type:i,uid:o}=t.connector,s={id:n,name:r,type:i,uid:o};return[e,{...t,connector:s}]})},chainId:e.chainId,current:e.current}),merge(e,t){"object"==typeof e&&e&&"status"in e&&delete e.status;const n=g(e,t.chainId);return{...t,...e,chainId:n}},skipHydration:i,storage:n,version:f}):h));function g(e,t){return e&&"object"==typeof e&&"chainId"in e&&"number"==typeof e.chainId&&a.getState().some(t=>t.id===e.chainId)?e.chainId:t}function y(e){m.setState(t=>{const n=t.connections.get(e.uid);return n?{...t,connections:new Map(t.connections).set(e.uid,{accounts:e.accounts??n.accounts,chainId:e.chainId??n.chainId,connector:n.connector})}:t})}function b(e){"connecting"!==m.getState().status&&"reconnecting"!==m.getState().status&&m.setState(t=>{const n=c.getState().find(t=>t.uid===e.uid);return n?(n.emitter.listenerCount("connect")&&n.emitter.off("connect",y),n.emitter.listenerCount("change")||n.emitter.on("change",y),n.emitter.listenerCount("disconnect")||n.emitter.on("disconnect",v),{...t,connections:new Map(t.connections).set(e.uid,{accounts:e.accounts,chainId:e.chainId,connector:n}),current:e.uid,status:"connected"}):t})}function v(e){m.setState(t=>{const n=t.connections.get(e.uid);if(n){const e=n.connector;e.emitter.listenerCount("change")&&n.connector.emitter.off("change",y),e.emitter.listenerCount("disconnect")&&n.connector.emitter.off("disconnect",v),e.emitter.listenerCount("connect")||n.connector.emitter.on("connect",b)}if(t.connections.delete(e.uid),0===t.connections.size)return{...t,connections:new Map,current:null,status:"disconnected"};const r=t.connections.values().next().value;return{...t,connections:new Map(t.connections),current:r.connector.uid}})}return m.setState(h()),r&&m.subscribe(({connections:e,current:t})=>{var n;return t?null==(n=e.get(t))?void 0:n.chainId:void 0},e=>{if(a.getState().some(t=>t.id===e))return m.setState(t=>({...t,chainId:e??t.chainId}))}),null==s||s.subscribe(e=>{const t=new Set,r=new Set;for(const n of c.getState())if(t.add(n.id),n.rdns){const e="string"==typeof n.rdns?[n.rdns]:n.rdns;for(const t of e)r.add(t)}const i=[];for(const n of e){if(r.has(n.info.rdns))continue;const e=l(u(n));t.has(e.id)||i.push(e)}n&&!m.persist.hasHydrated()||c.setState(e=>[...e,...i],!0)}),{get chains(){return a.getState()},get connectors(){return c.getState()},storage:n,getClient:function(e={}){const t=e.chainId??m.getState().chainId,n=a.getState().find(e=>e.id===t);if(e.chainId&&!n)throw new nA;{const e=d.get(m.getState().chainId);if(e&&!n)return e;if(!n)throw new nA}{const e=d.get(t);if(e)return e}let r;if(o.client)r=o.client({chain:n});else{const e=n.id,t=a.getState().map(e=>e.id),i={},s=Object.entries(o);for(const[n,r]of s)if("chains"!==n&&"client"!==n&&"connectors"!==n&&"transports"!==n)if("object"==typeof r)if(e in r)i[n]=r[e];else{if(t.some(e=>e in r))continue;i[n]=r}else i[n]=r;r=MS({...i,chain:n,batch:i.batch??{multicall:!0},transport:t=>o.transports[e]({...t,connectors:c})})}return d.set(t,r),r},get state(){return m.getState()},setState(e){let t;t="function"==typeof e?e(m.getState()):e;const n=h();"object"!=typeof t&&(t=n);Object.keys(n).some(e=>!(e in t))&&(t=n),m.setState(t,!0)},subscribe:(e,t,n)=>m.subscribe(e,t,n?{...n,fireImmediately:n.emitImmediately}:void 0),_internal:{mipd:s,store:m,ssr:Boolean(i),syncConnectedChain:r,transports:o.transports,chains:{setState(e){const t="function"==typeof e?e(a.getState()):e;if(0!==t.length)return a.setState(t,!0)},subscribe:e=>a.subscribe(e)},connectors:{providerDetailToConnector:u,setup:l,setState:e=>c.setState("function"==typeof e?e(c.getState()):e,!0),subscribe:e=>c.subscribe(e)},events:{change:y,connect:b,disconnect:v}}}}({chains:[nP,KA,oP,zA,iP,HA,tP,WA],connectors:[pA(),aP({dappMetadata:{name:"Coinley Payment",icon:cP}}),sP({appName:"Coinley Payment",appLogoUrl:cP})],transports:{[nP.id]:jA([$S(`https://eth-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://eth-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://cloudflare-eth.com",{timeout:1e4,retryCount:1}),$S("https://eth.llamarpc.com",{timeout:1e4,retryCount:1}),$S("https://ethereum.publicnode.com",{timeout:1e4,retryCount:1})]),[KA.id]:jA([$S(`https://bnb-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://bnb-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://bsc-dataseed.bnbchain.org",{timeout:1e4,retryCount:1}),$S("https://bsc-dataseed-public.bnbchain.org",{timeout:1e4,retryCount:1}),$S("https://bsc.nodereal.io",{timeout:1e4,retryCount:1})]),[oP.id]:jA([$S(`https://polygon-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://polygon-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://polygon.llamarpc.com",{timeout:1e4,retryCount:1}),$S("https://polygon-rpc.com",{timeout:1e4,retryCount:1}),$S("https://polygon.drpc.org",{timeout:1e4,retryCount:1})]),[zA.id]:jA([$S(`https://arb-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://arb-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://arb1.arbitrum.io/rpc",{timeout:1e4,retryCount:1}),$S("https://arbitrum.llamarpc.com",{timeout:1e4,retryCount:1})]),[iP.id]:jA([$S(`https://opt-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://opt-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://mainnet.optimism.io",{timeout:1e4,retryCount:1}),$S("https://optimism.llamarpc.com",{timeout:1e4,retryCount:1})]),[HA.id]:jA([$S(`https://avax-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://avax-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://api.avax.network/ext/bc/C/rpc",{timeout:1e4,retryCount:1}),$S("https://avalanche.public-rpc.com",{timeout:1e4,retryCount:1})]),[tP.id]:jA([$S(`https://celo-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://celo-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://forno.celo.org",{timeout:1e4,retryCount:1}),$S("https://celo.drpc.org",{timeout:1e4,retryCount:1})]),[WA.id]:jA([$S(`https://base-mainnet.g.alchemy.com/v2/${lP}`,{timeout:1e4,retryCount:1}),$S(`https://base-mainnet.g.alchemy.com/v2/${uP}`,{timeout:1e4,retryCount:1}),$S("https://mainnet.base.org",{timeout:1e4,retryCount:1}),$S("https://base.llamarpc.com",{timeout:1e4,retryCount:1}),$S("https://base.meowrpc.com",{timeout:1e4,retryCount:1})])}});class hP{constructor(e,t,n=null){this.baseURL=e.endsWith("/")?e.slice(0,-1):e,t&&t.startsWith("pk_")?(this.publicKey=t,this.apiKey=null,this.apiSecret=null):(this.publicKey=null,this.apiKey=t,this.apiSecret=n)}async request(e,t={}){const n=`${this.baseURL}${e}`,r={"Content-Type":"application/json",...t.headers};this.publicKey?r["X-Public-Key"]=this.publicKey:(r["X-API-Key"]=this.apiKey,r["X-API-Secret"]=this.apiSecret);const i=t.timeout||6e4,o=new AbortController,s=setTimeout(()=>o.abort(),i);try{const e=await fetch(n,{...t,headers:r,signal:o.signal});if(clearTimeout(s),!e.ok){const t=await e.json().catch(()=>({}));throw new Error(t.error||`HTTP ${e.status}`)}return e.json()}catch(a){if(clearTimeout(s),"AbortError"===a.name)throw new Error(`Request timeout after ${i/1e3}s: ${e}`);throw a}}async getNetworks(){try{return await this.request("/api/networks")}catch(e){return{networks:[{id:"1",name:"Ethereum",shortName:"ethereum",chainId:"0x1",type:"ethereum"},{id:"56",name:"BSC",shortName:"bsc",chainId:"0x38",type:"bsc"},{id:"137",name:"Polygon",shortName:"polygon",chainId:"0x89",type:"polygon"},{id:"42161",name:"Arbitrum",shortName:"arbitrum",chainId:"0xa4b1",type:"arbitrum"},{id:"10",name:"Optimism",shortName:"optimism",chainId:"0xa",type:"optimism"},{id:"43114",name:"Avalanche",shortName:"avalanche",chainId:"0xa86a",type:"avalanche"}]}}}async getTokens(){try{return await this.request("/api/networks/stablecoins")}catch(e){return{stablecoins:[{id:"1",name:"Tether USD",symbol:"USDT",contractAddress:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"2",name:"USD Coin",symbol:"USDC",contractAddress:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6,networkId:"1",Network:{shortName:"ethereum",name:"Ethereum"}},{id:"3",name:"Tether USD",symbol:"USDT",contractAddress:"0x55d398326f99059fF775485246999027B3197955",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"4",name:"USD Coin",symbol:"USDC",contractAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18,networkId:"56",Network:{shortName:"bsc",name:"BSC"}},{id:"5",name:"Tether USD",symbol:"USDT",contractAddress:"0xc2132D05D31c914a87c6611C10748AEb04B58e8F",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"6",name:"USD Coin",symbol:"USDC",contractAddress:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",decimals:6,networkId:"137",Network:{shortName:"polygon",name:"Polygon"}},{id:"7",name:"Tether USD",symbol:"USDT",contractAddress:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"8",name:"USD Coin",symbol:"USDC",contractAddress:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",decimals:6,networkId:"42161",Network:{shortName:"arbitrum",name:"Arbitrum"}},{id:"9",name:"Tether USD",symbol:"USDT",contractAddress:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"10",name:"USD Coin",symbol:"USDC",contractAddress:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",decimals:6,networkId:"10",Network:{shortName:"optimism",name:"Optimism"}},{id:"11",name:"Tether USD",symbol:"USDT",contractAddress:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"12",name:"USD Coin",symbol:"USDC",contractAddress:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",decimals:6,networkId:"43114",Network:{shortName:"avalanche",name:"Avalanche"}},{id:"13",name:"Tether USD",symbol:"USDT",contractAddress:"0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"14",name:"USD Coin",symbol:"USDC",contractAddress:"0xcebA9300f2b948710d2653dD7B07f33A8B32118C",decimals:6,networkId:"42220",Network:{shortName:"celo",name:"Celo"}},{id:"15",name:"Tether USD",symbol:"USDT",contractAddress:"0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}},{id:"16",name:"USD Coin",symbol:"USDC",contractAddress:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",decimals:6,networkId:"8453",Network:{shortName:"base",name:"Base"}}]}}}async createPayment(e){return await this.request("/api/payments/create",{method:"POST",body:JSON.stringify(e)})}async verifyQRPayment(e){return await this.request("/api/payments/verify-qr",{method:"POST",body:JSON.stringify({paymentId:e})})}async checkPaymentStatus(e){return await this.request(`/api/payments/status/${e}`)}async getContractInfo(e){try{const t=await this.request(`/api/payments/contract/${e}`);if(!t.success)throw new Error("Contract not supported on this network");return t.contractInfo}catch(t){throw new Error(t.message||"Failed to get contract information")}}async processPayment(e,t,n,r){try{return await this.request("/api/payments/process",{method:"POST",body:JSON.stringify({paymentId:e,transactionHash:t,network:n,senderAddress:r}),timeout:9e4})}catch(i){throw i}}async failPayment(e,t="Payment cancelled by user"){return await this.request("/api/payments/fail",{method:"POST",body:JSON.stringify({paymentId:e,reason:t,status:"failed"})})}}const fP={ethereum:1,bsc:56,polygon:137,arbitrum:42161,optimism:10,avalanche:43114,celo:42220,base:8453},pP=e=>"number"==typeof e?e:"string"==typeof e?e.startsWith("0x")?parseInt(e,16):parseInt(e,10):1,mP=e=>fP[e]||1,gP=()=>{const[e,t]=yt.useState(null),[n,r]=yt.useState(null),[i,o]=yt.useState(""),{connect:s,connectors:a}=GI(),{isConnected:c,address:l,chain:u}=AC(),{switchChain:d}=function(e={}){const{mutation:t}=e,n=iC(e),r=RI(n),{mutate:i,mutateAsync:o,...s}=HI({...t,...r});return{...s,chains:WI({config:n}),switchChain:i,switchChainAsync:o}}();yt.useEffect(()=>{r(c&&l?{account:l,chainId:null==u?void 0:u.id,walletType:e}:null)},[c,l,u,e]);return{selectedWalletType:e,connectedWallet:n,connectionError:i,isConnected:c,address:l,chain:u,connectors:a,handleWalletSelection:e=>{t(e),o("")},connectWallet:async(e,t=null)=>{var n,r,i;if(!e)return o("Please select a wallet first"),!1;try{if(o(""),await s({connector:e}),t){const s=mP(t.shortName),c=(null==(n=e.name)?void 0:n.toLowerCase())||"",l=c.includes("zerion")||c.includes("trust")||c.includes("rabby")?5e3:500;await new Promise(e=>setTimeout(e,l));const u=lA(dP).chainId;if(s&&u!==s)try{await d({chainId:s}),await new Promise(e=>setTimeout(e,1e3))}catch(a){return 4001===a.code||(null==(r=a.message)?void 0:r.includes("User rejected"))?o("Network switch was cancelled by user"):(null==(i=a.message)?void 0:i.includes("Unrecognized chain ID"))?o(`${t.name} network is not added to your wallet. Please add it manually.`):o(`Failed to switch to ${t.name}. Please switch manually in your wallet.`),!1}}return!0}catch(c){return 4001===c.code||c.message.includes("User rejected")||c.message.includes("rejected")?o("User cancelled the connection request"):o(`Failed to connect to ${e.name}. Please try again.`),!1}},disconnectWallet:()=>{r(null),t(null),o("")},switchChain:d,ensureCorrectNetwork:async e=>{var t,n;if(!e)return!0;try{const i=mP(e.shortName),s=lA(dP).chainId;if(i&&s!==i)try{return await d({chainId:i}),await new Promise(e=>setTimeout(e,1e3)),!0}catch(r){return 4001===r.code||(null==(t=r.message)?void 0:t.includes("User rejected"))?o("Network switch was cancelled. Please switch to the correct network in your wallet."):(null==(n=r.message)?void 0:n.includes("Unrecognized chain ID"))?o(`${e.name} network is not added to your wallet. Please add it manually.`):o(`Failed to switch to ${e.name}. Please switch manually in your wallet.`),!1}return!0}catch(i){return o("Failed to verify network. Please check your wallet connection."),!1}},clearError:()=>{o("")},setSelectedWalletType:t,connect:s}},yP=(e,t,n=!1)=>{if(!e||"string"!=typeof e)throw new Error(`Missing ${t} address`);if(!e.startsWith("0x"))throw new Error(`Invalid ${t} address format: must start with 0x`);if(42!==e.length)throw new Error(`Invalid ${t} address length: expected 42 characters, got ${e.length}`);if("0x0000000000000000000000000000000000000000"===e&&!n)throw new Error(`Invalid ${t} address: cannot be zero address`)},bP=e=>{const t=(e=>{yP(e.token,"token"),yP(e.recipient1,"recipient1"),yP(e.recipient2,"recipient2");const t=0n===BigInt(e.recipient3Percentage||0);if(yP(e.recipient3,"recipient3",t),!e.paymentId||"string"!=typeof e.paymentId||0===e.paymentId.length)throw new Error("Invalid payment ID: must be a non-empty string");let n,r,i,o;try{n=BigInt(e.amount||0),r=BigInt(e.recipient1Percentage||0),i=BigInt(e.recipient2Percentage||0),o=BigInt(e.recipient3Percentage||0)}catch(a){throw new Error("Invalid numeric values: cannot convert to BigInt")}if(n<=0n)throw new Error(`Invalid amount: ${e.amount} (must be greater than 0)`);const s=r+i+o;if(10000n!==s)throw new Error(`Invalid percentages: total is ${s} but must equal 10000 basis points (100%). Individual: ${r}, ${i}, ${o}`);return{amount:n,percentage1:r,percentage2:i,percentage3:o}})(e);return{token:e.token,amount:t.amount,paymentId:e.paymentId,recipient1:e.recipient1,recipient2:e.recipient2,recipient3:e.recipient3,recipient1Percentage:t.percentage1,recipient2Percentage:t.percentage2,recipient3Percentage:t.percentage3}},vP=[{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"}],wP=[{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"}],EP=e=>{var t,n;const r=(null==(t=null==e?void 0:e.message)?void 0:t.toLowerCase())||(null==(n=null==e?void 0:e.toString())?void 0:n.toLowerCase())||"",i=(null==e?void 0:e.code)||(null==e?void 0:e.reason)||"";return r.includes("user rejected")||r.includes("user denied")||r.includes("user cancelled")||r.includes("rejected by user")||4001===i||"ACTION_REJECTED"===i?{type:"user_rejected",title:"Transaction Cancelled",message:"You cancelled the transaction. No charges were made.",suggestion:'Click "Pay Now" to try again when you\'re ready.'}:r.includes("insufficient funds")||r.includes("insufficient balance")||r.includes("insufficient eth")||r.includes("insufficient matic")||r.includes("insufficient bnb")||-32e3===i?{type:"insufficient_funds",title:"Insufficient Funds",message:"You don't have enough tokens or gas fees in your wallet.",suggestion:"Add more funds to your wallet and try again."}:r.includes("network error")||r.includes("rpc error")||r.includes("connection failed")||r.includes("timeout")||r.includes("request failed")?{type:"network_error",title:"Network Error",message:"Unable to connect to the blockchain network.",suggestion:"Check your internet connection and try again."}:r.includes("wrong network")||r.includes("unsupported network")||r.includes("chain mismatch")||4902===i?{type:"wrong_network",title:"Wrong Network",message:"Please switch to the correct network in your wallet.",suggestion:"Your wallet should prompt you to switch networks."}:r.includes("wallet not connected")||r.includes("no provider")||r.includes("wallet disconnected")||4900===i?{type:"wallet_disconnected",title:"Wallet Disconnected",message:"Your wallet is not connected.",suggestion:"Please reconnect your wallet and try again."}:r.includes("gas estimation failed")||r.includes("execution reverted")||r.includes("out of gas")?{type:"gas_error",title:"Transaction Failed",message:"The transaction couldn't be processed.",suggestion:"This might be a temporary issue. Please try again."}:r.includes("approve")&&r.includes("failed")?{type:"approval_failed",title:"Token Approval Failed",message:"Failed to approve token spending.",suggestion:"Please try the approval step again."}:r.includes("transaction failed")||r.includes("revert")||r.includes("contract call failed")?{type:"transaction_failed",title:"Transaction Failed",message:"The blockchain transaction was unsuccessful.",suggestion:"Please check your wallet and try again."}:r.includes("popup")||r.includes("blocked")?{type:"popup_blocked",title:"Wallet Popup Blocked",message:"Your browser blocked the wallet popup.",suggestion:"Please allow popups for this site and try again."}:r.includes("rate limit")||r.includes("too many requests")?{type:"rate_limited",title:"Too Many Requests",message:"Please wait a moment before trying again.",suggestion:"Wait 30 seconds and retry your transaction."}:r.includes("payment not yet confirmed")||r.includes("not yet confirmed on-chain")||r.includes("payment not found on-chain")||r.includes("please complete the payment")?{type:"payment_pending",title:"Payment Pending",message:"Your payment is still being confirmed on the blockchain.",suggestion:"Please wait a moment and try again, or check if your transaction completed successfully."}:r.includes("deep link")||r.includes("app not installed")||r.includes("wallet app")?{type:"mobile_wallet_error",title:"Wallet App Issue",message:"Unable to open or connect to your wallet app.",suggestion:"Make sure your wallet app is installed and try again."}:{type:"unknown_error",title:"Something Went Wrong",message:"An unexpected error occurred.",suggestion:"Please try again or contact support if the problem persists."}},_P=(e,t="")=>({timestamp:(new Date).toISOString(),context:t,userFriendly:EP(e),technical:{message:(null==e?void 0:e.message)||"Unknown error",code:null==e?void 0:e.code,reason:null==e?void 0:e.reason,stack:null==e?void 0:e.stack,name:null==e?void 0:e.name}}),xP=async(e,t)=>{try{const n=await cA(e,{chainId:t}),r=120n,i=100n;return{maxFeePerGas:n.maxFeePerGas?n.maxFeePerGas*r/i:void 0,maxPriorityFeePerGas:n.maxPriorityFeePerGas?n.maxPriorityFeePerGas*r/i:void 0}}catch(n){return{}}},kP="YWG990wOlIikc1tU7-WWTepfU8d1f4dp",SP=(e,t,n,r,i,o)=>{const[s,a]=yt.useState("idle"),[c,l]=yt.useState(""),[u,d]=yt.useState(null),{data:h,isPending:f}=VI(),{isLoading:p,isSuccess:m}=ZI({hash:h}),g=async()=>{var e,t,n,r,o,s,c;try{a("splitPayment");const l=window.coinleyPendingSplitPayment;if(!l)throw new Error("Missing split payment data");const{contractCall:f,selectedToken:p,paymentData:m,selectedNetwork:g}=l,y=g.chainId||10,b=await i.getContractInfo(y),{abi:v}=b,w=bP(f.params),E=pP(y),_=1===E,x=_||43114===E;try{const{request:e}=await async function(e,t){const{abi:n,chainId:r,connector:i,...o}=t;let s;s=t.account?t.account:(await aA(e,{chainId:r,connector:i})).account;const a=e.getClient({chainId:r}),c=YI(a,Wk,"simulateContract"),{result:l,request:u}=await c({...o,abi:n,account:s});return{chainId:a.chain.id,result:l,request:{...u,chainId:r}}}(dP,{address:f.contractAddress,abi:v,functionName:"splitPayment",args:[w]})}catch(u){const i=u.data||(null==(e=u.cause)?void 0:e.data);i&&("string"==typeof i&&i.startsWith("0x08c379a0")||"string"==typeof i&&i.startsWith("0x4e487b71"));u.reason||(null==(t=u.cause)?void 0:t.reason)||(null==(n=u.cause)?void 0:n.shortMessage)||(null==(r=u.data)||r.message);if(!x){const{userFriendlyMessage:e}=(e=>{if(!e.message)return{revertReason:"Transaction will revert",userFriendlyMessage:"Transaction simulation failed"};const t=e.message.toLowerCase();return t.includes("abi encoding params/values length mismatch")?{revertReason:"Smart contract parameter mismatch. This is likely a technical issue.",userFriendlyMessage:"Technical error: Contract parameters mismatch. Please try again or contact support."}:t.includes("payment id already used")?{revertReason:"This payment ID has already been used.",userFriendlyMessage:"This payment has already been processed. Please check your transaction history."}:t.includes("percentages must equal 100")?{revertReason:"Payment split percentages are incorrect.",userFriendlyMessage:"Internal error: Payment split configuration is invalid. Please contact support."}:t.includes("token transfer failed")||t.includes("transfer amount exceeds")?{revertReason:"Insufficient token balance or approval.",userFriendlyMessage:"Insufficient balance or token approval. Please check your wallet balance."}:t.includes("amount must be greater than 0")?{revertReason:"Payment amount is invalid.",userFriendlyMessage:"Invalid payment amount. Please try again."}:t.includes("invalid recipient")||t.includes("zero address")?{revertReason:"One of the payment recipients has an invalid address.",userFriendlyMessage:"Payment configuration error: Invalid recipient address. Please contact support."}:t.includes("insufficient gas")||t.includes("out of gas")?{revertReason:"Insufficient gas for transaction.",userFriendlyMessage:"Not enough gas to process transaction. Please increase gas limit or check ETH balance."}:t.includes("nonce")?{revertReason:"Transaction nonce conflict.",userFriendlyMessage:"Transaction ordering conflict. Please try again in a moment."}:{revertReason:e.message,userFriendlyMessage:`Transaction simulation failed: ${e.message.substring(0,100)}${e.message.length>100?"...":""}`}})(u);throw new Error(e)}}const k=await xP(dP,y),S="arbitrum"===g.shortName,C=S?2:0;let I;for(let e=0;e<=C;e++)try{if(e>0){const t=2e3*e;await new Promise(e=>setTimeout(e,t))}I=await fA(dP,{address:f.contractAddress,abi:v,functionName:"splitPayment",args:[w],...k});break}catch(h){const t=(null==(o=h.message)?void 0:o.includes("Internal JSON-RPC error"))||(null==(s=h.message)?void 0:s.includes("-32603"))||(null==(c=h.message)?void 0:c.includes("nonce"));if(e===C||!t&&!S)throw h}return d(I),a("processing"),window.coinleyPendingSplitPayment=null,I}catch(f){_P(f,"split_payment_transaction");const e=EP(f);throw l(e),a("error"),f}},y=async t=>{try{if(a("processing"),!i||!i.processPayment)throw new Error("API instance not available or missing processPayment method");await new Promise(e=>setTimeout(e,8e3));const o=await i.processPayment(e.id,t,n.shortName,r);return a("success"),o}catch(o){_P(o,"final_payment_processing");const e=EP(o);throw l(e),a("error"),o}};return{transactionStep:s,transactionError:c,currentTransactionHash:u,txPending:f,isConfirming:p,isConfirmed:m,executePaymentTransaction:async()=>{var i,s;if(!r||!(null==e?void 0:e.contractCall))throw new Error("Missing wallet connection or payment data");const c=e.contractCall;if(!c.contractAddress)throw new Error("PaymentSplitter contract data missing from payment response");if((null==o?void 0:o.ensureCorrectNetwork)&&n){if(!(await o.ensureCorrectNetwork(n)))throw new Error("Network verification failed. Please ensure you are on the correct network.")}if(!t.contractAddress)throw new Error("Native token transactions not yet supported with PaymentSplitter. Please use ERC-20 tokens.");{const o=t.decimals||6,w=c.approvalAmount||Math.floor(e.totalAmount*Math.pow(10,o));try{let e,i="unknown";try{e=await uA(dP,{address:c.tokenAddress,abi:wP,functionName:"balanceOf",args:[r]}),i="wallet-rpc"}catch(u){const t=(null==n?void 0:n.chainId)||(null==n?void 0:n.id);if(!t)throw u;{const n=(e=>{const t={1:nP,56:KA,137:oP,42161:zA,10:iP,43114:HA,42220:tP,8453:WA}[e],n={1:[`https://eth-mainnet.g.alchemy.com/v2/${kP}`,"https://cloudflare-eth.com","https://eth.llamarpc.com","https://ethereum.publicnode.com"],56:[`https://bnb-mainnet.g.alchemy.com/v2/${kP}`,"https://bsc-dataseed.bnbchain.org","https://bsc-dataseed-public.bnbchain.org","https://bsc.nodereal.io"],137:[`https://polygon-mainnet.g.alchemy.com/v2/${kP}`,"https://polygon.llamarpc.com","https://polygon-rpc.com","https://polygon.drpc.org"],42161:[`https://arb-mainnet.g.alchemy.com/v2/${kP}`,"https://arb1.arbitrum.io/rpc","https://arbitrum.llamarpc.com"],10:[`https://opt-mainnet.g.alchemy.com/v2/${kP}`,"https://mainnet.optimism.io","https://optimism.llamarpc.com"],43114:[`https://avax-mainnet.g.alchemy.com/v2/${kP}`,"https://api.avax.network/ext/bc/C/rpc","https://avalanche.public-rpc.com"],42220:[`https://celo-mainnet.g.alchemy.com/v2/${kP}`,"https://forno.celo.org","https://celo.drpc.org"],8453:[`https://base-mainnet.g.alchemy.com/v2/${kP}`,"https://mainnet.base.org","https://base.llamarpc.com","https://base.meowrpc.com"]}[e];return t&&n?LS({chain:t,transport:DS(n.map(e=>$S(e,{timeout:1e4,retryCount:1})))}):null})(pP(t));if(!n)throw u;try{e=await n.readContract({address:c.tokenAddress,abi:wP,functionName:"balanceOf",args:[r]}),i="fallback-rpc"}catch(h){throw u}}}const s=BigInt(w);if(e<s){const n=`Insufficient ${t.symbol} balance. You have ${(Number(e)/Math.pow(10,o)).toFixed(6)} ${t.symbol} but need ${(Number(s)/Math.pow(10,o)).toFixed(6)} ${t.symbol}`;throw new Error(n)}}catch(f){if(f.message.includes("Insufficient"))throw f}a("approve"),window.coinleyPendingSplitPayment={contractCall:c,selectedToken:t,paymentData:e,selectedNetwork:n};try{const e="0xdac17f958d2ee523a2206206994597c13d831ec7"===c.tokenAddress.toLowerCase()||"USDT"===t.symbol.toUpperCase();let i,o=Vh;e&&(o=vP);try{i=BigInt(w)}catch(p){throw new Error(`Invalid amount value: ${w}`)}let s=0n,l=0;const u=3;for(;l<u;)try{s=await uA(dP,{address:c.tokenAddress,abi:Vh,functionName:"allowance",args:[r,c.contractAddress]});break}catch(m){l++,l<u?await new Promise(e=>setTimeout(e,2e3)):s=0n}if(s>=i){a("splitPayment");const e=await g();return e&&await y(e),e}if(e&&s>0n){const e=await xP(dP,n.chainId),t=await fA(dP,{address:c.tokenAddress,abi:Vh,functionName:"approve",args:[c.contractAddress,0n],...e});await hA(dP,{hash:t,confirmations:1,timeout:12e4})}const h=await xP(dP,n.chainId),f=await fA(dP,{address:c.tokenAddress,abi:Vh,functionName:"approve",args:[c.contractAddress,i],...h});d(f);await hA(dP,{hash:f,confirmations:1,timeout:12e4});await new Promise(e=>setTimeout(e,3e3));let v=0;const E=3;let _=!1;for(;v<E&&!_;){try{if(await uA(dP,{address:c.tokenAddress,abi:Vh,functionName:"allowance",args:[r,c.contractAddress]})>=i){_=!0;break}v<E-1&&await new Promise(e=>setTimeout(e,2e3))}catch(b){v<E-1&&await new Promise(e=>setTimeout(e,2e3))}v++}const x=await g();return x&&await y(x),x}catch(v){_P(v,"approve_transaction");const e=EP(v);if(l(e),a("idle"),(null==(i=v.message)?void 0:i.includes("User rejected"))||(null==(s=v.message)?void 0:s.includes("User denied"))||4001===v.code)throw new Error("Transaction was cancelled by user");throw new Error(`Approve failed: ${v.message}`)}}},executeSplitPayment:g,processFinalPayment:y,resetTransaction:()=>{a("idle"),l(""),d(null),window.coinleyPendingSplitPayment=null},setTransactionError:l,setTransactionStep:a}},CP=({options:e=[],value:t,onChange:n,placeholder:r,renderOption:i,getOptionKey:o,getOptionValue:s,getSearchableText:a,disabled:c=!1})=>{const[l,u]=yt.useState(!1),[d,h]=yt.useState(""),[f,p]=yt.useState({top:0,left:0,width:400,maxHeight:450}),m=yt.useRef(null),g=yt.useRef(null),y=e.filter(e=>(a?a(e):"").toLowerCase().includes(d.toLowerCase())),b=e.find(e=>s(e)===t),v=()=>{if(g.current){const e=window.innerWidth,t=window.innerHeight,n=Math.min(400,e-40),r=Math.min(450,t-100);p({top:t/2-r/2,left:e/2-n/2,width:n,maxHeight:r})}};yt.useEffect(()=>{const e=e=>{m.current&&!m.current.contains(e.target)&&g.current&&!g.current.contains(e.target)&&(u(!1),h(""))},t=()=>{l&&v()};if(l){v();const n=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${n}px`,document.body.style.width="100%",document.addEventListener("mousedown",e),window.addEventListener("resize",t)}return()=>{if(l){const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",window.scrollTo(0,-1*parseInt(e||"0"))}document.removeEventListener("mousedown",e),window.removeEventListener("resize",t)}},[l]);const w=l&&Dh.jsxs(Dh.Fragment,{children:[Dh.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-30 transition-opacity",style:{zIndex:999998},onClick:()=>{u(!1),h("")}}),Dh.jsxs("div",{ref:m,className:"fixed bg-white border-2 border-gray-200 rounded-3xl shadow-2xl overflow-hidden",style:{top:f.top,left:f.left,width:f.width,maxHeight:f.maxHeight,zIndex:999999,transform:"translateZ(0)",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05)"},children:[Dh.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 bg-gradient-to-r from-[#7042D2]/10 to-purple-50",children:[Dh.jsx("h3",{className:"text-lg font-semibold text-[#7042D2]",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:r||"Select Option"}),Dh.jsx("button",{onClick:()=>{u(!1),h("")},className:"text-gray-500 hover:text-gray-700 transition-colors p-1 rounded-full hover:bg-gray-100",children:Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),Dh.jsx("div",{className:"p-4 border-b border-gray-200 bg-gray-50",children:Dh.jsx("input",{type:"text",placeholder:"Search networks and tokens...",value:d,onChange:e=>h(e.target.value),className:"w-full p-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-[#7042D2]/20 focus:border-[#7042D2] text-sm",style:{fontFamily:"Bricolage Grotesque, sans-serif"},autoFocus:!0})}),Dh.jsx("div",{className:"overflow-y-auto custom-scrollbar",style:{maxHeight:(f.maxHeight||450)-180+"px",minHeight:"200px"},children:0===y.length?Dh.jsxs("div",{className:"p-8 text-gray-500 text-center",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[Dh.jsx("div",{className:"text-4xl mb-3",children:"🔍"}),Dh.jsx("div",{className:"text-lg mb-2",children:"No options found"}),Dh.jsx("div",{className:"text-sm text-gray-400",children:"Try a different search term"})]}):Dh.jsxs(Dh.Fragment,{children:[Dh.jsxs("div",{className:"px-4 py-3 bg-gray-50 border-b border-gray-100 text-sm text-gray-600",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[Dh.jsx("span",{className:"font-semibold",children:y.length})," option",1!==y.length?"s":""," available"]}),Dh.jsx("div",{className:"p-2",children:y.map(e=>Dh.jsx("button",{type:"button",onClick:()=>{n(s(e)),u(!1),h("")},className:"w-full p-4 text-left hover:bg-[#7042D2]/10 transition-all duration-200 rounded-xl mb-2 last:mb-0 "+(s(e)===t?"bg-[#7042D2]/20 text-[#7042D2] border-2 border-[#7042D2]/30":"text-gray-800 border-2 border-transparent hover:border-[#7042D2]/20"),style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:i(e)},o(e)))})]})}),Dh.jsx("div",{className:"p-3 bg-gradient-to-r from-gray-50 to-gray-100 border-t border-gray-200 text-center",children:Dh.jsx("div",{className:"text-xs text-gray-500",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:y.length>5?"↕️ Scroll to see more options":"✨ Select your preferred option"})})]})]});return Dh.jsxs(Dh.Fragment,{children:[Dh.jsx("div",{className:"relative",children:Dh.jsx("button",{ref:g,type:"button",onClick:()=>{c||(l||v(),u(!l))},disabled:c,className:`w-full p-4 border-2 rounded-2xl bg-gradient-to-r from-white to-gray-50 text-left focus:outline-none focus:ring-3 focus:ring-[#7042D2]/20 focus:border-[#7042D2] transition-all duration-300 ease-out shadow-lg hover:shadow-xl ${c?"opacity-50 cursor-not-allowed":"hover:border-[#7042D2]/50 cursor-pointer"} ${l?"border-[#7042D2] ring-3 ring-[#7042D2]/20":"border-gray-200"}`,style:{minHeight:"60px",fontFamily:"Bricolage Grotesque, sans-serif",fontSize:"16px",fontWeight:"500"},children:Dh.jsxs("div",{className:"flex items-center justify-between",children:[Dh.jsx("div",{className:"flex items-center space-x-3",children:b?i(b):Dh.jsx("span",{className:"text-gray-500",children:r})}),Dh.jsx("div",{className:"transform transition-transform duration-200 "+(l?"rotate-180":""),children:Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-[#7042D2]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})})}),"undefined"!=typeof document&&document.body&&Ch.createPortal(w,document.body),Dh.jsx("style",{jsx:!0,children:"\n .custom-scrollbar {\n scrollbar-width: thin;\n scrollbar-color: #7042D2 #f1f1f1;\n }\n .custom-scrollbar::-webkit-scrollbar {\n width: 12px;\n }\n .custom-scrollbar::-webkit-scrollbar-track {\n background: #f8f9fa;\n border-radius: 10px;\n margin: 4px;\n }\n .custom-scrollbar::-webkit-scrollbar-thumb {\n background: linear-gradient(180deg, #7042D2 0%, #5b34b1 100%);\n border-radius: 10px;\n border: 2px solid #f8f9fa;\n }\n .custom-scrollbar::-webkit-scrollbar-thumb:hover {\n background: linear-gradient(180deg, #5b34b1 0%, #4c2a93 100%);\n }\n .custom-scrollbar::-webkit-scrollbar-corner {\n background: #f8f9fa;\n }\n "})]})},IP=({currentStep:e,targetStep:t,children:n,className:r="",duration:i=300})=>{const[o,s]=yt.useState(e===t),[a,c]=yt.useState(e===t);return yt.useEffect(()=>{e===t?(c(!0),setTimeout(()=>s(!0),10)):(s(!1),setTimeout(()=>c(!1),i))},[e,t,i]),a?Dh.jsx("div",{className:`\n transition-all duration-300 ease-out\n ${o?"transform translate-y-0 opacity-100":"transform translate-y-full opacity-0"}\n ${r}\n `,style:{transitionDuration:`${i}ms`},children:n}):null},AP=({status:e,message:t,theme:n="light",payment:r=null,transactionHash:i=null,selectedPaymentMethod:o=null,selectedNetwork:s=null,merchantName:a="Merchant",onClose:c=null})=>{const[l,u]=yt.useState(!1),[d,h]=yt.useState(0);yt.useEffect(()=>{if("processing"===e){const e=setInterval(()=>{h(e=>e>=90?e:e+15*Math.random())},500);return()=>clearInterval(e)}},[e]);const f=async()=>{if(i)try{await navigator.clipboard.writeText(i),u(!0),setTimeout(()=>u(!1),2e3)}catch(e){}},p=()=>{switch(e){case"processing":return Dh.jsxs("div",{className:"relative",children:[Dh.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-[#7042D2] border-blue-500/20"}),Dh.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:Dh.jsx("div",{className:"w-6 h-6 bg-[#7042D2] rounded-full animate-pulse"})})]});case"success":return Dh.jsx("div",{className:"rounded-full h-16 w-16 bg-green-500 flex items-center justify-center animate-bounce",children:Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-10 w-10 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return Dh.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}};return"processing"===e?Dh.jsxs("div",{className:"flex flex-col items-center justify-center py-6 px-4",children:[Dh.jsx("div",{className:"mb-6",children:p()}),Dh.jsx("h3",{className:"text-xl font-bold mb-3 text-gray-900",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Processing Payment"}),Dh.jsx("p",{className:"text-center text-gray-600 mb-6",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Your transaction has been sent to the blockchain and is being processed..."}),Dh.jsxs("div",{className:"w-full max-w-xs mb-4",children:[Dh.jsx("div",{className:"bg-gray-200 rounded-full h-3",children:Dh.jsx("div",{className:"bg-[#7042D2] h-3 rounded-full transition-all duration-500 ease-out",style:{width:`${d}%`}})}),Dh.jsxs("div",{className:"text-center mt-2 text-sm text-gray-500",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Processing... ",Math.round(d),"%"]})]}),Dh.jsxs("div",{className:"text-center space-y-2",children:[Dh.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[Dh.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),Dh.jsx("span",{className:"text-sm text-gray-600",children:"Transaction submitted"})]}),Dh.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[Dh.jsx("div",{className:"w-2 h-2 bg-yellow-500 rounded-full animate-pulse"}),Dh.jsx("span",{className:"text-sm text-gray-600",children:"Confirming on blockchain..."})]}),Dh.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[Dh.jsx("div",{className:"w-2 h-2 bg-gray-300 rounded-full"}),Dh.jsx("span",{className:"text-sm text-gray-400",children:"Finalizing payment..."})]})]}),Dh.jsx("div",{className:"mt-6 p-3 bg-blue-50 rounded-lg border border-blue-200",children:Dh.jsx("p",{className:"text-xs text-blue-800 text-center",children:"Please don't close this window. This usually takes 10-30 seconds."})})]}):"success"===e?Dh.jsxs("div",{className:"flex flex-col items-center justify-center py-6 px-4",children:[Dh.jsx("div",{className:"mb-6",children:p()}),Dh.jsx("h3",{className:"text-2xl font-bold mb-3 text-gray-900",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Payment Successful!"}),r&&o&&Dh.jsxs("p",{className:"text-center max-w-[235px] mb-6 text-gray-600",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Your payment of ",Dh.jsxs("span",{className:"text-[#7042D2] font-semibold",children:[r.totalAmount||r.amount," ",o.currency]})," has been completed."]}),i&&Dh.jsxs("div",{className:"w-full mb-6 px-4",children:[Dh.jsx("p",{className:"text-sm font-medium mb-2 text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Transaction Details"}),Dh.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-colors bg-gray-50 border-gray-200 hover:bg-gray-100 mb-3",onClick:f,children:[Dh.jsx("span",{className:"font-mono text-sm text-gray-700",children:(m=i,m?m.length<=16?m:`${m.slice(0,8)}...${m.slice(-8)}`:"")}),Dh.jsxs("div",{className:"flex items-center",children:[l?Dh.jsx("span",{className:"text-green-500 text-xs font-medium mr-2",children:"Copied!"}):null,Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})]}),(()=>{const e=((e,t)=>{if(!e||!t)return null;const n="string"==typeof t?t:t.shortName||t.name;return{ethereum:`https://etherscan.io/tx/${e}`,bsc:`https://bscscan.com/tx/${e}`,polygon:`https://polygonscan.com/tx/${e}`,arbitrum:`https://arbiscan.io/tx/${e}`,optimism:`https://optimistic.etherscan.io/tx/${e}`,avalanche:`https://snowtrace.io/tx/${e}`,celo:`https://celoscan.io/tx/${e}`,base:`https://basescan.org/tx/${e}`}[null==n?void 0:n.toLowerCase()]||null})(i,s),t=(e=>{if(!e)return"Explorer";const t="string"==typeof e?e:e.shortName||e.name;return{ethereum:"Etherscan",bsc:"BscScan",polygon:"PolygonScan",arbitrum:"Arbiscan",optimism:"Optimistic Etherscan",avalanche:"SnowTrace",celo:"CeloScan",base:"BaseScan"}[null==t?void 0:t.toLowerCase()]||"Explorer"})(s);return s&&e&&Dh.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full p-3 rounded-lg border border-[#7042D2] bg-white hover:bg-purple-50 transition-colors group",children:[Dh.jsxs("span",{className:"text-sm font-medium text-[#7042D2]",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["View on ",t]}),Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-[#7042D2] group-hover:translate-x-1 transition-transform",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})})()]}),c&&Dh.jsx("button",{onClick:c,className:"w-full py-3 px-4 bg-[#7042D2] text-white font-semibold rounded-2xl text-lg shadow-md hover:bg-[#5b34b1] transition-colors",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Close"})]}):Dh.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[Dh.jsx("div",{className:"mb-4",children:p()}),Dh.jsx("h3",{className:"text-xl font-bold mb-2 text-gray-900",children:"processing"===e?"Processing Payment":"error"===e?"Payment Failed":"Unknown Status"}),Dh.jsx("p",{className:"text-center text-gray-600",children:t})]});var m};var PP={},MP={},OP={};let TP;const RP=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];OP.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},OP.getSymbolTotalCodewords=function(e){return RP[e]},OP.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},OP.setToSJISFunction=function(e){if("function"!=typeof e)throw new Error('"toSJISFunc" is not a valid function.');TP=e},OP.isKanjiModeEnabled=function(){return void 0!==TP},OP.toSJIS=function(e){return TP(e)};var NP,LP={};function BP(){this.buffer=[],this.length=0}(NP=LP).L={bit:1},NP.M={bit:0},NP.Q={bit:3},NP.H={bit:2},NP.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},NP.from=function(e,t){if(NP.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return NP.L;case"m":case"medium":return NP.M;case"q":case"quartile":return NP.Q;case"h":case"high":return NP.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(n){return t}},BP.prototype={get:function(e){const t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(let n=0;n<t;n++)this.putBit(1==(e>>>t-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var jP=BP;function DP(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}DP.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},DP.prototype.get=function(e,t){return this.data[e*this.size+t]},DP.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},DP.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var UP=DP,FP={};!function(e){const t=OP.getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];const n=Math.floor(e/7)+2,r=t(e),i=145===r?26:2*Math.ceil((r-13)/(2*n-2)),o=[r-7];for(let t=1;t<n-1;t++)o[t]=o[t-1]-i;return o.push(6),o.reverse()},e.getPositions=function(t){const n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)0===e&&0===t||0===e&&t===i-1||e===i-1&&0===t||n.push([r[e],r[t]]);return n}}(FP);var $P={};const zP=OP.getSymbolSize;$P.getPositions=function(e){const t=zP(e);return[[0,0],[t-7,0],[0,t-7]]};var HP={};!function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t=3,n=3,r=40,i=10;function o(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){const n=e.size;let r=0,i=0,o=0,s=null,a=null;for(let c=0;c<n;c++){i=o=0,s=a=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===s?i++:(i>=5&&(r+=t+(i-5)),s=n,i=1),n=e.get(l,c),n===a?o++:(o>=5&&(r+=t+(o-5)),a=n,o=1)}i>=5&&(r+=t+(i-5)),o>=5&&(r+=t+(o-5))}return r},e.getPenaltyN2=function(e){const t=e.size;let r=0;for(let n=0;n<t-1;n++)for(let i=0;i<t-1;i++){const t=e.get(n,i)+e.get(n,i+1)+e.get(n+1,i)+e.get(n+1,i+1);4!==t&&0!==t||r++}return r*n},e.getPenaltyN3=function(e){const t=e.size;let n=0,i=0,o=0;for(let r=0;r<t;r++){i=o=0;for(let s=0;s<t;s++)i=i<<1&2047|e.get(r,s),s>=10&&(1488===i||93===i)&&n++,o=o<<1&2047|e.get(s,r),s>=10&&(1488===o||93===o)&&n++}return n*r},e.getPenaltyN4=function(e){let t=0;const n=e.data.length;for(let r=0;r<n;r++)t+=e.data[r];return Math.abs(Math.ceil(100*t/n/5)-10)*i},e.applyMask=function(e,t){const n=t.size;for(let r=0;r<n;r++)for(let i=0;i<n;i++)t.isReserved(i,r)||t.xor(i,r,o(e,i,r))},e.getBestMask=function(t,n){const r=Object.keys(e.Patterns).length;let i=0,o=1/0;for(let s=0;s<r;s++){n(s),e.applyMask(s,t);const r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(s,t),r<o&&(o=r,i=s)}return i}}(HP);var qP={};const WP=LP,KP=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],GP=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];qP.getBlocksCount=function(e,t){switch(t){case WP.L:return KP[4*(e-1)+0];case WP.M:return KP[4*(e-1)+1];case WP.Q:return KP[4*(e-1)+2];case WP.H:return KP[4*(e-1)+3];default:return}},qP.getTotalCodewordsCount=function(e,t){switch(t){case WP.L:return GP[4*(e-1)+0];case WP.M:return GP[4*(e-1)+1];case WP.Q:return GP[4*(e-1)+2];case WP.H:return GP[4*(e-1)+3];default:return}};var VP={},ZP={};const YP=new Uint8Array(512),JP=new Uint8Array(256);!function(){let e=1;for(let t=0;t<255;t++)YP[t]=e,JP[e]=t,e<<=1,256&e&&(e^=285);for(let t=255;t<512;t++)YP[t]=YP[t-255]}(),ZP.log=function(e){if(e<1)throw new Error("log("+e+")");return JP[e]},ZP.exp=function(e){return YP[e]},ZP.mul=function(e,t){return 0===e||0===t?0:YP[JP[e]+JP[t]]},function(e){const t=ZP;e.mul=function(e,n){const r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let o=0;o<n.length;o++)r[i+o]^=t.mul(e[i],n[o]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){const e=r[0];for(let o=0;o<n.length;o++)r[o]^=t.mul(n[o],e);let i=0;for(;i<r.length&&0===r[i];)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}}(VP);const QP=VP;function XP(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}XP.prototype.initialize=function(e){this.degree=e,this.genPoly=QP.generateECPolynomial(this.degree)},XP.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(e.length+this.degree);t.set(e);const n=QP.mod(t,this.genPoly),r=this.degree-n.length;if(r>0){const e=new Uint8Array(this.degree);return e.set(n,r),e}return n};var eM=XP,tM={},nM={},rM={isValid:function(e){return!isNaN(e)&&e>=1&&e<=40}},iM={};const oM="[0-9]+";let sM="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";sM=sM.replace(/u/g,"\\u");const aM="(?:(?![A-Z0-9 $%*+\\-./:]|"+sM+")(?:.|[\r\n]))+";iM.KANJI=new RegExp(sM,"g"),iM.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),iM.BYTE=new RegExp(aM,"g"),iM.NUMERIC=new RegExp(oM,"g"),iM.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const cM=new RegExp("^"+sM+"$"),lM=new RegExp("^"+oM+"$"),uM=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");iM.testKanji=function(e){return cM.test(e)},iM.testNumeric=function(e){return lM.test(e)},iM.testAlphanumeric=function(e){return uM.test(e)},function(e){const t=rM,n=iM;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,n){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(r){return n}}}(nM),function(e){const t=OP,n=qP,r=LP,i=nM,o=rM,s=t.getBCHDigit(7973);function a(e,t){return i.getCharCountIndicator(e,t)+4}function c(e,t){let n=0;return e.forEach(function(e){const r=a(e.mode,t);n+=r+e.getBitsLength()}),n}e.from=function(e,t){return o.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,s){if(!o.isValid(e))throw new Error("Invalid QR Code version");void 0===s&&(s=i.BYTE);const c=8*(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r));if(s===i.MIXED)return c;const l=c-a(s,e);switch(s){case i.NUMERIC:return Math.floor(l/10*3);case i.ALPHANUMERIC:return Math.floor(l/11*2);case i.KANJI:return Math.floor(l/13);case i.BYTE:default:return Math.floor(l/8)}},e.getBestVersionForData=function(t,n){let o;const s=r.from(n,r.M);if(Array.isArray(t)){if(t.length>1)return function(t,n){for(let r=1;r<=40;r++)if(c(t,r)<=e.getCapacity(r,n,i.MIXED))return r}(t,s);if(0===t.length)return 1;o=t[0]}else o=t;return function(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}(o.mode,o.getLength(),s)},e.getEncodedBits=function(e){if(!o.isValid(e)||e<7)throw new Error("Invalid QR Code version");let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=7973<<t.getBCHDigit(n)-s;return e<<12|n}}(tM);var dM={};const hM=OP,fM=hM.getBCHDigit(1335);dM.getEncodedBits=function(e,t){const n=e.bit<<3|t;let r=n<<10;for(;hM.getBCHDigit(r)-fM>=0;)r^=1335<<hM.getBCHDigit(r)-fM;return 21522^(n<<10|r)};var pM={};const mM=nM;function gM(e){this.mode=mM.NUMERIC,this.data=e.toString()}gM.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},gM.prototype.getLength=function(){return this.data.length},gM.prototype.getBitsLength=function(){return gM.getBitsLength(this.data.length)},gM.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);const i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,3*i+1))};var yM=gM;const bM=nM,vM=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function wM(e){this.mode=bM.ALPHANUMERIC,this.data=e}wM.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},wM.prototype.getLength=function(){return this.data.length},wM.prototype.getBitsLength=function(){return wM.getBitsLength(this.data.length)},wM.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*vM.indexOf(this.data[t]);n+=vM.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(vM.indexOf(this.data[t]),6)};var EM=wM;const _M=nM;function xM(e){this.mode=_M.BYTE,this.data="string"==typeof e?(new TextEncoder).encode(e):new Uint8Array(e)}xM.getBitsLength=function(e){return 8*e},xM.prototype.getLength=function(){return this.data.length},xM.prototype.getBitsLength=function(){return xM.getBitsLength(this.data.length)},xM.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var kM=xM;const SM=nM,CM=OP;function IM(e){this.mode=SM.KANJI,this.data=e}IM.getBitsLength=function(e){return 13*e},IM.prototype.getLength=function(){return this.data.length},IM.prototype.getBitsLength=function(){return IM.getBitsLength(this.data.length)},IM.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=CM.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}};var AM,PM=IM,MM={exports:{}};AM={single_source_shortest_paths:function(e,t,n){var r={},i={};i[t]=0;var o,s,a,c,l,u,d,h=AM.PriorityQueue.make();for(h.push(t,0);!h.empty();)for(a in s=(o=h.pop()).value,c=o.cost,l=e[s]||{})l.hasOwnProperty(a)&&(u=c+l[a],d=i[a],(void 0===i[a]||d>u)&&(i[a]=u,h.push(a,u),r[a]=s));if(void 0!==n&&void 0===i[n]){var f=["Could not find a path from ",t," to ",n,"."].join("");throw new Error(f)}return r},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,n){var r=AM.single_source_shortest_paths(e,t,n);return AM.extract_shortest_path_from_predecessor_list(r,n)},PriorityQueue:{make:function(e){var t,n=AM.PriorityQueue,r={};for(t in e=e||{},n)n.hasOwnProperty(t)&&(r[t]=n[t]);return r.queue=[],r.sorter=e.sorter||n.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}},MM.exports=AM;var OM=MM.exports;!function(e){const t=nM,n=yM,r=EM,i=kM,o=PM,s=iM,a=OP,c=OM;function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){const r=[];let i;for(;null!==(i=e.exec(n));)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){const n=u(s.NUMERIC,t.NUMERIC,e),r=u(s.ALPHANUMERIC,t.ALPHANUMERIC,e);let i,o;a.isKanjiModeEnabled()?(i=u(s.BYTE,t.BYTE,e),o=u(s.KANJI,t.KANJI,e)):(i=u(s.BYTE_KANJI,t.BYTE,e),o=[]);return n.concat(r,i,o).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function h(e,s){switch(s){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return o.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function f(e,s){let c;const l=t.getBestModeForData(e);if(c=t.from(s,l),c!==t.BYTE&&c.bit<l.bit)throw new Error('"'+e+'" cannot be encoded with mode '+t.toString(c)+".\n Suggested mode is: "+t.toString(l));switch(c!==t.KANJI||a.isKanjiModeEnabled()||(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new o(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(f(t,null)):t.data&&e.push(f(t.data,t.mode)),e},[])},e.fromString=function(n,r){const i=function(e){const n=[];for(let r=0;r<e.length;r++){const i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}(d(n,a.isKanjiModeEnabled())),o=function(e,n){const r={},i={start:{}};let o=["start"];for(let s=0;s<e.length;s++){const a=e[s],c=[];for(let e=0;e<a.length;e++){const l=a[e],u=""+s+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<o.length;e++){const s=o[e];r[s]&&r[s].node.mode===l.mode?(i[s][u]=h(r[s].lastCount+l.length,l.mode)-h(r[s].lastCount,l.mode),r[s].lastCount+=l.length):(r[s]&&(r[s].lastCount=l.length),i[s][u]=h(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}o=c}for(let t=0;t<o.length;t++)i[o[t]].end=0;return{map:i,table:r}}(i,r),s=c.find_path(o.map,"start","end"),u=[];for(let e=1;e<s.length-1;e++)u.push(o.table[s[e]].node);return e.fromArray(function(e){return e.reduce(function(e,t){const n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(u))},e.rawSplit=function(t){return e.fromArray(d(t,a.isKanjiModeEnabled()))}}(pM);const TM=OP,RM=LP,NM=jP,LM=UP,BM=FP,jM=$P,DM=HP,UM=qP,FM=eM,$M=tM,zM=dM,HM=nM,qM=pM;function WM(e,t,n){const r=e.size,i=zM.getEncodedBits(t,n);let o,s;for(o=0;o<15;o++)s=1==(i>>o&1),o<6?e.set(o,8,s,!0):o<8?e.set(o+1,8,s,!0):e.set(r-15+o,8,s,!0),o<8?e.set(8,r-o-1,s,!0):o<9?e.set(8,15-o-1+1,s,!0):e.set(8,15-o-1,s,!0);e.set(r-8,8,1,!0)}function KM(e,t,n){const r=new NM;n.forEach(function(t){r.put(t.mode.bit,4),r.put(t.getLength(),HM.getCharCountIndicator(t.mode,e)),t.write(r)});const i=8*(TM.getSymbolTotalCodewords(e)-UM.getTotalCodewordsCount(e,t));for(r.getLengthInBits()+4<=i&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);const o=(i-r.getLengthInBits())/8;for(let s=0;s<o;s++)r.put(s%2?17:236,8);return function(e,t,n){const r=TM.getSymbolTotalCodewords(t),i=UM.getTotalCodewordsCount(t,n),o=r-i,s=UM.getBlocksCount(t,n),a=r%s,c=s-a,l=Math.floor(r/s),u=Math.floor(o/s),d=u+1,h=l-u,f=new FM(h);let p=0;const m=new Array(s),g=new Array(s);let y=0;const b=new Uint8Array(e.buffer);for(let x=0;x<s;x++){const e=x<c?u:d;m[x]=b.slice(p,p+e),g[x]=f.encode(m[x]),p+=e,y=Math.max(y,e)}const v=new Uint8Array(r);let w,E,_=0;for(w=0;w<y;w++)for(E=0;E<s;E++)w<m[E].length&&(v[_++]=m[E][w]);for(w=0;w<h;w++)for(E=0;E<s;E++)v[_++]=g[E][w];return v}(r,e,t)}function GM(e,t,n,r){let i;if(Array.isArray(e))i=qM.fromArray(e);else{if("string"!=typeof e)throw new Error("Invalid data");{let r=t;if(!r){const t=qM.rawSplit(e);r=$M.getBestVersionForData(t,n)}i=qM.fromString(e,r||40)}}const o=$M.getBestVersionForData(i,n);if(!o)throw new Error("The amount of data is too big to be stored in a QR Code");if(t){if(t<o)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+o+".\n")}else t=o;const s=KM(t,n,i),a=TM.getSymbolSize(t),c=new LM(a);return function(e,t){const n=e.size,r=jM.getPositions(t);for(let i=0;i<r.length;i++){const t=r[i][0],o=r[i][1];for(let r=-1;r<=7;r++)if(!(t+r<=-1||n<=t+r))for(let i=-1;i<=7;i++)o+i<=-1||n<=o+i||(r>=0&&r<=6&&(0===i||6===i)||i>=0&&i<=6&&(0===r||6===r)||r>=2&&r<=4&&i>=2&&i<=4?e.set(t+r,o+i,!0,!0):e.set(t+r,o+i,!1,!0))}}(c,t),function(e){const t=e.size;for(let n=8;n<t-8;n++){const t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}(c),function(e,t){const n=BM.getPositions(t);for(let r=0;r<n.length;r++){const t=n[r][0],i=n[r][1];for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)-2===n||2===n||-2===r||2===r||0===n&&0===r?e.set(t+n,i+r,!0,!0):e.set(t+n,i+r,!1,!0)}}(c,t),WM(c,n,0),t>=7&&function(e,t){const n=e.size,r=$M.getEncodedBits(t);let i,o,s;for(let a=0;a<18;a++)i=Math.floor(a/3),o=a%3+n-8-3,s=1==(r>>a&1),e.set(i,o,s,!0),e.set(o,i,s,!0)}(c,t),function(e,t){const n=e.size;let r=-1,i=n-1,o=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,a-n)){let r=!1;s<t.length&&(r=1==(t[s]>>>o&1)),e.set(i,a-n,r),o--,-1===o&&(s++,o=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}(c,s),isNaN(r)&&(r=DM.getBestMask(c,WM.bind(null,c,n))),DM.applyMask(r,c),WM(c,n,r),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}MP.create=function(e,t){if(void 0===e||""===e)throw new Error("No input text");let n,r,i=RM.M;return void 0!==t&&(i=RM.from(t.errorCorrectionLevel,RM.M),n=$M.from(t.version),r=DM.from(t.maskPattern),t.toSJISFunc&&TM.setToSJISFunction(t.toSJISFunc)),GM(e,n,i,r)};var VM={},ZM={};!function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");const n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});const n=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,n){const r=e.getScale(t,n);return Math.floor((t+2*n.margin)*r)},e.qrToImageData=function(t,n,r){const i=n.modules.size,o=n.modules.data,s=e.getScale(i,r),a=Math.floor((i+2*r.margin)*s),c=r.margin*s,l=[r.color.light,r.color.dark];for(let e=0;e<a;e++)for(let n=0;n<a;n++){let u=4*(e*a+n),d=r.color.light;if(e>=c&&n>=c&&e<a-c&&n<a-c){d=l[o[Math.floor((e-c)/s)*i+Math.floor((n-c)/s)]?1:0]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}}(ZM),function(e){const t=ZM;e.render=function(e,n,r){let i=r,o=n;void 0!==i||n&&n.getContext||(i=n,n=void 0),n||(o=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),i=t.getOptions(i);const s=t.getImageWidth(e.modules.size,i),a=o.getContext("2d"),c=a.createImageData(s,s);return t.qrToImageData(c.data,e,i),function(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=n,t.width=n,t.style.height=n+"px",t.style.width=n+"px"}(a,o,s),a.putImageData(c,0,0),o},e.renderToDataURL=function(t,n,r){let i=r;void 0!==i||n&&n.getContext||(i=n,n=void 0),i||(i={});const o=e.render(t,n,i),s=i.type||"image/png",a=i.rendererOpts||{};return o.toDataURL(s,a.quality)}}(VM);var YM={};const JM=ZM;function QM(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function XM(e,t,n){let r=e+t;return void 0!==n&&(r+=" "+n),r}YM.render=function(e,t,n){const r=JM.getOptions(t),i=e.modules.size,o=e.modules.data,s=i+2*r.margin,a=r.color.light.a?"<path "+QM(r.color.light,"fill")+' d="M0 0h'+s+"v"+s+'H0z"/>':"",c="<path "+QM(r.color.dark,"stroke")+' d="'+function(e,t,n){let r="",i=0,o=!1,s=0;for(let a=0;a<e.length;a++){const c=Math.floor(a%t),l=Math.floor(a/t);c||o||(o=!0),e[a]?(s++,a>0&&c>0&&e[a-1]||(r+=o?XM("M",c+n,.5+l+n):XM("m",i,0),i=0,o=!1),c+1<t&&e[a+1]||(r+=XM("h",s),s=0)):i++}return r}(o,i,r.margin)+'"/>',l='viewBox="0 0 '+s+" "+s+'"',u='<svg xmlns="http://www.w3.org/2000/svg" '+(r.width?'width="'+r.width+'" height="'+r.width+'" ':"")+l+' shape-rendering="crispEdges">'+a+c+"</svg>\n";return"function"==typeof n&&n(null,u),u};const eO=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},tO=MP,nO=VM,rO=YM;function iO(e,t,n,r,i){const o=[].slice.call(arguments,1),s=o.length,a="function"==typeof o[s-1];if(!a&&!eO())throw new Error("Callback required as last argument");if(!a){if(s<1)throw new Error("Too few arguments provided");return 1===s?(n=t,t=r=void 0):2!==s||t.getContext||(r=n,n=t,t=void 0),new Promise(function(i,o){try{const o=tO.create(n,r);i(e(o,t,r))}catch(s){o(s)}})}if(s<2)throw new Error("Too few arguments provided");2===s?(i=n,n=t,t=r=void 0):3===s&&(t.getContext&&void 0===i?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0));try{const o=tO.create(n,r);i(null,e(o,t,r))}catch(c){i(c)}}PP.create=tO.create,PP.toCanvas=iO.bind(null,nO.render),PP.toDataURL=iO.bind(null,nO.renderToDataURL),PP.toString=iO.bind(null,function(e,t,n){return rO.render(e,n)});const oO={bitcoin:1,ethereum:1027,bsc:1839,polygon:3890,cardano:2010,avalanche:5805,fantom:3513,arbitrum:11841,optimism:11840,USDT:825,USDC:3408,BUSD:4687,DAI:4943,FRAX:6952,TUSD:2563,USDP:5992,USDD:5994,FDUSD:26081,PYUSD:28295,WBTC:3717,LINK:1975,UNI:7083,AAVE:7278,COMP:5692,YFI:5864,MKR:1518,SUSHI:6758,CRV:6538,SNX:2586,UMA:5617,BAL:5728,MANA:1966,SAND:6210,APE:18876,LDO:8e3,GRT:6719,ENS:13855,RPL:2943,SHIB:5994,MATIC:3890,BNB:1839,ADA:2010,SOL:5426,DOT:6636,AVAX:5805,TRX:1958,ALGO:4030,FTM:3513,ARB:11841,OP:11840,"1INCH":8104,DYDX:11156,ICP:8916,FIL:2280,CAKE:7186,RUNE:4157,ALPHA:7232,BNT:1727,KNC:1982,ZRX:1896,REN:2539,LRC:1934,WETH:2396,WMATIC:3890,WBNB:1839,UST:7129,USTC:7129,LUSD:8115,MIM:9681,FEI:8642,TRIBE:8741,RAI:8525,SUSD:2927},sO={ethereum:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",bsc:"https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png",polygon:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png",arbitrum:"https://s2.coinmarketcap.com/static/img/coins/64x64/11841.png",avalanche:"https://s2.coinmarketcap.com/static/img/coins/64x64/5805.png",celo:"https://s2.coinmarketcap.com/static/img/coins/64x64/5567.png",optimism:"https://s2.coinmarketcap.com/static/img/coins/64x64/11840.png",base:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",eth:"https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png",bnb:"https://s2.coinmarketcap.com/static/img/coins/64x64/1839.png",trx:"https://s2.coinmarketcap.com/static/img/coins/64x64/1958.png",algo:"https://s2.coinmarketcap.com/static/img/coins/64x64/4030.png",sol:"https://s2.coinmarketcap.com/static/img/coins/64x64/5426.png",matic:"https://s2.coinmarketcap.com/static/img/coins/64x64/28321.png",arb:"https://s2.coinmarketcap.com/static/img/coins/64x64/11841.png",avax:"https://s2.coinmarketcap.com/static/img/coins/64x64/5805.png",op:"https://s2.coinmarketcap.com/static/img/coins/64x64/11840.png"},aO={metamask:"https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Fox.svg",coinbase:"https://avatars.githubusercontent.com/u/18060234?s=280&v=4",rabby:"https://rabby.io/logo-128.png",zerion:"https://app.zerion.io/favicon-32x32.png",phantom:"https://phantom.app/favicons/apple-touch-icon.png",trust:"https://trustwallet.com/favicon-196x196.png",okx:"https://static.okx.com/cdn/assets/imgs/248/58E63FEA47A2B7D7.png",binance:"https://bin.bnbstatic.com/static/images/common/favicon.ico",cryptocom:"https://crypto.com/favicon.ico",hot:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiNGRjZBNkEiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMmg0djhoLTR2LTJoMnYtNGgtMnYtMnptNiAwaDJ2MmgtdjdoLTJ2LTIiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg==",backpack:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiMwMEQ0QUEiIHN0cm9rZT0iI0ZGRkZGRiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMGg4djJoLTJ2NmgtdjhoLTZWMTB6bTIgMnY0aDJWMTJ6IiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4=","1inch":"https://1inch.io/favicon.svg",default:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTQiIGZpbGw9IiM2MzY2RjEiIHN0cm9rZT0iI0Y5RkFGQiIgc3Ryb2tlLXdpZHRoPSIyIi8+CjxwYXRoIGQ9Ik0xMCAxMmgxMnY4SDEweiIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxLjUiIHJ4PSIxIi8+CjxjaXJjbGUgY3g9IjE4IiBjeT0iMTYiIHI9IjEiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg=="},cO=e=>(e=>{if(!e)return null;const t=oO[e.toUpperCase()];return t?`https://s2.coinmarketcap.com/static/img/coins/64x64/${t}.png`:null})(e),lO=(e,t)=>{const n=e.toLowerCase(),r=t.toLowerCase();for(const[i,o]of Object.entries(aO))if(n.includes(i)||r.includes(i))return o;return aO.default},uO=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),dO=e=>{switch(e){case"trust":return window.ethereum&&!0===window.ethereum.isTrust;case"metaMask":return window.ethereum&&!0===window.ethereum.isMetaMask;case"injected":return window.ethereum&&!window.ethereum.isMetaMask&&!window.ethereum.isCoinbaseWallet;default:return!1}},hO=(e,t)=>{if(!t)return[];if(!["ethereum","bsc","polygon","arbitrum","optimism","avalanche","celo","base"].includes(t.shortName))return[];return[...(e||[]).map(e=>(e=>({type:e.id,name:e.name,icon:lO(e.name,e.id),description:`Connect using ${e.name}`,isInstalled:!0,connector:e,isWagmi:!0}))(e)),...uO()?[{type:"trust",name:"Trust Wallet",icon:"🛡️",description:"Multi-chain wallet with transaction deep links",isInstalled:!1,connector:null,isWagmi:!1,mobileOnly:!0,hasTransactionDeepLinks:!0}]:[]]},fO=(e,t,n,r,i="metamask",o=null)=>{if(!e)return null;try{const t="https://paymentscreen.vercel.app",r=new URLSearchParams,o=(null==e?void 0:e.id)||(null==e?void 0:e.splitterPaymentId);if(!o)return null;r.set("paymentId",o),r.set("preferredWallet",i),r.set("isMobile","true");const s=`${t}?${r.toString()}`;let a;switch(i){case"metamask":a=`https://metamask.app.link/dapp/${s.replace("https://","")}`;break;case"trust":const e=(null==n?void 0:n.chainId)||1;a=`https://link.trustwallet.com/open_url?coin_id=${(e=>{const t="string"==typeof e&&e.startsWith("0x")?parseInt(e,16):parseInt(e);return[1,56,137,42161,10,43114,42220,8453].includes(t)?60:{}[t]||60})(e)}&url=${encodeURIComponent(s)}`;break;case"coinbase":a=`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(s)}`;break;default:a=s}return a}catch(s){return null}},pO=(e,t)=>{if(!t)return null;try{switch(e){case"metamask":return t.includes("metamask.app.link")?t:`https://metamask.app.link/dapp/${t.replace("https://","")}`;case"trust":return t.includes("link.trustwallet.com")?t:`https://link.trustwallet.com/open_url?coin_id=60&url=${encodeURIComponent(t)}`;case"coinbase":return t.includes("go.cb-w.com")?t:`https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(t)}`;default:return t}}catch(n){return t}},mO=Object.freeze(Object.defineProperty({__proto__:null,generateMobilePaymentDeepLink:pO,generateQRPaymentURI:fO},Symbol.toStringTag,{value:"Module"})),gO=({walletAddress:e,amount:t,currency:n,network:r,theme:i="light",paymentData:o=null,onPaymentDetected:s=null,config:a=null,selectedToken:c=null,selectedNetwork:l=null,preferredWallet:u="metamask",compact:d=!1})=>{const[h,f]=yt.useState(""),[p,m]=yt.useState(""),[g,y]=yt.useState(!0),[b,v]=yt.useState(!1),[w,E]=yt.useState(!1),_=yt.useRef(null);return yt.useEffect(()=>{(async()=>{if(null==o?void 0:o.id){y(!0);try{if(!c||!c.contractAddress)throw new Error("Cannot generate QR code: Token contract address required");if(!l||!l.chainId)throw new Error("Cannot generate QR code: Network chain ID required");const e=fO(o,0,l,0,u);if(e.includes("metamask.app.link")||e.includes("link.trustwallet.com")||e.includes("go.cb-w.com"),!e)throw new Error("Failed to generate Coinley payment URL");f(e);const t=uO(),n=await PP.toDataURL(e,{width:d?140:t?350:280,margin:2,errorCorrectionLevel:"M",color:{dark:"dark"===i?"#FFFFFF":"#000000",light:"dark"===i?"#000000":"#FFFFFF"}});m(n),y(!1)}catch(e){y(!1)}}else y(!1)})()},[o,t,n,r,i,c,l,a,u]),yt.useEffect(()=>()=>{_.current&&clearInterval(_.current)},[]),Dh.jsx("div",{className:"flex flex-col items-center",children:Dh.jsxs("div",{className:"flex gap-3 items-start w-full mb-2",children:[Dh.jsx("div",{className:"p-1.5 rounded-lg bg-white shadow-sm border flex-shrink-0",children:g?Dh.jsx("div",{className:"flex items-center justify-center",style:{width:140,height:140},children:Dh.jsxs("div",{className:"text-center",children:[Dh.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-purple-600 mx-auto mb-1"}),Dh.jsx("div",{className:"text-xs text-gray-600",children:"Generating..."})]})}):p?Dh.jsx("img",{src:p,alt:"Payment QR Code",className:"rounded-lg",style:{width:140,height:140}}):Dh.jsx("div",{className:"flex items-center justify-center bg-gray-100 rounded-lg",style:{width:140,height:140},children:Dh.jsxs("div",{className:"text-center p-2",children:[Dh.jsx("div",{className:"text-lg mb-1",children:"⚠️"}),Dh.jsx("div",{className:"text-xs text-gray-600",children:(null==o?void 0:o.id)?"QR Failed":"Payment not created"})]})})}),Dh.jsxs("div",{className:"flex-1 flex flex-col justify-center",children:[Dh.jsxs("div",{className:"p-2 bg-gray-50 rounded-lg mb-2",children:[Dh.jsxs("div",{className:"flex justify-between items-center mb-1",children:[Dh.jsx("span",{className:"text-xs font-medium text-gray-600",children:"Amount:"}),Dh.jsxs("span",{className:"text-sm font-bold text-[#7042D2]",children:[t," ",n]})]}),Dh.jsxs("div",{className:"flex justify-between items-center",children:[Dh.jsx("span",{className:"text-xs text-gray-500",children:"Network:"}),Dh.jsx("span",{className:"text-xs font-medium text-gray-700",children:r})]})]}),w?Dh.jsxs("div",{className:"flex items-center justify-center text-xs font-semibold text-green-600 p-1.5 bg-green-50 rounded-lg",children:[Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Payment Received!"]}):Dh.jsx("div",{className:"p-1.5 rounded-lg bg-blue-50 border border-blue-200",children:Dh.jsx("p",{className:"text-xs text-blue-700 text-center leading-tight",children:"📱 Scan with phone camera"})})]})]})})},yO=({selectedNetwork:e,onWalletSelect:t,onConnect:n,connectedWallet:r,loading:i,paymentData:o=null,selectedToken:s=null,api:a=null})=>{const[c,l]=yt.useState(null),{connectors:u}=GI(),{isConnected:d,address:h}=AC(),f=hO(u,e),p=async(t,n)=>{if(uO())if(o)try{const{generateQRPaymentURI:r,generateMobilePaymentDeepLink:i}=await Promise.resolve().then(()=>mO),c=r(o,s,e,(null==a?void 0:a.config)||{},n);if(!c)throw new Error("Failed to generate payment URL");const l=i(n,c);if(!l)throw new Error(`Failed to generate ${t.name} deep link`);window.location.href=l}catch(r){alert(`Failed to open ${t.name}: ${r.message}`)}else alert("Please create a payment first before selecting a mobile wallet.");else alert(`Please install ${t.name} mobile app or use the browser extension if available.`)};return e?0===f.length?Dh.jsxs("div",{className:"text-center p-4",children:[Dh.jsxs("p",{className:"text-gray-500 mb-4",children:["No compatible wallets found for ",e.name]}),Dh.jsx("div",{className:"p-3 bg-amber-50 rounded-lg border border-amber-200",children:Dh.jsxs("div",{className:"text-sm text-amber-800",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:[Dh.jsx("div",{className:"font-medium mb-2",children:"Install a compatible wallet:"}),Dh.jsxs("div",{className:"space-y-1 text-xs",children:[Dh.jsxs("div",{children:["• ",Dh.jsx("a",{href:"https://metamask.io/download/",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-900",children:"Install MetaMask Wallet"})]}),Dh.jsxs("div",{children:["• ",Dh.jsx("a",{href:"https://www.coinbase.com/wallet",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-900",children:"Install Coinbase Wallet"})]})]})]})})]}):Dh.jsxs("div",{className:"space-y-4",children:[Dh.jsxs("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:["Select Wallet for ",e.name]}),Dh.jsx(CP,{options:f,value:(null==r?void 0:r.walletType)||c||"",onChange:async e=>{l(e);const r=f.find(t=>t.type===e);r&&(t(e),r.isWagmi&&r.connector?await n(r.connector):r.isWagmi||await p(r,e))},placeholder:"Choose your wallet...",renderOption:e=>{var t,n;return Dh.jsxs("div",{className:"flex items-center space-x-3",children:[Dh.jsxs("div",{className:"w-8 h-8 flex items-center justify-center",children:[e.icon.startsWith("http")||e.icon.startsWith("data:")?Dh.jsx("img",{src:e.icon,alt:e.name,className:"w-6 h-6 rounded-full object-contain",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="block"}}):Dh.jsx("div",{className:"text-2xl",children:e.icon}),Dh.jsx("div",{className:"text-xl",style:{display:"none"},children:"🔗"})]}),Dh.jsxs("div",{className:"flex-1",children:[Dh.jsxs("div",{className:"font-semibold text-gray-800 flex items-center",children:[e.name,dO(e.type)&&Dh.jsx("span",{className:"ml-2 px-2 py-1 bg-blue-100 text-blue-700 text-xs rounded-full",children:"DETECTED"}),(null==r?void 0:r.walletType)===e.type&&Dh.jsx("span",{className:"ml-2 px-2 py-1 bg-green-100 text-green-700 text-xs rounded-full",children:"CONNECTED"})]}),Dh.jsx("div",{className:"text-sm text-gray-500",children:(null==r?void 0:r.walletType)===e.type?`Connected • ${null==(t=r.account)?void 0:t.slice(0,6)}...${null==(n=r.account)?void 0:n.slice(-4)}`:e.description})]}),i&&c===e.type&&Dh.jsx("div",{className:"animate-spin rounded-full h-5 w-5 border-b-2 border-[#7042D2]"})]})},getOptionKey:e=>e.type,getOptionValue:e=>e.type,getSearchableText:e=>`${e.name} ${e.description}`,disabled:i})]}):Dh.jsx("div",{className:"text-center p-4",children:Dh.jsx("p",{className:"text-gray-500",children:"Please select a network first"})})},bO=(()=>{if("undefined"!=typeof process&&process.env)return!1;if("undefined"!=typeof window){const e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e||e.includes("192.168.")}return!1})()||(()=>{if("undefined"!=typeof window){const e=new URLSearchParams(window.location.search);return"true"===e.get("debug")||"true"===e.get("debugMode")}return!1})(),vO=({paymentData:e,selectedToken:t,selectedNetwork:n,config:r,onPaymentStarted:i=()=>{},onError:o=()=>{}})=>{var s,a;const[c,l]=yt.useState(null),[u,d]=yt.useState(!1),[h,f]=yt.useState([]),[p,m]=yt.useState(!1),[g,y]=yt.useState(0);yt.useEffect(()=>{var r,i,o;(null==e?void 0:e.id)&&(null==t?void 0:t.contractAddress)&&(null==n?void 0:n.chainId)&&((null==(r=null==e?void 0:e.contractCall)?void 0:r.contractAddress)||(null==e?void 0:e.contractAddress))?b("success","✅ Payment data complete",{paymentId:e.id,tokenContract:t.contractAddress,chainId:n.chainId,paymentContract:(null==(o=null==e?void 0:e.contractCall)?void 0:o.contractAddress)||(null==e?void 0:e.contractAddress)}):(b("debug","⏳ Waiting for complete payment data",{hasPaymentId:!!(null==e?void 0:e.id),hasTokenContract:!!(null==t?void 0:t.contractAddress),hasChainId:!!(null==n?void 0:n.chainId),hasPaymentContract:!(!(null==(i=null==e?void 0:e.contractCall)?void 0:i.contractAddress)&&!(null==e?void 0:e.contractAddress)),checkCount:g}),y(e=>e+1))},[e,t,n,g]);const b=(e,t,n=null)=>{const r=(new Date).toLocaleTimeString(),i={id:Date.now()+Math.random(),type:e,message:t,data:n,timestamp:r};bO&&(f(e=>[...e,i].slice(-20)),e.toUpperCase())},v=[{id:"metamask",name:"MetaMask",icon:"🦊",description:"Connect with MetaMask mobile"},{id:"trust",name:"Trust Wallet",icon:"🛡️",description:"Connect with Trust Wallet"},{id:"coinbase",name:"Coinbase Wallet",icon:"💙",description:"Connect with Coinbase Wallet"}];if(!e)return Dh.jsx("div",{className:"p-4 bg-amber-50 rounded-lg border border-amber-200",children:Dh.jsxs("div",{className:"text-center",children:[Dh.jsx("div",{className:"text-amber-800 font-medium mb-2",children:"⚠️ Payment Required"}),Dh.jsx("div",{className:"text-sm text-amber-700",children:"Please create a payment before selecting a wallet"})]})});const w=(null==e?void 0:e.id)&&(null==t?void 0:t.contractAddress)&&(null==n?void 0:n.chainId)&&((null==(s=null==e?void 0:e.contractCall)?void 0:s.contractAddress)||(null==e?void 0:e.contractAddress));return Dh.jsx("div",{className:"space-y-4",children:w?Dh.jsxs(Dh.Fragment,{children:[Dh.jsxs("div",{className:"space-y-2",children:[Dh.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:"Bricolage Grotesque, sans-serif"},children:"Select Mobile Wallet"}),Dh.jsx(CP,{options:v,value:c||"",onChange:async s=>{const a=v.find(e=>e.id===s);if(a){l(s),d(!0);try{if(b("info",`🚀 Mobile wallet selected: ${a.name}`),!e)throw new Error("Payment data not available. Please create payment first.");b("debug","🔍 Payment Data Check",{hasPaymentData:!!e,hasSelectedToken:!!t,hasSelectedNetwork:!!n,hasConfig:!!r,paymentId:(null==e?void 0:e.id)||(null==e?void 0:e.splitterPaymentId),tokenAddress:null==t?void 0:t.contractAddress,networkChainId:null==n?void 0:n.chainId,amount:(null==e?void 0:e.totalAmount)||(null==e?void 0:e.amount)||(null==r?void 0:r.amount)});const o=fO(e,0,n,0,s);if(!o)throw new Error("Failed to generate payment URL");b("success","📱 Generated payment URL",{url:o,length:o.length});const c=pO(s,o);if(!c)throw new Error(`Failed to generate ${a.name} deep link`);b("success",`🔗 Deep link generated for ${a.name}`,{deepLink:c}),i({walletType:s,walletName:a.name,paymentUrl:o,deepLink:c}),setTimeout(()=>{b("info",`📱 Opening ${a.name}...`),window.location.href=c},500)}catch(c){b("error","❌ Mobile wallet connection failed",{error:c.message,walletId:s,hasPaymentData:!!e,hasSelectedToken:!!t,hasSelectedNetwork:!!n}),o(c.message),d(!1),l(null)}}},placeholder:"Choose your wallet...",renderOption:e=>Dh.jsxs("div",{className:"flex items-center space-x-3",children:[Dh.jsx("div",{className:"w-8 h-8 flex items-center justify-center",children:Dh.jsx("div",{className:"text-2xl",children:e.icon})}),Dh.jsxs("div",{className:"flex-1",children:[Dh.jsxs("div",{className:"font-semibold text-gray-800",children:[e.name,c===e.id&&u&&Dh.jsx("span",{className:"ml-2 px-2 py-1 bg-blue-100 text-blue-700 text-xs rounded-full animate-pulse",children:"Opening..."})]}),Dh.jsx("div",{className:"text-sm text-gray-500",children:e.description})]})]}),getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.description}`,disabled:u}),Dh.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"Select a wallet to open it with your payment details"})]}),u&&c&&Dh.jsx("div",{className:"p-3 bg-blue-50 border border-blue-200 rounded-lg animate-pulse",children:Dh.jsxs("div",{className:"flex items-center space-x-2",children:[Dh.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-blue-600 border-t-transparent"}),Dh.jsxs("div",{className:"text-sm text-blue-700",children:["Opening ",null==(a=v.find(e=>e.id===c))?void 0:a.name,"..."]})]})}),Dh.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[Dh.jsxs("div",{className:"flex justify-between items-center text-sm",children:[Dh.jsx("span",{className:"text-gray-600",children:"Amount:"}),Dh.jsxs("span",{className:"font-semibold text-gray-800",children:[e.totalAmount," ",(null==t?void 0:t.symbol)||"USDC"]})]}),Dh.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[Dh.jsx("span",{className:"text-gray-600",children:"Network:"}),Dh.jsx("span",{className:"text-gray-800",children:(null==n?void 0:n.name)||"Ethereum"})]})]}),Dh.jsx("div",{className:"p-3 bg-purple-50 border border-purple-200 rounded-lg",children:Dh.jsxs("div",{className:"text-xs text-purple-700",children:[Dh.jsx("div",{className:"font-medium mb-1",children:"📱 Mobile Payment"}),Dh.jsx("div",{children:"Your selected wallet app will open with payment details pre-filled"})]})}),bO&&Dh.jsxs("div",{className:"mt-4",children:[Dh.jsxs("button",{onClick:()=>m(!p),className:"w-full text-xs py-2 px-3 bg-gray-100 text-gray-600 rounded-lg hover:bg-gray-200 transition-colors",children:[p?"🔽 Hide Debug Info":"🔧 Show Debug Info"," (",h.length," logs)"]}),p&&Dh.jsxs("div",{className:"mt-2 p-3 bg-gray-900 text-green-400 rounded-lg text-xs font-mono max-h-80 overflow-y-auto",children:[Dh.jsx("div",{className:"text-white mb-2 font-bold",children:"📱 Mobile Debug Panel"}),0===h.length?Dh.jsx("div",{className:"text-gray-400",children:"No debug logs yet. Try selecting a wallet..."}):h.map(e=>Dh.jsxs("div",{className:"mb-3 pb-2 border-b border-gray-700",children:[Dh.jsxs("div",{className:"flex items-center justify-between mb-1",children:[Dh.jsx("span",{className:"px-2 py-1 rounded text-xs font-bold "+("error"===e.type?"bg-red-600 text-white":"success"===e.type?"bg-green-600 text-white":"debug"===e.type?"bg-blue-600 text-white":"bg-gray-600 text-white"),children:e.type.toUpperCase()}),Dh.jsx("span",{className:"text-gray-400",children:e.timestamp})]}),Dh.jsx("div",{className:"text-yellow-300 mb-1",children:e.message}),e.data&&Dh.jsx("div",{className:"text-gray-300 text-xs",children:Dh.jsxs("details",{children:[Dh.jsx("summary",{className:"cursor-pointer text-blue-300 hover:text-blue-200",children:"📊 Data"}),Dh.jsx("pre",{className:"mt-1 p-2 bg-gray-800 rounded overflow-x-auto whitespace-pre-wrap",children:JSON.stringify(e.data,null,2)})]})})]},e.id)),Dh.jsx("button",{onClick:()=>f([]),className:"mt-2 px-3 py-1 bg-red-600 text-white rounded text-xs hover:bg-red-700",children:"Clear Logs"})]})]})]}):Dh.jsx("div",{className:"p-4 bg-amber-50 rounded-lg border border-amber-200",children:Dh.jsxs("div",{className:"text-center",children:[Dh.jsx("div",{className:"text-amber-800 font-medium mb-2",children:"⏳ Preparing Payment..."}),Dh.jsx("div",{className:"text-sm text-amber-700",children:"Payment is being prepared. Please wait a moment..."}),Dh.jsx("div",{className:"mt-3",children:Dh.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-amber-600 border-t-transparent mx-auto"})})]})})})},wO=({error:e,onRetry:t,onDismiss:n,context:r="payment",className:i=""})=>{if(!e)return null;const o=EP(e),s=(e=>{switch(e){case"user_rejected":return"info";case"insufficient_funds":case"wrong_network":case"wallet_disconnected":case"payment_pending":return"warning";case"network_error":case"gas_error":case"rate_limited":return"error";default:return"critical"}})(o.type),a=(e=>{switch(e){case"user_rejected":default:return"Try Again";case"insufficient_funds":return"Add Funds & Retry";case"wrong_network":return"Switch Network & Retry";case"wallet_disconnected":return"Reconnect Wallet";case"payment_pending":return"Check Again";case"network_error":case"rate_limited":return"Retry";case"popup_blocked":return"Allow Popups & Retry";case"mobile_wallet_error":return"Open Wallet App"}})(o.type),c={info:{container:"bg-blue-50 border-blue-200",title:"text-blue-800",message:"text-blue-700",icon:"ℹ️",button:"bg-blue-600 hover:bg-blue-700"},warning:{container:"bg-amber-50 border-amber-200",title:"text-amber-800",message:"text-amber-700",icon:"⚠️",button:"bg-amber-600 hover:bg-amber-700"},error:{container:"bg-red-50 border-red-200",title:"text-red-800",message:"text-red-700",icon:"❌",button:"bg-red-600 hover:bg-red-700"},critical:{container:"bg-red-50 border-red-300",title:"text-red-900",message:"text-red-800",icon:"🚨",button:"bg-red-700 hover:bg-red-800"}},l=c[s]||c.error;return Dh.jsxs("div",{className:`p-4 border rounded-lg ${l.container} ${i}`,children:[Dh.jsxs("div",{className:"flex items-start space-x-3",children:[Dh.jsx("div",{className:"flex-shrink-0 text-xl",children:l.icon}),Dh.jsxs("div",{className:"flex-1 min-w-0",children:[Dh.jsx("div",{className:`font-semibold ${l.title} mb-1`,children:o.title}),Dh.jsx("div",{className:`text-sm ${l.message} mb-2`,children:o.message}),o.suggestion&&Dh.jsxs("div",{className:`text-xs ${l.message} opacity-90`,children:["💡 ",o.suggestion]})]}),n&&Dh.jsx("button",{onClick:n,className:"flex-shrink-0 text-gray-400 hover:text-gray-600 transition-colors","aria-label":"Dismiss error",children:Dh.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:Dh.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),t&&Dh.jsxs("div",{className:"mt-3 flex justify-end space-x-2",children:[n&&"info"===s&&Dh.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs text-gray-600 hover:text-gray-800 transition-colors",children:"Cancel"}),Dh.jsx("button",{onClick:t,className:`px-4 py-2 text-sm font-medium text-white rounded-md transition-colors ${l.button}`,children:a})]}),!1]})},EO="method",_O="confirm",xO="processing",kO="success",SO="wallet",CO="qr",IO="Bricolage Grotesque, sans-serif",AO=new AI,PO=({publicKey:e,apiKey:t,apiSecret:n,apiUrl:r,config:i,onSuccess:o,onError:s,onClose:a,isOpen:c,theme:l="light"})=>{const u=((e,t,n)=>{const[r,i]=yt.useState("method"),[o,s]=yt.useState([]),[a,c]=yt.useState([]),[l,u]=yt.useState(null),[d,h]=yt.useState(null),[f,p]=yt.useState(null),[m,g]=yt.useState(null),[y,b]=yt.useState(!1),[v,w]=yt.useState(""),[E,_]=yt.useState(!1),[x,k]=yt.useState("Processing transaction..."),[S,C]=yt.useState("wallet"),[I,A]=yt.useState(null),P=yt.useRef(new hP(e,t,n));return{currentStep:r,networks:o,tokens:a,selectedNetwork:l,selectedToken:d,paymentMethod:f,paymentData:m,loading:y,error:v,processing:E,processingMessage:x,paymentType:S,actualTransactionHash:I,setCurrentStep:i,setSelectedNetwork:u,setSelectedToken:h,setPaymentMethod:p,setError:w,setProcessing:_,setProcessingMessage:k,setPaymentType:C,setActualTransactionHash:A,loadData:async()=>{var e,t;try{b(!0),w("");const[n,r]=await Promise.all([P.current.getNetworks(),P.current.getTokens()]),i=(null==(e=n.networks)?void 0:e.reduce((e,t)=>{if("solana"===t.shortName||"tron"===t.shortName||"algorand"===t.shortName)return e;if(!t.chainId||null===t.chainId)return e;const n=`${t.chainId}-${t.shortName}`;return e.some(e=>`${e.chainId}-${e.shortName}`===n)||e.push(t),e},[]))||[],o=(null==(t=r.stablecoins)?void 0:t.reduce((e,t)=>{var n,r,i;if("USDC"!==t.symbol&&"USDT"!==t.symbol)return e;if("solana"===(null==(n=t.Network)?void 0:n.shortName)||"tron"===(null==(r=t.Network)?void 0:r.shortName)||"algorand"===(null==(i=t.Network)?void 0:i.shortName))return e;const o=`${t.symbol}-${t.networkId}`;return e.some(e=>`${e.symbol}-${e.networkId}`===o)||e.push(t),e},[]))||[];s(i),c(o)}catch(n){w("Failed to load payment options. Using fallback data.")}finally{b(!1)}},createPayment:async e=>{try{b(!0),w("");const t={amount:e.amount,currency:d.symbol,network:l.shortName,customerEmail:e.customerEmail,callbackUrl:e.callbackUrl,metadata:{...e.metadata,merchantWalletAddresses:e.merchantWalletAddresses,paymentMethod:f,selectedNetwork:l.shortName,selectedToken:d.symbol,wagmiEnabled:!0}},n=await P.current.createPayment(t);g(n.payment),i("confirm")}catch(t){w(t.message)}finally{b(!1)}},failPayment:async(e="Payment cancelled by user")=>{if(null==m?void 0:m.id)try{await P.current.failPayment(m.id,e)}catch(t){}},resetState:()=>{i("method"),u(null),h(null),p(null),g(null),w(""),_(!1),A(null),C("wallet")},resetTransactionState:()=>{w(""),_(!1),A(null),i("confirm")},api:P.current}})(r,e||t,e?null:n),d=gP(),[h,f]=yt.useState("metamask"),[p,m]=yt.useState(!1),[g,y]=yt.useState(()=>!("undefined"==typeof window||!window.sessionStorage)&&"true"===sessionStorage.getItem("coinley_mobile_payment_started")),[b,v]=yt.useState(!1);yt.useEffect(()=>{m(uO())},[]);const{currentStep:w,networks:E,tokens:_,selectedNetwork:x,selectedToken:k,paymentData:S,loading:C,error:I,paymentType:A,loadData:P,createPayment:M,failPayment:O,resetState:T,setSelectedNetwork:R,setSelectedToken:N,setPaymentType:L,setCurrentStep:B,setError:j}=u,{connectedWallet:D,address:U,connectWallet:F,handleWalletSelection:$}=d,z=SP(S,k,x,U,u.api,d),{executePaymentTransaction:H,processFinalPayment:q,transactionStep:W,transactionError:K,currentTransactionHash:G}=z;yt.useEffect(()=>{w===kO&&"undefined"!=typeof window&&window.sessionStorage&&sessionStorage.removeItem("coinley_mobile_payment_started")},[w]),yt.useEffect(()=>{if(c){P(),T();const e=window.scrollY;document.body.style.position="fixed",document.body.style.top=`-${e}px`,document.body.style.width="100%",document.body.style.overflow="hidden"}else{const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,-1*parseInt(e||"0"))}return()=>{if(c){const e=document.body.style.top;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflow="",window.scrollTo(0,-1*parseInt(e||"0"))}}},[c]),yt.useEffect(()=>{if("processing"===W||"approve"===W||"splitPayment"===W){const e=setTimeout(()=>{j("Transaction timed out. Please try again."),B(_O),z.resetTransaction()},12e4);return()=>clearTimeout(e)}},[W]);const V=async()=>{await O(),a()};return c?Dh.jsxs("div",{className:"fixed inset-0 z-50",children:[Dh.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:V,"aria-hidden":"true"}),Dh.jsx("div",{className:"fixed inset-0 flex items-center justify-center p-4",style:{zIndex:51},children:Dh.jsxs("div",{className:"relative pt-4 w-full max-w-md max-h-[90vh] mx-auto shadow-xl bg-gray-100 rounded-3xl flex flex-col overflow-hidden",style:{zIndex:52},children:[Dh.jsxs("div",{className:"flex-shrink-0 bg-white flex justify-between items-center mb-3 mr-3 ml-3 py-3 px-2 rounded-full",children:[Dh.jsxs("div",{className:"flex-1 flex items-center gap-2 px-4",children:[Dh.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center",children:Dh.jsx("img",{src:cP,alt:"Coinley"})}),Dh.jsx("span",{className:"text-base font-semibold text-gray-800",style:{fontFamily:IO},children:"Payment Details"})]}),w!==kO&&w!==xO&&Dh.jsx("button",{onClick:V,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:Dh.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Dh.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i&&w!==kO&&Dh.jsx("div",{className:"flex-shrink-0 mb-3 px-4",children:Dh.jsxs("div",{className:"text-center",children:[Dh.jsx("div",{className:"text-xs text-gray-600",children:"Total Amount"}),Dh.jsxs("div",{className:"text-3xl font-bold text-[#7042D2] mt-1 leading-tight tracking-tight",style:{fontFamily:IO},children:["$",(Z=i.amount,parseFloat(Z).toFixed(2))]}),Dh.jsx("div",{className:"mt-1 text-xs text-gray-500",children:"No additional fees"}),Dh.jsx("div",{className:"text-xs text-gray-600 mt-2",children:"Payment to:"}),Dh.jsxs("div",{className:"text-sm font-semibold mt-0.5 flex gap-1.5 items-center justify-center",style:{fontFamily:IO},children:[Dh.jsx("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Dh.jsx("path",{d:"M15.3 7.50065L15.8 10.0007H4.2L4.7 7.50065H15.3ZM16.6667 3.33398H3.33333V5.00065H16.6667V3.33398ZM16.6667 5.83398H3.33333L2.5 10.0007V11.6673H3.33333V16.6673H11.6667V11.6673H15V16.6673H16.6667V11.6673H17.5V10.0007L16.6667 5.83398ZM5 15.0007V11.6673H10V15.0007H5Z",fill:"#7042D2"})}),i.merchantName||"Merchant"]})]})}),Dh.jsxs("div",{className:"flex-1 overflow-y-auto overscroll-contain",children:[Dh.jsx(IP,{currentStep:w,targetStep:EO,children:Dh.jsxs("div",{className:"pb-4 pt-3 px-5 bg-white rounded-t-2xl",children:[Dh.jsx("h3",{className:"font-semibold text-center mb-3 text-sm",style:{fontFamily:IO},children:"Choose Payment Method"}),Dh.jsxs("div",{className:"space-y-3 mb-4",children:[Dh.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:IO},children:"Select Network"}),Dh.jsx(CP,{options:E,value:(null==x?void 0:x.id)||"",onChange:e=>{const t=E.find(t=>t.id===e);R(t),N(null)},placeholder:"Choose your network...",renderOption:e=>{var t,n;const r="object"==typeof(i=e)&&(null==i?void 0:i.logo)?i.logo:"object"==typeof i&&(null==i?void 0:i.shortName)?sO[i.shortName.toLowerCase()]:"string"==typeof i?sO[i.toLowerCase()]:null;var i;return Dh.jsxs("div",{className:"flex items-center space-x-3",children:[r?Dh.jsx("img",{src:r,alt:e.name,className:"w-8 h-8 rounded-full",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="flex"}}):null,Dh.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center",style:{display:r?"none":"flex"},children:Dh.jsx("span",{className:"text-xs font-bold text-gray-600",children:null==(t=e.shortName)?void 0:t.slice(0,2).toUpperCase()})}),Dh.jsxs("div",{children:[Dh.jsx("div",{className:"font-semibold text-gray-800",children:e.name}),Dh.jsx("div",{className:"text-sm text-gray-500",children:null==(n=e.shortName)?void 0:n.toUpperCase()})]})]})},getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.shortName}`,disabled:C})]}),x&&Dh.jsxs("div",{className:"space-y-3 mb-4",children:[Dh.jsx("label",{className:"block text-sm font-medium text-gray-700",style:{fontFamily:IO},children:"Select Token"}),Dh.jsx(CP,{options:_.filter(e=>{var t;return(null==(t=e.Network)?void 0:t.shortName)===(null==x?void 0:x.shortName)||e.networkId===(null==x?void 0:x.id)}),value:(null==k?void 0:k.id)||"",onChange:e=>{const t=_.filter(e=>{var t;return(null==(t=e.Network)?void 0:t.shortName)===(null==x?void 0:x.shortName)||e.networkId===(null==x?void 0:x.id)}).find(t=>t.id===e);N(t)},placeholder:"Choose your token...",renderOption:e=>{var t,n;const r=cO(e.symbol);return Dh.jsxs("div",{className:"flex items-center space-x-3",children:[r?Dh.jsx("img",{src:r,alt:e.symbol,className:"w-8 h-8 rounded-full",onError:e=>{e.target.style.display="none",e.target.nextSibling.style.display="flex"}}):null,Dh.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-200 flex items-center justify-center",style:{display:r?"none":"flex"},children:Dh.jsx("span",{className:"text-xs font-bold text-gray-600",children:null==(t=e.symbol)?void 0:t.slice(0,2)})}),Dh.jsxs("div",{children:[Dh.jsxs("div",{className:"font-semibold text-gray-800",children:[e.name," (",e.symbol,")"]}),Dh.jsxs("div",{className:"text-sm text-gray-500",children:[(null==(n=e.Network)?void 0:n.name)||"Unknown Network",e.isStablecoin&&Dh.jsx("span",{className:"ml-2 text-green-600",children:"• Stablecoin"})]})]})]})},getOptionKey:e=>e.id,getOptionValue:e=>e.id,getSearchableText:e=>`${e.name} ${e.symbol}`,disabled:C})]}),x&&k&&Dh.jsx("button",{onClick:()=>M(i),disabled:C,className:"w-full bg-[#7042D2] text-white py-4 px-4 rounded-xl hover:bg-[#5b34b1] disabled:opacity-50 font-semibold transition-all duration-200 shadow-lg hover:shadow-xl",style:{fontFamily:IO},children:C?"Creating Payment...":"Continue"})]})}),Dh.jsx(IP,{currentStep:w,targetStep:_O,children:x&&k&&S&&Dh.jsxs("div",{className:"pb-4 pt-4 px-4 bg-white rounded-t-2xl",children:[!p&&Dh.jsx("div",{className:"mb-4",children:Dh.jsxs("div",{className:"flex border-b border-gray-200",children:[Dh.jsx("button",{onClick:()=>L(SO),className:"py-3 px-6 text-sm font-semibold transition-all duration-200 "+(A===SO?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),style:{fontFamily:IO},children:"Connect Wallet"}),Dh.jsx("button",{onClick:()=>L(CO),className:"py-3 px-6 text-sm font-semibold transition-all duration-200 "+(A===CO?"border-b-2 border-[#7042D2] text-[#7042D2]":"text-gray-500 hover:text-gray-700"),style:{fontFamily:IO},children:"QR Code"})]})}),p?Dh.jsx(vO,{paymentData:S,selectedToken:k,selectedNetwork:x,config:i,onPaymentStarted:e=>{y(!0),"undefined"!=typeof window&&window.sessionStorage&&sessionStorage.setItem("coinley_mobile_payment_started","true"),e.walletName},onError:e=>{j(e)}}):A===SO?Dh.jsx(yO,{selectedNetwork:x,onWalletSelect:$,onConnect:async e=>{await F(e,x)},connectedWallet:D,loading:C}):null,A===CO&&Dh.jsxs(Dh.Fragment,{children:[Dh.jsxs("div",{className:"mb-2",children:[Dh.jsx("div",{className:"text-xs font-medium text-gray-600 mb-1.5 text-center",style:{fontFamily:IO},children:"Optimize QR for:"}),Dh.jsx("div",{className:"flex gap-1.5 justify-center flex-wrap",children:[{id:"metamask",name:"MetaMask",icon:"🦊"},{id:"trust",name:"Trust",icon:"🛡️"},{id:"coinbase",name:"Coinbase",icon:"💙"}].map(e=>Dh.jsxs("button",{onClick:()=>f(e.id),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-medium transition-all duration-200 "+(h===e.id?"bg-[#7042D2] text-white shadow-md":"bg-gray-100 text-gray-700 hover:bg-gray-200"),style:{fontFamily:IO},children:[Dh.jsx("span",{className:"text-sm",children:e.icon}),Dh.jsx("span",{children:e.name})]},e.id))})]}),Dh.jsx(gO,{amount:(null==S?void 0:S.totalAmount)||(null==S?void 0:S.amount)||(null==i?void 0:i.amount),currency:null==k?void 0:k.symbol,network:null==x?void 0:x.shortName,theme:l,paymentData:S,config:i,selectedToken:k,selectedNetwork:x,preferredWallet:h,compact:!0})]}),(I||K)&&Dh.jsx("div",{className:"mt-4",children:Dh.jsx(wO,{error:K||I,onRetry:()=>{j(""),z.resetTransaction(),"error"===W&&D&&H()},onDismiss:()=>{j(""),z.resetTransaction()},context:"payment"})}),Dh.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-4",children:[Dh.jsx("button",{type:"button",onClick:()=>B(EO),className:"w-full py-2.5 px-3 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-semibold rounded-xl transition-all duration-200 text-sm",style:{fontFamily:IO},children:"Back"}),Dh.jsx("button",{type:"button",onClick:async()=>{var e,t,n,r,i,s,a,c,l,d;if(p&&g){if(!(null==S?void 0:S.id))return void j("Payment ID not found. Please refresh and try again.");try{v(!0),B(xO),j("");const i=await u.api.checkPaymentStatus(S.id);if("completed"===(null==(e=i.payment)?void 0:e.status))B(kO),o&&o({paymentId:S.id,transactionHash:i.payment.transactionHash,paymentDetails:i.payment});else if("pending"===(null==(t=i.payment)?void 0:t.status)){const e=await u.api.verifyQRPayment(S.id);if(e.success&&e.verified)B(kO),o&&o({paymentId:S.id,transactionHash:null==(n=e.onChainData)?void 0:n.transactionHash,paymentDetails:e.payment});else{const t=e.message||"Payment not yet confirmed on blockchain";j(`${t}. Please complete the payment in your wallet and try again.`),B(_O)}}else"failed"===(null==(r=i.payment)?void 0:r.status)?(j("Payment failed. Please try creating a new payment."),B(_O)):(j("Payment not found. Please verify the payment ID and try again."),B(_O))}catch(h){j(`Verification failed: ${h.message}. Please ensure payment was completed and try again.`),B(_O)}finally{v(!1)}}else if(A!==CO){if(D&&U)try{B(xO),j("");const e=await H();e&&(j(""),z.setTransactionError(""),B(kO),o&&o({paymentId:S.id,transactionHash:e,paymentDetails:S}))}catch(h){B(_O),(null==(l=h.message)?void 0:l.includes("User rejected"))||(null==(d=h.message)?void 0:d.includes("User denied"))||4001===h.code||"ACTION_REJECTED"===h.code?j("Transaction was cancelled by user. Please try again."):j(h.message||"Transaction failed. Please try again."),z.resetTransaction()}}else{if(!(null==S?void 0:S.id))return void j("Payment ID not found. Please refresh and try again.");try{B(xO),j("");const e=await u.api.checkPaymentStatus(S.id);if("completed"===(null==(i=e.payment)?void 0:i.status))B(kO),o&&o({paymentId:S.id,transactionHash:e.payment.transactionHash,paymentDetails:e.payment});else if("pending"===(null==(s=e.payment)?void 0:s.status)){const e=await u.api.verifyQRPayment(S.id);if(e.success&&e.verified)B(kO),o&&o({paymentId:S.id,transactionHash:null==(a=e.onChainData)?void 0:a.transactionHash,paymentDetails:e.payment});else{const t=e.message||"Payment not yet confirmed on blockchain";j(`${t}. Please complete the payment and try again.`),B(_O)}}else"failed"===(null==(c=e.payment)?void 0:c.status)?(j("Payment failed. Please try creating a new payment."),B(_O)):(j("Payment not found. Please verify the payment ID and try again."),B(_O))}catch(h){j(`Verification failed: ${h.message}. Please ensure payment was completed and try again.`),B(_O)}}},className:"bg-green-600 text-white w-full py-2.5 px-3 font-semibold rounded-xl hover:bg-green-700 transition-all duration-200 shadow-lg hover:shadow-xl disabled:opacity-50 text-sm",disabled:A===SO&&!D&&!p||p&&!g||"processing"===W||b,style:{fontFamily:IO},children:b?"Verifying...":"processing"===W?"Processing...":p&&g?"I Have Paid":p?"Select Wallet":A===CO?"I Have Paid":"Pay Now"})]})]})}),Dh.jsx(IP,{currentStep:w,targetStep:xO,children:Dh.jsx(AP,{status:"processing",message:"approve"===W?"Approving token spending...":"splitPayment"===W?"Processing payment split...":G?"Confirming transaction on blockchain...":"Processing your payment...",theme:l,transactionHash:G,selectedNetwork:x})}),Dh.jsx(IP,{currentStep:w,targetStep:kO,children:Dh.jsx(AP,{status:"success",message:"Payment completed successfully!",theme:l,payment:S,transactionHash:G||(null==S?void 0:S.transactionHash),selectedPaymentMethod:k,selectedNetwork:x,merchantName:(null==i?void 0:i.merchantName)||"Merchant",onClose:a})}),(I||K)&&Dh.jsxs("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg mx-6 mb-4",children:[Dh.jsx("p",{className:"text-red-800 text-sm",children:I||K}),Dh.jsx("button",{onClick:()=>{j(""),z.setTransactionError("")},className:"mt-2 text-red-600 hover:text-red-800 text-xs underline",children:"Dismiss"})]})]}),w!==kO&&Dh.jsxs("div",{className:"text-center text-xs text-gray-500 flex items-center justify-center gap-1 py-6 bg-white rounded-b-3xl",style:{fontFamily:IO},children:[Dh.jsxs("p",{children:["Powered by ",Dh.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Coinley"})," - Multi-Wallet Support"]}),Dh.jsxs("svg",{className:"inline w-4 h-4 text-green-500 ml-1",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[Dh.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none"}),Dh.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})})]}):null;var Z},MO=e=>Dh.jsx(tC,{config:dP,children:Dh.jsx(DI,{client:AO,children:Dh.jsx(PO,{...e})})});class OO{constructor(e={}){if(!e.publicKey&&!e.apiKey)throw new Error("CoinleyVanilla: publicKey or apiKey is required");if(!e.publicKey&&!e.apiSecret)throw new Error("CoinleyVanilla: apiSecret is required when using apiKey");if(!e.apiUrl)throw new Error("CoinleyVanilla: apiUrl is required");this.config={publicKey:e.publicKey||null,apiKey:e.apiKey||null,apiSecret:e.apiSecret||null,apiUrl:e.apiUrl.replace(/\/$/,""),theme:e.theme||"light",debug:e.debug||!1,...e},this.isOpen=!1,this.root=null,this.container=null,this.callbacks={},this.currentPayment=null,this.config.debug}open(e,t={}){if(!this.isOpen)try{this._validatePaymentConfig(e),this.callbacks=t,this.currentPayment=e,this._createContainer(),this.root=Ih(this.container),this.isOpen=!0,this.root.render(bt.createElement(MO,{publicKey:this.config.publicKey,apiKey:this.config.apiKey,apiSecret:this.config.apiSecret,apiUrl:this.config.apiUrl,isOpen:!0,theme:this.config.theme,config:{amount:e.amount,customerEmail:e.customerEmail,merchantName:e.merchantName||"Merchant",callbackUrl:e.callbackUrl||this._getDefaultCallbackUrl(),merchantWalletAddresses:e.merchantWalletAddresses||{},preferredNetwork:e.preferredNetwork,preferredCurrency:e.preferredCurrency,metadata:{...e.metadata,source:"vanilla-sdk",sdkVersion:"2.0.0",timestamp:(new Date).toISOString()}},onSuccess:this._handleSuccess.bind(this),onError:this._handleError.bind(this),onClose:this._handleClose.bind(this)})),this.config.debug}catch(n){t.onError&&t.onError(n.message||"Failed to open payment modal")}}close(){this.isOpen&&(this._cleanup(),this.config.debug)}isPaymentOpen(){return this.isOpen}updateConfig(e){this.config={...this.config,...e},this.config.debug}getConfig(){return{...this.config}}getCurrentPayment(){return this.currentPayment?{...this.currentPayment}:null}_validatePaymentConfig(e){if(!e)throw new Error("Payment configuration is required");if(!e.amount||"number"!=typeof e.amount||e.amount<=0)throw new Error("Valid amount (number > 0) is required");if(!e.customerEmail||"string"!=typeof e.customerEmail)throw new Error("Customer email is required");if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.customerEmail))throw new Error("Invalid email format");if(e.merchantWalletAddresses){if("object"!=typeof e.merchantWalletAddresses)throw new Error("merchantWalletAddresses must be an object");Object.keys(e.merchantWalletAddresses).length}}_createContainer(){this.container||(this.container=document.createElement("div"),this.container.id="coinley-payment-container",this.container.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 999999;\n ",document.body.appendChild(this.container))}_getDefaultCallbackUrl(){return"undefined"!=typeof window?`${window.location.origin}/api/webhooks/coinley`:""}_handleSuccess(e,t,n){this.config.debug,this.callbacks.onSuccess&&this.callbacks.onSuccess(e,t,n)}_handleError(e){this.config.debug,this.callbacks.onError&&this.callbacks.onError(e)}_handleClose(){this._cleanup(),this.callbacks.onClose&&this.callbacks.onClose()}_cleanup(){if(this.isOpen=!1,this.root){try{this.root.unmount()}catch(e){}this.root=null}this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null),this.currentPayment=null}}function TO(){document.querySelectorAll('script[src*="coinley-vanilla"]').forEach(e=>{const t=e.getAttribute("data-public-key"),n=e.getAttribute("data-api-key"),r=e.getAttribute("data-api-secret"),i=e.getAttribute("data-api-url"),o=e.getAttribute("data-theme")||"light",s=e.hasAttribute("data-debug");if((t||n&&r)&&i)try{window.coinley=new OO({publicKey:t,apiKey:n,apiSecret:r,apiUrl:i,theme:o,debug:s})}catch(a){}})}function RO(e,t){let n;try{n=e()}catch(r){return}return{getItem:e=>{var t;const r=e=>null===e?null:JSON.parse(e,void 0),i=null!=(t=n.getItem(e))?t:null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,t)=>n.setItem(e,JSON.stringify(t,void 0)),removeItem:e=>n.removeItem(e)}}"undefined"!=typeof window&&(window.CoinleyVanilla=OO,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",TO):TO());const NO=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then:e=>NO(e)(n),catch(e){return this}}}catch(n){return{then(e){return this},catch:e=>NO(e)(n)}}},LO=(e,t)=>(n,r,i)=>{let o={storage:RO(()=>localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},s=!1;const a=new Set,c=new Set;let l=o.storage;if(!l)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...e)},r,i);const u=()=>{const e=o.partialize({...r()});return l.setItem(o.name,{state:e,version:o.version})},d=i.setState;i.setState=(e,t)=>{d(e,t),u()};const h=e((...e)=>{n(...e),u()},r,i);let f;i.getInitialState=()=>h;const p=()=>{var e,t;if(!l)return;s=!1,a.forEach(e=>{var t;return e(null!=(t=r())?t:h)});const i=(null==(t=o.onRehydrateStorage)?void 0:t.call(o,null!=(e=r())?e:h))||void 0;return NO(l.getItem.bind(l))(o.name).then(e=>{if(e){if("number"!=typeof e.version||e.version===o.version)return[!1,e.state];if(o.migrate){const t=o.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(e=>{var t;const[i,s]=e;if(f=o.merge(s,null!=(t=r())?t:h),n(f,!0),i)return u()}).then(()=>{null==i||i(f,void 0),f=r(),s=!0,c.forEach(e=>e(f))}).catch(e=>{null==i||i(void 0,e)})};return i.persist={setOptions:e=>{o={...o,...e},e.storage&&(l=e.storage)},clearStorage:()=>{null==l||l.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>p(),hasHydrated:()=>s,onHydrate:e=>(a.add(e),()=>{a.delete(e)}),onFinishHydration:e=>(c.add(e),()=>{c.delete(e)})},o.skipHydration||p(),f||h},BO=e=>{let t;const n=new Set,r=(e,r)=>{const i="function"==typeof e?e(t):e;if(!Object.is(i,t)){const e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>s,subscribe:e=>(n.add(e),()=>n.delete(e))},s=t=e(r,i,o);return o},jO=e=>e?BO(e):BO;var DO,UO,FO,$O,zO,HO,qO,WO,KO,GO,VO,ZO,YO={},JO=[],QO=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,XO=Array.isArray;function eT(e,t){for(var n in t)e[n]=t[n];return e}function tT(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function nT(e,t,n){var r,i,o,s={};for(o in t)"key"==o?r=t[o]:"ref"==o?i=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?DO.call(arguments,2):n),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===s[o]&&(s[o]=e.defaultProps[o]);return rT(e,s,r,i,null)}function rT(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==i?++FO:i,__i:-1,__u:0};return null==i&&null!=UO.vnode&&UO.vnode(o),o}function iT(e){return e.children}function oT(e,t){this.props=e,this.context=t}function sT(e,t){if(null==t)return e.__?sT(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?sT(e):null}function aT(e){var t,n;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e){e.__e=e.__c.base=n.__e;break}return aT(e)}}function cT(e){(!e.__d&&(e.__d=!0)&&zO.push(e)&&!lT.__r++||HO!==UO.debounceRendering)&&((HO=UO.debounceRendering)||qO)(lT)}function lT(){var e,t,n,r,i,o,s,a;for(zO.sort(WO);e=zO.shift();)e.__d&&(t=zO.length,r=void 0,o=(i=(n=e).__v).__e,s=[],a=[],n.__P&&((r=eT({},i)).__v=i.__v+1,UO.vnode&&UO.vnode(r),gT(n.__P,r,i,n.__n,n.__P.namespaceURI,32&i.__u?[o]:null,s,null==o?sT(i):o,!!(32&i.__u),a),r.__v=i.__v,r.__.__k[r.__i]=r,yT(s,r,a),r.__e!=o&&aT(r)),zO.length>t&&zO.sort(WO));lT.__r=0}function uT(e,t,n,r,i,o,s,a,c,l,u){var d,h,f,p,m,g=r&&r.__k||JO,y=t.length;for(n.__d=c,function(e,t,n){var r,i,o,s,a,c=t.length,l=n.length,u=l,d=0;for(e.__k=[],r=0;r<c;r++)null!=(i=t[r])&&"boolean"!=typeof i&&"function"!=typeof i?(s=r+d,(i=e.__k[r]="string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?rT(null,i,null,null,null):XO(i)?rT(iT,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?rT(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=e,i.__b=e.__b+1,o=null,-1!==(a=i.__i=hT(i,n,s,u))&&(u--,(o=n[a])&&(o.__u|=131072)),null==o||null===o.__v?(-1==a&&d--,"function"!=typeof i.type&&(i.__u|=65536)):a!==s&&(a==s-1?d--:a==s+1?d++:(a>s?d--:d++,i.__u|=65536))):i=e.__k[r]=null;if(u)for(r=0;r<l;r++)null!=(o=n[r])&&!(131072&o.__u)&&(o.__e==e.__d&&(e.__d=sT(o)),vT(o,o))}(n,t,g),c=n.__d,d=0;d<y;d++)null!=(f=n.__k[d])&&(h=-1===f.__i?YO:g[f.__i]||YO,f.__i=d,gT(e,f,h,i,o,s,a,c,l,u),p=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&bT(h.ref,null,f),u.push(f.ref,f.__c||p,f)),null==m&&null!=p&&(m=p),65536&f.__u||h.__k===f.__k?c=dT(f,c,e):"function"==typeof f.type&&void 0!==f.__d?c=f.__d:p&&(c=p.nextSibling),f.__d=void 0,f.__u&=-196609);n.__d=c,n.__e=m}function dT(e,t,n){var r,i;if("function"==typeof e.type){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=dT(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!n.contains(t)&&(t=sT(e)),n.insertBefore(e.__e,t||null),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8===t.nodeType);return t}function hT(e,t,n,r){var i=e.key,o=e.type,s=n-1,a=n+1,c=t[n];if(null===c||c&&i==c.key&&o===c.type&&!(131072&c.__u))return n;if(r>(null==c||131072&c.__u?0:1))for(;s>=0||a<t.length;){if(s>=0){if((c=t[s])&&!(131072&c.__u)&&i==c.key&&o===c.type)return s;s--}if(a<t.length){if((c=t[a])&&!(131072&c.__u)&&i==c.key&&o===c.type)return a;a++}}return-1}function fT(e,t,n){"-"===t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||QO.test(t)?n:n+"px"}function pT(e,t,n,r,i){var o;e:if("style"===t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof r&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||fT(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||fT(e.style,t,n[t])}else if("o"===t[0]&&"n"===t[1])o=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e||"onFocusOut"===t||"onFocusIn"===t?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n.u=r.u:(n.u=KO,e.addEventListener(t,o?VO:GO,o)):e.removeEventListener(t,o?VO:GO,o);else{if("http://www.w3.org/2000/svg"==i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(s){}"function"==typeof n||(null==n||!1===n&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function mT(e){return function(t){if(this.l){var n=this.l[t.type+e];if(null==t.t)t.t=KO++;else if(t.t<n.u)return;return n(UO.event?UO.event(t):t)}}}function gT(e,t,n,r,i,o,s,a,c,l){var u,d,h,f,p,m,g,y,b,v,w,E,_,x,k,S,C=t.type;if(void 0!==t.constructor)return null;128&n.__u&&(c=!!(32&n.__u),o=[a=t.__e=n.__e]),(u=UO.__b)&&u(t);e:if("function"==typeof C)try{if(y=t.props,b="prototype"in C&&C.prototype.render,v=(u=C.contextType)&&r[u.__c],w=u?v?v.props.value:u.__:r,n.__c?g=(d=t.__c=n.__c).__=d.__E:(b?t.__c=d=new C(y,w):(t.__c=d=new oT(y,w),d.constructor=C,d.render=wT),v&&v.sub(d),d.props=y,d.state||(d.state={}),d.context=w,d.__n=r,h=d.__d=!0,d.__h=[],d._sb=[]),b&&null==d.__s&&(d.__s=d.state),b&&null!=C.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=eT({},d.__s)),eT(d.__s,C.getDerivedStateFromProps(y,d.__s))),f=d.props,p=d.state,d.__v=t,h)b&&null==C.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),b&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(b&&null==C.getDerivedStateFromProps&&y!==f&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(y,w),!d.__e&&(null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(y,d.__s,w)||t.__v===n.__v)){for(t.__v!==n.__v&&(d.props=y,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),E=0;E<d._sb.length;E++)d.__h.push(d._sb[E]);d._sb=[],d.__h.length&&s.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(y,d.__s,w),b&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(f,p,m)})}if(d.context=w,d.props=y,d.__P=e,d.__e=!1,_=UO.__r,x=0,b){for(d.state=d.__s,d.__d=!1,_&&_(t),u=d.render(d.props,d.state,d.context),k=0;k<d._sb.length;k++)d.__h.push(d._sb[k]);d._sb=[]}else do{d.__d=!1,_&&_(t),u=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++x<25);d.state=d.__s,null!=d.getChildContext&&(r=eT(eT({},r),d.getChildContext())),b&&!h&&null!=d.getSnapshotBeforeUpdate&&(m=d.getSnapshotBeforeUpdate(f,p)),uT(e,XO(S=null!=u&&u.type===iT&&null==u.key?u.props.children:u)?S:[S],t,n,r,i,o,s,a,c,l),d.base=t.__e,t.__u&=-161,d.__h.length&&s.push(d),g&&(d.__E=d.__=null)}catch(I){if(t.__v=null,c||null!=o){for(t.__u|=c?160:32;a&&8===a.nodeType&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,t.__e=a}else t.__e=n.__e,t.__k=n.__k;UO.__e(I,t,n)}else null==o&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=function(e,t,n,r,i,o,s,a,c){var l,u,d,h,f,p,m,g=n.props,y=t.props,b=t.type;if("svg"===b?i="http://www.w3.org/2000/svg":"math"===b?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=o)for(l=0;l<o.length;l++)if((f=o[l])&&"setAttribute"in f==!!b&&(b?f.localName===b:3===f.nodeType)){e=f,o[l]=null;break}if(null==e){if(null===b)return document.createTextNode(y);e=document.createElementNS(i,b,y.is&&y),a&&(UO.__m&&UO.__m(t,o),a=!1),o=null}if(null===b)g===y||a&&e.data===y||(e.data=y);else{if(o=o&&DO.call(e.childNodes),g=n.props||YO,!a&&null!=o)for(g={},l=0;l<e.attributes.length;l++)g[(f=e.attributes[l]).name]=f.value;for(l in g)if(f=g[l],"children"==l);else if("dangerouslySetInnerHTML"==l)d=f;else if(!(l in y)){if("value"==l&&"defaultValue"in y||"checked"==l&&"defaultChecked"in y)continue;pT(e,l,null,f,i)}for(l in y)f=y[l],"children"==l?h=f:"dangerouslySetInnerHTML"==l?u=f:"value"==l?p=f:"checked"==l?m=f:a&&"function"!=typeof f||g[l]===f||pT(e,l,f,g[l],i);if(u)a||d&&(u.__html===d.__html||u.__html===e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),uT(e,XO(h)?h:[h],t,n,r,"foreignObject"===b?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&sT(n,0),a,c),null!=o)for(l=o.length;l--;)tT(o[l]);a||(l="value","progress"===b&&null==p?e.removeAttribute("value"):void 0!==p&&(p!==e[l]||"progress"===b&&!p||"option"===b&&p!==g[l])&&pT(e,l,p,g[l],i),l="checked",void 0!==m&&m!==e[l]&&pT(e,l,m,g[l],i))}return e}(n.__e,t,n,r,i,o,s,c,l);(u=UO.diffed)&&u(t)}function yT(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)bT(n[r],n[++r],n[++r]);UO.__c&&UO.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(n){UO.__e(n,t.__v)}})}function bT(e,t,n){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==t||(e.__u=e(t))}else e.current=t}catch(i){UO.__e(i,n)}}function vT(e,t,n){var r,i;if(UO.unmount&&UO.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||bT(r,null,t)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){UO.__e(o,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&vT(r[i],t,n||"function"!=typeof e.type);n||tT(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function wT(e,t,n){return this.constructor(e,n)}function ET(e,t,n){var r,i,o,s;UO.__&&UO.__(e,t),i=(r="function"==typeof n)?null:n&&n.__k||t.__k,o=[],s=[],gT(t,e=(!r&&n||t).__k=nT(iT,null,[e]),i||YO,YO,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?DO.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,s),yT(o,e,s)}DO=JO.slice,UO={__e:function(e,t,n,r){for(var i,o,s;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(e)),s=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e,r||{}),s=i.__d),s)return i.__E=i}catch(a){e=a}throw e}},FO=0,$O=function(e){return null!=e&&null==e.constructor},oT.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=eT({},this.state),"function"==typeof e&&(e=e(eT({},n),this.props)),e&&eT(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),cT(this))},oT.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),cT(this))},oT.prototype.render=iT,zO=[],qO="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,WO=function(e,t){return e.__v.__b-t.__v.__b},lT.__r=0,KO=0,GO=mT(!1),VO=mT(!0),ZO=0;const _T=Object.freeze(Object.defineProperty({__proto__:null,Component:oT,Fragment:iT,cloneElement:function(e,t,n){var r,i,o,s,a=eT({},e.props);for(o in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)"key"==o?r=t[o]:"ref"==o?i=t[o]:a[o]=void 0===t[o]&&void 0!==s?s[o]:t[o];return arguments.length>2&&(a.children=arguments.length>3?DO.call(arguments,2):n),rT(e.type,a,r||e.key,i||e.ref,null)},createContext:function(e,t){var n={__c:t="__cC"+ZO++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var n,r;return this.getChildContext||(n=[],(r={})[t]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&n.some(function(e){e.__e=!0,cT(e)})},this.sub=function(e){n.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.splice(n.indexOf(e),1),t&&t.call(e)}}),e.children}};return n.Provider.__=n.Consumer.contextType=n},createElement:nT,createRef:function(){return{current:null}},h:nT,hydrate:function e(t,n){ET(t,n,e)},get isValidElement(){return $O},get options(){return UO},render:ET,toChildArray:function e(t,n){return n=n||[],null==t||"boolean"==typeof t||(XO(t)?t.some(function(t){e(t,n)}):n.push(t)),n}},Symbol.toStringTag,{value:"Module"}));function xT(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=xT(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function kT(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=xT(e))&&(r&&(r+=" "),r+=t);return r}const ST=Object.freeze(Object.defineProperty({__proto__:null,clsx:kT,default:kT},Symbol.toStringTag,{value:"Module"}));var CT,IT,AT,PT,MT=0,OT=[],TT=UO,RT=TT.__b,NT=TT.__r,LT=TT.diffed,BT=TT.__c,jT=TT.unmount,DT=TT.__;function UT(e,t){TT.__h&&TT.__h(IT,e,MT||t),MT=0;var n=IT.__H||(IT.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function FT(e){return MT=1,$T(JT,e)}function $T(e,t,n){var r=UT(CT++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):JT(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=IT,!IT.u)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!o||o.call(this,e,t,n);var s=!1;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(s=!0)}}),!(!s&&r.__c.props===e)&&(!o||o.call(this,e,t,n))};IT.u=!0;var o=IT.shouldComponentUpdate,s=IT.componentWillUpdate;IT.componentWillUpdate=function(e,t,n){if(this.__e){var r=o;o=void 0,i(e,t,n),o=r}s&&s.call(this,e,t,n)},IT.shouldComponentUpdate=i}return r.__N||r.__}function zT(e,t){var n=UT(CT++,3);!TT.__s&&YT(n.__H,t)&&(n.__=e,n.i=t,IT.__H.__h.push(n))}function HT(e,t){var n=UT(CT++,4);!TT.__s&&YT(n.__H,t)&&(n.__=e,n.i=t,IT.__h.push(n))}function qT(e,t){var n=UT(CT++,7);return YT(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function WT(){for(var e;e=OT.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(VT),e.__H.__h.forEach(ZT),e.__H.__h=[]}catch(Gle){e.__H.__h=[],TT.__e(Gle,e.__v)}}TT.__b=function(e){IT=null,RT&&RT(e)},TT.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),DT&&DT(e,t)},TT.__r=function(e){NT&&NT(e),CT=0;var t=(IT=e.__c).__H;t&&(AT===IT?(t.__h=[],IT.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.i=e.__N=void 0})):(t.__h.forEach(VT),t.__h.forEach(ZT),t.__h=[],CT=0)),AT=IT},TT.diffed=function(e){LT&&LT(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==OT.push(t)&&PT===TT.requestAnimationFrame||((PT=TT.requestAnimationFrame)||GT)(WT)),t.__H.__.forEach(function(e){e.i&&(e.__H=e.i),e.i=void 0})),AT=IT=null},TT.__c=function(e,t){t.some(function(e){try{e.__h.forEach(VT),e.__h=e.__h.filter(function(e){return!e.__||ZT(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],TT.__e(n,e.__v)}}),BT&&BT(e,t)},TT.unmount=function(e){jT&&jT(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{VT(e)}catch(n){t=n}}),n.__H=void 0,t&&TT.__e(t,n.__v))};var KT="function"==typeof requestAnimationFrame;function GT(e){var t,n=function(){clearTimeout(r),KT&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);KT&&(t=requestAnimationFrame(n))}function VT(e){var t=IT,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),IT=t}function ZT(e){var t=IT;e.__c=e.__(),IT=t}function YT(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function JT(e,t){return"function"==typeof t?t(e):t}const QT=Object.freeze(Object.defineProperty({__proto__:null,useCallback:function(e,t){return MT=8,qT(function(){return e},t)},useContext:function(e){var t=IT.context[e.__c],n=UT(CT++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(IT)),t.props.value):e.__},useDebugValue:function(e,t){TT.useDebugValue&&TT.useDebugValue(t?t(e):e)},useEffect:zT,useErrorBoundary:function(e){var t=UT(CT++,10),n=FT();return t.__=e,IT.componentDidCatch||(IT.componentDidCatch=function(e,r){t.__&&t.__(e,r),n[1](e)}),[n[0],function(){n[1](void 0)}]},useId:function(){var e=UT(CT++,11);if(!e.__){for(var t=IT.__v;null!==t&&!t.__m&&null!==t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__},useImperativeHandle:function(e,t,n){MT=6,HT(function(){return"function"==typeof e?(e(t()),function(){return e(null)}):e?(e.current=t(),function(){return e.current=null}):void 0},null==n?n:n.concat(e))},useLayoutEffect:HT,useMemo:qT,useReducer:$T,useRef:function(e){return MT=5,qT(function(){return{current:e}},[])},useState:FT},Symbol.toStringTag,{value:"Module"})),XT=[{inputs:[{name:"preOpGas",type:"uint256"},{name:"paid",type:"uint256"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"targetSuccess",type:"bool"},{name:"targetResult",type:"bytes"}],name:"ExecutionResult",type:"error"},{inputs:[{name:"opIndex",type:"uint256"},{name:"reason",type:"string"}],name:"FailedOp",type:"error"},{inputs:[{name:"sender",type:"address"}],name:"SenderAddressResult",type:"error"},{inputs:[{name:"aggregator",type:"address"}],name:"SignatureValidationFailed",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"}],name:"ValidationResult",type:"error"},{inputs:[{components:[{name:"preOpGas",type:"uint256"},{name:"prefund",type:"uint256"},{name:"sigFailed",type:"bool"},{name:"validAfter",type:"uint48"},{name:"validUntil",type:"uint48"},{name:"paymasterContext",type:"bytes"}],name:"returnInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"senderInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"factoryInfo",type:"tuple"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"paymasterInfo",type:"tuple"},{components:[{name:"aggregator",type:"address"},{components:[{name:"stake",type:"uint256"},{name:"unstakeDelaySec",type:"uint256"}],name:"stakeInfo",type:"tuple"}],name:"aggregatorInfo",type:"tuple"}],name:"ValidationResultWithAggregation",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"factory",type:"address"},{indexed:!1,name:"paymaster",type:"address"}],name:"AccountDeployed",type:"event"},{anonymous:!1,inputs:[],name:"BeforeExecution",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalDeposit",type:"uint256"}],name:"Deposited",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"aggregator",type:"address"}],name:"SignatureAggregatorChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"totalStaked",type:"uint256"},{indexed:!1,name:"unstakeDelaySec",type:"uint256"}],name:"StakeLocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawTime",type:"uint256"}],name:"StakeUnlocked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"StakeWithdrawn",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!0,name:"paymaster",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"success",type:"bool"},{indexed:!1,name:"actualGasCost",type:"uint256"},{indexed:!1,name:"actualGasUsed",type:"uint256"}],name:"UserOperationEvent",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"userOpHash",type:"bytes32"},{indexed:!0,name:"sender",type:"address"},{indexed:!1,name:"nonce",type:"uint256"},{indexed:!1,name:"revertReason",type:"bytes"}],name:"UserOperationRevertReason",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"account",type:"address"},{indexed:!1,name:"withdrawAddress",type:"address"},{indexed:!1,name:"amount",type:"uint256"}],name:"Withdrawn",type:"event"},{inputs:[],name:"SIG_VALIDATION_FAILED",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"},{name:"sender",type:"address"},{name:"paymasterAndData",type:"bytes"}],name:"_validateSenderAndPaymaster",outputs:[],stateMutability:"view",type:"function"},{inputs:[{name:"unstakeDelaySec",type:"uint32"}],name:"addStake",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"depositTo",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"",type:"address"}],name:"deposits",outputs:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"getDepositInfo",outputs:[{components:[{name:"deposit",type:"uint112"},{name:"staked",type:"bool"},{name:"stake",type:"uint112"},{name:"unstakeDelaySec",type:"uint32"},{name:"withdrawTime",type:"uint48"}],name:"info",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{name:"sender",type:"address"},{name:"key",type:"uint192"}],name:"getNonce",outputs:[{name:"nonce",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"initCode",type:"bytes"}],name:"getSenderAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOps",type:"tuple[]"},{name:"aggregator",type:"address"},{name:"signature",type:"bytes"}],name:"opsPerAggregator",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleAggregatedOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"ops",type:"tuple[]"},{name:"beneficiary",type:"address"}],name:"handleOps",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"key",type:"uint192"}],name:"incrementNonce",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"callData",type:"bytes"},{components:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"paymaster",type:"address"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"}],name:"mUserOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"prefund",type:"uint256"},{name:"contextOffset",type:"uint256"},{name:"preOpGas",type:"uint256"}],name:"opInfo",type:"tuple"},{name:"context",type:"bytes"}],name:"innerHandleOp",outputs:[{name:"actualGasCost",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"",type:"address"},{name:"",type:"uint192"}],name:"nonceSequenceNumber",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"op",type:"tuple"},{name:"target",type:"address"},{name:"targetCallData",type:"bytes"}],name:"simulateHandleOp",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"simulateValidation",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unlockStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"}],name:"withdrawStake",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"withdrawAddress",type:"address"},{name:"withdrawAmount",type:"uint256"}],name:"withdrawTo",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}];function eR(e){const{authorization:t,factory:n,factoryData:r}=e;if("0x7702"===n||"0x7702000000000000000000000000000000000000"===n){if(!t)return"0x7702000000000000000000000000000000000000";return rm([t.address,r??"0x"])}return n?rm([n,r??"0x"]):"0x"}function tR(e){const{callGasLimit:t,callData:n,maxPriorityFeePerGas:r,maxFeePerGas:i,paymaster:o,paymasterData:s,paymasterPostOpGasLimit:a,paymasterVerificationGasLimit:c,sender:l,signature:u="0x",verificationGasLimit:d}=e;return{accountGasLimits:rm([Rf(Vf(d||0n),{size:16}),Rf(Vf(t||0n),{size:16})]),callData:n,initCode:eR(e),gasFees:rm([Rf(Vf(r||0n),{size:16}),Rf(Vf(i||0n),{size:16})]),nonce:e.nonce??0n,paymasterAndData:o?rm([o,Rf(Vf(c||0n),{size:16}),Rf(Vf(a||0n),{size:16}),s||"0x"]):"0x",preVerificationGas:e.preVerificationGas??0n,sender:l,signature:u}}const nR={PackedUserOperation:[{type:"address",name:"sender"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"bytes32",name:"accountGasLimits"},{type:"uint256",name:"preVerificationGas"},{type:"bytes32",name:"gasFees"},{type:"bytes",name:"paymasterAndData"}]};function rR(e){const{chainId:t,entryPointAddress:n,entryPointVersion:r}=e,i=e.userOperation,{authorization:o,callData:s="0x",callGasLimit:a,maxFeePerGas:c,maxPriorityFeePerGas:l,nonce:u,paymasterAndData:d="0x",preVerificationGas:h,sender:f,verificationGasLimit:p}=i;if("0.8"===r)return S_(function(e){const{chainId:t,entryPointAddress:n,userOperation:r}=e,i=tR(r);return{types:nR,primaryType:"PackedUserOperation",domain:{name:"ERC4337",version:"1",chainId:t,verifyingContract:n},message:i}}({chainId:t,entryPointAddress:n,userOperation:i}));const m=(()=>{var e,t;if("0.6"===r){const n=null==(e=i.initCode)?void 0:e.slice(0,42),r=null==(t=i.initCode)?void 0:t.slice(42),m=eR({authorization:o,factory:n,factoryData:r});return cm([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"bytes32"}],[f,u,Bp(m),Bp(s),a,p,h,c,l,Bp(d)])}if("0.7"===r){const e=tR(i);return cm([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[e.sender,e.nonce,Bp(e.initCode),Bp(e.callData),e.accountGasLimits,e.preVerificationGas,e.gasFees,Bp(e.paymasterAndData)])}throw new Error(`entryPointVersion "${r}" not supported.`)})();return Bp(cm([{type:"bytes32"},{type:"address"},{type:"uint256"}],[Bp(m),n,BigInt(t)]))}class iR extends tf{constructor({cause:e}){super("Smart Account is not deployed.",{cause:e,metaMessages:["This could arise when:","- No `factory`/`factoryData` or `initCode` properties are provided for Smart Account deployment.","- An incorrect `sender` address is provided."],name:"AccountNotDeployedError"})}}Object.defineProperty(iR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa20/});class oR extends tf{constructor({cause:e,data:t,message:n}={}){var r;const i=null==(r=null==n?void 0:n.replace("execution reverted: ",""))?void 0:r.replace("execution reverted","");super(`Execution reverted ${i?`with reason: ${i}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t}}Object.defineProperty(oR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32521}),Object.defineProperty(oR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class sR extends tf{constructor({cause:e}){super("Failed to send funds to beneficiary.",{cause:e,name:"FailedToSendToBeneficiaryError"})}}Object.defineProperty(sR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa91/});class aR extends tf{constructor({cause:e}){super("Gas value overflowed.",{cause:e,metaMessages:["This could arise when:","- one of the gas values exceeded 2**120 (uint120)"].filter(Boolean),name:"GasValuesOverflowError"})}}Object.defineProperty(aR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa94/});class cR extends tf{constructor({cause:e}){super("The `handleOps` function was called by the Bundler with a gas limit too low.",{cause:e,name:"HandleOpsOutOfGasError"})}}Object.defineProperty(cR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa95/});class lR extends tf{constructor({cause:e,factory:t,factoryData:n,initCode:r}){super("Failed to simulate deployment for Smart Account.",{cause:e,metaMessages:["This could arise when:","- Invalid `factory`/`factoryData` or `initCode` properties are present","- Smart Account deployment execution ran out of gas (low `verificationGasLimit` value)","- Smart Account deployment execution reverted with an error\n",t&&`factory: ${t}`,n&&`factoryData: ${n}`,r&&`initCode: ${r}`].filter(Boolean),name:"InitCodeFailedError"})}}Object.defineProperty(lR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa13/});class uR extends tf{constructor({cause:e,factory:t,factoryData:n,initCode:r}){super("Smart Account initialization implementation did not create an account.",{cause:e,metaMessages:["This could arise when:","- `factory`/`factoryData` or `initCode` properties are invalid","- Smart Account initialization implementation is incorrect\n",t&&`factory: ${t}`,n&&`factoryData: ${n}`,r&&`initCode: ${r}`].filter(Boolean),name:"InitCodeMustCreateSenderError"})}}Object.defineProperty(uR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa15/});class dR extends tf{constructor({cause:e,factory:t,factoryData:n,initCode:r,sender:i}){super("Smart Account initialization implementation does not return the expected sender.",{cause:e,metaMessages:["This could arise when:","Smart Account initialization implementation does not return a sender address\n",t&&`factory: ${t}`,n&&`factoryData: ${n}`,r&&`initCode: ${r}`,i&&`sender: ${i}`].filter(Boolean),name:"InitCodeMustReturnSenderError"})}}Object.defineProperty(dR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa14/});class hR extends tf{constructor({cause:e}){super("Smart Account does not have sufficient funds to execute the User Operation.",{cause:e,metaMessages:["This could arise when:","- the Smart Account does not have sufficient funds to cover the required prefund, or","- a Paymaster was not provided"].filter(Boolean),name:"InsufficientPrefundError"})}}Object.defineProperty(hR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa21/});class fR extends tf{constructor({cause:e}){super("Bundler attempted to call an invalid function on the EntryPoint.",{cause:e,name:"InternalCallOnlyError"})}}Object.defineProperty(fR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa92/});class pR extends tf{constructor({cause:e}){super("Bundler used an invalid aggregator for handling aggregated User Operations.",{cause:e,name:"InvalidAggregatorError"})}}Object.defineProperty(pR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa96/});class mR extends tf{constructor({cause:e,nonce:t}){super("Invalid Smart Account nonce used for User Operation.",{cause:e,metaMessages:[t&&`nonce: ${t}`].filter(Boolean),name:"InvalidAccountNonceError"})}}Object.defineProperty(mR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa25/});class gR extends tf{constructor({cause:e}){super("Bundler has not set a beneficiary address.",{cause:e,name:"InvalidBeneficiaryError"})}}Object.defineProperty(gR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa90/});class yR extends tf{constructor({cause:e}){super("Invalid fields set on User Operation.",{cause:e,name:"InvalidFieldsError"})}}Object.defineProperty(yR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class bR extends tf{constructor({cause:e,paymasterAndData:t}){super("Paymaster properties provided are invalid.",{cause:e,metaMessages:["This could arise when:","- the `paymasterAndData` property is of an incorrect length\n",t&&`paymasterAndData: ${t}`].filter(Boolean),name:"InvalidPaymasterAndDataError"})}}Object.defineProperty(bR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa93/});class vR extends tf{constructor({cause:e}){super("Paymaster deposit for the User Operation is too low.",{cause:e,metaMessages:["This could arise when:","- the Paymaster has deposited less than the expected amount via the `deposit` function"].filter(Boolean),name:"PaymasterDepositTooLowError"})}}Object.defineProperty(vR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32508}),Object.defineProperty(vR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa31/});class wR extends tf{constructor({cause:e}){super("The `validatePaymasterUserOp` function on the Paymaster reverted.",{cause:e,name:"PaymasterFunctionRevertedError"})}}Object.defineProperty(wR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa33/});class ER extends tf{constructor({cause:e}){super("The Paymaster contract has not been deployed.",{cause:e,name:"PaymasterNotDeployedError"})}}Object.defineProperty(ER,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa30/});class _R extends tf{constructor({cause:e}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:e,name:"PaymasterRateLimitError"})}}Object.defineProperty(_R,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32504});class xR extends tf{constructor({cause:e}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:e,name:"PaymasterStakeTooLowError"})}}Object.defineProperty(xR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32505});class kR extends tf{constructor({cause:e}){super("Paymaster `postOp` function reverted.",{cause:e,name:"PaymasterPostOpFunctionRevertedError"})}}Object.defineProperty(kR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa50/});class SR extends tf{constructor({cause:e,factory:t,factoryData:n,initCode:r}){super("Smart Account has already been deployed.",{cause:e,metaMessages:["Remove the following properties and try again:",t&&"`factory`",n&&"`factoryData`",r&&"`initCode`"].filter(Boolean),name:"SenderAlreadyConstructedError"})}}Object.defineProperty(SR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa10/});class CR extends tf{constructor({cause:e}){super("UserOperation rejected because account signature check failed (or paymaster signature, if the paymaster uses its data as signature).",{cause:e,name:"SignatureCheckFailedError"})}}Object.defineProperty(CR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32507});class IR extends tf{constructor({cause:e}){super("The `validateUserOp` function on the Smart Account reverted.",{cause:e,name:"SmartAccountFunctionRevertedError"})}}Object.defineProperty(IR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa23/});class AR extends tf{constructor({cause:e}){super("UserOperation rejected because account specified unsupported signature aggregator.",{cause:e,name:"UnsupportedSignatureAggregatorError"})}}Object.defineProperty(AR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32506});class PR extends tf{constructor({cause:e}){super("User Operation expired.",{cause:e,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validateUserOp` on the Smart Account are not satisfied"].filter(Boolean),name:"UserOperationExpiredError"})}}Object.defineProperty(PR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa22/});class MR extends tf{constructor({cause:e}){super("Paymaster for User Operation expired.",{cause:e,metaMessages:["This could arise when:","- the `validAfter` or `validUntil` values returned from `validatePaymasterUserOp` on the Paymaster are not satisfied"].filter(Boolean),name:"UserOperationPaymasterExpiredError"})}}Object.defineProperty(MR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa32/});class OR extends tf{constructor({cause:e}){super("Signature provided for the User Operation is invalid.",{cause:e,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Smart Account"].filter(Boolean),name:"UserOperationSignatureError"})}}Object.defineProperty(OR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa24/});class TR extends tf{constructor({cause:e}){super("Signature provided for the User Operation is invalid.",{cause:e,metaMessages:["This could arise when:","- the `signature` for the User Operation is incorrectly computed, and unable to be verified by the Paymaster"].filter(Boolean),name:"UserOperationPaymasterSignatureError"})}}Object.defineProperty(TR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa34/});class RR extends tf{constructor({cause:e}){super("User Operation rejected by EntryPoint's `simulateValidation` during account creation or validation.",{cause:e,name:"UserOperationRejectedByEntryPointError"})}}Object.defineProperty(RR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32500});class NR extends tf{constructor({cause:e}){super("User Operation rejected by Paymaster's `validatePaymasterUserOp`.",{cause:e,name:"UserOperationRejectedByPaymasterError"})}}Object.defineProperty(NR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32501});class LR extends tf{constructor({cause:e}){super("User Operation rejected with op code validation error.",{cause:e,name:"UserOperationRejectedByOpCodeError"})}}Object.defineProperty(LR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32502});class BR extends tf{constructor({cause:e}){super("UserOperation out of time-range: either wallet or paymaster returned a time-range, and it is already expired (or will expire soon).",{cause:e,name:"UserOperationOutOfTimeRangeError"})}}Object.defineProperty(BR,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32503});class jR extends tf{constructor({cause:e}){super(`An error occurred while executing user operation: ${null==e?void 0:e.shortMessage}`,{cause:e,name:"UnknownBundlerError"})}}class DR extends tf{constructor({cause:e}){super("User Operation verification gas limit exceeded.",{cause:e,metaMessages:["This could arise when:","- the gas used for verification exceeded the `verificationGasLimit`"].filter(Boolean),name:"VerificationGasLimitExceededError"})}}Object.defineProperty(DR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa40/});class UR extends tf{constructor({cause:e}){super("User Operation verification gas limit is too low.",{cause:e,metaMessages:["This could arise when:","- the `verificationGasLimit` is too low to verify the User Operation"].filter(Boolean),name:"VerificationGasLimitTooLowError"})}}Object.defineProperty(UR,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa41/});class FR extends tf{constructor(e,{callData:t,callGasLimit:n,docsPath:r,factory:i,factoryData:o,initCode:s,maxFeePerGas:a,maxPriorityFeePerGas:c,nonce:l,paymaster:u,paymasterAndData:d,paymasterData:h,paymasterPostOpGasLimit:f,paymasterVerificationGasLimit:p,preVerificationGas:m,sender:g,signature:y,verificationGasLimit:b}){const v=Gg({callData:t,callGasLimit:n,factory:i,factoryData:o,initCode:s,maxFeePerGas:void 0!==a&&`${Hg(a)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Hg(c)} gwei`,nonce:l,paymaster:u,paymasterAndData:d,paymasterData:h,paymasterPostOpGasLimit:f,paymasterVerificationGasLimit:p,preVerificationGas:m,sender:g,signature:y,verificationGasLimit:b});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",v].filter(Boolean),name:"UserOperationExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class $R extends tf{constructor({hash:e}){super(`User Operation receipt with hash "${e}" could not be found. The User Operation may not have been processed yet.`,{name:"UserOperationReceiptNotFoundError"})}}class zR extends tf{constructor({hash:e}){super(`User Operation with hash "${e}" could not be found.`,{name:"UserOperationNotFoundError"})}}class HR extends tf{constructor({hash:e}){super(`Timed out while waiting for User Operation with hash "${e}" to be confirmed.`,{name:"WaitForUserOperationReceiptTimeoutError"})}}const qR=[oR,yR,vR,_R,xR,CR,AR,BR,RR,NR,LR];function WR(e,{calls:t,docsPath:n,...r}){const i=(()=>{const n=function(e,t){const n=(e.details||"").toLowerCase();if(iR.message.test(n))return new iR({cause:e});if(sR.message.test(n))return new sR({cause:e});if(aR.message.test(n))return new aR({cause:e});if(cR.message.test(n))return new cR({cause:e});if(lR.message.test(n))return new lR({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(uR.message.test(n))return new uR({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(dR.message.test(n))return new dR({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode,sender:t.sender});if(hR.message.test(n))return new hR({cause:e});if(fR.message.test(n))return new fR({cause:e});if(mR.message.test(n))return new mR({cause:e,nonce:t.nonce});if(pR.message.test(n))return new pR({cause:e});if(gR.message.test(n))return new gR({cause:e});if(bR.message.test(n))return new bR({cause:e});if(vR.message.test(n))return new vR({cause:e});if(wR.message.test(n))return new wR({cause:e});if(ER.message.test(n))return new ER({cause:e});if(kR.message.test(n))return new kR({cause:e});if(IR.message.test(n))return new IR({cause:e});if(SR.message.test(n))return new SR({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(PR.message.test(n))return new PR({cause:e});if(MR.message.test(n))return new MR({cause:e});if(TR.message.test(n))return new TR({cause:e});if(OR.message.test(n))return new OR({cause:e});if(DR.message.test(n))return new DR({cause:e});if(UR.message.test(n))return new UR({cause:e});const r=e.walk(e=>qR.some(t=>t.code===e.code));if(r){if(r.code===oR.code)return new oR({cause:e,data:r.data,message:r.details});if(r.code===yR.code)return new yR({cause:e});if(r.code===vR.code)return new vR({cause:e});if(r.code===_R.code)return new _R({cause:e});if(r.code===xR.code)return new xR({cause:e});if(r.code===CR.code)return new CR({cause:e});if(r.code===AR.code)return new AR({cause:e});if(r.code===BR.code)return new BR({cause:e});if(r.code===RR.code)return new RR({cause:e});if(r.code===NR.code)return new NR({cause:e});if(r.code===LR.code)return new LR({cause:e})}return new jR({cause:e})}(e,r);if(t&&n instanceof oR){const e=function(e){let t;return e.walk(e=>{var n,r,i,o;const s=e;if("string"==typeof s.data||"string"==typeof(null==(n=s.data)?void 0:n.revertData)||!(s instanceof tf)&&"string"==typeof s.message){const e=null==(o=(i=(null==(r=s.data)?void 0:r.revertData)||s.data||s.message).match)?void 0:o.call(i,/(0x[A-Za-z0-9]*)/);if(e)return t=e[1],!0}return!1}),t}(n),r=null==t?void 0:t.filter(e=>e.abi);if(e&&r.length>0)return function(e){const{calls:t,revertData:n}=e,{abi:r,functionName:i,args:o,to:s}=(()=>{const e=null==t?void 0:t.filter(e=>Boolean(e.abi));if(1===e.length)return e[0];const r=e.filter(e=>{try{return Boolean(Lg({abi:e.abi,data:n}))}catch{return!1}});return 1===r.length?r[0]:{abi:[],functionName:e.reduce((e,t)=>`${e?`${e} | `:""}${t.functionName}`,""),args:void 0,to:void 0}})(),a="0x"===n?new sy({functionName:i}):new oy({abi:r,data:n,functionName:i});return new iy(a,{abi:r,args:o,contractAddress:s,functionName:i})}({calls:r,revertData:e})}return n})();return new FR(i,{docsPath:n,...r})}function KR(e){const t={};var n;return void 0!==e.callData&&(t.callData=e.callData),void 0!==e.callGasLimit&&(t.callGasLimit=Vf(e.callGasLimit)),void 0!==e.factory&&(t.factory=e.factory),void 0!==e.factoryData&&(t.factoryData=e.factoryData),void 0!==e.initCode&&(t.initCode=e.initCode),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=Vf(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=Vf(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=Vf(e.nonce)),void 0!==e.paymaster&&(t.paymaster=e.paymaster),void 0!==e.paymasterAndData&&(t.paymasterAndData=e.paymasterAndData||"0x"),void 0!==e.paymasterData&&(t.paymasterData=e.paymasterData),void 0!==e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=Vf(e.paymasterPostOpGasLimit)),void 0!==e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=Vf(e.paymasterVerificationGasLimit)),void 0!==e.preVerificationGas&&(t.preVerificationGas=Vf(e.preVerificationGas)),void 0!==e.sender&&(t.sender=e.sender),void 0!==e.signature&&(t.signature=e.signature),void 0!==e.verificationGasLimit&&(t.verificationGasLimit=Vf(e.verificationGasLimit)),void 0!==e.authorization&&(t.eip7702Auth={address:(n=e.authorization).address,chainId:Vf(n.chainId),nonce:Vf(n.nonce),r:n.r?Vf(BigInt(n.r),{size:32}):Rf("0x",{size:32}),s:n.s?Vf(BigInt(n.s),{size:32}):Rf("0x",{size:32}),yParity:n.yParity?Vf(n.yParity,{size:1}):Rf("0x",{size:32})}),t}async function GR(e,t){const{chainId:n,entryPointAddress:r,context:i,...o}=t,s=KR(o),{paymasterPostOpGasLimit:a,paymasterVerificationGasLimit:c,...l}=await e.request({method:"pm_getPaymasterData",params:[{...s,callGasLimit:s.callGasLimit??"0x0",verificationGasLimit:s.verificationGasLimit??"0x0",preVerificationGas:s.preVerificationGas??"0x0"},r,Vf(n),i]});return{...l,...a&&{paymasterPostOpGasLimit:$f(a)},...c&&{paymasterVerificationGasLimit:$f(c)}}}async function VR(e,t){const{chainId:n,entryPointAddress:r,context:i,...o}=t,s=KR(o),{paymasterPostOpGasLimit:a,paymasterVerificationGasLimit:c,...l}=await e.request({method:"pm_getPaymasterStubData",params:[{...s,callGasLimit:s.callGasLimit??"0x0",verificationGasLimit:s.verificationGasLimit??"0x0",preVerificationGas:s.preVerificationGas??"0x0"},r,Vf(n),i]});return{...l,...a&&{paymasterPostOpGasLimit:$f(a)},...c&&{paymasterVerificationGasLimit:$f(c)}}}const ZR=["factory","fees","gas","paymaster","nonce","signature","authorization"];async function YR(e,t){var n;const r=t,{account:i=e.account,parameters:o=ZR,stateOverride:s}=r;if(!i)throw new oS;const a=Og(i),c=e,l=r.paymaster??(null==c?void 0:c.paymaster),u="string"==typeof l?l:void 0,{getPaymasterStubData:d,getPaymasterData:h}=(()=>{if(!0===l)return{getPaymasterStubData:e=>Ey(c,VR,"getPaymasterStubData")(e),getPaymasterData:e=>Ey(c,GR,"getPaymasterData")(e)};if("object"==typeof l){const{getPaymasterStubData:e,getPaymasterData:t}=l;return{getPaymasterStubData:t&&e?e:t,getPaymasterData:t&&e?t:void 0}}return{getPaymasterStubData:void 0,getPaymasterData:void 0}})(),f=r.paymasterContext?r.paymasterContext:null==c?void 0:c.paymasterContext;let p={...r,paymaster:u,sender:a.address};const[m,g,y,b,v]=await Promise.all([(async()=>r.calls?a.encodeCalls(r.calls.map(e=>{const t=e;return t.abi?{data:kg(t),to:t.to,value:t.value}:t})):r.callData)(),(async()=>{if(!o.includes("factory"))return;if(r.initCode)return{initCode:r.initCode};if(r.factory&&r.factoryData)return{factory:r.factory,factoryData:r.factoryData};const{factory:e,factoryData:t}=await a.getFactoryArgs();return"0.6"===a.entryPoint.version?{initCode:e&&t?rm([e,t]):void 0}:{factory:e,factoryData:t}})(),(async()=>{var t;if(o.includes("fees")){if("bigint"==typeof r.maxFeePerGas&&"bigint"==typeof r.maxPriorityFeePerGas)return p;if(null==(t=null==c?void 0:c.userOperation)?void 0:t.estimateFeesPerGas){const e=await c.userOperation.estimateFeesPerGas({account:a,bundlerClient:c,userOperation:p});return{...p,...e}}try{const t=c.client??e,n=await Ey(t,rE,"estimateFeesPerGas")({chain:t.chain,type:"eip1559"});return{maxFeePerGas:"bigint"==typeof r.maxFeePerGas?r.maxFeePerGas:BigInt(2n*n.maxFeePerGas),maxPriorityFeePerGas:"bigint"==typeof r.maxPriorityFeePerGas?r.maxPriorityFeePerGas:BigInt(2n*n.maxPriorityFeePerGas)}}catch{return}}})(),(async()=>{if(o.includes("nonce"))return"bigint"==typeof r.nonce?r.nonce:a.getNonce()})(),(async()=>{if(o.includes("authorization")){if("object"==typeof r.authorization)return r.authorization;if(a.authorization&&!(await a.isDeployed())){const e=await async function(e,t){var n;const{account:r=e.account,chainId:i,nonce:o}=t;if(!r)throw new oS({docsPath:"/docs/eip7702/prepareAuthorization"});const s=Og(r),a=(()=>{if(t.executor)return"self"===t.executor?t.executor:Og(t.executor)})(),c={address:t.contractAddress??t.address,chainId:i,nonce:o};return void 0===c.chainId&&(c.chainId=(null==(n=e.chain)?void 0:n.id)??await Ey(e,AE,"getChainId")({})),void 0===c.nonce&&(c.nonce=await Ey(e,oE,"getTransactionCount")({address:s.address,blockTag:"pending"}),("self"===a||(null==a?void 0:a.address)&&DE(a.address,s.address))&&(c.nonce+=1)),c}(a.client,a.authorization);return{...e,r:"0xfffffffffffffffffffffffffffffff000000000000000000000000000000000",s:"0x7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",yParity:1}}}})()]);let w;async function E(){if(w)return w;if(e.chain)return e.chain.id;const t=await Ey(e,AE,"getChainId")({});return w=t,w}void 0!==m&&(p.callData=m),void 0!==g&&(p={...p,...g}),void 0!==y&&(p={...p,...y}),void 0!==b&&(p.nonce=b),void 0!==v&&(p.authorization=v),o.includes("signature")&&(void 0!==r.signature?p.signature=r.signature:p.signature=await a.getStubSignature(p)),"0.6"!==a.entryPoint.version||p.initCode||(p.initCode="0x");let _=!1;if(o.includes("paymaster")&&d&&!u&&!r.paymasterAndData){const{isFinal:e=!1,sponsor:t,...n}=await d({chainId:await E(),entryPointAddress:a.entryPoint.address,context:f,...p});_=e,p={...p,...n}}if("0.6"!==a.entryPoint.version||p.paymasterAndData||(p.paymasterAndData="0x"),o.includes("gas")){if(null==(n=a.userOperation)?void 0:n.estimateGas){const e=await a.userOperation.estimateGas(p);p={...p,...e}}if(void 0===p.callGasLimit||void 0===p.preVerificationGas||void 0===p.verificationGasLimit||p.paymaster&&void 0===p.paymasterPostOpGasLimit||p.paymaster&&void 0===p.paymasterVerificationGasLimit){const e=await Ey(c,JR,"estimateUserOperationGas")({account:a,callGasLimit:0n,preVerificationGas:0n,verificationGasLimit:0n,stateOverride:s,...p.paymaster?{paymasterPostOpGasLimit:0n,paymasterVerificationGasLimit:0n}:{},...p});p={...p,callGasLimit:p.callGasLimit??e.callGasLimit,preVerificationGas:p.preVerificationGas??e.preVerificationGas,verificationGasLimit:p.verificationGasLimit??e.verificationGasLimit,paymasterPostOpGasLimit:p.paymasterPostOpGasLimit??e.paymasterPostOpGasLimit,paymasterVerificationGasLimit:p.paymasterVerificationGasLimit??e.paymasterVerificationGasLimit}}}if(o.includes("paymaster")&&h&&!u&&!r.paymasterAndData&&!_){const e=await h({chainId:await E(),entryPointAddress:a.entryPoint.address,context:f,...p});p={...p,...e}}return delete p.calls,delete p.parameters,delete p.paymasterContext,"string"!=typeof p.paymaster&&delete p.paymaster,p}async function JR(e,t){var n;const{account:r=e.account,entryPointAddress:i,stateOverride:o}=t;if(!r&&!t.sender)throw new oS;const s=r?Og(r):void 0,a=cw(o),c=s?await Ey(e,YR,"prepareUserOperation")({...t,parameters:["authorization","factory","nonce","paymaster","signature"]}):t;try{const t=[KR(c),i??(null==(n=null==s?void 0:s.entryPoint)?void 0:n.address)];return function(e){const t={};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),t}(await e.request({method:"eth_estimateUserOperationGas",params:a?[...t,a]:[...t]}))}catch(l){const e=t.calls;throw WR(l,{...c,...e?{calls:e}:{}})}}function QR(e){const t={...e};return e.callGasLimit&&(t.callGasLimit=BigInt(e.callGasLimit)),e.maxFeePerGas&&(t.maxFeePerGas=BigInt(e.maxFeePerGas)),e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=BigInt(e.maxPriorityFeePerGas)),e.nonce&&(t.nonce=BigInt(e.nonce)),e.paymasterPostOpGasLimit&&(t.paymasterPostOpGasLimit=BigInt(e.paymasterPostOpGasLimit)),e.paymasterVerificationGasLimit&&(t.paymasterVerificationGasLimit=BigInt(e.paymasterVerificationGasLimit)),e.preVerificationGas&&(t.preVerificationGas=BigInt(e.preVerificationGas)),e.verificationGasLimit&&(t.verificationGasLimit=BigInt(e.verificationGasLimit)),t}async function XR(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationReceipt",params:[t]},{dedupe:!0});if(!n)throw new $R({hash:t});return function(e){const t={...e};return e.actualGasCost&&(t.actualGasCost=BigInt(e.actualGasCost)),e.actualGasUsed&&(t.actualGasUsed=BigInt(e.actualGasUsed)),e.logs&&(t.logs=e.logs.map(e=>HE(e))),e.receipt&&(t.receipt=f_(t.receipt)),t}(n)}function eN(e){return{estimateUserOperationGas:t=>JR(e,t),getChainId:()=>AE(e),getSupportedEntryPoints:()=>function(e){return e.request({method:"eth_supportedEntryPoints"})}(e),getUserOperation:t=>async function(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationByHash",params:[t]},{dedupe:!0});if(!n)throw new zR({hash:t});const{blockHash:r,blockNumber:i,entryPoint:o,transactionHash:s,userOperation:a}=n;return{blockHash:r,blockNumber:BigInt(i),entryPoint:o,transactionHash:s,userOperation:QR(a)}}(e,t),getUserOperationReceipt:t=>XR(e,t),prepareUserOperation:t=>YR(e,t),sendUserOperation:t=>async function(e,t){var n,r;const{account:i=e.account,entryPointAddress:o}=t;if(!i&&!t.sender)throw new oS;const s=i?Og(i):void 0,a=s?await Ey(e,YR,"prepareUserOperation")(t):t,c=t.signature||await(null==(n=null==s?void 0:s.signUserOperation)?void 0:n.call(s,a)),l=KR({...a,signature:c});try{return await e.request({method:"eth_sendUserOperation",params:[l,o??(null==(r=null==s?void 0:s.entryPoint)?void 0:r.address)]},{retryCount:0})}catch(u){const e=t.calls;throw WR(u,{...a,...e?{calls:e}:{},signature:c})}}(e,t),waitForUserOperationReceipt:t=>function(e,t){const{hash:n,pollingInterval:r=e.pollingInterval,retryCount:i,timeout:o=12e4}=t;let s=0;const a=Bg(["waitForUserOperationReceipt",e.uid,n]);return new Promise((t,c)=>{const l=tS(a,{resolve:t,reject:c},t=>{const a=e=>{u(),e(),l()},c=o?setTimeout(()=>a(()=>t.reject(new HR({hash:n}))),o):void 0,u=nS(async()=>{i&&s>=i&&(clearTimeout(c),a(()=>t.reject(new HR({hash:n}))));try{const r=await Ey(e,XR,"getUserOperationReceipt")({hash:n});a(()=>t.resolve(r))}catch(r){const e=r;"UserOperationReceiptNotFoundError"!==e.name&&a(()=>t.reject(e))}finally{clearTimeout(c)}s++},{emitOnBegin:!0,interval:r});return u})})}(e,t)}}function tN(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}function nN(e,t){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(t);const r=tN(n);return(e,n)=>r.then(r=>n(r.transaction(t,e).objectStore(t)))}let rN;function iN(){return rN||(rN=nN("keyval-store","keyval")),rN}const oN="4.3.6",sN="@coinbase/wallet-sdk",aN=jO(LO((...e)=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{chains:[]}),{keys:{}}),{account:{}}),{subAccount:void 0}),{spendPermissions:[]}),(()=>({config:{version:oN}}))(...e)),{subAccountConfig:{}}),{name:"cbwsdk.store",storage:RO(()=>localStorage),partialize:e=>({chains:e.chains,keys:e.keys,account:e.account,subAccount:e.subAccount,spendPermissions:e.spendPermissions,config:e.config})})),cN={get:()=>aN.getState().config,set:e=>{aN.setState(t=>({config:Object.assign(Object.assign({},t.config),e)}))}},lN={subAccounts:{get:()=>aN.getState().subAccount,set:e=>{aN.setState(t=>({subAccount:t.subAccount?Object.assign(Object.assign({},t.subAccount),e):Object.assign({address:e.address},e)}))},clear:()=>{aN.setState({subAccount:void 0})}},subAccountsConfig:{get:()=>aN.getState().subAccountConfig,set:e=>{aN.setState(t=>({subAccountConfig:Object.assign(Object.assign({},t.subAccountConfig),e)}))},clear:()=>{aN.setState({subAccountConfig:{}})}},spendPermissions:{get:()=>aN.getState().spendPermissions,set:e=>{aN.setState({spendPermissions:e})},clear:()=>{aN.setState({spendPermissions:[]})}},account:{get:()=>aN.getState().account,set:e=>{aN.setState(t=>({account:Object.assign(Object.assign({},t.account),e)}))},clear:()=>{aN.setState({account:{}})}},chains:{get:()=>aN.getState().chains,set:e=>{aN.setState({chains:e})},clear:()=>{aN.setState({chains:[]})}},keys:{get:e=>aN.getState().keys[e],set:(e,t)=>{aN.setState(n=>({keys:Object.assign(Object.assign({},n.keys),{[e]:t})}))},clear:()=>{aN.setState({keys:{}})}},config:cN},uN=Object.assign(Object.assign({},aN),lN),dN=()=>{var e,t,n;if("undefined"!=typeof window){const r=null!==(n=null!==(e=uN.config.get().deviceId)&&void 0!==e?e:null===(t=window.crypto)||void 0===t?void 0:t.randomUUID())&&void 0!==n?n:"";if(window.ClientAnalytics){const{init:e,identify:t,PlatformName:n}=window.ClientAnalytics;e({isProd:!0,amplitudeApiKey:"c66737ad47ec354ced777935b0af822e",platform:n.web,projectName:"base_account_sdk",showDebugLogging:!1,version:"1.0.0",apiEndpoint:"https://cca-lite.coinbase.com"}),t({deviceId:r}),uN.config.set({deviceId:r})}}},hN={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},fN={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902},pN={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},mN="Unspecified error message.";function gN(e,t=mN){if(e&&Number.isInteger(e)){const t=e.toString();if(wN(pN,t))return pN[t].message;if(bN(e))return"Unspecified server error."}return t}function yN(e,{shouldIncludeStack:t=!1}={}){const n={};if(e&&"object"==typeof e&&!Array.isArray(e)&&wN(e,"code")&&function(e){if(!Number.isInteger(e))return!1;const t=e.toString();return!!pN[t]||!!bN(e)}(e.code)){const t=e;n.code=t.code,t.message&&"string"==typeof t.message?(n.message=t.message,wN(t,"data")&&(n.data=t.data)):(n.message=gN(n.code),n.data={originalError:vN(e)})}else n.code=hN.internal,n.message=EN(e,"message")?e.message:mN,n.data={originalError:vN(e)};return t&&(n.stack=EN(e,"stack")?e.stack:void 0),n}function bN(e){return e>=-32099&&e<=-32e3}function vN(e){return e&&"object"==typeof e&&!Array.isArray(e)?Object.assign({},e):e}function wN(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function EN(e,t){return"object"==typeof e&&null!==e&&t in e&&"string"==typeof e[t]}const _N={parse:e=>kN(hN.parse,e),invalidRequest:e=>kN(hN.invalidRequest,e),invalidParams:e=>kN(hN.invalidParams,e),methodNotFound:e=>kN(hN.methodNotFound,e),internal:e=>kN(hN.internal,e),server:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return kN(t,e)},invalidInput:e=>kN(hN.invalidInput,e),resourceNotFound:e=>kN(hN.resourceNotFound,e),resourceUnavailable:e=>kN(hN.resourceUnavailable,e),transactionRejected:e=>kN(hN.transactionRejected,e),methodNotSupported:e=>kN(hN.methodNotSupported,e),limitExceeded:e=>kN(hN.limitExceeded,e)},xN={userRejectedRequest:e=>SN(fN.userRejectedRequest,e),unauthorized:e=>SN(fN.unauthorized,e),unsupportedMethod:e=>SN(fN.unsupportedMethod,e),disconnected:e=>SN(fN.disconnected,e),chainDisconnected:e=>SN(fN.chainDisconnected,e),unsupportedChain:e=>SN(fN.unsupportedChain,e),custom:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:n,data:r}=e;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new AN(t,n,r)}};function kN(e,t){const[n,r]=CN(t);return new IN(e,n||gN(e),r)}function SN(e,t){const[n,r]=CN(t);return new AN(e,n||gN(e),r)}function CN(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t||void 0,n]}}return[]}let IN=class extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a nonempty string.');super(t),this.code=e,void 0!==n&&(this.data=n)}},AN=class extends IN{constructor(e,t,n){if(!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,n)}};function PN(e){return"object"==typeof e&&null!==e&&"code"in e&&"data"in e&&-32090===e.code&&"object"==typeof e.data&&null!==e.data&&"type"in e.data&&"INSUFFICIENT_FUNDS"===e.data.type}function MN(e){return"object"==typeof e&&null!==e&&"details"in e}const ON=e=>e,TN=e=>e;function RN(e){return Math.floor(e)}var NN=["buffer","Buffer"];const LN=/^[0-9]*$/,BN=/^[a-f0-9]*$/;function jN(e){return DN(crypto.getRandomValues(new Uint8Array(e)))}function DN(e){return[...e].map(e=>e.toString(16).padStart(2,"0")).join("")}function UN(e){return new Uint8Array(e.match(/.{1,2}/g).map(e=>Number.parseInt(e,16)))}function FN(e,t=!1){const n=e.toString("hex");return ON(t?`0x${n}`:n)}function $N(e){return FN(JN(e),!0)}function zN(e){return TN(e.toString(10))}function HN(e){return ON(`0x${BigInt(e).toString(16)}`)}function qN(e){return e.startsWith("0x")||e.startsWith("0X")}function WN(e){return qN(e)?e.slice(2):e}function KN(e){return qN(e)?`0x${e.slice(2)}`:`0x${e}`}function GN(e){if("string"!=typeof e)return!1;const t=WN(e).toLowerCase();return BN.test(t)}function VN(e,t=!1){if("string"==typeof e){const n=WN(e).toLowerCase();if(BN.test(n))return ON(t?`0x${n}`:n)}throw _N.invalidParams(`"${String(e)}" is not a hexadecimal string`)}function ZN(e,t=!1){let n=VN(e,!1);return n.length%2==1&&(n=ON(`0${n}`)),t?ON(`0x${n}`):n}function YN(e){if("string"==typeof e){const t=WN(e).toLowerCase();if(GN(t)&&40===t.length)return KN(t)}throw _N.invalidParams(`Invalid Ethereum address: ${String(e)}`)}function JN(e){if(NN.isBuffer(e))return e;if("string"==typeof e){if(GN(e)){const t=ZN(e,!1);return NN.from(t,"hex")}return NN.from(e,"utf8")}throw _N.invalidParams(`Not binary data: ${String(e)}`)}function QN(e){if("number"==typeof e&&Number.isInteger(e))return RN(e);if("string"==typeof e){if(LN.test(e))return RN(Number(e));if(GN(e))return RN(Number(BigInt(ZN(e,!0))))}throw _N.invalidParams(`Not an integer: ${String(e)}`)}function XN(e){if(null!==e&&("bigint"==typeof e||function(e){if(null==e||"function"!=typeof e.constructor)return!1;const{constructor:t}=e;return"function"==typeof t.config&&"number"==typeof t.EUCLID}(e)))return BigInt(e.toString(10));if("number"==typeof e)return BigInt(QN(e));if("string"==typeof e){if(LN.test(e))return BigInt(e);if(GN(e))return BigInt(ZN(e,!0))}throw _N.invalidParams(`Not an integer: ${String(e)}`)}function eL(e){if("string"==typeof e)return JSON.parse(e);if("object"==typeof e)return e;throw _N.invalidParams(`Not a JSON string or an object: ${String(e)}`)}const{checkCrossOriginOpenerPolicy:tL,getCrossOriginOpenerPolicy:nL}=(()=>{let e;return{getCrossOriginOpenerPolicy:()=>void 0===e?"undefined":e,checkCrossOriginOpenerPolicy:async()=>{if("undefined"!=typeof window)try{const t=`${window.location.origin}${window.location.pathname}`,n=await fetch(t,{method:"HEAD"});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=n.headers.get("Cross-Origin-Opener-Policy");e=null!=r?r:"null","same-origin"===e&&console.error("Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app.\n\nPlease see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.")}catch(t){console.error("Error checking Cross-Origin-Opener-Policy:",t.message),e="error"}else e="non-browser-env"}}})();async function rL(e,t){const n=Object.assign(Object.assign({},e),{jsonrpc:"2.0",id:crypto.randomUUID()}),r=await window.fetch(t,{method:"POST",body:JSON.stringify(n),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":oN,"X-Cbw-Sdk-Platform":sN}}),{result:i,error:o}=await r.json();if(o)throw o;return i}function iL({metadata:e,preference:t}){var n,r;const{appName:i,appLogoUrl:o,appChainIds:s}=e;if("smartWalletOnly"!==t.options){const e=globalThis.coinbaseWalletExtension;if(e)return null===(n=e.setAppInfo)||void 0===n||n.call(e,i,o,s,t),e}const a=function(){var e,t;try{const n=globalThis;return null!==(e=n.ethereum)&&void 0!==e?e:null===(t=n.top)||void 0===t?void 0:t.ethereum}catch(n){return}}();if(null==a?void 0:a.isCoinbaseBrowser)return null===(r=a.setAppInfo)||void 0===r||r.call(a,i,o,s,t),a}function oL(e){if("function"!=typeof e)throw new Error("toAccount is not a function")}const sL="https://rpc.wallet.coinbase.com",aL="https://www.walletlink.org";var cL,lL,uL,dL,hL,fL;function pL(e,t,n){var r,i,o,s;window.ClientAnalytics&&(null===(r=window.ClientAnalytics)||void 0===r||r.logEvent(e,Object.assign(Object.assign({},t),{sdkVersion:oN,appName:null!==(o=null===(i=uN.config.get().metadata)||void 0===i?void 0:i.appName)&&void 0!==o?o:"",appOrigin:window.location.origin,appPreferredSigner:null===(s=uN.config.get().preference)||void 0===s?void 0:s.options}),n))}(lL=cL||(cL={})).unknown="unknown",lL.banner="banner",lL.button="button",lL.card="card",lL.chart="chart",lL.content_script="content_script",lL.dropdown="dropdown",lL.link="link",lL.page="page",lL.modal="modal",lL.table="table",lL.search_bar="search_bar",lL.service_worker="service_worker",lL.text="text",lL.text_input="text_input",lL.tray="tray",lL.checkbox="checkbox",lL.icon="icon",(dL=uL||(uL={})).unknown="unknown",dL.blur="blur",dL.click="click",dL.change="change",dL.dismiss="dismiss",dL.focus="focus",dL.hover="hover",dL.select="select",dL.measurement="measurement",dL.move="move",dL.process="process",dL.render="render",dL.scroll="scroll",dL.view="view",dL.search="search",dL.keyPress="keyPress",dL.error="error",(fL=hL||(hL={})).low="low",fL.high="high";const mL=({snackbarContext:e})=>{pL(`snackbar.${e}.shown`,{action:uL.render,componentType:cL.modal,snackbarContext:e},hL.high)},gL=({snackbarContext:e,snackbarAction:t})=>{pL(`snackbar.${e}.action_clicked`,{action:uL.click,componentType:cL.button,snackbarContext:e,snackbarAction:t},hL.high)},yL=(()=>'@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}')();function bL(){const e=document.createElement("style");e.type="text/css",e.appendChild(document.createTextNode(yL)),document.documentElement.appendChild(e)}function vL(){try{return function(){try{return null!==window.frameElement}catch(e){return!1}}()&&window.top?window.top.location:window.location}catch(e){return window.location}}function wL(){var e,t;return null!==(t=null===(e=null===window||void 0===window?void 0:window.matchMedia)||void 0===e?void 0:e.call(window,"(prefers-color-scheme: dark)").matches)&&void 0!==t&&t}const EL=(()=>".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}")();let _L=class{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=wL()}attach(e){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",e.appendChild(this.root),this.render()}presentItem(e){const t=this.nextItemKey++;return this.items.set(t,e),this.render(),()=>{this.items.delete(t),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&ET(nT("div",null,nT(xL,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([e,t])=>nT(kL,Object.assign({},t,{key:e}))))),this.root)}};const xL=e=>nT("div",{class:kT("-cbwsdk-snackbar-container")},nT("style",null,EL),nT("div",{class:"-cbwsdk-snackbar"},e.children)),kL=({autoExpand:e,message:t,menuItems:n})=>{const[r,i]=FT(!0),[o,s]=FT(null!=e&&e);zT(()=>{const e=[window.setTimeout(()=>{i(!1)},1),window.setTimeout(()=>{s(!0)},1e4)];return()=>{e.forEach(window.clearTimeout)}});return nT("div",{class:kT("-cbwsdk-snackbar-instance",r&&"-cbwsdk-snackbar-instance-hidden",o&&"-cbwsdk-snackbar-instance-expanded")},nT("div",{class:"-cbwsdk-snackbar-instance-header",onClick:()=>{s(!o)}},nT("img",{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",nT("div",{class:"-cbwsdk-snackbar-instance-header-message"},t),nT("div",{class:"-gear-container"},!o&&nT("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},nT("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),nT("img",{src:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=",class:"-gear-icon",title:"Expand"}))),n&&n.length>0&&nT("div",{class:"-cbwsdk-snackbar-instance-menu"},n.map((e,t)=>nT("div",{class:kT("-cbwsdk-snackbar-instance-menu-item",e.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:e.onClick,key:t},nT("svg",{width:e.svgWidth,height:e.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},nT("path",{"fill-rule":e.defaultFillRule,"clip-rule":e.defaultClipRule,d:e.path,fill:"#AAAAAA"})),nT("span",{class:kT("-cbwsdk-snackbar-instance-menu-item-info",e.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},e.info)))))},SL="M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z";let CL=class{constructor(){this.attached=!1,this.snackbar=new _L}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,t=document.createElement("div");t.className="-cbwsdk-css-reset",e.appendChild(t),this.snackbar.attach(t),this.attached=!0,bL()}showConnecting(e){let t;return t=e.isUnlinkedErrorState?{autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:{message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:SL,defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(t)}};const IL={isRed:!1,info:"Retry",svgWidth:"10",svgHeight:"11",path:SL,defaultFillRule:"evenodd",defaultClipRule:"evenodd"};let AL=null;function PL(e){const t=(window.innerWidth-420)/2+window.screenX,n=(window.innerHeight-700)/2+window.screenY;function r(){const r=`wallet_${crypto.randomUUID()}`,i=window.open(e,r,`width=420, height=700, left=${t}, top=${n}`);return null==i||i.focus(),i||null}!function(e){const t={sdkName:sN,sdkVersion:oN,origin:window.location.origin,coop:nL()};for(const[n,r]of Object.entries(t))e.searchParams.has(n)||e.searchParams.append(n,r.toString())}(e);let i=r();if(!i){const e=ML();return new Promise((t,n)=>{mL({snackbarContext:"popup_blocked"}),e.presentItem({autoExpand:!0,message:"Popup was blocked. Try again.",menuItems:[Object.assign(Object.assign({},IL),{onClick:()=>{gL({snackbarContext:"popup_blocked",snackbarAction:"confirm"}),i=r(),i?t(i):n(_N.internal("Popup window was blocked")),e.clear()}})]})})}return Promise.resolve(i)}function ML(){if(!AL){const e=document.createElement("div");e.className="-cbwsdk-css-reset",document.body.appendChild(e),AL=new _L,AL.attach(e)}return AL}class OL{constructor({url:e="https://keys.coinbase.com/connect",metadata:t,preference:n}){this.popup=null,this.listeners=new Map,this.postMessage=async e=>{(await this.waitForPopupLoaded()).postMessage(e,this.url.origin)},this.postRequestAndWaitForResponse=async e=>{const t=this.onMessage(({requestId:t})=>t===e.id);return this.postMessage(e),await t},this.onMessage=async e=>new Promise((t,n)=>{const r=n=>{if(n.origin!==this.url.origin)return;const i=n.data;e(i)&&(t(i),window.removeEventListener("message",r),this.listeners.delete(r))};window.addEventListener("message",r),this.listeners.set(r,{reject:n})}),this.disconnect=()=>{var e;(e=this.popup)&&!e.closed&&e.close(),this.popup=null,this.listeners.forEach(({reject:e},t)=>{e(xN.userRejectedRequest("Request rejected")),window.removeEventListener("message",t)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(pL("communicator.popup_setup.started",{action:uL.unknown,componentType:cL.unknown},hL.high),this.popup=await PL(this.url),this.onMessage(({event:e})=>"PopupUnload"===e).then(()=>{this.disconnect(),pL("communicator.popup_unload.received",{action:uL.unknown,componentType:cL.unknown},hL.high)}).catch(()=>{}),this.onMessage(({event:e})=>"PopupLoaded"===e).then(e=>{this.postMessage({requestId:e.id,data:{version:oN,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw _N.internal();return pL("communicator.popup_setup.completed",{action:uL.unknown,componentType:cL.unknown},hL.high),this.popup})),this.url=new URL(e),this.metadata=t,this.preference=n}}function TL(e){return void 0!==e.errorMessage}function RL(e){const t=yN(function(e){var t;if("string"==typeof e)return{message:e,code:hN.internal};if(TL(e)){const n=e.errorMessage,r=null!==(t=e.errorCode)&&void 0!==t?t:n.match(/(denied|rejected)/i)?fN.userRejectedRequest:void 0;return Object.assign(Object.assign({},e),{message:n,code:r,data:{method:e.method}})}return e}(e),{shouldIncludeStack:!0}),n=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return n.searchParams.set("version",oN),n.searchParams.set("code",t.code.toString()),n.searchParams.set("message",t.message),Object.assign(Object.assign({},t),{docUrl:n.href})}class NL extends SA{}let LL=class e{constructor(e,t){this.scope=e,this.module=t}storeObject(e,t){this.setItem(e,JSON.stringify(t))}loadObject(e){const t=this.getItem(e);return t?JSON.parse(t):void 0}setItem(e,t){localStorage.setItem(this.scopedKey(e),t)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),t=[];for(let n=0;n<localStorage.length;n++){const r=localStorage.key(n);"string"==typeof r&&r.startsWith(e)&&t.push(r)}t.forEach(e=>localStorage.removeItem(e))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new e("CBWSDK").clear(),new e("walletlink").clear()}};const BL=jO(()=>({correlationIds:new Map})),jL=e=>BL.getState().correlationIds.get(e),DL=(e,t)=>{BL.setState(n=>{const r=new Map(n.correlationIds);return r.set(e,t),{correlationIds:r}})},UL=e=>{BL.setState(t=>{const n=new Map(t.correlationIds);return n.delete(e),{correlationIds:n}})},FL=()=>{BL.setState({correlationIds:new Map})},$L=e=>"message"in e&&"string"==typeof e.message?e.message:"",zL=jO(()=>({}));function HL(e){e.forEach(e=>{var t,n,r,i,o,s,a,c;if(!e.rpcUrl)return;const l=LS({chain:d_({id:e.id,rpcUrls:{default:{http:[e.rpcUrl]}},name:null!==(n=null===(t=e.nativeCurrency)||void 0===t?void 0:t.name)&&void 0!==n?n:"",nativeCurrency:{name:null!==(i=null===(r=e.nativeCurrency)||void 0===r?void 0:r.name)&&void 0!==i?i:"",symbol:null!==(s=null===(o=e.nativeCurrency)||void 0===o?void 0:o.symbol)&&void 0!==s?s:"",decimals:null!==(c=null===(a=e.nativeCurrency)||void 0===a?void 0:a.decimal)&&void 0!==c?c:18}}),transport:$S(e.rpcUrl)}),u=function(e){const{client:t,key:n="bundler",name:r="Bundler Client",paymaster:i,paymasterContext:o,transport:s,userOperation:a}=e;return Object.assign(MS({...e,chain:e.chain??(null==t?void 0:t.chain),key:n,name:r,transport:s,type:"bundlerClient"}),{client:t,paymaster:i,paymasterContext:o,userOperation:a}).extend(eN)}({client:l,transport:$S(e.rpcUrl)});zL.setState({[e.id]:{client:l,bundlerClient:u}})})}function qL(e){var t;return null===(t=zL.getState()[e])||void 0===t?void 0:t.client}function WL(e,t,n){if(null==e)throw null!=t?t:_N.invalidParams({message:"value must be present",data:e})}function KL(e,t){if(!Array.isArray(e))throw _N.invalidParams({message:null!=t?t:"value must be an array",data:e})}function GL(e){if("object"!=typeof e||null===e)throw _N.internal("sub account info is not an object");if(!("address"in e))throw _N.internal("sub account is invalid");if("address"in e&&"string"==typeof e.address&&!Fp(e.address))throw _N.internal("sub account address is invalid");if("factory"in e&&"string"==typeof e.factory&&!Fp(e.factory))throw _N.internal("sub account factory address is invalid");if("factoryData"in e&&"string"==typeof e.factoryData&&!Jh(e.factoryData))throw _N.internal("sub account factory data is invalid")}function VL(e){switch(e){case"public":return"spki";case"private":return"pkcs8"}}async function ZL(e,t){const n=VL(e),r=await crypto.subtle.exportKey(n,t);return DN(new Uint8Array(r))}async function YL(e,t){const n=VL(e),r=UN(t).buffer;return await crypto.subtle.importKey(n,new Uint8Array(r),{name:"ECDH",namedCurve:"P-256"},!0,"private"===e?["deriveKey"]:[])}async function JL(e,t){return async function(e,t){const n=crypto.getRandomValues(new Uint8Array(12));return{iv:n,cipherText:await crypto.subtle.encrypt({name:"AES-GCM",iv:n},e,(new TextEncoder).encode(t))}}(t,JSON.stringify(e,(e,t)=>{if(!(t instanceof Error))return t;const n=t;return Object.assign(Object.assign({},n.code?{code:n.code}:{}),{message:n.message})}))}async function QL(e,t){return JSON.parse(await async function(e,{iv:t,cipherText:n}){const r=await crypto.subtle.decrypt({name:"AES-GCM",iv:t},e,n);return(new TextDecoder).decode(r)}(t,e))}class XL extends Error{constructor(e,t={}){const n=(()=>{var e;if(t.cause instanceof XL){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return(null==(e=t.cause)?void 0:e.message)?t.cause.message:t.details})(),r=t.cause instanceof XL&&t.cause.docsPath||t.docsPath,i=`https://oxlib.sh${r??""}`;super([e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${i}`:void 0]:[]].filter(e=>"string"==typeof e).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{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,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:"ox@0.1.1"}),this.cause=t.cause,this.details=n,this.docs=i,this.docsPath=r,this.shortMessage=e}walk(e){return eB(this,e)}}function eB(e,t){return(null==t?void 0:t(e))?e:e&&"object"==typeof e&&"cause"in e&&e.cause?eB(e.cause,t):t?null:e}
41
41
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function tB(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(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 nB(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 rB(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function iB(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function oB(e,t){return e<<32-t|e>>>t}function sB(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),tB(e),e}let aB=class{};function cB(e){const t=t=>e().update(sB(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function lB(e,t,n){return e&t^~e&n}function uB(e,t,n){return e&t^e&n^t&n}let dB=class extends aB{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=iB(this.buffer)}update(e){nB(this),tB(e=sB(e));const{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s===r){const t=iB(e);for(;r<=i-o;o+=r)this.process(t,o);continue}n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){nB(this),function(e,t){tB(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;t[o++]=128,rB(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(n,0),o=0);for(let u=o;u<r;u++)t[u]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=iB(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)s.setUint32(4*u,l[u],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=i,e.length=r,e.pos=s,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}};const hB=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fB=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),pB=new Uint32Array(64);let mB=class extends dB{constructor(e=32){super(64,e,8,!1),this.A=0|hB[0],this.B=0|hB[1],this.C=0|hB[2],this.D=0|hB[3],this.E=0|hB[4],this.F=0|hB[5],this.G=0|hB[6],this.H=0|hB[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let u=0;u<16;u++,t+=4)pB[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const e=pB[u-15],t=pB[u-2],n=oB(e,7)^oB(e,18)^e>>>3,r=oB(t,17)^oB(t,19)^t>>>10;pB[u]=r+pB[u-7]+n+pB[u-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:c,H:l}=this;for(let u=0;u<64;u++){const e=l+(oB(s,6)^oB(s,11)^oB(s,25))+lB(s,a,c)+fB[u]+pB[u]|0,t=(oB(n,2)^oB(n,13)^oB(n,22))+uB(n,r,i)|0;l=c,c=a,a=s,s=o+e|0,o=i,i=r,r=n,n=e+t|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,o,s,a,c,l)}roundClean(){rB(pB)}destroy(){this.set(0,0,0,0,0,0,0,0),rB(this.buffer)}};const gB=cB(()=>new mB),yB="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;
42
42
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
43
43
  function bB(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function vB(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function wB(e,...t){if(!bB(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 EB(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");vB(e.outputLen),vB(e.blockLen)}function _B(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 xB(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function kB(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function SB(e,t){return e<<32-t|e>>>t}const CB=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),IB=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function AB(e){if(wB(e),CB)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=IB[e[n]];return t}const PB=48,MB=57,OB=65,TB=70,RB=97,NB=102;function LB(e){return e>=PB&&e<=MB?e-PB:e>=OB&&e<=TB?e-(OB-10):e>=RB&&e<=NB?e-(RB-10):void 0}function BB(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(CB)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let i=0,o=0;i<n;i++,o+=2){const t=LB(e.charCodeAt(o)),n=LB(e.charCodeAt(o+1));if(void 0===t||void 0===n){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[i]=16*t+n}return r}function jB(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),wB(e),e}function DB(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];wB(n),t+=n.length}const n=new Uint8Array(t);for(let r=0,i=0;r<e.length;r++){const t=e[r];n.set(t,i),i+=t.length}return n}let UB=class{};function FB(e){const t=t=>e().update(jB(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function $B(e=32){if(yB&&"function"==typeof yB.getRandomValues)return yB.getRandomValues(new Uint8Array(e));if(yB&&"function"==typeof yB.randomBytes)return Uint8Array.from(yB.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}