@ffaerber/swarm-connect 0.2.0 β 0.3.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(O,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react"),require("wagmi"),require("@tanstack/react-query"),require("viem")):typeof define=="function"&&define.amd?define(["exports","react","wagmi","@tanstack/react-query","viem"],E):(O=typeof globalThis<"u"?globalThis:O||self,E(O.SwarmConnect={},O.React,O.wagmi,O.ReactQuery,O.viem))})(this,function(O,E,U,
|
|
1
|
+
(function(O,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react"),require("wagmi"),require("@tanstack/react-query"),require("viem")):typeof define=="function"&&define.amd?define(["exports","react","wagmi","@tanstack/react-query","viem"],E):(O=typeof globalThis<"u"?globalThis:O||self,E(O.SwarmConnect={},O.React,O.wagmi,O.ReactQuery,O.viem))})(this,function(O,E,U,Re,k){"use strict";var de={exports:{}},K={};/**
|
|
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 ke;function ct(){if(ke)return K;ke=1;var r=E,n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),c=Object.prototype.hasOwnProperty,u=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function g(x,f,i){var d,v={},m=null,R=null;i!==void 0&&(m=""+i),f.key!==void 0&&(m=""+f.key),f.ref!==void 0&&(R=f.ref);for(d in f)c.call(f,d)&&!p.hasOwnProperty(d)&&(v[d]=f[d]);if(x&&x.defaultProps)for(d in f=x.defaultProps,f)v[d]===void 0&&(v[d]=f[d]);return{$$typeof:n,type:x,key:m,ref:R,props:v,_owner:u.current}}return K.Fragment=s,K.jsx=g,K.jsxs=g,K}var J={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,24 +14,24 @@
|
|
|
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
|
|
18
|
-
`+
|
|
17
|
+
*/var _e;function lt(){return _e||(_e=1,process.env.NODE_ENV!=="production"&&function(){var r=E,n=Symbol.for("react.element"),s=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),x=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),i=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),R=Symbol.for("react.offscreen"),F=Symbol.iterator,M="@@iterator";function B(e){if(e===null||typeof e!="object")return null;var o=F&&e[F]||e[M];return typeof o=="function"?o:null}var P=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(e){{for(var o=arguments.length,l=new Array(o>1?o-1:0),h=1;h<o;h++)l[h-1]=arguments[h];A("error",e,l)}}function A(e,o,l){{var h=P.ReactDebugCurrentFrame,j=h.getStackAddendum();j!==""&&(o+="%s",l=l.concat([j]));var w=l.map(function(b){return String(b)});w.unshift("Warning: "+o),Function.prototype.apply.call(console[e],console,w)}}var I=!1,C=!1,z=!1,Q=!1,ve=!1,Z;Z=Symbol.for("react.module.reference");function Pt(e){return!!(typeof e=="string"||typeof e=="function"||e===c||e===p||ve||e===u||e===i||e===d||Q||e===R||I||C||z||typeof e=="object"&&e!==null&&(e.$$typeof===m||e.$$typeof===v||e.$$typeof===g||e.$$typeof===x||e.$$typeof===f||e.$$typeof===Z||e.getModuleId!==void 0))}function Ot(e,o,l){var h=e.displayName;if(h)return h;var j=o.displayName||o.name||"";return j!==""?l+"("+j+")":l}function Ue(e){return e.displayName||"Context"}function $(e){if(e==null)return null;if(typeof e.tag=="number"&&S("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 c:return"Fragment";case s:return"Portal";case p:return"Profiler";case u:return"StrictMode";case i:return"Suspense";case d:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case x:var o=e;return Ue(o)+".Consumer";case g:var l=e;return Ue(l._context)+".Provider";case f:return Ot(e,e.render,"ForwardRef");case v:var h=e.displayName||null;return h!==null?h:$(e.type)||"Memo";case m:{var j=e,w=j._payload,b=j._init;try{return $(b(w))}catch{return null}}}return null}var Y=Object.assign,ee=0,ze,Me,Be,$e,Ne,Ye,qe;function Ve(){}Ve.__reactDisabledLog=!0;function At(){{if(ee===0){ze=console.log,Me=console.info,Be=console.warn,$e=console.error,Ne=console.group,Ye=console.groupCollapsed,qe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}ee++}}function Dt(){{if(ee--,ee===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Y({},e,{value:ze}),info:Y({},e,{value:Me}),warn:Y({},e,{value:Be}),error:Y({},e,{value:$e}),group:Y({},e,{value:Ne}),groupCollapsed:Y({},e,{value:Ye}),groupEnd:Y({},e,{value:qe})})}ee<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ye=P.ReactCurrentDispatcher,be;function ae(e,o,l){{if(be===void 0)try{throw Error()}catch(j){var h=j.stack.trim().match(/\n( *(at )?)/);be=h&&h[1]||""}return`
|
|
18
|
+
`+be+e}}var me=!1,ce;{var Wt=typeof WeakMap=="function"?WeakMap:Map;ce=new Wt}function Ge(e,o){if(!e||me)return"";{var l=ce.get(e);if(l!==void 0)return l}var h;me=!0;var j=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var w;w=ye.current,ye.current=null,At();try{if(o){var b=function(){throw Error()};if(Object.defineProperty(b.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(b,[])}catch(W){h=W}Reflect.construct(e,[],b)}else{try{b.call()}catch(W){h=W}e.call(b.prototype)}}else{try{throw Error()}catch(W){h=W}e()}}catch(W){if(W&&h&&typeof W.stack=="string"){for(var y=W.stack.split(`
|
|
19
19
|
`),D=h.stack.split(`
|
|
20
|
-
`),_=y.length-1,
|
|
21
|
-
`+y[_].replace(" at new "," at ");return e.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",e.displayName)),typeof e=="function"&&ce.set(e,L),L}while(_>=1&&
|
|
20
|
+
`),_=y.length-1,T=D.length-1;_>=1&&T>=0&&y[_]!==D[T];)T--;for(;_>=1&&T>=0;_--,T--)if(y[_]!==D[T]){if(_!==1||T!==1)do if(_--,T--,T<0||y[_]!==D[T]){var L=`
|
|
21
|
+
`+y[_].replace(" at new "," at ");return e.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",e.displayName)),typeof e=="function"&&ce.set(e,L),L}while(_>=1&&T>=0);break}}}finally{me=!1,ye.current=w,Dt(),Error.prepareStackTrace=j}var H=e?e.displayName||e.name:"",q=H?ae(H):"";return typeof e=="function"&&ce.set(e,q),q}function Ft(e,o,l){return Ge(e,!1)}function Lt(e){var o=e.prototype;return!!(o&&o.isReactComponent)}function le(e,o,l){if(e==null)return"";if(typeof e=="function")return Ge(e,Lt(e));if(typeof e=="string")return ae(e);switch(e){case i:return ae("Suspense");case d:return ae("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return Ft(e.render);case v:return le(e.type,o,l);case m:{var h=e,j=h._payload,w=h._init;try{return le(w(j),o,l)}catch{}}}return""}var te=Object.prototype.hasOwnProperty,He={},Ke=P.ReactDebugCurrentFrame;function ue(e){if(e){var o=e._owner,l=le(e.type,e._source,o?o.type:null);Ke.setExtraStackFrame(l)}else Ke.setExtraStackFrame(null)}function Ut(e,o,l,h,j){{var w=Function.call.bind(te);for(var b in e)if(w(e,b)){var y=void 0;try{if(typeof e[b]!="function"){var D=Error((h||"React class")+": "+l+" type `"+b+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[b]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw D.name="Invariant Violation",D}y=e[b](o,b,h,l,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(_){y=_}y&&!(y instanceof Error)&&(ue(j),S("%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).",h||"React class",l,b,typeof y),ue(null)),y instanceof Error&&!(y.message in He)&&(He[y.message]=!0,ue(j),S("Failed %s type: %s",l,y.message),ue(null))}}}var zt=Array.isArray;function xe(e){return zt(e)}function Mt(e){{var o=typeof Symbol=="function"&&Symbol.toStringTag,l=o&&e[Symbol.toStringTag]||e.constructor.name||"Object";return l}}function Bt(e){try{return Je(e),!1}catch{return!0}}function Je(e){return""+e}function Xe(e){if(Bt(e))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Mt(e)),Je(e)}var Qe=P.ReactCurrentOwner,$t={key:!0,ref:!0,__self:!0,__source:!0},Ze,et;function Nt(e){if(te.call(e,"ref")){var o=Object.getOwnPropertyDescriptor(e,"ref").get;if(o&&o.isReactWarning)return!1}return e.ref!==void 0}function Yt(e){if(te.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function qt(e,o){typeof e.ref=="string"&&Qe.current}function Vt(e,o){{var l=function(){Ze||(Ze=!0,S("%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)",o))};l.isReactWarning=!0,Object.defineProperty(e,"key",{get:l,configurable:!0})}}function Gt(e,o){{var l=function(){et||(et=!0,S("%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)",o))};l.isReactWarning=!0,Object.defineProperty(e,"ref",{get:l,configurable:!0})}}var Ht=function(e,o,l,h,j,w,b){var y={$$typeof:n,type:e,key:o,ref:l,props:b,_owner:w};return y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(y,"_self",{configurable:!1,enumerable:!1,writable:!1,value:h}),Object.defineProperty(y,"_source",{configurable:!1,enumerable:!1,writable:!1,value:j}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y};function Kt(e,o,l,h,j){{var w,b={},y=null,D=null;l!==void 0&&(Xe(l),y=""+l),Yt(o)&&(Xe(o.key),y=""+o.key),Nt(o)&&(D=o.ref,qt(o,j));for(w in o)te.call(o,w)&&!$t.hasOwnProperty(w)&&(b[w]=o[w]);if(e&&e.defaultProps){var _=e.defaultProps;for(w in _)b[w]===void 0&&(b[w]=_[w])}if(y||D){var T=typeof e=="function"?e.displayName||e.name||"Unknown":e;y&&Vt(b,T),D&&Gt(b,T)}return Ht(e,y,D,j,h,Qe.current,b)}}var je=P.ReactCurrentOwner,tt=P.ReactDebugCurrentFrame;function G(e){if(e){var o=e._owner,l=le(e.type,e._source,o?o.type:null);tt.setExtraStackFrame(l)}else tt.setExtraStackFrame(null)}var we;we=!1;function Se(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function rt(){{if(je.current){var e=$(je.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 Jt(e){return""}var nt={};function Xt(e){{var o=rt();if(!o){var l=typeof e=="string"?e:e.displayName||e.name;l&&(o=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+l+">.")}return o}}function ot(e,o){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var l=Xt(o);if(nt[l])return;nt[l]=!0;var h="";e&&e._owner&&e._owner!==je.current&&(h=" It was passed a child from "+$(e._owner.type)+"."),G(e),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',l,h),G(null)}}function st(e,o){{if(typeof e!="object")return;if(xe(e))for(var l=0;l<e.length;l++){var h=e[l];Se(h)&&ot(h,o)}else if(Se(e))e._store&&(e._store.validated=!0);else if(e){var j=B(e);if(typeof j=="function"&&j!==e.entries)for(var w=j.call(e),b;!(b=w.next()).done;)Se(b.value)&&ot(b.value,o)}}}function Qt(e){{var o=e.type;if(o==null||typeof o=="string")return;var l;if(typeof o=="function")l=o.propTypes;else if(typeof o=="object"&&(o.$$typeof===f||o.$$typeof===v))l=o.propTypes;else return;if(l){var h=$(o);Ut(l,e.props,"prop",h,e)}else if(o.PropTypes!==void 0&&!we){we=!0;var j=$(o);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",j||"Unknown")}typeof o.getDefaultProps=="function"&&!o.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Zt(e){{for(var o=Object.keys(e.props),l=0;l<o.length;l++){var h=o[l];if(h!=="children"&&h!=="key"){G(e),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",h),G(null);break}}e.ref!==null&&(G(e),S("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}var it={};function at(e,o,l,h,j,w){{var b=Pt(e);if(!b){var y="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(y+=" 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 D=Jt();D?y+=D:y+=rt();var _;e===null?_="null":xe(e)?_="array":e!==void 0&&e.$$typeof===n?(_="<"+($(e.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):_=typeof e,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",_,y)}var T=Kt(e,o,l,j,w);if(T==null)return T;if(b){var L=o.children;if(L!==void 0)if(h)if(xe(L)){for(var H=0;H<L.length;H++)st(L[H],e);Object.freeze&&Object.freeze(L)}else S("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 st(L,e)}if(te.call(o,"key")){var q=$(e),W=Object.keys(o).filter(function(sr){return sr!=="key"}),Ce=W.length>0?"{key: someKey, "+W.join(": ..., ")+": ...}":"{key: someKey}";if(!it[q+Ce]){var or=W.length>0?"{"+W.join(": ..., ")+": ...}":"{}";S(`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} />`,Se,Y,rt,Y),ir[Y+Se]=!0}}return e===l?Jr(I):Kr(I),I}}function Xr(e,n,c){return ar(e,n,c,!0)}function Qr(e,n,c){return ar(e,n,c,!1)}var Zr=Qr,et=Xr;J.Fragment=l,J.jsx=Zr,J.jsxs=et}()),J}process.env.NODE_ENV==="production"?de.exports=cr():de.exports=lr();var r=de.exports;const te=100,ne="http://localhost:1633",a={colors:{primary:"#1a56db",primaryHover:"#1e429f",success:"#0e9f6e",successLight:"#f0fdf4",error:"#f05252",errorLight:"#fff5f5",warning:"#ff8a4c",warningLight:"#fffbf5",border:"#e5e7eb",text:"#111827",muted:"#6b7280",overlay:"rgba(0,0,0,0.5)"}};function _e(t=ne){const[o,s]=E.useState({isRunning:!1,isChecking:!1}),l=E.useCallback(async()=>{s({isRunning:!1,isChecking:!0});try{const f=await fetch(`${t}/health`,{signal:AbortSignal.timeout(5e3)});if(f.ok){const p=await f.json();s({isRunning:!0,isChecking:!1,version:p.version})}else s({isRunning:!1,isChecking:!1,error:`Node returned HTTP ${f.status}`})}catch{s({isRunning:!1,isChecking:!1,error:`Cannot reach Bee node at ${t}`})}},[t]);return{...o,check:l}}function Ee(t=ne){const[o,s]=E.useState([]),[l,f]=E.useState(!1),[p,g]=E.useState(),[b,u]=E.useState(),i=E.useCallback(async()=>{f(!0),g(void 0);try{const d=await fetch(`${t}/stamps`,{signal:AbortSignal.timeout(5e3)});if(d.ok){const v=await d.json();s(v.stamps??[])}else g(`HTTP ${d.status}`)}catch{g("Could not fetch postage stamps")}finally{f(!1)}},[t]);return{stamps:o,isLoading:l,error:p,fetchStamps:i,selectedStampId:b,selectStamp:u}}function Te(t={}){const[o,s]=E.useState(t.beeApiUrl??ne),l=_e(o),f=Ee(o),{address:p,isConnected:g}=U.useAccount(),b=U.useChainId(),u=b===te;return{beeNode:l,stamps:f,beeApiUrl:o,setBeeApiUrl:s,isWalletConnected:g,address:p,isOnGnosis:u,chainId:b,isFullyConnected:l.isRunning&&!!f.selectedStampId&&g&&u}}function ur({beeApiUrl:t,setBeeApiUrl:o,beeNode:s,stamps:l}){return E.useEffect(()=>{s.check()},[t]),E.useEffect(()=>{s.isRunning&&l.fetchStamps()},[s.isRunning]),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[r.jsxs("section",{children:[r.jsx(Ie,{children:"Bee Node"}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[r.jsx(dr,{value:t,disabled:s.isChecking,onSubmit:o}),r.jsx(fr,{beeApiUrl:t,status:s,onRetry:s.check})]})]}),s.isRunning&&r.jsxs("section",{children:[r.jsx(Ie,{children:"Postage Stamp"}),r.jsx(hr,{stamps:l})]})]})}function dr({value:t,disabled:o,onSubmit:s}){const[l,f]=E.useState(t);E.useEffect(()=>{f(t)},[t]);const p=l.trim().replace(/\/+$/,""),g=p!==t&&p.length>0,b=()=>{g&&s(p)};return r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"url",value:l,disabled:o,onChange:u=>f(u.target.value),onKeyDown:u=>{u.key==="Enter"&&b()},placeholder:"http://localhost:1633",spellCheck:!1,autoComplete:"off",style:{flex:1,minWidth:0,padding:"8px 10px",fontSize:13,fontFamily:"monospace",border:`1px solid ${a.colors.border}`,borderRadius:6,color:a.colors.text,outline:"none",background:o?"#f9fafb":"#fff"}}),r.jsx("button",{onClick:b,disabled:o||!g,style:{...fe,alignSelf:"auto",cursor:o||!g?"default":"pointer",opacity:o||!g?.5:1},children:"Connect"})]})}function Ie({children:t}){return r.jsx("div",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:a.colors.muted,marginBottom:8},children:t})}function fr({beeApiUrl:t,status:o,onRetry:s}){return o.isChecking?r.jsxs("div",{style:q,children:[r.jsx(Ae,{}),r.jsxs("span",{style:{color:a.colors.muted,fontSize:14},children:["Checking ",t,"β¦"]})]}):o.isRunning?r.jsxs("div",{style:{...q,borderColor:a.colors.success,background:a.colors.successLight},children:[r.jsx(Oe,{color:a.colors.success}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Node running"}),o.version&&r.jsxs("div",{style:{color:a.colors.muted,fontSize:12},children:["v",o.version]})]})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{...q,borderColor:a.colors.error,background:a.colors.errorLight},children:[r.jsx(Oe,{color:a.colors.error}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.error,fontSize:14},children:"Node not reachable"}),r.jsx("div",{style:{color:a.colors.muted,fontSize:12},children:o.error??`Cannot reach ${t}`})]})]}),r.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Start: ",r.jsx("code",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:3},children:"bee start"})]}),r.jsx("button",{onClick:s,style:fe,children:"Retry"})]})}function hr({stamps:t}){return t.isLoading?r.jsxs("div",{style:{...q,gap:10},children:[r.jsx(Ae,{}),r.jsx("span",{style:{color:a.colors.muted,fontSize:14},children:"Loading stampsβ¦"})]}):t.error?r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsx("div",{style:{...q,borderColor:a.colors.error,background:a.colors.errorLight},children:r.jsx("span",{style:{color:a.colors.error,fontSize:13},children:t.error})}),r.jsx("button",{onClick:t.fetchStamps,style:fe,children:"Retry"})]}):t.stamps.length===0?r.jsxs("div",{style:{...q,flexDirection:"column",alignItems:"flex-start",gap:4},children:[r.jsx("div",{style:{fontSize:14,color:a.colors.muted},children:"No postage stamps found."}),r.jsx("div",{style:{fontSize:12,color:a.colors.muted},children:"Buy a stamp via the Bee API or Swarm Desktop to continue."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:t.stamps.map(o=>r.jsx(pr,{stamp:o,selected:t.selectedStampId===o.batchID,onSelect:()=>t.selectStamp(o.batchID)},o.batchID))})}function pr({stamp:t,selected:o,onSelect:s}){const l=Math.floor(t.batchTTL/86400),f=`${t.batchID.slice(0,8)}β¦${t.batchID.slice(-6)}`;return r.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:`1.5px solid ${o?a.colors.primary:a.colors.border}`,borderRadius:8,cursor:"pointer",background:o?"#eff6ff":"#fff",textAlign:"left",width:"100%",transition:"all 0.15s"},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:a.colors.text},children:f}),t.label&&r.jsx("div",{style:{fontSize:12,color:a.colors.muted,marginTop:2},children:t.label})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[r.jsx("span",{style:{fontSize:11,color:a.colors.muted},children:l>0?`${l}d`:"expiring"}),t.usable?r.jsx(Pe,{bg:a.colors.successLight,color:a.colors.success,children:"usable"}):r.jsx(Pe,{bg:a.colors.errorLight,color:a.colors.error,children:"unusable"}),r.jsx("div",{style:{width:16,height:16,borderRadius:"50%",flexShrink:0,border:`2px solid ${o?a.colors.primary:a.colors.border}`,background:o?a.colors.primary:"transparent"}})]})]})}function Pe({children:t,bg:o,color:s}){return r.jsx("span",{style:{fontSize:11,background:o,color:s,borderRadius:4,padding:"2px 6px"},children:t})}function Oe({color:t}){return r.jsx("span",{style:{fontSize:10,color:t,lineHeight:1},children:"β"})}function Ae(){return r.jsx("div",{style:{width:15,height:15,flexShrink:0,border:"2px solid #e5e7eb",borderTopColor:a.colors.primary,borderRadius:"50%",animation:"spin 0.7s linear infinite"}})}const q={display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.border}`,borderRadius:8,background:"#fff"},fe={background:"none",border:`1px solid ${a.colors.border}`,borderRadius:6,padding:"5px 14px",cursor:"pointer",fontSize:13,color:a.colors.muted,alignSelf:"flex-start"};function gr(t){const o={formatters:void 0,fees:void 0,serializers:void 0,...t};function s(l){return f=>{const p=typeof f=="function"?f(l):f,g={...l,...p};return Object.assign(g,{extend:s(g)})}}return Object.assign(o,{extend:s(o)})}const he=gr({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 vr(){const{address:t,isConnected:o}=U.useAccount(),s=U.useChainId(),l=s===te;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[r.jsxs("section",{children:[r.jsx(De,{children:"Wallet"}),o?r.jsx(yr,{address:t}):r.jsx(br,{})]}),o&&r.jsxs("section",{children:[r.jsx(De,{children:"Network"}),r.jsx(mr,{isOnGnosis:l,chainId:s})]})]})}function De({children:t}){return r.jsx("div",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:a.colors.muted,marginBottom:8},children:t})}function yr({address:t}){const{disconnect:o}=U.useDisconnect();return r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"11px 14px",border:`1px solid ${a.colors.success}`,borderRadius:8,background:a.colors.successLight},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Connected"}),t&&r.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:a.colors.muted,marginTop:2},children:`${t.slice(0,8)}β¦${t.slice(-6)}`})]}),r.jsx("button",{onClick:()=>o(),style:{background:"none",border:`1px solid ${a.colors.border}`,borderRadius:6,padding:"5px 12px",cursor:"pointer",fontSize:12,color:a.colors.muted},children:"Disconnect"})]})}function br(){const{connectors:t,connect:o,isPending:s,error:l}=U.useConnect();return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.map(f=>r.jsxs("button",{onClick:()=>o({connector:f}),disabled:s,style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px",border:`1.5px solid ${a.colors.border}`,borderRadius:8,cursor:s?"not-allowed":"pointer",background:"#fff",fontSize:14,fontWeight:500,color:a.colors.text,opacity:s?.6:1,transition:"border-color 0.15s",width:"100%"},onMouseOver:p=>{s||(p.currentTarget.style.borderColor=a.colors.primary)},onMouseOut:p=>{p.currentTarget.style.borderColor=a.colors.border},children:[f.icon?r.jsx("img",{src:f.icon,width:20,height:20,alt:"",style:{borderRadius:4}}):r.jsx("span",{style:{width:20,textAlign:"center",fontSize:16},children:"π"}),f.name]},f.uid)),l&&r.jsx("div",{style:{fontSize:12,color:a.colors.error,marginTop:2},children:l.message})]})}function mr({isOnGnosis:t,chainId:o}){const{switchChain:s,isPending:l,error:f}=U.useSwitchChain();return t?r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.success}`,borderRadius:8,background:a.colors.successLight},children:[r.jsx("span",{style:{color:a.colors.success,fontSize:10,lineHeight:1},children:"β"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Gnosis chain"}),r.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Chain ID ",te]})]})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.warning}`,borderRadius:8,background:a.colors.warningLight},children:[r.jsx("span",{style:{color:a.colors.warning,fontSize:10,lineHeight:1},children:"β"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.warning,fontSize:14},children:"Wrong network"}),r.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Chain ",o??"β"," active β Gnosis (",te,") required"]})]})]}),r.jsx("button",{onClick:()=>s({chainId:he.id}),disabled:l,style:{background:a.colors.primary,color:"#fff",border:"none",borderRadius:6,padding:"9px 20px",cursor:l?"not-allowed":"pointer",fontSize:14,fontWeight:500,opacity:l?.7:1,alignSelf:"flex-start"},children:l?"Switchingβ¦":"Switch to Gnosis"}),f&&r.jsx("div",{style:{fontSize:12,color:a.colors.error},children:f.message})]})}function We({onClose:t,beeNode:o,stamps:s,beeApiUrl:l,setBeeApiUrl:f}){const[p,g]=E.useState("swarm");return r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
30
|
+
<%s key={someKey} {...props} />`,Ce,q,or,q),it[q+Ce]=!0}}return e===c?Zt(T):Qt(T),T}}function er(e,o,l){return at(e,o,l,!0)}function tr(e,o,l){return at(e,o,l,!1)}var rr=tr,nr=er;J.Fragment=c,J.jsx=rr,J.jsxs=nr}()),J}process.env.NODE_ENV==="production"?de.exports=ct():de.exports=lt();var t=de.exports;const re=100,ne="http://localhost:1633",Ee="swarm-connect:bee-api-url",a={colors:{primary:"#1a56db",primaryHover:"#1e429f",success:"#0e9f6e",successLight:"#f0fdf4",error:"#f05252",errorLight:"#fff5f5",warning:"#ff8a4c",warningLight:"#fffbf5",border:"#e5e7eb",text:"#111827",muted:"#6b7280",overlay:"rgba(0,0,0,0.5)",stepActive:"#1a56db"}};function Ie(r=ne){const[n,s]=E.useState({isRunning:!1,isChecking:!1}),c=E.useCallback(async()=>{s({isRunning:!1,isChecking:!0});try{const u=await fetch(`${r}/health`,{signal:AbortSignal.timeout(5e3)});if(u.ok){const p=await u.json();s({isRunning:!0,isChecking:!1,version:p.version})}else s({isRunning:!1,isChecking:!1,error:`Node returned HTTP ${u.status}`})}catch{s({isRunning:!1,isChecking:!1,error:`Cannot reach Bee node at ${r}`})}},[r]);return{...n,check:c}}function Te(r=ne){const[n,s]=E.useState([]),[c,u]=E.useState(!1),[p,g]=E.useState(),[x,f]=E.useState(),i=E.useCallback(async()=>{u(!0),g(void 0);try{const d=await fetch(`${r}/stamps`,{signal:AbortSignal.timeout(5e3)});if(d.ok){const v=await d.json();s(v.stamps??[])}else g(`HTTP ${d.status}`)}catch{g("Could not fetch postage stamps")}finally{u(!1)}},[r]);return{stamps:n,isLoading:c,error:p,fetchStamps:i,selectedStampId:x,selectStamp:f}}function ut(){if(!(typeof window>"u"))try{return window.localStorage.getItem(Ee)??void 0}catch{return}}function Pe(r={}){const[n,s]=E.useState(()=>r.beeApiUrl??ut()??ne);E.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ee,n)}catch{}},[n]);const c=Ie(n),u=Te(n),{address:p,isConnected:g}=U.useAccount(),x=U.useChainId(),f=x===re;return{beeNode:c,stamps:u,beeApiUrl:n,setBeeApiUrl:s,isWalletConnected:g,address:p,isOnGnosis:f,chainId:x,isFullyConnected:c.isRunning&&!!u.selectedStampId&&g&&f}}function fe({step:r,done:n=!1,children:s}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[t.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:"50%",flexShrink:0,fontSize:11,fontWeight:700,lineHeight:1,color:"#fff",background:n?a.colors.success:a.colors.stepActive},children:n?"β":r}),t.jsx("span",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:a.colors.muted},children:s})]})}function dt({beeApiUrl:r,setBeeApiUrl:n,beeNode:s,stamps:c}){return E.useEffect(()=>{s.check()},[r]),E.useEffect(()=>{s.isRunning&&c.fetchStamps()},[s.isRunning]),t.jsxs(t.Fragment,{children:[t.jsxs("section",{children:[t.jsx(fe,{step:1,done:s.isRunning,children:"Bee Node"}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(ft,{value:r,disabled:s.isChecking,onSubmit:n}),t.jsx(pt,{beeApiUrl:r,status:s,onRetry:s.check})]})]}),t.jsxs("section",{style:{opacity:s.isRunning?1:.5},children:[t.jsx(fe,{step:2,done:!!c.selectedStampId,children:"Postage Stamp"}),s.isRunning?t.jsx(gt,{stamps:c}):t.jsx(ht,{children:"Connect a running Bee node to load postage stamps."})]})]})}function ft({value:r,disabled:n,onSubmit:s}){const[c,u]=E.useState(r);E.useEffect(()=>{u(r)},[r]);const p=c.trim().replace(/\/+$/,""),g=p!==r&&p.length>0,x=()=>{g&&s(p)};return t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("input",{type:"url",value:c,disabled:n,onChange:f=>u(f.target.value),onKeyDown:f=>{f.key==="Enter"&&x()},placeholder:"http://localhost:1633",spellCheck:!1,autoComplete:"off",style:{flex:1,minWidth:0,padding:"8px 10px",fontSize:13,fontFamily:"monospace",border:`1px solid ${a.colors.border}`,borderRadius:6,color:a.colors.text,outline:"none",background:n?"#f9fafb":"#fff"}}),t.jsx("button",{onClick:x,disabled:n||!g,style:{...he,alignSelf:"auto",cursor:n||!g?"default":"pointer",opacity:n||!g?.5:1},children:"Connect"})]})}function ht({children:r}){return t.jsxs("div",{style:{...N,color:a.colors.muted,fontSize:13,borderStyle:"dashed",background:"#fafafa"},children:[t.jsx("span",{style:{fontSize:13},children:"π"}),t.jsx("span",{children:r})]})}function pt({beeApiUrl:r,status:n,onRetry:s}){return n.isChecking?t.jsxs("div",{style:N,children:[t.jsx(De,{}),t.jsxs("span",{style:{color:a.colors.muted,fontSize:14},children:["Checking ",r,"β¦"]})]}):n.isRunning?t.jsxs("div",{style:{...N,borderColor:a.colors.success,background:a.colors.successLight},children:[t.jsx(Ae,{color:a.colors.success}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Node running"}),n.version&&t.jsxs("div",{style:{color:a.colors.muted,fontSize:12},children:["v",n.version]})]})]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("div",{style:{...N,borderColor:a.colors.error,background:a.colors.errorLight},children:[t.jsx(Ae,{color:a.colors.error}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,color:a.colors.error,fontSize:14},children:"Node not reachable"}),t.jsx("div",{style:{color:a.colors.muted,fontSize:12},children:n.error??`Cannot reach ${r}`})]})]}),t.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Start: ",t.jsx("code",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:3},children:"bee start"})]}),t.jsx("button",{onClick:s,style:he,children:"Retry"})]})}function gt({stamps:r}){return r.isLoading?t.jsxs("div",{style:{...N,gap:10},children:[t.jsx(De,{}),t.jsx("span",{style:{color:a.colors.muted,fontSize:14},children:"Loading stampsβ¦"})]}):r.error?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("div",{style:{...N,borderColor:a.colors.error,background:a.colors.errorLight},children:t.jsx("span",{style:{color:a.colors.error,fontSize:13},children:r.error})}),t.jsx("button",{onClick:r.fetchStamps,style:he,children:"Retry"})]}):r.stamps.length===0?t.jsxs("div",{style:{...N,flexDirection:"column",alignItems:"flex-start",gap:4},children:[t.jsx("div",{style:{fontSize:14,color:a.colors.muted},children:"No postage stamps found."}),t.jsx("div",{style:{fontSize:12,color:a.colors.muted},children:"Buy a stamp via the Bee API or Swarm Desktop to continue."})]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:r.stamps.map(n=>t.jsx(vt,{stamp:n,selected:r.selectedStampId===n.batchID,onSelect:()=>r.selectStamp(n.batchID)},n.batchID))})}function vt({stamp:r,selected:n,onSelect:s}){const c=Math.floor(r.batchTTL/86400),u=`${r.batchID.slice(0,8)}β¦${r.batchID.slice(-6)}`;return t.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:`1.5px solid ${n?a.colors.primary:a.colors.border}`,borderRadius:8,cursor:"pointer",background:n?"#eff6ff":"#fff",textAlign:"left",width:"100%",transition:"all 0.15s"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:a.colors.text},children:u}),r.label&&t.jsx("div",{style:{fontSize:12,color:a.colors.muted,marginTop:2},children:r.label})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[t.jsx("span",{style:{fontSize:11,color:a.colors.muted},children:c>0?`${c}d`:"expiring"}),r.usable?t.jsx(Oe,{bg:a.colors.successLight,color:a.colors.success,children:"usable"}):t.jsx(Oe,{bg:a.colors.errorLight,color:a.colors.error,children:"unusable"}),t.jsx("div",{style:{width:16,height:16,borderRadius:"50%",flexShrink:0,border:`2px solid ${n?a.colors.primary:a.colors.border}`,background:n?a.colors.primary:"transparent"}})]})]})}function Oe({children:r,bg:n,color:s}){return t.jsx("span",{style:{fontSize:11,background:n,color:s,borderRadius:4,padding:"2px 6px"},children:r})}function Ae({color:r}){return t.jsx("span",{style:{fontSize:10,color:r,lineHeight:1},children:"β"})}function De(){return t.jsx("div",{style:{width:15,height:15,flexShrink:0,border:"2px solid #e5e7eb",borderTopColor:a.colors.primary,borderRadius:"50%",animation:"spin 0.7s linear infinite"}})}const N={display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.border}`,borderRadius:8,background:"#fff"},he={background:"none",border:`1px solid ${a.colors.border}`,borderRadius:6,padding:"5px 14px",cursor:"pointer",fontSize:13,color:a.colors.muted,alignSelf:"flex-start"};function yt(r){const n={formatters:void 0,fees:void 0,serializers:void 0,...r};function s(c){return u=>{const p=typeof u=="function"?u(c):u,g={...c,...p};return Object.assign(g,{extend:s(g)})}}return Object.assign(n,{extend:s(n)})}const pe=yt({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 bt({swarmReady:r}){const{address:n,isConnected:s}=U.useAccount(),c=U.useChainId(),u=c===re;return t.jsxs("section",{style:{opacity:r?1:.5},children:[t.jsx(fe,{step:3,done:s&&u,children:"Wallet"}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[s?t.jsx(mt,{address:n}):r?t.jsx(jt,{}):t.jsx(xt,{}),s&&t.jsx(wt,{isOnGnosis:u,chainId:c})]})]})}function mt({address:r}){const{disconnect:n}=U.useDisconnect();return t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"11px 14px",border:`1px solid ${a.colors.success}`,borderRadius:8,background:a.colors.successLight},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Connected"}),r&&t.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:a.colors.muted,marginTop:2},children:`${r.slice(0,8)}β¦${r.slice(-6)}`})]}),t.jsx("button",{onClick:()=>n(),style:{background:"none",border:`1px solid ${a.colors.border}`,borderRadius:6,padding:"5px 12px",cursor:"pointer",fontSize:12,color:a.colors.muted},children:"Disconnect"})]})}function xt(){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px dashed ${a.colors.border}`,borderRadius:8,background:"#fafafa"},children:[t.jsx("span",{style:{fontSize:13},children:"π"}),t.jsx("span",{style:{fontSize:13,color:a.colors.muted},children:"Complete steps 1 and 2 β a running Bee node and a selected postage stamp β to connect your wallet."})]})}function jt(){const{connectors:r,connect:n,isPending:s,error:c}=U.useConnect();return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.map(u=>t.jsxs("button",{onClick:()=>n({connector:u}),disabled:s,style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px",border:`1.5px solid ${a.colors.border}`,borderRadius:8,cursor:s?"not-allowed":"pointer",background:"#fff",fontSize:14,fontWeight:500,color:a.colors.text,opacity:s?.6:1,transition:"border-color 0.15s",width:"100%"},onMouseOver:p=>{s||(p.currentTarget.style.borderColor=a.colors.primary)},onMouseOut:p=>{p.currentTarget.style.borderColor=a.colors.border},children:[u.icon?t.jsx("img",{src:u.icon,width:20,height:20,alt:"",style:{borderRadius:4}}):t.jsx("span",{style:{width:20,textAlign:"center",fontSize:16},children:"π"}),u.name]},u.uid)),c&&t.jsx("div",{style:{fontSize:12,color:a.colors.error,marginTop:2},children:c.message})]})}function wt({isOnGnosis:r,chainId:n}){const{switchChain:s,isPending:c,error:u}=U.useSwitchChain();return r?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.success}`,borderRadius:8,background:a.colors.successLight},children:[t.jsx("span",{style:{color:a.colors.success,fontSize:10,lineHeight:1},children:"β"}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Gnosis chain"}),t.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Chain ID ",re]})]})]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.warning}`,borderRadius:8,background:a.colors.warningLight},children:[t.jsx("span",{style:{color:a.colors.warning,fontSize:10,lineHeight:1},children:"β"}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,color:a.colors.warning,fontSize:14},children:"Wrong network"}),t.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Chain ",n??"β"," active β Gnosis (",re,") required"]})]})]}),t.jsx("button",{onClick:()=>s({chainId:pe.id}),disabled:c,style:{background:a.colors.primary,color:"#fff",border:"none",borderRadius:6,padding:"9px 20px",cursor:c?"not-allowed":"pointer",fontSize:14,fontWeight:500,opacity:c?.7:1,alignSelf:"flex-start"},children:c?"Switchingβ¦":"Switch to Gnosis"}),u&&t.jsx("div",{style:{fontSize:12,color:a.colors.error},children:u.message})]})}function We({onClose:r,beeNode:n,stamps:s,beeApiUrl:c,setBeeApiUrl:u}){const p=n.isRunning&&!!s.selectedStampId;return t.jsxs(t.Fragment,{children:[t.jsx("style",{children:`
|
|
31
31
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
32
32
|
@keyframes scIn {
|
|
33
33
|
from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
|
|
34
34
|
to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
|
|
35
35
|
}
|
|
36
|
-
`}),
|
|
37
|
-
`),s.cause&&(this.cause=s.cause),this.details=
|
|
36
|
+
`}),t.jsx("div",{onClick:r,style:{position:"fixed",inset:0,background:a.colors.overlay,zIndex:9998}}),t.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",zIndex:9999,background:"#fff",borderRadius:16,boxShadow:"0 24px 64px rgba(0,0,0,0.18)",width:460,maxWidth:"calc(100vw - 32px)",animation:"scIn 0.2s ease forwards",overflow:"hidden",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},children:[t.jsxs("div",{style:{padding:"18px 20px 0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{fontSize:20},children:"π"}),t.jsx("span",{style:{fontWeight:700,fontSize:16,color:a.colors.text},children:"Swarm Connect"})]}),t.jsx("button",{onClick:r,"aria-label":"Close",style:{background:"none",border:"none",cursor:"pointer",color:a.colors.muted,fontSize:22,lineHeight:1,padding:"0 2px",borderRadius:4},children:"Γ"})]}),t.jsxs("div",{style:{padding:"20px",marginTop:6,minHeight:260,maxHeight:"64vh",overflowY:"auto",display:"flex",flexDirection:"column",gap:28},children:[t.jsx(dt,{beeApiUrl:c,setBeeApiUrl:u,beeNode:n,stamps:s}),t.jsx(bt,{swarmReady:p})]})]})]})}function St({beeApiUrl:r=ne,label:n}){const[s,c]=E.useState(!1),{beeNode:u,stamps:p,beeApiUrl:g,setBeeApiUrl:x,isWalletConnected:f,address:i,isOnGnosis:d,isFullyConnected:v}=Pe({beeApiUrl:r}),m=n??(v?i?`${i.slice(0,6)}β¦${i.slice(-4)}`:"Connected":"Connect to Swarm");return t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>c(!0),style:{display:"inline-flex",alignItems:"center",gap:8,background:v?a.colors.successLight:a.colors.primary,color:v?a.colors.success:"#fff",border:v?`1.5px solid ${a.colors.success}`:"none",borderRadius:8,padding:"10px 18px",cursor:"pointer",fontSize:15,fontWeight:600,boxShadow:v?"none":"0 2px 8px rgba(26,86,219,0.25)",transition:"all 0.15s",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},onMouseOver:R=>{v||(R.currentTarget.style.background=a.colors.primaryHover)},onMouseOut:R=>{R.currentTarget.style.background=v?a.colors.successLight:a.colors.primary},children:[!v&&t.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center"},children:[t.jsx(oe,{ok:u.isRunning,checking:u.isChecking}),t.jsx(oe,{ok:!!p.selectedStampId}),t.jsx(oe,{ok:f}),t.jsx(oe,{ok:d})]}),m]}),s&&t.jsx(We,{onClose:()=>c(!1),beeNode:u,stamps:p,beeApiUrl:g,setBeeApiUrl:x})]})}function oe({ok:r,checking:n}){const s=n?a.colors.warning:r?a.colors.success:a.colors.error;return t.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:s}})}const Ct="2.22.1",Rt=()=>`@wagmi/core@${Ct}`;var Fe=function(r,n,s,c){if(s==="a"&&!c)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?r!==n||!c:!n.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return s==="m"?c:s==="a"?c.call(r):c?c.value:n.get(r)},se,Le;class X extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return Rt()}constructor(n,s={}){var p;super(),se.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 c=s.cause instanceof X?s.cause.details:(p=s.cause)!=null&&p.message?s.cause.message:s.details,u=s.cause instanceof X&&s.cause.docsPath||s.docsPath;this.message=[n||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...u?[`Docs: ${this.docsBaseUrl}${u}.html${s.docsSlug?`#${s.docsSlug}`:""}`]:[],...c?[`Details: ${c}`]:[],`Version: ${this.version}`].join(`
|
|
37
|
+
`),s.cause&&(this.cause=s.cause),this.details=c,this.docsPath=u,this.metaMessages=s.metaMessages,this.shortMessage=n}walk(n){return Fe(this,se,"m",Le).call(this,this,n)}}se=new WeakSet,Le=function r(n,s){return s!=null&&s(n)?n:n.cause?Fe(this,se,"m",r).call(this,n.cause,s):n};class kt extends X{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class V extends X{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}function ir(r){return r}ge.type="injected";function ge(r={}){const{shimDisconnect:n=!0,unstable_shimAsyncInject:s}=r;function c(){const f=r.target;if(typeof f=="function"){const i=f();if(i)return i}return typeof f=="object"?f:typeof f=="string"?{..._t[f]??{id:f,name:`${f[0].toUpperCase()}${f.slice(1)}`,provider:`is${f[0].toUpperCase()}${f.slice(1)}`}}:{id:"injected",name:"Injected",provider(i){return i==null?void 0:i.ethereum}}}let u,p,g,x;return f=>({get icon(){return c().icon},get id(){return c().id},get name(){return c().name},get supportsSimulation(){return!0},type:ge.type,async setup(){const i=await this.getProvider();i!=null&&i.on&&r.target&&(g||(g=this.onConnect.bind(this),i.on("connect",g)),u||(u=this.onAccountsChanged.bind(this),i.on("accountsChanged",u)))},async connect({chainId:i,isReconnecting:d,withCapabilities:v}={}){var F,M,B,P,S,A;const m=await this.getProvider();if(!m)throw new V;let R=[];if(d)R=await this.getAccounts().catch(()=>[]);else if(n)try{R=(P=(B=(M=(F=(await m.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0])==null?void 0:F.caveats)==null?void 0:M[0])==null?void 0:B.value)==null?void 0:P.map(C=>k.getAddress(C)),R.length>0&&(R=await this.getAccounts())}catch(I){const C=I;if(C.code===k.UserRejectedRequestError.code)throw new k.UserRejectedRequestError(C);if(C.code===k.ResourceUnavailableRpcError.code)throw C}try{!(R!=null&&R.length)&&!d&&(R=(await m.request({method:"eth_requestAccounts"})).map(z=>k.getAddress(z))),g&&(m.removeListener("connect",g),g=void 0),u||(u=this.onAccountsChanged.bind(this),m.on("accountsChanged",u)),p||(p=this.onChainChanged.bind(this),m.on("chainChanged",p)),x||(x=this.onDisconnect.bind(this),m.on("disconnect",x));let I=await this.getChainId();if(i&&I!==i){const C=await this.switchChain({chainId:i}).catch(z=>{if(z.code===k.UserRejectedRequestError.code)throw z;return{id:I}});I=(C==null?void 0:C.id)??I}return n&&await((S=f.storage)==null?void 0:S.removeItem(`${this.id}.disconnected`)),r.target||await((A=f.storage)==null?void 0:A.setItem("injected.connected",!0)),{accounts:v?R.map(C=>({address:C,capabilities:{}})):R,chainId:I}}catch(I){const C=I;throw C.code===k.UserRejectedRequestError.code?new k.UserRejectedRequestError(C):C.code===k.ResourceUnavailableRpcError.code?new k.ResourceUnavailableRpcError(C):C}},async disconnect(){var d,v;const i=await this.getProvider();if(!i)throw new V;p&&(i.removeListener("chainChanged",p),p=void 0),x&&(i.removeListener("disconnect",x),x=void 0),g||(g=this.onConnect.bind(this),i.on("connect",g));try{await k.withTimeout(()=>i.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}n&&await((d=f.storage)==null?void 0:d.setItem(`${this.id}.disconnected`,!0)),r.target||await((v=f.storage)==null?void 0:v.removeItem("injected.connected"))},async getAccounts(){const i=await this.getProvider();if(!i)throw new V;return(await i.request({method:"eth_accounts"})).map(v=>k.getAddress(v))},async getChainId(){const i=await this.getProvider();if(!i)throw new V;const d=await i.request({method:"eth_chainId"});return Number(d)},async getProvider(){if(typeof window>"u")return;let i;const d=c();return typeof d.provider=="function"?i=d.provider(window):typeof d.provider=="string"?i=ie(window,d.provider):i=d.provider,i&&!i.removeListener&&("off"in i&&typeof i.off=="function"?i.removeListener=i.off:i.removeListener=()=>{}),i},async isAuthorized(){var i,d;try{if(n&&await((i=f.storage)==null?void 0:i.getItem(`${this.id}.disconnected`))||!r.target&&!await((d=f.storage)==null?void 0:d.getItem("injected.connected")))return!1;if(!await this.getProvider()){if(s!==void 0&&s!==!1){const F=async()=>(typeof window<"u"&&window.removeEventListener("ethereum#initialized",F),!!await this.getProvider()),M=typeof s=="number"?s:1e3;if(await Promise.race([...typeof window<"u"?[new Promise(P=>window.addEventListener("ethereum#initialized",()=>P(F()),{once:!0}))]:[],new Promise(P=>setTimeout(()=>P(F()),M))]))return!0}throw new V}return!!(await k.withRetry(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:i,chainId:d}){var F,M,B,P;const v=await this.getProvider();if(!v)throw new V;const m=f.chains.find(S=>S.id===d);if(!m)throw new k.SwitchChainError(new kt);const R=new Promise(S=>{const A=I=>{"chainId"in I&&I.chainId===d&&(f.emitter.off("change",A),S())};f.emitter.on("change",A)});try{return await Promise.all([v.request({method:"wallet_switchEthereumChain",params:[{chainId:k.numberToHex(d)}]}).then(async()=>{await this.getChainId()===d&&f.emitter.emit("change",{chainId:d})}),R]),m}catch(S){const A=S;if(A.code===4902||((M=(F=A==null?void 0:A.data)==null?void 0:F.originalError)==null?void 0:M.code)===4902)try{const{default:I,...C}=m.blockExplorers??{};let z;i!=null&&i.blockExplorerUrls?z=i.blockExplorerUrls:I&&(z=[I.url,...Object.values(C).map(Z=>Z.url)]);let Q;(B=i==null?void 0:i.rpcUrls)!=null&&B.length?Q=i.rpcUrls:Q=[((P=m.rpcUrls.default)==null?void 0:P.http[0])??""];const ve={blockExplorerUrls:z,chainId:k.numberToHex(d),chainName:(i==null?void 0:i.chainName)??m.name,iconUrls:i==null?void 0:i.iconUrls,nativeCurrency:(i==null?void 0:i.nativeCurrency)??m.nativeCurrency,rpcUrls:Q};return await Promise.all([v.request({method:"wallet_addEthereumChain",params:[ve]}).then(async()=>{if(await this.getChainId()===d)f.emitter.emit("change",{chainId:d});else throw new k.UserRejectedRequestError(new Error("User rejected switch after adding network."))}),R]),m}catch(I){throw new k.UserRejectedRequestError(I)}throw A.code===k.UserRejectedRequestError.code?new k.UserRejectedRequestError(A):new k.SwitchChainError(A)}},async onAccountsChanged(i){var d;if(i.length===0)this.onDisconnect();else if(f.emitter.listenerCount("connect")){const v=(await this.getChainId()).toString();this.onConnect({chainId:v}),n&&await((d=f.storage)==null?void 0:d.removeItem(`${this.id}.disconnected`))}else f.emitter.emit("change",{accounts:i.map(v=>k.getAddress(v))})},onChainChanged(i){const d=Number(i);f.emitter.emit("change",{chainId:d})},async onConnect(i){const d=await this.getAccounts();if(d.length===0)return;const v=Number(i.chainId);f.emitter.emit("connect",{accounts:d,chainId:v});const m=await this.getProvider();m&&(g&&(m.removeListener("connect",g),g=void 0),u||(u=this.onAccountsChanged.bind(this),m.on("accountsChanged",u)),p||(p=this.onChainChanged.bind(this),m.on("chainChanged",p)),x||(x=this.onDisconnect.bind(this),m.on("disconnect",x)))},async onDisconnect(i){const d=await this.getProvider();i&&i.code===1013&&d&&(await this.getAccounts()).length||(f.emitter.emit("disconnect"),d&&(p&&(d.removeListener("chainChanged",p),p=void 0),x&&(d.removeListener("disconnect",x),x=void 0),g||(g=this.onConnect.bind(this),d.on("connect",g))))}})}const _t={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider(r){return r!=null&&r.coinbaseWalletExtension?r.coinbaseWalletExtension:ie(r,"isCoinbaseWallet")}},metaMask:{id:"metaMask",name:"MetaMask",provider(r){return ie(r,n=>{if(!n.isMetaMask||n.isBraveWallet&&!n._events&&!n._state)return!1;const s=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPhantom","isPortal","isRabby","isTokenPocket","isTokenary","isUniswapWallet","isZerion"];for(const c of s)if(n[c])return!1;return!0})}},phantom:{id:"phantom",name:"Phantom",provider(r){var n,s;return(n=r==null?void 0:r.phantom)!=null&&n.ethereum?(s=r.phantom)==null?void 0:s.ethereum:ie(r,"isPhantom")}}};function ie(r,n){function s(u){return typeof n=="function"?n(u):typeof n=="string"?u[n]:!0}const c=r.ethereum;if(c!=null&&c.providers)return c.providers.find(u=>s(u));if(c&&s(c))return c}const Et=new Re.QueryClient,It=U.createConfig({chains:[pe],connectors:[ge()],transports:{[pe.id]:U.http()}});function Tt({children:r}){return t.jsx(U.WagmiProvider,{config:It,children:t.jsx(Re.QueryClientProvider,{client:Et,children:r})})}O.SwarmConnectButton=St,O.SwarmConnectModal=We,O.SwarmConnectProvider=Tt,O.useBeeNode=Ie,O.usePostageStamps=Te,O.useSwarmConnect=Pe,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
|