@weave-sdk/widget 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -111,7 +111,7 @@ ${sR(h)}`),super(t.shortMessage,{cause:t,docsPath:r,metaMessages:[...t.metaMessa
111
111
  *
112
112
  * This source code is licensed under the MIT license found in the
113
113
  * LICENSE file in the root directory of this source tree.
114
- */var B6;function l7(){return B6||(B6=1,process.env.NODE_ENV!=="production"&&function(){function e(u,l){return u===l&&(u!==0||1/u===1/l)||u!==u&&l!==l}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=ce,n=O6(),r=typeof Object.is=="function"?Object.is:e,i=n.useSyncExternalStore,s=t.useRef,o=t.useEffect,a=t.useMemo,c=t.useDebugValue;Km.useSyncExternalStoreWithSelector=function(u,l,d,f,h){var m=s(null);if(m.current===null){var y={hasValue:!1,value:null};m.current=y}else y=m.current;m=a(function(){function b(M){if(!E){if(E=!0,v=M,M=f(M),h!==void 0&&y.hasValue){var L=y.value;if(h(L,M))return A=L}return A=M}if(L=A,r(v,M))return L;var U=f(M);return h!==void 0&&h(L,U)?(v=M,L):(v=M,A=U)}var E=!1,v,A,P=d===void 0?null:d;return[function(){return b(l())},P===null?void 0:function(){return b(P())}]},[l,d,f,h]);var w=i(u,m[0],m[1]);return o(function(){y.hasValue=!0,y.value=w},[w]),c(w),w},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Km}process.env.NODE_ENV==="production"?Wm.exports=u7():Wm.exports=l7();var d7=Wm.exports;const Jm=e=>typeof e=="object"&&!Array.isArray(e);function f7(e,t,n=t,r=ro){const i=ce.useRef([]),s=d7.useSyncExternalStoreWithSelector(e,t,n,o=>o,(o,a)=>{if(Jm(o)&&Jm(a)&&i.current.length){for(const c of i.current)if(!r(o[c],a[c]))return!1;return!0}return r(o,a)});return ce.useMemo(()=>{if(Jm(s)){const o={...s};let a={};for(const[c,u]of Object.entries(o))a={...a,[c]:{configurable:!1,enumerable:!0,get:()=>(i.current.includes(c)||i.current.push(c),u)}};return Object.defineProperties(o,a),o}return s},[s])}function Zm(e={}){const t=Or(e);return f7(n=>OB(t,{onChange:n}),()=>y6(t))}var Aa=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(){}},h7=(oI=class extends Aa{constructor(){super();Pe(this,No);Pe(this,Rs);Pe(this,Ac);ye(this,Ac,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){V(this,Rs)||this.setEventListener(V(this,Ac))}onUnsubscribe(){var t;this.hasListeners()||((t=V(this,Rs))==null||t.call(this),ye(this,Rs,void 0))}setEventListener(t){var n;ye(this,Ac,t),(n=V(this,Rs))==null||n.call(this),ye(this,Rs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){V(this,No)!==t&&(ye(this,No,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof V(this,No)=="boolean"?V(this,No):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},No=new WeakMap,Rs=new WeakMap,Ac=new WeakMap,oI),Ym=new h7,p7={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},m7=(aI=class{constructor(){Pe(this,ci,p7);Pe(this,Lo,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&V(this,Lo)&&e!==V(this,ci)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:V(this,ci),provider:e}),ye(this,ci,e),process.env.NODE_ENV!=="production"&&ye(this,Lo,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&ye(this,Lo,!0),V(this,ci).setTimeout(e,t)}clearTimeout(e){V(this,ci).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&ye(this,Lo,!0),V(this,ci).setInterval(e,t)}clearInterval(e){V(this,ci).clearInterval(e)}},ci=new WeakMap,Lo=new WeakMap,aI),io=new m7;function g7(e){setTimeout(e,0)}var y7=typeof window>"u"||"Deno"in globalThis;function Nn(){}function b7(e,t){return typeof e=="function"?e(t):e}function Qm(e){return typeof e=="number"&&e>=0&&e!==1/0}function N6(e,t){return Math.max(e+(t||0)-Date.now(),0)}function hs(e,t){return typeof e=="function"?e(t):e}function hr(e,t){return typeof e=="function"?e(t):e}function L6(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==Xm(o,t.options))return!1}else if(!Cu(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||i&&i!==t.state.fetchStatus||s&&!s(t))}function j6(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(so(t.options.mutationKey)!==so(s))return!1}else if(!Cu(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Xm(e,t){return((t==null?void 0:t.queryKeyHashFn)||so)(e)}function so(e){return JSON.stringify(e,(t,n)=>tg(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Cu(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Cu(e[n],t[n])):!1}var w7=Object.prototype.hasOwnProperty;function eg(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=$6(e)&&$6(t);if(!r&&!(tg(e)&&tg(t)))return t;const s=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),a=o.length,c=r?new Array(a):{};let u=0;for(let l=0;l<a;l++){const d=r?l:o[l],f=e[d],h=t[d];if(f===h){c[d]=f,(r?l<s:w7.call(e,d))&&u++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){c[d]=h;continue}const m=eg(f,h,n+1);c[d]=m,m===f&&u++}return s===a&&u===s?e:c}function Yd(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 $6(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function tg(e){if(!F6(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!F6(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function F6(e){return Object.prototype.toString.call(e)==="[object Object]"}function v7(e){return new Promise(t=>{io.setTimeout(t,e)})}function ng(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return eg(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return eg(e,t)}return t}function _7(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function E7(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Qd=Symbol();function D6(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Qd&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Qd?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function rg(e,t){return typeof e=="function"?e(...t):!!e}function x7(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),e}var Pu=(()=>{let e=()=>y7;return{isServer(){return e()},setIsServer(t){e=t}}})();function ig(){let e,t;const n=new Promise((i,s)=>{e=i,t=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}var S7=g7;function k7(){let e=[],t=0,n=a=>{a()},r=a=>{a()},i=S7;const s=a=>{t?e.push(a):i(()=>{n(a)})},o=()=>{const a=e;e=[],a.length&&i(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||o()}return c},batchCalls:a=>(...c)=>{s(()=>{a(...c)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}var nn=k7(),A7=(cI=class extends Aa{constructor(){super();Pe(this,Ic,!0);Pe(this,Ts);Pe(this,Cc);ye(this,Cc,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){V(this,Ts)||this.setEventListener(V(this,Cc))}onUnsubscribe(){var t;this.hasListeners()||((t=V(this,Ts))==null||t.call(this),ye(this,Ts,void 0))}setEventListener(t){var n;ye(this,Cc,t),(n=V(this,Ts))==null||n.call(this),ye(this,Ts,t(this.setOnline.bind(this)))}setOnline(t){V(this,Ic)!==t&&(ye(this,Ic,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return V(this,Ic)}},Ic=new WeakMap,Ts=new WeakMap,Cc=new WeakMap,cI),Xd=new A7;function I7(e){return Math.min(1e3*2**e,3e4)}function U6(e){return(e??"online")==="online"?Xd.isOnline():!0}var sg=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function H6(e){let t=!1,n=0,r;const i=ig(),s=()=>i.status!=="pending",o=y=>{var w;if(!s()){const b=new sg(y);f(b),(w=e.onCancel)==null||w.call(e,b)}},a=()=>{t=!0},c=()=>{t=!1},u=()=>Ym.isFocused()&&(e.networkMode==="always"||Xd.isOnline())&&e.canRun(),l=()=>U6(e.networkMode)&&e.canRun(),d=y=>{s()||(r==null||r(),i.resolve(y))},f=y=>{s()||(r==null||r(),i.reject(y))},h=()=>new Promise(y=>{var w;r=b=>{(s()||u())&&y(b)},(w=e.onPause)==null||w.call(e)}).then(()=>{var y;r=void 0,s()||(y=e.onContinue)==null||y.call(e)}),m=()=>{if(s())return;let y;const w=n===0?e.initialPromise:void 0;try{y=w??e.fn()}catch(b){y=Promise.reject(b)}Promise.resolve(y).then(d).catch(b=>{var M;if(s())return;const E=e.retry??(Pu.isServer()?0:3),v=e.retryDelay??I7,A=typeof v=="function"?v(n,b):v,P=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,b);if(t||!P){f(b);return}n++,(M=e.onFail)==null||M.call(e,n,b),v7(A).then(()=>u()?void 0:h()).then(()=>{t?f(b):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r==null||r(),i),cancelRetry:a,continueRetry:c,canStart:l,start:()=>(l()?m():h().then(m),i)}}var z6=(uI=class{constructor(){Pe(this,jo)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Qm(this.gcTime)&&ye(this,jo,io.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Pu.isServer()?1/0:5*60*1e3))}clearGcTimeout(){V(this,jo)!==void 0&&(io.clearTimeout(V(this,jo)),ye(this,jo,void 0))}},jo=new WeakMap,uI),C7=(lI=class extends z6{constructor(t){super();Pe(this,cr);Pe(this,$o);Pe(this,Pc);Pe(this,Sr);Pe(this,Fo);Pe(this,pn);Pe(this,zl);Pe(this,Do);ye(this,Do,!1),ye(this,zl,t.defaultOptions),this.setOptions(t.options),this.observers=[],ye(this,Fo,t.client),ye(this,Sr,V(this,Fo).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ye(this,$o,q6(this.options)),this.state=t.state??V(this,$o),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=V(this,pn))==null?void 0:t.promise}setOptions(t){if(this.options={...V(this,zl),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=q6(this.options);n.data!==void 0&&(this.setState(G6(n.data,n.dataUpdatedAt)),ye(this,$o,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&V(this,Sr).remove(this)}setData(t,n){const r=ng(this.state.data,t,this.options);return je(this,cr,Yi).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){je(this,cr,Yi).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,i;const n=(r=V(this,pn))==null?void 0:r.promise;return(i=V(this,pn))==null||i.cancel(t),n?n.then(Nn).catch(Nn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return V(this,$o)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>hr(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Qd||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>hs(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!N6(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=V(this,pn))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=V(this,pn))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),V(this,Sr).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(V(this,pn)&&(V(this,Do)||je(this,cr,wI).call(this)?V(this,pn).cancel({revert:!0}):V(this,pn).cancelRetry()),this.scheduleGc()),V(this,Sr).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||je(this,cr,Yi).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,l,d,f,h,m,y,w,b,E,v;if(this.state.fetchStatus!=="idle"&&((c=V(this,pn))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(V(this,pn))return V(this,pn).continueRetry(),V(this,pn).promise}if(t&&this.setOptions(t),!this.options.queryFn){const A=this.observers.find(P=>P.options.queryFn);A&&this.setOptions(A.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,i=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(ye(this,Do,!0),r.signal)})},s=()=>{const A=D6(this.options,n),M=(()=>{const L={client:V(this,Fo),queryKey:this.queryKey,meta:this.meta};return i(L),L})();return ye(this,Do,!1),this.options.persister?this.options.persister(A,M,this):A(M)},a=(()=>{const A={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:V(this,Fo),state:this.state,fetchFn:s};return i(A),A})();(u=this.options.behavior)==null||u.onFetch(a,this),ye(this,Pc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((l=a.fetchOptions)==null?void 0:l.meta))&&je(this,cr,Yi).call(this,{type:"fetch",meta:(d=a.fetchOptions)==null?void 0:d.meta}),ye(this,pn,H6({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:A=>{A instanceof sg&&A.revert&&this.setState({...V(this,Pc),fetchStatus:"idle"}),r.abort()},onFail:(A,P)=>{je(this,cr,Yi).call(this,{type:"failed",failureCount:A,error:P})},onPause:()=>{je(this,cr,Yi).call(this,{type:"pause"})},onContinue:()=>{je(this,cr,Yi).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const A=await V(this,pn).start();if(A===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(A),(h=(f=V(this,Sr).config).onSuccess)==null||h.call(f,A,this),(y=(m=V(this,Sr).config).onSettled)==null||y.call(m,A,this.state.error,this),A}catch(A){if(A instanceof sg){if(A.silent)return V(this,pn).promise;if(A.revert){if(this.state.data===void 0)throw A;return this.state.data}}throw je(this,cr,Yi).call(this,{type:"error",error:A}),(b=(w=V(this,Sr).config).onError)==null||b.call(w,A,this),(v=(E=V(this,Sr).config).onSettled)==null||v.call(E,this.state.data,A,this),A}finally{this.scheduleGc()}}},$o=new WeakMap,Pc=new WeakMap,Sr=new WeakMap,Fo=new WeakMap,pn=new WeakMap,zl=new WeakMap,Do=new WeakMap,cr=new WeakSet,wI=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Yi=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...W6(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...G6(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ye(this,Pc,t.manual?i:void 0),i;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),nn.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),V(this,Sr).notify({query:this,type:"updated",action:t})})},lI);function W6(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:U6(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function G6(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function q6(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?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 P7=(dI=class extends Aa{constructor(t,n){super();Pe(this,ct);Pe(this,Xn);Pe(this,et);Pe(this,Wl);Pe(this,Dn);Pe(this,Uo);Pe(this,Rc);Pe(this,zi);Pe(this,Os);Pe(this,Gl);Pe(this,Tc);Pe(this,Oc);Pe(this,Ho);Pe(this,zo);Pe(this,Ms);Pe(this,Mc,new Set);this.options=n,ye(this,Xn,t),ye(this,Os,null),ye(this,zi,ig()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(V(this,et).addObserver(this),V6(V(this,et),this.options)?je(this,ct,Kl).call(this):this.updateResult(),je(this,ct,aw).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return og(V(this,et),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return og(V(this,et),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,je(this,ct,cw).call(this),je(this,ct,uw).call(this),V(this,et).removeObserver(this)}setOptions(t){const n=this.options,r=V(this,et);if(this.options=V(this,Xn).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof hr(this.options.enabled,V(this,et))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");je(this,ct,lw).call(this),V(this,et).setOptions(this.options),n._defaulted&&!Yd(this.options,n)&&V(this,Xn).getQueryCache().notify({type:"observerOptionsUpdated",query:V(this,et),observer:this});const i=this.hasListeners();i&&K6(V(this,et),r,this.options,n)&&je(this,ct,Kl).call(this),this.updateResult(),i&&(V(this,et)!==r||hr(this.options.enabled,V(this,et))!==hr(n.enabled,V(this,et))||hs(this.options.staleTime,V(this,et))!==hs(n.staleTime,V(this,et)))&&je(this,ct,iw).call(this);const s=je(this,ct,sw).call(this);i&&(V(this,et)!==r||hr(this.options.enabled,V(this,et))!==hr(n.enabled,V(this,et))||s!==V(this,Ms))&&je(this,ct,ow).call(this,s)}getOptimisticResult(t){const n=V(this,Xn).getQueryCache().build(V(this,Xn),t),r=this.createResult(n,t);return T7(this,r)&&(ye(this,Dn,r),ye(this,Rc,this.options),ye(this,Uo,V(this,et).state)),r}getCurrentResult(){return V(this,Dn)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&V(this,zi).status==="pending"&&V(this,zi).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(t){V(this,Mc).add(t)}getCurrentQuery(){return V(this,et)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=V(this,Xn).defaultQueryOptions(t),r=V(this,Xn).getQueryCache().build(V(this,Xn),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return je(this,ct,Kl).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),V(this,Dn)))}createResult(t,n){var j;const r=V(this,et),i=this.options,s=V(this,Dn),o=V(this,Uo),a=V(this,Rc),u=t!==r?t.state:V(this,Wl),{state:l}=t;let d={...l},f=!1,h;if(n._optimisticResults){const Z=this.hasListeners(),Y=!Z&&V6(t,n),W=Z&&K6(t,r,n,i);(Y||W)&&(d={...d,...W6(l.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:y,status:w}=d;h=d.data;let b=!1;if(n.placeholderData!==void 0&&h===void 0&&w==="pending"){let Z;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(Z=s.data,b=!0):Z=typeof n.placeholderData=="function"?n.placeholderData((j=V(this,Oc))==null?void 0:j.state.data,V(this,Oc)):n.placeholderData,Z!==void 0&&(w="success",h=ng(s==null?void 0:s.data,Z,n),f=!0)}if(n.select&&h!==void 0&&!b)if(s&&h===(o==null?void 0:o.data)&&n.select===V(this,Gl))h=V(this,Tc);else try{ye(this,Gl,n.select),h=n.select(h),h=ng(s==null?void 0:s.data,h,n),ye(this,Tc,h),ye(this,Os,null)}catch(Z){ye(this,Os,Z)}V(this,Os)&&(m=V(this,Os),h=V(this,Tc),y=Date.now(),w="error");const E=d.fetchStatus==="fetching",v=w==="pending",A=w==="error",P=v&&E,M=h!==void 0,U={status:w,fetchStatus:d.fetchStatus,isPending:v,isSuccess:w==="success",isError:A,isInitialLoading:P,isLoading:P,data:h,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:y,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:E,isRefetching:E&&!v,isLoadingError:A&&!M,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:A&&M,isStale:ag(t,n),refetch:this.refetch,promise:V(this,zi),isEnabled:hr(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const Z=U.data!==void 0,Y=U.status==="error"&&!Z,W=g=>{Y?g.reject(U.error):Z&&g.resolve(U.data)},I=()=>{const g=ye(this,zi,U.promise=ig());W(g)},p=V(this,zi);switch(p.status){case"pending":t.queryHash===r.queryHash&&W(p);break;case"fulfilled":(Y||U.data!==p.value)&&I();break;case"rejected":(!Y||U.error!==p.reason)&&I();break}}return U}updateResult(){const t=V(this,Dn),n=this.createResult(V(this,et),this.options);if(ye(this,Uo,V(this,et).state),ye(this,Rc,this.options),V(this,Uo).data!==void 0&&ye(this,Oc,V(this,et)),Yd(n,t))return;ye(this,Dn,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!V(this,Mc).size)return!0;const o=new Set(s??V(this,Mc));return this.options.throwOnError&&o.add("error"),Object.keys(V(this,Dn)).some(a=>{const c=a;return V(this,Dn)[c]!==t[c]&&o.has(c)})};je(this,ct,vI).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&je(this,ct,aw).call(this)}},Xn=new WeakMap,et=new WeakMap,Wl=new WeakMap,Dn=new WeakMap,Uo=new WeakMap,Rc=new WeakMap,zi=new WeakMap,Os=new WeakMap,Gl=new WeakMap,Tc=new WeakMap,Oc=new WeakMap,Ho=new WeakMap,zo=new WeakMap,Ms=new WeakMap,Mc=new WeakMap,ct=new WeakSet,Kl=function(t){je(this,ct,lw).call(this);let n=V(this,et).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Nn)),n},iw=function(){je(this,ct,cw).call(this);const t=hs(this.options.staleTime,V(this,et));if(Pu.isServer()||V(this,Dn).isStale||!Qm(t))return;const r=N6(V(this,Dn).dataUpdatedAt,t)+1;ye(this,Ho,io.setTimeout(()=>{V(this,Dn).isStale||this.updateResult()},r))},sw=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(V(this,et)):this.options.refetchInterval)??!1},ow=function(t){je(this,ct,uw).call(this),ye(this,Ms,t),!(Pu.isServer()||hr(this.options.enabled,V(this,et))===!1||!Qm(V(this,Ms))||V(this,Ms)===0)&&ye(this,zo,io.setInterval(()=>{(this.options.refetchIntervalInBackground||Ym.isFocused())&&je(this,ct,Kl).call(this)},V(this,Ms)))},aw=function(){je(this,ct,iw).call(this),je(this,ct,ow).call(this,je(this,ct,sw).call(this))},cw=function(){V(this,Ho)!==void 0&&(io.clearTimeout(V(this,Ho)),ye(this,Ho,void 0))},uw=function(){V(this,zo)!==void 0&&(io.clearInterval(V(this,zo)),ye(this,zo,void 0))},lw=function(){const t=V(this,Xn).getQueryCache().build(V(this,Xn),this.options);if(t===V(this,et))return;const n=V(this,et);ye(this,et,t),ye(this,Wl,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},vI=function(t){nn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(V(this,Dn))}),V(this,Xn).getQueryCache().notify({query:V(this,et),type:"observerResultsUpdated"})})},dI);function R7(e,t){return hr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function V6(e,t){return R7(e,t)||e.state.data!==void 0&&og(e,t,t.refetchOnMount)}function og(e,t,n){if(hr(t.enabled,e)!==!1&&hs(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ag(e,t)}return!1}function K6(e,t,n,r){return(e!==t||hr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ag(e,n)}function ag(e,t){return hr(t.enabled,e)!==!1&&e.isStaleByTime(hs(t.staleTime,e))}function T7(e,t){return!Yd(e.getCurrentResult(),t)}function J6(e){return{onFetch:(t,n)=>{var l,d,f,h,m;const r=t.options,i=(f=(d=(l=t.fetchOptions)==null?void 0:l.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,s=((h=t.state.data)==null?void 0:h.pages)||[],o=((m=t.state.data)==null?void 0:m.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let y=!1;const w=v=>{x7(v,()=>t.signal,()=>y=!0)},b=D6(t.options,t.fetchOptions),E=async(v,A,P)=>{if(y)return Promise.reject();if(A==null&&v.pages.length)return Promise.resolve(v);const L=(()=>{const Y={client:t.client,queryKey:t.queryKey,pageParam:A,direction:P?"backward":"forward",meta:t.options.meta};return w(Y),Y})(),U=await b(L),{maxPages:j}=t.options,Z=P?E7:_7;return{pages:Z(v.pages,U,j),pageParams:Z(v.pageParams,A,j)}};if(i&&s.length){const v=i==="backward",A=v?O7:Z6,P={pages:s,pageParams:o},M=A(r,P);a=await E(P,M,v)}else{const v=e??s.length;do{const A=c===0?o[0]??r.initialPageParam:Z6(r,a);if(c>0&&A==null)break;a=await E(a,A),c++}while(c<v)}return a};t.options.persister?t.fetchFn=()=>{var y,w;return(w=(y=t.options).persister)==null?void 0:w.call(y,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Z6(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 O7(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var M7=(fI=class extends z6{constructor(t){super();Pe(this,li);Pe(this,ql);Pe(this,ui);Pe(this,Pn);Pe(this,Wo);ye(this,ql,t.client),this.mutationId=t.mutationId,ye(this,Pn,t.mutationCache),ye(this,ui,[]),this.state=t.state||Y6(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){V(this,ui).includes(t)||(V(this,ui).push(t),this.clearGcTimeout(),V(this,Pn).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ye(this,ui,V(this,ui).filter(n=>n!==t)),this.scheduleGc(),V(this,Pn).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){V(this,ui).length||(this.state.status==="pending"?this.scheduleGc():V(this,Pn).remove(this))}continue(){var t;return((t=V(this,Wo))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,a,c,u,l,d,f,h,m,y,w,b,E,v,A,P,M,L;const n=()=>{je(this,li,$s).call(this,{type:"continue"})},r={client:V(this,ql),meta:this.options.meta,mutationKey:this.options.mutationKey};ye(this,Wo,H6({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(U,j)=>{je(this,li,$s).call(this,{type:"failed",failureCount:U,error:j})},onPause:()=>{je(this,li,$s).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>V(this,Pn).canRun(this)}));const i=this.state.status==="pending",s=!V(this,Wo).canStart();try{if(i)n();else{je(this,li,$s).call(this,{type:"pending",variables:t,isPaused:s}),V(this,Pn).config.onMutate&&await V(this,Pn).config.onMutate(t,this,r);const j=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t,r));j!==this.state.context&&je(this,li,$s).call(this,{type:"pending",context:j,variables:t,isPaused:s})}const U=await V(this,Wo).start();return await((u=(c=V(this,Pn).config).onSuccess)==null?void 0:u.call(c,U,t,this.state.context,this,r)),await((d=(l=this.options).onSuccess)==null?void 0:d.call(l,U,t,this.state.context,r)),await((h=(f=V(this,Pn).config).onSettled)==null?void 0:h.call(f,U,null,this.state.variables,this.state.context,this,r)),await((y=(m=this.options).onSettled)==null?void 0:y.call(m,U,null,t,this.state.context,r)),je(this,li,$s).call(this,{type:"success",data:U}),U}catch(U){try{await((b=(w=V(this,Pn).config).onError)==null?void 0:b.call(w,U,t,this.state.context,this,r))}catch(j){Promise.reject(j)}try{await((v=(E=this.options).onError)==null?void 0:v.call(E,U,t,this.state.context,r))}catch(j){Promise.reject(j)}try{await((P=(A=V(this,Pn).config).onSettled)==null?void 0:P.call(A,void 0,U,this.state.variables,this.state.context,this,r))}catch(j){Promise.reject(j)}try{await((L=(M=this.options).onSettled)==null?void 0:L.call(M,void 0,U,t,this.state.context,r))}catch(j){Promise.reject(j)}throw je(this,li,$s).call(this,{type:"error",error:U}),U}finally{V(this,Pn).runNext(this)}}},ql=new WeakMap,ui=new WeakMap,Pn=new WeakMap,Wo=new WeakMap,li=new WeakSet,$s=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),nn.batch(()=>{V(this,ui).forEach(r=>{r.onMutationUpdate(t)}),V(this,Pn).notify({mutation:this,type:"updated",action:t})})},fI);function Y6(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var B7=(hI=class extends Aa{constructor(t={}){super();Pe(this,Wi);Pe(this,Hr);Pe(this,Vl);this.config=t,ye(this,Wi,new Set),ye(this,Hr,new Map),ye(this,Vl,0)}build(t,n,r){const i=new M7({client:t,mutationCache:this,mutationId:++O0(this,Vl)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){V(this,Wi).add(t);const n=ef(t);if(typeof n=="string"){const r=V(this,Hr).get(n);r?r.push(t):V(this,Hr).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(V(this,Wi).delete(t)){const n=ef(t);if(typeof n=="string"){const r=V(this,Hr).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&V(this,Hr).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=ef(t);if(typeof n=="string"){const r=V(this,Hr).get(n),i=r==null?void 0:r.find(s=>s.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r;const n=ef(t);if(typeof n=="string"){const i=(r=V(this,Hr).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){nn.batch(()=>{V(this,Wi).forEach(t=>{this.notify({type:"removed",mutation:t})}),V(this,Wi).clear(),V(this,Hr).clear()})}getAll(){return Array.from(V(this,Wi))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>j6(n,r))}findAll(t={}){return this.getAll().filter(n=>j6(t,n))}notify(t){nn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return nn.batch(()=>Promise.all(t.map(n=>n.continue().catch(Nn))))}},Wi=new WeakMap,Hr=new WeakMap,Vl=new WeakMap,hI);function ef(e){var t;return(t=e.options.scope)==null?void 0:t.id}var N7=(pI=class extends Aa{constructor(t,n){super();Pe(this,Vi);Pe(this,Gi);Pe(this,Bs);Pe(this,er);Pe(this,qi);ye(this,Gi,t),this.setOptions(n),this.bindMethods(),je(this,Vi,M0).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=V(this,Gi).defaultMutationOptions(t),Yd(this.options,n)||V(this,Gi).getMutationCache().notify({type:"observerOptionsUpdated",mutation:V(this,er),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&so(n.mutationKey)!==so(this.options.mutationKey)?this.reset():((r=V(this,er))==null?void 0:r.state.status)==="pending"&&V(this,er).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=V(this,er))==null||t.removeObserver(this)}onMutationUpdate(t){je(this,Vi,M0).call(this),je(this,Vi,dw).call(this,t)}getCurrentResult(){return V(this,Bs)}reset(){var t;(t=V(this,er))==null||t.removeObserver(this),ye(this,er,void 0),je(this,Vi,M0).call(this),je(this,Vi,dw).call(this)}mutate(t,n){var r;return ye(this,qi,n),(r=V(this,er))==null||r.removeObserver(this),ye(this,er,V(this,Gi).getMutationCache().build(V(this,Gi),this.options)),V(this,er).addObserver(this),V(this,er).execute(t)}},Gi=new WeakMap,Bs=new WeakMap,er=new WeakMap,qi=new WeakMap,Vi=new WeakSet,M0=function(){var n;const t=((n=V(this,er))==null?void 0:n.state)??Y6();ye(this,Bs,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},dw=function(t){nn.batch(()=>{var n,r,i,s,o,a,c,u;if(V(this,qi)&&this.hasListeners()){const l=V(this,Bs).variables,d=V(this,Bs).context,f={client:V(this,Gi),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(n=V(this,qi)).onSuccess)==null||r.call(n,t.data,l,d,f)}catch(h){Promise.reject(h)}try{(s=(i=V(this,qi)).onSettled)==null||s.call(i,t.data,null,l,d,f)}catch(h){Promise.reject(h)}}else if((t==null?void 0:t.type)==="error"){try{(a=(o=V(this,qi)).onError)==null||a.call(o,t.error,l,d,f)}catch(h){Promise.reject(h)}try{(u=(c=V(this,qi)).onSettled)==null||u.call(c,void 0,t.error,l,d,f)}catch(h){Promise.reject(h)}}}this.listeners.forEach(l=>{l(V(this,Bs))})})},pI),L7=(mI=class extends Aa{constructor(t={}){super();Pe(this,di);this.config=t,ye(this,di,new Map)}build(t,n,r){const i=n.queryKey,s=n.queryHash??Xm(i,n);let o=this.get(s);return o||(o=new C7({client:t,queryKey:i,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(o)),o}add(t){V(this,di).has(t.queryHash)||(V(this,di).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=V(this,di).get(t.queryHash);n&&(t.destroy(),n===t&&V(this,di).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){nn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return V(this,di).get(t)}getAll(){return[...V(this,di).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>L6(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>L6(t,r)):n}notify(t){nn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){nn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){nn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},di=new WeakMap,mI),j7=(gI=class{constructor(e={}){Pe(this,Ft);Pe(this,Ns);Pe(this,Ls);Pe(this,Bc);Pe(this,Nc);Pe(this,js);Pe(this,Lc);Pe(this,jc);ye(this,Ft,e.queryCache||new L7),ye(this,Ns,e.mutationCache||new B7),ye(this,Ls,e.defaultOptions||{}),ye(this,Bc,new Map),ye(this,Nc,new Map),ye(this,js,0)}mount(){O0(this,js)._++,V(this,js)===1&&(ye(this,Lc,Ym.subscribe(async e=>{e&&(await this.resumePausedMutations(),V(this,Ft).onFocus())})),ye(this,jc,Xd.subscribe(async e=>{e&&(await this.resumePausedMutations(),V(this,Ft).onOnline())})))}unmount(){var e,t;O0(this,js)._--,V(this,js)===0&&((e=V(this,Lc))==null||e.call(this),ye(this,Lc,void 0),(t=V(this,jc))==null||t.call(this),ye(this,jc,void 0))}isFetching(e){return V(this,Ft).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return V(this,Ns).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=V(this,Ft).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=V(this,Ft).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(hs(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return V(this,Ft).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=V(this,Ft).get(r.queryHash),s=i==null?void 0:i.state.data,o=b7(t,s);if(o!==void 0)return V(this,Ft).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return nn.batch(()=>V(this,Ft).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=V(this,Ft).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=V(this,Ft);nn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=V(this,Ft);return nn.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=nn.batch(()=>V(this,Ft).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Nn).catch(Nn)}invalidateQueries(e,t={}){return nn.batch(()=>(V(this,Ft).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=nn.batch(()=>V(this,Ft).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(Nn)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Nn)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=V(this,Ft).build(this,t);return n.isStaleByTime(hs(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Nn).catch(Nn)}fetchInfiniteQuery(e){return e.behavior=J6(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Nn).catch(Nn)}ensureInfiniteQueryData(e){return e.behavior=J6(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Xd.isOnline()?V(this,Ns).resumePausedMutations():Promise.resolve()}getQueryCache(){return V(this,Ft)}getMutationCache(){return V(this,Ns)}getDefaultOptions(){return V(this,Ls)}setDefaultOptions(e){ye(this,Ls,e)}setQueryDefaults(e,t){V(this,Bc).set(so(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...V(this,Bc).values()],n={};return t.forEach(r=>{Cu(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){V(this,Nc).set(so(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...V(this,Nc).values()],n={};return t.forEach(r=>{Cu(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...V(this,Ls).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Xm(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Qd&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...V(this,Ls).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){V(this,Ft).clear(),V(this,Ns).clear()}},Ft=new WeakMap,Ns=new WeakMap,Ls=new WeakMap,Bc=new WeakMap,Nc=new WeakMap,js=new WeakMap,Lc=new WeakMap,jc=new WeakMap,gI);function $7(e){return JSON.stringify(e,(t,n)=>F7(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):typeof n=="bigint"?n.toString():n)}function F7(e){if(!Q6(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!Q6(n)||!n.hasOwnProperty("isPrototypeOf"))}function Q6(e){return Object.prototype.toString.call(e)==="[object Object]"}function D7(e){const{_defaulted:t,behavior:n,gcTime:r,initialData:i,initialDataUpdatedAt:s,maxPages:o,meta:a,networkMode:c,queryFn:u,queryHash:l,queryKey:d,queryKeyHashFn:f,retry:h,retryDelay:m,structuralSharing:y,getPreviousPageParam:w,getNextPageParam:b,initialPageParam:E,_optimisticResults:v,enabled:A,notifyOnChangeProps:P,placeholderData:M,refetchInterval:L,refetchIntervalInBackground:U,refetchOnMount:j,refetchOnReconnect:Z,refetchOnWindowFocus:Y,retryOnMount:W,select:I,staleTime:p,suspense:g,throwOnError:S,config:R,connector:T,query:B,...$}=e;return $}function U7(e){return{mutationFn(t){return dB(e,t)},mutationKey:["connect"]}}function H7(e){return{mutationFn(t){return EB(e,t)},mutationKey:["disconnect"]}}function z7(e,t={}){return{async queryFn({queryKey:n}){const{address:r,scopeKey:i,...s}=n[1];if(!r)throw new Error("address is required");return await AB(e,{...s,address:r})??null},queryKey:W7(t)}}function W7(e={}){return["balance",D7(e)]}function G7(e){return{mutationFn(t){return CB(e,t)},mutationKey:["sendTransaction"]}}function q7(e){return{mutationFn(t){return RB(e,t)},mutationKey:["switchChain"]}}function V7(e){return{mutationFn(t){return LB(e,t)},mutationKey:["writeContract"]}}var X6=en.createContext(void 0),e5=e=>{const t=en.useContext(X6);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},K7=({client:e,children:t})=>(en.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),C.jsx(X6.Provider,{value:e,children:t})),t5=en.createContext(!1),J7=()=>en.useContext(t5);t5.Provider;function Z7(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Y7=en.createContext(Z7()),Q7=()=>en.useContext(Y7),X7=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?rg(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},eN=e=>{en.useEffect(()=>{e.clearReset()},[e])},tN=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||rg(n,[e.error,r])),nN=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},rN=(e,t)=>e.isLoading&&e.isFetching&&!t,iN=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,n5=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function sN(e,t,n){var f,h,m,y;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=J7(),i=Q7(),s=e5(),o=s.defaultQueryOptions(e);(h=(f=s.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||h.call(f,o);const a=s.getQueryCache().get(o.queryHash);process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),o._optimisticResults=r?"isRestoring":"optimistic",nN(o),X7(o,i,a),eN(i);const c=!s.getQueryCache().get(o.queryHash),[u]=en.useState(()=>new t(s,o)),l=u.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(en.useSyncExternalStore(en.useCallback(w=>{const b=d?u.subscribe(nn.batchCalls(w)):Nn;return u.updateResult(),b},[u,d]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),en.useEffect(()=>{u.setOptions(o)},[o,u]),iN(o,l))throw n5(o,u,i);if(tN({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw l.error;if((y=(m=s.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||y.call(m,o,l),o.experimental_prefetchInRender&&!Pu.isServer()&&rN(l,r)){const w=c?n5(o,u,i):a==null?void 0:a.promise;w==null||w.catch(Nn).finally(()=>{u.updateResult()})}return o.notifyOnChangeProps?l:u.trackResult(l)}function oN(e,t){return sN(e,P7)}function Ru(e,t){const n=e5(),[r]=en.useState(()=>new N7(n,e));en.useEffect(()=>{r.setOptions(e)},[r,e]);const i=en.useSyncExternalStore(en.useCallback(o=>r.subscribe(nn.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=en.useCallback((o,a)=>{r.mutate(o,a).catch(Nn)},[r]);if(i.error&&rg(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}function aN(e){const t=oN({...e,queryKeyHashFn:$7});return t.queryKey=e.queryKey,t}function cN(e={}){const t=Or(e);return ce.useSyncExternalStore(n=>MB(t,{onChange:n}),()=>w6(t),()=>w6(t))}function cg(e={}){const{address:t,query:n={}}=e,r=Or(e),i=cN({config:r}),s=z7(r,{...e,chainId:e.chainId??i}),o=!!(t&&(n.enabled??!0));return aN({...n,...s,enabled:o})}function uN(e={}){const t=Or(e);return ce.useSyncExternalStore(n=>o7(t,{onChange:n}),()=>v6(t),()=>v6(t))}function lN(e={}){const t=Or(e);return ce.useSyncExternalStore(n=>NB(t,{onChange:n}),()=>_6(t),()=>_6(t))}function dN(e={}){const{mutation:t}=e,n=Or(e),r=U7(n),{mutate:i,mutateAsync:s,...o}=Ru({...t,...r});return ce.useEffect(()=>n.subscribe(({status:a})=>a,(a,c)=>{c==="connected"&&a==="disconnected"&&o.reset()}),[n,o.reset]),{...o,connect:i,connectAsync:s,connectors:lN({config:n})}}function fN(e={}){const t=Or(e);return ce.useSyncExternalStore(n=>BB(t,{onChange:n}),()=>Fm(t),()=>Fm(t))}function hN(e={}){const{mutation:t}=e,n=Or(e),r=H7(n),{mutate:i,mutateAsync:s,...o}=Ru({...t,...r});return{...o,connectors:fN({config:n}).map(a=>a.connector),disconnect:i,disconnectAsync:s}}function pN(e={}){const{mutation:t}=e,n=Or(e),r=G7(n),{mutate:i,mutateAsync:s,...o}=Ru({...t,...r});return{...o,sendTransaction:i,sendTransactionAsync:s}}function mN(e={}){const{mutation:t}=e,n=Or(e),r=q7(n),{mutate:i,mutateAsync:s,...o}=Ru({...t,...r});return{...o,chains:uN({config:n}),switchChain:i,switchChainAsync:s}}function gN(e={}){const{mutation:t}=e,n=Or(e),r=V7(n),{mutate:i,mutateAsync:s,...o}=Ru({...t,...r});return{...o,writeContract:i,writeContractAsync:s}}tf.type="coinbaseWallet";function tf(e={}){return e.version==="3"||e.headlessMode?bN(e):yN(e)}function yN(e){let t,n,r,i;return s=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",rdns:"com.coinbase.wallet",type:tf.type,async connect({chainId:o,withCapabilities:a,...c}={}){try{const u=await this.getProvider(),l=(await u.request({method:"eth_requestAccounts",params:"instantOnboarding"in c&&c.instantOnboarding?[{onboarding:"instant"}]:[]})).map(f=>gn(f));n||(n=this.onAccountsChanged.bind(this),u.on("accountsChanged",n)),r||(r=this.onChainChanged.bind(this),u.on("chainChanged",r)),i||(i=this.onDisconnect.bind(this),u.on("disconnect",i));let d=await this.getChainId();if(o&&d!==o){const f=await this.switchChain({chainId:o}).catch(h=>{if(h.code===Wt.code)throw h;return{id:d}});d=(f==null?void 0:f.id)??d}return{accounts:a?l.map(f=>({address:f,capabilities:{}})):l,chainId:d}}catch(u){throw/(user closed modal|accounts received is empty|user denied account|request rejected)/i.test(u.message)?new Wt(u):u}},async disconnect(){var a;const o=await this.getProvider();n&&(o.removeListener("accountsChanged",n),n=void 0),r&&(o.removeListener("chainChanged",r),r=void 0),i&&(o.removeListener("disconnect",i),i=void 0),o.disconnect(),(a=o.close)==null||a.call(o)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(a=>gn(a))},async getChainId(){const a=await(await this.getProvider()).request({method:"eth_chainId"});return Number(a)},async getProvider(){if(!t){const o=(()=>{var u;return typeof e.preference=="string"?{options:e.preference}:{...e.preference,options:((u=e.preference)==null?void 0:u.options)??"all"}})(),{createCoinbaseWalletSDK:a}=await Promise.resolve().then(()=>RH);t=a({...e,appChainIds:s.chains.map(u=>u.id),preference:o}).getProvider()}return t},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:o,chainId:a}){var l,d,f,h;const c=s.chains.find(m=>m.id===a);if(!c)throw new Ar(new Sa);const u=await this.getProvider();try{return await u.request({method:"wallet_switchEthereumChain",params:[{chainId:ae(c.id)}]}),c}catch(m){if(m.code===4902)try{let y;o!=null&&o.blockExplorerUrls?y=o.blockExplorerUrls:y=(l=c.blockExplorers)!=null&&l.default.url?[(d=c.blockExplorers)==null?void 0:d.default.url]:[];let w;(f=o==null?void 0:o.rpcUrls)!=null&&f.length?w=o.rpcUrls:w=[((h=c.rpcUrls.default)==null?void 0:h.http[0])??""];const b={blockExplorerUrls:y,chainId:ae(a),chainName:(o==null?void 0:o.chainName)??c.name,iconUrls:o==null?void 0:o.iconUrls,nativeCurrency:(o==null?void 0:o.nativeCurrency)??c.nativeCurrency,rpcUrls:w};return await u.request({method:"wallet_addEthereumChain",params:[b]}),c}catch(y){throw new Wt(y)}throw new Ar(m)}},onAccountsChanged(o){o.length===0?this.onDisconnect():s.emitter.emit("change",{accounts:o.map(a=>gn(a))})},onChainChanged(o){const a=Number(o);s.emitter.emit("change",{chainId:a})},async onDisconnect(o){s.emitter.emit("disconnect");const a=await this.getProvider();n&&(a.removeListener("accountsChanged",n),n=void 0),r&&(a.removeListener("chainChanged",r),r=void 0),i&&(a.removeListener("disconnect",i),i=void 0)}})}function bN(e){let n,r,i,s,o;return a=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",rdns:"com.coinbase.wallet",type:tf.type,async connect({chainId:c,withCapabilities:u}={}){try{const l=await this.getProvider(),d=(await l.request({method:"eth_requestAccounts"})).map(h=>gn(h));i||(i=this.onAccountsChanged.bind(this),l.on("accountsChanged",i)),s||(s=this.onChainChanged.bind(this),l.on("chainChanged",s)),o||(o=this.onDisconnect.bind(this),l.on("disconnect",o));let f=await this.getChainId();if(c&&f!==c){const h=await this.switchChain({chainId:c}).catch(m=>{if(m.code===Wt.code)throw m;return{id:f}});f=(h==null?void 0:h.id)??f}return{accounts:u?d.map(h=>({address:h,capabilities:{}})):d,chainId:f}}catch(l){throw/(user closed modal|accounts received is empty|user denied account)/i.test(l.message)?new Wt(l):l}},async disconnect(){const c=await this.getProvider();i&&(c.removeListener("accountsChanged",i),i=void 0),s&&(c.removeListener("chainChanged",s),s=void 0),o&&(c.removeListener("disconnect",o),o=void 0),c.disconnect(),c.close()},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(u=>gn(u))},async getChainId(){const u=await(await this.getProvider()).request({method:"eth_chainId"});return Number(u)},async getProvider(){var c;if(!r){const u=await(async()=>{const{default:m}=await Promise.resolve().then(()=>aQ);return typeof m!="function"&&typeof m.default=="function"?m.default:m})();n=new u({...e,reloadOnDisconnect:!1});const l=(c=n.walletExtension)==null?void 0:c.getChainId(),d=a.chains.find(m=>e.chainId?m.id===e.chainId:m.id===l)||a.chains[0],f=e.chainId||(d==null?void 0:d.id),h=e.jsonRpcUrl||(d==null?void 0:d.rpcUrls.default.http[0]);r=n.makeWeb3Provider(h,f)}return r},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:c,chainId:u}){var f,h,m,y;const l=a.chains.find(w=>w.id===u);if(!l)throw new Ar(new Sa);const d=await this.getProvider();try{return await d.request({method:"wallet_switchEthereumChain",params:[{chainId:ae(l.id)}]}),l}catch(w){if(w.code===4902)try{let b;c!=null&&c.blockExplorerUrls?b=c.blockExplorerUrls:b=(f=l.blockExplorers)!=null&&f.default.url?[(h=l.blockExplorers)==null?void 0:h.default.url]:[];let E;(m=c==null?void 0:c.rpcUrls)!=null&&m.length?E=c.rpcUrls:E=[((y=l.rpcUrls.default)==null?void 0:y.http[0])??""];const v={blockExplorerUrls:b,chainId:ae(u),chainName:(c==null?void 0:c.chainName)??l.name,iconUrls:c==null?void 0:c.iconUrls,nativeCurrency:(c==null?void 0:c.nativeCurrency)??l.nativeCurrency,rpcUrls:E};return await d.request({method:"wallet_addEthereumChain",params:[v]}),l}catch(b){throw new Wt(b)}throw new Ar(w)}},onAccountsChanged(c){c.length===0?this.onDisconnect():a.emitter.emit("change",{accounts:c.map(u=>gn(u))})},onChainChanged(c){const u=Number(c);a.emitter.emit("change",{chainId:u})},async onDisconnect(c){a.emitter.emit("disconnect");const u=await this.getProvider();i&&(u.removeListener("accountsChanged",i),i=void 0),s&&(u.removeListener("chainChanged",s),s=void 0),o&&(u.removeListener("disconnect",o),o=void 0)}})}var ug={exports:{}},lg,r5;function wN(){if(r5)return lg;r5=1;var e=1e3,t=e*60,n=t*60,r=n*24,i=r*7,s=r*365.25;lg=function(l,d){d=d||{};var f=typeof l;if(f==="string"&&l.length>0)return o(l);if(f==="number"&&isFinite(l))return d.long?c(l):a(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function o(l){if(l=String(l),!(l.length>100)){var d=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(d){var f=parseFloat(d[1]),h=(d[2]||"ms").toLowerCase();switch(h){case"years":case"year":case"yrs":case"yr":case"y":return f*s;case"weeks":case"week":case"w":return f*i;case"days":case"day":case"d":return f*r;case"hours":case"hour":case"hrs":case"hr":case"h":return f*n;case"minutes":case"minute":case"mins":case"min":case"m":return f*t;case"seconds":case"second":case"secs":case"sec":case"s":return f*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}function a(l){var d=Math.abs(l);return d>=r?Math.round(l/r)+"d":d>=n?Math.round(l/n)+"h":d>=t?Math.round(l/t)+"m":d>=e?Math.round(l/e)+"s":l+"ms"}function c(l){var d=Math.abs(l);return d>=r?u(l,d,r,"day"):d>=n?u(l,d,n,"hour"):d>=t?u(l,d,t,"minute"):d>=e?u(l,d,e,"second"):l+" ms"}function u(l,d,f,h){var m=d>=f*1.5;return Math.round(l/f)+" "+h+(m?"s":"")}return lg}function vN(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=a,n.humanize=wN(),n.destroy=u,Object.keys(e).forEach(l=>{n[l]=e[l]}),n.names=[],n.skips=[],n.formatters={};function t(l){let d=0;for(let f=0;f<l.length;f++)d=(d<<5)-d+l.charCodeAt(f),d|=0;return n.colors[Math.abs(d)%n.colors.length]}n.selectColor=t;function n(l){let d,f=null,h,m;function y(...w){if(!y.enabled)return;const b=y,E=Number(new Date),v=E-(d||E);b.diff=v,b.prev=d,b.curr=E,d=E,w[0]=n.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let A=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(M,L)=>{if(M==="%%")return"%";A++;const U=n.formatters[L];if(typeof U=="function"){const j=w[A];M=U.call(b,j),w.splice(A,1),A--}return M}),n.formatArgs.call(b,w),(b.log||n.log).apply(b,w)}return y.namespace=l,y.useColors=n.useColors(),y.color=n.selectColor(l),y.extend=r,y.destroy=n.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(h!==n.namespaces&&(h=n.namespaces,m=n.enabled(l)),m),set:w=>{f=w}}),typeof n.init=="function"&&n.init(y),y}function r(l,d){const f=n(this.namespace+(typeof d>"u"?":":d)+l);return f.log=this.log,f}function i(l){n.save(l),n.namespaces=l,n.names=[],n.skips=[];const d=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const f of d)f[0]==="-"?n.skips.push(f.slice(1)):n.names.push(f)}function s(l,d){let f=0,h=0,m=-1,y=0;for(;f<l.length;)if(h<d.length&&(d[h]===l[f]||d[h]==="*"))d[h]==="*"?(m=h,y=f,h++):(f++,h++);else if(m!==-1)h=m+1,y++,f=y;else return!1;for(;h<d.length&&d[h]==="*";)h++;return h===d.length}function o(){const l=[...n.names,...n.skips.map(d=>"-"+d)].join(",");return n.enable(""),l}function a(l){for(const d of n.skips)if(s(l,d))return!1;for(const d of n.names)if(s(l,d))return!0;return!1}function c(l){return l instanceof Error?l.stack||l.message:l}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}var _N=vN;(function(e,t){t.formatArgs=r,t.save=i,t.load=s,t.useColors=n,t.storage=o(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const u="color: "+this.color;c.splice(1,0,u,"color: inherit");let l=0,d=0;c[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&(l++,f==="%c"&&(d=l))}),c.splice(d,0,u)}t.log=console.debug||console.log||(()=>{});function i(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function o(){try{return localStorage}catch{}}e.exports=_N(t);const{formatters:a}=e.exports;a.j=function(c){try{return JSON.stringify(c)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}})(ug,ug.exports);var EN=ug.exports,dg={exports:{}};const xN="2.0.0",i5=256,SN=Number.MAX_SAFE_INTEGER||9007199254740991,kN=16,AN=i5-6;var nf={MAX_LENGTH:i5,MAX_SAFE_COMPONENT_LENGTH:kN,MAX_SAFE_BUILD_LENGTH:AN,MAX_SAFE_INTEGER:SN,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:xN,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},rf=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};(function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=nf,s=rf;t=e.exports={};const o=t.re=[],a=t.safeRe=[],c=t.src=[],u=t.safeSrc=[],l=t.t={};let d=0;const f="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",i],[f,r]],m=w=>{for(const[b,E]of h)w=w.split(`${b}*`).join(`${b}{0,${E}}`).split(`${b}+`).join(`${b}{1,${E}}`);return w},y=(w,b,E)=>{const v=m(b),A=d++;s(w,A,b),l[w]=A,c[A]=b,u[A]=v,o[A]=new RegExp(b,E?"g":void 0),a[A]=new RegExp(v,E?"g":void 0)};y("NUMERICIDENTIFIER","0|[1-9]\\d*"),y("NUMERICIDENTIFIERLOOSE","\\d+"),y("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`),y("MAINVERSION",`(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})`),y("MAINVERSIONLOOSE",`(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})`),y("PRERELEASEIDENTIFIER",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIER]})`),y("PRERELEASEIDENTIFIERLOOSE",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIERLOOSE]})`),y("PRERELEASE",`(?:-(${c[l.PRERELEASEIDENTIFIER]}(?:\\.${c[l.PRERELEASEIDENTIFIER]})*))`),y("PRERELEASELOOSE",`(?:-?(${c[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[l.PRERELEASEIDENTIFIERLOOSE]})*))`),y("BUILDIDENTIFIER",`${f}+`),y("BUILD",`(?:\\+(${c[l.BUILDIDENTIFIER]}(?:\\.${c[l.BUILDIDENTIFIER]})*))`),y("FULLPLAIN",`v?${c[l.MAINVERSION]}${c[l.PRERELEASE]}?${c[l.BUILD]}?`),y("FULL",`^${c[l.FULLPLAIN]}$`),y("LOOSEPLAIN",`[v=\\s]*${c[l.MAINVERSIONLOOSE]}${c[l.PRERELEASELOOSE]}?${c[l.BUILD]}?`),y("LOOSE",`^${c[l.LOOSEPLAIN]}$`),y("GTLT","((?:<|>)?=?)"),y("XRANGEIDENTIFIERLOOSE",`${c[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),y("XRANGEIDENTIFIER",`${c[l.NUMERICIDENTIFIER]}|x|X|\\*`),y("XRANGEPLAIN",`[v=\\s]*(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:${c[l.PRERELEASE]})?${c[l.BUILD]}?)?)?`),y("XRANGEPLAINLOOSE",`[v=\\s]*(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:${c[l.PRERELEASELOOSE]})?${c[l.BUILD]}?)?)?`),y("XRANGE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAIN]}$`),y("XRANGELOOSE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAINLOOSE]}$`),y("COERCEPLAIN",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),y("COERCE",`${c[l.COERCEPLAIN]}(?:$|[^\\d])`),y("COERCEFULL",c[l.COERCEPLAIN]+`(?:${c[l.PRERELEASE]})?(?:${c[l.BUILD]})?(?:$|[^\\d])`),y("COERCERTL",c[l.COERCE],!0),y("COERCERTLFULL",c[l.COERCEFULL],!0),y("LONETILDE","(?:~>?)"),y("TILDETRIM",`(\\s*)${c[l.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",y("TILDE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAIN]}$`),y("TILDELOOSE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAINLOOSE]}$`),y("LONECARET","(?:\\^)"),y("CARETTRIM",`(\\s*)${c[l.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",y("CARET",`^${c[l.LONECARET]}${c[l.XRANGEPLAIN]}$`),y("CARETLOOSE",`^${c[l.LONECARET]}${c[l.XRANGEPLAINLOOSE]}$`),y("COMPARATORLOOSE",`^${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]})$|^$`),y("COMPARATOR",`^${c[l.GTLT]}\\s*(${c[l.FULLPLAIN]})$|^$`),y("COMPARATORTRIM",`(\\s*)${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]}|${c[l.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",y("HYPHENRANGE",`^\\s*(${c[l.XRANGEPLAIN]})\\s+-\\s+(${c[l.XRANGEPLAIN]})\\s*$`),y("HYPHENRANGELOOSE",`^\\s*(${c[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[l.XRANGEPLAINLOOSE]})\\s*$`),y("STAR","(<|>)?=?\\s*\\*"),y("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),y("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(dg,dg.exports);var Tu=dg.exports;const IN=Object.freeze({loose:!0}),CN=Object.freeze({});var fg=e=>e?typeof e!="object"?IN:e:CN;const s5=/^[0-9]+$/,o5=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e===t?0:e<t?-1:1;const n=s5.test(e),r=s5.test(t);return n&&r&&(e=+e,t=+t),e===t?0:n&&!r?-1:r&&!n?1:e<t?-1:1};var a5={compareIdentifiers:o5,rcompareIdentifiers:(e,t)=>o5(t,e)};const sf=rf,{MAX_LENGTH:c5,MAX_SAFE_INTEGER:of}=nf,{safeRe:af,t:cf}=Tu,PN=fg,{compareIdentifiers:hg}=a5;var Ou=class pi{constructor(t,n){if(n=PN(n),t instanceof pi){if(t.loose===!!n.loose&&t.includePrerelease===!!n.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>c5)throw new TypeError(`version is longer than ${c5} characters`);sf("SemVer",t,n),this.options=n,this.loose=!!n.loose,this.includePrerelease=!!n.includePrerelease;const r=t.trim().match(n.loose?af[cf.LOOSE]:af[cf.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>of||this.major<0)throw new TypeError("Invalid major version");if(this.minor>of||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>of||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){const s=+i;if(s>=0&&s<of)return s}return i}):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(sf("SemVer.compare",this.version,this.options,t),!(t instanceof pi)){if(typeof t=="string"&&t===this.version)return 0;t=new pi(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof pi||(t=new pi(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(t){if(t instanceof pi||(t=new pi(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let n=0;do{const r=this.prerelease[n],i=t.prerelease[n];if(sf("prerelease compare",n,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;return hg(r,i)}while(++n)}compareBuild(t){t instanceof pi||(t=new pi(t,this.options));let n=0;do{const r=this.build[n],i=t.build[n];if(sf("build compare",n,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;return hg(r,i)}while(++n)}inc(t,n,r){if(t.startsWith("pre")){if(!n&&r===!1)throw new Error("invalid increment argument: identifier is empty");if(n){const i=`-${n}`.match(this.options.loose?af[cf.PRERELEASELOOSE]:af[cf.PRERELEASE]);if(!i||i[1]!==n)throw new Error(`invalid identifier: ${n}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",n,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",n,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",n,r),this.inc("pre",n,r);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",n,r),this.inc("pre",n,r);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const i=Number(r)?1:0;if(this.prerelease.length===0)this.prerelease=[i];else{let s=this.prerelease.length;for(;--s>=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);if(s===-1){if(n===this.prerelease.join(".")&&r===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(n){let s=[n,i];r===!1&&(s=[n]),hg(this.prerelease[0],n)===0?isNaN(this.prerelease[1])&&(this.prerelease=s):this.prerelease=s}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};const u5=Ou;var RN=(e,t,n=!1)=>{if(e instanceof u5)return e;try{return new u5(e,t)}catch(r){if(!n)return null;throw r}};const TN=RN;var ON=(e,t)=>{const n=TN(e,t);return n?n.version:null};const l5=Ou;var Ia=(e,t,n)=>new l5(e,n).compare(new l5(t,n));const MN=Ia;var pg=(e,t,n)=>MN(e,t,n)>0;const BN=Ia;var d5=(e,t,n)=>BN(e,t,n)<0;const NN=Ia;var LN=(e,t,n)=>NN(e,t,n)===0;const jN=Ia;var $N=(e,t,n)=>jN(e,t,n)!==0;const FN=Ia;var f5=(e,t,n)=>FN(e,t,n)>=0;const DN=Ia;var h5=(e,t,n)=>DN(e,t,n)<=0;const UN=LN,HN=$N,zN=pg,WN=f5,GN=d5,qN=h5;var VN=(e,t,n,r)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof n=="object"&&(n=n.version),e===n;case"!==":return typeof e=="object"&&(e=e.version),typeof n=="object"&&(n=n.version),e!==n;case"":case"=":case"==":return UN(e,n,r);case"!=":return HN(e,n,r);case">":return zN(e,n,r);case">=":return WN(e,n,r);case"<":return GN(e,n,r);case"<=":return qN(e,n,r);default:throw new TypeError(`Invalid operator: ${t}`)}};const{safeRe:CQ,t:PQ}=Tu;class KN{constructor(){this.max=1e3,this.map=new Map}get(t){const n=this.map.get(t);if(n!==void 0)return this.map.delete(t),this.map.set(t,n),n}delete(t){return this.map.delete(t)}set(t,n){if(!this.delete(t)&&n!==void 0){if(this.map.size>=this.max){const i=this.map.keys().next().value;this.delete(i)}this.map.set(t,n)}return this}}var JN=KN,mg,p5;function Mr(){if(p5)return mg;p5=1;const e=/\s+/g;class t{constructor(g,S){if(S=i(S),g instanceof t)return g.loose===!!S.loose&&g.includePrerelease===!!S.includePrerelease?g:new t(g.raw,S);if(g instanceof s)return this.raw=g.value,this.set=[[g]],this.formatted=void 0,this;if(this.options=S,this.loose=!!S.loose,this.includePrerelease=!!S.includePrerelease,this.raw=g.trim().replace(e," "),this.set=this.raw.split("||").map(R=>this.parseRange(R.trim())).filter(R=>R.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const R=this.set[0];if(this.set=this.set.filter(T=>!y(T[0])),this.set.length===0)this.set=[R];else if(this.set.length>1){for(const T of this.set)if(T.length===1&&w(T[0])){this.set=[T];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let g=0;g<this.set.length;g++){g>0&&(this.formatted+="||");const S=this.set[g];for(let R=0;R<S.length;R++)R>0&&(this.formatted+=" "),this.formatted+=S[R].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(g){const R=((this.options.includePrerelease&&h)|(this.options.loose&&m))+":"+g,T=r.get(R);if(T)return T;const B=this.options.loose,$=B?c[u.HYPHENRANGELOOSE]:c[u.HYPHENRANGE];g=g.replace($,W(this.options.includePrerelease)),o("hyphen replace",g),g=g.replace(c[u.COMPARATORTRIM],l),o("comparator trim",g),g=g.replace(c[u.TILDETRIM],d),o("tilde trim",g),g=g.replace(c[u.CARETTRIM],f),o("caret trim",g);let O=g.split(" ").map(ne=>E(ne,this.options)).join(" ").split(/\s+/).map(ne=>Y(ne,this.options));B&&(O=O.filter(ne=>(o("loose invalid filter",ne,this.options),!!ne.match(c[u.COMPARATORLOOSE])))),o("range list",O);const _=new Map,D=O.map(ne=>new s(ne,this.options));for(const ne of D){if(y(ne))return[ne];_.set(ne.value,ne)}_.size>1&&_.has("")&&_.delete("");const ue=[..._.values()];return r.set(R,ue),ue}intersects(g,S){if(!(g instanceof t))throw new TypeError("a Range is required");return this.set.some(R=>b(R,S)&&g.set.some(T=>b(T,S)&&R.every(B=>T.every($=>B.intersects($,S)))))}test(g){if(!g)return!1;if(typeof g=="string")try{g=new a(g,this.options)}catch{return!1}for(let S=0;S<this.set.length;S++)if(I(this.set[S],g,this.options))return!0;return!1}}mg=t;const n=JN,r=new n,i=fg,s=uf(),o=rf,a=Ou,{safeRe:c,t:u,comparatorTrimReplace:l,tildeTrimReplace:d,caretTrimReplace:f}=Tu,{FLAG_INCLUDE_PRERELEASE:h,FLAG_LOOSE:m}=nf,y=p=>p.value==="<0.0.0-0",w=p=>p.value==="",b=(p,g)=>{let S=!0;const R=p.slice();let T=R.pop();for(;S&&R.length;)S=R.every(B=>T.intersects(B,g)),T=R.pop();return S},E=(p,g)=>(p=p.replace(c[u.BUILD],""),o("comp",p,g),p=M(p,g),o("caret",p),p=A(p,g),o("tildes",p),p=U(p,g),o("xrange",p),p=Z(p,g),o("stars",p),p),v=p=>!p||p.toLowerCase()==="x"||p==="*",A=(p,g)=>p.trim().split(/\s+/).map(S=>P(S,g)).join(" "),P=(p,g)=>{const S=g.loose?c[u.TILDELOOSE]:c[u.TILDE];return p.replace(S,(R,T,B,$,O)=>{o("tilde",p,R,T,B,$,O);let _;return v(T)?_="":v(B)?_=`>=${T}.0.0 <${+T+1}.0.0-0`:v($)?_=`>=${T}.${B}.0 <${T}.${+B+1}.0-0`:O?(o("replaceTilde pr",O),_=`>=${T}.${B}.${$}-${O} <${T}.${+B+1}.0-0`):_=`>=${T}.${B}.${$} <${T}.${+B+1}.0-0`,o("tilde return",_),_})},M=(p,g)=>p.trim().split(/\s+/).map(S=>L(S,g)).join(" "),L=(p,g)=>{o("caret",p,g);const S=g.loose?c[u.CARETLOOSE]:c[u.CARET],R=g.includePrerelease?"-0":"";return p.replace(S,(T,B,$,O,_)=>{o("caret",p,T,B,$,O,_);let D;return v(B)?D="":v($)?D=`>=${B}.0.0${R} <${+B+1}.0.0-0`:v(O)?B==="0"?D=`>=${B}.${$}.0${R} <${B}.${+$+1}.0-0`:D=`>=${B}.${$}.0${R} <${+B+1}.0.0-0`:_?(o("replaceCaret pr",_),B==="0"?$==="0"?D=`>=${B}.${$}.${O}-${_} <${B}.${$}.${+O+1}-0`:D=`>=${B}.${$}.${O}-${_} <${B}.${+$+1}.0-0`:D=`>=${B}.${$}.${O}-${_} <${+B+1}.0.0-0`):(o("no pr"),B==="0"?$==="0"?D=`>=${B}.${$}.${O}${R} <${B}.${$}.${+O+1}-0`:D=`>=${B}.${$}.${O}${R} <${B}.${+$+1}.0-0`:D=`>=${B}.${$}.${O} <${+B+1}.0.0-0`),o("caret return",D),D})},U=(p,g)=>(o("replaceXRanges",p,g),p.split(/\s+/).map(S=>j(S,g)).join(" ")),j=(p,g)=>{p=p.trim();const S=g.loose?c[u.XRANGELOOSE]:c[u.XRANGE];return p.replace(S,(R,T,B,$,O,_)=>{o("xRange",p,R,T,B,$,O,_);const D=v(B),ue=D||v($),ne=ue||v(O),G=ne;return T==="="&&G&&(T=""),_=g.includePrerelease?"-0":"",D?T===">"||T==="<"?R="<0.0.0-0":R="*":T&&G?(ue&&($=0),O=0,T===">"?(T=">=",ue?(B=+B+1,$=0,O=0):($=+$+1,O=0)):T==="<="&&(T="<",ue?B=+B+1:$=+$+1),T==="<"&&(_="-0"),R=`${T+B}.${$}.${O}${_}`):ue?R=`>=${B}.0.0${_} <${+B+1}.0.0-0`:ne&&(R=`>=${B}.${$}.0${_} <${B}.${+$+1}.0-0`),o("xRange return",R),R})},Z=(p,g)=>(o("replaceStars",p,g),p.trim().replace(c[u.STAR],"")),Y=(p,g)=>(o("replaceGTE0",p,g),p.trim().replace(c[g.includePrerelease?u.GTE0PRE:u.GTE0],"")),W=p=>(g,S,R,T,B,$,O,_,D,ue,ne,G)=>(v(R)?S="":v(T)?S=`>=${R}.0.0${p?"-0":""}`:v(B)?S=`>=${R}.${T}.0${p?"-0":""}`:$?S=`>=${S}`:S=`>=${S}${p?"-0":""}`,v(D)?_="":v(ue)?_=`<${+D+1}.0.0-0`:v(ne)?_=`<${D}.${+ue+1}.0-0`:G?_=`<=${D}.${ue}.${ne}-${G}`:p?_=`<${D}.${ue}.${+ne+1}-0`:_=`<=${_}`,`${S} ${_}`.trim()),I=(p,g,S)=>{for(let R=0;R<p.length;R++)if(!p[R].test(g))return!1;if(g.prerelease.length&&!S.includePrerelease){for(let R=0;R<p.length;R++)if(o(p[R].semver),p[R].semver!==s.ANY&&p[R].semver.prerelease.length>0){const T=p[R].semver;if(T.major===g.major&&T.minor===g.minor&&T.patch===g.patch)return!0}return!1}return!0};return mg}var gg,m5;function uf(){if(m5)return gg;m5=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(l,d){if(d=n(d),l instanceof t){if(l.loose===!!d.loose)return l;l=l.value}l=l.trim().split(/\s+/).join(" "),o("comparator",l,d),this.options=d,this.loose=!!d.loose,this.parse(l),this.semver===e?this.value="":this.value=this.operator+this.semver.version,o("comp",this)}parse(l){const d=this.options.loose?r[i.COMPARATORLOOSE]:r[i.COMPARATOR],f=l.match(d);if(!f)throw new TypeError(`Invalid comparator: ${l}`);this.operator=f[1]!==void 0?f[1]:"",this.operator==="="&&(this.operator=""),f[2]?this.semver=new a(f[2],this.options.loose):this.semver=e}toString(){return this.value}test(l){if(o("Comparator.test",l,this.options.loose),this.semver===e||l===e)return!0;if(typeof l=="string")try{l=new a(l,this.options)}catch{return!1}return s(l,this.operator,this.semver,this.options)}intersects(l,d){if(!(l instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(l.value,d).test(this.value):l.operator===""?l.value===""?!0:new c(this.value,d).test(l.semver):(d=n(d),d.includePrerelease&&(this.value==="<0.0.0-0"||l.value==="<0.0.0-0")||!d.includePrerelease&&(this.value.startsWith("<0.0.0")||l.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&l.operator.startsWith(">")||this.operator.startsWith("<")&&l.operator.startsWith("<")||this.semver.version===l.semver.version&&this.operator.includes("=")&&l.operator.includes("=")||s(this.semver,"<",l.semver,d)&&this.operator.startsWith(">")&&l.operator.startsWith("<")||s(this.semver,">",l.semver,d)&&this.operator.startsWith("<")&&l.operator.startsWith(">")))}}gg=t;const n=fg,{safeRe:r,t:i}=Tu,s=VN,o=rf,a=Ou,c=Mr();return gg}const ZN=Mr();var g5=(e,t,n)=>{try{t=new ZN(t,n)}catch{return!1}return t.test(e)};Mr(),Mr(),Mr(),Mr();const YN=Mr();var QN=(e,t)=>{try{return new YN(e,t).range||"*"}catch{return null}};const XN=Ou,y5=uf(),{ANY:eL}=y5,tL=Mr(),nL=g5,b5=pg,w5=d5,rL=h5,iL=f5;var sL=(e,t,n,r)=>{e=new XN(e,r),t=new tL(t,r);let i,s,o,a,c;switch(n){case">":i=b5,s=rL,o=w5,a=">",c=">=";break;case"<":i=w5,s=iL,o=b5,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(nL(e,t,r))return!1;for(let u=0;u<t.set.length;++u){const l=t.set[u];let d=null,f=null;if(l.forEach(h=>{h.semver===eL&&(h=new y5(">=0.0.0")),d=d||h,f=f||h,i(h.semver,d.semver,r)?d=h:o(h.semver,f.semver,r)&&(f=h)}),d.operator===a||d.operator===c||(!f.operator||f.operator===a)&&s(e,f.semver))return!1;if(f.operator===c&&o(e,f.semver))return!1}return!0};const oL=sL;var aL=(e,t,n)=>oL(e,t,">",n);Mr(),Mr();const yg=uf(),{ANY:BQ}=yg;new yg(">=0.0.0-0"),new yg(">=0.0.0");const bg=Tu,v5=nf,_5=a5,cL=ON,uL=pg;uf(),Mr();var lL={valid:cL,gt:uL,satisfies:g5,validRange:QN,gtr:aL,re:bg.re,src:bg.src,tokens:bg.t,SEMVER_SPEC_VERSION:v5.SEMVER_SPEC_VERSION,RELEASE_TYPES:v5.RELEASE_TYPES,compareIdentifiers:_5.compareIdentifiers,rcompareIdentifiers:_5.rcompareIdentifiers},dL=Mu;Mu.default=Mu,Mu.stable=S5,Mu.stableStringify=S5;var lf="[...]",E5="[Circular]",oo=[],ao=[];function x5(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Mu(e,t,n,r){typeof r>"u"&&(r=x5()),wg(e,"",0,[],void 0,0,r);var i;try{ao.length===0?i=JSON.stringify(e,t,n):i=JSON.stringify(e,k5(t),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;oo.length!==0;){var s=oo.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function Ca(e,t,n,r){var i=Object.getOwnPropertyDescriptor(r,n);i.get!==void 0?i.configurable?(Object.defineProperty(r,n,{value:e}),oo.push([r,n,t,i])):ao.push([t,n,e]):(r[n]=e,oo.push([r,n,t]))}function wg(e,t,n,r,i,s,o){s+=1;var a;if(typeof e=="object"&&e!==null){for(a=0;a<r.length;a++)if(r[a]===e){Ca(E5,e,t,i);return}if(typeof o.depthLimit<"u"&&s>o.depthLimit){Ca(lf,e,t,i);return}if(typeof o.edgesLimit<"u"&&n+1>o.edgesLimit){Ca(lf,e,t,i);return}if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)wg(e[a],a,a,r,e,s,o);else{var c=Object.keys(e);for(a=0;a<c.length;a++){var u=c[a];wg(e[u],u,a,r,e,s,o)}}r.pop()}}function fL(e,t){return e<t?-1:e>t?1:0}function S5(e,t,n,r){typeof r>"u"&&(r=x5());var i=vg(e,"",0,[],void 0,0,r)||e,s;try{ao.length===0?s=JSON.stringify(i,t,n):s=JSON.stringify(i,k5(t),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;oo.length!==0;){var o=oo.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return s}function vg(e,t,n,r,i,s,o){s+=1;var a;if(typeof e=="object"&&e!==null){for(a=0;a<r.length;a++)if(r[a]===e){Ca(E5,e,t,i);return}try{if(typeof e.toJSON=="function")return}catch{return}if(typeof o.depthLimit<"u"&&s>o.depthLimit){Ca(lf,e,t,i);return}if(typeof o.edgesLimit<"u"&&n+1>o.edgesLimit){Ca(lf,e,t,i);return}if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)vg(e[a],a,a,r,e,s,o);else{var c={},u=Object.keys(e).sort(fL);for(a=0;a<u.length;a++){var l=u[a];vg(e[l],l,a,r,e,s,o),c[l]=e[l]}if(typeof i<"u")oo.push([i,t,e]),i[t]=c;else return c}r.pop()}}function k5(e){return e=typeof e<"u"?e:function(t,n){return n},function(t,n){if(ao.length>0)for(var r=0;r<ao.length;r++){var i=ao[r];if(i[1]===t&&i[0]===n){n=i[2],ao.splice(r,1);break}}return e.call(this,t,n)}}const hL={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},pL={block:jT({format(e){var n;return{transactions:(n=e.transactions)==null?void 0:n.map(r=>{if(typeof r=="string")return r;const i=Eu(r);return i.typeHex==="0x7e"&&(i.isSystemTx=r.isSystemTx,i.mint=r.mint?Rt(r.mint):void 0,i.sourceHash=r.sourceHash,i.type="deposit"),i}),stateRoot:e.stateRoot}}}),transaction:NT({format(e){const t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Rt(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:UO({format(e){return{l1GasPrice:e.l1GasPrice?Rt(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Rt(e.l1GasUsed):null,l1Fee:e.l1Fee?Rt(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};function mL(e,t){return bL(e)?yL(e):xO(e,t)}const gL={transaction:mL};function yL(e){wL(e);const{sourceHash:t,data:n,from:r,gas:i,isSystemTx:s,mint:o,to:a,value:c}=e,u=[t,r,a??"0x",o?tn(o):"0x",c?tn(c):"0x",i?tn(i):"0x",s?"0x1":"0x",n??"0x"];return zn(["0x7e",is(u)])}function bL(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function wL(e){const{from:t,to:n}=e;if(t&&!Ot(t))throw new xn({address:t});if(n&&!Ot(n))throw new xn({address:n})}const df={blockTime:2e3,contracts:hL,formatters:pL,serializers:gL},A5=ls({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}}}),Bu=1,_g=ls({...df,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:{...df.contracts,disputeGameFactory:{[Bu]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[Bu]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[Bu]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[Bu]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:Bu});({..._g});const I5=ls({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}}}),C5=ls({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}}}),Nu=1,P5=ls({...df,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:{...df.contracts,disputeGameFactory:{[Nu]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[Nu]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[Nu]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[Nu]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId:Nu}),R5=ls({id:137,name:"Polygon",blockTime:2e3,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon.drpc.org"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.etherscan.io/v2/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}}),T5=QB({chains:[_g,C5,A5,P5,R5,I5],transports:{[_g.id]:fs(),[C5.id]:fs("https://ethereum-rpc.publicnode.com"),[A5.id]:fs(),[P5.id]:fs(),[R5.id]:fs(),[I5.id]:fs()},connectors:[qd(),tf({appName:"Weave Checkout"})]}),vL=new Set([8453,1,10,42161,137,56]),O5={8453:"BASE",1:"ETHEREUM",10:"OPTIMISM",42161:"ARBITRUM",137:"POLYGON",56:"BSC"},Eg={8453:"Base",1:"Ethereum",10:"Optimism",42161:"Arbitrum",137:"Polygon",56:"BNB Chain"},M5={8453:"#1C4FE0",1:"#627EEA",10:"#FF3F57",42161:"#12AAFF",137:"#8247E5",56:"#F3BA2F"},B5={8453:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",1:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",10:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",42161:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",137:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",56:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},N5={1:"0xdAC17F958D2ee523a2206206994597C13D831ec7",10:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",42161:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",137:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",56:"0x55d398326f99059fF775485246999027B3197955"};function _L(){return typeof window<"u"&&window.__WEAVE_API_BASE__?window.__WEAVE_API_BASE__:"http://localhost:4000/api/v1"}async function ff(e,t,n,r=15e3){const i=_L(),s={"Content-Type":"application/json","x-api-key":t,...n==null?void 0:n.headers},o=new AbortController,a=setTimeout(()=>o.abort(),r);try{const c=await fetch(`${i}${e}`,{...n,headers:s,signal:o.signal});if(c.status===204)return null;const u=await c.json();if(!u.success)throw new Error(u.error??"API error");return u.data}catch(c){throw(c==null?void 0:c.name)==="AbortError"?new Error("Request timed out — please check your connection"):c}finally{clearTimeout(a)}}const co=e=>`fiat:${e.toUpperCase()}`,hf=(e,t)=>`crypto:${e.toUpperCase()}:${t.toUpperCase()}`;async function Lu(e,t){const n=new URLSearchParams({from:t.from,to:t.to,amount:String(t.amount),...t.amountIn?{amountIn:t.amountIn}:{}});return ff(`/quotes?${n}`,e)}async function xg(e,t){return ff("/orders",e,{method:"POST",body:JSON.stringify(t)})}async function ju(e,t){return ff(`/orders/${t}`,e)}async function EL(e){return ff("/assets",e)}const xL=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],SL=Tw,kL=t7,AL=K7,pf={forest:"#3D6B50",tan:"#B8935A",ink:"#1C1B17"},K={ink:"var(--weave-ink, #0B0F0E)",ink2:"var(--weave-ink2, #3A4240)",mute:"var(--weave-mute, #6B7572)",hair:"var(--weave-hair, #E8EAE6)",surface:"var(--weave-surface, #FFFFFF)",page:"var(--weave-page, #F5F4EF)",panel:"var(--weave-panel, #FAFAF7)",accent:"var(--weave-accent, #0F5D4C)",accentSoft:"var(--weave-accent-soft, #E6F0EC)",good:"var(--weave-good, #1F7A4D)",goodSoft:"var(--weave-good-soft, #E6F3EC)",warn:"var(--weave-warn, #A46A00)",warnSoft:"var(--weave-warn-soft, #FBF0DC)",err:"var(--weave-err, #A8321E)"},Ti=L0.reduce((e,t)=>{const n=t.key.split(":").pop();return e[n]={name:t.name,symbol:t.symbol,flag:t.flag,rate:t.rate,min:t.min,country:t.country,psp:"GTBank",bank:"GTBank ••7890",method:"Bank transfer"},e},{}),mf=[{token:"ETH",chain:"Optimism",amount:.312,usd:1024.4,icon:"Ξ",chainTint:"#ff3f57",logo:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png"},{token:"USDC",chain:"Base",amount:150,usd:150,icon:"$",chainTint:"#1C4FE0",logo:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png"},{token:"STRK",chain:"Starknet",amount:840,usd:184.8,icon:"S",chainTint:"#EC796B",logo:"https://assets.coingecko.com/coins/images/35293/standard/starknet.png"},{token:"DAI",chain:"Ethereum",amount:502,usd:502,icon:"D",chainTint:"#F5AC37",logo:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EedeAC495271d0F/logo.png"}],IL=(e,t,n)=>{const r=Ti[t],s=!!r?0:4,o=Number.isInteger(e)?0:s,a=Math.pow(10,o),c=o>0?Math.ceil(e*a)/a:Math.ceil(e),u=new Intl.NumberFormat("en-US",{minimumFractionDigits:o,maximumFractionDigits:o}).format(c);return`${r.symbol}${u}`},$u=(e,t=4)=>{const n=Math.pow(10,t);return(Math.ceil(e*n)/n).toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})},CL=async(e,t,n,r)=>{const i=document.createElement("canvas"),s=i.getContext("2d");if(!s)return;const o=pf[r]||r||"#0F5D4C",a=800,c=1100;i.width=a,i.height=c,s.fillStyle="#FDFDFB",s.fillRect(0,0,a,c),s.strokeStyle="#E8EAE6",s.lineWidth=2,s.strokeRect(40,40,a-80,c-80),s.fillStyle=o,s.font="700 32px Figtree, Inter, sans-serif",s.fillText("Weave",80,110),s.fillStyle="#6B7572",s.font="500 16px Inter, sans-serif",s.fillText("PAYMENT RECEIPT",a-240,105),s.fillStyle="#E6F0EC";const u=230,l=36;s.beginPath(),s.roundRect(80,160,u,l,8),s.fill(),s.fillStyle=o,s.font="700 12px Inter, sans-serif",s.textAlign="center",s.fillText("✓ TRANSACTION SUCCESSFUL",80+u/2,182),s.textAlign="left",s.fillStyle="#0B0F0E",s.font="700 72px Figtree, Inter, sans-serif";const d=IL(e.amount,e.currency);s.fillText(d,80,280),s.fillStyle="#6B7572",s.font="500 18px Inter, sans-serif",s.fillText("Total amount paid to "+e.name,80,315);const f=(w,b,E)=>{s.fillStyle="#6B7572",s.font="500 15px Inter, sans-serif",s.fillText(w,80,E),s.fillStyle="#0B0F0E",s.font="600 16px Inter, sans-serif",s.textAlign="right",s.fillText(b,a-80,E),s.textAlign="left",s.strokeStyle="#E8EAE6",s.lineWidth=1,s.beginPath(),s.moveTo(80,E+25),s.lineTo(a-80,E+25),s.stroke()},h=new Date((t==null?void 0:t.createdAt)||Date.now()).toLocaleDateString("en-US",{day:"numeric",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"});f("Payment Date",h,420),f("Transaction Ref",((t==null?void 0:t.id)||"N/A").toUpperCase(),490),f("Merchant",e.name,560),f("Payout Destination",n,630),f("Status","Completed",700),s.fillStyle="#F5F4EF",s.fillRect(80,800,a-160,120),s.fillStyle="#0B0F0E",s.font="600 16px Inter, sans-serif",s.fillText("Security Verification",110,845),s.fillStyle="#6B7572",s.font="400 14px Inter, sans-serif",s.fillText("This transaction was secured with 256-bit encryption by Paycrest.",110,875),s.fillText("You can verify this order directly on the Weave Dashboard.",110,895),s.textAlign="center",s.fillStyle="#0B0F0E",s.font="700 24px Figtree, Inter, sans-serif",s.fillText("Thank you for using Weave.",a/2,1020),s.fillStyle="#6B7572",s.font="400 12px Inter, sans-serif",s.fillText("Support: help@weave.com",a/2,1050);const m=i.toDataURL("image/png"),y=document.createElement("a");y.download=`weave-receipt-${((t==null?void 0:t.id)||"txn").slice(0,8)}.png`,y.href=m,y.click()};function ve({gap:e=12,children:t,style:n}){return C.jsx("div",{style:{display:"flex",flexDirection:"column",gap:e,...n},children:t})}function rn({gap:e=10,align:t="center",justify:n="flex-start",children:r,style:i}){return C.jsx("div",{style:{display:"flex",alignItems:t,justifyContent:n,gap:e,...i},children:r})}function Pa(){return C.jsx("div",{style:{height:1,background:K.hair,width:"100%"}})}function Fu({children:e,tone:t="neutral"}){const n={neutral:{bg:"#F1F0EB",fg:K.ink2},good:{bg:K.goodSoft,fg:K.good},accent:{bg:K.accentSoft,fg:K.accent},warn:{bg:K.warnSoft,fg:K.warn}}[t];return C.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:6,height:22,padding:"0 9px",borderRadius:999,background:n.bg,color:n.fg,fontSize:11.5,fontWeight:500,letterSpacing:.1},children:e})}function Ra({bg:e,children:t,size:n=32}){return C.jsx("div",{style:{width:n,height:n,borderRadius:n/2,background:e,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:n*.42,flexShrink:0,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:t})}function Sg({size:e=22}){return C.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[C.jsx("path",{d:"M3 5 L8 19 L12 9 L16 19 L21 5",stroke:K.accent,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),C.jsx("path",{d:"M5 9 L12 19 L19 9",stroke:K.ink,strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3"})]})}const L5={width:28,height:28,borderRadius:14,border:"none",cursor:"pointer",background:"transparent",color:K.mute,display:"flex",alignItems:"center",justifyContent:"center"},PL={...L5,color:K.ink};function RL({merchantName:e,onClose:t,showBack:n,onBack:r}){return C.jsxs("div",{style:{padding:"16px 20px 14px",display:"flex",alignItems:"center",gap:10,borderBottom:`1px solid ${K.hair}`},children:[n?C.jsx("button",{onClick:r,style:PL,children:C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M15 18L9 12L15 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}):C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx(Sg,{size:22}),C.jsx("span",{style:{fontWeight:600,fontSize:15,letterSpacing:-.2},children:"Weave"})]}),C.jsxs("div",{style:{flex:1,textAlign:"center",fontSize:12.5,color:K.mute},children:["Paying ",C.jsx("span",{style:{color:K.ink,fontWeight:500},children:e})]}),C.jsx("button",{onClick:t,style:L5,children:C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M6 6L18 18M6 18L18 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})})]})}function TL(){return C.jsxs("div",{style:{padding:"12px 20px 14px",borderTop:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:K.mute,background:K.panel,borderRadius:"0 0 16px 16px"},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[C.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M12 2L3 6V12C3 17 6.5 21 12 22C17.5 21 21 17 21 12V6L12 2Z",stroke:"currentColor",strokeWidth:"1.8"})}),"Secured by Dewdrop Labs"]}),C.jsx("div",{style:{display:"flex",alignItems:"center",gap:10},children:C.jsx("span",{children:"xoxo ❤️"})})]})}const Du={width:"100%",padding:"12px 14px",borderRadius:12,border:`1px solid ${K.hair}`,background:"#fff",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:12,transition:"border-color 0.15s, background 0.15s, transform 0.1s"},OL={padding:"10px 12px",borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:8,transition:"border-color 0.15s, background 0.15s"},ps={width:"100%",height:46,borderRadius:10,border:"none",background:K.ink,color:"#fff",fontSize:14.5,fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:8,cursor:"pointer",fontFamily:"inherit",letterSpacing:-.1,transition:"transform 0.08s, background 0.2s"},kg={width:"100%",height:46,borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",color:K.ink,fontSize:14,fontWeight:500,display:"flex",alignItems:"center",gap:10,paddingLeft:14,paddingRight:14,cursor:"pointer",fontFamily:"inherit"};function ML({onPick:e,merchant:t,currencies:n,fmtCur:r,submitting:i,disabledMethods:s}){const o=n[t.currency]||Ti[t.currency],[a,c]=ce.useState(!1),[u,l]=ce.useState(null);ce.useEffect(()=>{i||l(null)},[i]);const d=f=>{i||u||(l(f),e(f))};return C.jsxs(ve,{gap:16,style:{padding:"22px 20px 6px"},children:[C.jsxs(ve,{gap:10,style:{alignItems:"center",padding:"4px 0 6px"},children:[C.jsx("div",{style:{width:44,height:44,borderRadius:10,background:pf[t.currency==="USDC"?"ink":"forest"]||"#2B1810",color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:18,fontFamily:"var(--weave-font-display, Georgia, serif)",boxShadow:"0 2px 8px rgba(0,0,0,0.12)"},children:(()=>{var h;const f=t.name.trim().split(/\s+/).filter(Boolean);return f.length>=2?(f[0][0]+f[1][0]).toUpperCase():((h=f[0])==null?void 0:h.slice(0,2).toUpperCase())??"?"})()}),C.jsxs(ve,{gap:3,style:{alignItems:"center"},children:[C.jsxs("div",{style:{fontSize:12.5,color:K.mute},children:["Pay ",t.name]}),C.jsx("div",{style:{fontSize:30,fontWeight:600,letterSpacing:-.6,color:K.ink},children:r(t.amount,t.currency)}),C.jsx("div",{style:{fontSize:11.5,color:K.mute},children:t.description||"Secure checkout"})]})]}),C.jsxs(ve,{gap:8,children:[C.jsx("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"How would you like to pay?"}),C.jsxs("button",{onClick:()=>!(s!=null&&s.fiat)&&d("fiat"),disabled:!!(i||u||s!=null&&s.fiat),title:s==null?void 0:s.fiat,style:{...Du,opacity:i||u||s!=null&&s.fiat?.7:1,cursor:i||u?"not-allowed":s!=null&&s.fiat?"help":"pointer",filter:s!=null&&s.fiat?"grayscale(1)":"none"},children:[C.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"#fff",border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:u==="fiat"?C.jsx("div",{style:{width:18,height:18,borderRadius:"50%",border:`2px solid ${K.hair}`,borderTopColor:K.accent,animation:"wspin 0.8s linear infinite"}}):C.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M3 21H21M5 21V10M9 21V10M15 21V10M19 21V10M2 10L12 3L22 10H2Z",stroke:K.ink,strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}),C.jsxs(ve,{gap:2,style:{flex:1,textAlign:"left",minWidth:0},children:[C.jsx("div",{style:{fontSize:14,fontWeight:500,color:K.ink},children:u==="fiat"?"Setting up payment…":"Bank transfer"}),C.jsx("div",{style:{fontSize:11.5,color:K.mute},children:(s==null?void 0:s.fiat)||`Pay in ${(o==null?void 0:o.name)??t.currency} · Instant · No fees`})]}),u!=="fiat"&&!(s!=null&&s.fiat)&&C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{marginLeft:4,flexShrink:0},children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),C.jsxs("button",{onClick:()=>d("deposit"),disabled:!!(i||u),style:{...Du,opacity:i||u?.7:1,cursor:i||u?"not-allowed":"pointer"},children:[C.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"#fff",border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:C.jsx(Ra,{bg:"#F6851B",size:24,children:"🦊"})}),C.jsxs(ve,{gap:2,style:{flex:1,textAlign:"left",minWidth:0},children:[C.jsx("div",{style:{fontSize:14,fontWeight:500},children:"Pay with crypto wallet"}),C.jsx("div",{style:{fontSize:11.5,color:K.mute},children:"MetaMask detected · Any chain, any token"})]}),C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{marginLeft:4,flexShrink:0},children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),a?C.jsx(ve,{gap:6,style:{padding:"2px 0"},children:C.jsxs("button",{onClick:()=>d("externalDeposit"),disabled:!!(i||u),style:{...OL,opacity:i||u?.7:1,cursor:i||u?"not-allowed":"pointer"},children:[C.jsx("div",{style:{width:20,height:20,borderRadius:5,background:K.panel,border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",children:[C.jsx("rect",{x:"3",y:"3",width:"7",height:"7",stroke:K.ink,strokeWidth:"2"}),C.jsx("rect",{x:"14",y:"3",width:"7",height:"7",stroke:K.ink,strokeWidth:"2"}),C.jsx("rect",{x:"3",y:"14",width:"7",height:"7",stroke:K.ink,strokeWidth:"2"})]})}),C.jsx("span",{style:{fontSize:12.5,fontWeight:500},children:"Pay from mobile / hardware / exchange"}),C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",style:{marginLeft:"auto"},children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})}):C.jsx("button",{onClick:()=>!u&&c(!0),style:{background:"transparent",border:"none",cursor:u?"not-allowed":"pointer",fontFamily:"inherit",fontSize:12,color:K.mute,padding:"4px 0",textAlign:"center",opacity:u?.5:1},children:"Use a different wallet ↓"})]})]})}function BL({onNext:e,merchant:t,balances:n,selected:r,setSelected:i,currencies:s}){var o;return C.jsxs(ve,{gap:14,style:{padding:"18px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Choose what you'd like to pay with"}),C.jsxs("div",{style:{fontSize:12.5,color:K.mute},children:["We found these balances in your wallet. Pick any — we'll convert to ",((o=s[t.currency])==null?void 0:o.name)??t.currency," for ",t.name,"."]})]}),C.jsx(ve,{gap:6,children:n.map((a,c)=>{const u=s[t.currency]||Ti[t.currency],l=a.usd>=t.amount/((u==null?void 0:u.rate)||1),d=r===c;return C.jsxs("button",{onClick:()=>l&&i(c),disabled:!l,style:{width:"100%",padding:"12px 14px",background:d?K.accentSoft:"#fff",border:`1.5px solid ${d?K.accent:K.hair}`,borderRadius:12,cursor:l?"pointer":"not-allowed",opacity:l?1:.48,display:"flex",alignItems:"center",gap:12,textAlign:"left",fontFamily:"inherit",transition:"all 0.15s"},children:[C.jsx(Ra,{bg:a.chainTint,size:36,children:a.logo?C.jsx("img",{src:a.logo,style:{width:"100%",height:"100%",borderRadius:"inherit",objectFit:"cover"}}):a.icon}),C.jsxs(ve,{gap:2,style:{flex:1},children:[C.jsxs("div",{style:{fontSize:14,fontWeight:500,color:K.ink},children:[$u(a.amount)," ",a.token]}),C.jsxs("div",{style:{fontSize:12,color:K.mute},children:["on ",a.chain," · ≈ $",a.usd.toFixed(2)]})]}),!l&&C.jsx(Fu,{tone:"warn",children:"Too low"}),l&&d&&C.jsx("div",{style:{width:20,height:20,borderRadius:10,background:K.accent,display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})})})]},c)})}),C.jsx("button",{onClick:()=>e("quote"),style:{...ps,opacity:r===null?.5:1},disabled:r===null,children:"Continue"})]})}function NL({merchant:e,balance:t,onConfirm:n,submitting:r,error:i,quote:s,quoteLoading:o,currencies:a,fmtCur:c}){if(o&&!s)return C.jsxs(ve,{style:{padding:"60px 0",minHeight:320,alignItems:"center",justifyContent:"center"},children:[C.jsx(gf,{}),C.jsx("div",{style:{marginTop:16,fontSize:13,color:K.mute},children:"Calculating best route…"})]});const u=a[e.currency]||Ti[e.currency],l=(u==null?void 0:u.rate)||1,d=e.amount/l,f=s?s.breakdown.inputAmount:d,h=t.amount>0?t.usd/t.amount:t.token==="ETH"?3400:1,m=f/(h||1),y=s?s.breakdown.bridgeFeeUsd:t.chain==="Base"&&t.token==="USDC"?0:1.8,w=s?s.breakdown.senderFeeUsd+s.breakdown.appFeeUsd:f*.0075,b=y+w,E=s?s.breakdown.sellRate:l,v=s?s.estimatedFiat:e.amount;return C.jsxs(ve,{gap:14,style:{padding:"16px 20px 6px"},children:[C.jsxs(ve,{gap:6,children:[C.jsx("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"You pay"}),C.jsxs(rn,{align:"baseline",gap:8,children:[C.jsx("div",{style:{fontSize:30,fontWeight:600,letterSpacing:-.6},children:$u(m,5)}),C.jsx("div",{style:{fontSize:16,color:K.ink2,fontWeight:500},children:t.token})]}),C.jsxs(rn,{gap:6,style:{fontSize:12,color:K.mute},children:[C.jsx(Ra,{bg:t.chainTint,size:14,children:t.logo?C.jsx("img",{src:t.logo,style:{width:"100%",height:"100%",objectFit:"cover"}}):t.icon}),"on ",t.chain]})]}),C.jsxs("div",{style:{padding:"2px 0",position:"relative"},children:[C.jsx(Pa,{}),C.jsxs("div",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"#fff",padding:"0 10px",fontSize:11,color:K.mute,letterSpacing:.4,display:"flex",alignItems:"center",gap:6},children:[C.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M12 5V19M5 12L12 19L19 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"converts to"]})]}),C.jsxs(ve,{gap:6,children:[C.jsxs("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:[e.name," receives"]}),C.jsx(rn,{align:"baseline",gap:8,children:C.jsx("div",{style:{fontSize:30,fontWeight:600,letterSpacing:-.6,color:K.accent},children:c(v,e.currency)})}),C.jsxs(rn,{gap:6,style:{fontSize:12,color:K.mute},children:["via ",(u==null?void 0:u.method)||"Transfer"," · ",(u==null?void 0:u.psp)||"Partner"]})]}),C.jsxs(ve,{gap:7,style:{fontSize:12.5},children:[C.jsxs(rn,{justify:"space-between",children:[C.jsx("span",{style:{color:K.mute},children:"Rate"}),C.jsxs("span",{children:["1 USDC = ",c(E,e.currency)]})]}),y>0&&C.jsxs(rn,{justify:"space-between",children:[C.jsx("span",{style:{color:K.mute},children:"Network & bridge"}),C.jsxs("span",{children:["$",y.toFixed(2)]})]}),C.jsxs(rn,{justify:"space-between",children:[C.jsx("span",{style:{color:K.mute},children:"Weave fee"}),C.jsxs("span",{children:["$",w.toFixed(2)]})]}),C.jsx(Pa,{}),C.jsxs(rn,{justify:"space-between",style:{fontWeight:500,color:K.ink},children:[C.jsx("span",{children:"Total fees"}),C.jsxs("span",{children:["$",b.toFixed(2)]})]}),o&&C.jsx("div",{style:{fontSize:11,color:K.mute,textAlign:"center"},children:"Fetching live rate…"})]}),C.jsxs(ve,{gap:8,children:[i&&C.jsx("div",{style:{background:"#FBEEE9",border:`1px solid ${K.err}33`,borderRadius:10,padding:"10px 12px",fontSize:12,color:K.err,lineHeight:1.5},children:i}),C.jsxs("button",{onClick:n,disabled:r,style:{...ps,opacity:r?.6:1,cursor:r?"not-allowed":"pointer"},children:[r?"Creating order…":"Confirm in wallet",!r&&C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12H19M13 6L19 12L13 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),C.jsx("div",{style:{fontSize:11,color:K.mute,textAlign:"center"},children:"Rate locked for 30s · You'll sign one transaction in your wallet"})]})]})}function gf(){return C.jsxs("div",{style:{position:"relative",width:56,height:56},children:[C.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 56 56",style:{position:"absolute",inset:0},children:[C.jsx("circle",{cx:"28",cy:"28",r:"24",stroke:K.hair,strokeWidth:"2.5",fill:"none"}),C.jsx("circle",{cx:"28",cy:"28",r:"24",stroke:K.accent,strokeWidth:"2.5",fill:"none",strokeDasharray:"40 150",strokeLinecap:"round",style:{transformOrigin:"center",animation:"wspin 1.2s linear infinite"}})]}),C.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsx(Sg,{size:22})})]})}function LL({onNext:e,details:t}){const[n,r]=ce.useState(!0),[i,s]=ce.useState(null),o=ce.useRef(!1),a=()=>{if(!t){s("Payment details unavailable. Please retry."),r(!1);return}const{accessCode:c}=t,u=()=>{if(o.current)return;o.current=!0,r(!1);const d=window.PaystackPop;if(!d){s("Paystack failed to load. Please check your connection and retry."),o.current=!1;return}new d().resumeTransaction(c,{onSuccess:()=>e("processing"),onCancel:()=>{o.current=!1}})};if(window.PaystackPop){u();return}const l=document.createElement("script");l.src="https://js.paystack.co/v2/inline.js",l.onload=u,l.onerror=()=>{r(!1),s("Could not load Paystack. Check your network and try again.")},document.head.appendChild(l)};return ce.useEffect(()=>{a()},[]),n?C.jsx(ve,{gap:24,style:{padding:"28px 20px"},children:C.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[C.jsx("div",{style:{width:36,height:36,borderRadius:"50%",border:`3px solid ${K.hair}`,borderTopColor:K.accent,animation:"wspin 0.8s linear infinite",margin:"0 auto"}}),C.jsx("div",{style:{marginTop:14,fontSize:14,color:K.mute},children:"Opening payment popup…"})]})}):i?C.jsxs(ve,{gap:16,style:{padding:"28px 20px"},children:[C.jsx("div",{style:{textAlign:"center",fontSize:14,color:K.err,padding:"8px 0"},children:i}),C.jsx("button",{onClick:()=>{o.current=!1,s(null),r(!0),a()},style:ps,children:"Retry"})]}):C.jsxs(ve,{gap:16,style:{padding:"28px 20px"},children:[C.jsx("div",{style:{textAlign:"center",fontSize:14,color:K.mute,padding:"12px 0"},children:"A Paystack payment popup has opened. Complete payment there to continue."}),C.jsx("button",{onClick:()=>{o.current=!1,a()},style:{...ps,background:K.page,color:K.ink},children:"Re-open popup"})]})}const jL=new Set(["completed"]),$L=new Set(["failed","expired","refunded"]);function j5({onNext:e,merchant:t,mode:n,apiKey:r,orderId:i,bankDetails:s,currencies:o,fmtCur:a}){const[c,u]=ce.useState(0),[l,d]=ce.useState(0),f=ce.useRef(!1),h=Ti[t.currency];ce.useEffect(()=>{const b=setInterval(()=>d(E=>E+1),1e3);return()=>clearInterval(b)},[]);const m=s!=null&&s.amountToTransfer?(()=>{const b=s.amountToTransfer,E=b.includes(".")?b.split(".")[1].length:0;return a(Number(b),t.currency,E)})():a(t.amount,t.currency),y=n==="fiat"?[{label:"Confirming your transfer",sub:`Matching the ${m} from your bank`,dur:1600},{label:"Completing payment",sub:`Sending to ${t.name}`,dur:2400}]:[{label:"Confirming transaction",sub:"Processing your transaction on-chain",dur:1400},{label:"Confirming your payment",sub:`Settling ${(h==null?void 0:h.name)||t.currency} to ${t.name}`,dur:2600}];ce.useEffect(()=>{if(i)return;if(c>=y.length){e("success");return}const b=setTimeout(()=>u(E=>E+1),y[c].dur);return()=>clearTimeout(b)},[c,i]),ce.useEffect(()=>{if(!i)return;f.current=!1;let b,E=0;const v=5e3,A=3e4,P=async()=>{if(f.current)return;try{const L=await ju(r,i);E=0;const U=String(L.status??"").toLowerCase(),j=String(L.paycrestStatus??"").toLowerCase();if(jL.has(U)){f.current=!0,e("success");return}if($L.has(U)){f.current=!0,e("error");return}j==="fulfilled"&&u(1)}catch{E++}const M=Math.min(v*Math.pow(2,E),A);b=setTimeout(P,M)};return P(),()=>{f.current=!0,clearTimeout(b)}},[i,r]);const w=y[Math.min(c,y.length-1)];return C.jsxs(ve,{gap:20,style:{padding:"28px 20px 12px",minHeight:360},children:[C.jsxs(ve,{gap:12,style:{alignItems:"center",paddingTop:12},children:[C.jsx(gf,{}),C.jsxs(ve,{gap:4,style:{alignItems:"center"},children:[C.jsx("div",{style:{fontSize:17,fontWeight:600,letterSpacing:-.3},children:w.label}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,textAlign:"center"},children:w.sub})]})]}),C.jsx(ve,{gap:0,style:{padding:"4px 8px"},children:y.map((b,E)=>C.jsxs(rn,{gap:12,style:{padding:"10px 0"},children:[C.jsxs("div",{style:{width:22,height:22,borderRadius:11,flexShrink:0,background:E<c?K.accent:"#fff",border:E<c?"none":`1.5px solid ${E===c?K.accent:K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[E<c&&C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})}),E===c&&C.jsx("div",{style:{width:8,height:8,borderRadius:4,background:K.accent,animation:"wpulse 1.1s ease-in-out infinite"}})]}),C.jsxs(ve,{gap:1,children:[C.jsx("div",{style:{fontSize:13,fontWeight:500,color:E<=c?K.ink:K.mute},children:b.label}),C.jsx("div",{style:{fontSize:11.5,color:K.mute},children:E<c?"Completed":E===c?b.sub:"Pending"})]})]},E))}),C.jsx("div",{style:{fontSize:11,color:K.mute,textAlign:"center"},children:"You can safely close this window. We'll email a receipt."})]})}function $5({onNext:e,merchant:t,balance:n,direction:r,apiKey:i,orderId:s,accentColor:o,currencies:a,fmtCur:c}){var P,M,L,U;const[u,l]=ce.useState(null);ce.useEffect(()=>{if(!s)return;let j=!1;return ju(i,s).then(Z=>{j||l(Z)}).catch(()=>{}),()=>{j=!0}},[i,s]);const f=(u!=null&&u.sourceAssetKey?II(u.sourceAssetKey):void 0)||n,h=f.token||(typeof(u==null?void 0:u.sourceAssetKey)=="string"?u.sourceAssetKey.split(":").pop():void 0),m=u?Number(u.sourceAmount):t.amount,y=r==="offramp"&&u?`${$u(Number(u.sourceAmount),4)} ${h??f.token}`:`${c(m,t.currency)}`,w=(P=u==null?void 0:u.destInstrument)==null?void 0:P.bankInstitution,b=r==="offramp"?w?bw(t.currency,w):((M=a[t.currency])==null?void 0:M.bank)||((L=Ti[t.currency])==null?void 0:L.bank):t.name,E=u!=null&&u.createdAt&&(u!=null&&u.updatedAt)?Math.max(1,Math.round((new Date(u.updatedAt).getTime()-new Date(u.createdAt).getTime())/1e3)):null,v=E==null?"—":E<60?`${E}s`:`${Math.round(E/60)}m`,A=!u;return C.jsxs(ve,{gap:18,style:{padding:"28px 20px 12px",minHeight:360},children:[C.jsxs(ve,{gap:14,style:{alignItems:"center",paddingTop:8},children:[C.jsx("div",{style:{width:64,height:64,borderRadius:32,background:K.accent,display:"flex",alignItems:"center",justifyContent:"center",animation:"wpop 0.5s cubic-bezier(0.2, 1.2, 0.4, 1)"},children:C.jsx("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"white",strokeWidth:"3.2",strokeLinecap:"round",strokeLinejoin:"round"})})}),C.jsxs(ve,{gap:4,style:{alignItems:"center"},children:[C.jsx("div",{style:{fontSize:20,fontWeight:600,letterSpacing:-.3},children:"Payment complete"}),C.jsx("div",{style:{fontSize:13,color:K.mute,textAlign:"center",lineHeight:1.5,maxWidth:280,animation:A?"wpulse 1.5s ease-in-out infinite":void 0},children:r==="offramp"?C.jsxs(C.Fragment,{children:[c(t.amount,t.currency)," is on its way to ",C.jsx("span",{style:{color:K.ink},children:t.name}),"."]}):C.jsxs(C.Fragment,{children:["Your payment of ",c(m,t.currency)," has been sent to ",C.jsx("span",{style:{color:K.ink},children:t.name}),"."]})})]})]}),C.jsxs(ve,{gap:0,style:{background:K.panel,border:`1px solid ${K.hair}`,borderRadius:12,overflow:"hidden"},children:[C.jsxs(rn,{justify:"space-between",style:{padding:"12px 14px",fontSize:12.5},children:[C.jsx("span",{style:{color:K.mute},children:"Paid with"}),r==="offramp"?C.jsxs(rn,{gap:6,style:{animation:A?"wpulse 1.5s ease-in-out infinite":void 0},children:[C.jsx(Ra,{bg:f.chainTint||f.tint,size:16,children:f.logo?C.jsx("img",{src:f.logo,style:{width:"100%",height:"100%",objectFit:"cover"}}):f.icon?f.icon:f.flag?f.flag:f.symbol}),C.jsx("span",{style:{fontWeight:500},children:y})]}):C.jsxs(rn,{gap:6,children:[C.jsx("div",{style:{width:16,height:16,borderRadius:8,background:"#fff",border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10},children:((U=a[t.currency])==null?void 0:U.flag)||"🇳🇬"}),C.jsx("span",{style:{fontWeight:500},children:c(m,t.currency)})]})]}),C.jsx(Pa,{}),C.jsxs(rn,{justify:"space-between",style:{padding:"12px 14px",fontSize:12.5},children:[C.jsx("span",{style:{color:K.mute},children:r==="offramp"?"Settled to":"Paid to"}),C.jsx("span",{style:{fontWeight:500,animation:A?"wpulse 1.5s ease-in-out infinite":void 0},children:b})]}),C.jsx(Pa,{}),C.jsxs(rn,{justify:"space-between",style:{padding:"12px 14px",fontSize:12.5},children:[C.jsx("span",{style:{color:K.mute},children:"Completed in"}),C.jsx(rn,{gap:6,children:C.jsx("span",{style:{animation:A?"wpulse 1.5s ease-in-out infinite":void 0},children:C.jsx(Fu,{tone:"good",children:v})})})]})]}),C.jsxs(ve,{gap:8,children:[C.jsx("button",{onClick:()=>e("connect"),style:ps,children:"Done"}),C.jsxs("button",{onClick:()=>CL(t,u,b,o),style:{...kg,justifyContent:"center",paddingLeft:0},children:[C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M12 3V15M12 15L7 10M12 15L17 10M3 19H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Download receipt"]})]})]})}function F5({onNext:e,onBack:t}){return C.jsxs(ve,{gap:16,style:{padding:"28px 20px 12px",minHeight:360},children:[C.jsxs(ve,{gap:14,style:{alignItems:"center",paddingTop:8},children:[C.jsx("div",{style:{width:64,height:64,borderRadius:32,background:"#FBEEE9",display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",children:[C.jsx("path",{d:"M12 8V13M12 17V17.01",stroke:K.err,strokeWidth:"2.4",strokeLinecap:"round"}),C.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:K.err,strokeWidth:"2"})]})}),C.jsxs(ve,{gap:4,style:{alignItems:"center"},children:[C.jsx("div",{style:{fontSize:18,fontWeight:600},children:"Transaction didn't go through"}),C.jsx("div",{style:{fontSize:13,color:K.mute,textAlign:"center",maxWidth:280},children:"Your wallet rejected the signature or the rate expired. No funds were moved."})]})]}),C.jsxs(ve,{gap:8,children:[C.jsx("button",{onClick:()=>t("quote"),style:ps,children:"Try again"}),C.jsx("button",{onClick:()=>e("connect"),style:kg,children:"Use a different payment method"})]})]})}const FL=new Set(["XRP","TON","STELLAR","NEAR"]),DL={BASE:"0x…",ETHEREUM:"0x…",ARBITRUM:"0x…",OPTIMISM:"0x…",POLYGON:"0x…",BSC:"0x…",AVALANCHE:"0x…",GNOSIS:"0x…",SCROLL:"0x…",XLAYER:"0x…",MONAD:"0x…",BERA:"0x…",SOLANA:"e.g. 5Gh8…base58",TRON:"T…",NEAR:"alice.near or 64-hex",TON:"UQ… / EQ…",SUI:"0x… (64 chars)",APTOS:"0x… (64 chars)",STARKNET:"0x…",BITCOIN:"bc1… or 1…",XRP:"r…",STELLAR:"G…",CARDANO:"addr1…",DOGE:"D…",LITECOIN:"ltc1… or L…",BCH:"bitcoincash:q… or q…",ZEC:"t1… or zs1…",DASH:"X…"},UL={"BASE:USDC":{chainId:8453,contract:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",decimals:6},"OPTIMISM:USDC":{chainId:10,contract:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",decimals:6},"ARBITRUM:USDC":{chainId:42161,contract:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",decimals:6},"POLYGON:USDC":{chainId:137,contract:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",decimals:6}},HL=(e,t,n,r)=>{if(!e)return"";if(!t||!n||!r)return e;const i=UL[`${n.toUpperCase()}:${r.toUpperCase()}`];if(!i)return e;const s=Math.ceil(t*100)/100,o=BigInt(Math.round(s*10**i.decimals));return`ethereum:${i.contract}@${i.chainId}/transfer?address=${e}&uint256=${o.toString()}`};function zL({onNext:e,merchant:t,depositAddress:n,depositMemo:r,amountToSend:i,sourceToken:s,sourceChain:o,loading:a,error:c,onChainChange:u,ready:l,apiKey:d,orderId:f,preSelectedChainIdx:h,depositChains:m,currencies:y,fmtCur:w}){var ge,z;const[b,E]=ce.useState(""),[v,A]=ce.useState(h??null),[P,M]=ce.useState(!1),[L,U]=ce.useState(""),[j,Z]=ce.useState(""),[Y,W]=ce.useState(!1),[I,p]=ce.useState(!1),[g,S]=ce.useState(!1),R=L.trim()?m.map((F,oe)=>({c:F,i:oe})).filter(({c:F})=>{const oe=L.trim().toLowerCase();return F.name.toLowerCase().includes(oe)||F.token.toLowerCase().includes(oe)||F.network.toLowerCase().includes(oe)||F.id.toLowerCase().includes(oe)}):m.map((F,oe)=>({c:F,i:oe})),T=v!=null?m[v]:null,B=n??"",$=r??"",O=s??(T==null?void 0:T.token)??"",_=t.amount/(((ge=y[t.currency])==null?void 0:ge.rate)||((z=Ti[t.currency])==null?void 0:z.rate)||1),D=i??_,ue=HL(B,i,o,s),ne=ce.useRef(null),G=T?FL.has(T.id):!1,J=()=>{if(!T||!j.trim())return;const F=`${T.id}:${T.token}:${j.trim()}`;ne.current!==F&&(ne.current=F,W(!0),u(T.id,T.token,j.trim()))};ce.useEffect(()=>{W(!1),Z(""),ne.current=null},[v]),ce.useEffect(()=>{if(!f)return;let F=!1,oe;const de=async()=>{if(!F){try{const Ee=await ju(d,f),Se=String(Ee.status??"").toLowerCase(),xe=String(Ee.nearStatus??"").toLowerCase();E(xe);const Pt=Array.isArray(Ee.steps)&&Ee.steps.some(Ze=>(Ze==null?void 0:Ze.provider)==="nearintents")&&xe==="processing";if(Se&&Se!=="awaiting_deposit"||Pt){F=!0,Se==="completed"?e("success"):["failed","refunded"].includes(Se)?e("error"):e("processing");return}}catch{}oe=setTimeout(de,5e3)}};return de(),()=>{F=!0,clearTimeout(oe)}},[d,f,e]);const te=()=>{var F;B&&((F=navigator.clipboard)==null||F.writeText(B),p(!0),setTimeout(()=>p(!1),1500))},le=()=>{var F;$&&((F=navigator.clipboard)==null||F.writeText($),S(!0),setTimeout(()=>S(!1),1500))};return P?C.jsxs(ve,{gap:12,style:{padding:"16px 20px 6px"},children:[C.jsxs(ve,{gap:8,children:[C.jsxs("button",{onClick:()=>{M(!1),U("")},style:{alignSelf:"flex-start",padding:"4px 0",background:"transparent",border:"none",cursor:"pointer",fontSize:12,color:K.mute,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:[C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M15 18L9 12L15 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back"]}),C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Select a network"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"We'll generate a deposit address for the network you choose."})]}),C.jsxs("div",{style:{position:"relative"},children:[C.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:[C.jsx("circle",{cx:"11",cy:"11",r:"7",stroke:K.mute,strokeWidth:"2"}),C.jsx("path",{d:"M20 20L16 16",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round"})]}),C.jsx("input",{autoFocus:!0,placeholder:"Search networks or tokens…",value:L,onChange:F=>U(F.target.value),style:{width:"100%",boxSizing:"border-box",padding:"10px 12px 10px 34px",borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",fontSize:13,fontFamily:"inherit",color:K.ink,outline:"none"}})]}),C.jsx("div",{style:{maxHeight:360,overflowY:"auto",border:`1px solid ${K.hair}`,borderRadius:10,background:"#fff",padding:4,display:"flex",flexDirection:"column",gap:1},children:R.length===0?C.jsxs("div",{style:{padding:"24px 10px",fontSize:12,color:K.mute,textAlign:"center"},children:['No matches for "',L.trim(),'"']}):R.map(({c:F,i:oe})=>C.jsxs("button",{onClick:()=>{A(oe),M(!1),U("")},style:{width:"100%",padding:"10px 10px",borderRadius:7,background:oe===v?K.accentSoft:"transparent",border:"none",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:10,textAlign:"left"},children:[C.jsx(Ra,{bg:F.tint,size:24,children:F.logo?C.jsx("img",{src:F.logo,style:{width:"100%",height:"100%",borderRadius:"inherit",objectFit:"cover"}}):F.icon}),C.jsxs("div",{style:{flex:1},children:[C.jsxs("div",{style:{fontSize:13,fontWeight:500},children:[F.token," on ",F.name]}),C.jsx("div",{style:{fontSize:10.5,color:K.mute},children:F.network})]}),oe===v&&C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:K.accent,strokeWidth:"2.8",strokeLinecap:"round",strokeLinejoin:"round"})})]},`${F.id}:${F.token}`))})]}):C.jsxs(ve,{gap:14,style:{padding:"16px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Send from any wallet"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"Scan the QR or copy the address. Send from a mobile wallet, exchange, or hardware device — we'll detect the deposit automatically."})]}),C.jsxs(ve,{gap:6,children:[C.jsx("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Network"}),C.jsx("button",{onClick:()=>M(!0),style:{padding:"10px 12px",borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:10,textAlign:"left"},children:T?C.jsxs(C.Fragment,{children:[C.jsx(Ra,{bg:T.tint,size:26,children:T.logo?C.jsx("img",{src:T.logo,style:{width:"100%",height:"100%",objectFit:"cover"}}):T.icon}),C.jsxs(ve,{gap:1,style:{flex:1},children:[C.jsxs("div",{style:{fontSize:13.5,fontWeight:500},children:[T.token," on ",T.name]}),C.jsx("div",{style:{fontSize:11,color:K.mute},children:T.network})]}),C.jsx("div",{style:{fontSize:11,color:K.mute},children:"Change"})]}):C.jsxs(C.Fragment,{children:[C.jsx("div",{style:{width:26,height:26,borderRadius:13,border:`1px dashed ${K.hair}`,background:K.panel,display:"flex",alignItems:"center",justifyContent:"center",color:K.mute,fontSize:13},children:"?"}),C.jsxs(ve,{gap:1,style:{flex:1},children:[C.jsx("div",{style:{fontSize:13.5,fontWeight:500,color:K.ink},children:"Choose a network"}),C.jsx("div",{style:{fontSize:11,color:K.mute},children:"30+ chains supported · powered by NEAR Intents"})]}),C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M6 9L12 15L18 9",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]}),T?Y?C.jsxs(C.Fragment,{children:[C.jsxs("div",{style:{background:K.panel,border:`1px solid ${K.hair}`,borderRadius:12,padding:"16px",display:"flex",gap:14,alignItems:"center"},children:[C.jsx("div",{style:{padding:8,background:"#fff",borderRadius:10,border:`1px solid ${K.hair}`,flexShrink:0},children:ue?C.jsx(SL,{value:ue,size:120,level:"M",includeMargin:!1}):C.jsxs("div",{style:{width:120,height:120,borderRadius:12,background:K.panel,border:`1px dashed ${K.hair}`,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10},children:[C.jsx("div",{className:"weaving-spinner"}),C.jsx("div",{style:{fontSize:10,color:K.mute,letterSpacing:.8,fontWeight:500,textTransform:"uppercase"},children:"Generating Address"})]})}),C.jsxs(ve,{gap:8,style:{flex:1,minWidth:0},children:[C.jsxs(ve,{gap:2,children:[C.jsx("div",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Amount"}),C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:a?C.jsx("span",{style:{color:K.mute,fontWeight:400},children:"Calculating…"}):C.jsxs(C.Fragment,{children:[$u(D)," ",O]})}),C.jsxs("div",{style:{fontSize:11,color:K.mute},children:["on ",T.name]})]}),C.jsxs("div",{style:{fontSize:10.5,color:K.mute,lineHeight:1.4},children:["Rate locked for ",C.jsx("span",{style:{color:K.ink,fontWeight:500},children:"9:42"})]})]})]}),C.jsxs(ve,{gap:6,children:[C.jsx("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Deposit address"}),C.jsxs("div",{style:{display:"flex",alignItems:"center",border:`1px solid ${K.hair}`,borderRadius:10,background:"#fff",overflow:"hidden"},children:[C.jsx("div",{style:{flex:1,padding:"10px 12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12.5,color:B?K.ink:K.mute,letterSpacing:-.2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a?"Generating address…":B||"—"}),C.jsx("button",{onClick:te,disabled:!B,style:{height:40,padding:"0 14px",border:"none",borderLeft:`1px solid ${K.hair}`,background:I?K.accentSoft:"#fff",color:I?K.accent:B?K.ink:K.mute,fontSize:12,fontWeight:500,cursor:B?"pointer":"not-allowed",fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:I?C.jsxs(C.Fragment,{children:[C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied"]}):C.jsxs(C.Fragment,{children:[C.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:[C.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2",stroke:"currentColor",strokeWidth:"2"}),C.jsx("path",{d:"M16 8V5C16 4.45 15.55 4 15 4H5C4.45 4 4 4.45 4 5V15C4 15.55 4.45 16 5 16H8",stroke:"currentColor",strokeWidth:"2"})]}),"Copy"]})})]}),c&&C.jsxs(ve,{gap:6,children:[C.jsx("div",{style:{fontSize:11.5,color:K.err},children:c}),C.jsx("button",{onClick:()=>{W(!1),ne.current=null},style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:7,background:"transparent",border:`1px solid ${K.hair}`,cursor:"pointer",fontFamily:"inherit",fontSize:11.5,color:K.ink},children:"Edit refund address"})]})]}),($||G)&&C.jsxs(ve,{gap:6,children:[C.jsxs("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6,display:"flex",alignItems:"center",gap:6},children:[T.id==="XRP"?"Destination tag":"Memo",C.jsx("span",{style:{fontSize:10,color:K.warn,fontWeight:600,letterSpacing:.4},children:"REQUIRED"})]}),C.jsxs("div",{style:{display:"flex",alignItems:"center",border:`1px solid ${K.hair}`,borderRadius:10,background:"#fff",overflow:"hidden"},children:[C.jsx("div",{style:{flex:1,padding:"10px 12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12.5,color:$?K.ink:K.mute,letterSpacing:-.2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a?"Generating memo…":$||"—"}),C.jsx("button",{onClick:le,disabled:!$,style:{height:40,padding:"0 14px",border:"none",borderLeft:`1px solid ${K.hair}`,background:g?K.accentSoft:"#fff",color:g?K.accent:$?K.ink:K.mute,fontSize:12,fontWeight:500,cursor:$?"pointer":"not-allowed",fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:g?C.jsxs(C.Fragment,{children:[C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied"]}):C.jsxs(C.Fragment,{children:[C.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:[C.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2",stroke:"currentColor",strokeWidth:"2"}),C.jsx("path",{d:"M16 8V5C16 4.45 15.55 4 15 4H5C4.45 4 4 4.45 4 5V15C4 15.55 4.45 16 5 16H8",stroke:"currentColor",strokeWidth:"2"})]}),"Copy"]})})]}),C.jsxs("div",{style:{fontSize:11,color:K.warn,lineHeight:1.5},children:["You must include this ",T.id==="XRP"?"destination tag":"memo"," when you send — without it the funds can't be credited and may be lost."]})]}),C.jsxs("div",{style:{background:K.warnSoft,border:`1px solid ${K.warn}22`,borderRadius:10,padding:"10px 12px",display:"flex",gap:10,fontSize:11.5,color:K.warn,lineHeight:1.5},children:[C.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0,marginTop:1},children:[C.jsx("path",{d:"M12 2L2 20H22L12 2Z",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"}),C.jsx("path",{d:"M12 10V13M12 16V16.01",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),C.jsxs("span",{children:["Only send ",C.jsx("b",{children:T.token})," on the ",C.jsx("b",{children:T.name})," network. Sending other assets or from a different network may result in loss."]})]}),C.jsx("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",background:b==="incomplete_deposit"?"#FFF5F5":"#fff",border:`1px solid ${b==="incomplete_deposit"?"#FFD1D1":K.hair}`,borderRadius:10},children:b==="incomplete_deposit"?C.jsx("div",{style:{flex:1,fontSize:12,color:"#D94E4E",fontWeight:500,lineHeight:1.4},children:"Partial payment received. Still waiting for the remaining balance to complete your order."}):C.jsxs(C.Fragment,{children:[C.jsxs("div",{style:{position:"relative",width:10,height:10},children:[C.jsx("div",{style:{position:"absolute",inset:0,borderRadius:5,background:K.accent}}),C.jsx("div",{style:{position:"absolute",inset:-3,borderRadius:8,background:K.accent,opacity:.25,animation:"wpulse 1.6s ease-in-out infinite"}})]}),C.jsxs("div",{style:{flex:1,fontSize:12,color:K.ink2},children:["Watching for deposit on ",T.name,"…"]})]})})]}):C.jsxs(ve,{gap:10,children:[C.jsxs(ve,{gap:6,children:[C.jsxs("label",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:["Your refund wallet on ",T.name]}),C.jsx("input",{autoFocus:!0,placeholder:DL[T.id]??"Paste your wallet address",value:j,onChange:F=>Z(F.target.value),onKeyDown:F=>{F.key==="Enter"&&J()},style:{width:"100%",boxSizing:"border-box",padding:"11px 14px",borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",fontSize:13,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:K.ink,outline:"none",letterSpacing:-.2}}),C.jsxs("div",{style:{fontSize:11,color:K.mute,lineHeight:1.5},children:["If the swap fails or you send the wrong amount, funds are returned to this address. Must be a valid address on ",C.jsx("b",{children:T.name}),"."]})]}),C.jsx("button",{onClick:J,disabled:!j.trim(),style:{...ps,opacity:j.trim()?1:.5,cursor:j.trim()?"pointer":"not-allowed"},children:"Generate deposit address"})]}):C.jsx("div",{style:{background:K.panel,border:`1px dashed ${K.hair}`,borderRadius:12,padding:"28px 16px",textAlign:"center",fontSize:12.5,color:K.mute,lineHeight:1.5},children:"Pick a network above to generate your deposit address."})]})}const Ag={width:"100%",padding:"11px 14px",borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",fontSize:14,fontWeight:500,color:K.ink,fontFamily:"inherit",outline:"none",boxSizing:"border-box"};function WL({merchant:e,value:t,onChange:n,onSubmit:r,submitting:i,error:s}){const o=yw[e.currency]??[],a=t.institution.length>0&&t.accountIdentifier.trim().length>=8&&t.accountName.trim().length>=2;return C.jsxs(ve,{gap:14,style:{padding:"16px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Where should refunds go?"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"If your payment can't be matched, we'll return the funds to this account. Must be in your name."})]}),C.jsxs(ve,{gap:10,children:[C.jsxs(ve,{gap:6,children:[C.jsx("label",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Bank"}),C.jsxs("select",{value:t.institution,onChange:c=>n({...t,institution:c.target.value}),style:{...Ag,appearance:"none",backgroundImage:`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none'><path d='M6 9L12 15L18 9' stroke='%236B7572' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 12px center",paddingRight:36},children:[C.jsx("option",{value:"",disabled:!0,children:"Select your bank…"}),o.map(c=>C.jsx("option",{value:c.code,children:c.name},c.code))]})]}),C.jsxs(ve,{gap:6,children:[C.jsx("label",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Account number"}),C.jsx("input",{inputMode:"numeric",placeholder:"0123456789",value:t.accountIdentifier,onChange:c=>n({...t,accountIdentifier:c.target.value.replace(/\D/g,"")}),style:{...Ag,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",letterSpacing:-.2}})]}),C.jsxs(ve,{gap:6,children:[C.jsx("label",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Account name"}),C.jsx("input",{placeholder:"Full name as it appears on your account",value:t.accountName,onChange:c=>n({...t,accountName:c.target.value}),style:Ag})]})]}),C.jsxs("div",{style:{background:K.panel,border:`1px solid ${K.hair}`,borderRadius:10,padding:"10px 12px",display:"flex",gap:10,fontSize:11.5,color:K.ink2,lineHeight:1.5},children:[C.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0,marginTop:1,color:K.mute},children:[C.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.8"}),C.jsx("path",{d:"M12 8V13M12 16V16.01",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),C.jsx("span",{children:"We only use this account if the payment fails. Refunds arrive within 1 business day."})]}),s&&C.jsx("div",{style:{background:"#FBEEE9",border:`1px solid ${K.err}33`,borderRadius:10,padding:"10px 12px",fontSize:12,color:K.err,lineHeight:1.5},children:s}),C.jsx("button",{onClick:r,disabled:!a||i,style:{...ps,opacity:a&&!i?1:.5,cursor:a&&!i?"pointer":"not-allowed"},children:i?"Creating payment…":"Continue"})]})}const GL={NGN:{bank:"Wema Bank",accountNumber:"8203 7461 92",accountName:"Weave / Afriloom-0481"}};function qL({onNext:e,merchant:t,bankDetails:n,apiKey:r,orderId:i,currencies:s,fmtCur:o}){const a=Ti[t.currency],c=n?{bank:bw(t.currency,n.institution),accountNumber:n.accountIdentifier,accountName:n.accountName}:GL[t.currency],u=n!=null&&n.amountToTransfer?(()=>{const E=n.amountToTransfer,v=E.includes(".")?E.split(".")[1].length:0;return o(Number(E),t.currency,v)})():o(t.amount,t.currency),[l,d]=ce.useState(null),[f,h]=ce.useState(9),[m,y]=ce.useState(42);ce.useEffect(()=>{const E=setInterval(()=>{y(v=>v>0?v-1:(h(A=>Math.max(0,A-1)),59))},1e3);return()=>clearInterval(E)},[]),ce.useEffect(()=>{if(!i)return;let E=!1,v;const A=async()=>{if(!E){try{const P=await ju(r,i),M=String(P.status??"").toLowerCase();if(M&&M!=="awaiting_deposit"){E=!0,M==="completed"?e("success"):["failed","refunded"].includes(M)?e("error"):e("processing");return}}catch{}v=setTimeout(A,5e3)}};return A(),()=>{E=!0,clearTimeout(v)}},[r,i,e]);const w=(E,v)=>{var A;(A=navigator.clipboard)==null||A.writeText(v),d(E),setTimeout(()=>d(null),1400)},b=({label:E,value:v,k:A,mono:P=!0})=>C.jsxs(rn,{justify:"space-between",style:{padding:"11px 14px"},children:[C.jsxs(ve,{gap:2,style:{minWidth:0},children:[C.jsx("div",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:E}),C.jsx("div",{style:{fontSize:14,fontWeight:500,color:K.ink,fontFamily:P?"ui-monospace, SFMono-Regular, Menlo, monospace":"inherit",letterSpacing:P?-.2:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v})]}),C.jsx("button",{onClick:()=>w(A,v),style:{height:28,padding:"0 10px",borderRadius:7,border:`1px solid ${K.hair}`,background:l===A?K.accentSoft:"#fff",color:l===A?K.accent:K.ink,fontSize:11.5,fontWeight:500,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:5},children:l===A?C.jsxs(C.Fragment,{children:[C.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied"]}):"Copy"})]});return C.jsxs(ve,{gap:14,style:{padding:"16px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsxs(rn,{justify:"space-between",align:"flex-start",children:[C.jsxs("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:["Send ",u]}),C.jsxs(Fu,{tone:"warn",children:[C.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",style:{marginRight:2},children:[C.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2"}),C.jsx("path",{d:"M12 7V12L15 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),f,":",String(m).padStart(2,"0")]})]}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"Open your bank app and transfer to this account. We'll confirm your payment automatically — no need to send proof."})]}),C.jsxs("div",{style:{background:"#fff",border:`1px solid ${K.hair}`,borderRadius:12,overflow:"hidden"},children:[C.jsxs(rn,{gap:10,style:{padding:"12px 14px",background:K.panel,borderBottom:`1px solid ${K.hair}`},children:[C.jsx("div",{style:{width:28,height:28,borderRadius:14,background:"#fff",border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600,color:K.ink},children:a.flag}),C.jsxs(ve,{gap:1,style:{flex:1},children:[C.jsx("div",{style:{fontSize:13,fontWeight:500},children:c.bank}),C.jsxs("div",{style:{fontSize:11,color:K.mute},children:["Virtual account · one-time · ",t.currency]})]})]}),C.jsx(b,{label:"Account number",value:c.accountNumber,k:"acc"}),C.jsx(Pa,{}),C.jsx(b,{label:"Account name",value:c.accountName,k:"name",mono:!1}),C.jsx(Pa,{}),C.jsx(b,{label:"Amount",value:u,k:"amt",mono:!1})]}),C.jsxs("div",{style:{background:K.warnSoft,border:`1px solid ${K.warn}22`,borderRadius:10,padding:"10px 12px",display:"flex",gap:10,fontSize:11.5,color:K.warn,lineHeight:1.5},children:[C.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0,marginTop:1},children:[C.jsx("path",{d:"M12 2L2 20H22L12 2Z",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"}),C.jsx("path",{d:"M12 10V13M12 16V16.01",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),C.jsx("span",{children:"Send the exact amount. Any difference may delay delivery."})]})]})}function VL({onConnected:e,onExternalFlow:t}){const{connect:n,connectors:r,isPending:i}=dN(),{isConnected:s}=Zm();return ce.useEffect(()=>{s&&e()},[s]),C.jsxs(ve,{gap:16,style:{padding:"22px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Connect your wallet"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"Pay directly from your crypto holdings. We'll handle the conversion."})]}),C.jsx(ve,{gap:8,children:r.map(o=>{const a=o.name.toLowerCase(),c=a.includes("metamask")?"Browser extension or MetaMask mobile":a.includes("coinbase")?"Coinbase Wallet app or extension":a.includes("phantom")?"Phantom wallet extension":a.includes("brave")?"Brave browser built-in wallet":"Connect with this wallet";return C.jsxs("button",{onClick:()=>n({connector:o}),disabled:i,style:{...Du,opacity:i?.6:1},children:[C.jsx("div",{style:{width:40,height:40,borderRadius:10,background:K.panel,border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden"},children:o.icon?C.jsx("img",{src:o.icon,alt:o.name,style:{width:28,height:28,borderRadius:6,objectFit:"contain"}}):C.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",children:[C.jsx("rect",{x:"2",y:"6",width:"20",height:"14",rx:"3",stroke:K.ink2,strokeWidth:"1.8"}),C.jsx("path",{d:"M2 10H22",stroke:K.ink2,strokeWidth:"1.8"}),C.jsx("circle",{cx:"17",cy:"15",r:"1.5",fill:K.ink2})]})}),C.jsxs(ve,{gap:2,style:{flex:1,textAlign:"left"},children:[C.jsx("div",{style:{fontSize:14,fontWeight:500},children:o.name}),C.jsx("div",{style:{fontSize:11.5,color:K.mute},children:c})]}),i?C.jsx("div",{style:{width:12,height:12,borderRadius:6,background:K.accent,opacity:.5,animation:"wpulse 1s infinite"}}):C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},o.uid)})}),C.jsx("button",{onClick:t,style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:K.mute,padding:"4px 0",textAlign:"center"},children:"Don't have a browser wallet? Send from any app →"})]})}function KL({onSelectToken:e,onExternalFlow:t,merchant:n,currencies:r,fmtCur:i,ethUsdPrice:s,loadingEthPrice:o}){var g,S;const{address:a,chainId:c}=Zm(),{switchChain:u,isPending:l}=mN(),d=c?B5[c]:void 0,f=c?N5[c]:void 0,h=c?vL.has(c):!1,m=c?Eg[c]??"Unknown":"Unknown",y=c?M5[c]??K.accent:K.accent,w=a?`${a.slice(0,6)}…${a.slice(-4)}`:"",{data:b,isLoading:E}=cg({address:a,chainId:c,query:{enabled:!!a}}),{data:v,isLoading:A}=cg({address:a,token:d,chainId:c,query:{enabled:!!a&&!!d}}),{data:P,isLoading:M}=cg({address:a,token:f,chainId:c,query:{enabled:!!a&&!!f}}),L=b?Number(dd(b.value)):0,U=v?Number(fa(v.value,v.decimals)):0,j=P?Number(fa(P.value,P.decimals)):0;if(o||E||A||M)return C.jsxs(ve,{style:{padding:"60px 0",minHeight:280,alignItems:"center",justifyContent:"center"},children:[C.jsx(gf,{}),C.jsx("div",{style:{marginTop:16,fontSize:13,color:K.mute},children:"Fetching market rates…"})]});const Y=L*s,W=n.amount/(((g=r[n.currency])==null?void 0:g.rate)||1),I={ETH:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",USDC:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",USDT:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png"},p=[{tokenKey:"USDC",token:"USDC",chain:m,amount:U,usd:U,icon:"$",chainTint:y,logo:I.USDC},...f?[{tokenKey:"USDT",token:"USDT",chain:m,amount:j,usd:j,icon:"$",chainTint:y,logo:I.USDT}]:[],{tokenKey:"ETH",token:"ETH",chain:m,amount:L,usd:Y,icon:"Ξ",chainTint:y,logo:I.ETH}];return h?C.jsxs(ve,{gap:14,style:{padding:"18px 20px 6px"},children:[C.jsxs(rn,{justify:"space-between",align:"center",children:[C.jsxs(ve,{gap:1,children:[C.jsx("div",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Connected wallet"}),C.jsx("div",{style:{fontSize:13,fontWeight:500,color:K.ink,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:w})]}),C.jsx(Fu,{tone:"accent",children:m})]}),C.jsxs("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:["Select a token to pay with. We'll bridge it to ",((S=r[n.currency])==null?void 0:S.name)??n.currency," automatically."]}),C.jsx(ve,{gap:6,children:p.map(R=>{const T=R.usd>=W;return C.jsxs("button",{onClick:()=>T&&e(R.tokenKey,R),disabled:!T,style:{...Du,opacity:T?1:.42,cursor:T?"pointer":"not-allowed"},children:[C.jsx("div",{style:{width:36,height:36,borderRadius:9,flexShrink:0,background:R.chainTint+"22",border:`1px solid ${R.chainTint}44`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:15,color:R.chainTint,overflow:"hidden"},children:R.logo?C.jsx("img",{src:R.logo,style:{width:"100%",height:"100%",objectFit:"cover"}}):R.icon}),C.jsxs(ve,{gap:2,style:{flex:1,textAlign:"left"},children:[C.jsxs("div",{style:{fontSize:14,fontWeight:500},children:[$u(R.amount,R.tokenKey==="ETH"?4:2)," ",R.tokenKey]}),C.jsxs("div",{style:{fontSize:11.5,color:K.mute},children:["≈ $",R.usd.toFixed(2)," on ",m]})]}),T?C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):C.jsx(Fu,{tone:"warn",children:"Insufficient"})]},R.tokenKey)})}),C.jsx("button",{onClick:t,style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:K.mute,textAlign:"center",padding:"2px 0"},children:"Pay from another wallet or exchange →"})]}):C.jsxs(ve,{gap:14,style:{padding:"22px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Switch Network"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"Your wallet is on an unsupported chain. Switch to one of these to continue."})]}),C.jsx(ve,{gap:6,children:[8453,10,42161,1,137].map(R=>C.jsxs("button",{onClick:()=>u({chainId:R}),disabled:l,style:{...Du,opacity:l?.6:1},children:[C.jsx("div",{style:{width:32,height:32,borderRadius:8,flexShrink:0,background:M5[R],color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:13},children:Eg[R][0]}),C.jsx("div",{style:{fontSize:13,fontWeight:500},children:Eg[R]}),C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{marginLeft:"auto"},children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},R))})]})}function JL({onRetry:e}){return C.jsxs(ve,{gap:20,style:{padding:"40px 20px 20px",minHeight:280,alignItems:"center",justifyContent:"center"},children:[C.jsx(gf,{}),C.jsxs(ve,{gap:6,style:{alignItems:"center"},children:[C.jsx("div",{style:{fontSize:17,fontWeight:600,letterSpacing:-.3},children:"Confirm in your wallet"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,textAlign:"center",maxWidth:260,lineHeight:1.6},children:"Check your wallet extension or app and approve the transaction to send funds."}),C.jsx("button",{onClick:e,style:{...kg,marginTop:12,fontSize:13,padding:"8px 16px"},children:"Not seeing the pop-up? Try again"})]})]})}const ZL={name:"Afriloom Textiles",amount:700,currency:"NGN"},Ig={Base:"BASE",Optimism:"OPTIMISM",Ethereum:"ETHEREUM",Arbitrum:"ARBITRUM",Polygon:"POLYGON"},YL=new j7;function QL({merchant:e=ZL,apiKey:t,sessionId:n,userAddress:r,customer:i,theme:s="organic",borderRadius:o=16,accentColor:a,onSuccess:c,onError:u,onClose:l,apiBase:d,disabledMethods:f}){d&&typeof window<"u"&&(window.__WEAVE_API_BASE__=d);const h=t??(typeof window<"u"?window.__WEAVE_API_KEY__:void 0)??"pk_live_72a9e3afde82acf51db54bbcaa65832f4b549c56294fe88f"??"pk_test_demo",m=r??"0x2B4fB6F7255DeF56d985fb01134ab1431Efbd3be"??"0x0000000000000000000000000000000000000000",{address:y,chainId:w,isConnected:b}=Zm(),{disconnect:E}=hN(),v=()=>{E(),localStorage.clear()},{writeContractAsync:A}=gN(),{sendTransactionAsync:P}=pN(),[M,L]=ce.useState("connect"),[U,j]=ce.useState("offramp"),[Z,Y]=ce.useState(0),[W,I]=ce.useState(null),[p,g]=ce.useState(!1),[S,R]=ce.useState({institution:"",accountIdentifier:"",accountName:""}),[T,B]=ce.useState(null),[$,O]=ce.useState(null),[_,D]=ce.useState(null),[ue,ne]=ce.useState(null),[G,J]=ce.useState(null),[te,le]=ce.useState(null),[ge,z]=ce.useState(null),[F,oe]=ce.useState(null),[de,Ee]=ce.useState(!1),[Se,xe]=ce.useState(null),[ze,Pt]=ce.useState(null),[Ze,Ye]=ce.useState(!1),[wt,We]=ce.useState(!1),[nt,vt]=ce.useState(null),[Fe,N]=ce.useState({fiat:L0,crypto:mw}),x=ce.useRef(0),k=ce.useRef(0),H=ce.useRef(null),[Q,X]=ce.useState(()=>typeof navigator<"u"?navigator.onLine:!0);ce.useEffect(()=>{const re=()=>X(!0),se=()=>X(!1);return window.addEventListener("online",re),window.addEventListener("offline",se),()=>{window.removeEventListener("online",re),window.removeEventListener("offline",se)}},[]);const[ie,Me]=ce.useState("USDC"),[Te,Re]=ce.useState(null),[ot,Ce]=ce.useState(3400),[ht,_n]=ce.useState(!0);ce.useEffect(()=>{const re=localStorage.getItem(`weave-order-${h}`);if(re)try{const{orderId:se,screen:fe,createdAt:we}=JSON.parse(re);Date.now()-we<1*60*60*1e3&&ju(h,se).then(me=>{var Ge;const he=me,Ae=CI(he.sourceAssetKey,he.destAssetKey);if(j(Ae==="onramp"?"onramp":"offramp"),["awaiting_deposit","processing"].includes(he.status)){B(he.id);const Oe=he.steps.find(Le=>Le.status!=="done")||he.steps[0];if(Ae==="onramp")(Oe==null?void 0:Oe.provider)==="paycrest"&&(Oe.depositAddress||Oe.amountOut)?(((Ge=he.sourceInstrument)==null?void 0:Ge.kind)==="bank_account"&&O({accountName:he.sourceInstrument.bankAccountName||"",accountIdentifier:he.sourceInstrument.bankAccountIdentifier||"",institution:he.sourceInstrument.bankInstitution||"",currency:he.destAssetKey.split(":").pop()||"NGN",amountToTransfer:he.sourceAmount.toString()}),L("vaccount")):L("processing");else if((Oe==null?void 0:Oe.provider)==="nearintents"&&he.status==="awaiting_deposit"){ne(Oe.depositAddress),J(Oe.depositMemo),le(Number(Oe.amountIn));const Le=Oe.fromAsset.split(":");z(Le[2]||Le[1]),oe(Le[1]),L("deposit")}else L("processing")}else he.status==="completed"?(B(he.id),L("success")):localStorage.removeItem(`weave-order-${h}`)}).catch(()=>{localStorage.removeItem(`weave-order-${h}`)})}catch{localStorage.removeItem(`weave-order-${h}`)}if(EL(h).then(se=>{se&&N(se)}).catch(()=>{}),e.sourceAssetKey&&e.amountIn==="source"){const se=Fe.crypto.findIndex(fe=>{var we;return`${fe.id}:${fe.token}`===((we=e.sourceAssetKey)==null?void 0:we.split("crypto:")[1])});se!==-1&&(I(se),j("offramp"),L("deposit"))}},[h]),ce.useEffect(()=>{h&&(_n(!0),Lu(h,{from:"crypto:ETHEREUM:ETH",to:co(e.currency),amount:1,amountIn:"source"}).then(re=>{const se=Fe.fiat.find(me=>me.key===co(e.currency)),fe=(se==null?void 0:se.rate)||1515,we=re.estimatedDest/fe;!isNaN(we)&&we>0&&Ce(we),_n(!1)}).catch(re=>{console.warn("[WeaveCheckoutInner] Live ETH price fetch failed:",re),_n(!1)}))},[h,e.currency,Fe.fiat]),ce.useEffect(()=>{T&&!["success","error"].includes(M)?localStorage.setItem(`weave-order-${h}`,JSON.stringify({orderId:T,screen:M,createdAt:Date.now()})):M==="success"&&localStorage.removeItem(`weave-order-${h}`)},[T,M,h]);const De=Fe.fiat.reduce((re,se)=>{const fe=se.key.split(":").pop();return re[fe]={name:se.name,symbol:se.symbol,flag:se.flag,rate:se.rate,min:se.min,country:se.country,psp:"GTBank",bank:"GTBank ••7890",method:"Bank transfer"},re},{}),ut=Fe.crypto,an=(re,se,fe)=>{const we=De[se]||Ti[se];if(!we)return`${se} ${re}`;const he=!!we?0:4,Ae=fe??(Number.isInteger(re)?0:he),Ge=Math.pow(10,Ae),Oe=Ae>0?Math.ceil(re*Ge)/Ge:Math.ceil(re),Le=new Intl.NumberFormat("en-US",{minimumFractionDigits:Ae,maximumFractionDigits:Ae}).format(Oe);return`${we.symbol}${Le}`},_t=re=>{vt(null),B(null),ne(null),J(null),xe(null),O(null),Pt(null),Re(null),re==="fiat"?(j("onramp"),e.currency==="NGN"&&e.destAssetKey==="fiat:NGN"?zr():L("refundAccount")):re==="crypto"?(j("offramp"),L("wallet")):re==="deposit"?(j("offramp"),L(b?"walletAsset":"walletConnect")):re==="externalDeposit"&&(j("offramp"),L("deposit"))},pt=async(re,se,fe)=>{const we=++x.current;Ee(!0),xe(null),ne(null),J(null),le(null),z(null),oe(null);try{const me=hf(re,se),he=e.destAssetKey||co(e.currency),Ae=e.amountIn??"dest";let Ge=e.amount;he.startsWith("crypto:")&&e.currency==="NGN"&&(Ge=(await Lu(h,{from:co(e.currency),to:he,amount:e.amount,amountIn:"source"})).estimatedDest);const Oe=await Lu(h,{from:me,to:he,amount:Ge,amountIn:Ae}),Le={inline:{kind:"crypto_wallet",assetKey:me,walletAddress:""}};H.current??(H.current="weave_"+Math.random().toString(36).slice(2)+Date.now().toString(36));const gt=await xg(h,{source:Le,amount:Ge,amountIn:Ae,refundAddress:fe,reference:H.current,sessionId:n,customer:i??void 0,dest:e.destInstrument?{inline:{...e.destInstrument,assetKey:he}}:void 0});if(x.current!==we)return;H.current=null,B(gt.order.id),ne(gt.nextAction.depositAddress??null),J(gt.nextAction.depositMemo??null),O(gt.nextAction.bankDetails??null),le(typeof gt.nextAction.amount=="number"?gt.nextAction.amount:null),z(gt.nextAction.token??se),oe(gt.nextAction.chain??re)}catch(me){if(x.current!==we)return;xe(me.message??"Could not generate a deposit address"),u==null||u(me)}finally{x.current===we&&Ee(!1)}},fi=async()=>{L("quote");const re=mf[Z??0],se=++k.current;Ye(!0),Pt(null);try{const fe=await Lu(h,{from:hf(Ig[re.chain]??re.chain,re.token),to:co(e.currency),amount:e.amount,amountIn:"dest"});if(k.current!==se)return;Pt({estimatedFiat:fe.estimatedDest,netUsdc:fe.breakdown.netUsd,fiatCurrency:e.currency,breakdown:{inputAmount:fe.breakdown.usdEquivalent,inputToken:re.token,fastPath:fe.route.steps.length===1,bridgeFeeUsd:fe.breakdown.bridgeFeeUsd,senderFeeUsd:fe.breakdown.senderFeeUsd,appFeeUsd:fe.breakdown.appFeeUsd,sellRate:fe.breakdown.sellRate??0}})}catch{}finally{k.current===se&&Ye(!1)}},mt=async(re,se)=>{if(Re(re),Me(se),L("quote"),!w)return;const fe=O5[w];if(!fe)return;const we=++k.current;Ye(!0),Pt(null);try{const me=await Lu(h,{from:hf(fe,se),to:co(e.currency),amount:e.amount,amountIn:"dest"});if(k.current!==we)return;Pt({estimatedFiat:me.estimatedDest,netUsdc:me.breakdown.netUsd,fiatCurrency:e.currency,breakdown:{inputAmount:me.breakdown.usdEquivalent,inputToken:se,fastPath:me.route.steps.length===1,bridgeFeeUsd:me.breakdown.bridgeFeeUsd,senderFeeUsd:me.breakdown.senderFeeUsd,appFeeUsd:me.breakdown.appFeeUsd,sellRate:me.breakdown.sellRate??0}})}catch{}finally{k.current===we&&Ye(!1)}},tt=re=>{re==="success"&&c&&T&&c({orderId:T,status:"completed"}),L(re)},zr=async re=>{var se;We(!0),vt(null);try{const fe={inline:{kind:"bank_account",assetKey:co(e.currency),bankInstitution:S.institution,bankAccountIdentifier:S.accountIdentifier,bankAccountName:S.accountName}};H.current??(H.current="weave_"+Math.random().toString(36).slice(2)+Date.now().toString(36));const we=await xg(h,{source:fe,amount:e.amount,reference:H.current,sessionId:n,customer:i??void 0,dest:e.destInstrument?{inline:{...e.destInstrument,assetKey:e.destAssetKey||e.destInstrument.assetKey}}:void 0,amountIn:(se=e.destAssetKey)!=null&&se.startsWith("fiat:")?"dest":void 0});H.current=null,B(we.order.id),O(we.nextAction.bankDetails??null),D(we.nextAction.paystackPopupDetails??null);const me=we.nextAction.screen==="paystack_popup"?"paystack_popup":"vaccount";L(me)}catch(fe){vt(fe.message??"Failed to create order"),u==null||u(fe)}finally{We(!1)}},Et=()=>zr(),lt=async()=>{if(wt)return;const re=Te??mf[Z??0],se=b&&y&&w&&Te;We(!0),vt(null);try{let fe=T,we=ue,me=te;if(!fe||!we){const he=se?O5[w]??Ig[re.chain]??re.chain:Ig[re.chain]??re.chain,Ae=se?ie:re.token,Oe={inline:{kind:"crypto_wallet",assetKey:hf(he,Ae),walletAddress:se?y:m}};H.current??(H.current="weave_"+Math.random().toString(36).slice(2)+Date.now().toString(36));const Le=await xg(h,{source:Oe,amount:e.amount,amountIn:"dest",flow:se?"self":void 0,reference:H.current,sessionId:n,customer:i??void 0,dest:e.destInstrument?{inline:{...e.destInstrument,assetKey:e.destAssetKey||e.destInstrument.assetKey}}:void 0});H.current=null,fe=Le.order.id,we=Le.nextAction.depositAddress??null,me=Le.order.sourceAmount,B(fe),ne(we),le(me),z(Le.nextAction.token??Ae),oe(Le.nextAction.chain??he)}if(se&&we){L("walletSign");const he=ie,Ae=me;let Ge;if(he==="ETH")Ge=await P({to:we,value:v9(Ae.toString()),chainId:w});else{const Oe=he==="USDC"?B5[w]:N5[w];if(!Oe)throw new Error(`${he} is not available on this chain`);Ge=await A({address:Oe,abi:xL,functionName:"transfer",args:[we,Q_(Ae.toString(),6)],chainId:w})}try{await TB(T5,{hash:Ge,timeout:6e4})}catch(Oe){console.warn("[widget] transaction wait timed out or failed:",Oe.message)}}else ne(we);L("processing")}catch(fe){const we=fe.message??"",me=we.toLowerCase().includes("reject")||we.toLowerCase().includes("denied")||we.toLowerCase().includes("cancelled");vt(me?"Transaction was rejected. Please try again.":we||"Failed to complete payment"),M==="walletSign"&&L("quote"),u==null||u(fe)}finally{We(!1)}};if(p)return C.jsxs("div",{style:{position:"absolute",bottom:24,right:24,zIndex:10,background:K.ink,color:"#fff",padding:"10px 16px",borderRadius:999,fontSize:13,display:"flex",alignItems:"center",gap:8,cursor:"pointer",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",minWidth:"185px"},onClick:()=>g(!1),children:[C.jsx(Sg,{size:16}),"Pay with Weave"]});const ur=mf[Z??0],dt=U==="onramp",at=re=>{H.current=null,B(null),vt(null),O(null),D(null),ne(null),J(null),xe(null),Pt(null),Re(null),L(re)},hi=(()=>{if(M==="connect")return C.jsx(ML,{onPick:_t,merchant:e,currencies:De,fmtCur:an,submitting:wt,disabledMethods:f});if(dt){if(M==="refundAccount")return C.jsx(WL,{merchant:e,value:S,onChange:R,onSubmit:Et,submitting:wt,error:nt});if(M==="vaccount")return C.jsx(qL,{onNext:tt,merchant:e,bankDetails:$,apiKey:h,orderId:T,currencies:De,fmtCur:an});if(M==="paystack_popup")return C.jsx(LL,{onNext:tt,details:_});if(M==="processing")return C.jsx(j5,{onNext:tt,merchant:e,mode:"fiat",apiKey:h,orderId:T,bankDetails:$,currencies:De,fmtCur:an});if(M==="success")return C.jsx($5,{onNext:tt,balance:ur,merchant:e,direction:U,apiKey:h,orderId:T,accentColor:a,currencies:De,fmtCur:an});if(M==="error")return C.jsx(F5,{onNext:()=>at("connect"),onBack:()=>at("refundAccount")})}else{if(M==="walletConnect")return C.jsx(VL,{onConnected:()=>L("walletAsset"),onExternalFlow:()=>{j("offramp"),L("deposit")}});if(M==="walletAsset")return C.jsx(KL,{onSelectToken:(re,se)=>mt(se,re),onExternalFlow:()=>L("deposit"),merchant:e,currencies:De,fmtCur:an,ethUsdPrice:ot,loadingEthPrice:ht});if(M==="walletSign")return C.jsx(JL,{onRetry:lt});if(M==="deposit")return C.jsx(zL,{onNext:tt,merchant:e,depositAddress:ue,depositMemo:G,amountToSend:te,sourceToken:ge,sourceChain:F,loading:de,error:Se,onChainChange:pt,ready:!!T&&!!ue&&!de,apiKey:h,orderId:T,preSelectedChainIdx:W,depositChains:ut,currencies:De,fmtCur:an});if(M==="wallet")return C.jsx(BL,{onNext:()=>fi(),merchant:e,balances:mf,selected:Z,setSelected:Y,currencies:De});if(M==="quote")return C.jsx(NL,{merchant:e,balance:Te??ur,onConfirm:lt,submitting:wt,error:nt,quote:ze,quoteLoading:Ze,currencies:De,fmtCur:an});if(M==="processing")return C.jsx(j5,{onNext:tt,merchant:e,mode:"crypto",apiKey:h,orderId:T,currencies:De,fmtCur:an});if(M==="success")return C.jsx($5,{onNext:tt,balance:ur,merchant:e,direction:U,apiKey:h,orderId:T,accentColor:a,currencies:De,fmtCur:an});if(M==="error")return C.jsx(F5,{onNext:()=>at("connect"),onBack:()=>at("quote")})}return null})(),xt=["wallet","quote","deposit","walletConnect","walletAsset","walletSign"].includes(M)&&!dt||["refundAccount","vaccount"].includes(M)&&dt,q=M==="quote"?Te?"walletAsset":"wallet":M==="vaccount"?"refundAccount":M==="walletAsset"?"connect":M==="walletSign"?"quote":"connect";return C.jsxs("div",{className:`weave-checkout weave-theme-${s}`,style:{"--weave-accent":pf[a]||a||"#0F5D4C","--weave-accent-soft":(pf[a]||a||"#0F5D4C")+"15",width:400,background:K.surface,borderRadius:o,boxShadow:"0 30px 80px rgba(11, 15, 14, 0.22), 0 0 0 1px rgba(0,0,0,0.04)",overflow:"hidden",fontFamily:"Inter, -apple-system, BlinkMacSystemFont, sans-serif",color:K.ink,animation:"wslide 0.35s cubic-bezier(0.2, 1, 0.3, 1)"},children:[C.jsx(RL,{merchantName:e.name,onClose:()=>{g(!0),l==null||l()},showBack:xt,onBack:()=>{M==="walletAsset"&&v(),L(q)}}),!Q&&C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",background:K.warnSoft,color:K.warn,fontSize:12,fontWeight:500},children:[C.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M1 6l5.5 5.5M17 6l-5.5 5.5M12 20v.01"}),C.jsx("path",{d:"M5 10l-4-4M23 2L1 22"})]}),"No connection — your payment is safe, reconnecting…"]}),C.jsx("div",{style:{animation:"wfade 0.25s ease"},children:hi},M),C.jsx(TL,{})]})}function XL(e){return C.jsx(kL,{config:T5,children:C.jsx(AL,{client:YL,children:C.jsx(QL,{...e})})})}const un={ink:"#0B0F0E",ink2:"#3A4240",mute:"#6B7572",hair:"#E8EAE6",page:"#F5F4EF"},ej={NGN:"₦"},yf=(e,t)=>`${ej[t]??""}${new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(e)}`;function tj({currency:e="NGN",amount:t=15e4}){const n=[{name:"Ẹ̀wà Handwoven Throw",sub:"Indigo / 150 × 200cm",price:12e4},{name:"Aso-Oke Runner",sub:"Earth / 35 × 180cm",price:25e3}];return C.jsxs("div",{style:{position:"absolute",inset:0,background:un.page,fontFamily:"Inter, -apple-system, sans-serif",color:un.ink,overflow:"hidden"},children:[C.jsxs("div",{style:{height:56,padding:"0 32px",borderBottom:`1px solid ${un.hair}`,display:"flex",alignItems:"center",background:"#fff"},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[C.jsx("div",{style:{width:26,height:26,borderRadius:6,background:"#2B1810",color:"#F5DEB3",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:13,fontFamily:"Georgia, serif"},children:"A"}),C.jsx("span",{style:{fontWeight:600,fontSize:14,letterSpacing:-.1},children:"Afriloom"}),C.jsx("span",{style:{color:un.mute,fontSize:13,marginLeft:16},children:"Shop · Journal · About"})]}),C.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:14,fontSize:13,color:un.ink2},children:[C.jsx("span",{children:"Search"}),C.jsx("span",{children:"Account"}),C.jsx("span",{children:"Cart (2)"})]})]}),C.jsxs("div",{style:{display:"flex",padding:"32px 32px",gap:40,height:"calc(100% - 56px)"},children:[C.jsxs("div",{style:{flex:"0 0 340px"},children:[C.jsx("div",{style:{fontSize:11,color:un.mute,textTransform:"uppercase",letterSpacing:.8,marginBottom:14},children:"Order summary"}),n.map((r,i)=>C.jsxs("div",{style:{display:"flex",gap:14,padding:"12px 0",borderBottom:`1px solid ${un.hair}`},children:[C.jsx("div",{style:{width:60,height:72,borderRadius:6,flexShrink:0,background:i===0?"repeating-linear-gradient(90deg, #2D3E60 0 6px, #1F2D45 6px 12px, #3A4F75 12px 16px)":"repeating-linear-gradient(0deg, #8B6D47 0 4px, #6B5236 4px 8px, #A8855D 8px 14px)"}}),C.jsxs("div",{style:{flex:1,fontSize:12.5},children:[C.jsx("div",{style:{fontWeight:500},children:r.name}),C.jsx("div",{style:{color:un.mute,fontSize:11.5,marginTop:2},children:r.sub}),C.jsx("div",{style:{marginTop:4},children:yf(r.price,e)})]})]},i)),C.jsxs("div",{style:{padding:"12px 0",fontSize:12.5,display:"flex",flexDirection:"column",gap:6},children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:un.mute},children:[C.jsx("span",{children:"Subtotal"}),C.jsx("span",{children:yf(145e3,e)})]}),C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:un.mute},children:[C.jsx("span",{children:"Shipping"}),C.jsx("span",{children:yf(5e3,e)})]}),C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:600,fontSize:14,marginTop:6,color:un.ink},children:[C.jsx("span",{children:"Total"}),C.jsx("span",{children:yf(t,e)})]})]})]}),C.jsxs("div",{style:{flex:1,maxWidth:440},children:[C.jsx("div",{style:{fontSize:11,color:un.mute,textTransform:"uppercase",letterSpacing:.8,marginBottom:14},children:"Payment"}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,opacity:.4},children:[C.jsx("div",{style:{height:42,border:`1px solid ${un.hair}`,borderRadius:8,background:"#fff",display:"flex",alignItems:"center",padding:"0 14px",fontSize:13,color:un.mute},children:"Email"}),C.jsx("div",{style:{height:42,border:`1px solid ${un.hair}`,borderRadius:8,background:"#fff",display:"flex",alignItems:"center",padding:"0 14px",fontSize:13,color:un.mute},children:"Card number"}),C.jsxs("div",{style:{display:"flex",gap:10},children:[C.jsx("div",{style:{flex:1,height:42,border:`1px solid ${un.hair}`,borderRadius:8,background:"#fff"}}),C.jsx("div",{style:{flex:1,height:42,border:`1px solid ${un.hair}`,borderRadius:8,background:"#fff"}})]})]})]})]}),C.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(11, 15, 14, 0.35)",backdropFilter:"blur(1px)"}})]})}function D5(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var s;const o=c=>c===null?null:JSON.parse(c,void 0),a=(s=n.getItem(i))!=null?s:null;return a instanceof Promise?a.then(o):o(a)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const Cg=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return Cg(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Cg(r)(n)}}}},nj=(e,t)=>(n,r,i)=>{let s={storage:D5(()=>localStorage),partialize:y=>y,version:0,merge:(y,w)=>({...w,...y}),...t},o=!1;const a=new Set,c=new Set;let u=s.storage;if(!u)return e((...y)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...y)},r,i);const l=()=>{const y=s.partialize({...r()});return u.setItem(s.name,{state:y,version:s.version})},d=i.setState;i.setState=(y,w)=>{d(y,w),l()};const f=e((...y)=>{n(...y),l()},r,i);i.getInitialState=()=>f;let h;const m=()=>{var y,w;if(!u)return;o=!1,a.forEach(E=>{var v;return E((v=r())!=null?v:f)});const b=((w=s.onRehydrateStorage)==null?void 0:w.call(s,(y=r())!=null?y:f))||void 0;return Cg(u.getItem.bind(u))(s.name).then(E=>{if(E)if(typeof E.version=="number"&&E.version!==s.version){if(s.migrate){const v=s.migrate(E.state,E.version);return v instanceof Promise?v.then(A=>[!0,A]):[!0,v]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,E.state];return[!1,void 0]}).then(E=>{var v;const[A,P]=E;if(h=s.merge(P,(v=r())!=null?v:f),n(h,!0),A)return l()}).then(()=>{b==null||b(h,void 0),h=r(),o=!0,c.forEach(E=>E(h))}).catch(E=>{b==null||b(void 0,E)})};return i.persist={setOptions:y=>{s={...s,...y},y.storage&&(u=y.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>m(),hasHydrated:()=>o,onHydrate:y=>(a.add(y),()=>{a.delete(y)}),onFinishHydration:y=>(c.add(y),()=>{c.delete(y)})},s.skipHydration||m(),h||f},U5=e=>{let t;const n=new Set,r=(u,l)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const f=t;t=l??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(h=>h(t,f))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(r,i,a);return a},Pg=e=>e?U5(e):U5;var bf,Tt,H5,uo,z5,W5,Rg,Tg,Og,Mg,Uu={},G5=[],rj=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Bg=Array.isArray;function ms(e,t){for(var n in t)e[n]=t[n];return e}function q5(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function yt(e,t,n){var r,i,s,o={};for(s in t)s=="key"?r=t[s]:s=="ref"?i=t[s]:o[s]=t[s];if(arguments.length>2&&(o.children=arguments.length>3?bf.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)o[s]===void 0&&(o[s]=e.defaultProps[s]);return wf(e,o,r,i,null)}function wf(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:i??++H5,__i:-1,__u:0};return i==null&&Tt.vnode!=null&&Tt.vnode(s),s}function vf(e){return e.children}function _f(e,t){this.props=e,this.context=t}function Ta(e,t){if(t==null)return e.__?Ta(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Ta(e):null}function V5(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return V5(e)}}function K5(e){(!e.__d&&(e.__d=!0)&&uo.push(e)&&!Ef.__r++||z5!==Tt.debounceRendering)&&((z5=Tt.debounceRendering)||W5)(Ef)}function Ef(){var e,t,n,r,i,s,o,a;for(uo.sort(Rg);e=uo.shift();)e.__d&&(t=uo.length,r=void 0,s=(i=(n=e).__v).__e,o=[],a=[],n.__P&&((r=ms({},i)).__v=i.__v+1,Tt.vnode&&Tt.vnode(r),Ng(n.__P,r,i,n.__n,n.__P.namespaceURI,32&i.__u?[s]:null,o,s??Ta(i),!!(32&i.__u),a),r.__v=i.__v,r.__.__k[r.__i]=r,X5(o,r,a),r.__e!=s&&V5(r)),uo.length>t&&uo.sort(Rg));Ef.__r=0}function J5(e,t,n,r,i,s,o,a,c,u,l){var d,f,h,m,y,w=r&&r.__k||G5,b=t.length;for(n.__d=c,ij(n,t,w),c=n.__d,d=0;d<b;d++)(h=n.__k[d])!=null&&(f=h.__i===-1?Uu:w[h.__i]||Uu,h.__i=d,Ng(e,h,f,i,s,o,a,c,u,l),m=h.__e,h.ref&&f.ref!=h.ref&&(f.ref&&Lg(f.ref,null,h),l.push(h.ref,h.__c||m,h)),y==null&&m!=null&&(y=m),65536&h.__u||f.__k===h.__k?c=Z5(h,c,e):typeof h.type=="function"&&h.__d!==void 0?c=h.__d:m&&(c=m.nextSibling),h.__d=void 0,h.__u&=-196609);n.__d=c,n.__e=y}function ij(e,t,n){var r,i,s,o,a,c=t.length,u=n.length,l=u,d=0;for(e.__k=[],r=0;r<c;r++)(i=t[r])!=null&&typeof i!="boolean"&&typeof i!="function"?(o=r+d,(i=e.__k[r]=typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?wf(null,i,null,null,null):Bg(i)?wf(vf,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?wf(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=e,i.__b=e.__b+1,s=null,(a=i.__i=sj(i,n,o,l))!==-1&&(l--,(s=n[a])&&(s.__u|=131072)),s==null||s.__v===null?(a==-1&&d--,typeof i.type!="function"&&(i.__u|=65536)):a!==o&&(a==o-1?d--:a==o+1?d++:(a>o?d--:d++,i.__u|=65536))):i=e.__k[r]=null;if(l)for(r=0;r<u;r++)(s=n[r])!=null&&!(131072&s.__u)&&(s.__e==e.__d&&(e.__d=Ta(s)),eE(s,s))}function Z5(e,t,n){var r,i;if(typeof e.type=="function"){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=Z5(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!n.contains(t)&&(t=Ta(e)),n.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType===8);return t}function sj(e,t,n,r){var i=e.key,s=e.type,o=n-1,a=n+1,c=t[n];if(c===null||c&&i==c.key&&s===c.type&&!(131072&c.__u))return n;if(r>(c!=null&&!(131072&c.__u)?1:0))for(;o>=0||a<t.length;){if(o>=0){if((c=t[o])&&!(131072&c.__u)&&i==c.key&&s===c.type)return o;o--}if(a<t.length){if((c=t[a])&&!(131072&c.__u)&&i==c.key&&s===c.type)return a;a++}}return-1}function Y5(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||rj.test(t)?n:n+"px"}function xf(e,t,n,r,i){var s;e:if(t==="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Y5(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||Y5(e.style,t,n[t])}else if(t[0]==="o"&&t[1]==="n")s=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e||t==="onFocusOut"||t==="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?r?n.u=r.u:(n.u=Tg,e.addEventListener(t,s?Mg:Og,s)):e.removeEventListener(t,s?Mg:Og,s);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function Q5(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Tg++;else if(t.t<n.u)return;return n(Tt.event?Tt.event(t):t)}}}function Ng(e,t,n,r,i,s,o,a,c,u){var l,d,f,h,m,y,w,b,E,v,A,P,M,L,U,j,Z=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),s=[a=t.__e=n.__e]),(l=Tt.__b)&&l(t);e:if(typeof Z=="function")try{if(b=t.props,E="prototype"in Z&&Z.prototype.render,v=(l=Z.contextType)&&r[l.__c],A=l?v?v.props.value:l.__:r,n.__c?w=(d=t.__c=n.__c).__=d.__E:(E?t.__c=d=new Z(b,A):(t.__c=d=new _f(b,A),d.constructor=Z,d.render=aj),v&&v.sub(d),d.props=b,d.state||(d.state={}),d.context=A,d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),E&&d.__s==null&&(d.__s=d.state),E&&Z.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=ms({},d.__s)),ms(d.__s,Z.getDerivedStateFromProps(b,d.__s))),h=d.props,m=d.state,d.__v=t,f)E&&Z.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),E&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(E&&Z.getDerivedStateFromProps==null&&b!==h&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(b,A),!d.__e&&(d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(b,d.__s,A)===!1||t.__v===n.__v)){for(t.__v!==n.__v&&(d.props=b,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(Y){Y&&(Y.__=t)}),P=0;P<d._sb.length;P++)d.__h.push(d._sb[P]);d._sb=[],d.__h.length&&o.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(b,d.__s,A),E&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(h,m,y)})}if(d.context=A,d.props=b,d.__P=e,d.__e=!1,M=Tt.__r,L=0,E){for(d.state=d.__s,d.__d=!1,M&&M(t),l=d.render(d.props,d.state,d.context),U=0;U<d._sb.length;U++)d.__h.push(d._sb[U]);d._sb=[]}else do d.__d=!1,M&&M(t),l=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++L<25);d.state=d.__s,d.getChildContext!=null&&(r=ms(ms({},r),d.getChildContext())),E&&!f&&d.getSnapshotBeforeUpdate!=null&&(y=d.getSnapshotBeforeUpdate(h,m)),J5(e,Bg(j=l!=null&&l.type===vf&&l.key==null?l.props.children:l)?j:[j],t,n,r,i,s,o,a,c,u),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),w&&(d.__E=d.__=null)}catch(Y){if(t.__v=null,c||s!=null){for(t.__u|=c?160:32;a&&a.nodeType===8&&a.nextSibling;)a=a.nextSibling;s[s.indexOf(a)]=null,t.__e=a}else t.__e=n.__e,t.__k=n.__k;Tt.__e(Y,t,n)}else s==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=oj(n.__e,t,n,r,i,s,o,c,u);(l=Tt.diffed)&&l(t)}function X5(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)Lg(n[r],n[++r],n[++r]);Tt.__c&&Tt.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(s){s.call(i)})}catch(s){Tt.__e(s,i.__v)}})}function oj(e,t,n,r,i,s,o,a,c){var u,l,d,f,h,m,y,w=n.props,b=t.props,E=t.type;if(E==="svg"?i="http://www.w3.org/2000/svg":E==="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(u=0;u<s.length;u++)if((h=s[u])&&"setAttribute"in h==!!E&&(E?h.localName===E:h.nodeType===3)){e=h,s[u]=null;break}}if(e==null){if(E===null)return document.createTextNode(b);e=document.createElementNS(i,E,b.is&&b),a&&(Tt.__m&&Tt.__m(t,s),a=!1),s=null}if(E===null)w===b||a&&e.data===b||(e.data=b);else{if(s=s&&bf.call(e.childNodes),w=n.props||Uu,!a&&s!=null)for(w={},u=0;u<e.attributes.length;u++)w[(h=e.attributes[u]).name]=h.value;for(u in w)if(h=w[u],u!="children"){if(u=="dangerouslySetInnerHTML")d=h;else if(!(u in b)){if(u=="value"&&"defaultValue"in b||u=="checked"&&"defaultChecked"in b)continue;xf(e,u,null,h,i)}}for(u in b)h=b[u],u=="children"?f=h:u=="dangerouslySetInnerHTML"?l=h:u=="value"?m=h:u=="checked"?y=h:a&&typeof h!="function"||w[u]===h||xf(e,u,h,w[u],i);if(l)a||d&&(l.__html===d.__html||l.__html===e.innerHTML)||(e.innerHTML=l.__html),t.__k=[];else if(d&&(e.innerHTML=""),J5(e,Bg(f)?f:[f],t,n,r,E==="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,o,s?s[0]:n.__k&&Ta(n,0),a,c),s!=null)for(u=s.length;u--;)q5(s[u]);a||(u="value",E==="progress"&&m==null?e.removeAttribute("value"):m!==void 0&&(m!==e[u]||E==="progress"&&!m||E==="option"&&m!==w[u])&&xf(e,u,m,w[u],i),u="checked",y!==void 0&&y!==e[u]&&xf(e,u,y,w[u],i))}return e}function Lg(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){Tt.__e(i,n)}}function eE(e,t,n){var r,i;if(Tt.unmount&&Tt.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||Lg(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){Tt.__e(s,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&eE(r[i],t,n||typeof e.type!="function");n||q5(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function aj(e,t,n){return this.constructor(e,n)}function jg(e,t,n){var r,i,s,o;Tt.__&&Tt.__(e,t),i=(r=!1)?null:t.__k,s=[],o=[],Ng(t,e=t.__k=yt(vf,null,[e]),i||Uu,Uu,t.namespaceURI,i?null:t.firstChild?bf.call(t.childNodes):null,s,i?i.__e:t.firstChild,r,o),X5(s,e,o)}bf=G5.slice,Tt={__e:function(e,t,n,r){for(var i,s,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(a){e=a}throw e}},H5=0,_f.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=ms({},this.state),typeof e=="function"&&(e=e(ms({},n),this.props)),e&&ms(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),K5(this))},_f.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),K5(this))},_f.prototype.render=vf,uo=[],W5=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Rg=function(e,t){return e.__v.__b-t.__v.__b},Ef.__r=0,Tg=0,Og=Q5(!1),Mg=Q5(!0);function tE(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=tE(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function lo(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=tE(e))&&(r&&(r+=" "),r+=t);return r}const cj=Object.freeze(Object.defineProperty({__proto__:null,clsx:lo,default:lo},Symbol.toStringTag,{value:"Module"}));var Sf,Gt,$g,nE,Fg=0,rE=[],Qt=Tt,iE=Qt.__b,sE=Qt.__r,oE=Qt.diffed,aE=Qt.__c,cE=Qt.unmount,uE=Qt.__;function lE(e,t){Qt.__h&&Qt.__h(Gt,e,Fg||t),Fg=0;var n=Gt.__H||(Gt.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function dE(e){return Fg=1,uj(hE,e)}function uj(e,t,n){var r=lE(Sf++,2);if(r.t=e,!r.__c&&(r.__=[hE(void 0,t),function(a){var c=r.__N?r.__N[0]:r.__[0],u=r.t(c,a);c!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=Gt,!Gt.u)){var i=function(a,c,u){if(!r.__c.__H)return!0;var l=r.__c.__H.__.filter(function(f){return!!f.__c});if(l.every(function(f){return!f.__N}))return!s||s.call(this,a,c,u);var d=!1;return l.forEach(function(f){if(f.__N){var h=f.__[0];f.__=f.__N,f.__N=void 0,h!==f.__[0]&&(d=!0)}}),!(!d&&r.__c.props===a)&&(!s||s.call(this,a,c,u))};Gt.u=!0;var s=Gt.shouldComponentUpdate,o=Gt.componentWillUpdate;Gt.componentWillUpdate=function(a,c,u){if(this.__e){var l=s;s=void 0,i(a,c,u),s=l}o&&o.call(this,a,c,u)},Gt.shouldComponentUpdate=i}return r.__N||r.__}function lj(e,t){var n=lE(Sf++,3);!Qt.__s&&hj(n.__H,t)&&(n.__=e,n.i=t,Gt.__H.__h.push(n))}function dj(){for(var e;e=rE.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(kf),e.__H.__h.forEach(Dg),e.__H.__h=[]}catch(t){e.__H.__h=[],Qt.__e(t,e.__v)}}Qt.__b=function(e){Gt=null,iE&&iE(e)},Qt.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),uE&&uE(e,t)},Qt.__r=function(e){sE&&sE(e),Sf=0;var t=(Gt=e.__c).__H;t&&($g===Gt?(t.__h=[],Gt.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.i=n.__N=void 0})):(t.__h.forEach(kf),t.__h.forEach(Dg),t.__h=[],Sf=0)),$g=Gt},Qt.diffed=function(e){oE&&oE(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(rE.push(t)!==1&&nE===Qt.requestAnimationFrame||((nE=Qt.requestAnimationFrame)||fj)(dj)),t.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.i=void 0})),$g=Gt=null},Qt.__c=function(e,t){t.some(function(n){try{n.__h.forEach(kf),n.__h=n.__h.filter(function(r){return!r.__||Dg(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Qt.__e(r,n.__v)}}),aE&&aE(e,t)},Qt.unmount=function(e){cE&&cE(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{kf(r)}catch(i){t=i}}),n.__H=void 0,t&&Qt.__e(t,n.__v))};var fE=typeof requestAnimationFrame=="function";function fj(e){var t,n=function(){clearTimeout(r),fE&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);fE&&(t=requestAnimationFrame(n))}function kf(e){var t=Gt,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),Gt=t}function Dg(e){var t=Gt;e.__c=e.__(),Gt=t}function hj(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function hE(e,t){return typeof t=="function"?t(e):t}const pj=[{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"}],mj="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";function pE(e,t={}){const{forHash:n}=t,{authorization:r,factory:i,factoryData:s}=e;return n&&(i==="0x7702"||i==="0x7702000000000000000000000000000000000000")?r?Yt([r.address,s??"0x"]):"0x7702000000000000000000000000000000000000":i?Yt([i,s??"0x"]):"0x"}const mE="0x22e325a297439656";function gE(e,t={}){const{callGasLimit:n,callData:r,maxPriorityFeePerGas:i,maxFeePerGas:s,paymaster:o,paymasterData:a,paymasterPostOpGasLimit:c,paymasterSignature:u,paymasterVerificationGasLimit:l,sender:d,signature:f="0x",verificationGasLimit:h}=e,m=Yt([Jt(ae(h||0n),{size:16}),Jt(ae(n||0n),{size:16})]),y=pE(e,t),w=Yt([Jt(ae(i||0n),{size:16}),Jt(ae(s||0n),{size:16})]),b=e.nonce??0n,E=o?Yt([o,Jt(ae(l||0n),{size:16}),Jt(ae(c||0n),{size:16}),a||"0x",...u?t.forHash?[mE]:[u,Jt(ae(kt(u)),{size:2}),mE]:[]]):"0x",v=e.preVerificationGas??0n;return{accountGasLimits:m,callData:r,initCode:y,gasFees:w,nonce:b,paymasterAndData:E,preVerificationGas:v,sender:d,signature:f}}const gj={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 yj(e){const{chainId:t,entryPointAddress:n,userOperation:r}=e,i=gE(r,{forHash:!0});return{types:gj,primaryType:"PackedUserOperation",domain:{name:"ERC4337",version:"1",chainId:t,verifyingContract:n},message:i}}function bj(e){const{chainId:t,entryPointAddress:n,entryPointVersion:r}=e,i=e.userOperation,{authorization:s,callData:o="0x",callGasLimit:a,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:l,paymasterAndData:d="0x",preVerificationGas:f,sender:h,verificationGasLimit:m}=i;if(r==="0.8"||r==="0.9")return Au(yj({chainId:t,entryPointAddress:n,userOperation:i}));const y=(()=>{var w,b;if(r==="0.6"){const E=(w=i.initCode)==null?void 0:w.slice(0,42),v=(b=i.initCode)==null?void 0:b.slice(42),A=pE({authorization:s,factory:E,factoryData:v},{forHash:!0});return Wn([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"bytes32"}],[h,l,At(A),At(o),a,m,f,c,u,At(d)])}if(r==="0.7"){const E=gE(i,{forHash:!0});return Wn([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[E.sender,E.nonce,At(E.initCode),At(E.callData),E.accountGasLimits,E.preVerificationGas,E.gasFees,At(E.paymasterAndData)])}throw new Error(`entryPointVersion "${r}" not supported.`)})();return At(Wn([{type:"bytes32"},{type:"address"},{type:"uint256"}],[At(y),n,BigInt(t)]))}async function wj(e){const{extend:t,nonceKeyManager:n=HO({source:{get(){return Date.now()},set(){}}}),...r}=e;let i=!1;const s=await e.getAddress();return{...t,...r,address:s,async getFactoryArgs(){return"isDeployed"in this&&await this.isDeployed()?{factory:void 0,factoryData:void 0}:e.getFactoryArgs()},async getNonce(o){const a=(o==null?void 0:o.key)??BigInt(await n.consume({address:s,chainId:e.client.chain.id,client:e.client}));return e.getNonce?await e.getNonce({...o,key:a}):await Mn(e.client,{abi:op(["function getNonce(address, uint192) pure returns (uint256)"]),address:e.entryPoint.address,functionName:"getNonce",args:[s,a]})},async isDeployed(){return i?!0:(i=!!await _e(e.client,wa,"getCode")({address:s}),i)},...e.sign?{async sign(o){const[{factory:a,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.sign(o)]);return a&&c?Rm({address:a,data:c,signature:u}):u}}:{},async signMessage(o){const[{factory:a,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.signMessage(o)]);return a&&c&&a!=="0x7702"?Rm({address:a,data:c,signature:u}):u},async signTypedData(o){const[{factory:a,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.signTypedData(o)]);return a&&c&&a!=="0x7702"?Rm({address:a,data:c,signature:u}):u},type:"smart"}}class Ug extends ee{constructor({cause:t}){super("Smart Account is not deployed.",{cause:t,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(Ug,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa20/});class Oa extends ee{constructor({cause:t,data:n,message:r}={}){var s;const i=(s=r==null?void 0:r.replace("execution reverted: ",""))==null?void 0:s.replace("execution reverted","");super(`Execution reverted ${i?`with reason: ${i}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n}}Object.defineProperty(Oa,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32521}),Object.defineProperty(Oa,"message",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Hg extends ee{constructor({cause:t}){super("Failed to send funds to beneficiary.",{cause:t,name:"FailedToSendToBeneficiaryError"})}}Object.defineProperty(Hg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa91/});class zg extends ee{constructor({cause:t}){super("Gas value overflowed.",{cause:t,metaMessages:["This could arise when:","- one of the gas values exceeded 2**120 (uint120)"].filter(Boolean),name:"GasValuesOverflowError"})}}Object.defineProperty(zg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa94/});class Wg extends ee{constructor({cause:t}){super("The `handleOps` function was called by the Bundler with a gas limit too low.",{cause:t,name:"HandleOpsOutOfGasError"})}}Object.defineProperty(Wg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa95/});class Gg extends ee{constructor({cause:t,factory:n,factoryData:r,initCode:i}){super("Failed to simulate deployment for Smart Account.",{cause:t,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
114
+ */var B6;function l7(){return B6||(B6=1,process.env.NODE_ENV!=="production"&&function(){function e(u,l){return u===l&&(u!==0||1/u===1/l)||u!==u&&l!==l}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=ce,n=O6(),r=typeof Object.is=="function"?Object.is:e,i=n.useSyncExternalStore,s=t.useRef,o=t.useEffect,a=t.useMemo,c=t.useDebugValue;Km.useSyncExternalStoreWithSelector=function(u,l,d,f,h){var m=s(null);if(m.current===null){var y={hasValue:!1,value:null};m.current=y}else y=m.current;m=a(function(){function b(M){if(!E){if(E=!0,v=M,M=f(M),h!==void 0&&y.hasValue){var L=y.value;if(h(L,M))return A=L}return A=M}if(L=A,r(v,M))return L;var U=f(M);return h!==void 0&&h(L,U)?(v=M,L):(v=M,A=U)}var E=!1,v,A,P=d===void 0?null:d;return[function(){return b(l())},P===null?void 0:function(){return b(P())}]},[l,d,f,h]);var w=i(u,m[0],m[1]);return o(function(){y.hasValue=!0,y.value=w},[w]),c(w),w},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Km}process.env.NODE_ENV==="production"?Wm.exports=u7():Wm.exports=l7();var d7=Wm.exports;const Jm=e=>typeof e=="object"&&!Array.isArray(e);function f7(e,t,n=t,r=ro){const i=ce.useRef([]),s=d7.useSyncExternalStoreWithSelector(e,t,n,o=>o,(o,a)=>{if(Jm(o)&&Jm(a)&&i.current.length){for(const c of i.current)if(!r(o[c],a[c]))return!1;return!0}return r(o,a)});return ce.useMemo(()=>{if(Jm(s)){const o={...s};let a={};for(const[c,u]of Object.entries(o))a={...a,[c]:{configurable:!1,enumerable:!0,get:()=>(i.current.includes(c)||i.current.push(c),u)}};return Object.defineProperties(o,a),o}return s},[s])}function Zm(e={}){const t=Or(e);return f7(n=>OB(t,{onChange:n}),()=>y6(t))}var Aa=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(){}},h7=(oI=class extends Aa{constructor(){super();Pe(this,No);Pe(this,Rs);Pe(this,Ac);ye(this,Ac,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){V(this,Rs)||this.setEventListener(V(this,Ac))}onUnsubscribe(){var t;this.hasListeners()||((t=V(this,Rs))==null||t.call(this),ye(this,Rs,void 0))}setEventListener(t){var n;ye(this,Ac,t),(n=V(this,Rs))==null||n.call(this),ye(this,Rs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){V(this,No)!==t&&(ye(this,No,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof V(this,No)=="boolean"?V(this,No):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},No=new WeakMap,Rs=new WeakMap,Ac=new WeakMap,oI),Ym=new h7,p7={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},m7=(aI=class{constructor(){Pe(this,ci,p7);Pe(this,Lo,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&V(this,Lo)&&e!==V(this,ci)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:V(this,ci),provider:e}),ye(this,ci,e),process.env.NODE_ENV!=="production"&&ye(this,Lo,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&ye(this,Lo,!0),V(this,ci).setTimeout(e,t)}clearTimeout(e){V(this,ci).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&ye(this,Lo,!0),V(this,ci).setInterval(e,t)}clearInterval(e){V(this,ci).clearInterval(e)}},ci=new WeakMap,Lo=new WeakMap,aI),io=new m7;function g7(e){setTimeout(e,0)}var y7=typeof window>"u"||"Deno"in globalThis;function Nn(){}function b7(e,t){return typeof e=="function"?e(t):e}function Qm(e){return typeof e=="number"&&e>=0&&e!==1/0}function N6(e,t){return Math.max(e+(t||0)-Date.now(),0)}function hs(e,t){return typeof e=="function"?e(t):e}function hr(e,t){return typeof e=="function"?e(t):e}function L6(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==Xm(o,t.options))return!1}else if(!Cu(t.queryKey,o))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||i&&i!==t.state.fetchStatus||s&&!s(t))}function j6(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(so(t.options.mutationKey)!==so(s))return!1}else if(!Cu(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Xm(e,t){return((t==null?void 0:t.queryKeyHashFn)||so)(e)}function so(e){return JSON.stringify(e,(t,n)=>tg(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Cu(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Cu(e[n],t[n])):!1}var w7=Object.prototype.hasOwnProperty;function eg(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=$6(e)&&$6(t);if(!r&&!(tg(e)&&tg(t)))return t;const s=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),a=o.length,c=r?new Array(a):{};let u=0;for(let l=0;l<a;l++){const d=r?l:o[l],f=e[d],h=t[d];if(f===h){c[d]=f,(r?l<s:w7.call(e,d))&&u++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){c[d]=h;continue}const m=eg(f,h,n+1);c[d]=m,m===f&&u++}return s===a&&u===s?e:c}function Yd(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 $6(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function tg(e){if(!F6(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!F6(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function F6(e){return Object.prototype.toString.call(e)==="[object Object]"}function v7(e){return new Promise(t=>{io.setTimeout(t,e)})}function ng(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return eg(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return eg(e,t)}return t}function _7(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function E7(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Qd=Symbol();function D6(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Qd&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Qd?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function rg(e,t){return typeof e=="function"?e(...t):!!e}function x7(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),e}var Pu=(()=>{let e=()=>y7;return{isServer(){return e()},setIsServer(t){e=t}}})();function ig(){let e,t;const n=new Promise((i,s)=>{e=i,t=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}var S7=g7;function k7(){let e=[],t=0,n=a=>{a()},r=a=>{a()},i=S7;const s=a=>{t?e.push(a):i(()=>{n(a)})},o=()=>{const a=e;e=[],a.length&&i(()=>{r(()=>{a.forEach(c=>{n(c)})})})};return{batch:a=>{let c;t++;try{c=a()}finally{t--,t||o()}return c},batchCalls:a=>(...c)=>{s(()=>{a(...c)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}var nn=k7(),A7=(cI=class extends Aa{constructor(){super();Pe(this,Ic,!0);Pe(this,Ts);Pe(this,Cc);ye(this,Cc,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){V(this,Ts)||this.setEventListener(V(this,Cc))}onUnsubscribe(){var t;this.hasListeners()||((t=V(this,Ts))==null||t.call(this),ye(this,Ts,void 0))}setEventListener(t){var n;ye(this,Cc,t),(n=V(this,Ts))==null||n.call(this),ye(this,Ts,t(this.setOnline.bind(this)))}setOnline(t){V(this,Ic)!==t&&(ye(this,Ic,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return V(this,Ic)}},Ic=new WeakMap,Ts=new WeakMap,Cc=new WeakMap,cI),Xd=new A7;function I7(e){return Math.min(1e3*2**e,3e4)}function U6(e){return(e??"online")==="online"?Xd.isOnline():!0}var sg=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function H6(e){let t=!1,n=0,r;const i=ig(),s=()=>i.status!=="pending",o=y=>{var w;if(!s()){const b=new sg(y);f(b),(w=e.onCancel)==null||w.call(e,b)}},a=()=>{t=!0},c=()=>{t=!1},u=()=>Ym.isFocused()&&(e.networkMode==="always"||Xd.isOnline())&&e.canRun(),l=()=>U6(e.networkMode)&&e.canRun(),d=y=>{s()||(r==null||r(),i.resolve(y))},f=y=>{s()||(r==null||r(),i.reject(y))},h=()=>new Promise(y=>{var w;r=b=>{(s()||u())&&y(b)},(w=e.onPause)==null||w.call(e)}).then(()=>{var y;r=void 0,s()||(y=e.onContinue)==null||y.call(e)}),m=()=>{if(s())return;let y;const w=n===0?e.initialPromise:void 0;try{y=w??e.fn()}catch(b){y=Promise.reject(b)}Promise.resolve(y).then(d).catch(b=>{var M;if(s())return;const E=e.retry??(Pu.isServer()?0:3),v=e.retryDelay??I7,A=typeof v=="function"?v(n,b):v,P=E===!0||typeof E=="number"&&n<E||typeof E=="function"&&E(n,b);if(t||!P){f(b);return}n++,(M=e.onFail)==null||M.call(e,n,b),v7(A).then(()=>u()?void 0:h()).then(()=>{t?f(b):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r==null||r(),i),cancelRetry:a,continueRetry:c,canStart:l,start:()=>(l()?m():h().then(m),i)}}var z6=(uI=class{constructor(){Pe(this,jo)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Qm(this.gcTime)&&ye(this,jo,io.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Pu.isServer()?1/0:5*60*1e3))}clearGcTimeout(){V(this,jo)!==void 0&&(io.clearTimeout(V(this,jo)),ye(this,jo,void 0))}},jo=new WeakMap,uI),C7=(lI=class extends z6{constructor(t){super();Pe(this,cr);Pe(this,$o);Pe(this,Pc);Pe(this,Sr);Pe(this,Fo);Pe(this,pn);Pe(this,zl);Pe(this,Do);ye(this,Do,!1),ye(this,zl,t.defaultOptions),this.setOptions(t.options),this.observers=[],ye(this,Fo,t.client),ye(this,Sr,V(this,Fo).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ye(this,$o,q6(this.options)),this.state=t.state??V(this,$o),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=V(this,pn))==null?void 0:t.promise}setOptions(t){if(this.options={...V(this,zl),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=q6(this.options);n.data!==void 0&&(this.setState(G6(n.data,n.dataUpdatedAt)),ye(this,$o,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&V(this,Sr).remove(this)}setData(t,n){const r=ng(this.state.data,t,this.options);return je(this,cr,Yi).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){je(this,cr,Yi).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,i;const n=(r=V(this,pn))==null?void 0:r.promise;return(i=V(this,pn))==null||i.cancel(t),n?n.then(Nn).catch(Nn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return V(this,$o)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>hr(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Qd||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>hs(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!N6(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=V(this,pn))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=V(this,pn))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),V(this,Sr).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(V(this,pn)&&(V(this,Do)||je(this,cr,wI).call(this)?V(this,pn).cancel({revert:!0}):V(this,pn).cancelRetry()),this.scheduleGc()),V(this,Sr).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||je(this,cr,Yi).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,l,d,f,h,m,y,w,b,E,v;if(this.state.fetchStatus!=="idle"&&((c=V(this,pn))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(V(this,pn))return V(this,pn).continueRetry(),V(this,pn).promise}if(t&&this.setOptions(t),!this.options.queryFn){const A=this.observers.find(P=>P.options.queryFn);A&&this.setOptions(A.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,i=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(ye(this,Do,!0),r.signal)})},s=()=>{const A=D6(this.options,n),M=(()=>{const L={client:V(this,Fo),queryKey:this.queryKey,meta:this.meta};return i(L),L})();return ye(this,Do,!1),this.options.persister?this.options.persister(A,M,this):A(M)},a=(()=>{const A={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:V(this,Fo),state:this.state,fetchFn:s};return i(A),A})();(u=this.options.behavior)==null||u.onFetch(a,this),ye(this,Pc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((l=a.fetchOptions)==null?void 0:l.meta))&&je(this,cr,Yi).call(this,{type:"fetch",meta:(d=a.fetchOptions)==null?void 0:d.meta}),ye(this,pn,H6({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:A=>{A instanceof sg&&A.revert&&this.setState({...V(this,Pc),fetchStatus:"idle"}),r.abort()},onFail:(A,P)=>{je(this,cr,Yi).call(this,{type:"failed",failureCount:A,error:P})},onPause:()=>{je(this,cr,Yi).call(this,{type:"pause"})},onContinue:()=>{je(this,cr,Yi).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{const A=await V(this,pn).start();if(A===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(A),(h=(f=V(this,Sr).config).onSuccess)==null||h.call(f,A,this),(y=(m=V(this,Sr).config).onSettled)==null||y.call(m,A,this.state.error,this),A}catch(A){if(A instanceof sg){if(A.silent)return V(this,pn).promise;if(A.revert){if(this.state.data===void 0)throw A;return this.state.data}}throw je(this,cr,Yi).call(this,{type:"error",error:A}),(b=(w=V(this,Sr).config).onError)==null||b.call(w,A,this),(v=(E=V(this,Sr).config).onSettled)==null||v.call(E,this.state.data,A,this),A}finally{this.scheduleGc()}}},$o=new WeakMap,Pc=new WeakMap,Sr=new WeakMap,Fo=new WeakMap,pn=new WeakMap,zl=new WeakMap,Do=new WeakMap,cr=new WeakSet,wI=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Yi=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...W6(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...G6(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ye(this,Pc,t.manual?i:void 0),i;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),nn.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),V(this,Sr).notify({query:this,type:"updated",action:t})})},lI);function W6(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:U6(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function G6(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function q6(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?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 P7=(dI=class extends Aa{constructor(t,n){super();Pe(this,ct);Pe(this,Xn);Pe(this,et);Pe(this,Wl);Pe(this,Dn);Pe(this,Uo);Pe(this,Rc);Pe(this,zi);Pe(this,Os);Pe(this,Gl);Pe(this,Tc);Pe(this,Oc);Pe(this,Ho);Pe(this,zo);Pe(this,Ms);Pe(this,Mc,new Set);this.options=n,ye(this,Xn,t),ye(this,Os,null),ye(this,zi,ig()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(V(this,et).addObserver(this),V6(V(this,et),this.options)?je(this,ct,Kl).call(this):this.updateResult(),je(this,ct,aw).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return og(V(this,et),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return og(V(this,et),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,je(this,ct,cw).call(this),je(this,ct,uw).call(this),V(this,et).removeObserver(this)}setOptions(t){const n=this.options,r=V(this,et);if(this.options=V(this,Xn).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof hr(this.options.enabled,V(this,et))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");je(this,ct,lw).call(this),V(this,et).setOptions(this.options),n._defaulted&&!Yd(this.options,n)&&V(this,Xn).getQueryCache().notify({type:"observerOptionsUpdated",query:V(this,et),observer:this});const i=this.hasListeners();i&&K6(V(this,et),r,this.options,n)&&je(this,ct,Kl).call(this),this.updateResult(),i&&(V(this,et)!==r||hr(this.options.enabled,V(this,et))!==hr(n.enabled,V(this,et))||hs(this.options.staleTime,V(this,et))!==hs(n.staleTime,V(this,et)))&&je(this,ct,iw).call(this);const s=je(this,ct,sw).call(this);i&&(V(this,et)!==r||hr(this.options.enabled,V(this,et))!==hr(n.enabled,V(this,et))||s!==V(this,Ms))&&je(this,ct,ow).call(this,s)}getOptimisticResult(t){const n=V(this,Xn).getQueryCache().build(V(this,Xn),t),r=this.createResult(n,t);return T7(this,r)&&(ye(this,Dn,r),ye(this,Rc,this.options),ye(this,Uo,V(this,et).state)),r}getCurrentResult(){return V(this,Dn)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&V(this,zi).status==="pending"&&V(this,zi).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(t){V(this,Mc).add(t)}getCurrentQuery(){return V(this,et)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=V(this,Xn).defaultQueryOptions(t),r=V(this,Xn).getQueryCache().build(V(this,Xn),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return je(this,ct,Kl).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),V(this,Dn)))}createResult(t,n){var j;const r=V(this,et),i=this.options,s=V(this,Dn),o=V(this,Uo),a=V(this,Rc),u=t!==r?t.state:V(this,Wl),{state:l}=t;let d={...l},f=!1,h;if(n._optimisticResults){const Z=this.hasListeners(),Y=!Z&&V6(t,n),W=Z&&K6(t,r,n,i);(Y||W)&&(d={...d,...W6(l.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:y,status:w}=d;h=d.data;let b=!1;if(n.placeholderData!==void 0&&h===void 0&&w==="pending"){let Z;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(Z=s.data,b=!0):Z=typeof n.placeholderData=="function"?n.placeholderData((j=V(this,Oc))==null?void 0:j.state.data,V(this,Oc)):n.placeholderData,Z!==void 0&&(w="success",h=ng(s==null?void 0:s.data,Z,n),f=!0)}if(n.select&&h!==void 0&&!b)if(s&&h===(o==null?void 0:o.data)&&n.select===V(this,Gl))h=V(this,Tc);else try{ye(this,Gl,n.select),h=n.select(h),h=ng(s==null?void 0:s.data,h,n),ye(this,Tc,h),ye(this,Os,null)}catch(Z){ye(this,Os,Z)}V(this,Os)&&(m=V(this,Os),h=V(this,Tc),y=Date.now(),w="error");const E=d.fetchStatus==="fetching",v=w==="pending",A=w==="error",P=v&&E,M=h!==void 0,U={status:w,fetchStatus:d.fetchStatus,isPending:v,isSuccess:w==="success",isError:A,isInitialLoading:P,isLoading:P,data:h,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:y,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:E,isRefetching:E&&!v,isLoadingError:A&&!M,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:A&&M,isStale:ag(t,n),refetch:this.refetch,promise:V(this,zi),isEnabled:hr(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const Z=U.data!==void 0,Y=U.status==="error"&&!Z,W=g=>{Y?g.reject(U.error):Z&&g.resolve(U.data)},I=()=>{const g=ye(this,zi,U.promise=ig());W(g)},p=V(this,zi);switch(p.status){case"pending":t.queryHash===r.queryHash&&W(p);break;case"fulfilled":(Y||U.data!==p.value)&&I();break;case"rejected":(!Y||U.error!==p.reason)&&I();break}}return U}updateResult(){const t=V(this,Dn),n=this.createResult(V(this,et),this.options);if(ye(this,Uo,V(this,et).state),ye(this,Rc,this.options),V(this,Uo).data!==void 0&&ye(this,Oc,V(this,et)),Yd(n,t))return;ye(this,Dn,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!V(this,Mc).size)return!0;const o=new Set(s??V(this,Mc));return this.options.throwOnError&&o.add("error"),Object.keys(V(this,Dn)).some(a=>{const c=a;return V(this,Dn)[c]!==t[c]&&o.has(c)})};je(this,ct,vI).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&je(this,ct,aw).call(this)}},Xn=new WeakMap,et=new WeakMap,Wl=new WeakMap,Dn=new WeakMap,Uo=new WeakMap,Rc=new WeakMap,zi=new WeakMap,Os=new WeakMap,Gl=new WeakMap,Tc=new WeakMap,Oc=new WeakMap,Ho=new WeakMap,zo=new WeakMap,Ms=new WeakMap,Mc=new WeakMap,ct=new WeakSet,Kl=function(t){je(this,ct,lw).call(this);let n=V(this,et).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Nn)),n},iw=function(){je(this,ct,cw).call(this);const t=hs(this.options.staleTime,V(this,et));if(Pu.isServer()||V(this,Dn).isStale||!Qm(t))return;const r=N6(V(this,Dn).dataUpdatedAt,t)+1;ye(this,Ho,io.setTimeout(()=>{V(this,Dn).isStale||this.updateResult()},r))},sw=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(V(this,et)):this.options.refetchInterval)??!1},ow=function(t){je(this,ct,uw).call(this),ye(this,Ms,t),!(Pu.isServer()||hr(this.options.enabled,V(this,et))===!1||!Qm(V(this,Ms))||V(this,Ms)===0)&&ye(this,zo,io.setInterval(()=>{(this.options.refetchIntervalInBackground||Ym.isFocused())&&je(this,ct,Kl).call(this)},V(this,Ms)))},aw=function(){je(this,ct,iw).call(this),je(this,ct,ow).call(this,je(this,ct,sw).call(this))},cw=function(){V(this,Ho)!==void 0&&(io.clearTimeout(V(this,Ho)),ye(this,Ho,void 0))},uw=function(){V(this,zo)!==void 0&&(io.clearInterval(V(this,zo)),ye(this,zo,void 0))},lw=function(){const t=V(this,Xn).getQueryCache().build(V(this,Xn),this.options);if(t===V(this,et))return;const n=V(this,et);ye(this,et,t),ye(this,Wl,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},vI=function(t){nn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(V(this,Dn))}),V(this,Xn).getQueryCache().notify({query:V(this,et),type:"observerResultsUpdated"})})},dI);function R7(e,t){return hr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function V6(e,t){return R7(e,t)||e.state.data!==void 0&&og(e,t,t.refetchOnMount)}function og(e,t,n){if(hr(t.enabled,e)!==!1&&hs(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&ag(e,t)}return!1}function K6(e,t,n,r){return(e!==t||hr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&ag(e,n)}function ag(e,t){return hr(t.enabled,e)!==!1&&e.isStaleByTime(hs(t.staleTime,e))}function T7(e,t){return!Yd(e.getCurrentResult(),t)}function J6(e){return{onFetch:(t,n)=>{var l,d,f,h,m;const r=t.options,i=(f=(d=(l=t.fetchOptions)==null?void 0:l.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,s=((h=t.state.data)==null?void 0:h.pages)||[],o=((m=t.state.data)==null?void 0:m.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const u=async()=>{let y=!1;const w=v=>{x7(v,()=>t.signal,()=>y=!0)},b=D6(t.options,t.fetchOptions),E=async(v,A,P)=>{if(y)return Promise.reject();if(A==null&&v.pages.length)return Promise.resolve(v);const L=(()=>{const Y={client:t.client,queryKey:t.queryKey,pageParam:A,direction:P?"backward":"forward",meta:t.options.meta};return w(Y),Y})(),U=await b(L),{maxPages:j}=t.options,Z=P?E7:_7;return{pages:Z(v.pages,U,j),pageParams:Z(v.pageParams,A,j)}};if(i&&s.length){const v=i==="backward",A=v?O7:Z6,P={pages:s,pageParams:o},M=A(r,P);a=await E(P,M,v)}else{const v=e??s.length;do{const A=c===0?o[0]??r.initialPageParam:Z6(r,a);if(c>0&&A==null)break;a=await E(a,A),c++}while(c<v)}return a};t.options.persister?t.fetchFn=()=>{var y,w;return(w=(y=t.options).persister)==null?void 0:w.call(y,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function Z6(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 O7(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var M7=(fI=class extends z6{constructor(t){super();Pe(this,li);Pe(this,ql);Pe(this,ui);Pe(this,Pn);Pe(this,Wo);ye(this,ql,t.client),this.mutationId=t.mutationId,ye(this,Pn,t.mutationCache),ye(this,ui,[]),this.state=t.state||Y6(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){V(this,ui).includes(t)||(V(this,ui).push(t),this.clearGcTimeout(),V(this,Pn).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ye(this,ui,V(this,ui).filter(n=>n!==t)),this.scheduleGc(),V(this,Pn).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){V(this,ui).length||(this.state.status==="pending"?this.scheduleGc():V(this,Pn).remove(this))}continue(){var t;return((t=V(this,Wo))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,a,c,u,l,d,f,h,m,y,w,b,E,v,A,P,M,L;const n=()=>{je(this,li,$s).call(this,{type:"continue"})},r={client:V(this,ql),meta:this.options.meta,mutationKey:this.options.mutationKey};ye(this,Wo,H6({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(U,j)=>{je(this,li,$s).call(this,{type:"failed",failureCount:U,error:j})},onPause:()=>{je(this,li,$s).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>V(this,Pn).canRun(this)}));const i=this.state.status==="pending",s=!V(this,Wo).canStart();try{if(i)n();else{je(this,li,$s).call(this,{type:"pending",variables:t,isPaused:s}),V(this,Pn).config.onMutate&&await V(this,Pn).config.onMutate(t,this,r);const j=await((a=(o=this.options).onMutate)==null?void 0:a.call(o,t,r));j!==this.state.context&&je(this,li,$s).call(this,{type:"pending",context:j,variables:t,isPaused:s})}const U=await V(this,Wo).start();return await((u=(c=V(this,Pn).config).onSuccess)==null?void 0:u.call(c,U,t,this.state.context,this,r)),await((d=(l=this.options).onSuccess)==null?void 0:d.call(l,U,t,this.state.context,r)),await((h=(f=V(this,Pn).config).onSettled)==null?void 0:h.call(f,U,null,this.state.variables,this.state.context,this,r)),await((y=(m=this.options).onSettled)==null?void 0:y.call(m,U,null,t,this.state.context,r)),je(this,li,$s).call(this,{type:"success",data:U}),U}catch(U){try{await((b=(w=V(this,Pn).config).onError)==null?void 0:b.call(w,U,t,this.state.context,this,r))}catch(j){Promise.reject(j)}try{await((v=(E=this.options).onError)==null?void 0:v.call(E,U,t,this.state.context,r))}catch(j){Promise.reject(j)}try{await((P=(A=V(this,Pn).config).onSettled)==null?void 0:P.call(A,void 0,U,this.state.variables,this.state.context,this,r))}catch(j){Promise.reject(j)}try{await((L=(M=this.options).onSettled)==null?void 0:L.call(M,void 0,U,t,this.state.context,r))}catch(j){Promise.reject(j)}throw je(this,li,$s).call(this,{type:"error",error:U}),U}finally{V(this,Pn).runNext(this)}}},ql=new WeakMap,ui=new WeakMap,Pn=new WeakMap,Wo=new WeakMap,li=new WeakSet,$s=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),nn.batch(()=>{V(this,ui).forEach(r=>{r.onMutationUpdate(t)}),V(this,Pn).notify({mutation:this,type:"updated",action:t})})},fI);function Y6(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var B7=(hI=class extends Aa{constructor(t={}){super();Pe(this,Wi);Pe(this,Hr);Pe(this,Vl);this.config=t,ye(this,Wi,new Set),ye(this,Hr,new Map),ye(this,Vl,0)}build(t,n,r){const i=new M7({client:t,mutationCache:this,mutationId:++O0(this,Vl)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){V(this,Wi).add(t);const n=ef(t);if(typeof n=="string"){const r=V(this,Hr).get(n);r?r.push(t):V(this,Hr).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(V(this,Wi).delete(t)){const n=ef(t);if(typeof n=="string"){const r=V(this,Hr).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&V(this,Hr).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=ef(t);if(typeof n=="string"){const r=V(this,Hr).get(n),i=r==null?void 0:r.find(s=>s.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r;const n=ef(t);if(typeof n=="string"){const i=(r=V(this,Hr).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){nn.batch(()=>{V(this,Wi).forEach(t=>{this.notify({type:"removed",mutation:t})}),V(this,Wi).clear(),V(this,Hr).clear()})}getAll(){return Array.from(V(this,Wi))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>j6(n,r))}findAll(t={}){return this.getAll().filter(n=>j6(t,n))}notify(t){nn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return nn.batch(()=>Promise.all(t.map(n=>n.continue().catch(Nn))))}},Wi=new WeakMap,Hr=new WeakMap,Vl=new WeakMap,hI);function ef(e){var t;return(t=e.options.scope)==null?void 0:t.id}var N7=(pI=class extends Aa{constructor(t,n){super();Pe(this,Vi);Pe(this,Gi);Pe(this,Bs);Pe(this,er);Pe(this,qi);ye(this,Gi,t),this.setOptions(n),this.bindMethods(),je(this,Vi,M0).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const n=this.options;this.options=V(this,Gi).defaultMutationOptions(t),Yd(this.options,n)||V(this,Gi).getMutationCache().notify({type:"observerOptionsUpdated",mutation:V(this,er),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&so(n.mutationKey)!==so(this.options.mutationKey)?this.reset():((r=V(this,er))==null?void 0:r.state.status)==="pending"&&V(this,er).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=V(this,er))==null||t.removeObserver(this)}onMutationUpdate(t){je(this,Vi,M0).call(this),je(this,Vi,dw).call(this,t)}getCurrentResult(){return V(this,Bs)}reset(){var t;(t=V(this,er))==null||t.removeObserver(this),ye(this,er,void 0),je(this,Vi,M0).call(this),je(this,Vi,dw).call(this)}mutate(t,n){var r;return ye(this,qi,n),(r=V(this,er))==null||r.removeObserver(this),ye(this,er,V(this,Gi).getMutationCache().build(V(this,Gi),this.options)),V(this,er).addObserver(this),V(this,er).execute(t)}},Gi=new WeakMap,Bs=new WeakMap,er=new WeakMap,qi=new WeakMap,Vi=new WeakSet,M0=function(){var n;const t=((n=V(this,er))==null?void 0:n.state)??Y6();ye(this,Bs,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},dw=function(t){nn.batch(()=>{var n,r,i,s,o,a,c,u;if(V(this,qi)&&this.hasListeners()){const l=V(this,Bs).variables,d=V(this,Bs).context,f={client:V(this,Gi),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(r=(n=V(this,qi)).onSuccess)==null||r.call(n,t.data,l,d,f)}catch(h){Promise.reject(h)}try{(s=(i=V(this,qi)).onSettled)==null||s.call(i,t.data,null,l,d,f)}catch(h){Promise.reject(h)}}else if((t==null?void 0:t.type)==="error"){try{(a=(o=V(this,qi)).onError)==null||a.call(o,t.error,l,d,f)}catch(h){Promise.reject(h)}try{(u=(c=V(this,qi)).onSettled)==null||u.call(c,void 0,t.error,l,d,f)}catch(h){Promise.reject(h)}}}this.listeners.forEach(l=>{l(V(this,Bs))})})},pI),L7=(mI=class extends Aa{constructor(t={}){super();Pe(this,di);this.config=t,ye(this,di,new Map)}build(t,n,r){const i=n.queryKey,s=n.queryHash??Xm(i,n);let o=this.get(s);return o||(o=new C7({client:t,queryKey:i,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(o)),o}add(t){V(this,di).has(t.queryHash)||(V(this,di).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=V(this,di).get(t.queryHash);n&&(t.destroy(),n===t&&V(this,di).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){nn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return V(this,di).get(t)}getAll(){return[...V(this,di).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>L6(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>L6(t,r)):n}notify(t){nn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){nn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){nn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},di=new WeakMap,mI),j7=(gI=class{constructor(e={}){Pe(this,Ft);Pe(this,Ns);Pe(this,Ls);Pe(this,Bc);Pe(this,Nc);Pe(this,js);Pe(this,Lc);Pe(this,jc);ye(this,Ft,e.queryCache||new L7),ye(this,Ns,e.mutationCache||new B7),ye(this,Ls,e.defaultOptions||{}),ye(this,Bc,new Map),ye(this,Nc,new Map),ye(this,js,0)}mount(){O0(this,js)._++,V(this,js)===1&&(ye(this,Lc,Ym.subscribe(async e=>{e&&(await this.resumePausedMutations(),V(this,Ft).onFocus())})),ye(this,jc,Xd.subscribe(async e=>{e&&(await this.resumePausedMutations(),V(this,Ft).onOnline())})))}unmount(){var e,t;O0(this,js)._--,V(this,js)===0&&((e=V(this,Lc))==null||e.call(this),ye(this,Lc,void 0),(t=V(this,jc))==null||t.call(this),ye(this,jc,void 0))}isFetching(e){return V(this,Ft).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return V(this,Ns).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=V(this,Ft).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=V(this,Ft).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(hs(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return V(this,Ft).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=V(this,Ft).get(r.queryHash),s=i==null?void 0:i.state.data,o=b7(t,s);if(o!==void 0)return V(this,Ft).build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return nn.batch(()=>V(this,Ft).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=V(this,Ft).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=V(this,Ft);nn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=V(this,Ft);return nn.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=nn.batch(()=>V(this,Ft).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Nn).catch(Nn)}invalidateQueries(e,t={}){return nn.batch(()=>(V(this,Ft).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=nn.batch(()=>V(this,Ft).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(Nn)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Nn)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=V(this,Ft).build(this,t);return n.isStaleByTime(hs(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Nn).catch(Nn)}fetchInfiniteQuery(e){return e.behavior=J6(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Nn).catch(Nn)}ensureInfiniteQueryData(e){return e.behavior=J6(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Xd.isOnline()?V(this,Ns).resumePausedMutations():Promise.resolve()}getQueryCache(){return V(this,Ft)}getMutationCache(){return V(this,Ns)}getDefaultOptions(){return V(this,Ls)}setDefaultOptions(e){ye(this,Ls,e)}setQueryDefaults(e,t){V(this,Bc).set(so(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...V(this,Bc).values()],n={};return t.forEach(r=>{Cu(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){V(this,Nc).set(so(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...V(this,Nc).values()],n={};return t.forEach(r=>{Cu(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...V(this,Ls).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Xm(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Qd&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...V(this,Ls).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){V(this,Ft).clear(),V(this,Ns).clear()}},Ft=new WeakMap,Ns=new WeakMap,Ls=new WeakMap,Bc=new WeakMap,Nc=new WeakMap,js=new WeakMap,Lc=new WeakMap,jc=new WeakMap,gI);function $7(e){return JSON.stringify(e,(t,n)=>F7(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):typeof n=="bigint"?n.toString():n)}function F7(e){if(!Q6(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!Q6(n)||!n.hasOwnProperty("isPrototypeOf"))}function Q6(e){return Object.prototype.toString.call(e)==="[object Object]"}function D7(e){const{_defaulted:t,behavior:n,gcTime:r,initialData:i,initialDataUpdatedAt:s,maxPages:o,meta:a,networkMode:c,queryFn:u,queryHash:l,queryKey:d,queryKeyHashFn:f,retry:h,retryDelay:m,structuralSharing:y,getPreviousPageParam:w,getNextPageParam:b,initialPageParam:E,_optimisticResults:v,enabled:A,notifyOnChangeProps:P,placeholderData:M,refetchInterval:L,refetchIntervalInBackground:U,refetchOnMount:j,refetchOnReconnect:Z,refetchOnWindowFocus:Y,retryOnMount:W,select:I,staleTime:p,suspense:g,throwOnError:S,config:R,connector:T,query:B,...$}=e;return $}function U7(e){return{mutationFn(t){return dB(e,t)},mutationKey:["connect"]}}function H7(e){return{mutationFn(t){return EB(e,t)},mutationKey:["disconnect"]}}function z7(e,t={}){return{async queryFn({queryKey:n}){const{address:r,scopeKey:i,...s}=n[1];if(!r)throw new Error("address is required");return await AB(e,{...s,address:r})??null},queryKey:W7(t)}}function W7(e={}){return["balance",D7(e)]}function G7(e){return{mutationFn(t){return CB(e,t)},mutationKey:["sendTransaction"]}}function q7(e){return{mutationFn(t){return RB(e,t)},mutationKey:["switchChain"]}}function V7(e){return{mutationFn(t){return LB(e,t)},mutationKey:["writeContract"]}}var X6=en.createContext(void 0),e5=e=>{const t=en.useContext(X6);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},K7=({client:e,children:t})=>(en.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),C.jsx(X6.Provider,{value:e,children:t})),t5=en.createContext(!1),J7=()=>en.useContext(t5);t5.Provider;function Z7(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Y7=en.createContext(Z7()),Q7=()=>en.useContext(Y7),X7=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?rg(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},eN=e=>{en.useEffect(()=>{e.clearReset()},[e])},tN=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||rg(n,[e.error,r])),nN=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},rN=(e,t)=>e.isLoading&&e.isFetching&&!t,iN=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,n5=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function sN(e,t,n){var f,h,m,y;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=J7(),i=Q7(),s=e5(),o=s.defaultQueryOptions(e);(h=(f=s.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||h.call(f,o);const a=s.getQueryCache().get(o.queryHash);process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),o._optimisticResults=r?"isRestoring":"optimistic",nN(o),X7(o,i,a),eN(i);const c=!s.getQueryCache().get(o.queryHash),[u]=en.useState(()=>new t(s,o)),l=u.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(en.useSyncExternalStore(en.useCallback(w=>{const b=d?u.subscribe(nn.batchCalls(w)):Nn;return u.updateResult(),b},[u,d]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),en.useEffect(()=>{u.setOptions(o)},[o,u]),iN(o,l))throw n5(o,u,i);if(tN({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw l.error;if((y=(m=s.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||y.call(m,o,l),o.experimental_prefetchInRender&&!Pu.isServer()&&rN(l,r)){const w=c?n5(o,u,i):a==null?void 0:a.promise;w==null||w.catch(Nn).finally(()=>{u.updateResult()})}return o.notifyOnChangeProps?l:u.trackResult(l)}function oN(e,t){return sN(e,P7)}function Ru(e,t){const n=e5(),[r]=en.useState(()=>new N7(n,e));en.useEffect(()=>{r.setOptions(e)},[r,e]);const i=en.useSyncExternalStore(en.useCallback(o=>r.subscribe(nn.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=en.useCallback((o,a)=>{r.mutate(o,a).catch(Nn)},[r]);if(i.error&&rg(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}function aN(e){const t=oN({...e,queryKeyHashFn:$7});return t.queryKey=e.queryKey,t}function cN(e={}){const t=Or(e);return ce.useSyncExternalStore(n=>MB(t,{onChange:n}),()=>w6(t),()=>w6(t))}function cg(e={}){const{address:t,query:n={}}=e,r=Or(e),i=cN({config:r}),s=z7(r,{...e,chainId:e.chainId??i}),o=!!(t&&(n.enabled??!0));return aN({...n,...s,enabled:o})}function uN(e={}){const t=Or(e);return ce.useSyncExternalStore(n=>o7(t,{onChange:n}),()=>v6(t),()=>v6(t))}function lN(e={}){const t=Or(e);return ce.useSyncExternalStore(n=>NB(t,{onChange:n}),()=>_6(t),()=>_6(t))}function dN(e={}){const{mutation:t}=e,n=Or(e),r=U7(n),{mutate:i,mutateAsync:s,...o}=Ru({...t,...r});return ce.useEffect(()=>n.subscribe(({status:a})=>a,(a,c)=>{c==="connected"&&a==="disconnected"&&o.reset()}),[n,o.reset]),{...o,connect:i,connectAsync:s,connectors:lN({config:n})}}function fN(e={}){const t=Or(e);return ce.useSyncExternalStore(n=>BB(t,{onChange:n}),()=>Fm(t),()=>Fm(t))}function hN(e={}){const{mutation:t}=e,n=Or(e),r=H7(n),{mutate:i,mutateAsync:s,...o}=Ru({...t,...r});return{...o,connectors:fN({config:n}).map(a=>a.connector),disconnect:i,disconnectAsync:s}}function pN(e={}){const{mutation:t}=e,n=Or(e),r=G7(n),{mutate:i,mutateAsync:s,...o}=Ru({...t,...r});return{...o,sendTransaction:i,sendTransactionAsync:s}}function mN(e={}){const{mutation:t}=e,n=Or(e),r=q7(n),{mutate:i,mutateAsync:s,...o}=Ru({...t,...r});return{...o,chains:uN({config:n}),switchChain:i,switchChainAsync:s}}function gN(e={}){const{mutation:t}=e,n=Or(e),r=V7(n),{mutate:i,mutateAsync:s,...o}=Ru({...t,...r});return{...o,writeContract:i,writeContractAsync:s}}tf.type="coinbaseWallet";function tf(e={}){return e.version==="3"||e.headlessMode?bN(e):yN(e)}function yN(e){let t,n,r,i;return s=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",rdns:"com.coinbase.wallet",type:tf.type,async connect({chainId:o,withCapabilities:a,...c}={}){try{const u=await this.getProvider(),l=(await u.request({method:"eth_requestAccounts",params:"instantOnboarding"in c&&c.instantOnboarding?[{onboarding:"instant"}]:[]})).map(f=>gn(f));n||(n=this.onAccountsChanged.bind(this),u.on("accountsChanged",n)),r||(r=this.onChainChanged.bind(this),u.on("chainChanged",r)),i||(i=this.onDisconnect.bind(this),u.on("disconnect",i));let d=await this.getChainId();if(o&&d!==o){const f=await this.switchChain({chainId:o}).catch(h=>{if(h.code===Wt.code)throw h;return{id:d}});d=(f==null?void 0:f.id)??d}return{accounts:a?l.map(f=>({address:f,capabilities:{}})):l,chainId:d}}catch(u){throw/(user closed modal|accounts received is empty|user denied account|request rejected)/i.test(u.message)?new Wt(u):u}},async disconnect(){var a;const o=await this.getProvider();n&&(o.removeListener("accountsChanged",n),n=void 0),r&&(o.removeListener("chainChanged",r),r=void 0),i&&(o.removeListener("disconnect",i),i=void 0),o.disconnect(),(a=o.close)==null||a.call(o)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(a=>gn(a))},async getChainId(){const a=await(await this.getProvider()).request({method:"eth_chainId"});return Number(a)},async getProvider(){if(!t){const o=(()=>{var u;return typeof e.preference=="string"?{options:e.preference}:{...e.preference,options:((u=e.preference)==null?void 0:u.options)??"all"}})(),{createCoinbaseWalletSDK:a}=await Promise.resolve().then(()=>RH);t=a({...e,appChainIds:s.chains.map(u=>u.id),preference:o}).getProvider()}return t},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:o,chainId:a}){var l,d,f,h;const c=s.chains.find(m=>m.id===a);if(!c)throw new Ar(new Sa);const u=await this.getProvider();try{return await u.request({method:"wallet_switchEthereumChain",params:[{chainId:ae(c.id)}]}),c}catch(m){if(m.code===4902)try{let y;o!=null&&o.blockExplorerUrls?y=o.blockExplorerUrls:y=(l=c.blockExplorers)!=null&&l.default.url?[(d=c.blockExplorers)==null?void 0:d.default.url]:[];let w;(f=o==null?void 0:o.rpcUrls)!=null&&f.length?w=o.rpcUrls:w=[((h=c.rpcUrls.default)==null?void 0:h.http[0])??""];const b={blockExplorerUrls:y,chainId:ae(a),chainName:(o==null?void 0:o.chainName)??c.name,iconUrls:o==null?void 0:o.iconUrls,nativeCurrency:(o==null?void 0:o.nativeCurrency)??c.nativeCurrency,rpcUrls:w};return await u.request({method:"wallet_addEthereumChain",params:[b]}),c}catch(y){throw new Wt(y)}throw new Ar(m)}},onAccountsChanged(o){o.length===0?this.onDisconnect():s.emitter.emit("change",{accounts:o.map(a=>gn(a))})},onChainChanged(o){const a=Number(o);s.emitter.emit("change",{chainId:a})},async onDisconnect(o){s.emitter.emit("disconnect");const a=await this.getProvider();n&&(a.removeListener("accountsChanged",n),n=void 0),r&&(a.removeListener("chainChanged",r),r=void 0),i&&(a.removeListener("disconnect",i),i=void 0)}})}function bN(e){let n,r,i,s,o;return a=>({id:"coinbaseWalletSDK",name:"Coinbase Wallet",rdns:"com.coinbase.wallet",type:tf.type,async connect({chainId:c,withCapabilities:u}={}){try{const l=await this.getProvider(),d=(await l.request({method:"eth_requestAccounts"})).map(h=>gn(h));i||(i=this.onAccountsChanged.bind(this),l.on("accountsChanged",i)),s||(s=this.onChainChanged.bind(this),l.on("chainChanged",s)),o||(o=this.onDisconnect.bind(this),l.on("disconnect",o));let f=await this.getChainId();if(c&&f!==c){const h=await this.switchChain({chainId:c}).catch(m=>{if(m.code===Wt.code)throw m;return{id:f}});f=(h==null?void 0:h.id)??f}return{accounts:u?d.map(h=>({address:h,capabilities:{}})):d,chainId:f}}catch(l){throw/(user closed modal|accounts received is empty|user denied account)/i.test(l.message)?new Wt(l):l}},async disconnect(){const c=await this.getProvider();i&&(c.removeListener("accountsChanged",i),i=void 0),s&&(c.removeListener("chainChanged",s),s=void 0),o&&(c.removeListener("disconnect",o),o=void 0),c.disconnect(),c.close()},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(u=>gn(u))},async getChainId(){const u=await(await this.getProvider()).request({method:"eth_chainId"});return Number(u)},async getProvider(){var c;if(!r){const u=await(async()=>{const{default:m}=await Promise.resolve().then(()=>aQ);return typeof m!="function"&&typeof m.default=="function"?m.default:m})();n=new u({...e,reloadOnDisconnect:!1});const l=(c=n.walletExtension)==null?void 0:c.getChainId(),d=a.chains.find(m=>e.chainId?m.id===e.chainId:m.id===l)||a.chains[0],f=e.chainId||(d==null?void 0:d.id),h=e.jsonRpcUrl||(d==null?void 0:d.rpcUrls.default.http[0]);r=n.makeWeb3Provider(h,f)}return r},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({addEthereumChainParameter:c,chainId:u}){var f,h,m,y;const l=a.chains.find(w=>w.id===u);if(!l)throw new Ar(new Sa);const d=await this.getProvider();try{return await d.request({method:"wallet_switchEthereumChain",params:[{chainId:ae(l.id)}]}),l}catch(w){if(w.code===4902)try{let b;c!=null&&c.blockExplorerUrls?b=c.blockExplorerUrls:b=(f=l.blockExplorers)!=null&&f.default.url?[(h=l.blockExplorers)==null?void 0:h.default.url]:[];let E;(m=c==null?void 0:c.rpcUrls)!=null&&m.length?E=c.rpcUrls:E=[((y=l.rpcUrls.default)==null?void 0:y.http[0])??""];const v={blockExplorerUrls:b,chainId:ae(u),chainName:(c==null?void 0:c.chainName)??l.name,iconUrls:c==null?void 0:c.iconUrls,nativeCurrency:(c==null?void 0:c.nativeCurrency)??l.nativeCurrency,rpcUrls:E};return await d.request({method:"wallet_addEthereumChain",params:[v]}),l}catch(b){throw new Wt(b)}throw new Ar(w)}},onAccountsChanged(c){c.length===0?this.onDisconnect():a.emitter.emit("change",{accounts:c.map(u=>gn(u))})},onChainChanged(c){const u=Number(c);a.emitter.emit("change",{chainId:u})},async onDisconnect(c){a.emitter.emit("disconnect");const u=await this.getProvider();i&&(u.removeListener("accountsChanged",i),i=void 0),s&&(u.removeListener("chainChanged",s),s=void 0),o&&(u.removeListener("disconnect",o),o=void 0)}})}var ug={exports:{}},lg,r5;function wN(){if(r5)return lg;r5=1;var e=1e3,t=e*60,n=t*60,r=n*24,i=r*7,s=r*365.25;lg=function(l,d){d=d||{};var f=typeof l;if(f==="string"&&l.length>0)return o(l);if(f==="number"&&isFinite(l))return d.long?c(l):a(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function o(l){if(l=String(l),!(l.length>100)){var d=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(d){var f=parseFloat(d[1]),h=(d[2]||"ms").toLowerCase();switch(h){case"years":case"year":case"yrs":case"yr":case"y":return f*s;case"weeks":case"week":case"w":return f*i;case"days":case"day":case"d":return f*r;case"hours":case"hour":case"hrs":case"hr":case"h":return f*n;case"minutes":case"minute":case"mins":case"min":case"m":return f*t;case"seconds":case"second":case"secs":case"sec":case"s":return f*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return f;default:return}}}}function a(l){var d=Math.abs(l);return d>=r?Math.round(l/r)+"d":d>=n?Math.round(l/n)+"h":d>=t?Math.round(l/t)+"m":d>=e?Math.round(l/e)+"s":l+"ms"}function c(l){var d=Math.abs(l);return d>=r?u(l,d,r,"day"):d>=n?u(l,d,n,"hour"):d>=t?u(l,d,t,"minute"):d>=e?u(l,d,e,"second"):l+" ms"}function u(l,d,f,h){var m=d>=f*1.5;return Math.round(l/f)+" "+h+(m?"s":"")}return lg}function vN(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=a,n.humanize=wN(),n.destroy=u,Object.keys(e).forEach(l=>{n[l]=e[l]}),n.names=[],n.skips=[],n.formatters={};function t(l){let d=0;for(let f=0;f<l.length;f++)d=(d<<5)-d+l.charCodeAt(f),d|=0;return n.colors[Math.abs(d)%n.colors.length]}n.selectColor=t;function n(l){let d,f=null,h,m;function y(...w){if(!y.enabled)return;const b=y,E=Number(new Date),v=E-(d||E);b.diff=v,b.prev=d,b.curr=E,d=E,w[0]=n.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let A=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(M,L)=>{if(M==="%%")return"%";A++;const U=n.formatters[L];if(typeof U=="function"){const j=w[A];M=U.call(b,j),w.splice(A,1),A--}return M}),n.formatArgs.call(b,w),(b.log||n.log).apply(b,w)}return y.namespace=l,y.useColors=n.useColors(),y.color=n.selectColor(l),y.extend=r,y.destroy=n.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(h!==n.namespaces&&(h=n.namespaces,m=n.enabled(l)),m),set:w=>{f=w}}),typeof n.init=="function"&&n.init(y),y}function r(l,d){const f=n(this.namespace+(typeof d>"u"?":":d)+l);return f.log=this.log,f}function i(l){n.save(l),n.namespaces=l,n.names=[],n.skips=[];const d=(typeof l=="string"?l:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const f of d)f[0]==="-"?n.skips.push(f.slice(1)):n.names.push(f)}function s(l,d){let f=0,h=0,m=-1,y=0;for(;f<l.length;)if(h<d.length&&(d[h]===l[f]||d[h]==="*"))d[h]==="*"?(m=h,y=f,h++):(f++,h++);else if(m!==-1)h=m+1,y++,f=y;else return!1;for(;h<d.length&&d[h]==="*";)h++;return h===d.length}function o(){const l=[...n.names,...n.skips.map(d=>"-"+d)].join(",");return n.enable(""),l}function a(l){for(const d of n.skips)if(s(l,d))return!1;for(const d of n.names)if(s(l,d))return!0;return!1}function c(l){return l instanceof Error?l.stack||l.message:l}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}var _N=vN;(function(e,t){t.formatArgs=r,t.save=i,t.load=s,t.useColors=n,t.storage=o(),t.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let c;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(c=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(c[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const u="color: "+this.color;c.splice(1,0,u,"color: inherit");let l=0,d=0;c[0].replace(/%[a-zA-Z%]/g,f=>{f!=="%%"&&(l++,f==="%c"&&(d=l))}),c.splice(d,0,u)}t.log=console.debug||console.log||(()=>{});function i(c){try{c?t.storage.setItem("debug",c):t.storage.removeItem("debug")}catch{}}function s(){let c;try{c=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c}function o(){try{return localStorage}catch{}}e.exports=_N(t);const{formatters:a}=e.exports;a.j=function(c){try{return JSON.stringify(c)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}})(ug,ug.exports);var EN=ug.exports,dg={exports:{}};const xN="2.0.0",i5=256,SN=Number.MAX_SAFE_INTEGER||9007199254740991,kN=16,AN=i5-6;var nf={MAX_LENGTH:i5,MAX_SAFE_COMPONENT_LENGTH:kN,MAX_SAFE_BUILD_LENGTH:AN,MAX_SAFE_INTEGER:SN,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:xN,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},rf=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};(function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=nf,s=rf;t=e.exports={};const o=t.re=[],a=t.safeRe=[],c=t.src=[],u=t.safeSrc=[],l=t.t={};let d=0;const f="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",i],[f,r]],m=w=>{for(const[b,E]of h)w=w.split(`${b}*`).join(`${b}{0,${E}}`).split(`${b}+`).join(`${b}{1,${E}}`);return w},y=(w,b,E)=>{const v=m(b),A=d++;s(w,A,b),l[w]=A,c[A]=b,u[A]=v,o[A]=new RegExp(b,E?"g":void 0),a[A]=new RegExp(v,E?"g":void 0)};y("NUMERICIDENTIFIER","0|[1-9]\\d*"),y("NUMERICIDENTIFIERLOOSE","\\d+"),y("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`),y("MAINVERSION",`(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})`),y("MAINVERSIONLOOSE",`(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})`),y("PRERELEASEIDENTIFIER",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIER]})`),y("PRERELEASEIDENTIFIERLOOSE",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIERLOOSE]})`),y("PRERELEASE",`(?:-(${c[l.PRERELEASEIDENTIFIER]}(?:\\.${c[l.PRERELEASEIDENTIFIER]})*))`),y("PRERELEASELOOSE",`(?:-?(${c[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[l.PRERELEASEIDENTIFIERLOOSE]})*))`),y("BUILDIDENTIFIER",`${f}+`),y("BUILD",`(?:\\+(${c[l.BUILDIDENTIFIER]}(?:\\.${c[l.BUILDIDENTIFIER]})*))`),y("FULLPLAIN",`v?${c[l.MAINVERSION]}${c[l.PRERELEASE]}?${c[l.BUILD]}?`),y("FULL",`^${c[l.FULLPLAIN]}$`),y("LOOSEPLAIN",`[v=\\s]*${c[l.MAINVERSIONLOOSE]}${c[l.PRERELEASELOOSE]}?${c[l.BUILD]}?`),y("LOOSE",`^${c[l.LOOSEPLAIN]}$`),y("GTLT","((?:<|>)?=?)"),y("XRANGEIDENTIFIERLOOSE",`${c[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),y("XRANGEIDENTIFIER",`${c[l.NUMERICIDENTIFIER]}|x|X|\\*`),y("XRANGEPLAIN",`[v=\\s]*(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:${c[l.PRERELEASE]})?${c[l.BUILD]}?)?)?`),y("XRANGEPLAINLOOSE",`[v=\\s]*(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:${c[l.PRERELEASELOOSE]})?${c[l.BUILD]}?)?)?`),y("XRANGE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAIN]}$`),y("XRANGELOOSE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAINLOOSE]}$`),y("COERCEPLAIN",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),y("COERCE",`${c[l.COERCEPLAIN]}(?:$|[^\\d])`),y("COERCEFULL",c[l.COERCEPLAIN]+`(?:${c[l.PRERELEASE]})?(?:${c[l.BUILD]})?(?:$|[^\\d])`),y("COERCERTL",c[l.COERCE],!0),y("COERCERTLFULL",c[l.COERCEFULL],!0),y("LONETILDE","(?:~>?)"),y("TILDETRIM",`(\\s*)${c[l.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",y("TILDE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAIN]}$`),y("TILDELOOSE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAINLOOSE]}$`),y("LONECARET","(?:\\^)"),y("CARETTRIM",`(\\s*)${c[l.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",y("CARET",`^${c[l.LONECARET]}${c[l.XRANGEPLAIN]}$`),y("CARETLOOSE",`^${c[l.LONECARET]}${c[l.XRANGEPLAINLOOSE]}$`),y("COMPARATORLOOSE",`^${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]})$|^$`),y("COMPARATOR",`^${c[l.GTLT]}\\s*(${c[l.FULLPLAIN]})$|^$`),y("COMPARATORTRIM",`(\\s*)${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]}|${c[l.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",y("HYPHENRANGE",`^\\s*(${c[l.XRANGEPLAIN]})\\s+-\\s+(${c[l.XRANGEPLAIN]})\\s*$`),y("HYPHENRANGELOOSE",`^\\s*(${c[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[l.XRANGEPLAINLOOSE]})\\s*$`),y("STAR","(<|>)?=?\\s*\\*"),y("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),y("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(dg,dg.exports);var Tu=dg.exports;const IN=Object.freeze({loose:!0}),CN=Object.freeze({});var fg=e=>e?typeof e!="object"?IN:e:CN;const s5=/^[0-9]+$/,o5=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e===t?0:e<t?-1:1;const n=s5.test(e),r=s5.test(t);return n&&r&&(e=+e,t=+t),e===t?0:n&&!r?-1:r&&!n?1:e<t?-1:1};var a5={compareIdentifiers:o5,rcompareIdentifiers:(e,t)=>o5(t,e)};const sf=rf,{MAX_LENGTH:c5,MAX_SAFE_INTEGER:of}=nf,{safeRe:af,t:cf}=Tu,PN=fg,{compareIdentifiers:hg}=a5;var Ou=class pi{constructor(t,n){if(n=PN(n),t instanceof pi){if(t.loose===!!n.loose&&t.includePrerelease===!!n.includePrerelease)return t;t=t.version}else if(typeof t!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>c5)throw new TypeError(`version is longer than ${c5} characters`);sf("SemVer",t,n),this.options=n,this.loose=!!n.loose,this.includePrerelease=!!n.includePrerelease;const r=t.trim().match(n.loose?af[cf.LOOSE]:af[cf.FULL]);if(!r)throw new TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>of||this.major<0)throw new TypeError("Invalid major version");if(this.minor>of||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>of||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){const s=+i;if(s>=0&&s<of)return s}return i}):this.prerelease=[],this.build=r[5]?r[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(sf("SemVer.compare",this.version,this.options,t),!(t instanceof pi)){if(typeof t=="string"&&t===this.version)return 0;t=new pi(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof pi||(t=new pi(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:this.patch>t.patch?1:0}comparePre(t){if(t instanceof pi||(t=new pi(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let n=0;do{const r=this.prerelease[n],i=t.prerelease[n];if(sf("prerelease compare",n,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;return hg(r,i)}while(++n)}compareBuild(t){t instanceof pi||(t=new pi(t,this.options));let n=0;do{const r=this.build[n],i=t.build[n];if(sf("build compare",n,r,i),r===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(r===void 0)return-1;if(r===i)continue;return hg(r,i)}while(++n)}inc(t,n,r){if(t.startsWith("pre")){if(!n&&r===!1)throw new Error("invalid increment argument: identifier is empty");if(n){const i=`-${n}`.match(this.options.loose?af[cf.PRERELEASELOOSE]:af[cf.PRERELEASE]);if(!i||i[1]!==n)throw new Error(`invalid identifier: ${n}`)}}switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",n,r);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",n,r);break;case"prepatch":this.prerelease.length=0,this.inc("patch",n,r),this.inc("pre",n,r);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",n,r),this.inc("pre",n,r);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const i=Number(r)?1:0;if(this.prerelease.length===0)this.prerelease=[i];else{let s=this.prerelease.length;for(;--s>=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);if(s===-1){if(n===this.prerelease.join(".")&&r===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(n){let s=[n,i];r===!1&&(s=[n]),hg(this.prerelease[0],n)===0?isNaN(this.prerelease[1])&&(this.prerelease=s):this.prerelease=s}break}default:throw new Error(`invalid increment argument: ${t}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};const u5=Ou;var RN=(e,t,n=!1)=>{if(e instanceof u5)return e;try{return new u5(e,t)}catch(r){if(!n)return null;throw r}};const TN=RN;var ON=(e,t)=>{const n=TN(e,t);return n?n.version:null};const l5=Ou;var Ia=(e,t,n)=>new l5(e,n).compare(new l5(t,n));const MN=Ia;var pg=(e,t,n)=>MN(e,t,n)>0;const BN=Ia;var d5=(e,t,n)=>BN(e,t,n)<0;const NN=Ia;var LN=(e,t,n)=>NN(e,t,n)===0;const jN=Ia;var $N=(e,t,n)=>jN(e,t,n)!==0;const FN=Ia;var f5=(e,t,n)=>FN(e,t,n)>=0;const DN=Ia;var h5=(e,t,n)=>DN(e,t,n)<=0;const UN=LN,HN=$N,zN=pg,WN=f5,GN=d5,qN=h5;var VN=(e,t,n,r)=>{switch(t){case"===":return typeof e=="object"&&(e=e.version),typeof n=="object"&&(n=n.version),e===n;case"!==":return typeof e=="object"&&(e=e.version),typeof n=="object"&&(n=n.version),e!==n;case"":case"=":case"==":return UN(e,n,r);case"!=":return HN(e,n,r);case">":return zN(e,n,r);case">=":return WN(e,n,r);case"<":return GN(e,n,r);case"<=":return qN(e,n,r);default:throw new TypeError(`Invalid operator: ${t}`)}};const{safeRe:CQ,t:PQ}=Tu;class KN{constructor(){this.max=1e3,this.map=new Map}get(t){const n=this.map.get(t);if(n!==void 0)return this.map.delete(t),this.map.set(t,n),n}delete(t){return this.map.delete(t)}set(t,n){if(!this.delete(t)&&n!==void 0){if(this.map.size>=this.max){const i=this.map.keys().next().value;this.delete(i)}this.map.set(t,n)}return this}}var JN=KN,mg,p5;function Mr(){if(p5)return mg;p5=1;const e=/\s+/g;class t{constructor(g,S){if(S=i(S),g instanceof t)return g.loose===!!S.loose&&g.includePrerelease===!!S.includePrerelease?g:new t(g.raw,S);if(g instanceof s)return this.raw=g.value,this.set=[[g]],this.formatted=void 0,this;if(this.options=S,this.loose=!!S.loose,this.includePrerelease=!!S.includePrerelease,this.raw=g.trim().replace(e," "),this.set=this.raw.split("||").map(R=>this.parseRange(R.trim())).filter(R=>R.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const R=this.set[0];if(this.set=this.set.filter(T=>!y(T[0])),this.set.length===0)this.set=[R];else if(this.set.length>1){for(const T of this.set)if(T.length===1&&w(T[0])){this.set=[T];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let g=0;g<this.set.length;g++){g>0&&(this.formatted+="||");const S=this.set[g];for(let R=0;R<S.length;R++)R>0&&(this.formatted+=" "),this.formatted+=S[R].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(g){const R=((this.options.includePrerelease&&h)|(this.options.loose&&m))+":"+g,T=r.get(R);if(T)return T;const B=this.options.loose,$=B?c[u.HYPHENRANGELOOSE]:c[u.HYPHENRANGE];g=g.replace($,W(this.options.includePrerelease)),o("hyphen replace",g),g=g.replace(c[u.COMPARATORTRIM],l),o("comparator trim",g),g=g.replace(c[u.TILDETRIM],d),o("tilde trim",g),g=g.replace(c[u.CARETTRIM],f),o("caret trim",g);let O=g.split(" ").map(ne=>E(ne,this.options)).join(" ").split(/\s+/).map(ne=>Y(ne,this.options));B&&(O=O.filter(ne=>(o("loose invalid filter",ne,this.options),!!ne.match(c[u.COMPARATORLOOSE])))),o("range list",O);const _=new Map,D=O.map(ne=>new s(ne,this.options));for(const ne of D){if(y(ne))return[ne];_.set(ne.value,ne)}_.size>1&&_.has("")&&_.delete("");const ue=[..._.values()];return r.set(R,ue),ue}intersects(g,S){if(!(g instanceof t))throw new TypeError("a Range is required");return this.set.some(R=>b(R,S)&&g.set.some(T=>b(T,S)&&R.every(B=>T.every($=>B.intersects($,S)))))}test(g){if(!g)return!1;if(typeof g=="string")try{g=new a(g,this.options)}catch{return!1}for(let S=0;S<this.set.length;S++)if(I(this.set[S],g,this.options))return!0;return!1}}mg=t;const n=JN,r=new n,i=fg,s=uf(),o=rf,a=Ou,{safeRe:c,t:u,comparatorTrimReplace:l,tildeTrimReplace:d,caretTrimReplace:f}=Tu,{FLAG_INCLUDE_PRERELEASE:h,FLAG_LOOSE:m}=nf,y=p=>p.value==="<0.0.0-0",w=p=>p.value==="",b=(p,g)=>{let S=!0;const R=p.slice();let T=R.pop();for(;S&&R.length;)S=R.every(B=>T.intersects(B,g)),T=R.pop();return S},E=(p,g)=>(p=p.replace(c[u.BUILD],""),o("comp",p,g),p=M(p,g),o("caret",p),p=A(p,g),o("tildes",p),p=U(p,g),o("xrange",p),p=Z(p,g),o("stars",p),p),v=p=>!p||p.toLowerCase()==="x"||p==="*",A=(p,g)=>p.trim().split(/\s+/).map(S=>P(S,g)).join(" "),P=(p,g)=>{const S=g.loose?c[u.TILDELOOSE]:c[u.TILDE];return p.replace(S,(R,T,B,$,O)=>{o("tilde",p,R,T,B,$,O);let _;return v(T)?_="":v(B)?_=`>=${T}.0.0 <${+T+1}.0.0-0`:v($)?_=`>=${T}.${B}.0 <${T}.${+B+1}.0-0`:O?(o("replaceTilde pr",O),_=`>=${T}.${B}.${$}-${O} <${T}.${+B+1}.0-0`):_=`>=${T}.${B}.${$} <${T}.${+B+1}.0-0`,o("tilde return",_),_})},M=(p,g)=>p.trim().split(/\s+/).map(S=>L(S,g)).join(" "),L=(p,g)=>{o("caret",p,g);const S=g.loose?c[u.CARETLOOSE]:c[u.CARET],R=g.includePrerelease?"-0":"";return p.replace(S,(T,B,$,O,_)=>{o("caret",p,T,B,$,O,_);let D;return v(B)?D="":v($)?D=`>=${B}.0.0${R} <${+B+1}.0.0-0`:v(O)?B==="0"?D=`>=${B}.${$}.0${R} <${B}.${+$+1}.0-0`:D=`>=${B}.${$}.0${R} <${+B+1}.0.0-0`:_?(o("replaceCaret pr",_),B==="0"?$==="0"?D=`>=${B}.${$}.${O}-${_} <${B}.${$}.${+O+1}-0`:D=`>=${B}.${$}.${O}-${_} <${B}.${+$+1}.0-0`:D=`>=${B}.${$}.${O}-${_} <${+B+1}.0.0-0`):(o("no pr"),B==="0"?$==="0"?D=`>=${B}.${$}.${O}${R} <${B}.${$}.${+O+1}-0`:D=`>=${B}.${$}.${O}${R} <${B}.${+$+1}.0-0`:D=`>=${B}.${$}.${O} <${+B+1}.0.0-0`),o("caret return",D),D})},U=(p,g)=>(o("replaceXRanges",p,g),p.split(/\s+/).map(S=>j(S,g)).join(" ")),j=(p,g)=>{p=p.trim();const S=g.loose?c[u.XRANGELOOSE]:c[u.XRANGE];return p.replace(S,(R,T,B,$,O,_)=>{o("xRange",p,R,T,B,$,O,_);const D=v(B),ue=D||v($),ne=ue||v(O),G=ne;return T==="="&&G&&(T=""),_=g.includePrerelease?"-0":"",D?T===">"||T==="<"?R="<0.0.0-0":R="*":T&&G?(ue&&($=0),O=0,T===">"?(T=">=",ue?(B=+B+1,$=0,O=0):($=+$+1,O=0)):T==="<="&&(T="<",ue?B=+B+1:$=+$+1),T==="<"&&(_="-0"),R=`${T+B}.${$}.${O}${_}`):ue?R=`>=${B}.0.0${_} <${+B+1}.0.0-0`:ne&&(R=`>=${B}.${$}.0${_} <${B}.${+$+1}.0-0`),o("xRange return",R),R})},Z=(p,g)=>(o("replaceStars",p,g),p.trim().replace(c[u.STAR],"")),Y=(p,g)=>(o("replaceGTE0",p,g),p.trim().replace(c[g.includePrerelease?u.GTE0PRE:u.GTE0],"")),W=p=>(g,S,R,T,B,$,O,_,D,ue,ne,G)=>(v(R)?S="":v(T)?S=`>=${R}.0.0${p?"-0":""}`:v(B)?S=`>=${R}.${T}.0${p?"-0":""}`:$?S=`>=${S}`:S=`>=${S}${p?"-0":""}`,v(D)?_="":v(ue)?_=`<${+D+1}.0.0-0`:v(ne)?_=`<${D}.${+ue+1}.0-0`:G?_=`<=${D}.${ue}.${ne}-${G}`:p?_=`<${D}.${ue}.${+ne+1}-0`:_=`<=${_}`,`${S} ${_}`.trim()),I=(p,g,S)=>{for(let R=0;R<p.length;R++)if(!p[R].test(g))return!1;if(g.prerelease.length&&!S.includePrerelease){for(let R=0;R<p.length;R++)if(o(p[R].semver),p[R].semver!==s.ANY&&p[R].semver.prerelease.length>0){const T=p[R].semver;if(T.major===g.major&&T.minor===g.minor&&T.patch===g.patch)return!0}return!1}return!0};return mg}var gg,m5;function uf(){if(m5)return gg;m5=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(l,d){if(d=n(d),l instanceof t){if(l.loose===!!d.loose)return l;l=l.value}l=l.trim().split(/\s+/).join(" "),o("comparator",l,d),this.options=d,this.loose=!!d.loose,this.parse(l),this.semver===e?this.value="":this.value=this.operator+this.semver.version,o("comp",this)}parse(l){const d=this.options.loose?r[i.COMPARATORLOOSE]:r[i.COMPARATOR],f=l.match(d);if(!f)throw new TypeError(`Invalid comparator: ${l}`);this.operator=f[1]!==void 0?f[1]:"",this.operator==="="&&(this.operator=""),f[2]?this.semver=new a(f[2],this.options.loose):this.semver=e}toString(){return this.value}test(l){if(o("Comparator.test",l,this.options.loose),this.semver===e||l===e)return!0;if(typeof l=="string")try{l=new a(l,this.options)}catch{return!1}return s(l,this.operator,this.semver,this.options)}intersects(l,d){if(!(l instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(l.value,d).test(this.value):l.operator===""?l.value===""?!0:new c(this.value,d).test(l.semver):(d=n(d),d.includePrerelease&&(this.value==="<0.0.0-0"||l.value==="<0.0.0-0")||!d.includePrerelease&&(this.value.startsWith("<0.0.0")||l.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&l.operator.startsWith(">")||this.operator.startsWith("<")&&l.operator.startsWith("<")||this.semver.version===l.semver.version&&this.operator.includes("=")&&l.operator.includes("=")||s(this.semver,"<",l.semver,d)&&this.operator.startsWith(">")&&l.operator.startsWith("<")||s(this.semver,">",l.semver,d)&&this.operator.startsWith("<")&&l.operator.startsWith(">")))}}gg=t;const n=fg,{safeRe:r,t:i}=Tu,s=VN,o=rf,a=Ou,c=Mr();return gg}const ZN=Mr();var g5=(e,t,n)=>{try{t=new ZN(t,n)}catch{return!1}return t.test(e)};Mr(),Mr(),Mr(),Mr();const YN=Mr();var QN=(e,t)=>{try{return new YN(e,t).range||"*"}catch{return null}};const XN=Ou,y5=uf(),{ANY:eL}=y5,tL=Mr(),nL=g5,b5=pg,w5=d5,rL=h5,iL=f5;var sL=(e,t,n,r)=>{e=new XN(e,r),t=new tL(t,r);let i,s,o,a,c;switch(n){case">":i=b5,s=rL,o=w5,a=">",c=">=";break;case"<":i=w5,s=iL,o=b5,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(nL(e,t,r))return!1;for(let u=0;u<t.set.length;++u){const l=t.set[u];let d=null,f=null;if(l.forEach(h=>{h.semver===eL&&(h=new y5(">=0.0.0")),d=d||h,f=f||h,i(h.semver,d.semver,r)?d=h:o(h.semver,f.semver,r)&&(f=h)}),d.operator===a||d.operator===c||(!f.operator||f.operator===a)&&s(e,f.semver))return!1;if(f.operator===c&&o(e,f.semver))return!1}return!0};const oL=sL;var aL=(e,t,n)=>oL(e,t,">",n);Mr(),Mr();const yg=uf(),{ANY:BQ}=yg;new yg(">=0.0.0-0"),new yg(">=0.0.0");const bg=Tu,v5=nf,_5=a5,cL=ON,uL=pg;uf(),Mr();var lL={valid:cL,gt:uL,satisfies:g5,validRange:QN,gtr:aL,re:bg.re,src:bg.src,tokens:bg.t,SEMVER_SPEC_VERSION:v5.SEMVER_SPEC_VERSION,RELEASE_TYPES:v5.RELEASE_TYPES,compareIdentifiers:_5.compareIdentifiers,rcompareIdentifiers:_5.rcompareIdentifiers},dL=Mu;Mu.default=Mu,Mu.stable=S5,Mu.stableStringify=S5;var lf="[...]",E5="[Circular]",oo=[],ao=[];function x5(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Mu(e,t,n,r){typeof r>"u"&&(r=x5()),wg(e,"",0,[],void 0,0,r);var i;try{ao.length===0?i=JSON.stringify(e,t,n):i=JSON.stringify(e,k5(t),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;oo.length!==0;){var s=oo.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function Ca(e,t,n,r){var i=Object.getOwnPropertyDescriptor(r,n);i.get!==void 0?i.configurable?(Object.defineProperty(r,n,{value:e}),oo.push([r,n,t,i])):ao.push([t,n,e]):(r[n]=e,oo.push([r,n,t]))}function wg(e,t,n,r,i,s,o){s+=1;var a;if(typeof e=="object"&&e!==null){for(a=0;a<r.length;a++)if(r[a]===e){Ca(E5,e,t,i);return}if(typeof o.depthLimit<"u"&&s>o.depthLimit){Ca(lf,e,t,i);return}if(typeof o.edgesLimit<"u"&&n+1>o.edgesLimit){Ca(lf,e,t,i);return}if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)wg(e[a],a,a,r,e,s,o);else{var c=Object.keys(e);for(a=0;a<c.length;a++){var u=c[a];wg(e[u],u,a,r,e,s,o)}}r.pop()}}function fL(e,t){return e<t?-1:e>t?1:0}function S5(e,t,n,r){typeof r>"u"&&(r=x5());var i=vg(e,"",0,[],void 0,0,r)||e,s;try{ao.length===0?s=JSON.stringify(i,t,n):s=JSON.stringify(i,k5(t),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;oo.length!==0;){var o=oo.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return s}function vg(e,t,n,r,i,s,o){s+=1;var a;if(typeof e=="object"&&e!==null){for(a=0;a<r.length;a++)if(r[a]===e){Ca(E5,e,t,i);return}try{if(typeof e.toJSON=="function")return}catch{return}if(typeof o.depthLimit<"u"&&s>o.depthLimit){Ca(lf,e,t,i);return}if(typeof o.edgesLimit<"u"&&n+1>o.edgesLimit){Ca(lf,e,t,i);return}if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)vg(e[a],a,a,r,e,s,o);else{var c={},u=Object.keys(e).sort(fL);for(a=0;a<u.length;a++){var l=u[a];vg(e[l],l,a,r,e,s,o),c[l]=e[l]}if(typeof i<"u")oo.push([i,t,e]),i[t]=c;else return c}r.pop()}}function k5(e){return e=typeof e<"u"?e:function(t,n){return n},function(t,n){if(ao.length>0)for(var r=0;r<ao.length;r++){var i=ao[r];if(i[1]===t&&i[0]===n){n=i[2],ao.splice(r,1);break}}return e.call(this,t,n)}}const hL={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},pL={block:jT({format(e){var n;return{transactions:(n=e.transactions)==null?void 0:n.map(r=>{if(typeof r=="string")return r;const i=Eu(r);return i.typeHex==="0x7e"&&(i.isSystemTx=r.isSystemTx,i.mint=r.mint?Rt(r.mint):void 0,i.sourceHash=r.sourceHash,i.type="deposit"),i}),stateRoot:e.stateRoot}}}),transaction:NT({format(e){const t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Rt(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:UO({format(e){return{l1GasPrice:e.l1GasPrice?Rt(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Rt(e.l1GasUsed):null,l1Fee:e.l1Fee?Rt(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};function mL(e,t){return bL(e)?yL(e):xO(e,t)}const gL={transaction:mL};function yL(e){wL(e);const{sourceHash:t,data:n,from:r,gas:i,isSystemTx:s,mint:o,to:a,value:c}=e,u=[t,r,a??"0x",o?tn(o):"0x",c?tn(c):"0x",i?tn(i):"0x",s?"0x1":"0x",n??"0x"];return zn(["0x7e",is(u)])}function bL(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function wL(e){const{from:t,to:n}=e;if(t&&!Ot(t))throw new xn({address:t});if(n&&!Ot(n))throw new xn({address:n})}const df={blockTime:2e3,contracts:hL,formatters:pL,serializers:gL},A5=ls({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}}}),Bu=1,_g=ls({...df,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:{...df.contracts,disputeGameFactory:{[Bu]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[Bu]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[Bu]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[Bu]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:Bu});({..._g});const I5=ls({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}}}),C5=ls({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}}}),Nu=1,P5=ls({...df,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:{...df.contracts,disputeGameFactory:{[Nu]:{address:"0xe5965Ab5962eDc7477C8520243A95517CD252fA9"}},l2OutputOracle:{[Nu]:{address:"0xdfe97868233d1aa22e815a266982f2cf17685a27"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:4286263},portal:{[Nu]:{address:"0xbEb5Fc579115071764c7423A4f12eDde41f106Ed"}},l1StandardBridge:{[Nu]:{address:"0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"}}},sourceId:Nu}),R5=ls({id:137,name:"Polygon",blockTime:2e3,nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon.drpc.org"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://polygonscan.com",apiUrl:"https://api.etherscan.io/v2/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:25770160}}}),T5=QB({chains:[_g,C5,A5,P5,R5,I5],transports:{[_g.id]:fs(),[C5.id]:fs("https://ethereum-rpc.publicnode.com"),[A5.id]:fs(),[P5.id]:fs(),[R5.id]:fs(),[I5.id]:fs()},connectors:[qd(),tf({appName:"Weave Checkout"})]}),vL=new Set([8453,1,10,42161,137,56]),O5={8453:"BASE",1:"ETHEREUM",10:"OPTIMISM",42161:"ARBITRUM",137:"POLYGON",56:"BSC"},Eg={8453:"Base",1:"Ethereum",10:"Optimism",42161:"Arbitrum",137:"Polygon",56:"BNB Chain"},M5={8453:"#1C4FE0",1:"#627EEA",10:"#FF3F57",42161:"#12AAFF",137:"#8247E5",56:"#F3BA2F"},B5={8453:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",1:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",10:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",42161:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",137:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",56:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},N5={1:"0xdAC17F958D2ee523a2206206994597C13D831ec7",10:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",42161:"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",137:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",56:"0x55d398326f99059fF775485246999027B3197955"};function _L(){return typeof window<"u"&&window.__WEAVE_API_BASE__?window.__WEAVE_API_BASE__:"http://localhost:4000/api/v1"}async function ff(e,t,n,r=15e3){const i=_L(),s={"Content-Type":"application/json","x-api-key":t,...n==null?void 0:n.headers},o=new AbortController,a=setTimeout(()=>o.abort(),r);try{const c=await fetch(`${i}${e}`,{...n,headers:s,signal:o.signal});if(c.status===204)return null;const u=await c.json();if(!u.success)throw new Error(u.error??"API error");return u.data}catch(c){throw(c==null?void 0:c.name)==="AbortError"?new Error("Request timed out — please check your connection"):c}finally{clearTimeout(a)}}const co=e=>`fiat:${e.toUpperCase()}`,hf=(e,t)=>`crypto:${e.toUpperCase()}:${t.toUpperCase()}`;async function Lu(e,t){const n=new URLSearchParams({from:t.from,to:t.to,amount:String(t.amount),...t.amountIn?{amountIn:t.amountIn}:{}});return ff(`/quotes?${n}`,e)}async function xg(e,t){return ff("/orders",e,{method:"POST",body:JSON.stringify(t)})}async function ju(e,t){return ff(`/orders/${t}`,e)}async function EL(e){return ff("/assets",e)}const xL=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],SL=Tw,kL=t7,AL=K7,pf={forest:"#3D6B50",tan:"#B8935A",ink:"#1C1B17"},K={ink:"var(--weave-ink, #0B0F0E)",ink2:"var(--weave-ink2, #3A4240)",mute:"var(--weave-mute, #6B7572)",hair:"var(--weave-hair, #E8EAE6)",surface:"var(--weave-surface, #FFFFFF)",page:"var(--weave-page, #F5F4EF)",panel:"var(--weave-panel, #FAFAF7)",accent:"var(--weave-accent, #0F5D4C)",accentSoft:"var(--weave-accent-soft, #E6F0EC)",good:"var(--weave-good, #1F7A4D)",goodSoft:"var(--weave-good-soft, #E6F3EC)",warn:"var(--weave-warn, #A46A00)",warnSoft:"var(--weave-warn-soft, #FBF0DC)",err:"var(--weave-err, #A8321E)"},Ti=L0.reduce((e,t)=>{const n=t.key.split(":").pop();return e[n]={name:t.name,symbol:t.symbol,flag:t.flag,rate:t.rate,min:t.min,country:t.country,psp:"GTBank",bank:"GTBank ••7890",method:"Bank transfer"},e},{}),mf=[{token:"ETH",chain:"Optimism",amount:.312,usd:1024.4,icon:"Ξ",chainTint:"#ff3f57",logo:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png"},{token:"USDC",chain:"Base",amount:150,usd:150,icon:"$",chainTint:"#1C4FE0",logo:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png"},{token:"STRK",chain:"Starknet",amount:840,usd:184.8,icon:"S",chainTint:"#EC796B",logo:"https://assets.coingecko.com/coins/images/35293/standard/starknet.png"},{token:"DAI",chain:"Ethereum",amount:502,usd:502,icon:"D",chainTint:"#F5AC37",logo:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0x6B175474E89094C44Da98b954EedeAC495271d0F/logo.png"}],IL=(e,t,n)=>{const r=Ti[t],s=!!r?0:4,o=Number.isInteger(e)?0:s,a=Math.pow(10,o),c=o>0?Math.ceil(e*a)/a:Math.ceil(e),u=new Intl.NumberFormat("en-US",{minimumFractionDigits:o,maximumFractionDigits:o}).format(c);return`${r.symbol}${u}`},$u=(e,t=4)=>{const n=Math.pow(10,t);return(Math.ceil(e*n)/n).toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})},CL=async(e,t,n,r)=>{const i=document.createElement("canvas"),s=i.getContext("2d");if(!s)return;const o=pf[r]||r||"#0F5D4C",a=800,c=1100;i.width=a,i.height=c,s.fillStyle="#FDFDFB",s.fillRect(0,0,a,c),s.strokeStyle="#E8EAE6",s.lineWidth=2,s.strokeRect(40,40,a-80,c-80),s.fillStyle=o,s.font="700 32px Figtree, Inter, sans-serif",s.fillText("Weave",80,110),s.fillStyle="#6B7572",s.font="500 16px Inter, sans-serif",s.fillText("PAYMENT RECEIPT",a-240,105),s.fillStyle="#E6F0EC";const u=230,l=36;s.beginPath(),s.roundRect(80,160,u,l,8),s.fill(),s.fillStyle=o,s.font="700 12px Inter, sans-serif",s.textAlign="center",s.fillText("✓ TRANSACTION SUCCESSFUL",80+u/2,182),s.textAlign="left",s.fillStyle="#0B0F0E",s.font="700 72px Figtree, Inter, sans-serif";const d=IL(e.amount,e.currency);s.fillText(d,80,280),s.fillStyle="#6B7572",s.font="500 18px Inter, sans-serif",s.fillText("Total amount paid to "+e.name,80,315);const f=(w,b,E)=>{s.fillStyle="#6B7572",s.font="500 15px Inter, sans-serif",s.fillText(w,80,E),s.fillStyle="#0B0F0E",s.font="600 16px Inter, sans-serif",s.textAlign="right",s.fillText(b,a-80,E),s.textAlign="left",s.strokeStyle="#E8EAE6",s.lineWidth=1,s.beginPath(),s.moveTo(80,E+25),s.lineTo(a-80,E+25),s.stroke()},h=new Date((t==null?void 0:t.createdAt)||Date.now()).toLocaleDateString("en-US",{day:"numeric",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"});f("Payment Date",h,420),f("Transaction Ref",((t==null?void 0:t.id)||"N/A").toUpperCase(),490),f("Merchant",e.name,560),f("Payout Destination",n,630),f("Status","Completed",700),s.fillStyle="#F5F4EF",s.fillRect(80,800,a-160,120),s.fillStyle="#0B0F0E",s.font="600 16px Inter, sans-serif",s.fillText("Security Verification",110,845),s.fillStyle="#6B7572",s.font="400 14px Inter, sans-serif",s.fillText("This transaction was secured with 256-bit encryption by Paycrest.",110,875),s.fillText("You can verify this order directly on the Weave Dashboard.",110,895),s.textAlign="center",s.fillStyle="#0B0F0E",s.font="700 24px Figtree, Inter, sans-serif",s.fillText("Thank you for using Weave.",a/2,1020),s.fillStyle="#6B7572",s.font="400 12px Inter, sans-serif",s.fillText("Support: help@weave.com",a/2,1050);const m=i.toDataURL("image/png"),y=document.createElement("a");y.download=`weave-receipt-${((t==null?void 0:t.id)||"txn").slice(0,8)}.png`,y.href=m,y.click()};function ve({gap:e=12,children:t,style:n}){return C.jsx("div",{style:{display:"flex",flexDirection:"column",gap:e,...n},children:t})}function rn({gap:e=10,align:t="center",justify:n="flex-start",children:r,style:i}){return C.jsx("div",{style:{display:"flex",alignItems:t,justifyContent:n,gap:e,...i},children:r})}function Pa(){return C.jsx("div",{style:{height:1,background:K.hair,width:"100%"}})}function Fu({children:e,tone:t="neutral"}){const n={neutral:{bg:"#F1F0EB",fg:K.ink2},good:{bg:K.goodSoft,fg:K.good},accent:{bg:K.accentSoft,fg:K.accent},warn:{bg:K.warnSoft,fg:K.warn}}[t];return C.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:6,height:22,padding:"0 9px",borderRadius:999,background:n.bg,color:n.fg,fontSize:11.5,fontWeight:500,letterSpacing:.1},children:e})}function Ra({bg:e,children:t,size:n=32}){return C.jsx("div",{style:{width:n,height:n,borderRadius:n/2,background:e,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:n*.42,flexShrink:0,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:t})}function Sg({size:e=22}){return C.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[C.jsx("path",{d:"M3 5 L8 19 L12 9 L16 19 L21 5",stroke:K.accent,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),C.jsx("path",{d:"M5 9 L12 19 L19 9",stroke:K.ink,strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3"})]})}const L5={width:28,height:28,borderRadius:14,border:"none",cursor:"pointer",background:"transparent",color:K.mute,display:"flex",alignItems:"center",justifyContent:"center"},PL={...L5,color:K.ink};function RL({merchantName:e,onClose:t,showBack:n,onBack:r}){return C.jsxs("div",{style:{padding:"16px 20px 14px",display:"flex",alignItems:"center",gap:10,borderBottom:`1px solid ${K.hair}`},children:[n?C.jsx("button",{onClick:r,style:PL,children:C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M15 18L9 12L15 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}):C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx(Sg,{size:22}),C.jsx("span",{style:{fontWeight:600,fontSize:15,letterSpacing:-.2},children:"Weave"})]}),C.jsxs("div",{style:{flex:1,textAlign:"center",fontSize:12.5,color:K.mute},children:["Paying ",C.jsx("span",{style:{color:K.ink,fontWeight:500},children:e})]}),C.jsx("button",{onClick:t,style:L5,children:C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M6 6L18 18M6 18L18 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round"})})})]})}function TL(){return C.jsxs("div",{style:{padding:"12px 20px 14px",borderTop:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:K.mute,background:K.panel,borderRadius:"0 0 16px 16px"},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[C.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M12 2L3 6V12C3 17 6.5 21 12 22C17.5 21 21 17 21 12V6L12 2Z",stroke:"currentColor",strokeWidth:"1.8"})}),"Secured by Dewdrop Labs"]}),C.jsx("div",{style:{display:"flex",alignItems:"center",gap:10},children:C.jsx("span",{children:"xoxo ❤️"})})]})}const Du={width:"100%",padding:"12px 14px",borderRadius:12,border:`1px solid ${K.hair}`,background:"#fff",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:12,transition:"border-color 0.15s, background 0.15s, transform 0.1s"},OL={padding:"10px 12px",borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:8,transition:"border-color 0.15s, background 0.15s"},ps={width:"100%",height:46,borderRadius:10,border:"none",background:K.ink,color:"#fff",fontSize:14.5,fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:8,cursor:"pointer",fontFamily:"inherit",letterSpacing:-.1,transition:"transform 0.08s, background 0.2s"},kg={width:"100%",height:46,borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",color:K.ink,fontSize:14,fontWeight:500,display:"flex",alignItems:"center",gap:10,paddingLeft:14,paddingRight:14,cursor:"pointer",fontFamily:"inherit"};function ML({onPick:e,merchant:t,currencies:n,fmtCur:r,submitting:i,disabledMethods:s}){const o=n[t.currency]||Ti[t.currency],[a,c]=ce.useState(!1),[u,l]=ce.useState(null);ce.useEffect(()=>{i||l(null)},[i]);const d=f=>{i||u||(l(f),e(f))};return C.jsxs(ve,{gap:16,style:{padding:"22px 20px 6px"},children:[C.jsxs(ve,{gap:10,style:{alignItems:"center",padding:"4px 0 6px"},children:[C.jsx("div",{style:{width:44,height:44,borderRadius:10,background:pf[t.currency==="USDC"?"ink":"forest"]||"#2B1810",color:"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:18,fontFamily:"var(--weave-font-display, Georgia, serif)",boxShadow:"0 2px 8px rgba(0,0,0,0.12)"},children:(()=>{var h;const f=t.name.trim().split(/\s+/).filter(Boolean);return f.length>=2?(f[0][0]+f[1][0]).toUpperCase():((h=f[0])==null?void 0:h.slice(0,2).toUpperCase())??"?"})()}),C.jsxs(ve,{gap:3,style:{alignItems:"center"},children:[C.jsxs("div",{style:{fontSize:12.5,color:K.mute},children:["Pay ",t.name]}),C.jsx("div",{style:{fontSize:30,fontWeight:600,letterSpacing:-.6,color:K.ink},children:r(t.amount,t.currency)}),C.jsx("div",{style:{fontSize:11.5,color:K.mute},children:t.description||"Secure checkout"})]})]}),C.jsxs(ve,{gap:8,children:[C.jsx("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"How would you like to pay?"}),C.jsxs("button",{onClick:()=>!(s!=null&&s.fiat)&&d("fiat"),disabled:!!(i||u||s!=null&&s.fiat),title:s==null?void 0:s.fiat,style:{...Du,opacity:i||u||s!=null&&s.fiat?.7:1,cursor:i||u?"not-allowed":s!=null&&s.fiat?"help":"pointer",filter:s!=null&&s.fiat?"grayscale(1)":"none"},children:[C.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"#fff",border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:u==="fiat"?C.jsx("div",{style:{width:18,height:18,borderRadius:"50%",border:`2px solid ${K.hair}`,borderTopColor:K.accent,animation:"wspin 0.8s linear infinite"}}):C.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M3 21H21M5 21V10M9 21V10M15 21V10M19 21V10M2 10L12 3L22 10H2Z",stroke:K.ink,strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})}),C.jsxs(ve,{gap:2,style:{flex:1,textAlign:"left",minWidth:0},children:[C.jsx("div",{style:{fontSize:14,fontWeight:500,color:K.ink},children:u==="fiat"?"Setting up payment…":`Pay with ${(o==null?void 0:o.name)??t.currency}`}),C.jsx("div",{style:{fontSize:11.5,color:K.mute},children:(s==null?void 0:s.fiat)||"Card, bank transfer & USSD · Instant"})]}),u!=="fiat"&&!(s!=null&&s.fiat)&&C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{marginLeft:4,flexShrink:0},children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),C.jsxs("button",{onClick:()=>d("externalDeposit"),disabled:!!(i||u),style:{...Du,opacity:i||u?.7:1,cursor:i||u?"not-allowed":"pointer"},children:[C.jsx("div",{style:{width:40,height:40,borderRadius:10,background:"#fff",border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:C.jsx(Ra,{bg:"#F6851B",size:24,children:"🦊"})}),C.jsxs(ve,{gap:2,style:{flex:1,textAlign:"left",minWidth:0},children:[C.jsx("div",{style:{fontSize:14,fontWeight:500},children:"Pay with crypto"}),C.jsx("div",{style:{fontSize:11.5,color:K.mute},children:"Transfer from any chain, any token, any wallet."})]}),C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{marginLeft:4,flexShrink:0},children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),a?C.jsx(ve,{gap:6,style:{padding:"2px 0"},children:C.jsxs("button",{onClick:()=>d("deposit"),disabled:!!(i||u),style:{...OL,opacity:i||u?.7:1,cursor:i||u?"not-allowed":"pointer"},children:[C.jsx("div",{style:{width:20,height:20,borderRadius:5,background:K.panel,border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",children:[C.jsx("rect",{x:"3",y:"3",width:"7",height:"7",stroke:K.ink,strokeWidth:"2"}),C.jsx("rect",{x:"14",y:"3",width:"7",height:"7",stroke:K.ink,strokeWidth:"2"}),C.jsx("rect",{x:"3",y:"14",width:"7",height:"7",stroke:K.ink,strokeWidth:"2"})]})}),C.jsx("span",{style:{fontSize:12.5,fontWeight:500},children:"Pay from connected wallet"}),C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",style:{marginLeft:"auto"},children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})}):C.jsx("button",{onClick:()=>!u&&c(!0),style:{background:"transparent",border:"none",cursor:u?"not-allowed":"pointer",fontFamily:"inherit",fontSize:12,color:K.mute,padding:"4px 0",textAlign:"center",opacity:u?.5:1},children:"Connect your wallet ↓"})]})]})}function BL({onNext:e,merchant:t,balances:n,selected:r,setSelected:i,currencies:s}){var o;return C.jsxs(ve,{gap:14,style:{padding:"18px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Choose what you'd like to pay with"}),C.jsxs("div",{style:{fontSize:12.5,color:K.mute},children:["We found these balances in your wallet. Pick any — we'll convert to ",((o=s[t.currency])==null?void 0:o.name)??t.currency," for ",t.name,"."]})]}),C.jsx(ve,{gap:6,children:n.map((a,c)=>{const u=s[t.currency]||Ti[t.currency],l=a.usd>=t.amount/((u==null?void 0:u.rate)||1),d=r===c;return C.jsxs("button",{onClick:()=>l&&i(c),disabled:!l,style:{width:"100%",padding:"12px 14px",background:d?K.accentSoft:"#fff",border:`1.5px solid ${d?K.accent:K.hair}`,borderRadius:12,cursor:l?"pointer":"not-allowed",opacity:l?1:.48,display:"flex",alignItems:"center",gap:12,textAlign:"left",fontFamily:"inherit",transition:"all 0.15s"},children:[C.jsx(Ra,{bg:a.chainTint,size:36,children:a.logo?C.jsx("img",{src:a.logo,style:{width:"100%",height:"100%",borderRadius:"inherit",objectFit:"cover"}}):a.icon}),C.jsxs(ve,{gap:2,style:{flex:1},children:[C.jsxs("div",{style:{fontSize:14,fontWeight:500,color:K.ink},children:[$u(a.amount)," ",a.token]}),C.jsxs("div",{style:{fontSize:12,color:K.mute},children:["on ",a.chain," · ≈ $",a.usd.toFixed(2)]})]}),!l&&C.jsx(Fu,{tone:"warn",children:"Too low"}),l&&d&&C.jsx("div",{style:{width:20,height:20,borderRadius:10,background:K.accent,display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})})})]},c)})}),C.jsx("button",{onClick:()=>e("quote"),style:{...ps,opacity:r===null?.5:1},disabled:r===null,children:"Continue"})]})}function NL({merchant:e,balance:t,onConfirm:n,submitting:r,error:i,quote:s,quoteLoading:o,currencies:a,fmtCur:c}){if(o&&!s)return C.jsxs(ve,{style:{padding:"60px 0",minHeight:320,alignItems:"center",justifyContent:"center"},children:[C.jsx(gf,{}),C.jsx("div",{style:{marginTop:16,fontSize:13,color:K.mute},children:"Calculating best route…"})]});const u=a[e.currency]||Ti[e.currency],l=(u==null?void 0:u.rate)||1,d=e.amount/l,f=s?s.breakdown.inputAmount:d,h=t.amount>0?t.usd/t.amount:t.token==="ETH"?3400:1,m=f/(h||1),y=s?s.breakdown.bridgeFeeUsd:t.chain==="Base"&&t.token==="USDC"?0:1.8,w=s?s.breakdown.senderFeeUsd+s.breakdown.appFeeUsd:f*.0075,b=y+w,E=s?s.breakdown.sellRate:l,v=s?s.estimatedFiat:e.amount;return C.jsxs(ve,{gap:14,style:{padding:"16px 20px 6px"},children:[C.jsxs(ve,{gap:6,children:[C.jsx("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"You pay"}),C.jsxs(rn,{align:"baseline",gap:8,children:[C.jsx("div",{style:{fontSize:30,fontWeight:600,letterSpacing:-.6},children:$u(m,5)}),C.jsx("div",{style:{fontSize:16,color:K.ink2,fontWeight:500},children:t.token})]}),C.jsxs(rn,{gap:6,style:{fontSize:12,color:K.mute},children:[C.jsx(Ra,{bg:t.chainTint,size:14,children:t.logo?C.jsx("img",{src:t.logo,style:{width:"100%",height:"100%",objectFit:"cover"}}):t.icon}),"on ",t.chain]})]}),C.jsxs("div",{style:{padding:"2px 0",position:"relative"},children:[C.jsx(Pa,{}),C.jsxs("div",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"#fff",padding:"0 10px",fontSize:11,color:K.mute,letterSpacing:.4,display:"flex",alignItems:"center",gap:6},children:[C.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M12 5V19M5 12L12 19L19 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"converts to"]})]}),C.jsxs(ve,{gap:6,children:[C.jsxs("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:[e.name," receives"]}),C.jsx(rn,{align:"baseline",gap:8,children:C.jsx("div",{style:{fontSize:30,fontWeight:600,letterSpacing:-.6,color:K.accent},children:c(v,e.currency)})}),C.jsxs(rn,{gap:6,style:{fontSize:12,color:K.mute},children:["via ",(u==null?void 0:u.method)||"Transfer"," · ",(u==null?void 0:u.psp)||"Partner"]})]}),C.jsxs(ve,{gap:7,style:{fontSize:12.5},children:[C.jsxs(rn,{justify:"space-between",children:[C.jsx("span",{style:{color:K.mute},children:"Rate"}),C.jsxs("span",{children:["1 USDC = ",c(E,e.currency)]})]}),y>0&&C.jsxs(rn,{justify:"space-between",children:[C.jsx("span",{style:{color:K.mute},children:"Network & bridge"}),C.jsxs("span",{children:["$",y.toFixed(2)]})]}),C.jsxs(rn,{justify:"space-between",children:[C.jsx("span",{style:{color:K.mute},children:"Weave fee"}),C.jsxs("span",{children:["$",w.toFixed(2)]})]}),C.jsx(Pa,{}),C.jsxs(rn,{justify:"space-between",style:{fontWeight:500,color:K.ink},children:[C.jsx("span",{children:"Total fees"}),C.jsxs("span",{children:["$",b.toFixed(2)]})]}),o&&C.jsx("div",{style:{fontSize:11,color:K.mute,textAlign:"center"},children:"Fetching live rate…"})]}),C.jsxs(ve,{gap:8,children:[i&&C.jsx("div",{style:{background:"#FBEEE9",border:`1px solid ${K.err}33`,borderRadius:10,padding:"10px 12px",fontSize:12,color:K.err,lineHeight:1.5},children:i}),C.jsxs("button",{onClick:n,disabled:r,style:{...ps,opacity:r?.6:1,cursor:r?"not-allowed":"pointer"},children:[r?"Creating order…":"Confirm in wallet",!r&&C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12H19M13 6L19 12L13 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]}),C.jsx("div",{style:{fontSize:11,color:K.mute,textAlign:"center"},children:"Rate locked for 30s · You'll sign one transaction in your wallet"})]})]})}function gf(){return C.jsxs("div",{style:{position:"relative",width:56,height:56},children:[C.jsxs("svg",{width:"56",height:"56",viewBox:"0 0 56 56",style:{position:"absolute",inset:0},children:[C.jsx("circle",{cx:"28",cy:"28",r:"24",stroke:K.hair,strokeWidth:"2.5",fill:"none"}),C.jsx("circle",{cx:"28",cy:"28",r:"24",stroke:K.accent,strokeWidth:"2.5",fill:"none",strokeDasharray:"40 150",strokeLinecap:"round",style:{transformOrigin:"center",animation:"wspin 1.2s linear infinite"}})]}),C.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsx(Sg,{size:22})})]})}function LL({onNext:e,details:t}){const[n,r]=ce.useState(!0),[i,s]=ce.useState(null),o=ce.useRef(!1),a=()=>{if(!t){s("Payment details unavailable. Please retry."),r(!1);return}const{accessCode:c}=t,u=()=>{if(o.current)return;o.current=!0,r(!1);const d=window.PaystackPop;if(!d){s("Paystack failed to load. Please check your connection and retry."),o.current=!1;return}new d().resumeTransaction(c,{onSuccess:()=>e("processing"),onCancel:()=>{o.current=!1}})};if(window.PaystackPop){u();return}const l=document.createElement("script");l.src="https://js.paystack.co/v2/inline.js",l.onload=u,l.onerror=()=>{r(!1),s("Could not load Paystack. Check your network and try again.")},document.head.appendChild(l)};return ce.useEffect(()=>{a()},[]),n?C.jsx(ve,{gap:24,style:{padding:"28px 20px"},children:C.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[C.jsx("div",{style:{width:36,height:36,borderRadius:"50%",border:`3px solid ${K.hair}`,borderTopColor:K.accent,animation:"wspin 0.8s linear infinite",margin:"0 auto"}}),C.jsx("div",{style:{marginTop:14,fontSize:14,color:K.mute},children:"Opening payment popup…"})]})}):i?C.jsxs(ve,{gap:16,style:{padding:"28px 20px"},children:[C.jsx("div",{style:{textAlign:"center",fontSize:14,color:K.err,padding:"8px 0"},children:i}),C.jsx("button",{onClick:()=>{o.current=!1,s(null),r(!0),a()},style:ps,children:"Retry"})]}):C.jsxs(ve,{gap:16,style:{padding:"28px 20px"},children:[C.jsx("div",{style:{textAlign:"center",fontSize:14,color:K.mute,padding:"12px 0"},children:"A Paystack payment popup has opened. Complete payment there to continue."}),C.jsx("button",{onClick:()=>{o.current=!1,a()},style:{...ps,background:K.page,color:K.ink},children:"Re-open popup"})]})}const jL=new Set(["completed"]),$L=new Set(["failed","expired","refunded"]);function j5({onNext:e,merchant:t,mode:n,apiKey:r,orderId:i,bankDetails:s,currencies:o,fmtCur:a}){const[c,u]=ce.useState(0),[l,d]=ce.useState(0),f=ce.useRef(!1),h=Ti[t.currency];ce.useEffect(()=>{const b=setInterval(()=>d(E=>E+1),1e3);return()=>clearInterval(b)},[]);const m=s!=null&&s.amountToTransfer?(()=>{const b=s.amountToTransfer,E=b.includes(".")?b.split(".")[1].length:0;return a(Number(b),t.currency,E)})():a(t.amount,t.currency),y=n==="fiat"?[{label:"Confirming your transfer",sub:`Matching the ${m} from your bank`,dur:1600},{label:"Completing payment",sub:`Sending to ${t.name}`,dur:2400}]:[{label:"Confirming transaction",sub:"Processing your transaction on-chain",dur:1400},{label:"Confirming your payment",sub:`Settling ${(h==null?void 0:h.name)||t.currency} to ${t.name}`,dur:2600}];ce.useEffect(()=>{if(i)return;if(c>=y.length){e("success");return}const b=setTimeout(()=>u(E=>E+1),y[c].dur);return()=>clearTimeout(b)},[c,i]),ce.useEffect(()=>{if(!i)return;f.current=!1;let b,E=0;const v=5e3,A=3e4,P=async()=>{if(f.current)return;try{const L=await ju(r,i);E=0;const U=String(L.status??"").toLowerCase(),j=String(L.paycrestStatus??"").toLowerCase();if(jL.has(U)){f.current=!0,e("success");return}if($L.has(U)){f.current=!0,e("error");return}j==="fulfilled"&&u(1)}catch{E++}const M=Math.min(v*Math.pow(2,E),A);b=setTimeout(P,M)};return P(),()=>{f.current=!0,clearTimeout(b)}},[i,r]);const w=y[Math.min(c,y.length-1)];return C.jsxs(ve,{gap:20,style:{padding:"28px 20px 12px",minHeight:360},children:[C.jsxs(ve,{gap:12,style:{alignItems:"center",paddingTop:12},children:[C.jsx(gf,{}),C.jsxs(ve,{gap:4,style:{alignItems:"center"},children:[C.jsx("div",{style:{fontSize:17,fontWeight:600,letterSpacing:-.3},children:w.label}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,textAlign:"center"},children:w.sub})]})]}),C.jsx(ve,{gap:0,style:{padding:"4px 8px"},children:y.map((b,E)=>C.jsxs(rn,{gap:12,style:{padding:"10px 0"},children:[C.jsxs("div",{style:{width:22,height:22,borderRadius:11,flexShrink:0,background:E<c?K.accent:"#fff",border:E<c?"none":`1.5px solid ${E===c?K.accent:K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",position:"relative"},children:[E<c&&C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})}),E===c&&C.jsx("div",{style:{width:8,height:8,borderRadius:4,background:K.accent,animation:"wpulse 1.1s ease-in-out infinite"}})]}),C.jsxs(ve,{gap:1,children:[C.jsx("div",{style:{fontSize:13,fontWeight:500,color:E<=c?K.ink:K.mute},children:b.label}),C.jsx("div",{style:{fontSize:11.5,color:K.mute},children:E<c?"Completed":E===c?b.sub:"Pending"})]})]},E))}),C.jsx("div",{style:{fontSize:11,color:K.mute,textAlign:"center"},children:"You can safely close this window. We'll email a receipt."})]})}function $5({onNext:e,merchant:t,balance:n,direction:r,apiKey:i,orderId:s,accentColor:o,currencies:a,fmtCur:c}){var P,M,L,U;const[u,l]=ce.useState(null);ce.useEffect(()=>{if(!s)return;let j=!1;return ju(i,s).then(Z=>{j||l(Z)}).catch(()=>{}),()=>{j=!0}},[i,s]);const f=(u!=null&&u.sourceAssetKey?II(u.sourceAssetKey):void 0)||n,h=f.token||(typeof(u==null?void 0:u.sourceAssetKey)=="string"?u.sourceAssetKey.split(":").pop():void 0),m=u?Number(u.sourceAmount):t.amount,y=r==="offramp"&&u?`${$u(Number(u.sourceAmount),4)} ${h??f.token}`:`${c(m,t.currency)}`,w=(P=u==null?void 0:u.destInstrument)==null?void 0:P.bankInstitution,b=r==="offramp"?w?bw(t.currency,w):((M=a[t.currency])==null?void 0:M.bank)||((L=Ti[t.currency])==null?void 0:L.bank):t.name,E=u!=null&&u.createdAt&&(u!=null&&u.updatedAt)?Math.max(1,Math.round((new Date(u.updatedAt).getTime()-new Date(u.createdAt).getTime())/1e3)):null,v=E==null?"—":E<60?`${E}s`:`${Math.round(E/60)}m`,A=!u;return C.jsxs(ve,{gap:18,style:{padding:"28px 20px 12px",minHeight:360},children:[C.jsxs(ve,{gap:14,style:{alignItems:"center",paddingTop:8},children:[C.jsx("div",{style:{width:64,height:64,borderRadius:32,background:K.accent,display:"flex",alignItems:"center",justifyContent:"center",animation:"wpop 0.5s cubic-bezier(0.2, 1.2, 0.4, 1)"},children:C.jsx("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"white",strokeWidth:"3.2",strokeLinecap:"round",strokeLinejoin:"round"})})}),C.jsxs(ve,{gap:4,style:{alignItems:"center"},children:[C.jsx("div",{style:{fontSize:20,fontWeight:600,letterSpacing:-.3},children:"Payment complete"}),C.jsx("div",{style:{fontSize:13,color:K.mute,textAlign:"center",lineHeight:1.5,maxWidth:280,animation:A?"wpulse 1.5s ease-in-out infinite":void 0},children:r==="offramp"?C.jsxs(C.Fragment,{children:[c(t.amount,t.currency)," is on its way to ",C.jsx("span",{style:{color:K.ink},children:t.name}),"."]}):C.jsxs(C.Fragment,{children:["Your payment of ",c(m,t.currency)," has been sent to ",C.jsx("span",{style:{color:K.ink},children:t.name}),"."]})})]})]}),C.jsxs(ve,{gap:0,style:{background:K.panel,border:`1px solid ${K.hair}`,borderRadius:12,overflow:"hidden"},children:[C.jsxs(rn,{justify:"space-between",style:{padding:"12px 14px",fontSize:12.5},children:[C.jsx("span",{style:{color:K.mute},children:"Paid with"}),r==="offramp"?C.jsxs(rn,{gap:6,style:{animation:A?"wpulse 1.5s ease-in-out infinite":void 0},children:[C.jsx(Ra,{bg:f.chainTint||f.tint,size:16,children:f.logo?C.jsx("img",{src:f.logo,style:{width:"100%",height:"100%",objectFit:"cover"}}):f.icon?f.icon:f.flag?f.flag:f.symbol}),C.jsx("span",{style:{fontWeight:500},children:y})]}):C.jsxs(rn,{gap:6,children:[C.jsx("div",{style:{width:16,height:16,borderRadius:8,background:"#fff",border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10},children:((U=a[t.currency])==null?void 0:U.flag)||"🇳🇬"}),C.jsx("span",{style:{fontWeight:500},children:c(m,t.currency)})]})]}),C.jsx(Pa,{}),C.jsxs(rn,{justify:"space-between",style:{padding:"12px 14px",fontSize:12.5},children:[C.jsx("span",{style:{color:K.mute},children:r==="offramp"?"Settled to":"Paid to"}),C.jsx("span",{style:{fontWeight:500,animation:A?"wpulse 1.5s ease-in-out infinite":void 0},children:b})]}),C.jsx(Pa,{}),C.jsxs(rn,{justify:"space-between",style:{padding:"12px 14px",fontSize:12.5},children:[C.jsx("span",{style:{color:K.mute},children:"Completed in"}),C.jsx(rn,{gap:6,children:C.jsx("span",{style:{animation:A?"wpulse 1.5s ease-in-out infinite":void 0},children:C.jsx(Fu,{tone:"good",children:v})})})]})]}),C.jsxs(ve,{gap:8,children:[C.jsx("button",{onClick:()=>e("connect"),style:ps,children:"Done"}),C.jsxs("button",{onClick:()=>CL(t,u,b,o),style:{...kg,justifyContent:"center",paddingLeft:0},children:[C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M12 3V15M12 15L7 10M12 15L17 10M3 19H21",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Download receipt"]})]})]})}function F5({onNext:e,onBack:t}){return C.jsxs(ve,{gap:16,style:{padding:"28px 20px 12px",minHeight:360},children:[C.jsxs(ve,{gap:14,style:{alignItems:"center",paddingTop:8},children:[C.jsx("div",{style:{width:64,height:64,borderRadius:32,background:"#FBEEE9",display:"flex",alignItems:"center",justifyContent:"center"},children:C.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",children:[C.jsx("path",{d:"M12 8V13M12 17V17.01",stroke:K.err,strokeWidth:"2.4",strokeLinecap:"round"}),C.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:K.err,strokeWidth:"2"})]})}),C.jsxs(ve,{gap:4,style:{alignItems:"center"},children:[C.jsx("div",{style:{fontSize:18,fontWeight:600},children:"Transaction didn't go through"}),C.jsx("div",{style:{fontSize:13,color:K.mute,textAlign:"center",maxWidth:280},children:"Your wallet rejected the signature or the rate expired. No funds were moved."})]})]}),C.jsxs(ve,{gap:8,children:[C.jsx("button",{onClick:()=>t("quote"),style:ps,children:"Try again"}),C.jsx("button",{onClick:()=>e("connect"),style:kg,children:"Use a different payment method"})]})]})}const FL=new Set(["XRP","TON","STELLAR","NEAR"]),DL={BASE:"0x…",ETHEREUM:"0x…",ARBITRUM:"0x…",OPTIMISM:"0x…",POLYGON:"0x…",BSC:"0x…",AVALANCHE:"0x…",GNOSIS:"0x…",SCROLL:"0x…",XLAYER:"0x…",MONAD:"0x…",BERA:"0x…",SOLANA:"e.g. 5Gh8…base58",TRON:"T…",NEAR:"alice.near or 64-hex",TON:"UQ… / EQ…",SUI:"0x… (64 chars)",APTOS:"0x… (64 chars)",STARKNET:"0x…",BITCOIN:"bc1… or 1…",XRP:"r…",STELLAR:"G…",CARDANO:"addr1…",DOGE:"D…",LITECOIN:"ltc1… or L…",BCH:"bitcoincash:q… or q…",ZEC:"t1… or zs1…",DASH:"X…"},UL={"BASE:USDC":{chainId:8453,contract:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",decimals:6},"OPTIMISM:USDC":{chainId:10,contract:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",decimals:6},"ARBITRUM:USDC":{chainId:42161,contract:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",decimals:6},"POLYGON:USDC":{chainId:137,contract:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",decimals:6}},HL=(e,t,n,r)=>{if(!e)return"";if(!t||!n||!r)return e;const i=UL[`${n.toUpperCase()}:${r.toUpperCase()}`];if(!i)return e;const s=Math.ceil(t*100)/100,o=BigInt(Math.round(s*10**i.decimals));return`ethereum:${i.contract}@${i.chainId}/transfer?address=${e}&uint256=${o.toString()}`};function zL({onNext:e,merchant:t,depositAddress:n,depositMemo:r,amountToSend:i,sourceToken:s,sourceChain:o,loading:a,error:c,onChainChange:u,ready:l,apiKey:d,orderId:f,preSelectedChainIdx:h,depositChains:m,currencies:y,fmtCur:w}){var ge,z;const[b,E]=ce.useState(""),[v,A]=ce.useState(h??null),[P,M]=ce.useState(!1),[L,U]=ce.useState(""),[j,Z]=ce.useState(""),[Y,W]=ce.useState(!1),[I,p]=ce.useState(!1),[g,S]=ce.useState(!1),R=L.trim()?m.map((F,oe)=>({c:F,i:oe})).filter(({c:F})=>{const oe=L.trim().toLowerCase();return F.name.toLowerCase().includes(oe)||F.token.toLowerCase().includes(oe)||F.network.toLowerCase().includes(oe)||F.id.toLowerCase().includes(oe)}):m.map((F,oe)=>({c:F,i:oe})),T=v!=null?m[v]:null,B=n??"",$=r??"",O=s??(T==null?void 0:T.token)??"",_=t.amount/(((ge=y[t.currency])==null?void 0:ge.rate)||((z=Ti[t.currency])==null?void 0:z.rate)||1),D=i??_,ue=HL(B,i,o,s),ne=ce.useRef(null),G=T?FL.has(T.id):!1,J=()=>{if(!T||!j.trim())return;const F=`${T.id}:${T.token}:${j.trim()}`;ne.current!==F&&(ne.current=F,W(!0),u(T.id,T.token,j.trim()))};ce.useEffect(()=>{W(!1),Z(""),ne.current=null},[v]),ce.useEffect(()=>{if(!f)return;let F=!1,oe;const de=async()=>{if(!F){try{const Ee=await ju(d,f),Se=String(Ee.status??"").toLowerCase(),xe=String(Ee.nearStatus??"").toLowerCase();E(xe);const Pt=Array.isArray(Ee.steps)&&Ee.steps.some(Ze=>(Ze==null?void 0:Ze.provider)==="nearintents")&&xe==="processing";if(Se&&Se!=="awaiting_deposit"||Pt){F=!0,Se==="completed"?e("success"):["failed","refunded"].includes(Se)?e("error"):e("processing");return}}catch{}oe=setTimeout(de,5e3)}};return de(),()=>{F=!0,clearTimeout(oe)}},[d,f,e]);const te=()=>{var F;B&&((F=navigator.clipboard)==null||F.writeText(B),p(!0),setTimeout(()=>p(!1),1500))},le=()=>{var F;$&&((F=navigator.clipboard)==null||F.writeText($),S(!0),setTimeout(()=>S(!1),1500))};return P?C.jsxs(ve,{gap:12,style:{padding:"16px 20px 6px"},children:[C.jsxs(ve,{gap:8,children:[C.jsxs("button",{onClick:()=>{M(!1),U("")},style:{alignSelf:"flex-start",padding:"4px 0",background:"transparent",border:"none",cursor:"pointer",fontSize:12,color:K.mute,fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:[C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M15 18L9 12L15 6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Back"]}),C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Select a network"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"We'll generate a deposit address for the network you choose."})]}),C.jsxs("div",{style:{position:"relative"},children:[C.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:[C.jsx("circle",{cx:"11",cy:"11",r:"7",stroke:K.mute,strokeWidth:"2"}),C.jsx("path",{d:"M20 20L16 16",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round"})]}),C.jsx("input",{autoFocus:!0,placeholder:"Search networks or tokens…",value:L,onChange:F=>U(F.target.value),style:{width:"100%",boxSizing:"border-box",padding:"10px 12px 10px 34px",borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",fontSize:13,fontFamily:"inherit",color:K.ink,outline:"none"}})]}),C.jsx("div",{style:{maxHeight:360,overflowY:"auto",border:`1px solid ${K.hair}`,borderRadius:10,background:"#fff",padding:4,display:"flex",flexDirection:"column",gap:1},children:R.length===0?C.jsxs("div",{style:{padding:"24px 10px",fontSize:12,color:K.mute,textAlign:"center"},children:['No matches for "',L.trim(),'"']}):R.map(({c:F,i:oe})=>C.jsxs("button",{onClick:()=>{A(oe),M(!1),U("")},style:{width:"100%",padding:"10px 10px",borderRadius:7,background:oe===v?K.accentSoft:"transparent",border:"none",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:10,textAlign:"left"},children:[C.jsx(Ra,{bg:F.tint,size:24,children:F.logo?C.jsx("img",{src:F.logo,style:{width:"100%",height:"100%",borderRadius:"inherit",objectFit:"cover"}}):F.icon}),C.jsxs("div",{style:{flex:1},children:[C.jsxs("div",{style:{fontSize:13,fontWeight:500},children:[F.token," on ",F.name]}),C.jsx("div",{style:{fontSize:10.5,color:K.mute},children:F.network})]}),oe===v&&C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:K.accent,strokeWidth:"2.8",strokeLinecap:"round",strokeLinejoin:"round"})})]},`${F.id}:${F.token}`))})]}):C.jsxs(ve,{gap:14,style:{padding:"16px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Send from any wallet"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"Scan the QR or copy the address. Send from a mobile wallet, exchange, or hardware device — we'll detect the deposit automatically."})]}),C.jsxs(ve,{gap:6,children:[C.jsx("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Network"}),C.jsx("button",{onClick:()=>M(!0),style:{padding:"10px 12px",borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:10,textAlign:"left"},children:T?C.jsxs(C.Fragment,{children:[C.jsx(Ra,{bg:T.tint,size:26,children:T.logo?C.jsx("img",{src:T.logo,style:{width:"100%",height:"100%",objectFit:"cover"}}):T.icon}),C.jsxs(ve,{gap:1,style:{flex:1},children:[C.jsxs("div",{style:{fontSize:13.5,fontWeight:500},children:[T.token," on ",T.name]}),C.jsx("div",{style:{fontSize:11,color:K.mute},children:T.network})]}),C.jsx("div",{style:{fontSize:11,color:K.mute},children:"Change"})]}):C.jsxs(C.Fragment,{children:[C.jsx("div",{style:{width:26,height:26,borderRadius:13,border:`1px dashed ${K.hair}`,background:K.panel,display:"flex",alignItems:"center",justifyContent:"center",color:K.mute,fontSize:13},children:"?"}),C.jsxs(ve,{gap:1,style:{flex:1},children:[C.jsx("div",{style:{fontSize:13.5,fontWeight:500,color:K.ink},children:"Choose a network"}),C.jsx("div",{style:{fontSize:11,color:K.mute},children:"30+ chains supported · powered by NEAR Intents"})]}),C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M6 9L12 15L18 9",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]}),T?Y?C.jsxs(C.Fragment,{children:[C.jsxs("div",{style:{background:K.panel,border:`1px solid ${K.hair}`,borderRadius:12,padding:"16px",display:"flex",gap:14,alignItems:"center"},children:[C.jsx("div",{style:{padding:8,background:"#fff",borderRadius:10,border:`1px solid ${K.hair}`,flexShrink:0},children:ue?C.jsx(SL,{value:ue,size:120,level:"M",includeMargin:!1}):C.jsxs("div",{style:{width:120,height:120,borderRadius:12,background:K.panel,border:`1px dashed ${K.hair}`,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10},children:[C.jsx("div",{className:"weaving-spinner"}),C.jsx("div",{style:{fontSize:10,color:K.mute,letterSpacing:.8,fontWeight:500,textTransform:"uppercase"},children:"Generating Address"})]})}),C.jsxs(ve,{gap:8,style:{flex:1,minWidth:0},children:[C.jsxs(ve,{gap:2,children:[C.jsx("div",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Amount"}),C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:a?C.jsx("span",{style:{color:K.mute,fontWeight:400},children:"Calculating…"}):C.jsxs(C.Fragment,{children:[$u(D)," ",O]})}),C.jsxs("div",{style:{fontSize:11,color:K.mute},children:["on ",T.name]})]}),C.jsxs("div",{style:{fontSize:10.5,color:K.mute,lineHeight:1.4},children:["Rate locked for ",C.jsx("span",{style:{color:K.ink,fontWeight:500},children:"9:42"})]})]})]}),C.jsxs(ve,{gap:6,children:[C.jsx("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Deposit address"}),C.jsxs("div",{style:{display:"flex",alignItems:"center",border:`1px solid ${K.hair}`,borderRadius:10,background:"#fff",overflow:"hidden"},children:[C.jsx("div",{style:{flex:1,padding:"10px 12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12.5,color:B?K.ink:K.mute,letterSpacing:-.2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a?"Generating address…":B||"—"}),C.jsx("button",{onClick:te,disabled:!B,style:{height:40,padding:"0 14px",border:"none",borderLeft:`1px solid ${K.hair}`,background:I?K.accentSoft:"#fff",color:I?K.accent:B?K.ink:K.mute,fontSize:12,fontWeight:500,cursor:B?"pointer":"not-allowed",fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:I?C.jsxs(C.Fragment,{children:[C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied"]}):C.jsxs(C.Fragment,{children:[C.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:[C.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2",stroke:"currentColor",strokeWidth:"2"}),C.jsx("path",{d:"M16 8V5C16 4.45 15.55 4 15 4H5C4.45 4 4 4.45 4 5V15C4 15.55 4.45 16 5 16H8",stroke:"currentColor",strokeWidth:"2"})]}),"Copy"]})})]}),c&&C.jsxs(ve,{gap:6,children:[C.jsx("div",{style:{fontSize:11.5,color:K.err},children:c}),C.jsx("button",{onClick:()=>{W(!1),ne.current=null},style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:7,background:"transparent",border:`1px solid ${K.hair}`,cursor:"pointer",fontFamily:"inherit",fontSize:11.5,color:K.ink},children:"Edit refund address"})]})]}),($||G)&&C.jsxs(ve,{gap:6,children:[C.jsxs("div",{style:{fontSize:11,color:K.mute,textTransform:"uppercase",letterSpacing:.6,display:"flex",alignItems:"center",gap:6},children:[T.id==="XRP"?"Destination tag":"Memo",C.jsx("span",{style:{fontSize:10,color:K.warn,fontWeight:600,letterSpacing:.4},children:"REQUIRED"})]}),C.jsxs("div",{style:{display:"flex",alignItems:"center",border:`1px solid ${K.hair}`,borderRadius:10,background:"#fff",overflow:"hidden"},children:[C.jsx("div",{style:{flex:1,padding:"10px 12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12.5,color:$?K.ink:K.mute,letterSpacing:-.2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a?"Generating memo…":$||"—"}),C.jsx("button",{onClick:le,disabled:!$,style:{height:40,padding:"0 14px",border:"none",borderLeft:`1px solid ${K.hair}`,background:g?K.accentSoft:"#fff",color:g?K.accent:$?K.ink:K.mute,fontSize:12,fontWeight:500,cursor:$?"pointer":"not-allowed",fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:g?C.jsxs(C.Fragment,{children:[C.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied"]}):C.jsxs(C.Fragment,{children:[C.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:[C.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"2",stroke:"currentColor",strokeWidth:"2"}),C.jsx("path",{d:"M16 8V5C16 4.45 15.55 4 15 4H5C4.45 4 4 4.45 4 5V15C4 15.55 4.45 16 5 16H8",stroke:"currentColor",strokeWidth:"2"})]}),"Copy"]})})]}),C.jsxs("div",{style:{fontSize:11,color:K.warn,lineHeight:1.5},children:["You must include this ",T.id==="XRP"?"destination tag":"memo"," when you send — without it the funds can't be credited and may be lost."]})]}),C.jsxs("div",{style:{background:K.warnSoft,border:`1px solid ${K.warn}22`,borderRadius:10,padding:"10px 12px",display:"flex",gap:10,fontSize:11.5,color:K.warn,lineHeight:1.5},children:[C.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0,marginTop:1},children:[C.jsx("path",{d:"M12 2L2 20H22L12 2Z",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"}),C.jsx("path",{d:"M12 10V13M12 16V16.01",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),C.jsxs("span",{children:["Only send ",C.jsx("b",{children:T.token})," on the ",C.jsx("b",{children:T.name})," network. Sending other assets or from a different network may result in loss."]})]}),C.jsx("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",background:b==="incomplete_deposit"?"#FFF5F5":"#fff",border:`1px solid ${b==="incomplete_deposit"?"#FFD1D1":K.hair}`,borderRadius:10},children:b==="incomplete_deposit"?C.jsx("div",{style:{flex:1,fontSize:12,color:"#D94E4E",fontWeight:500,lineHeight:1.4},children:"Partial payment received. Still waiting for the remaining balance to complete your order."}):C.jsxs(C.Fragment,{children:[C.jsxs("div",{style:{position:"relative",width:10,height:10},children:[C.jsx("div",{style:{position:"absolute",inset:0,borderRadius:5,background:K.accent}}),C.jsx("div",{style:{position:"absolute",inset:-3,borderRadius:8,background:K.accent,opacity:.25,animation:"wpulse 1.6s ease-in-out infinite"}})]}),C.jsxs("div",{style:{flex:1,fontSize:12,color:K.ink2},children:["Watching for deposit on ",T.name,"…"]})]})})]}):C.jsxs(ve,{gap:10,children:[C.jsxs(ve,{gap:6,children:[C.jsxs("label",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:["Your refund wallet on ",T.name]}),C.jsx("input",{autoFocus:!0,placeholder:DL[T.id]??"Paste your wallet address",value:j,onChange:F=>Z(F.target.value),onKeyDown:F=>{F.key==="Enter"&&J()},style:{width:"100%",boxSizing:"border-box",padding:"11px 14px",borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",fontSize:13,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:K.ink,outline:"none",letterSpacing:-.2}}),C.jsxs("div",{style:{fontSize:11,color:K.mute,lineHeight:1.5},children:["If the swap fails or you send the wrong amount, funds are returned to this address. Must be a valid address on ",C.jsx("b",{children:T.name}),"."]})]}),C.jsx("button",{onClick:J,disabled:!j.trim(),style:{...ps,opacity:j.trim()?1:.5,cursor:j.trim()?"pointer":"not-allowed"},children:"Generate deposit address"})]}):C.jsx("div",{style:{background:K.panel,border:`1px dashed ${K.hair}`,borderRadius:12,padding:"28px 16px",textAlign:"center",fontSize:12.5,color:K.mute,lineHeight:1.5},children:"Pick a network above to generate your deposit address."})]})}const Ag={width:"100%",padding:"11px 14px",borderRadius:10,border:`1px solid ${K.hair}`,background:"#fff",fontSize:14,fontWeight:500,color:K.ink,fontFamily:"inherit",outline:"none",boxSizing:"border-box"};function WL({merchant:e,value:t,onChange:n,onSubmit:r,submitting:i,error:s}){const o=yw[e.currency]??[],a=t.institution.length>0&&t.accountIdentifier.trim().length>=8&&t.accountName.trim().length>=2;return C.jsxs(ve,{gap:14,style:{padding:"16px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Where should refunds go?"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"If your payment can't be matched, we'll return the funds to this account. Must be in your name."})]}),C.jsxs(ve,{gap:10,children:[C.jsxs(ve,{gap:6,children:[C.jsx("label",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Bank"}),C.jsxs("select",{value:t.institution,onChange:c=>n({...t,institution:c.target.value}),style:{...Ag,appearance:"none",backgroundImage:`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none'><path d='M6 9L12 15L18 9' stroke='%236B7572' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 12px center",paddingRight:36},children:[C.jsx("option",{value:"",disabled:!0,children:"Select your bank…"}),o.map(c=>C.jsx("option",{value:c.code,children:c.name},c.code))]})]}),C.jsxs(ve,{gap:6,children:[C.jsx("label",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Account number"}),C.jsx("input",{inputMode:"numeric",placeholder:"0123456789",value:t.accountIdentifier,onChange:c=>n({...t,accountIdentifier:c.target.value.replace(/\D/g,"")}),style:{...Ag,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",letterSpacing:-.2}})]}),C.jsxs(ve,{gap:6,children:[C.jsx("label",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Account name"}),C.jsx("input",{placeholder:"Full name as it appears on your account",value:t.accountName,onChange:c=>n({...t,accountName:c.target.value}),style:Ag})]})]}),C.jsxs("div",{style:{background:K.panel,border:`1px solid ${K.hair}`,borderRadius:10,padding:"10px 12px",display:"flex",gap:10,fontSize:11.5,color:K.ink2,lineHeight:1.5},children:[C.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0,marginTop:1,color:K.mute},children:[C.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.8"}),C.jsx("path",{d:"M12 8V13M12 16V16.01",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),C.jsx("span",{children:"We only use this account if the payment fails. Refunds arrive within 1 business day."})]}),s&&C.jsx("div",{style:{background:"#FBEEE9",border:`1px solid ${K.err}33`,borderRadius:10,padding:"10px 12px",fontSize:12,color:K.err,lineHeight:1.5},children:s}),C.jsx("button",{onClick:r,disabled:!a||i,style:{...ps,opacity:a&&!i?1:.5,cursor:a&&!i?"pointer":"not-allowed"},children:i?"Creating payment…":"Continue"})]})}const GL={NGN:{bank:"Wema Bank",accountNumber:"8203 7461 92",accountName:"Weave / Afriloom-0481"}};function qL({onNext:e,merchant:t,bankDetails:n,apiKey:r,orderId:i,currencies:s,fmtCur:o}){const a=Ti[t.currency],c=n?{bank:bw(t.currency,n.institution),accountNumber:n.accountIdentifier,accountName:n.accountName}:GL[t.currency],u=n!=null&&n.amountToTransfer?(()=>{const E=n.amountToTransfer,v=E.includes(".")?E.split(".")[1].length:0;return o(Number(E),t.currency,v)})():o(t.amount,t.currency),[l,d]=ce.useState(null),[f,h]=ce.useState(9),[m,y]=ce.useState(42);ce.useEffect(()=>{const E=setInterval(()=>{y(v=>v>0?v-1:(h(A=>Math.max(0,A-1)),59))},1e3);return()=>clearInterval(E)},[]),ce.useEffect(()=>{if(!i)return;let E=!1,v;const A=async()=>{if(!E){try{const P=await ju(r,i),M=String(P.status??"").toLowerCase();if(M&&M!=="awaiting_deposit"){E=!0,M==="completed"?e("success"):["failed","refunded"].includes(M)?e("error"):e("processing");return}}catch{}v=setTimeout(A,5e3)}};return A(),()=>{E=!0,clearTimeout(v)}},[r,i,e]);const w=(E,v)=>{var A;(A=navigator.clipboard)==null||A.writeText(v),d(E),setTimeout(()=>d(null),1400)},b=({label:E,value:v,k:A,mono:P=!0})=>C.jsxs(rn,{justify:"space-between",style:{padding:"11px 14px"},children:[C.jsxs(ve,{gap:2,style:{minWidth:0},children:[C.jsx("div",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:E}),C.jsx("div",{style:{fontSize:14,fontWeight:500,color:K.ink,fontFamily:P?"ui-monospace, SFMono-Regular, Menlo, monospace":"inherit",letterSpacing:P?-.2:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v})]}),C.jsx("button",{onClick:()=>w(A,v),style:{height:28,padding:"0 10px",borderRadius:7,border:`1px solid ${K.hair}`,background:l===A?K.accentSoft:"#fff",color:l===A?K.accent:K.ink,fontSize:11.5,fontWeight:500,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:5},children:l===A?C.jsxs(C.Fragment,{children:[C.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M5 12L10 17L19 7",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied"]}):"Copy"})]});return C.jsxs(ve,{gap:14,style:{padding:"16px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsxs(rn,{justify:"space-between",align:"flex-start",children:[C.jsxs("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:["Send ",u]}),C.jsxs(Fu,{tone:"warn",children:[C.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",style:{marginRight:2},children:[C.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2"}),C.jsx("path",{d:"M12 7V12L15 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),f,":",String(m).padStart(2,"0")]})]}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"Open your bank app and transfer to this account. We'll confirm your payment automatically — no need to send proof."})]}),C.jsxs("div",{style:{background:"#fff",border:`1px solid ${K.hair}`,borderRadius:12,overflow:"hidden"},children:[C.jsxs(rn,{gap:10,style:{padding:"12px 14px",background:K.panel,borderBottom:`1px solid ${K.hair}`},children:[C.jsx("div",{style:{width:28,height:28,borderRadius:14,background:"#fff",border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600,color:K.ink},children:a.flag}),C.jsxs(ve,{gap:1,style:{flex:1},children:[C.jsx("div",{style:{fontSize:13,fontWeight:500},children:c.bank}),C.jsxs("div",{style:{fontSize:11,color:K.mute},children:["Virtual account · one-time · ",t.currency]})]})]}),C.jsx(b,{label:"Account number",value:c.accountNumber,k:"acc"}),C.jsx(Pa,{}),C.jsx(b,{label:"Account name",value:c.accountName,k:"name",mono:!1}),C.jsx(Pa,{}),C.jsx(b,{label:"Amount",value:u,k:"amt",mono:!1})]}),C.jsxs("div",{style:{background:K.warnSoft,border:`1px solid ${K.warn}22`,borderRadius:10,padding:"10px 12px",display:"flex",gap:10,fontSize:11.5,color:K.warn,lineHeight:1.5},children:[C.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0,marginTop:1},children:[C.jsx("path",{d:"M12 2L2 20H22L12 2Z",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"}),C.jsx("path",{d:"M12 10V13M12 16V16.01",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),C.jsx("span",{children:"Send the exact amount. Any difference may delay delivery."})]})]})}function VL({onConnected:e,onExternalFlow:t}){const{connect:n,connectors:r,isPending:i}=dN(),{isConnected:s}=Zm();return ce.useEffect(()=>{s&&e()},[s]),C.jsxs(ve,{gap:16,style:{padding:"22px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Connect your wallet"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"Pay directly from your crypto holdings. We'll handle the conversion."})]}),C.jsx(ve,{gap:8,children:r.map(o=>{const a=o.name.toLowerCase(),c=a.includes("metamask")?"Browser extension or MetaMask mobile":a.includes("coinbase")?"Coinbase Wallet app or extension":a.includes("phantom")?"Phantom wallet extension":a.includes("brave")?"Brave browser built-in wallet":"Connect with this wallet";return C.jsxs("button",{onClick:()=>n({connector:o}),disabled:i,style:{...Du,opacity:i?.6:1},children:[C.jsx("div",{style:{width:40,height:40,borderRadius:10,background:K.panel,border:`1px solid ${K.hair}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,overflow:"hidden"},children:o.icon?C.jsx("img",{src:o.icon,alt:o.name,style:{width:28,height:28,borderRadius:6,objectFit:"contain"}}):C.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",children:[C.jsx("rect",{x:"2",y:"6",width:"20",height:"14",rx:"3",stroke:K.ink2,strokeWidth:"1.8"}),C.jsx("path",{d:"M2 10H22",stroke:K.ink2,strokeWidth:"1.8"}),C.jsx("circle",{cx:"17",cy:"15",r:"1.5",fill:K.ink2})]})}),C.jsxs(ve,{gap:2,style:{flex:1,textAlign:"left"},children:[C.jsx("div",{style:{fontSize:14,fontWeight:500},children:o.name}),C.jsx("div",{style:{fontSize:11.5,color:K.mute},children:c})]}),i?C.jsx("div",{style:{width:12,height:12,borderRadius:6,background:K.accent,opacity:.5,animation:"wpulse 1s infinite"}}):C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},o.uid)})}),C.jsx("button",{onClick:t,style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:K.mute,padding:"4px 0",textAlign:"center"},children:"Don't have a browser wallet? Send from any app →"})]})}function KL({onSelectToken:e,onExternalFlow:t,merchant:n,currencies:r,fmtCur:i,ethUsdPrice:s,loadingEthPrice:o}){var g,S;const{address:a,chainId:c}=Zm(),{switchChain:u,isPending:l}=mN(),d=c?B5[c]:void 0,f=c?N5[c]:void 0,h=c?vL.has(c):!1,m=c?Eg[c]??"Unknown":"Unknown",y=c?M5[c]??K.accent:K.accent,w=a?`${a.slice(0,6)}…${a.slice(-4)}`:"",{data:b,isLoading:E}=cg({address:a,chainId:c,query:{enabled:!!a}}),{data:v,isLoading:A}=cg({address:a,token:d,chainId:c,query:{enabled:!!a&&!!d}}),{data:P,isLoading:M}=cg({address:a,token:f,chainId:c,query:{enabled:!!a&&!!f}}),L=b?Number(dd(b.value)):0,U=v?Number(fa(v.value,v.decimals)):0,j=P?Number(fa(P.value,P.decimals)):0;if(o||E||A||M)return C.jsxs(ve,{style:{padding:"60px 0",minHeight:280,alignItems:"center",justifyContent:"center"},children:[C.jsx(gf,{}),C.jsx("div",{style:{marginTop:16,fontSize:13,color:K.mute},children:"Fetching market rates…"})]});const Y=L*s,W=n.amount/(((g=r[n.currency])==null?void 0:g.rate)||1),I={ETH:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",USDC:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",USDT:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png"},p=[{tokenKey:"USDC",token:"USDC",chain:m,amount:U,usd:U,icon:"$",chainTint:y,logo:I.USDC},...f?[{tokenKey:"USDT",token:"USDT",chain:m,amount:j,usd:j,icon:"$",chainTint:y,logo:I.USDT}]:[],{tokenKey:"ETH",token:"ETH",chain:m,amount:L,usd:Y,icon:"Ξ",chainTint:y,logo:I.ETH}];return h?C.jsxs(ve,{gap:14,style:{padding:"18px 20px 6px"},children:[C.jsxs(rn,{justify:"space-between",align:"center",children:[C.jsxs(ve,{gap:1,children:[C.jsx("div",{style:{fontSize:10.5,color:K.mute,textTransform:"uppercase",letterSpacing:.6},children:"Connected wallet"}),C.jsx("div",{style:{fontSize:13,fontWeight:500,color:K.ink,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:w})]}),C.jsx(Fu,{tone:"accent",children:m})]}),C.jsxs("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:["Select a token to pay with. We'll bridge it to ",((S=r[n.currency])==null?void 0:S.name)??n.currency," automatically."]}),C.jsx(ve,{gap:6,children:p.map(R=>{const T=R.usd>=W;return C.jsxs("button",{onClick:()=>T&&e(R.tokenKey,R),disabled:!T,style:{...Du,opacity:T?1:.42,cursor:T?"pointer":"not-allowed"},children:[C.jsx("div",{style:{width:36,height:36,borderRadius:9,flexShrink:0,background:R.chainTint+"22",border:`1px solid ${R.chainTint}44`,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:15,color:R.chainTint,overflow:"hidden"},children:R.logo?C.jsx("img",{src:R.logo,style:{width:"100%",height:"100%",objectFit:"cover"}}):R.icon}),C.jsxs(ve,{gap:2,style:{flex:1,textAlign:"left"},children:[C.jsxs("div",{style:{fontSize:14,fontWeight:500},children:[$u(R.amount,R.tokenKey==="ETH"?4:2)," ",R.tokenKey]}),C.jsxs("div",{style:{fontSize:11.5,color:K.mute},children:["≈ $",R.usd.toFixed(2)," on ",m]})]}),T?C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):C.jsx(Fu,{tone:"warn",children:"Insufficient"})]},R.tokenKey)})}),C.jsx("button",{onClick:t,style:{background:"transparent",border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:K.mute,textAlign:"center",padding:"2px 0"},children:"Pay from another wallet or exchange →"})]}):C.jsxs(ve,{gap:14,style:{padding:"22px 20px 6px"},children:[C.jsxs(ve,{gap:4,children:[C.jsx("div",{style:{fontSize:18,fontWeight:600,letterSpacing:-.3},children:"Switch Network"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,lineHeight:1.5},children:"Your wallet is on an unsupported chain. Switch to one of these to continue."})]}),C.jsx(ve,{gap:6,children:[8453,10,42161,1,137].map(R=>C.jsxs("button",{onClick:()=>u({chainId:R}),disabled:l,style:{...Du,opacity:l?.6:1},children:[C.jsx("div",{style:{width:32,height:32,borderRadius:8,flexShrink:0,background:M5[R],color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:13},children:Eg[R][0]}),C.jsx("div",{style:{fontSize:13,fontWeight:500},children:Eg[R]}),C.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",style:{marginLeft:"auto"},children:C.jsx("path",{d:"M9 6L15 12L9 18",stroke:K.mute,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]},R))})]})}function JL({onRetry:e}){return C.jsxs(ve,{gap:20,style:{padding:"40px 20px 20px",minHeight:280,alignItems:"center",justifyContent:"center"},children:[C.jsx(gf,{}),C.jsxs(ve,{gap:6,style:{alignItems:"center"},children:[C.jsx("div",{style:{fontSize:17,fontWeight:600,letterSpacing:-.3},children:"Confirm in your wallet"}),C.jsx("div",{style:{fontSize:12.5,color:K.mute,textAlign:"center",maxWidth:260,lineHeight:1.6},children:"Check your wallet extension or app and approve the transaction to send funds."}),C.jsx("button",{onClick:e,style:{...kg,marginTop:12,fontSize:13,padding:"8px 16px"},children:"Not seeing the pop-up? Try again"})]})]})}const ZL={name:"Afriloom Textiles",amount:700,currency:"NGN"},Ig={Base:"BASE",Optimism:"OPTIMISM",Ethereum:"ETHEREUM",Arbitrum:"ARBITRUM",Polygon:"POLYGON"},YL=new j7;function QL({merchant:e=ZL,apiKey:t,sessionId:n,userAddress:r,customer:i,theme:s="organic",borderRadius:o=16,accentColor:a,onSuccess:c,onError:u,onClose:l,apiBase:d,disabledMethods:f}){d&&typeof window<"u"&&(window.__WEAVE_API_BASE__=d);const h=t??(typeof window<"u"?window.__WEAVE_API_KEY__:void 0)??"pk_live_72a9e3afde82acf51db54bbcaa65832f4b549c56294fe88f"??"pk_test_demo",m=r??"0x2B4fB6F7255DeF56d985fb01134ab1431Efbd3be"??"0x0000000000000000000000000000000000000000",{address:y,chainId:w,isConnected:b}=Zm(),{disconnect:E}=hN(),v=()=>{E(),localStorage.clear()},{writeContractAsync:A}=gN(),{sendTransactionAsync:P}=pN(),[M,L]=ce.useState("connect"),[U,j]=ce.useState("offramp"),[Z,Y]=ce.useState(0),[W,I]=ce.useState(null),[p,g]=ce.useState(!1),[S,R]=ce.useState({institution:"",accountIdentifier:"",accountName:""}),[T,B]=ce.useState(null),[$,O]=ce.useState(null),[_,D]=ce.useState(null),[ue,ne]=ce.useState(null),[G,J]=ce.useState(null),[te,le]=ce.useState(null),[ge,z]=ce.useState(null),[F,oe]=ce.useState(null),[de,Ee]=ce.useState(!1),[Se,xe]=ce.useState(null),[ze,Pt]=ce.useState(null),[Ze,Ye]=ce.useState(!1),[wt,We]=ce.useState(!1),[nt,vt]=ce.useState(null),[Fe,N]=ce.useState({fiat:L0,crypto:mw}),x=ce.useRef(0),k=ce.useRef(0),H=ce.useRef(null),[Q,X]=ce.useState(()=>typeof navigator<"u"?navigator.onLine:!0);ce.useEffect(()=>{const re=()=>X(!0),se=()=>X(!1);return window.addEventListener("online",re),window.addEventListener("offline",se),()=>{window.removeEventListener("online",re),window.removeEventListener("offline",se)}},[]);const[ie,Me]=ce.useState("USDC"),[Te,Re]=ce.useState(null),[ot,Ce]=ce.useState(3400),[ht,_n]=ce.useState(!0);ce.useEffect(()=>{const re=localStorage.getItem(`weave-order-${h}`);if(re)try{const{orderId:se,screen:fe,createdAt:we}=JSON.parse(re);Date.now()-we<1*60*60*1e3&&ju(h,se).then(me=>{var Ge;const he=me,Ae=CI(he.sourceAssetKey,he.destAssetKey);if(j(Ae==="onramp"?"onramp":"offramp"),["awaiting_deposit","processing"].includes(he.status)){B(he.id);const Oe=he.steps.find(Le=>Le.status!=="done")||he.steps[0];if(Ae==="onramp")(Oe==null?void 0:Oe.provider)==="paycrest"&&(Oe.depositAddress||Oe.amountOut)?(((Ge=he.sourceInstrument)==null?void 0:Ge.kind)==="bank_account"&&O({accountName:he.sourceInstrument.bankAccountName||"",accountIdentifier:he.sourceInstrument.bankAccountIdentifier||"",institution:he.sourceInstrument.bankInstitution||"",currency:he.destAssetKey.split(":").pop()||"NGN",amountToTransfer:he.sourceAmount.toString()}),L("vaccount")):L("processing");else if((Oe==null?void 0:Oe.provider)==="nearintents"&&he.status==="awaiting_deposit"){ne(Oe.depositAddress),J(Oe.depositMemo),le(Number(Oe.amountIn));const Le=Oe.fromAsset.split(":");z(Le[2]||Le[1]),oe(Le[1]),L("deposit")}else L("processing")}else he.status==="completed"?(B(he.id),L("success")):localStorage.removeItem(`weave-order-${h}`)}).catch(()=>{localStorage.removeItem(`weave-order-${h}`)})}catch{localStorage.removeItem(`weave-order-${h}`)}if(EL(h).then(se=>{se&&N(se)}).catch(()=>{}),e.sourceAssetKey&&e.amountIn==="source"){const se=Fe.crypto.findIndex(fe=>{var we;return`${fe.id}:${fe.token}`===((we=e.sourceAssetKey)==null?void 0:we.split("crypto:")[1])});se!==-1&&(I(se),j("offramp"),L("deposit"))}},[h]),ce.useEffect(()=>{h&&(_n(!0),Lu(h,{from:"crypto:ETHEREUM:ETH",to:co(e.currency),amount:1,amountIn:"source"}).then(re=>{const se=Fe.fiat.find(me=>me.key===co(e.currency)),fe=(se==null?void 0:se.rate)||1515,we=re.estimatedDest/fe;!isNaN(we)&&we>0&&Ce(we),_n(!1)}).catch(re=>{console.warn("[WeaveCheckoutInner] Live ETH price fetch failed:",re),_n(!1)}))},[h,e.currency,Fe.fiat]),ce.useEffect(()=>{T&&!["success","error"].includes(M)?localStorage.setItem(`weave-order-${h}`,JSON.stringify({orderId:T,screen:M,createdAt:Date.now()})):M==="success"&&localStorage.removeItem(`weave-order-${h}`)},[T,M,h]);const De=Fe.fiat.reduce((re,se)=>{const fe=se.key.split(":").pop();return re[fe]={name:se.name,symbol:se.symbol,flag:se.flag,rate:se.rate,min:se.min,country:se.country,psp:"GTBank",bank:"GTBank ••7890",method:"Bank transfer"},re},{}),ut=Fe.crypto,an=(re,se,fe)=>{const we=De[se]||Ti[se];if(!we)return`${se} ${re}`;const he=!!we?0:4,Ae=fe??(Number.isInteger(re)?0:he),Ge=Math.pow(10,Ae),Oe=Ae>0?Math.ceil(re*Ge)/Ge:Math.ceil(re),Le=new Intl.NumberFormat("en-US",{minimumFractionDigits:Ae,maximumFractionDigits:Ae}).format(Oe);return`${we.symbol}${Le}`},_t=re=>{vt(null),B(null),ne(null),J(null),xe(null),O(null),Pt(null),Re(null),re==="fiat"?(j("onramp"),e.currency==="NGN"&&e.destAssetKey==="fiat:NGN"?zr():L("refundAccount")):re==="crypto"?(j("offramp"),L("wallet")):re==="deposit"?(j("offramp"),L(b?"walletAsset":"walletConnect")):re==="externalDeposit"&&(j("offramp"),L("deposit"))},pt=async(re,se,fe)=>{const we=++x.current;Ee(!0),xe(null),ne(null),J(null),le(null),z(null),oe(null);try{const me=hf(re,se),he=e.destAssetKey||co(e.currency),Ae=e.amountIn??"dest";let Ge=e.amount;he.startsWith("crypto:")&&e.currency==="NGN"&&(Ge=(await Lu(h,{from:co(e.currency),to:he,amount:e.amount,amountIn:"source"})).estimatedDest);const Oe=await Lu(h,{from:me,to:he,amount:Ge,amountIn:Ae}),Le={inline:{kind:"crypto_wallet",assetKey:me,walletAddress:""}};H.current??(H.current="weave_"+Math.random().toString(36).slice(2)+Date.now().toString(36));const gt=await xg(h,{source:Le,amount:Ge,amountIn:Ae,refundAddress:fe,reference:H.current,sessionId:n,customer:i??void 0,dest:e.destInstrument?{inline:{...e.destInstrument,assetKey:he}}:void 0});if(x.current!==we)return;H.current=null,B(gt.order.id),ne(gt.nextAction.depositAddress??null),J(gt.nextAction.depositMemo??null),O(gt.nextAction.bankDetails??null),le(typeof gt.nextAction.amount=="number"?gt.nextAction.amount:null),z(gt.nextAction.token??se),oe(gt.nextAction.chain??re)}catch(me){if(x.current!==we)return;xe(me.message??"Could not generate a deposit address"),u==null||u(me)}finally{x.current===we&&Ee(!1)}},fi=async()=>{L("quote");const re=mf[Z??0],se=++k.current;Ye(!0),Pt(null);try{const fe=await Lu(h,{from:hf(Ig[re.chain]??re.chain,re.token),to:co(e.currency),amount:e.amount,amountIn:"dest"});if(k.current!==se)return;Pt({estimatedFiat:fe.estimatedDest,netUsdc:fe.breakdown.netUsd,fiatCurrency:e.currency,breakdown:{inputAmount:fe.breakdown.usdEquivalent,inputToken:re.token,fastPath:fe.route.steps.length===1,bridgeFeeUsd:fe.breakdown.bridgeFeeUsd,senderFeeUsd:fe.breakdown.senderFeeUsd,appFeeUsd:fe.breakdown.appFeeUsd,sellRate:fe.breakdown.sellRate??0}})}catch{}finally{k.current===se&&Ye(!1)}},mt=async(re,se)=>{if(Re(re),Me(se),L("quote"),!w)return;const fe=O5[w];if(!fe)return;const we=++k.current;Ye(!0),Pt(null);try{const me=await Lu(h,{from:hf(fe,se),to:co(e.currency),amount:e.amount,amountIn:"dest"});if(k.current!==we)return;Pt({estimatedFiat:me.estimatedDest,netUsdc:me.breakdown.netUsd,fiatCurrency:e.currency,breakdown:{inputAmount:me.breakdown.usdEquivalent,inputToken:se,fastPath:me.route.steps.length===1,bridgeFeeUsd:me.breakdown.bridgeFeeUsd,senderFeeUsd:me.breakdown.senderFeeUsd,appFeeUsd:me.breakdown.appFeeUsd,sellRate:me.breakdown.sellRate??0}})}catch{}finally{k.current===we&&Ye(!1)}},tt=re=>{re==="success"&&c&&T&&c({orderId:T,status:"completed"}),L(re)},zr=async re=>{var se;We(!0),vt(null);try{const fe={inline:{kind:"bank_account",assetKey:co(e.currency),bankInstitution:S.institution,bankAccountIdentifier:S.accountIdentifier,bankAccountName:S.accountName}};H.current??(H.current="weave_"+Math.random().toString(36).slice(2)+Date.now().toString(36));const we=await xg(h,{source:fe,amount:e.amount,reference:H.current,sessionId:n,customer:i??void 0,dest:e.destInstrument?{inline:{...e.destInstrument,assetKey:e.destAssetKey||e.destInstrument.assetKey}}:void 0,amountIn:(se=e.destAssetKey)!=null&&se.startsWith("fiat:")?"dest":void 0});H.current=null,B(we.order.id),O(we.nextAction.bankDetails??null),D(we.nextAction.paystackPopupDetails??null);const me=we.nextAction.screen==="paystack_popup"?"paystack_popup":"vaccount";L(me)}catch(fe){vt(fe.message??"Failed to create order"),u==null||u(fe)}finally{We(!1)}},Et=()=>zr(),lt=async()=>{if(wt)return;const re=Te??mf[Z??0],se=b&&y&&w&&Te;We(!0),vt(null);try{let fe=T,we=ue,me=te;if(!fe||!we){const he=se?O5[w]??Ig[re.chain]??re.chain:Ig[re.chain]??re.chain,Ae=se?ie:re.token,Oe={inline:{kind:"crypto_wallet",assetKey:hf(he,Ae),walletAddress:se?y:m}};H.current??(H.current="weave_"+Math.random().toString(36).slice(2)+Date.now().toString(36));const Le=await xg(h,{source:Oe,amount:e.amount,amountIn:"dest",flow:se?"self":void 0,reference:H.current,sessionId:n,customer:i??void 0,dest:e.destInstrument?{inline:{...e.destInstrument,assetKey:e.destAssetKey||e.destInstrument.assetKey}}:void 0});H.current=null,fe=Le.order.id,we=Le.nextAction.depositAddress??null,me=Le.order.sourceAmount,B(fe),ne(we),le(me),z(Le.nextAction.token??Ae),oe(Le.nextAction.chain??he)}if(se&&we){L("walletSign");const he=ie,Ae=me;let Ge;if(he==="ETH")Ge=await P({to:we,value:v9(Ae.toString()),chainId:w});else{const Oe=he==="USDC"?B5[w]:N5[w];if(!Oe)throw new Error(`${he} is not available on this chain`);Ge=await A({address:Oe,abi:xL,functionName:"transfer",args:[we,Q_(Ae.toString(),6)],chainId:w})}try{await TB(T5,{hash:Ge,timeout:6e4})}catch(Oe){console.warn("[widget] transaction wait timed out or failed:",Oe.message)}}else ne(we);L("processing")}catch(fe){const we=fe.message??"",me=we.toLowerCase().includes("reject")||we.toLowerCase().includes("denied")||we.toLowerCase().includes("cancelled");vt(me?"Transaction was rejected. Please try again.":we||"Failed to complete payment"),M==="walletSign"&&L("quote"),u==null||u(fe)}finally{We(!1)}};if(p)return C.jsxs("div",{style:{position:"absolute",bottom:24,right:24,zIndex:10,background:K.ink,color:"#fff",padding:"10px 16px",borderRadius:999,fontSize:13,display:"flex",alignItems:"center",gap:8,cursor:"pointer",boxShadow:"0 10px 30px rgba(0,0,0,0.25)",minWidth:"185px"},onClick:()=>g(!1),children:[C.jsx(Sg,{size:16}),"Pay with Weave"]});const ur=mf[Z??0],dt=U==="onramp",at=re=>{H.current=null,B(null),vt(null),O(null),D(null),ne(null),J(null),xe(null),Pt(null),Re(null),L(re)},hi=(()=>{if(M==="connect")return C.jsx(ML,{onPick:_t,merchant:e,currencies:De,fmtCur:an,submitting:wt,disabledMethods:f});if(dt){if(M==="refundAccount")return C.jsx(WL,{merchant:e,value:S,onChange:R,onSubmit:Et,submitting:wt,error:nt});if(M==="vaccount")return C.jsx(qL,{onNext:tt,merchant:e,bankDetails:$,apiKey:h,orderId:T,currencies:De,fmtCur:an});if(M==="paystack_popup")return C.jsx(LL,{onNext:tt,details:_});if(M==="processing")return C.jsx(j5,{onNext:tt,merchant:e,mode:"fiat",apiKey:h,orderId:T,bankDetails:$,currencies:De,fmtCur:an});if(M==="success")return C.jsx($5,{onNext:tt,balance:ur,merchant:e,direction:U,apiKey:h,orderId:T,accentColor:a,currencies:De,fmtCur:an});if(M==="error")return C.jsx(F5,{onNext:()=>at("connect"),onBack:()=>at("refundAccount")})}else{if(M==="walletConnect")return C.jsx(VL,{onConnected:()=>L("walletAsset"),onExternalFlow:()=>{j("offramp"),L("deposit")}});if(M==="walletAsset")return C.jsx(KL,{onSelectToken:(re,se)=>mt(se,re),onExternalFlow:()=>L("deposit"),merchant:e,currencies:De,fmtCur:an,ethUsdPrice:ot,loadingEthPrice:ht});if(M==="walletSign")return C.jsx(JL,{onRetry:lt});if(M==="deposit")return C.jsx(zL,{onNext:tt,merchant:e,depositAddress:ue,depositMemo:G,amountToSend:te,sourceToken:ge,sourceChain:F,loading:de,error:Se,onChainChange:pt,ready:!!T&&!!ue&&!de,apiKey:h,orderId:T,preSelectedChainIdx:W,depositChains:ut,currencies:De,fmtCur:an});if(M==="wallet")return C.jsx(BL,{onNext:()=>fi(),merchant:e,balances:mf,selected:Z,setSelected:Y,currencies:De});if(M==="quote")return C.jsx(NL,{merchant:e,balance:Te??ur,onConfirm:lt,submitting:wt,error:nt,quote:ze,quoteLoading:Ze,currencies:De,fmtCur:an});if(M==="processing")return C.jsx(j5,{onNext:tt,merchant:e,mode:"crypto",apiKey:h,orderId:T,currencies:De,fmtCur:an});if(M==="success")return C.jsx($5,{onNext:tt,balance:ur,merchant:e,direction:U,apiKey:h,orderId:T,accentColor:a,currencies:De,fmtCur:an});if(M==="error")return C.jsx(F5,{onNext:()=>at("connect"),onBack:()=>at("quote")})}return null})(),xt=["wallet","quote","deposit","walletConnect","walletAsset","walletSign"].includes(M)&&!dt||["refundAccount","vaccount"].includes(M)&&dt,q=M==="quote"?Te?"walletAsset":"wallet":M==="vaccount"?"refundAccount":M==="walletAsset"?"connect":M==="walletSign"?"quote":"connect";return C.jsxs("div",{className:`weave-checkout weave-theme-${s}`,style:{"--weave-accent":pf[a]||a||"#0F5D4C","--weave-accent-soft":(pf[a]||a||"#0F5D4C")+"15",width:400,background:K.surface,borderRadius:o,boxShadow:"0 30px 80px rgba(11, 15, 14, 0.22), 0 0 0 1px rgba(0,0,0,0.04)",overflow:"hidden",fontFamily:"Inter, -apple-system, BlinkMacSystemFont, sans-serif",color:K.ink,animation:"wslide 0.35s cubic-bezier(0.2, 1, 0.3, 1)"},children:[C.jsx(RL,{merchantName:e.name,onClose:()=>{g(!0),l==null||l()},showBack:xt,onBack:()=>{M==="walletAsset"&&v(),L(q)}}),!Q&&C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",background:K.warnSoft,color:K.warn,fontSize:12,fontWeight:500},children:[C.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("path",{d:"M1 6l5.5 5.5M17 6l-5.5 5.5M12 20v.01"}),C.jsx("path",{d:"M5 10l-4-4M23 2L1 22"})]}),"No connection — your payment is safe, reconnecting…"]}),C.jsx("div",{style:{animation:"wfade 0.25s ease"},children:hi},M),C.jsx(TL,{})]})}function XL(e){return C.jsx(kL,{config:T5,children:C.jsx(AL,{client:YL,children:C.jsx(QL,{...e})})})}const un={ink:"#0B0F0E",ink2:"#3A4240",mute:"#6B7572",hair:"#E8EAE6",page:"#F5F4EF"},ej={NGN:"₦"},yf=(e,t)=>`${ej[t]??""}${new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(e)}`;function tj({currency:e="NGN",amount:t=15e4}){const n=[{name:"Ẹ̀wà Handwoven Throw",sub:"Indigo / 150 × 200cm",price:12e4},{name:"Aso-Oke Runner",sub:"Earth / 35 × 180cm",price:25e3}];return C.jsxs("div",{style:{position:"absolute",inset:0,background:un.page,fontFamily:"Inter, -apple-system, sans-serif",color:un.ink,overflow:"hidden"},children:[C.jsxs("div",{style:{height:56,padding:"0 32px",borderBottom:`1px solid ${un.hair}`,display:"flex",alignItems:"center",background:"#fff"},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[C.jsx("div",{style:{width:26,height:26,borderRadius:6,background:"#2B1810",color:"#F5DEB3",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:13,fontFamily:"Georgia, serif"},children:"A"}),C.jsx("span",{style:{fontWeight:600,fontSize:14,letterSpacing:-.1},children:"Afriloom"}),C.jsx("span",{style:{color:un.mute,fontSize:13,marginLeft:16},children:"Shop · Journal · About"})]}),C.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:14,fontSize:13,color:un.ink2},children:[C.jsx("span",{children:"Search"}),C.jsx("span",{children:"Account"}),C.jsx("span",{children:"Cart (2)"})]})]}),C.jsxs("div",{style:{display:"flex",padding:"32px 32px",gap:40,height:"calc(100% - 56px)"},children:[C.jsxs("div",{style:{flex:"0 0 340px"},children:[C.jsx("div",{style:{fontSize:11,color:un.mute,textTransform:"uppercase",letterSpacing:.8,marginBottom:14},children:"Order summary"}),n.map((r,i)=>C.jsxs("div",{style:{display:"flex",gap:14,padding:"12px 0",borderBottom:`1px solid ${un.hair}`},children:[C.jsx("div",{style:{width:60,height:72,borderRadius:6,flexShrink:0,background:i===0?"repeating-linear-gradient(90deg, #2D3E60 0 6px, #1F2D45 6px 12px, #3A4F75 12px 16px)":"repeating-linear-gradient(0deg, #8B6D47 0 4px, #6B5236 4px 8px, #A8855D 8px 14px)"}}),C.jsxs("div",{style:{flex:1,fontSize:12.5},children:[C.jsx("div",{style:{fontWeight:500},children:r.name}),C.jsx("div",{style:{color:un.mute,fontSize:11.5,marginTop:2},children:r.sub}),C.jsx("div",{style:{marginTop:4},children:yf(r.price,e)})]})]},i)),C.jsxs("div",{style:{padding:"12px 0",fontSize:12.5,display:"flex",flexDirection:"column",gap:6},children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:un.mute},children:[C.jsx("span",{children:"Subtotal"}),C.jsx("span",{children:yf(145e3,e)})]}),C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:un.mute},children:[C.jsx("span",{children:"Shipping"}),C.jsx("span",{children:yf(5e3,e)})]}),C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontWeight:600,fontSize:14,marginTop:6,color:un.ink},children:[C.jsx("span",{children:"Total"}),C.jsx("span",{children:yf(t,e)})]})]})]}),C.jsxs("div",{style:{flex:1,maxWidth:440},children:[C.jsx("div",{style:{fontSize:11,color:un.mute,textTransform:"uppercase",letterSpacing:.8,marginBottom:14},children:"Payment"}),C.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,opacity:.4},children:[C.jsx("div",{style:{height:42,border:`1px solid ${un.hair}`,borderRadius:8,background:"#fff",display:"flex",alignItems:"center",padding:"0 14px",fontSize:13,color:un.mute},children:"Email"}),C.jsx("div",{style:{height:42,border:`1px solid ${un.hair}`,borderRadius:8,background:"#fff",display:"flex",alignItems:"center",padding:"0 14px",fontSize:13,color:un.mute},children:"Card number"}),C.jsxs("div",{style:{display:"flex",gap:10},children:[C.jsx("div",{style:{flex:1,height:42,border:`1px solid ${un.hair}`,borderRadius:8,background:"#fff"}}),C.jsx("div",{style:{flex:1,height:42,border:`1px solid ${un.hair}`,borderRadius:8,background:"#fff"}})]})]})]})]}),C.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(11, 15, 14, 0.35)",backdropFilter:"blur(1px)"}})]})}function D5(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var s;const o=c=>c===null?null:JSON.parse(c,void 0),a=(s=n.getItem(i))!=null?s:null;return a instanceof Promise?a.then(o):o(a)},setItem:(i,s)=>n.setItem(i,JSON.stringify(s,void 0)),removeItem:i=>n.removeItem(i)}}const Cg=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return Cg(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Cg(r)(n)}}}},nj=(e,t)=>(n,r,i)=>{let s={storage:D5(()=>localStorage),partialize:y=>y,version:0,merge:(y,w)=>({...w,...y}),...t},o=!1;const a=new Set,c=new Set;let u=s.storage;if(!u)return e((...y)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...y)},r,i);const l=()=>{const y=s.partialize({...r()});return u.setItem(s.name,{state:y,version:s.version})},d=i.setState;i.setState=(y,w)=>{d(y,w),l()};const f=e((...y)=>{n(...y),l()},r,i);i.getInitialState=()=>f;let h;const m=()=>{var y,w;if(!u)return;o=!1,a.forEach(E=>{var v;return E((v=r())!=null?v:f)});const b=((w=s.onRehydrateStorage)==null?void 0:w.call(s,(y=r())!=null?y:f))||void 0;return Cg(u.getItem.bind(u))(s.name).then(E=>{if(E)if(typeof E.version=="number"&&E.version!==s.version){if(s.migrate){const v=s.migrate(E.state,E.version);return v instanceof Promise?v.then(A=>[!0,A]):[!0,v]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,E.state];return[!1,void 0]}).then(E=>{var v;const[A,P]=E;if(h=s.merge(P,(v=r())!=null?v:f),n(h,!0),A)return l()}).then(()=>{b==null||b(h,void 0),h=r(),o=!0,c.forEach(E=>E(h))}).catch(E=>{b==null||b(void 0,E)})};return i.persist={setOptions:y=>{s={...s,...y},y.storage&&(u=y.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>m(),hasHydrated:()=>o,onHydrate:y=>(a.add(y),()=>{a.delete(y)}),onFinishHydration:y=>(c.add(y),()=>{c.delete(y)})},s.skipHydration||m(),h||f},U5=e=>{let t;const n=new Set,r=(u,l)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const f=t;t=l??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(h=>h(t,f))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u))},c=t=e(r,i,a);return a},Pg=e=>e?U5(e):U5;var bf,Tt,H5,uo,z5,W5,Rg,Tg,Og,Mg,Uu={},G5=[],rj=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Bg=Array.isArray;function ms(e,t){for(var n in t)e[n]=t[n];return e}function q5(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function yt(e,t,n){var r,i,s,o={};for(s in t)s=="key"?r=t[s]:s=="ref"?i=t[s]:o[s]=t[s];if(arguments.length>2&&(o.children=arguments.length>3?bf.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)o[s]===void 0&&(o[s]=e.defaultProps[s]);return wf(e,o,r,i,null)}function wf(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:i??++H5,__i:-1,__u:0};return i==null&&Tt.vnode!=null&&Tt.vnode(s),s}function vf(e){return e.children}function _f(e,t){this.props=e,this.context=t}function Ta(e,t){if(t==null)return e.__?Ta(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Ta(e):null}function V5(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return V5(e)}}function K5(e){(!e.__d&&(e.__d=!0)&&uo.push(e)&&!Ef.__r++||z5!==Tt.debounceRendering)&&((z5=Tt.debounceRendering)||W5)(Ef)}function Ef(){var e,t,n,r,i,s,o,a;for(uo.sort(Rg);e=uo.shift();)e.__d&&(t=uo.length,r=void 0,s=(i=(n=e).__v).__e,o=[],a=[],n.__P&&((r=ms({},i)).__v=i.__v+1,Tt.vnode&&Tt.vnode(r),Ng(n.__P,r,i,n.__n,n.__P.namespaceURI,32&i.__u?[s]:null,o,s??Ta(i),!!(32&i.__u),a),r.__v=i.__v,r.__.__k[r.__i]=r,X5(o,r,a),r.__e!=s&&V5(r)),uo.length>t&&uo.sort(Rg));Ef.__r=0}function J5(e,t,n,r,i,s,o,a,c,u,l){var d,f,h,m,y,w=r&&r.__k||G5,b=t.length;for(n.__d=c,ij(n,t,w),c=n.__d,d=0;d<b;d++)(h=n.__k[d])!=null&&(f=h.__i===-1?Uu:w[h.__i]||Uu,h.__i=d,Ng(e,h,f,i,s,o,a,c,u,l),m=h.__e,h.ref&&f.ref!=h.ref&&(f.ref&&Lg(f.ref,null,h),l.push(h.ref,h.__c||m,h)),y==null&&m!=null&&(y=m),65536&h.__u||f.__k===h.__k?c=Z5(h,c,e):typeof h.type=="function"&&h.__d!==void 0?c=h.__d:m&&(c=m.nextSibling),h.__d=void 0,h.__u&=-196609);n.__d=c,n.__e=y}function ij(e,t,n){var r,i,s,o,a,c=t.length,u=n.length,l=u,d=0;for(e.__k=[],r=0;r<c;r++)(i=t[r])!=null&&typeof i!="boolean"&&typeof i!="function"?(o=r+d,(i=e.__k[r]=typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?wf(null,i,null,null,null):Bg(i)?wf(vf,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?wf(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=e,i.__b=e.__b+1,s=null,(a=i.__i=sj(i,n,o,l))!==-1&&(l--,(s=n[a])&&(s.__u|=131072)),s==null||s.__v===null?(a==-1&&d--,typeof i.type!="function"&&(i.__u|=65536)):a!==o&&(a==o-1?d--:a==o+1?d++:(a>o?d--:d++,i.__u|=65536))):i=e.__k[r]=null;if(l)for(r=0;r<u;r++)(s=n[r])!=null&&!(131072&s.__u)&&(s.__e==e.__d&&(e.__d=Ta(s)),eE(s,s))}function Z5(e,t,n){var r,i;if(typeof e.type=="function"){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=Z5(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!n.contains(t)&&(t=Ta(e)),n.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType===8);return t}function sj(e,t,n,r){var i=e.key,s=e.type,o=n-1,a=n+1,c=t[n];if(c===null||c&&i==c.key&&s===c.type&&!(131072&c.__u))return n;if(r>(c!=null&&!(131072&c.__u)?1:0))for(;o>=0||a<t.length;){if(o>=0){if((c=t[o])&&!(131072&c.__u)&&i==c.key&&s===c.type)return o;o--}if(a<t.length){if((c=t[a])&&!(131072&c.__u)&&i==c.key&&s===c.type)return a;a++}}return-1}function Y5(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||rj.test(t)?n:n+"px"}function xf(e,t,n,r,i){var s;e:if(t==="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Y5(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||Y5(e.style,t,n[t])}else if(t[0]==="o"&&t[1]==="n")s=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e||t==="onFocusOut"||t==="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?r?n.u=r.u:(n.u=Tg,e.addEventListener(t,s?Mg:Og,s)):e.removeEventListener(t,s?Mg:Og,s);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function Q5(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=Tg++;else if(t.t<n.u)return;return n(Tt.event?Tt.event(t):t)}}}function Ng(e,t,n,r,i,s,o,a,c,u){var l,d,f,h,m,y,w,b,E,v,A,P,M,L,U,j,Z=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),s=[a=t.__e=n.__e]),(l=Tt.__b)&&l(t);e:if(typeof Z=="function")try{if(b=t.props,E="prototype"in Z&&Z.prototype.render,v=(l=Z.contextType)&&r[l.__c],A=l?v?v.props.value:l.__:r,n.__c?w=(d=t.__c=n.__c).__=d.__E:(E?t.__c=d=new Z(b,A):(t.__c=d=new _f(b,A),d.constructor=Z,d.render=aj),v&&v.sub(d),d.props=b,d.state||(d.state={}),d.context=A,d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),E&&d.__s==null&&(d.__s=d.state),E&&Z.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=ms({},d.__s)),ms(d.__s,Z.getDerivedStateFromProps(b,d.__s))),h=d.props,m=d.state,d.__v=t,f)E&&Z.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),E&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(E&&Z.getDerivedStateFromProps==null&&b!==h&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(b,A),!d.__e&&(d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(b,d.__s,A)===!1||t.__v===n.__v)){for(t.__v!==n.__v&&(d.props=b,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(Y){Y&&(Y.__=t)}),P=0;P<d._sb.length;P++)d.__h.push(d._sb[P]);d._sb=[],d.__h.length&&o.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(b,d.__s,A),E&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(h,m,y)})}if(d.context=A,d.props=b,d.__P=e,d.__e=!1,M=Tt.__r,L=0,E){for(d.state=d.__s,d.__d=!1,M&&M(t),l=d.render(d.props,d.state,d.context),U=0;U<d._sb.length;U++)d.__h.push(d._sb[U]);d._sb=[]}else do d.__d=!1,M&&M(t),l=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++L<25);d.state=d.__s,d.getChildContext!=null&&(r=ms(ms({},r),d.getChildContext())),E&&!f&&d.getSnapshotBeforeUpdate!=null&&(y=d.getSnapshotBeforeUpdate(h,m)),J5(e,Bg(j=l!=null&&l.type===vf&&l.key==null?l.props.children:l)?j:[j],t,n,r,i,s,o,a,c,u),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),w&&(d.__E=d.__=null)}catch(Y){if(t.__v=null,c||s!=null){for(t.__u|=c?160:32;a&&a.nodeType===8&&a.nextSibling;)a=a.nextSibling;s[s.indexOf(a)]=null,t.__e=a}else t.__e=n.__e,t.__k=n.__k;Tt.__e(Y,t,n)}else s==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=oj(n.__e,t,n,r,i,s,o,c,u);(l=Tt.diffed)&&l(t)}function X5(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)Lg(n[r],n[++r],n[++r]);Tt.__c&&Tt.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(s){s.call(i)})}catch(s){Tt.__e(s,i.__v)}})}function oj(e,t,n,r,i,s,o,a,c){var u,l,d,f,h,m,y,w=n.props,b=t.props,E=t.type;if(E==="svg"?i="http://www.w3.org/2000/svg":E==="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(u=0;u<s.length;u++)if((h=s[u])&&"setAttribute"in h==!!E&&(E?h.localName===E:h.nodeType===3)){e=h,s[u]=null;break}}if(e==null){if(E===null)return document.createTextNode(b);e=document.createElementNS(i,E,b.is&&b),a&&(Tt.__m&&Tt.__m(t,s),a=!1),s=null}if(E===null)w===b||a&&e.data===b||(e.data=b);else{if(s=s&&bf.call(e.childNodes),w=n.props||Uu,!a&&s!=null)for(w={},u=0;u<e.attributes.length;u++)w[(h=e.attributes[u]).name]=h.value;for(u in w)if(h=w[u],u!="children"){if(u=="dangerouslySetInnerHTML")d=h;else if(!(u in b)){if(u=="value"&&"defaultValue"in b||u=="checked"&&"defaultChecked"in b)continue;xf(e,u,null,h,i)}}for(u in b)h=b[u],u=="children"?f=h:u=="dangerouslySetInnerHTML"?l=h:u=="value"?m=h:u=="checked"?y=h:a&&typeof h!="function"||w[u]===h||xf(e,u,h,w[u],i);if(l)a||d&&(l.__html===d.__html||l.__html===e.innerHTML)||(e.innerHTML=l.__html),t.__k=[];else if(d&&(e.innerHTML=""),J5(e,Bg(f)?f:[f],t,n,r,E==="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,o,s?s[0]:n.__k&&Ta(n,0),a,c),s!=null)for(u=s.length;u--;)q5(s[u]);a||(u="value",E==="progress"&&m==null?e.removeAttribute("value"):m!==void 0&&(m!==e[u]||E==="progress"&&!m||E==="option"&&m!==w[u])&&xf(e,u,m,w[u],i),u="checked",y!==void 0&&y!==e[u]&&xf(e,u,y,w[u],i))}return e}function Lg(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){Tt.__e(i,n)}}function eE(e,t,n){var r,i;if(Tt.unmount&&Tt.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||Lg(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){Tt.__e(s,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&eE(r[i],t,n||typeof e.type!="function");n||q5(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function aj(e,t,n){return this.constructor(e,n)}function jg(e,t,n){var r,i,s,o;Tt.__&&Tt.__(e,t),i=(r=!1)?null:t.__k,s=[],o=[],Ng(t,e=t.__k=yt(vf,null,[e]),i||Uu,Uu,t.namespaceURI,i?null:t.firstChild?bf.call(t.childNodes):null,s,i?i.__e:t.firstChild,r,o),X5(s,e,o)}bf=G5.slice,Tt={__e:function(e,t,n,r){for(var i,s,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(a){e=a}throw e}},H5=0,_f.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=ms({},this.state),typeof e=="function"&&(e=e(ms({},n),this.props)),e&&ms(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),K5(this))},_f.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),K5(this))},_f.prototype.render=vf,uo=[],W5=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Rg=function(e,t){return e.__v.__b-t.__v.__b},Ef.__r=0,Tg=0,Og=Q5(!1),Mg=Q5(!0);function tE(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=tE(e[t]))&&(r&&(r+=" "),r+=n);else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function lo(){for(var e,t,n=0,r="";n<arguments.length;)(e=arguments[n++])&&(t=tE(e))&&(r&&(r+=" "),r+=t);return r}const cj=Object.freeze(Object.defineProperty({__proto__:null,clsx:lo,default:lo},Symbol.toStringTag,{value:"Module"}));var Sf,Gt,$g,nE,Fg=0,rE=[],Qt=Tt,iE=Qt.__b,sE=Qt.__r,oE=Qt.diffed,aE=Qt.__c,cE=Qt.unmount,uE=Qt.__;function lE(e,t){Qt.__h&&Qt.__h(Gt,e,Fg||t),Fg=0;var n=Gt.__H||(Gt.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function dE(e){return Fg=1,uj(hE,e)}function uj(e,t,n){var r=lE(Sf++,2);if(r.t=e,!r.__c&&(r.__=[hE(void 0,t),function(a){var c=r.__N?r.__N[0]:r.__[0],u=r.t(c,a);c!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=Gt,!Gt.u)){var i=function(a,c,u){if(!r.__c.__H)return!0;var l=r.__c.__H.__.filter(function(f){return!!f.__c});if(l.every(function(f){return!f.__N}))return!s||s.call(this,a,c,u);var d=!1;return l.forEach(function(f){if(f.__N){var h=f.__[0];f.__=f.__N,f.__N=void 0,h!==f.__[0]&&(d=!0)}}),!(!d&&r.__c.props===a)&&(!s||s.call(this,a,c,u))};Gt.u=!0;var s=Gt.shouldComponentUpdate,o=Gt.componentWillUpdate;Gt.componentWillUpdate=function(a,c,u){if(this.__e){var l=s;s=void 0,i(a,c,u),s=l}o&&o.call(this,a,c,u)},Gt.shouldComponentUpdate=i}return r.__N||r.__}function lj(e,t){var n=lE(Sf++,3);!Qt.__s&&hj(n.__H,t)&&(n.__=e,n.i=t,Gt.__H.__h.push(n))}function dj(){for(var e;e=rE.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(kf),e.__H.__h.forEach(Dg),e.__H.__h=[]}catch(t){e.__H.__h=[],Qt.__e(t,e.__v)}}Qt.__b=function(e){Gt=null,iE&&iE(e)},Qt.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),uE&&uE(e,t)},Qt.__r=function(e){sE&&sE(e),Sf=0;var t=(Gt=e.__c).__H;t&&($g===Gt?(t.__h=[],Gt.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.i=n.__N=void 0})):(t.__h.forEach(kf),t.__h.forEach(Dg),t.__h=[],Sf=0)),$g=Gt},Qt.diffed=function(e){oE&&oE(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(rE.push(t)!==1&&nE===Qt.requestAnimationFrame||((nE=Qt.requestAnimationFrame)||fj)(dj)),t.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.i=void 0})),$g=Gt=null},Qt.__c=function(e,t){t.some(function(n){try{n.__h.forEach(kf),n.__h=n.__h.filter(function(r){return!r.__||Dg(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Qt.__e(r,n.__v)}}),aE&&aE(e,t)},Qt.unmount=function(e){cE&&cE(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{kf(r)}catch(i){t=i}}),n.__H=void 0,t&&Qt.__e(t,n.__v))};var fE=typeof requestAnimationFrame=="function";function fj(e){var t,n=function(){clearTimeout(r),fE&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,100);fE&&(t=requestAnimationFrame(n))}function kf(e){var t=Gt,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),Gt=t}function Dg(e){var t=Gt;e.__c=e.__(),Gt=t}function hj(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function hE(e,t){return typeof t=="function"?t(e):t}const pj=[{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"}],mj="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";function pE(e,t={}){const{forHash:n}=t,{authorization:r,factory:i,factoryData:s}=e;return n&&(i==="0x7702"||i==="0x7702000000000000000000000000000000000000")?r?Yt([r.address,s??"0x"]):"0x7702000000000000000000000000000000000000":i?Yt([i,s??"0x"]):"0x"}const mE="0x22e325a297439656";function gE(e,t={}){const{callGasLimit:n,callData:r,maxPriorityFeePerGas:i,maxFeePerGas:s,paymaster:o,paymasterData:a,paymasterPostOpGasLimit:c,paymasterSignature:u,paymasterVerificationGasLimit:l,sender:d,signature:f="0x",verificationGasLimit:h}=e,m=Yt([Jt(ae(h||0n),{size:16}),Jt(ae(n||0n),{size:16})]),y=pE(e,t),w=Yt([Jt(ae(i||0n),{size:16}),Jt(ae(s||0n),{size:16})]),b=e.nonce??0n,E=o?Yt([o,Jt(ae(l||0n),{size:16}),Jt(ae(c||0n),{size:16}),a||"0x",...u?t.forHash?[mE]:[u,Jt(ae(kt(u)),{size:2}),mE]:[]]):"0x",v=e.preVerificationGas??0n;return{accountGasLimits:m,callData:r,initCode:y,gasFees:w,nonce:b,paymasterAndData:E,preVerificationGas:v,sender:d,signature:f}}const gj={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 yj(e){const{chainId:t,entryPointAddress:n,userOperation:r}=e,i=gE(r,{forHash:!0});return{types:gj,primaryType:"PackedUserOperation",domain:{name:"ERC4337",version:"1",chainId:t,verifyingContract:n},message:i}}function bj(e){const{chainId:t,entryPointAddress:n,entryPointVersion:r}=e,i=e.userOperation,{authorization:s,callData:o="0x",callGasLimit:a,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:l,paymasterAndData:d="0x",preVerificationGas:f,sender:h,verificationGasLimit:m}=i;if(r==="0.8"||r==="0.9")return Au(yj({chainId:t,entryPointAddress:n,userOperation:i}));const y=(()=>{var w,b;if(r==="0.6"){const E=(w=i.initCode)==null?void 0:w.slice(0,42),v=(b=i.initCode)==null?void 0:b.slice(42),A=pE({authorization:s,factory:E,factoryData:v},{forHash:!0});return Wn([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"uint256"},{type:"bytes32"}],[h,l,At(A),At(o),a,m,f,c,u,At(d)])}if(r==="0.7"){const E=gE(i,{forHash:!0});return Wn([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[E.sender,E.nonce,At(E.initCode),At(E.callData),E.accountGasLimits,E.preVerificationGas,E.gasFees,At(E.paymasterAndData)])}throw new Error(`entryPointVersion "${r}" not supported.`)})();return At(Wn([{type:"bytes32"},{type:"address"},{type:"uint256"}],[At(y),n,BigInt(t)]))}async function wj(e){const{extend:t,nonceKeyManager:n=HO({source:{get(){return Date.now()},set(){}}}),...r}=e;let i=!1;const s=await e.getAddress();return{...t,...r,address:s,async getFactoryArgs(){return"isDeployed"in this&&await this.isDeployed()?{factory:void 0,factoryData:void 0}:e.getFactoryArgs()},async getNonce(o){const a=(o==null?void 0:o.key)??BigInt(await n.consume({address:s,chainId:e.client.chain.id,client:e.client}));return e.getNonce?await e.getNonce({...o,key:a}):await Mn(e.client,{abi:op(["function getNonce(address, uint192) pure returns (uint256)"]),address:e.entryPoint.address,functionName:"getNonce",args:[s,a]})},async isDeployed(){return i?!0:(i=!!await _e(e.client,wa,"getCode")({address:s}),i)},...e.sign?{async sign(o){const[{factory:a,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.sign(o)]);return a&&c?Rm({address:a,data:c,signature:u}):u}}:{},async signMessage(o){const[{factory:a,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.signMessage(o)]);return a&&c&&a!=="0x7702"?Rm({address:a,data:c,signature:u}):u},async signTypedData(o){const[{factory:a,factoryData:c},u]=await Promise.all([this.getFactoryArgs(),e.signTypedData(o)]);return a&&c&&a!=="0x7702"?Rm({address:a,data:c,signature:u}):u},type:"smart"}}class Ug extends ee{constructor({cause:t}){super("Smart Account is not deployed.",{cause:t,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(Ug,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa20/});class Oa extends ee{constructor({cause:t,data:n,message:r}={}){var s;const i=(s=r==null?void 0:r.replace("execution reverted: ",""))==null?void 0:s.replace("execution reverted","");super(`Execution reverted ${i?`with reason: ${i}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n}}Object.defineProperty(Oa,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32521}),Object.defineProperty(Oa,"message",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Hg extends ee{constructor({cause:t}){super("Failed to send funds to beneficiary.",{cause:t,name:"FailedToSendToBeneficiaryError"})}}Object.defineProperty(Hg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa91/});class zg extends ee{constructor({cause:t}){super("Gas value overflowed.",{cause:t,metaMessages:["This could arise when:","- one of the gas values exceeded 2**120 (uint120)"].filter(Boolean),name:"GasValuesOverflowError"})}}Object.defineProperty(zg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa94/});class Wg extends ee{constructor({cause:t}){super("The `handleOps` function was called by the Bundler with a gas limit too low.",{cause:t,name:"HandleOpsOutOfGasError"})}}Object.defineProperty(Wg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa95/});class Gg extends ee{constructor({cause:t,factory:n,factoryData:r,initCode:i}){super("Failed to simulate deployment for Smart Account.",{cause:t,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
115
115
  `,n&&`factory: ${n}`,r&&`factoryData: ${r}`,i&&`initCode: ${i}`].filter(Boolean),name:"InitCodeFailedError"})}}Object.defineProperty(Gg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa13/});class qg extends ee{constructor({cause:t,factory:n,factoryData:r,initCode:i}){super("Smart Account initialization implementation did not create an account.",{cause:t,metaMessages:["This could arise when:","- `factory`/`factoryData` or `initCode` properties are invalid",`- Smart Account initialization implementation is incorrect
116
116
  `,n&&`factory: ${n}`,r&&`factoryData: ${r}`,i&&`initCode: ${i}`].filter(Boolean),name:"InitCodeMustCreateSenderError"})}}Object.defineProperty(qg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa15/});class Vg extends ee{constructor({cause:t,factory:n,factoryData:r,initCode:i,sender:s}){super("Smart Account initialization implementation does not return the expected sender.",{cause:t,metaMessages:["This could arise when:",`Smart Account initialization implementation does not return a sender address
117
117
  `,n&&`factory: ${n}`,r&&`factoryData: ${r}`,i&&`initCode: ${i}`,s&&`sender: ${s}`].filter(Boolean),name:"InitCodeMustReturnSenderError"})}}Object.defineProperty(Vg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa14/});class Kg extends ee{constructor({cause:t}){super("Smart Account does not have sufficient funds to execute the User Operation.",{cause:t,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(Kg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa21/});class Jg extends ee{constructor({cause:t}){super("Bundler attempted to call an invalid function on the EntryPoint.",{cause:t,name:"InternalCallOnlyError"})}}Object.defineProperty(Jg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa92/});class Zg extends ee{constructor({cause:t}){super("Bundler used an invalid aggregator for handling aggregated User Operations.",{cause:t,name:"InvalidAggregatorError"})}}Object.defineProperty(Zg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa96/});class Yg extends ee{constructor({cause:t,nonce:n}){super("Invalid Smart Account nonce used for User Operation.",{cause:t,metaMessages:[n&&`nonce: ${n}`].filter(Boolean),name:"InvalidAccountNonceError"})}}Object.defineProperty(Yg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa25/});class Qg extends ee{constructor({cause:t}){super("Bundler has not set a beneficiary address.",{cause:t,name:"InvalidBeneficiaryError"})}}Object.defineProperty(Qg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa90/});class Af extends ee{constructor({cause:t}){super("Invalid fields set on User Operation.",{cause:t,name:"InvalidFieldsError"})}}Object.defineProperty(Af,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Xg extends ee{constructor({cause:t,paymasterAndData:n}){super("Paymaster properties provided are invalid.",{cause:t,metaMessages:["This could arise when:","- the `paymasterAndData` property is of an incorrect length\n",n&&`paymasterAndData: ${n}`].filter(Boolean),name:"InvalidPaymasterAndDataError"})}}Object.defineProperty(Xg,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa93/});class fo extends ee{constructor({cause:t}){super("Paymaster deposit for the User Operation is too low.",{cause:t,metaMessages:["This could arise when:","- the Paymaster has deposited less than the expected amount via the `deposit` function"].filter(Boolean),name:"PaymasterDepositTooLowError"})}}Object.defineProperty(fo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32508}),Object.defineProperty(fo,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa31/});class ey extends ee{constructor({cause:t}){super("The `validatePaymasterUserOp` function on the Paymaster reverted.",{cause:t,name:"PaymasterFunctionRevertedError"})}}Object.defineProperty(ey,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa33/});class ty extends ee{constructor({cause:t}){super("The Paymaster contract has not been deployed.",{cause:t,name:"PaymasterNotDeployedError"})}}Object.defineProperty(ty,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa30/});class If extends ee{constructor({cause:t}){super("UserOperation rejected because paymaster (or signature aggregator) is throttled/banned.",{cause:t,name:"PaymasterRateLimitError"})}}Object.defineProperty(If,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32504});class Cf extends ee{constructor({cause:t}){super("UserOperation rejected because paymaster (or signature aggregator) stake or unstake-delay is too low.",{cause:t,name:"PaymasterStakeTooLowError"})}}Object.defineProperty(Cf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32505});class ny extends ee{constructor({cause:t}){super("Paymaster `postOp` function reverted.",{cause:t,name:"PaymasterPostOpFunctionRevertedError"})}}Object.defineProperty(ny,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa50/});class ry extends ee{constructor({cause:t,factory:n,factoryData:r,initCode:i}){super("Smart Account has already been deployed.",{cause:t,metaMessages:["Remove the following properties and try again:",n&&"`factory`",r&&"`factoryData`",i&&"`initCode`"].filter(Boolean),name:"SenderAlreadyConstructedError"})}}Object.defineProperty(ry,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa10/});class Pf extends ee{constructor({cause:t}){super("UserOperation rejected because account signature check failed (or paymaster signature, if the paymaster uses its data as signature).",{cause:t,name:"SignatureCheckFailedError"})}}Object.defineProperty(Pf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32507});class iy extends ee{constructor({cause:t}){super("The `validateUserOp` function on the Smart Account reverted.",{cause:t,name:"SmartAccountFunctionRevertedError"})}}Object.defineProperty(iy,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa23/});class Rf extends ee{constructor({cause:t}){super("UserOperation rejected because account specified unsupported signature aggregator.",{cause:t,name:"UnsupportedSignatureAggregatorError"})}}Object.defineProperty(Rf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32506});class sy extends ee{constructor({cause:t}){super("User Operation expired.",{cause:t,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(sy,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa22/});class oy extends ee{constructor({cause:t}){super("Paymaster for User Operation expired.",{cause:t,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(oy,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa32/});class ay extends ee{constructor({cause:t}){super("Signature provided for the User Operation is invalid.",{cause:t,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(ay,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa24/});class cy extends ee{constructor({cause:t}){super("Signature provided for the User Operation is invalid.",{cause:t,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(cy,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa34/});class Tf extends ee{constructor({cause:t}){super("User Operation rejected by EntryPoint's `simulateValidation` during account creation or validation.",{cause:t,name:"UserOperationRejectedByEntryPointError"})}}Object.defineProperty(Tf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32500});class Of extends ee{constructor({cause:t}){super("User Operation rejected by Paymaster's `validatePaymasterUserOp`.",{cause:t,name:"UserOperationRejectedByPaymasterError"})}}Object.defineProperty(Of,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32501});class Mf extends ee{constructor({cause:t}){super("User Operation rejected with op code validation error.",{cause:t,name:"UserOperationRejectedByOpCodeError"})}}Object.defineProperty(Mf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32502});class Bf extends ee{constructor({cause:t}){super("UserOperation out of time-range: either wallet or paymaster returned a time-range, and it is already expired (or will expire soon).",{cause:t,name:"UserOperationOutOfTimeRangeError"})}}Object.defineProperty(Bf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32503});class vj extends ee{constructor({cause:t}){super(`An error occurred while executing user operation: ${t==null?void 0:t.shortMessage}`,{cause:t,name:"UnknownBundlerError"})}}class uy extends ee{constructor({cause:t}){super("User Operation verification gas limit exceeded.",{cause:t,metaMessages:["This could arise when:","- the gas used for verification exceeded the `verificationGasLimit`"].filter(Boolean),name:"VerificationGasLimitExceededError"})}}Object.defineProperty(uy,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa40/});class ly extends ee{constructor({cause:t}){super("User Operation verification gas limit is too low.",{cause:t,metaMessages:["This could arise when:","- the `verificationGasLimit` is too low to verify the User Operation"].filter(Boolean),name:"VerificationGasLimitTooLowError"})}}Object.defineProperty(ly,"message",{enumerable:!0,configurable:!0,writable:!0,value:/aa41/});class _j extends ee{constructor(t,{callData:n,callGasLimit:r,docsPath:i,factory:s,factoryData:o,initCode:a,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:l,paymaster:d,paymasterAndData:f,paymasterData:h,paymasterPostOpGasLimit:m,paymasterVerificationGasLimit:y,preVerificationGas:w,sender:b,signature:E,verificationGasLimit:v}){const A=ha({callData:n,callGasLimit:r,factory:s,factoryData:o,initCode:a,maxFeePerGas:typeof c<"u"&&`${kn(c)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${kn(u)} gwei`,nonce:l,paymaster:d,paymasterAndData:f,paymasterData:h,paymasterPostOpGasLimit:m,paymasterVerificationGasLimit:y,preVerificationGas:w,sender:b,signature:E,verificationGasLimit:v});super(t.shortMessage,{cause:t,docsPath:i,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Request Arguments:",A].filter(Boolean),name:"UserOperationExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class Ej extends ee{constructor({hash:t}){super(`User Operation receipt with hash "${t}" could not be found. The User Operation may not have been processed yet.`,{name:"UserOperationReceiptNotFoundError"})}}class xj extends ee{constructor({hash:t}){super(`User Operation with hash "${t}" could not be found.`,{name:"UserOperationNotFoundError"})}}class yE extends ee{constructor({hash:t}){super(`Timed out while waiting for User Operation with hash "${t}" to be confirmed.`,{name:"WaitForUserOperationReceiptTimeoutError"})}}const Sj=[Oa,Af,fo,If,Cf,Pf,Rf,Bf,Tf,Of,Mf];function kj(e,t){const n=(e.details||"").toLowerCase();if(Ug.message.test(n))return new Ug({cause:e});if(Hg.message.test(n))return new Hg({cause:e});if(zg.message.test(n))return new zg({cause:e});if(Wg.message.test(n))return new Wg({cause:e});if(Gg.message.test(n))return new Gg({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(qg.message.test(n))return new qg({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(Vg.message.test(n))return new Vg({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode,sender:t.sender});if(Kg.message.test(n))return new Kg({cause:e});if(Jg.message.test(n))return new Jg({cause:e});if(Yg.message.test(n))return new Yg({cause:e,nonce:t.nonce});if(Zg.message.test(n))return new Zg({cause:e});if(Qg.message.test(n))return new Qg({cause:e});if(Xg.message.test(n))return new Xg({cause:e});if(fo.message.test(n))return new fo({cause:e});if(ey.message.test(n))return new ey({cause:e});if(ty.message.test(n))return new ty({cause:e});if(ny.message.test(n))return new ny({cause:e});if(iy.message.test(n))return new iy({cause:e});if(ry.message.test(n))return new ry({cause:e,factory:t.factory,factoryData:t.factoryData,initCode:t.initCode});if(sy.message.test(n))return new sy({cause:e});if(oy.message.test(n))return new oy({cause:e});if(cy.message.test(n))return new cy({cause:e});if(ay.message.test(n))return new ay({cause:e});if(uy.message.test(n))return new uy({cause:e});if(ly.message.test(n))return new ly({cause:e});const r=e.walk(i=>Sj.some(s=>s.code===i.code));if(r){if(r.code===Oa.code)return new Oa({cause:e,data:r.data,message:r.details});if(r.code===Af.code)return new Af({cause:e});if(r.code===fo.code)return new fo({cause:e});if(r.code===If.code)return new If({cause:e});if(r.code===Cf.code)return new Cf({cause:e});if(r.code===Pf.code)return new Pf({cause:e});if(r.code===Rf.code)return new Rf({cause:e});if(r.code===Bf.code)return new Bf({cause:e});if(r.code===Tf.code)return new Tf({cause:e});if(r.code===Of.code)return new Of({cause:e});if(r.code===Mf.code)return new Mf({cause:e})}return new vj({cause:e})}function bE(e,{calls:t,docsPath:n,...r}){const i=(()=>{const s=kj(e,r);if(t&&s instanceof Oa){const o=Aj(s),a=t==null?void 0:t.filter(c=>c.abi);if(o&&a.length>0)return Ij({calls:a,revertData:o})}return s})();return new _j(i,{docsPath:n,...r})}function Aj(e){let t;return e.walk(n=>{var i,s,o,a;const r=n;if(typeof r.data=="string"||typeof((i=r.data)==null?void 0:i.revertData)=="string"||!(r instanceof ee)&&typeof r.message=="string"){const c=(a=(o=((s=r.data)==null?void 0:s.revertData)||r.data||r.message).match)==null?void 0:a.call(o,/(0x[A-Za-z0-9]*)/);if(c)return t=c[1],!0}return!1}),t}function Ij(e){const{calls:t,revertData:n}=e,{abi:r,functionName:i,args:s,to:o}=(()=>{const c=t==null?void 0:t.filter(l=>!!l.abi);if(c.length===1)return c[0];const u=c.filter(l=>{try{return!!lp({abi:l.abi,data:n})}catch{return!1}});return u.length===1?u[0]:{abi:[],functionName:c.reduce((l,d)=>`${l?`${l} | `:""}${d.functionName}`,""),args:void 0,to:void 0}})(),a=n==="0x"?new Kv({functionName:i}):new hd({abi:r,data:n,functionName:i});return new fd(a,{abi:r,args:s,contractAddress:o,functionName:i})}function Cj(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}function Nf(e){const t={};return typeof e.callData<"u"&&(t.callData=e.callData),typeof e.callGasLimit<"u"&&(t.callGasLimit=ae(e.callGasLimit)),typeof e.factory<"u"&&(t.factory=e.factory),typeof e.factoryData<"u"&&(t.factoryData=e.factoryData),typeof e.initCode<"u"&&(t.initCode=e.initCode),typeof e.maxFeePerGas<"u"&&(t.maxFeePerGas=ae(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(t.maxPriorityFeePerGas=ae(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(t.nonce=ae(e.nonce)),typeof e.paymaster<"u"&&(t.paymaster=e.paymaster),typeof e.paymasterAndData<"u"&&(t.paymasterAndData=e.paymasterAndData||"0x"),typeof e.paymasterData<"u"&&(t.paymasterData=e.paymasterData),typeof e.paymasterPostOpGasLimit<"u"&&(t.paymasterPostOpGasLimit=ae(e.paymasterPostOpGasLimit)),typeof e.paymasterSignature<"u"&&(t.paymasterSignature=e.paymasterSignature),typeof e.paymasterVerificationGasLimit<"u"&&(t.paymasterVerificationGasLimit=ae(e.paymasterVerificationGasLimit)),typeof e.preVerificationGas<"u"&&(t.preVerificationGas=ae(e.preVerificationGas)),typeof e.sender<"u"&&(t.sender=e.sender),typeof e.signature<"u"&&(t.signature=e.signature),typeof e.verificationGasLimit<"u"&&(t.verificationGasLimit=ae(e.verificationGasLimit)),typeof e.authorization<"u"&&(t.eip7702Auth=Pj(e.authorization)),t}function Pj(e){return{address:e.address,chainId:ae(e.chainId),nonce:ae(e.nonce),r:e.r?ae(BigInt(e.r),{size:32}):Jt("0x",{size:32}),s:e.s?ae(BigInt(e.s),{size:32}):Jt("0x",{size:32}),yParity:e.yParity?ae(e.yParity,{size:1}):Jt("0x",{size:32})}}async function Rj(e,t){const{chainId:n,entryPointAddress:r,context:i,...s}=t,o=Nf(s),{paymasterPostOpGasLimit:a,paymasterVerificationGasLimit:c,...u}=await e.request({method:"pm_getPaymasterData",params:[{...o,callGasLimit:o.callGasLimit??"0x0",verificationGasLimit:o.verificationGasLimit??"0x0",preVerificationGas:o.preVerificationGas??"0x0"},r,ae(n),i]});return{...u,...a&&{paymasterPostOpGasLimit:Rt(a)},...c&&{paymasterVerificationGasLimit:Rt(c)}}}async function Tj(e,t){const{chainId:n,entryPointAddress:r,context:i,...s}=t,o=Nf(s),{paymasterPostOpGasLimit:a,paymasterVerificationGasLimit:c,...u}=await e.request({method:"pm_getPaymasterStubData",params:[{...o,callGasLimit:o.callGasLimit??"0x0",verificationGasLimit:o.verificationGasLimit??"0x0",preVerificationGas:o.preVerificationGas??"0x0"},r,ae(n),i]});return{...u,...a&&{paymasterPostOpGasLimit:Rt(a)},...c&&{paymasterVerificationGasLimit:Rt(c)}}}const Oj=["factory","fees","gas","paymaster","nonce","signature","authorization"];async function dy(e,t){var L,U;const n=t,{account:r=e.account,dataSuffix:i=typeof e.dataSuffix=="string"?e.dataSuffix:(L=e.dataSuffix)==null?void 0:L.value,parameters:s=Oj,stateOverride:o}=n;if(!r)throw new xa;const a=Ht(r),c=e,u=n.paymaster??(c==null?void 0:c.paymaster),l=typeof u=="string"?u:void 0,{getPaymasterStubData:d,getPaymasterData:f}=(()=>{if(u===!0)return{getPaymasterStubData:j=>_e(c,Tj,"getPaymasterStubData")(j),getPaymasterData:j=>_e(c,Rj,"getPaymasterData")(j)};if(typeof u=="object"){const{getPaymasterStubData:j,getPaymasterData:Z}=u;return{getPaymasterStubData:Z&&j?j:Z,getPaymasterData:Z&&j?Z:void 0}}return{getPaymasterStubData:void 0,getPaymasterData:void 0}})(),h=n.paymasterContext?n.paymasterContext:c==null?void 0:c.paymasterContext;let m={...n,paymaster:l,sender:a.address};const[y,w,b,E,v]=await Promise.all([(async()=>n.calls?a.encodeCalls(n.calls.map(j=>{const Z=j;return Z.abi?{data:$t(Z),to:Z.to,value:Z.value}:Z})):n.callData)(),(async()=>{if(!s.includes("factory"))return;if(n.initCode)return{initCode:n.initCode};if(n.factory&&n.factoryData)return{factory:n.factory,factoryData:n.factoryData};const{factory:j,factoryData:Z}=await a.getFactoryArgs();return a.entryPoint.version==="0.6"?{initCode:j&&Z?Yt([j,Z]):void 0}:{factory:j,factoryData:Z}})(),(async()=>{var j;if(s.includes("fees")){if(typeof n.maxFeePerGas=="bigint"&&typeof n.maxPriorityFeePerGas=="bigint")return m;if((j=c==null?void 0:c.userOperation)!=null&&j.estimateFeesPerGas){const Z=await c.userOperation.estimateFeesPerGas({account:a,bundlerClient:c,userOperation:m});return{...m,...Z}}try{const Z=c.client??e,Y=await _e(Z,z2,"estimateFeesPerGas")({chain:Z.chain,type:"eip1559"});return{maxFeePerGas:typeof n.maxFeePerGas=="bigint"?n.maxFeePerGas:BigInt(2n*Y.maxFeePerGas),maxPriorityFeePerGas:typeof n.maxPriorityFeePerGas=="bigint"?n.maxPriorityFeePerGas:BigInt(2n*Y.maxPriorityFeePerGas)}}catch{return}}})(),(async()=>{if(s.includes("nonce"))return typeof n.nonce=="bigint"?n.nonce:a.getNonce()})(),(async()=>{if(s.includes("authorization")){if(typeof n.authorization=="object")return n.authorization;if(a.authorization&&!await a.isDeployed())return{...await tB(a.client,a.authorization),r:"0xfffffffffffffffffffffffffffffff000000000000000000000000000000000",s:"0x7aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",yParity:1}}})()]);typeof y<"u"&&(m.callData=i?Yt([y,i]):y),typeof w<"u"&&(m={...m,...w}),typeof b<"u"&&(m={...m,...b}),typeof E<"u"&&(m.nonce=E),typeof v<"u"&&(m.authorization=v),s.includes("signature")&&(typeof n.signature<"u"?m.signature=n.signature:m.signature=await a.getStubSignature(m)),a.entryPoint.version==="0.6"&&!m.initCode&&(m.initCode="0x");let A;async function P(){return A||(e.chain?e.chain.id:(A=await _e(e,Xs,"getChainId")({}),A))}let M=!1;if(s.includes("paymaster")&&d&&!l&&!n.paymasterAndData){const{isFinal:j=!1,sponsor:Z,...Y}=await d({chainId:await P(),entryPointAddress:a.entryPoint.address,context:h,...m});M=j,m={...m,...Y}}if(a.entryPoint.version==="0.6"&&!m.paymasterAndData&&(m.paymasterAndData="0x"),s.includes("gas")){if((U=a.userOperation)!=null&&U.estimateGas){const j=await a.userOperation.estimateGas(m);m={...m,...j}}if(typeof m.callGasLimit>"u"||typeof m.preVerificationGas>"u"||typeof m.verificationGasLimit>"u"||m.paymaster&&typeof m.paymasterPostOpGasLimit>"u"||m.paymaster&&typeof m.paymasterVerificationGasLimit>"u"){const j=await _e(c,wE,"estimateUserOperationGas")({account:a,callGasLimit:0n,preVerificationGas:0n,verificationGasLimit:0n,stateOverride:o,...m.paymaster?{paymasterPostOpGasLimit:0n,paymasterVerificationGasLimit:0n}:{},...m});m={...m,callGasLimit:m.callGasLimit??j.callGasLimit,preVerificationGas:m.preVerificationGas??j.preVerificationGas,verificationGasLimit:m.verificationGasLimit??j.verificationGasLimit,paymasterPostOpGasLimit:m.paymasterPostOpGasLimit??j.paymasterPostOpGasLimit,paymasterVerificationGasLimit:m.paymasterVerificationGasLimit??j.paymasterVerificationGasLimit}}}if(s.includes("paymaster")&&f&&!l&&!n.paymasterAndData&&!M){const j=await f({chainId:await P(),entryPointAddress:a.entryPoint.address,context:h,...m});m={...m,...j}}return delete m.calls,delete m.parameters,delete m.paymasterContext,typeof m.paymaster!="string"&&delete m.paymaster,m}async function wE(e,t){var c;const{account:n=e.account,entryPointAddress:r,stateOverride:i}=t;if(!n&&!t.sender)throw new xa;const s=n?Ht(n):void 0,o=Ed(i),a=s?await _e(e,dy,"prepareUserOperation")({...t,parameters:["authorization","factory","nonce","paymaster","signature"]}):t;try{const u=[Nf(a),r??((c=s==null?void 0:s.entryPoint)==null?void 0:c.address)],l=await e.request({method:"eth_estimateUserOperationGas",params:o?[...u,o]:[...u]});return Cj(l)}catch(u){const l=t.calls;throw bE(u,{...a,...l?{calls:l}:{}})}}function Mj(e){return e.request({method:"eth_supportedEntryPoints"})}function Bj(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 Nj(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationByHash",params:[t]},{dedupe:!0});if(!n)throw new xj({hash:t});const{blockHash:r,blockNumber:i,entryPoint:s,transactionHash:o,userOperation:a}=n;return{blockHash:r,blockNumber:BigInt(i),entryPoint:s,transactionHash:o,userOperation:Bj(a)}}function Lj(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(n=>Rr(n))),e.receipt&&(t.receipt=Pd(t.receipt)),t}async function vE(e,{hash:t}){const n=await e.request({method:"eth_getUserOperationReceipt",params:[t]},{dedupe:!0});if(!n)throw new Ej({hash:t});return Lj(n)}async function jj(e,t){var c,u;const{account:n=e.account,entryPointAddress:r}=t;if(!n&&!t.sender)throw new xa;const i=n?Ht(n):void 0,s=i?await _e(e,dy,"prepareUserOperation")(t):t,o=t.signature||await((c=i==null?void 0:i.signUserOperation)==null?void 0:c.call(i,s)),a=Nf({...s,signature:o});try{return await e.request({method:"eth_sendUserOperation",params:[a,r??((u=i==null?void 0:i.entryPoint)==null?void 0:u.address)]},{retryCount:0})}catch(l){const d=t.calls;throw bE(l,{...s,...d?{calls:d}:{},signature:o})}}function $j(e,t){const{hash:n,pollingInterval:r=e.pollingInterval,retryCount:i,timeout:s=12e4}=t;let o=0;const a=zt(["waitForUserOperationReceipt",e.uid,n]);return new Promise((c,u)=>{const l=Vr(a,{resolve:c,reject:u},d=>{const f=y=>{m(),y(),l()},h=s?setTimeout(()=>f(()=>d.reject(new yE({hash:n}))),s):void 0,m=no(async()=>{i&&o>=i&&(clearTimeout(h),f(()=>d.reject(new yE({hash:n}))));try{const y=await _e(e,vE,"getUserOperationReceipt")({hash:n});clearTimeout(h),f(()=>d.resolve(y))}catch(y){const w=y;w.name!=="UserOperationReceiptNotFoundError"&&(clearTimeout(h),f(()=>d.reject(w)))}o++},{emitOnBegin:!0,interval:r});return m})})}function Fj(e){return{estimateUserOperationGas:t=>wE(e,t),getChainId:()=>Xs(e),getSupportedEntryPoints:()=>Mj(e),getUserOperation:t=>Nj(e,t),getUserOperationReceipt:t=>vE(e,t),prepareUserOperation:t=>dy(e,t),sendUserOperation:t=>jj(e,t),waitForUserOperationReceipt:t=>$j(e,t)}}function Dj(e){const{client:t,dataSuffix:n,key:r="bundler",name:i="Bundler Client",paymaster:s,paymasterContext:o,transport:a,userOperation:c}=e;return Object.assign(zd({...e,chain:e.chain??(t==null?void 0:t.chain),key:r,name:i,transport:a,type:"bundlerClient"}),{client:t,dataSuffix:n??(t==null?void 0:t.dataSuffix),paymaster:s,paymasterContext:o,userOperation:c}).extend(Fj)}const Uj="0.1.1";function Hj(){return Uj}class Mt extends Error{constructor(t,n={}){const r=(()=>{var c;if(n.cause instanceof Mt){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return(c=n.cause)!=null&&c.message?n.cause.message:n.details})(),i=n.cause instanceof Mt&&n.cause.docsPath||n.docsPath,o=`https://oxlib.sh${i??""}`,a=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||i?["",r?`Details: ${r}`:void 0,i?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`