@ffaerber/swarm-connect 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -18
- package/dist/components/SwarmConnectButton.d.ts +1 -1
- package/dist/components/SwarmConnectModal.d.ts +5 -4
- package/dist/components/steps.d.ts +1 -2
- package/dist/constants.d.ts +6 -3
- package/dist/hooks/useBeeNode.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/swarm-connect.js +804 -775
- package/dist/swarm-connect.umd.cjs +12 -12
- package/dist/types.d.ts +24 -7
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(W,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("wagmi"),require("viem"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","react","wagmi","viem","@tanstack/react-query"],m):(W=typeof globalThis<"u"?globalThis:W||self,m(W.SwarmConnect={},W.React,W.wagmi,W.viem,W.ReactQuery))})(this,function(W,m,O,E,ze){"use strict";var we={exports:{}},ne={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var We;function bt(){if(We)return ne;We=1;var n=m,r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function h(p,u,o){var l,g={},v=null,y=null;o!==void 0&&(v=""+o),u.key!==void 0&&(v=""+u.key),u.ref!==void 0&&(y=u.ref);for(l in u)s.call(u,l)&&!d.hasOwnProperty(l)&&(g[l]=u[l]);if(p&&p.defaultProps)for(l in u=p.defaultProps,u)g[l]===void 0&&(g[l]=u[l]);return{$$typeof:r,type:p,key:v,ref:y,props:g,_owner:i.current}}return ne.Fragment=a,ne.jsx=h,ne.jsxs=h,ne}var re={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Le;function
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),P=b.length-1,D=
|
|
21
|
-
`+b[P].replace(" at new "," at ");return e.displayName&&U.includes("<anonymous>")&&(U=U.replace("<anonymous>",e.displayName)),typeof e=="function"&&
|
|
17
|
+
*/var Le;function yt(){return Le||(Le=1,process.env.NODE_ENV!=="production"&&function(){var n=m,r=Symbol.for("react.element"),a=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),p=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),o=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),I=Symbol.iterator,T="@@iterator";function z(e){if(e===null||typeof e!="object")return null;var c=I&&e[I]||e[T];return typeof c=="function"?c:null}var C=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function k(e){{for(var c=arguments.length,f=new Array(c>1?c-1:0),x=1;x<c;x++)f[x-1]=arguments[x];F("error",e,f)}}function F(e,c,f){{var x=C.ReactDebugCurrentFrame,S=x.getStackAddendum();S!==""&&(c+="%s",f=f.concat([S]));var R=f.map(function(w){return String(w)});R.unshift("Warning: "+c),Function.prototype.apply.call(console[e],console,R)}}var _=!1,j=!1,L=!1,q=!1,Q=!1,N;N=Symbol.for("react.module.reference");function ie(e){return!!(typeof e=="string"||typeof e=="function"||e===s||e===d||Q||e===i||e===o||e===l||q||e===y||_||j||L||typeof e=="object"&&e!==null&&(e.$$typeof===v||e.$$typeof===g||e.$$typeof===h||e.$$typeof===p||e.$$typeof===u||e.$$typeof===N||e.getModuleId!==void 0))}function ce(e,c,f){var x=e.displayName;if(x)return x;var S=c.displayName||c.name||"";return S!==""?f+"("+S+")":f}function le(e){return e.displayName||"Context"}function Y(e){if(e==null)return null;if(typeof e.tag=="number"&&k("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case s:return"Fragment";case a:return"Portal";case d:return"Profiler";case i:return"StrictMode";case o:return"Suspense";case l:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var c=e;return le(c)+".Consumer";case h:var f=e;return le(f._context)+".Provider";case u:return ce(e,e.render,"ForwardRef");case g:var x=e.displayName||null;return x!==null?x:Y(e.type)||"Memo";case v:{var S=e,R=S._payload,w=S._init;try{return Y(w(R))}catch{return null}}}return null}var H=Object.assign,V=0,ve,A,de,Qe,et,tt,nt;function rt(){}rt.__reactDisabledLog=!0;function $t(){{if(V===0){ve=console.log,A=console.info,de=console.warn,Qe=console.error,et=console.group,tt=console.groupCollapsed,nt=console.groupEnd;var e={configurable:!0,enumerable:!0,value:rt,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}V++}}function Jt(){{if(V--,V===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:H({},e,{value:ve}),info:H({},e,{value:A}),warn:H({},e,{value:de}),error:H({},e,{value:Qe}),group:H({},e,{value:et}),groupCollapsed:H({},e,{value:tt}),groupEnd:H({},e,{value:nt})})}V<0&&k("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var _e=C.ReactCurrentDispatcher,Ie;function xe(e,c,f){{if(Ie===void 0)try{throw Error()}catch(S){var x=S.stack.trim().match(/\n( *(at )?)/);Ie=x&&x[1]||""}return`
|
|
18
|
+
`+Ie+e}}var Te=!1,me;{var Xt=typeof WeakMap=="function"?WeakMap:Map;me=new Xt}function at(e,c){if(!e||Te)return"";{var f=me.get(e);if(f!==void 0)return f}var x;Te=!0;var S=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var R;R=_e.current,_e.current=null,$t();try{if(c){var w=function(){throw Error()};if(Object.defineProperty(w.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(w,[])}catch(M){x=M}Reflect.construct(e,[],w)}else{try{w.call()}catch(M){x=M}e.call(w.prototype)}}else{try{throw Error()}catch(M){x=M}e()}}catch(M){if(M&&x&&typeof M.stack=="string"){for(var b=M.stack.split(`
|
|
19
|
+
`),B=x.stack.split(`
|
|
20
|
+
`),P=b.length-1,D=B.length-1;P>=1&&D>=0&&b[P]!==B[D];)D--;for(;P>=1&&D>=0;P--,D--)if(b[P]!==B[D]){if(P!==1||D!==1)do if(P--,D--,D<0||b[P]!==B[D]){var U=`
|
|
21
|
+
`+b[P].replace(" at new "," at ");return e.displayName&&U.includes("<anonymous>")&&(U=U.replace("<anonymous>",e.displayName)),typeof e=="function"&&me.set(e,U),U}while(P>=1&&D>=0);break}}}finally{Te=!1,_e.current=R,Jt(),Error.prepareStackTrace=S}var te=e?e.displayName||e.name:"",$=te?xe(te):"";return typeof e=="function"&&me.set(e,$),$}function Qt(e,c,f){return at(e,!1)}function en(e){var c=e.prototype;return!!(c&&c.isReactComponent)}function be(e,c,f){if(e==null)return"";if(typeof e=="function")return at(e,en(e));if(typeof e=="string")return xe(e);switch(e){case o:return xe("Suspense");case l:return xe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case u:return Qt(e.render);case g:return be(e.type,c,f);case v:{var x=e,S=x._payload,R=x._init;try{return be(R(S),c,f)}catch{}}}return""}var ue=Object.prototype.hasOwnProperty,ot={},st=C.ReactDebugCurrentFrame;function ye(e){if(e){var c=e._owner,f=be(e.type,e._source,c?c.type:null);st.setExtraStackFrame(f)}else st.setExtraStackFrame(null)}function tn(e,c,f,x,S){{var R=Function.call.bind(ue);for(var w in e)if(R(e,w)){var b=void 0;try{if(typeof e[w]!="function"){var B=Error((x||"React class")+": "+f+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw B.name="Invariant Violation",B}b=e[w](c,w,x,f,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(P){b=P}b&&!(b instanceof Error)&&(ye(S),k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",x||"React class",f,w,typeof b),ye(null)),b instanceof Error&&!(b.message in ot)&&(ot[b.message]=!0,ye(S),k("Failed %s type: %s",f,b.message),ye(null))}}}var nn=Array.isArray;function Fe(e){return nn(e)}function rn(e){{var c=typeof Symbol=="function"&&Symbol.toStringTag,f=c&&e[Symbol.toStringTag]||e.constructor.name||"Object";return f}}function an(e){try{return it(e),!1}catch{return!0}}function it(e){return""+e}function ct(e){if(an(e))return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",rn(e)),it(e)}var lt=C.ReactCurrentOwner,on={key:!0,ref:!0,__self:!0,__source:!0},dt,ut;function sn(e){if(ue.call(e,"ref")){var c=Object.getOwnPropertyDescriptor(e,"ref").get;if(c&&c.isReactWarning)return!1}return e.ref!==void 0}function cn(e){if(ue.call(e,"key")){var c=Object.getOwnPropertyDescriptor(e,"key").get;if(c&&c.isReactWarning)return!1}return e.key!==void 0}function ln(e,c){typeof e.ref=="string"&<.current}function dn(e,c){{var f=function(){dt||(dt=!0,k("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",c))};f.isReactWarning=!0,Object.defineProperty(e,"key",{get:f,configurable:!0})}}function un(e,c){{var f=function(){ut||(ut=!0,k("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",c))};f.isReactWarning=!0,Object.defineProperty(e,"ref",{get:f,configurable:!0})}}var fn=function(e,c,f,x,S,R,w){var b={$$typeof:r,type:e,key:c,ref:f,props:w,_owner:R};return b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(b,"_self",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.defineProperty(b,"_source",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b};function hn(e,c,f,x,S){{var R,w={},b=null,B=null;f!==void 0&&(ct(f),b=""+f),cn(c)&&(ct(c.key),b=""+c.key),sn(c)&&(B=c.ref,ln(c,S));for(R in c)ue.call(c,R)&&!on.hasOwnProperty(R)&&(w[R]=c[R]);if(e&&e.defaultProps){var P=e.defaultProps;for(R in P)w[R]===void 0&&(w[R]=P[R])}if(b||B){var D=typeof e=="function"?e.displayName||e.name||"Unknown":e;b&&dn(w,D),B&&un(w,D)}return fn(e,b,B,S,x,lt.current,w)}}var Pe=C.ReactCurrentOwner,ft=C.ReactDebugCurrentFrame;function ee(e){if(e){var c=e._owner,f=be(e.type,e._source,c?c.type:null);ft.setExtraStackFrame(f)}else ft.setExtraStackFrame(null)}var De;De=!1;function Ae(e){return typeof e=="object"&&e!==null&&e.$$typeof===r}function ht(){{if(Pe.current){var e=Y(Pe.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function pn(e){return""}var pt={};function gn(e){{var c=ht();if(!c){var f=typeof e=="string"?e:e.displayName||e.name;f&&(c=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+f+">.")}return c}}function gt(e,c){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var f=
|
|
25
|
+
Check the top-level render call using <`+f+">.")}return c}}function gt(e,c){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var f=gn(c);if(pt[f])return;pt[f]=!0;var x="";e&&e._owner&&e._owner!==Pe.current&&(x=" It was passed a child from "+Y(e._owner.type)+"."),ee(e),k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',f,x),ee(null)}}function vt(e,c){{if(typeof e!="object")return;if(Fe(e))for(var f=0;f<e.length;f++){var x=e[f];Ae(x)&>(x,c)}else if(Ae(e))e._store&&(e._store.validated=!0);else if(e){var S=z(e);if(typeof S=="function"&&S!==e.entries)for(var R=S.call(e),w;!(w=R.next()).done;)Ae(w.value)&>(w.value,c)}}}function vn(e){{var c=e.type;if(c==null||typeof c=="string")return;var f;if(typeof c=="function")f=c.propTypes;else if(typeof c=="object"&&(c.$$typeof===u||c.$$typeof===g))f=c.propTypes;else return;if(f){var x=Y(c);tn(f,e.props,"prop",x,e)}else if(c.PropTypes!==void 0&&!De){De=!0;var S=Y(c);k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",S||"Unknown")}typeof c.getDefaultProps=="function"&&!c.getDefaultProps.isReactClassApproved&&k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xn(e){{for(var c=Object.keys(e.props),f=0;f<c.length;f++){var x=c[f];if(x!=="children"&&x!=="key"){ee(e),k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",x),ee(null);break}}e.ref!==null&&(ee(e),k("Invalid attribute `ref` supplied to `React.Fragment`."),ee(null))}}var xt={};function mt(e,c,f,x,S,R){{var w=ie(e);if(!w){var b="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(b+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var B=pn();B?b+=B:b+=ht();var P;e===null?P="null":Fe(e)?P="array":e!==void 0&&e.$$typeof===r?(P="<"+(Y(e.type)||"Unknown")+" />",b=" Did you accidentally export a JSX literal instead of a component?"):P=typeof e,k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",P,b)}var D=hn(e,c,f,S,R);if(D==null)return D;if(w){var U=c.children;if(U!==void 0)if(x)if(Fe(U)){for(var te=0;te<U.length;te++)vt(U[te],e);Object.freeze&&Object.freeze(U)}else k("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else vt(U,e)}if(ue.call(c,"key")){var $=Y(e),M=Object.keys(c).filter(function(jn){return jn!=="key"}),Oe=M.length>0?"{key: someKey, "+M.join(": ..., ")+": ...}":"{key: someKey}";if(!xt[$+Oe]){var kn=M.length>0?"{"+M.join(": ..., ")+": ...}":"{}";k(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,
|
|
30
|
+
<%s key={someKey} {...props} />`,Oe,$,kn,$),xt[$+Oe]=!0}}return e===s?xn(D):vn(D),D}}function mn(e,c,f){return mt(e,c,f,!0)}function bn(e,c,f){return mt(e,c,f,!1)}var yn=bn,wn=mn;re.Fragment=s,re.jsx=yn,re.jsxs=wn}()),re}process.env.NODE_ENV==="production"?we.exports=bt():we.exports=yt();var t=we.exports;const Z=100,ae="http://localhost:1633",Be="swarm-connect:bee-api-url",Me="0xdBF3Ea6F5beE45c02255B2c26a16F300502F68da",ke=16,wt="0.1",kt="0.5",Ue={xdai:!0,xbzz:!1,postageStamp:!0};function Ne(n=ae){const[r,a]=m.useState({isRunning:!1,isChecking:!1}),s=m.useCallback(async()=>{a({isRunning:!1,isChecking:!0});try{const d=await fetch(`${n}/health`,{signal:AbortSignal.timeout(5e3)});if(d.ok){const h=await d.json();a({isRunning:!0,isChecking:!1,version:h.version})}else a({isRunning:!1,isChecking:!1,error:`Node returned HTTP ${d.status}`})}catch{a({isRunning:!1,isChecking:!1,error:`Cannot reach Bee node at ${n}`})}},[n]),i=m.useCallback(()=>{a({isRunning:!1,isChecking:!1})},[]);return{...r,check:s,disconnect:i}}function Ye(n=ae){const[r,a]=m.useState([]),[s,i]=m.useState(!1),[d,h]=m.useState(),[p,u]=m.useState(),[o,l]=m.useState(!1),[g,v]=m.useState(),y=m.useCallback(async()=>{i(!0),h(void 0);try{const T=await fetch(`${n}/stamps`,{signal:AbortSignal.timeout(5e3)});if(T.ok){const z=await T.json();a(z.stamps??[])}else h(`HTTP ${T.status}`)}catch{h("Could not fetch postage stamps")}finally{i(!1)}},[n]),I=m.useCallback(async({amount:T,depth:z,label:C})=>{l(!0),v(void 0);try{const k=C?`?label=${encodeURIComponent(C)}`:"",F=await fetch(`${n}/stamps/${T}/${z}${k}`,{method:"POST",signal:AbortSignal.timeout(24e4)});if(!F.ok){let j=`HTTP ${F.status}`;try{const L=await F.json();L.message&&(j=L.message)}catch{}v(j);return}const _=await F.json();return u(_.batchID),y(),_.batchID}catch{v("Stamp purchase failed — is the node wallet funded with xDAI and xBZZ?");return}finally{l(!1)}},[n,y]);return{stamps:r,isLoading:s,error:d,fetchStamps:y,selectedStampId:p,selectStamp:u,createStamp:I,isCreating:o,createError:g}}function je(n=ae){const[r,a]=m.useState({isLoading:!1}),s=m.useCallback(async()=>{a(i=>({...i,isLoading:!0,error:void 0}));try{const[i,d]=await Promise.all([fetch(`${n}/addresses`,{signal:AbortSignal.timeout(5e3)}),fetch(`${n}/wallet`,{signal:AbortSignal.timeout(5e3)})]);if(!i.ok||!d.ok){a(l=>({...l,isLoading:!1,error:`Node returned HTTP ${i.ok?d.status:i.status}`}));return}const h=await i.json(),p=await d.json(),u=p.bzzBalance??p.bzz,o=p.nativeTokenBalance??p.xDai;a({address:h.ethereum,xdai:o!==void 0?Number(o)/1e18:void 0,xbzz:u!==void 0?Number(u)/10**ke:void 0,isLoading:!1})}catch{a(i=>({...i,isLoading:!1,error:`Cannot read node wallet at ${n}`}))}},[n]);return{...r,isFunded:(r.xdai??0)>0&&(r.xbzz??0)>0,refresh:s}}function jt(){if(!(typeof window>"u"))try{return window.localStorage.getItem(Be)??void 0}catch{return}}function Ge(n={}){const[r,a]=m.useState(()=>n.beeApiUrl??jt()??ae);m.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Be,r)}catch{}},[r]);const s={...Ue,...n.requirements},i=Ne(r),d=Ye(r),h=je(r),{address:p,isConnected:u,chainId:o}=O.useAccount(),l=u&&o===Z,{data:g,isLoading:v}=O.useBalance({address:p,chainId:Z,query:{enabled:u}}),y=g?Number(g.formatted):void 0,I=l&&!!g&&g.value>0n;return{beeNode:i,stamps:d,beeApiUrl:r,setBeeApiUrl:a,requirements:s,nodeWallet:h,isWalletConnected:u,address:p,isOnGnosis:l,chainId:o,balance:{xdai:y,isLoading:u&&v,hasGas:I},isFullyConnected:u&&l&&i.isRunning&&(!s.xdai||I)&&(!s.xbzz||h.isFunded)&&(!s.postageStamp||!!d.selectedStampId)}}const St=`
|
|
31
31
|
.swarm-connect {
|
|
32
32
|
--void:#060809; --bunker:#0b0f12; --surface:#121821; --raised:#18202b; --raised-2:#1e2833;
|
|
33
33
|
--line:rgba(255,255,255,0.07); --line-2:rgba(255,255,255,0.12); --line-orange:rgba(255,107,0,0.45);
|
|
@@ -50,5 +50,5 @@ React keys must be passed directly to JSX without using spread:
|
|
|
50
50
|
.sc-scroll::-webkit-scrollbar { width:8px; }
|
|
51
51
|
.sc-scroll::-webkit-scrollbar-thumb { background:var(--line-2); border-radius:8px; border:2px solid transparent; background-clip:padding-box; }
|
|
52
52
|
.sc-scroll::-webkit-scrollbar-track { background:transparent; }
|
|
53
|
-
`;let Ye=!1;function Ge(){if(Ye||typeof document>"u")return;Ye=!0;const n=document.createElement("style");n.dataset.swarmConnect="",n.textContent=Et,document.head.appendChild(n)}function _t({size:n=18,stroke:r="var(--accent)",glow:a=!0,children:i}){return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",filter:a?"drop-shadow(0 0 6px var(--accent-glow))":"none"},children:t.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round",children:i})})}function oe({size:n=15}){return t.jsx("span",{style:{width:n,height:n,flexShrink:0,display:"inline-block",border:"2px solid rgba(255,255,255,.12)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"sc-spin .7s linear infinite"}})}function se({children:n,tone:r}){const a={ok:{c:"var(--ok)",b:"var(--ok-line)",w:"var(--ok-wash)"},bad:{c:"var(--bad)",b:"var(--bad-line)",w:"var(--bad-wash)"},warn:{c:"var(--warn)",b:"var(--warn-line)",w:"var(--warn-wash)"}}[r];return t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:".04em",textTransform:"uppercase",color:a.c,background:a.w,border:`1px solid ${a.b}`,borderRadius:3,padding:"2px 6px",lineHeight:1.3},children:n})}function V({tone:n,title:r,sub:a,children:i}){const s={ok:{b:"var(--ok-line)",w:"var(--ok-wash)",d:"var(--ok)"},bad:{b:"var(--bad-line)",w:"var(--bad-wash)",d:"var(--bad)"},warn:{b:"var(--warn-line)",w:"var(--warn-wash)",d:"var(--warn)"},flat:{b:"var(--line)",w:"var(--raised)",d:"var(--fg-muted)"}}[n],l=!!a&&(a.startsWith("0x")||a.includes("localhost")||a.includes("http"));return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:`1px solid ${s.b}`,borderRadius:8,background:s.w},children:[n!=="flat"&&t.jsx("span",{style:{width:8,height:8,flexShrink:0,borderRadius:"50%",background:s.d,boxShadow:`0 0 8px ${s.d}`,animation:n==="warn"?"sc-pulse-dot 1.6s var(--ease) infinite":"none"}}),t.jsxs("div",{style:{minWidth:0},children:[r&&t.jsx("div",{style:{fontWeight:600,fontSize:13.5,color:n==="flat"?"var(--fg-soft)":s.d},children:r}),a&&t.jsx("div",{style:{fontSize:12,color:"var(--fg-muted)",marginTop:2,fontFamily:l?"var(--font-mono)":"inherit",wordBreak:"break-all"},children:a})]}),i&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0},children:i})]})}function Z({children:n,onClick:r,disabled:a}){const[i,s]=m.useState(!1);return t.jsx("button",{onClick:r,disabled:a,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{fontFamily:"var(--font-mono)",fontSize:12,letterSpacing:".04em",background:"transparent",border:`1px solid ${i&&!a?"var(--line-orange)":"var(--line-2)"}`,color:a?"var(--fg-faint)":i?"var(--accent-bright)":"var(--fg-soft)",borderRadius:4,padding:"7px 14px",cursor:a?"default":"pointer",transition:"all .15s var(--ease)",opacity:a?.5:1},children:n})}function we({children:n,onClick:r,pending:a,block:i,style:s}){const[l,p]=m.useState(!1);return t.jsx("button",{onClick:r,disabled:a,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8,fontFamily:"var(--font-mono)",fontSize:13,fontWeight:600,letterSpacing:".06em",textTransform:"uppercase",width:i?"100%":"auto",background:"var(--accent)",color:"var(--accent-ink)",border:"none",borderRadius:4,padding:"11px 20px",cursor:a?"default":"pointer",boxShadow:l?"0 0 24px var(--accent-glow)":"0 0 14px var(--accent-glow)",transform:l?"translateY(-1px)":"none",transition:"all .15s var(--ease)",opacity:a?.8:1,whiteSpace:"nowrap",...s},children:n})}function J({children:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",border:"1px dashed var(--line-2)",borderRadius:8,background:"var(--bunker)"},children:[t.jsxs(_t,{size:15,stroke:"var(--fg-faint)",glow:!1,children:[t.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"1.5"}),t.jsx("path",{d:"M8 11V8a4 4 0 0 1 8 0v3"})]}),t.jsx("span",{style:{fontSize:12.5,color:"var(--fg-muted)"},children:n})]})}function X({step:n,state:r,children:a,hint:i}){const s=r==="done",l=r==="locked";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:12},children:[t.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,flexShrink:0,fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,lineHeight:1,color:s?"var(--ok)":l?"var(--fg-faint)":"var(--accent-ink)",background:s?"var(--ok-wash)":l?"transparent":"var(--accent)",border:s?"1px solid var(--ok-line)":l?"1px solid var(--line-2)":"none",clipPath:"polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%)",boxShadow:!s&&!l?"0 0 14px var(--accent-glow)":"none"},children:s?"✓":n}),t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:".18em",color:l?"var(--fg-faint)":"var(--fg-soft)"},children:a}),i&&t.jsx("span",{style:{marginLeft:"auto",fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:".06em",color:"var(--fg-faint)"},children:i})]})}function It({size:n=30}){return t.jsx("span",{style:{width:n,height:n,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--accent)",color:"var(--accent-ink)",clipPath:"polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%)",boxShadow:"0 0 18px var(--accent-glow)"},children:t.jsxs("svg",{width:n*.56,height:n*.56,viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-ink)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("ellipse",{cx:"12",cy:"14",rx:"5",ry:"6.5"}),t.jsx("path",{d:"M7 12h10M7 16h10M12 7.5V4M12 4l-2.5-1.5M12 4l2.5-1.5"})]})})}function Tt({states:n}){return t.jsx("span",{style:{display:"inline-flex",gap:5},children:n.map((r,a)=>t.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:r?"var(--ok)":"var(--line-2)",boxShadow:r?"0 0 8px var(--ok)":"none",transition:"all .2s"}},a))})}function Ft(n){const r={formatters:void 0,fees:void 0,serializers:void 0,...n};function a(i){return s=>{const l=typeof s=="function"?s(i):s,p={...i,...l};return Object.assign(p,{extend:a(p)})}}return Object.assign(r,{extend:a(r)})}const ke=Ft({id:100,name:"Gnosis",nativeCurrency:{decimals:18,name:"xDAI",symbol:"XDAI"},blockTime:5e3,rpcUrls:{default:{http:["https://rpc.gnosischain.com"],webSocket:["wss://rpc.gnosischain.com/wss"]}},blockExplorers:{default:{name:"Gnosisscan",url:"https://gnosisscan.io",apiUrl:"https://api.gnosisscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:21022491}}});function He(n){if(n)return n.shortMessage??n.message}function Pt({name:n,icon:r,pending:a,disabled:i,onClick:s}){const[l,p]=m.useState(!1);return t.jsxs("button",{onClick:s,disabled:i||a,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{display:"flex",alignItems:"center",gap:12,width:"100%",textAlign:"left",padding:"11px 13px",borderRadius:8,cursor:i?"default":"pointer",opacity:i?.45:1,border:`1px solid ${l&&!i?"var(--line-orange)":"var(--line)"}`,background:l&&!i?"var(--raised-2)":"var(--raised)",transition:"all .15s var(--ease)"},children:[t.jsx("span",{style:{width:30,height:30,flexShrink:0,borderRadius:7,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--bunker)",border:"1px solid var(--line-2)",color:"var(--accent-bright)",overflow:"hidden",fontFamily:"var(--font-display)",fontWeight:700,fontSize:15},children:r?t.jsx("img",{src:r,width:30,height:30,alt:"",style:{borderRadius:7}}):n.charAt(0)}),t.jsx("span",{style:{flex:1,fontSize:14,fontWeight:500,color:"var(--fg)"},children:n}),a?t.jsx(oe,{size:14}):t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:16,color:l&&!i?"var(--accent)":"var(--fg-faint)",transition:"color .15s"},children:"→"})]})}function Dt({isConnected:n,address:r}){const{connectors:a,connect:i,isPending:s,variables:l,error:p}=O.useConnect(),{disconnect:h}=O.useDisconnect();if(n)return t.jsx(V,{tone:"ok",title:"Wallet connected",sub:r,children:t.jsx(Z,{onClick:()=>h(),children:"disconnect"})});const d=s&&l!=null&&l.connector&&"uid"in l.connector?l.connector.uid:void 0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[a.map(o=>t.jsx(Pt,{name:o.name,icon:o.icon,pending:d===o.uid,disabled:s&&d!==o.uid,onClick:()=>i({connector:o})},o.uid)),p&&t.jsx("div",{style:{fontSize:12,color:"var(--bad)",fontFamily:"var(--font-mono)"},children:p.message})]})}function At({locked:n,isOnGnosis:r,chainId:a}){const{switchChain:i,isPending:s}=O.useSwitchChain();return n?t.jsx(J,{children:"Connect a wallet to verify it is on the Gnosis chain."}):r?t.jsx(V,{tone:"ok",title:"Gnosis chain",sub:`chain id ${H}`,children:t.jsx(se,{tone:"ok",children:"synced"})}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(V,{tone:"warn",title:"Wrong network",sub:`chain ${a??"—"} active — Gnosis (${H}) required`}),t.jsx(we,{onClick:()=>i({chainId:ke.id}),pending:s,block:!0,children:s?"switching…":"switch to Gnosis"})]})}function je({symbol:n,role:r,amount:a,loading:i}){const s=!i&&a===0,l=s?"var(--warn)":"var(--ok)",p=s?"var(--warn-line)":"var(--ok-line)",h=s?"var(--warn-wash)":"var(--ok-wash)";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:`1px solid ${i?"var(--line)":p}`,borderRadius:8,background:i?"var(--raised)":h},children:[i?t.jsx(oe,{size:14}):t.jsx("span",{style:{width:8,height:8,flexShrink:0,borderRadius:"50%",background:l,boxShadow:`0 0 8px ${l}`,animation:s?"sc-pulse-dot 1.6s var(--ease) infinite":"none"}}),t.jsxs("div",{style:{minWidth:0},children:[t.jsx("div",{style:{fontWeight:600,fontSize:13.5,color:i?"var(--fg-soft)":l},children:n}),t.jsx("div",{style:{fontSize:12,color:"var(--fg-muted)",marginTop:2},children:r})]}),t.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[!i&&t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13.5,fontWeight:500,color:s?"var(--warn)":"var(--fg)"},children:a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:4})}),!i&&t.jsx(se,{tone:s?"warn":"ok",children:s?"empty":"ok"})]})]})}function Ot({locked:n,balance:r}){if(n)return t.jsx(J,{children:"Switch to the Gnosis chain to read your wallet's xDAI balance."});const a=r.xdai??0,i=!r.isLoading&&a===0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx(je,{symbol:"xDAI",role:"gas for transactions from this wallet",amount:a,loading:r.isLoading}),t.jsx("div",{style:ie,children:"Your connected wallet signs and pays gas for its own transactions — separate from the wallet running your Bee node."}),i&&t.jsx(we,{onClick:()=>window.open("https://www.gnosisfaucet.com","_blank","noopener"),block:!0,children:"get xDAI"})]})}function zt({value:n,disabled:r,onSubmit:a}){const[i,s]=m.useState(n),[l,p]=m.useState(!1);m.useEffect(()=>{s(n)},[n]);const h=i.trim().replace(/\/+$/,""),d=h!==n&&h.length>0,o=()=>{d&&a(h)};return t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"0 12px",borderRadius:6,border:`1px solid ${l?"var(--line-orange)":"var(--line-2)"}`,background:r?"var(--bunker)":"var(--surface)",boxShadow:l?"0 0 0 3px var(--accent-wash)":"none",transition:"all .15s var(--ease)"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--accent)"},children:">"}),t.jsx("input",{type:"url",value:i,disabled:r,spellCheck:!1,autoComplete:"off",onFocus:()=>p(!0),onBlur:()=>p(!1),onChange:u=>s(u.target.value),onKeyDown:u=>{u.key==="Enter"&&o()},placeholder:"http://localhost:1633",style:{flex:1,minWidth:0,background:"transparent",border:"none",outline:"none",color:"var(--fg)",fontFamily:"var(--font-mono)",fontSize:12.5,padding:"9px 0"}})]}),t.jsx(Z,{onClick:o,disabled:r||!d,children:"connect"})]})}function Lt({node:n,beeApiUrl:r}){return n.isChecking?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:"1px solid var(--line)",borderRadius:8,background:"var(--raised)"},children:[t.jsx(oe,{}),t.jsxs("span",{style:{color:"var(--fg-muted)",fontSize:13,fontFamily:"var(--font-mono)"},children:["probing ",r,"…"]})]}):n.isRunning?t.jsx(V,{tone:"ok",title:"Node online",sub:`bee ${n.version??"—"} · ${r}`,children:t.jsx(se,{tone:"ok",children:"health ok"})}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(V,{tone:"bad",title:"Node unreachable",sub:n.error??`no /health response from ${r}`}),t.jsxs("div",{style:{fontSize:12,color:"var(--fg-muted)",display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("span",{children:"start one with"}),t.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11.5,background:"var(--bunker)",border:"1px solid var(--line)",color:"var(--accent-bright)",padding:"2px 7px",borderRadius:3},children:"bee start"}),t.jsx(Z,{onClick:n.check,children:"retry"})]})]})}function Ve({symbol:n,value:r,onChange:a,onSend:i,pending:s,confirming:l,done:p,disabled:h}){const d=s||l;return t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"0 12px",borderRadius:6,border:"1px solid var(--line-2)",background:d||h?"var(--bunker)":"var(--surface)"},children:[t.jsx("input",{inputMode:"decimal",value:r,disabled:d||h,spellCheck:!1,onChange:o=>a(o.target.value),style:{flex:1,minWidth:0,background:"transparent",border:"none",outline:"none",color:"var(--fg)",fontFamily:"var(--font-mono)",fontSize:12.5,padding:"8px 0"}}),t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--fg-muted)",flexShrink:0},children:n})]}),p?t.jsx(se,{tone:"ok",children:"sent"}):t.jsx(Z,{onClick:i,disabled:d||h||!r.trim(),children:s?"sign…":l?"mining…":`send ${n.toLowerCase()}`})]})}function Wt({to:n,onSettled:r}){const[a,i]=m.useState(kt),[s,l]=m.useState(jt),{address:p}=O.useAccount(),h=O.useSendTransaction(),d=O.useWriteContract(),o=O.useWaitForTransactionReceipt({hash:h.data}),u=O.useWaitForTransactionReceipt({hash:d.data});m.useEffect(()=>{o.isSuccess&&r()},[o.isSuccess]),m.useEffect(()=>{u.isSuccess&&r()},[u.isSuccess]);const v=O.useReadContract({abi:_.erc20Abi,address:Be,functionName:"balanceOf",args:p?[p]:void 0,chainId:H,query:{enabled:!!p}}),g=v.data!==void 0?Number(v.data)/10**be:void 0,y=(g??0)>0,T=()=>{const C=Ze(()=>_.parseEther(a.trim()));C!==void 0&&h.sendTransaction({to:n,value:C,chainId:H})},I=()=>{const C=Ze(()=>_.parseUnits(s.trim(),be));C!==void 0&&d.writeContract({abi:_.erc20Abi,address:Be,functionName:"transfer",args:[n,C],chainId:H})},z=He(h.error)??He(d.error);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("div",{style:ie,children:"One-time top-up — sent from your connected wallet to the node wallet:"}),t.jsx(Ve,{symbol:"xDAI",value:a,onChange:i,onSend:T,pending:h.isPending,confirming:o.isLoading&&!!h.data,done:o.isSuccess,disabled:!1}),t.jsx(Ve,{symbol:"xBZZ",value:s,onChange:l,onSend:I,pending:d.isPending,confirming:u.isLoading&&!!d.data,done:u.isSuccess,disabled:!y}),g!==void 0&&t.jsxs("div",{style:{...ie,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsxs("span",{children:["your wallet holds"," ",t.jsxs("span",{style:{fontFamily:"var(--font-mono)",color:y?"var(--fg-soft)":"var(--warn)"},children:[g.toLocaleString("en-US",{maximumFractionDigits:4})," xBZZ"]})]}),!y&&t.jsx(Z,{onClick:()=>window.open("https://www.ethswarm.org/get-bzz","_blank","noopener"),children:"get xBZZ"})]}),z&&t.jsx("div",{style:{fontSize:12,color:"var(--bad)",fontFamily:"var(--font-mono)"},children:z})]})}function Ze(n){try{return n()}catch{return}}function Bt({locked:n,nodeWallet:r}){if(n)return t.jsx(J,{children:"Bring your Bee node online to read its wallet."});if(r.error)return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(V,{tone:"bad",title:"Could not read node wallet",sub:r.error}),t.jsx(Z,{onClick:r.refresh,children:"retry"})]});const a=r.isLoading&&r.xdai===void 0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx(je,{symbol:"xDAI",role:"gas for the node's own transactions",amount:r.xdai??0,loading:a}),t.jsx(je,{symbol:"xBZZ",role:"pays for postage stamps",amount:r.xbzz??0,loading:a}),t.jsxs("div",{style:ie,children:["The Bee node has its own wallet",r.address&&t.jsxs(t.Fragment,{children:[" ",t.jsxs("span",{style:{fontFamily:"var(--font-mono)",color:"var(--fg-soft)"},children:[r.address.slice(0,8),"…",r.address.slice(-6)]})]})," ","— it buys and renews postage stamps on chain."]}),!r.isFunded&&r.address&&t.jsx(Wt,{to:r.address,onSettled:r.refresh})]})}function Mt({stamp:n,selected:r,onSelect:a}){const[i,s]=m.useState(!1),l=Math.floor(n.batchTTL/86400),p=`${n.batchID.slice(0,8)}…${n.batchID.slice(-6)}`,h=r||i;return t.jsxs("button",{onClick:a,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{display:"flex",alignItems:"center",gap:12,width:"100%",textAlign:"left",padding:"12px 14px",borderRadius:8,cursor:"pointer",border:`1px solid ${r?"var(--ok-line)":h?"var(--line-2)":"var(--line)"}`,background:r?"var(--ok-wash)":"var(--raised)",boxShadow:r?"0 0 0 1px var(--ok-line), 0 0 18px var(--ok-wash)":"none",transition:"all .15s var(--ease)"},children:[t.jsx("span",{style:{width:8,height:8,flexShrink:0,borderRadius:"50%",background:r?"var(--ok)":"var(--line-2)",boxShadow:r?"0 0 8px var(--ok)":"none",transition:"all .15s var(--ease)"}}),t.jsxs("div",{style:{minWidth:0,flex:1},children:[t.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:12.5,color:"var(--fg)"},children:p}),t.jsxs("div",{style:{fontSize:11.5,color:"var(--fg-muted)",marginTop:3,display:"flex",gap:8},children:[n.label&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n.label}),t.jsx("span",{style:{color:"var(--fg-faint)"},children:"·"})]}),t.jsxs("span",{children:["depth ",n.depth]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:l>30?"var(--fg-muted)":"var(--warn)"},children:l>0?`${l}d ttl`:"expiring"}),t.jsx(se,{tone:n.usable?"ok":"bad",children:n.usable?"usable":"unusable"})]})]})}function Se({label:n,value:r,onChange:a,placeholder:i,width:s}){return t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4,flex:s?`0 0 ${s}px`:1,minWidth:0},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:9.5,letterSpacing:".1em",textTransform:"uppercase",color:"var(--fg-faint)"},children:n}),t.jsx("input",{value:r,placeholder:i,spellCheck:!1,autoComplete:"off",onChange:l=>a(l.target.value),style:{minWidth:0,background:"var(--surface)",border:"1px solid var(--line-2)",borderRadius:6,outline:"none",color:"var(--fg)",fontFamily:"var(--font-mono)",fontSize:12,padding:"8px 10px"}})]})}function Ut({stamps:n}){const[r,a]=m.useState(""),[i,s]=m.useState(String(St)),[l,p]=m.useState(Ct);if(n.isCreating)return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:"1px solid var(--line)",borderRadius:8,background:"var(--raised)"},children:[t.jsx(oe,{}),t.jsx("span",{style:{color:"var(--fg-muted)",fontSize:13,fontFamily:"var(--font-mono)"},children:"buying stamp — waiting for the on-chain batch…"})]});const h=Number(i),d=Number.isInteger(h)&&h>=17&&/^\d+$/.test(l.trim());return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"12px 14px",border:"1px dashed var(--line-2)",borderRadius:8,background:"var(--bunker)"},children:[t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsx(Se,{label:"label",value:r,onChange:a,placeholder:"optional"}),t.jsx(Se,{label:"depth",value:i,onChange:s,width:64}),t.jsx(Se,{label:"amount (plur)",value:l,onChange:p,width:120})]}),t.jsx("div",{style:ie,children:"Cost ≈ 2^depth × amount PLUR, paid in xBZZ from the node wallet. Higher amount → longer stamp lifetime."}),t.jsx(we,{block:!0,onClick:()=>d&&n.createStamp({amount:l.trim(),depth:h,label:r.trim()||void 0}),style:d?void 0:{opacity:.5,cursor:"default"},children:"buy stamp"}),n.createError&&t.jsx("div",{style:{fontSize:12,color:"var(--bad)",fontFamily:"var(--font-mono)"},children:n.createError})]})}function Nt({stamps:n,locked:r,lockedHint:a,canCreate:i}){return r?t.jsx(J,{children:a}):n.isLoading?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:"1px solid var(--line)",borderRadius:8,background:"var(--raised)"},children:[t.jsx(oe,{}),t.jsx("span",{style:{color:"var(--fg-muted)",fontSize:13,fontFamily:"var(--font-mono)"},children:"reading /stamps…"})]}):n.error?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(V,{tone:"bad",title:"Could not read stamps",sub:n.error}),t.jsx(Z,{onClick:n.fetchStamps,children:"retry"})]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.stamps.length===0&&!i&&t.jsx(J,{children:"No postage stamps on this node — buy one via the Bee API to continue."}),n.stamps.map(s=>t.jsx(Mt,{stamp:s,selected:n.selectedStampId===s.batchID,onSelect:()=>n.selectStamp(s.batchID)},s.batchID)),i&&t.jsx(Ut,{stamps:n})]})}const ie={fontSize:11.5,color:"var(--fg-faint)",lineHeight:1.5,paddingLeft:2};function Ke({onClose:n,beeNode:r,stamps:a,beeApiUrl:i,setBeeApiUrl:s,stampMode:l="select",nodeWallet:p}){Ge();const h=l==="create",{address:d,isConnected:o}=O.useAccount(),u=O.useChainId(),v=u===H,{data:g,isLoading:y}=O.useBalance({address:d,chainId:H,query:{enabled:o}}),T=g?Number(g.formatted):void 0,I=v&&!!g&&g.value>0n,z={xdai:T,isLoading:o&&y,hasGas:I},C=ye(i),k=p??C;m.useEffect(()=>{r.check()},[i]),m.useEffect(()=>{r.isRunning&&(a.fetchStamps(),h&&k.refresh())},[r.isRunning]);const F=o?"done":"active",R=o?v?"done":"active":"locked",j=v?I?"done":"active":"locked",A=I?r.isRunning?"done":"active":"locked",N=A!=="done"?"locked":k.isFunded?"done":"active",Q=h?N==="done":A==="done",Y=Q?a.selectedStampId?"done":"active":"locked",Re=h?6:5,K=Y==="done",he=[o,v,I,r.isRunning,...h?[k.isFunded]:[],!!a.selectedStampId],G=h?"wallet · chain · gas · node · fund · stamp":"wallet · chain · gas · node · stamp";return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"swarm-connect",onClick:n,style:{position:"fixed",inset:0,zIndex:9998,background:"rgba(4,6,8,0.72)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",animation:"sc-backdrop-in .2s var(--ease)"}}),t.jsxs("div",{className:"swarm-connect",role:"dialog","aria-label":"Connect to Swarm",style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:9999,width:440,maxWidth:"calc(100vw - 28px)",background:"var(--surface)",borderRadius:14,border:"1px solid var(--line-2)",boxShadow:"0 32px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(255,107,0,.08), 0 0 60px rgba(255,107,0,.08)",overflow:"hidden",animation:"sc-modal-in .26s var(--ease) forwards",fontFamily:"var(--font-body)"},children:[t.jsxs("div",{style:{position:"relative",padding:"18px 20px 16px",borderBottom:"1px solid var(--line)",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:"radial-gradient(ellipse 60% 140% at 88% 0%, var(--accent-wash), transparent 70%)"}}),t.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:11},children:[t.jsx(It,{size:30}),t.jsxs("div",{children:[t.jsx("div",{style:{fontFamily:"var(--font-display)",fontWeight:600,fontSize:16,color:"var(--fg)",lineHeight:1.1},children:"Connect to Swarm"}),t.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:".12em",color:"var(--fg-muted)",marginTop:3},children:["// ",K?"ready":G]})]})]}),t.jsx("button",{onClick:n,"aria-label":"Close",style:{background:"transparent",border:"1px solid var(--line)",color:"var(--fg-muted)",width:30,height:30,borderRadius:6,cursor:"pointer",fontSize:18,lineHeight:1,display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all .15s"},onMouseEnter:M=>{M.currentTarget.style.borderColor="var(--line-orange)",M.currentTarget.style.color="var(--accent-bright)"},onMouseLeave:M=>{M.currentTarget.style.borderColor="var(--line)",M.currentTarget.style.color="var(--fg-muted)"},children:"×"})]})]}),t.jsxs("div",{className:"sc-scroll",style:{padding:20,display:"flex",flexDirection:"column",gap:24,maxHeight:"62vh",overflowY:"auto"},children:[t.jsxs("section",{style:{animation:"sc-step-in .3s var(--ease)"},children:[t.jsx(X,{step:1,state:F,hint:o?"linked":null,children:"Wallet"}),t.jsx(Dt,{isConnected:o,address:d})]}),t.jsxs("section",{style:{opacity:R==="locked"?.55:1,transition:"opacity .3s var(--ease)"},children:[t.jsx(X,{step:2,state:R,hint:o?v?"gnosis":"wrong net":null,children:"Network chain"}),t.jsx(At,{locked:R==="locked",isOnGnosis:v,chainId:u})]}),t.jsxs("section",{style:{opacity:j==="locked"?.55:1,transition:"opacity .3s var(--ease)"},children:[t.jsx(X,{step:3,state:j,hint:v?I?"funded":"low":null,children:"Balance"}),t.jsx(Ot,{locked:j==="locked",balance:z})]}),t.jsxs("section",{style:{opacity:A==="locked"?.55:1,transition:"opacity .3s var(--ease)"},children:[t.jsx(X,{step:4,state:A,hint:r.isRunning?r.version:null,children:"Bee node"}),A==="locked"?t.jsx(J,{children:"Top up xDAI gas to unlock the Bee node connection."}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(zt,{value:i,disabled:r.isChecking,onSubmit:s}),t.jsx(Lt,{node:r,beeApiUrl:i})]})]}),h&&t.jsxs("section",{style:{opacity:N==="locked"?.55:1,transition:"opacity .3s var(--ease)"},children:[t.jsx(X,{step:5,state:N,hint:N==="locked"?null:k.isFunded?"funded":"top up",children:"Node wallet"}),t.jsx(Bt,{locked:N==="locked",nodeWallet:k})]}),t.jsxs("section",{style:{opacity:Y==="locked"?.55:1,transition:"opacity .3s var(--ease)"},children:[t.jsx(X,{step:Re,state:Y,hint:a.selectedStampId?"1 selected":Q?`${a.stamps.length} found`:null,children:"Postage stamp"}),t.jsx(Nt,{stamps:a,locked:Y==="locked",canCreate:h,lockedHint:h?"Fund the node wallet to manage postage stamps.":"Bring a node online to load its postage stamps."})]})]}),t.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"space-between",background:K?"var(--accent-wash)":"var(--bunker)",transition:"background .3s"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,letterSpacing:".06em",color:K?"var(--accent-bright)":"var(--fg-muted)"},children:K?"// fully connected — ready to upload":"// gated · each step unlocks the next"}),K?t.jsxs("span",{style:{display:"inline-flex",gap:4,alignItems:"center",color:"var(--ok)",fontSize:12,fontFamily:"var(--font-mono)"},children:[t.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--ok)",boxShadow:"0 0 8px var(--ok)"}}),"done"]}):t.jsx(Tt,{states:he})]})]})]})}function Yt({beeApiUrl:n=ae,stampMode:r,label:a}){Ge();const[i,s]=m.useState(!1),l=Ne({beeApiUrl:n,stampMode:r}),{beeApiUrl:p,setBeeApiUrl:h,beeNode:d,stamps:o,nodeWallet:u,isFullyConnected:v,address:g}=l,[y,T]=m.useState(!1),I=a??(v&&g?`${g.slice(0,6)}…${g.slice(-4)}`:"Connect to Swarm");return t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:"swarm-connect",onClick:()=>s(!0),onMouseEnter:()=>T(!0),onMouseLeave:()=>T(!1),style:{display:"inline-flex",alignItems:"center",gap:10,fontFamily:"var(--font-mono)",fontSize:13,fontWeight:600,letterSpacing:".04em",padding:"10px 16px",borderRadius:6,cursor:"pointer",background:v?"var(--ok-wash)":"var(--accent)",color:v?"var(--ok)":"var(--accent-ink)",border:`1px solid ${v?"var(--ok-line)":"transparent"}`,boxShadow:v?"none":y?"0 0 26px var(--accent-glow)":"0 0 14px var(--accent-glow)",transform:y&&!v?"translateY(-1px)":"none",transition:"all .15s var(--ease)",whiteSpace:"nowrap"},children:[v?t.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"var(--ok)",boxShadow:"0 0 8px var(--ok)"}}):t.jsx(Gt,{swarm:l}),I]}),i&&t.jsx(Ke,{onClose:()=>s(!1),beeNode:d,stamps:o,beeApiUrl:p,setBeeApiUrl:h,stampMode:l.stampMode,nodeWallet:u})]})}function Gt({swarm:n}){const{beeNode:r,stamps:a,nodeWallet:i,stampMode:s,isWalletConnected:l,isOnGnosis:p,balance:h}=n,d=[l?"ok":"bad",p?"ok":"bad",h.hasGas?"ok":p?"warn":"bad",r.isChecking?"warn":r.isRunning?"ok":"bad",...s==="create"?[i.isFunded?"ok":"bad"]:[],a.selectedStampId?"ok":"bad"],o={ok:"var(--accent-ink)",bad:"rgba(26,14,2,.32)",warn:"#7a4a00"};return t.jsx("span",{style:{display:"inline-flex",gap:4,alignItems:"center"},children:d.map((u,v)=>t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:o[u],animation:u==="warn"?"sc-pulse-dot 1.4s var(--ease) infinite":"none"}},v))})}const Ht="2.22.1",Vt=()=>`@wagmi/core@${Ht}`;var $e=function(n,r,a,i){if(a==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?n!==r||!i:!r.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return a==="m"?i:a==="a"?i.call(n):i?i.value:r.get(n)},ue,Je;class ce extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return Vt()}constructor(r,a={}){var l;super(),ue.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const i=a.cause instanceof ce?a.cause.details:(l=a.cause)!=null&&l.message?a.cause.message:a.details,s=a.cause instanceof ce&&a.cause.docsPath||a.docsPath;this.message=[r||"An error occurred.","",...a.metaMessages?[...a.metaMessages,""]:[],...s?[`Docs: ${this.docsBaseUrl}${s}.html${a.docsSlug?`#${a.docsSlug}`:""}`]:[],...i?[`Details: ${i}`]:[],`Version: ${this.version}`].join(`
|
|
54
|
-
`),a.cause&&(this.cause=a.cause),this.details=
|
|
53
|
+
`;let He=!1;function Ve(){if(He||typeof document>"u")return;He=!0;const n=document.createElement("style");n.dataset.swarmConnect="",n.textContent=St,document.head.appendChild(n)}function Ct({size:n=18,stroke:r="var(--accent)",glow:a=!0,children:s}){return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",filter:a?"drop-shadow(0 0 6px var(--accent-glow))":"none"},children:t.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round",children:s})})}function fe({size:n=15}){return t.jsx("span",{style:{width:n,height:n,flexShrink:0,display:"inline-block",border:"2px solid rgba(255,255,255,.12)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"sc-spin .7s linear infinite"}})}function oe({children:n,tone:r}){const a={ok:{c:"var(--ok)",b:"var(--ok-line)",w:"var(--ok-wash)"},bad:{c:"var(--bad)",b:"var(--bad-line)",w:"var(--bad-wash)"},warn:{c:"var(--warn)",b:"var(--warn-line)",w:"var(--warn-wash)"}}[r];return t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:".04em",textTransform:"uppercase",color:a.c,background:a.w,border:`1px solid ${a.b}`,borderRadius:3,padding:"2px 6px",lineHeight:1.3},children:n})}function K({tone:n,title:r,sub:a,children:s}){const i={ok:{b:"var(--ok-line)",w:"var(--ok-wash)",d:"var(--ok)"},bad:{b:"var(--bad-line)",w:"var(--bad-wash)",d:"var(--bad)"},warn:{b:"var(--warn-line)",w:"var(--warn-wash)",d:"var(--warn)"},flat:{b:"var(--line)",w:"var(--raised)",d:"var(--fg-muted)"}}[n],d=!!a&&(a.startsWith("0x")||a.includes("localhost")||a.includes("http"));return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:`1px solid ${i.b}`,borderRadius:8,background:i.w},children:[n!=="flat"&&t.jsx("span",{style:{width:8,height:8,flexShrink:0,borderRadius:"50%",background:i.d,boxShadow:`0 0 8px ${i.d}`,animation:n==="warn"?"sc-pulse-dot 1.6s var(--ease) infinite":"none"}}),t.jsxs("div",{style:{minWidth:0},children:[r&&t.jsx("div",{style:{fontWeight:600,fontSize:13.5,color:n==="flat"?"var(--fg-soft)":i.d},children:r}),a&&t.jsx("div",{style:{fontSize:12,color:"var(--fg-muted)",marginTop:2,fontFamily:d?"var(--font-mono)":"inherit",wordBreak:"break-all"},children:a})]}),s&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0},children:s})]})}function G({children:n,onClick:r,disabled:a}){const[s,i]=m.useState(!1);return t.jsx("button",{onClick:r,disabled:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{fontFamily:"var(--font-mono)",fontSize:12,letterSpacing:".04em",background:"transparent",border:`1px solid ${s&&!a?"var(--line-orange)":"var(--line-2)"}`,color:a?"var(--fg-faint)":s?"var(--accent-bright)":"var(--fg-soft)",borderRadius:4,padding:"7px 14px",cursor:a?"default":"pointer",transition:"all .15s var(--ease)",opacity:a?.5:1},children:n})}function Ze({children:n,onClick:r,pending:a,block:s,style:i}){const[d,h]=m.useState(!1);return t.jsx("button",{onClick:r,disabled:a,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8,fontFamily:"var(--font-mono)",fontSize:13,fontWeight:600,letterSpacing:".06em",textTransform:"uppercase",width:s?"100%":"auto",background:"var(--accent)",color:"var(--accent-ink)",border:"none",borderRadius:4,padding:"11px 20px",cursor:a?"default":"pointer",boxShadow:d?"0 0 24px var(--accent-glow)":"0 0 14px var(--accent-glow)",transform:d?"translateY(-1px)":"none",transition:"all .15s var(--ease)",opacity:a?.8:1,whiteSpace:"nowrap",...i},children:n})}function J({children:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",border:"1px dashed var(--line-2)",borderRadius:8,background:"var(--bunker)"},children:[t.jsxs(Ct,{size:15,stroke:"var(--fg-faint)",glow:!1,children:[t.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"1.5"}),t.jsx("path",{d:"M8 11V8a4 4 0 0 1 8 0v3"})]}),t.jsx("span",{style:{fontSize:12.5,color:"var(--fg-muted)"},children:n})]})}function Rt({step:n,state:r,children:a,hint:s}){const i=r==="done",d=r==="locked";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:12},children:[t.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,flexShrink:0,fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,lineHeight:1,color:i?"var(--ok)":d?"var(--fg-faint)":"var(--accent-ink)",background:i?"var(--ok-wash)":d?"transparent":"var(--accent)",border:i?"1px solid var(--ok-line)":d?"1px solid var(--line-2)":"none",clipPath:"polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%)",boxShadow:!i&&!d?"0 0 14px var(--accent-glow)":"none"},children:i?"✓":n}),t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:".18em",color:d?"var(--fg-faint)":"var(--fg-soft)"},children:a}),s&&t.jsx("span",{style:{marginLeft:"auto",fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:".06em",color:"var(--fg-faint)"},children:s})]})}function Et({size:n=30}){return t.jsx("span",{style:{width:n,height:n,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--accent)",color:"var(--accent-ink)",clipPath:"polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%)",boxShadow:"0 0 18px var(--accent-glow)"},children:t.jsxs("svg",{width:n*.56,height:n*.56,viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-ink)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("ellipse",{cx:"12",cy:"14",rx:"5",ry:"6.5"}),t.jsx("path",{d:"M7 12h10M7 16h10M12 7.5V4M12 4l-2.5-1.5M12 4l2.5-1.5"})]})})}function _t({states:n}){return t.jsx("span",{style:{display:"inline-flex",gap:5},children:n.map((r,a)=>t.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:r?"var(--ok)":"var(--line-2)",boxShadow:r?"0 0 8px var(--ok)":"none",transition:"all .2s"}},a))})}function It(n){const r={formatters:void 0,fees:void 0,serializers:void 0,...n};function a(s){return i=>{const d=typeof i=="function"?i(s):i,h={...s,...d};return Object.assign(h,{extend:a(h)})}}return Object.assign(r,{extend:a(r)})}const Se=It({id:100,name:"Gnosis",nativeCurrency:{decimals:18,name:"xDAI",symbol:"XDAI"},blockTime:5e3,rpcUrls:{default:{http:["https://rpc.gnosischain.com"],webSocket:["wss://rpc.gnosischain.com/wss"]}},blockExplorers:{default:{name:"Gnosisscan",url:"https://gnosisscan.io",apiUrl:"https://api.gnosisscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:21022491}}});function Ce(n){if(n)return n.shortMessage??n.message}function Tt({name:n,icon:r,pending:a,disabled:s,onClick:i}){const[d,h]=m.useState(!1);return t.jsxs("button",{onClick:i,disabled:s||a,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{display:"flex",alignItems:"center",gap:12,width:"100%",textAlign:"left",padding:"11px 13px",borderRadius:8,cursor:s?"default":"pointer",opacity:s?.45:1,border:`1px solid ${d&&!s?"var(--line-orange)":"var(--line)"}`,background:d&&!s?"var(--raised-2)":"var(--raised)",transition:"all .15s var(--ease)"},children:[t.jsx("span",{style:{width:30,height:30,flexShrink:0,borderRadius:7,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--bunker)",border:"1px solid var(--line-2)",color:"var(--accent-bright)",overflow:"hidden",fontFamily:"var(--font-display)",fontWeight:700,fontSize:15},children:r?t.jsx("img",{src:r,width:30,height:30,alt:"",style:{borderRadius:7}}):n.charAt(0)}),t.jsx("span",{style:{flex:1,fontSize:14,fontWeight:500,color:"var(--fg)"},children:n}),a?t.jsx(fe,{size:14}):t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:16,color:d&&!s?"var(--accent)":"var(--fg-faint)",transition:"color .15s"},children:"→"})]})}function Ft({isConnected:n,address:r}){const{connectors:a,connect:s,isPending:i,variables:d,error:h}=O.useConnect(),{disconnect:p}=O.useDisconnect(),{connector:u}=O.useAccount();if(n)return t.jsx(K,{tone:"ok",title:`Wallet connected${u?` · ${u.name}`:""}`,sub:r,children:t.jsx(G,{onClick:()=>p(),children:"disconnect"})});const o=i&&d!=null&&d.connector&&"uid"in d.connector?d.connector.uid:void 0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[a.map(l=>t.jsx(Tt,{name:l.name,icon:l.icon,pending:o===l.uid,disabled:i&&o!==l.uid,onClick:()=>s({connector:l})},l.uid)),h&&t.jsx("div",{style:{fontSize:12,color:"var(--bad)",fontFamily:"var(--font-mono)"},children:h.message})]})}function Pt({locked:n,isOnGnosis:r,chainId:a}){const{switchChain:s,isPending:i,error:d}=O.useSwitchChain();return n?t.jsx(J,{children:"Connect a wallet to verify it is on the Gnosis chain."}):r?t.jsx(K,{tone:"ok",title:"Gnosis chain",sub:`wallet reports chain id ${a}`,children:t.jsx(oe,{tone:"ok",children:"synced"})}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(K,{tone:"warn",title:"Wrong network",sub:`chain ${a??"—"} active — Gnosis (${Z}) required`}),t.jsx(Ze,{onClick:()=>s({chainId:Se.id}),pending:i,block:!0,children:i?"switching…":"switch to Gnosis"}),d&&t.jsxs("div",{style:{fontSize:12,color:"var(--bad)",fontFamily:"var(--font-mono)",lineHeight:1.5},children:["switch failed: ",Ce(d)]})]})}function Re({symbol:n,role:r,amount:a,loading:s}){const i=!s&&a===0,d=i?"var(--warn)":"var(--ok)",h=i?"var(--warn-line)":"var(--ok-line)",p=i?"var(--warn-wash)":"var(--ok-wash)";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:`1px solid ${s?"var(--line)":h}`,borderRadius:8,background:s?"var(--raised)":p},children:[s?t.jsx(fe,{size:14}):t.jsx("span",{style:{width:8,height:8,flexShrink:0,borderRadius:"50%",background:d,boxShadow:`0 0 8px ${d}`,animation:i?"sc-pulse-dot 1.6s var(--ease) infinite":"none"}}),t.jsxs("div",{style:{minWidth:0},children:[t.jsx("div",{style:{fontWeight:600,fontSize:13.5,color:s?"var(--fg-soft)":d},children:n}),t.jsx("div",{style:{fontSize:12,color:"var(--fg-muted)",marginTop:2},children:r})]}),t.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[!s&&t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13.5,fontWeight:500,color:i?"var(--warn)":"var(--fg)"},children:a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:4})}),!s&&t.jsx(oe,{tone:i?"warn":"ok",children:i?"empty":"ok"})]})]})}function Dt({locked:n,balance:r}){if(n)return t.jsx(J,{children:"Switch to the Gnosis chain to read your wallet's xDAI balance."});const a=r.xdai??0,s=!r.isLoading&&a===0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx(Re,{symbol:"xDAI",role:"gas for transactions from this wallet",amount:a,loading:r.isLoading}),t.jsx("div",{style:he,children:"Your connected wallet signs and pays gas for its own transactions — separate from the wallet running your Bee node."}),s&&t.jsx(Ze,{onClick:()=>window.open("https://www.gnosisfaucet.com","_blank","noopener"),block:!0,children:"get xDAI"})]})}function At({value:n,disabled:r,onSubmit:a}){const[s,i]=m.useState(n),[d,h]=m.useState(!1);m.useEffect(()=>{i(n)},[n]);const p=s.trim().replace(/\/+$/,""),u=p!==n&&p.length>0,o=()=>{u&&a(p)};return t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"0 12px",borderRadius:6,border:`1px solid ${d?"var(--line-orange)":"var(--line-2)"}`,background:r?"var(--bunker)":"var(--surface)",boxShadow:d?"0 0 0 3px var(--accent-wash)":"none",transition:"all .15s var(--ease)"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--accent)"},children:">"}),t.jsx("input",{type:"url",value:s,disabled:r,spellCheck:!1,autoComplete:"off",onFocus:()=>h(!0),onBlur:()=>h(!1),onChange:l=>i(l.target.value),onKeyDown:l=>{l.key==="Enter"&&o()},placeholder:"http://localhost:1633",style:{flex:1,minWidth:0,background:"transparent",border:"none",outline:"none",color:"var(--fg)",fontFamily:"var(--font-mono)",fontSize:12.5,padding:"9px 0"}})]}),t.jsx(G,{onClick:o,disabled:r||!u,children:"connect"})]})}function Ot({node:n,beeApiUrl:r}){return n.isChecking?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:"1px solid var(--line)",borderRadius:8,background:"var(--raised)"},children:[t.jsx(fe,{}),t.jsxs("span",{style:{color:"var(--fg-muted)",fontSize:13,fontFamily:"var(--font-mono)"},children:["probing ",r,"…"]})]}):n.isRunning?t.jsx(K,{tone:"ok",title:"Node online",sub:`bee ${n.version??"—"} · ${r}`,children:t.jsx(oe,{tone:"ok",children:"health ok"})}):n.error?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(K,{tone:"bad",title:"Node unreachable",sub:n.error}),t.jsxs("div",{style:{fontSize:12,color:"var(--fg-muted)",display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("span",{children:"start one with"}),t.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11.5,background:"var(--bunker)",border:"1px solid var(--line)",color:"var(--accent-bright)",padding:"2px 7px",borderRadius:3},children:"bee start"}),t.jsx(G,{onClick:n.check,children:"retry"})]})]}):t.jsx(K,{tone:"flat",title:"Node not connected",sub:r,children:t.jsx(G,{onClick:n.check,children:"connect"})})}function Ke({symbol:n,value:r,onChange:a,onSend:s,pending:i,confirming:d,done:h,disabled:p}){const u=i||d;return t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"0 12px",borderRadius:6,border:"1px solid var(--line-2)",background:u||p?"var(--bunker)":"var(--surface)"},children:[t.jsx("input",{inputMode:"decimal",value:r,disabled:u||p,spellCheck:!1,onChange:o=>a(o.target.value),style:{flex:1,minWidth:0,background:"transparent",border:"none",outline:"none",color:"var(--fg)",fontFamily:"var(--font-mono)",fontSize:12.5,padding:"8px 0"}}),t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--fg-muted)",flexShrink:0},children:n})]}),h?t.jsx(oe,{tone:"ok",children:"sent"}):t.jsx(G,{onClick:s,disabled:u||p||!r.trim(),children:i?"sign…":d?"mining…":`send ${n.toLowerCase()}`})]})}function zt({to:n,onSettled:r}){const[a,s]=m.useState(wt),[i,d]=m.useState(kt),{address:h}=O.useAccount(),p=O.useSendTransaction(),u=O.useWriteContract(),o=O.useWaitForTransactionReceipt({hash:p.data}),l=O.useWaitForTransactionReceipt({hash:u.data});m.useEffect(()=>{o.isSuccess&&r()},[o.isSuccess]),m.useEffect(()=>{l.isSuccess&&r()},[l.isSuccess]);const g=O.useReadContract({abi:E.erc20Abi,address:Me,functionName:"balanceOf",args:h?[h]:void 0,chainId:Z,query:{enabled:!!h}}),v=g.data!==void 0?Number(g.data)/10**ke:void 0,y=(v??0)>0,I=()=>{const C=qe(()=>E.parseEther(a.trim()));C!==void 0&&p.sendTransaction({to:n,value:C,chainId:Z})},T=()=>{const C=qe(()=>E.parseUnits(i.trim(),ke));C!==void 0&&u.writeContract({abi:E.erc20Abi,address:Me,functionName:"transfer",args:[n,C],chainId:Z})},z=Ce(p.error)??Ce(u.error);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("div",{style:he,children:"One-time top-up — sent from your connected wallet to the node wallet:"}),t.jsx(Ke,{symbol:"xDAI",value:a,onChange:s,onSend:I,pending:p.isPending,confirming:o.isLoading&&!!p.data,done:o.isSuccess,disabled:!1}),t.jsx(Ke,{symbol:"xBZZ",value:i,onChange:d,onSend:T,pending:u.isPending,confirming:l.isLoading&&!!u.data,done:l.isSuccess,disabled:!y}),v!==void 0&&t.jsxs("div",{style:{...he,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsxs("span",{children:["your wallet holds"," ",t.jsxs("span",{style:{fontFamily:"var(--font-mono)",color:y?"var(--fg-soft)":"var(--warn)"},children:[v.toLocaleString("en-US",{maximumFractionDigits:4})," xBZZ"]})]}),!y&&t.jsx(G,{onClick:()=>window.open("https://www.ethswarm.org/get-bzz","_blank","noopener"),children:"get xBZZ"})]}),z&&t.jsx("div",{style:{fontSize:12,color:"var(--bad)",fontFamily:"var(--font-mono)"},children:z})]})}function qe(n){try{return n()}catch{return}}function Wt({locked:n,nodeWallet:r}){if(n)return t.jsx(J,{children:"Bring your Bee node online to read its wallet."});if(r.error)return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(K,{tone:"bad",title:"Could not read node wallet",sub:r.error}),t.jsx(G,{onClick:r.refresh,children:"retry"})]});const a=r.isLoading&&r.xdai===void 0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx(Re,{symbol:"xDAI",role:"gas for the node's own transactions",amount:r.xdai??0,loading:a}),t.jsx(Re,{symbol:"xBZZ",role:"pays for postage stamps",amount:r.xbzz??0,loading:a}),t.jsxs("div",{style:he,children:["The Bee node has its own wallet",r.address&&t.jsxs(t.Fragment,{children:[" ",t.jsxs("span",{style:{fontFamily:"var(--font-mono)",color:"var(--fg-soft)"},children:[r.address.slice(0,8),"…",r.address.slice(-6)]})]})," ","— it buys and renews postage stamps on chain."]}),!r.isFunded&&r.address&&t.jsx(zt,{to:r.address,onSettled:r.refresh})]})}function Lt({stamp:n,selected:r,onSelect:a}){const[s,i]=m.useState(!1),d=Math.floor(n.batchTTL/86400),h=`${n.batchID.slice(0,8)}…${n.batchID.slice(-6)}`,p=r||s;return t.jsxs("button",{onClick:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{display:"flex",alignItems:"center",gap:12,width:"100%",textAlign:"left",padding:"12px 14px",borderRadius:8,cursor:"pointer",border:`1px solid ${r?"var(--ok-line)":p?"var(--line-2)":"var(--line)"}`,background:r?"var(--ok-wash)":"var(--raised)",boxShadow:r?"0 0 0 1px var(--ok-line), 0 0 18px var(--ok-wash)":"none",transition:"all .15s var(--ease)"},children:[t.jsx("span",{style:{width:8,height:8,flexShrink:0,borderRadius:"50%",background:r?"var(--ok)":"var(--line-2)",boxShadow:r?"0 0 8px var(--ok)":"none",transition:"all .15s var(--ease)"}}),t.jsxs("div",{style:{minWidth:0,flex:1},children:[t.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:12.5,color:"var(--fg)"},children:h}),t.jsxs("div",{style:{fontSize:11.5,color:"var(--fg-muted)",marginTop:3,display:"flex",gap:8},children:[n.label&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n.label}),t.jsx("span",{style:{color:"var(--fg-faint)"},children:"·"})]}),t.jsxs("span",{children:["depth ",n.depth]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:d>30?"var(--fg-muted)":"var(--warn)"},children:d>0?`${d}d ttl`:"expiring"}),t.jsx(oe,{tone:n.usable?"ok":"bad",children:n.usable?"usable":"unusable"})]})]})}function Bt({stamps:n,locked:r,lockedHint:a}){return r?t.jsx(J,{children:a}):n.isLoading?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:"1px solid var(--line)",borderRadius:8,background:"var(--raised)"},children:[t.jsx(fe,{}),t.jsx("span",{style:{color:"var(--fg-muted)",fontSize:13,fontFamily:"var(--font-mono)"},children:"reading /stamps…"})]}):n.error?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(K,{tone:"bad",title:"Could not read stamps",sub:n.error}),t.jsx(G,{onClick:n.fetchStamps,children:"retry"})]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.stamps.length===0&&t.jsxs(t.Fragment,{children:[t.jsx(J,{children:"No postage stamps on this node yet — once the dApp buys one it will appear here."}),t.jsx(G,{onClick:n.fetchStamps,children:"refresh"})]}),n.stamps.map(s=>t.jsx(Lt,{stamp:s,selected:n.selectedStampId===s.batchID,onSelect:()=>n.selectStamp(s.batchID)},s.batchID))]})}const he={fontSize:11.5,color:"var(--fg-faint)",lineHeight:1.5,paddingLeft:2};function $e({onClose:n,beeNode:r,stamps:a,beeApiUrl:s,setBeeApiUrl:i,requirements:d,nodeWallet:h}){Ve();const p={...Ue,...d},{address:u,isConnected:o,chainId:l}=O.useAccount(),g=o&&l===Z,{data:v,isLoading:y}=O.useBalance({address:u,chainId:Z,query:{enabled:o}}),I=v?Number(v.formatted):void 0,T=g&&!!v&&v.value>0n,z={xdai:I,isLoading:o&&y,hasGas:T},C=je(s),k=h??C,F=m.useRef(!1);m.useEffect(()=>{!F.current&&(F.current=!0,r.isRunning)||r.check()},[s]),m.useEffect(()=>{r.isRunning&&(a.fetchStamps(),p.xbzz&&k.refresh())},[r.isRunning]);const _=!p.xdai||T,j=!p.xbzz||k.isFunded,L=o?"done":"active",q=o?g?"done":"active":"locked",Q=g?T?"done":"active":"locked",N=g&&_?r.isRunning?"done":"active":"locked",ie=N!=="done"?"locked":k.isFunded?"done":"active",ce=N==="done"&&j?a.selectedStampId?"done":"active":"locked",le=o&&g&&r.isRunning&&_&&j&&(!p.postageStamp||!!a.selectedStampId),{disconnect:Y}=O.useDisconnect(),H=()=>{Y(),r.disconnect(),n()},V=[{key:"wallet",title:"Wallet",state:L,hint:o?"linked":null,body:t.jsx(Ft,{isConnected:o,address:u})},{key:"network",title:"Network chain",state:q,hint:o?g?"gnosis":"wrong net":null,body:t.jsx(Pt,{locked:q==="locked",isOnGnosis:g,chainId:l})},...p.xdai?[{key:"balance",title:"Balance",state:Q,hint:g?T?"funded":"low":null,body:t.jsx(Dt,{locked:Q==="locked",balance:z})}]:[],{key:"node",title:"Bee node",state:N,hint:r.isRunning?r.version:null,body:N==="locked"?t.jsx(J,{children:p.xdai?"Top up xDAI gas to unlock the Bee node connection.":"Switch to the Gnosis chain to unlock the Bee node connection."}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(At,{value:s,disabled:r.isChecking,onSubmit:i}),t.jsx(Ot,{node:r,beeApiUrl:s})]})},...p.xbzz?[{key:"nodeWallet",title:"Node wallet",state:ie,hint:ie==="locked"?null:k.isFunded?"funded":"top up",body:t.jsx(Wt,{locked:ie==="locked",nodeWallet:k})}]:[],...p.postageStamp?[{key:"stamp",title:"Postage stamp",state:ce,hint:a.selectedStampId?"1 selected":ce!=="locked"?`${a.stamps.length} found`:null,body:t.jsx(Bt,{stamps:a,locked:ce==="locked",lockedHint:p.xbzz?"Fund the node wallet to manage postage stamps.":"Bring a node online to load its postage stamps."})}]:[]],ve=V.map(A=>({wallet:"wallet",network:"chain",balance:"gas",node:"node",nodeWallet:"fund",stamp:"stamp"})[A.key]).join(" · ");return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"swarm-connect",onClick:n,style:{position:"fixed",inset:0,zIndex:9998,background:"rgba(4,6,8,0.72)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",animation:"sc-backdrop-in .2s var(--ease)"}}),t.jsxs("div",{className:"swarm-connect",role:"dialog","aria-label":"Connect to Swarm",style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:9999,width:440,maxWidth:"calc(100vw - 28px)",background:"var(--surface)",borderRadius:14,border:"1px solid var(--line-2)",boxShadow:"0 32px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(255,107,0,.08), 0 0 60px rgba(255,107,0,.08)",overflow:"hidden",animation:"sc-modal-in .26s var(--ease) forwards",fontFamily:"var(--font-body)"},children:[t.jsxs("div",{style:{position:"relative",padding:"18px 20px 16px",borderBottom:"1px solid var(--line)",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:"radial-gradient(ellipse 60% 140% at 88% 0%, var(--accent-wash), transparent 70%)"}}),t.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:11},children:[t.jsx(Et,{size:30}),t.jsxs("div",{children:[t.jsx("div",{style:{fontFamily:"var(--font-display)",fontWeight:600,fontSize:16,color:"var(--fg)",lineHeight:1.1},children:"Connect to Swarm"}),t.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:".12em",color:"var(--fg-muted)",marginTop:3},children:["// ",le?"ready":ve]})]})]}),t.jsx("button",{onClick:n,"aria-label":"Close",style:{background:"transparent",border:"1px solid var(--line)",color:"var(--fg-muted)",width:30,height:30,borderRadius:6,cursor:"pointer",fontSize:18,lineHeight:1,display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all .15s"},onMouseEnter:A=>{A.currentTarget.style.borderColor="var(--line-orange)",A.currentTarget.style.color="var(--accent-bright)"},onMouseLeave:A=>{A.currentTarget.style.borderColor="var(--line)",A.currentTarget.style.color="var(--fg-muted)"},children:"×"})]})]}),t.jsx("div",{className:"sc-scroll",style:{padding:20,display:"flex",flexDirection:"column",gap:24,maxHeight:"62vh",overflowY:"auto"},children:V.map((A,de)=>t.jsxs("section",{style:de===0?{animation:"sc-step-in .3s var(--ease)"}:{opacity:A.state==="locked"?.55:1,transition:"opacity .3s var(--ease)"},children:[t.jsx(Rt,{step:de+1,state:A.state,hint:A.hint,children:A.title}),A.body]},A.key))}),le?t.jsx(Mt,{onDisconnect:H,onDone:n}):t.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bunker)",transition:"background .3s"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,letterSpacing:".06em",color:"var(--fg-muted)"},children:"// gated · each step unlocks the next"}),t.jsx(_t,{states:V.map(A=>A.state==="done")})]})]})]})}function Mt({onDisconnect:n,onDone:r}){const[a,s]=m.useState(!1),[i,d]=m.useState(!1);return t.jsxs("div",{style:{display:"flex",borderTop:"1px solid var(--line)"},children:[t.jsx("button",{onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{flex:"1 1 50%",minWidth:0,padding:"13px 20px",cursor:"pointer",background:a?"var(--bad-wash)":"var(--bunker)",border:"none",borderRight:"1px solid var(--line)",color:a?"var(--bad)":"var(--fg-muted)",fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,letterSpacing:".1em",textTransform:"uppercase",transition:"all .15s var(--ease)",whiteSpace:"nowrap"},children:"disconnect"}),t.jsx("button",{onClick:r,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{flex:"1 1 50%",minWidth:0,padding:"13px 20px",cursor:"pointer",background:i?"var(--ok-wash)":"var(--bunker)",border:"none",color:"var(--ok)",fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,letterSpacing:".1em",textTransform:"uppercase",transition:"all .15s var(--ease)",whiteSpace:"nowrap"},children:t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:7},children:[t.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--ok)",boxShadow:"0 0 8px var(--ok)"}}),"connected"]})})]})}function Ut({beeApiUrl:n=ae,requirements:r,label:a}){Ve();const[s,i]=m.useState(!1),d=Ge({beeApiUrl:n,requirements:r}),{beeApiUrl:h,setBeeApiUrl:p,beeNode:u,stamps:o,nodeWallet:l,isFullyConnected:g,address:v}=d,[y,I]=m.useState(!1),T=a??(g&&v?`${v.slice(0,6)}…${v.slice(-4)}`:"Connect to Swarm");return t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:"swarm-connect",onClick:()=>i(!0),onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),style:{display:"inline-flex",alignItems:"center",gap:10,fontFamily:"var(--font-mono)",fontSize:13,fontWeight:600,letterSpacing:".04em",padding:"10px 16px",borderRadius:6,cursor:"pointer",background:g?"var(--ok-wash)":"var(--accent)",color:g?"var(--ok)":"var(--accent-ink)",border:`1px solid ${g?"var(--ok-line)":"transparent"}`,boxShadow:g?"none":y?"0 0 26px var(--accent-glow)":"0 0 14px var(--accent-glow)",transform:y&&!g?"translateY(-1px)":"none",transition:"all .15s var(--ease)",whiteSpace:"nowrap"},children:[g?t.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"var(--ok)",boxShadow:"0 0 8px var(--ok)"}}):t.jsx(Nt,{swarm:d}),T]}),s&&t.jsx($e,{onClose:()=>i(!1),beeNode:u,stamps:o,beeApiUrl:h,setBeeApiUrl:p,requirements:d.requirements,nodeWallet:l})]})}function Nt({swarm:n}){const{beeNode:r,stamps:a,nodeWallet:s,requirements:i,isWalletConnected:d,isOnGnosis:h,balance:p}=n,u=[d?"ok":"bad",h?"ok":"bad",...i.xdai?[p.hasGas?"ok":h?"warn":"bad"]:[],r.isChecking?"warn":r.isRunning?"ok":"bad",...i.xbzz?[s.isFunded?"ok":"bad"]:[],...i.postageStamp?[a.selectedStampId?"ok":"bad"]:[]],o={ok:"var(--accent-ink)",bad:"rgba(26,14,2,.32)",warn:"#7a4a00"};return t.jsx("span",{style:{display:"inline-flex",gap:4,alignItems:"center"},children:u.map((l,g)=>t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:o[l],animation:l==="warn"?"sc-pulse-dot 1.4s var(--ease) infinite":"none"}},g))})}const Yt="2.22.1",Gt=()=>`@wagmi/core@${Yt}`;var Je=function(n,r,a,s){if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?n!==r||!s:!r.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return a==="m"?s:a==="a"?s.call(n):s?s.value:r.get(n)},pe,Xe;class se extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return Gt()}constructor(r,a={}){var d;super(),pe.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const s=a.cause instanceof se?a.cause.details:(d=a.cause)!=null&&d.message?a.cause.message:a.details,i=a.cause instanceof se&&a.cause.docsPath||a.docsPath;this.message=[r||"An error occurred.","",...a.metaMessages?[...a.metaMessages,""]:[],...i?[`Docs: ${this.docsBaseUrl}${i}.html${a.docsSlug?`#${a.docsSlug}`:""}`]:[],...s?[`Details: ${s}`]:[],`Version: ${this.version}`].join(`
|
|
54
|
+
`),a.cause&&(this.cause=a.cause),this.details=s,this.docsPath=i,this.metaMessages=a.metaMessages,this.shortMessage=r}walk(r){return Je(this,pe,"m",Xe).call(this,this,r)}}pe=new WeakSet,Xe=function n(r,a){return a!=null&&a(r)?r:r.cause?Je(this,pe,"m",n).call(this,r.cause,a):r};class Ht extends se{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class X extends se{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}function Sn(n){return n}Ee.type="injected";function Ee(n={}){const{shimDisconnect:r=!0,unstable_shimAsyncInject:a}=n;function s(){const u=n.target;if(typeof u=="function"){const o=u();if(o)return o}return typeof u=="object"?u:typeof u=="string"?{...Vt[u]??{id:u,name:`${u[0].toUpperCase()}${u.slice(1)}`,provider:`is${u[0].toUpperCase()}${u.slice(1)}`}}:{id:"injected",name:"Injected",provider(o){return o==null?void 0:o.ethereum}}}let i,d,h,p;return u=>({get icon(){return s().icon},get id(){return s().id},get name(){return s().name},get supportsSimulation(){return!0},type:Ee.type,async setup(){const o=await this.getProvider();o!=null&&o.on&&n.target&&(h||(h=this.onConnect.bind(this),o.on("connect",h)),i||(i=this.onAccountsChanged.bind(this),o.on("accountsChanged",i)))},async connect({chainId:o,isReconnecting:l,withCapabilities:g}={}){var I,T,z,C,k,F;const v=await this.getProvider();if(!v)throw new X;let y=[];if(l)y=await this.getAccounts().catch(()=>[]);else if(r)try{y=(C=(z=(T=(I=(await v.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0])==null?void 0:I.caveats)==null?void 0:T[0])==null?void 0:z.value)==null?void 0:C.map(j=>E.getAddress(j)),y.length>0&&(y=await this.getAccounts())}catch(_){const j=_;if(j.code===E.UserRejectedRequestError.code)throw new E.UserRejectedRequestError(j);if(j.code===E.ResourceUnavailableRpcError.code)throw j}try{!(y!=null&&y.length)&&!l&&(y=(await v.request({method:"eth_requestAccounts"})).map(L=>E.getAddress(L))),h&&(v.removeListener("connect",h),h=void 0),i||(i=this.onAccountsChanged.bind(this),v.on("accountsChanged",i)),d||(d=this.onChainChanged.bind(this),v.on("chainChanged",d)),p||(p=this.onDisconnect.bind(this),v.on("disconnect",p));let _=await this.getChainId();if(o&&_!==o){const j=await this.switchChain({chainId:o}).catch(L=>{if(L.code===E.UserRejectedRequestError.code)throw L;return{id:_}});_=(j==null?void 0:j.id)??_}return r&&await((k=u.storage)==null?void 0:k.removeItem(`${this.id}.disconnected`)),n.target||await((F=u.storage)==null?void 0:F.setItem("injected.connected",!0)),{accounts:g?y.map(j=>({address:j,capabilities:{}})):y,chainId:_}}catch(_){const j=_;throw j.code===E.UserRejectedRequestError.code?new E.UserRejectedRequestError(j):j.code===E.ResourceUnavailableRpcError.code?new E.ResourceUnavailableRpcError(j):j}},async disconnect(){var l,g;const o=await this.getProvider();if(!o)throw new X;d&&(o.removeListener("chainChanged",d),d=void 0),p&&(o.removeListener("disconnect",p),p=void 0),h||(h=this.onConnect.bind(this),o.on("connect",h));try{await E.withTimeout(()=>o.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}r&&await((l=u.storage)==null?void 0:l.setItem(`${this.id}.disconnected`,!0)),n.target||await((g=u.storage)==null?void 0:g.removeItem("injected.connected"))},async getAccounts(){const o=await this.getProvider();if(!o)throw new X;return(await o.request({method:"eth_accounts"})).map(g=>E.getAddress(g))},async getChainId(){const o=await this.getProvider();if(!o)throw new X;const l=await o.request({method:"eth_chainId"});return Number(l)},async getProvider(){if(typeof window>"u")return;let o;const l=s();return typeof l.provider=="function"?o=l.provider(window):typeof l.provider=="string"?o=ge(window,l.provider):o=l.provider,o&&!o.removeListener&&("off"in o&&typeof o.off=="function"?o.removeListener=o.off:o.removeListener=()=>{}),o},async isAuthorized(){var o,l;try{if(r&&await((o=u.storage)==null?void 0:o.getItem(`${this.id}.disconnected`))||!n.target&&!await((l=u.storage)==null?void 0:l.getItem("injected.connected")))return!1;if(!await this.getProvider()){if(a!==void 0&&a!==!1){const I=async()=>(typeof window<"u"&&window.removeEventListener("ethereum#initialized",I),!!await this.getProvider()),T=typeof a=="number"?a:1e3;if(await Promise.race([...typeof window<"u"?[new Promise(C=>window.addEventListener("ethereum#initialized",()=>C(I()),{once:!0}))]:[],new Promise(C=>setTimeout(()=>C(I()),T))]))return!0}throw new X}return!!(await E.withRetry(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:o,chainId:l}){var I,T,z,C;const g=await this.getProvider();if(!g)throw new X;const v=u.chains.find(k=>k.id===l);if(!v)throw new E.SwitchChainError(new Ht);const y=new Promise(k=>{const F=_=>{"chainId"in _&&_.chainId===l&&(u.emitter.off("change",F),k())};u.emitter.on("change",F)});try{return await Promise.all([g.request({method:"wallet_switchEthereumChain",params:[{chainId:E.numberToHex(l)}]}).then(async()=>{await this.getChainId()===l&&u.emitter.emit("change",{chainId:l})}),y]),v}catch(k){const F=k;if(F.code===4902||((T=(I=F==null?void 0:F.data)==null?void 0:I.originalError)==null?void 0:T.code)===4902)try{const{default:_,...j}=v.blockExplorers??{};let L;o!=null&&o.blockExplorerUrls?L=o.blockExplorerUrls:_&&(L=[_.url,...Object.values(j).map(N=>N.url)]);let q;(z=o==null?void 0:o.rpcUrls)!=null&&z.length?q=o.rpcUrls:q=[((C=v.rpcUrls.default)==null?void 0:C.http[0])??""];const Q={blockExplorerUrls:L,chainId:E.numberToHex(l),chainName:(o==null?void 0:o.chainName)??v.name,iconUrls:o==null?void 0:o.iconUrls,nativeCurrency:(o==null?void 0:o.nativeCurrency)??v.nativeCurrency,rpcUrls:q};return await Promise.all([g.request({method:"wallet_addEthereumChain",params:[Q]}).then(async()=>{if(await this.getChainId()===l)u.emitter.emit("change",{chainId:l});else throw new E.UserRejectedRequestError(new Error("User rejected switch after adding network."))}),y]),v}catch(_){throw new E.UserRejectedRequestError(_)}throw F.code===E.UserRejectedRequestError.code?new E.UserRejectedRequestError(F):new E.SwitchChainError(F)}},async onAccountsChanged(o){var l;if(o.length===0)this.onDisconnect();else if(u.emitter.listenerCount("connect")){const g=(await this.getChainId()).toString();this.onConnect({chainId:g}),r&&await((l=u.storage)==null?void 0:l.removeItem(`${this.id}.disconnected`))}else u.emitter.emit("change",{accounts:o.map(g=>E.getAddress(g))})},onChainChanged(o){const l=Number(o);u.emitter.emit("change",{chainId:l})},async onConnect(o){const l=await this.getAccounts();if(l.length===0)return;const g=Number(o.chainId);u.emitter.emit("connect",{accounts:l,chainId:g});const v=await this.getProvider();v&&(h&&(v.removeListener("connect",h),h=void 0),i||(i=this.onAccountsChanged.bind(this),v.on("accountsChanged",i)),d||(d=this.onChainChanged.bind(this),v.on("chainChanged",d)),p||(p=this.onDisconnect.bind(this),v.on("disconnect",p)))},async onDisconnect(o){const l=await this.getProvider();o&&o.code===1013&&l&&(await this.getAccounts()).length||(u.emitter.emit("disconnect"),l&&(d&&(l.removeListener("chainChanged",d),d=void 0),p&&(l.removeListener("disconnect",p),p=void 0),h||(h=this.onConnect.bind(this),l.on("connect",h))))}})}const Vt={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider(n){return n!=null&&n.coinbaseWalletExtension?n.coinbaseWalletExtension:ge(n,"isCoinbaseWallet")}},metaMask:{id:"metaMask",name:"MetaMask",provider(n){return ge(n,r=>{if(!r.isMetaMask||r.isBraveWallet&&!r._events&&!r._state)return!1;const a=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPhantom","isPortal","isRabby","isTokenPocket","isTokenary","isUniswapWallet","isZerion"];for(const s of a)if(r[s])return!1;return!0})}},phantom:{id:"phantom",name:"Phantom",provider(n){var r,a;return(r=n==null?void 0:n.phantom)!=null&&r.ethereum?(a=n.phantom)==null?void 0:a.ethereum:ge(n,"isPhantom")}}};function ge(n,r){function a(i){return typeof r=="function"?r(i):typeof r=="string"?i[r]:!0}const s=n.ethereum;if(s!=null&&s.providers)return s.providers.find(i=>a(i));if(s&&a(s))return s}const Zt=new ze.QueryClient,Kt=O.createConfig({chains:[Se],connectors:[Ee()],transports:{[Se.id]:O.http()}});function qt({children:n}){return t.jsx(O.WagmiProvider,{config:Kt,children:t.jsx(ze.QueryClientProvider,{client:Zt,children:n})})}W.SwarmConnectButton=Ut,W.SwarmConnectModal=$e,W.SwarmConnectProvider=qt,W.useBeeNode=Ne,W.useNodeWallet=je,W.usePostageStamps=Ye,W.useSwarmConnect=Ge,Object.defineProperty(W,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types.d.ts
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Which requirements this dApp needs before the user counts as connected.
|
|
3
|
+
* A disabled requirement drops its step from the modal and is ignored by
|
|
4
|
+
* isFullyConnected. Wallet, Gnosis chain, and a running Bee node are always
|
|
5
|
+
* required.
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
+
export interface SwarmConnectRequirements {
|
|
8
|
+
/** The user's wallet must hold xDAI for gas. Default: true. */
|
|
9
|
+
xdai?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The Bee node's own wallet must be funded with xDAI + xBZZ (adds the
|
|
12
|
+
* node-wallet top-up step) so the dApp can buy stamps, e.g. via
|
|
13
|
+
* stamps.createStamp(). Default: false.
|
|
14
|
+
*/
|
|
15
|
+
xbzz?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The user must select a postage stamp in the modal. Set false when the
|
|
18
|
+
* dApp manages stamps itself. Default: true.
|
|
19
|
+
*/
|
|
20
|
+
postageStamp?: boolean;
|
|
21
|
+
}
|
|
7
22
|
export interface SwarmConnectConfig {
|
|
8
23
|
beeApiUrl?: string;
|
|
9
|
-
/**
|
|
10
|
-
|
|
24
|
+
/** Per-dApp requirements; omitted fields use the defaults above. */
|
|
25
|
+
requirements?: SwarmConnectRequirements;
|
|
11
26
|
}
|
|
12
27
|
export interface BeeNodeStatus {
|
|
13
28
|
isRunning: boolean;
|
|
@@ -70,11 +85,13 @@ export interface NodeWalletState {
|
|
|
70
85
|
export interface SwarmConnectState {
|
|
71
86
|
beeNode: BeeNodeStatus & {
|
|
72
87
|
check: () => void;
|
|
88
|
+
disconnect: () => void;
|
|
73
89
|
};
|
|
74
90
|
stamps: PostageStampsState;
|
|
75
91
|
beeApiUrl: string;
|
|
76
92
|
setBeeApiUrl: (url: string) => void;
|
|
77
|
-
|
|
93
|
+
/** The resolved requirements (config merged with defaults). */
|
|
94
|
+
requirements: Required<SwarmConnectRequirements>;
|
|
78
95
|
nodeWallet: NodeWalletState;
|
|
79
96
|
isWalletConnected: boolean;
|
|
80
97
|
address?: string;
|