@micro-cms/crypto-auth-ui 1.0.32 → 1.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,6 +4,7 @@ A composable React widget and hook for authenticating users with crypto wallets
4
4
 
5
5
  ## Features
6
6
  - **Multi-Chain**: Supports Solana (Phantom) and EVM (MetaMask, Coinbase Wallet, etc.).
7
+ - **Highly Configurable**: Control which networks to display and customize the header.
7
8
  - **Style Isolation**: Uses scoped Tailwind CSS (prefixed with `mcms-`) and automatic style injection.
8
9
  - **Zero Configuration**: Works out of the box with Micro-CMS backend modules.
9
10
 
@@ -26,21 +27,43 @@ function LoginPage() {
26
27
  return (
27
28
  <AuthWidget
28
29
  onSuccess={handleSuccess}
30
+ // Configure allowed networks (default: ['solana', 'evm'])
31
+ allowedNetworks={['solana']}
32
+ // Optional: Hide default header or provide custom component
33
+ hideHeader={false}
34
+ // headerComponent={<MyCustomHeader />}
29
35
  endpoints={{
30
36
  nonce: '/api/auth/crypto/nonce',
31
37
  verify: '/api/auth/crypto/verify'
32
38
  }}
39
+ headers={{
40
+ 'X-Tenant-ID': 'my-tenant'
41
+ }}
33
42
  />
34
43
  );
35
44
  }
36
45
  ```
37
46
 
47
+ ### Properties
48
+
49
+ | Property | Type | Default | Description |
50
+ | :--- | :--- | :--- | :--- |
51
+ | `onSuccess` | `(token: string) => void` | - | Callback on successful authentication |
52
+ | `onError` | `(error: Error) => void` | - | Callback on authentication error |
53
+ | `allowedNetworks` | `('solana' \| 'evm')[]` | `['solana', 'evm']` | Which networks to show in the UI |
54
+ | `hideHeader` | `boolean` | `false` | Whether to hide the widget header |
55
+ | `headerComponent` | `React.ReactNode` | - | Custom component to replace the default header |
56
+ | `endpoints` | `{ nonce?: string, verify?: string }` | - | Custom backend API paths |
57
+ | `headers` | `Record<string, string>` | - | Custom headers for fetch requests |
58
+ | `className` | `string` | - | Custom container class |
59
+
38
60
  ### Using the Hook
39
61
  ```tsx
40
62
  import { useCryptoAuth } from '@micro-cms/crypto-auth-ui';
41
63
 
42
64
  const { authenticate, status, error } = useCryptoAuth({
43
- onSuccess: (token) => console.log(token)
65
+ onSuccess: (token) => console.log(token),
66
+ headers: { 'X-Tenant-ID': 'my-tenant' }
44
67
  });
45
68
 
46
69
  // Trigger login
package/dist/index.d.mts CHANGED
@@ -9,6 +9,10 @@ interface AuthWidgetProps {
9
9
  nonce?: string;
10
10
  verify?: string;
11
11
  };
12
+ headers?: Record<string, string>;
13
+ allowedNetworks?: ('solana' | 'evm')[];
14
+ hideHeader?: boolean;
15
+ headerComponent?: React.ReactNode;
12
16
  }
13
17
  declare const AuthWidget: React.FC<AuthWidgetProps>;
14
18
 
package/dist/index.d.ts CHANGED
@@ -9,6 +9,10 @@ interface AuthWidgetProps {
9
9
  nonce?: string;
10
10
  verify?: string;
11
11
  };
12
+ headers?: Record<string, string>;
13
+ allowedNetworks?: ('solana' | 'evm')[];
14
+ hideHeader?: boolean;
15
+ headerComponent?: React.ReactNode;
12
16
  }
13
17
  declare const AuthWidget: React.FC<AuthWidgetProps>;
14
18
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Nt=Object.create;var R=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var _t=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var X=(e,t)=>()=>(e&&(t=e(e=0)),t);var v=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),D=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},Z=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Mt(t))!Lt.call(e,i)&&i!==r&&R(e,i,{get:()=>t[i],enumerable:!(n=Rt(t,i))||n.enumerable});return e};var Q=(e,t,r)=>(r=e!=null?Nt(_t(e)):{},Z(t||!e||!e.__esModule?R(r,"default",{value:e,enumerable:!0}):r,e)),Pt=e=>Z(R({},"__esModule",{value:!0}),e);var et=v(M=>{"use strict";M.byteLength=vt;M.toByteArray=Ot;M.fromByteArray=qt;var x=[],y=[],$t=typeof Uint8Array<"u"?Uint8Array:Array,O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(A=0,tt=O.length;A<tt;++A)x[A]=O[A],y[O.charCodeAt(A)]=A;var A,tt;y[45]=62;y[95]=63;function rt(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function vt(e){var t=rt(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Dt(e,t,r){return(t+r)*3/4-r}function Ot(e){var t,r=rt(e),n=r[0],i=r[1],o=new $t(Dt(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=y[e.charCodeAt(u)]<<18|y[e.charCodeAt(u+1)]<<12|y[e.charCodeAt(u+2)]<<6|y[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=y[e.charCodeAt(u)]<<2|y[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=y[e.charCodeAt(u)]<<10|y[e.charCodeAt(u+1)]<<4|y[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Wt(e){return x[e>>18&63]+x[e>>12&63]+x[e>>6&63]+x[e&63]}function jt(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(Wt(n));return i.join("")}function qt(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(jt(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(x[t>>2]+x[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(x[t>>10]+x[t>>4&63]+x[t<<2&63]+"=")),i.join("")}});var nt=v(W=>{"use strict";W.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,h=u>>1,p=-7,m=r?i-1:0,g=r?-1:1,w=e[t+m];for(m+=g,o=w&(1<<-p)-1,w>>=-p,p+=a;p>0;o=o*256+e[t+m],m+=g,p-=8);for(s=o&(1<<-p)-1,o>>=-p,p+=n;p>0;s=s*256+e[t+m],m+=g,p-=8);if(o===0)o=1-h;else{if(o===u)return s?NaN:(w?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-h}return(w?-1:1)*s*Math.pow(2,o-n)};W.write=function(e,t,r,n,i,o){var s,a,u,h=o*8-i-1,p=(1<<h)-1,m=p>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:o-1,F=n?1:-1,Tt=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=p):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+m>=1?t+=g/u:t+=g*Math.pow(2,1-m),t*u>=2&&(s++,u/=2),s+m>=p?(a=0,s=p):s+m>=1?(a=(t*u-1)*Math.pow(2,i),s=s+m):(a=t*Math.pow(2,m-1)*Math.pow(2,i),s=0));i>=8;e[r+w]=a&255,w+=F,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;e[r+w]=s&255,w+=F,s/=256,h-=8);e[r+w-F]|=Tt*128}});var bt=v(T=>{"use strict";var j=et(),k=nt(),it=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;T.Buffer=c;T.SlowBuffer=Ht;T.INSPECT_MAX_BYTES=50;var _=2147483647;T.kMaxLength=_;c.TYPED_ARRAY_SUPPORT=zt();!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function zt(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function E(e){if(e>_)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return V(e)}return at(e,t,r)}c.poolSize=8192;function at(e,t,r){if(typeof e=="string")return Vt(e,t);if(ArrayBuffer.isView(e))return Yt(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(b(e,ArrayBuffer)||e&&b(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(b(e,SharedArrayBuffer)||e&&b(e.buffer,SharedArrayBuffer)))return z(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return c.from(n,t,r);let i=Jt(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}c.from=function(e,t,r){return at(e,t,r)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function ut(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function Gt(e,t,r){return ut(e),e<=0?E(e):t!==void 0?typeof r=="string"?E(e).fill(t,r):E(e).fill(t):E(e)}c.alloc=function(e,t,r){return Gt(e,t,r)};function V(e){return ut(e),E(e<0?0:Y(e)|0)}c.allocUnsafe=function(e){return V(e)};c.allocUnsafeSlow=function(e){return V(e)};function Vt(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=mt(e,t)|0,n=E(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function q(e){let t=e.length<0?0:Y(e.length)|0,r=E(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function Yt(e){if(b(e,Uint8Array)){let t=new Uint8Array(e);return z(t.buffer,t.byteOffset,t.byteLength)}return q(e)}function z(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,c.prototype),n}function Jt(e){if(c.isBuffer(e)){let t=Y(e.length)|0,r=E(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||H(e.length)?E(0):q(e);if(e.type==="Buffer"&&Array.isArray(e.data))return q(e.data)}function Y(e){if(e>=_)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_.toString(16)+" bytes");return e|0}function Ht(e){return+e!=e&&(e=0),c.alloc(+e)}c.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==c.prototype};c.compare=function(t,r){if(b(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),b(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(t)||!c.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};c.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return c.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=c.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if(b(s,Uint8Array))o+s.length>i.length?(c.isBuffer(s)||(s=c.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(c.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function mt(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||b(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return xt(e).length;default:if(i)return n?-1:G(e).length;t=(""+t).toLowerCase(),i=!0}}c.byteLength=mt;function Kt(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return sr(this,t,r);case"utf8":case"utf-8":return ht(this,t,r);case"ascii":return ir(this,t,r);case"latin1":case"binary":return or(this,t,r);case"base64":return er(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cr(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function U(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}c.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)U(this,r,r+1);return this};c.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)U(this,r,r+3),U(this,r+1,r+2);return this};c.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)U(this,r,r+7),U(this,r+1,r+6),U(this,r+2,r+5),U(this,r+3,r+4);return this};c.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?ht(this,0,t):Kt.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:c.compare(this,t)===0};c.prototype.inspect=function(){let t="",r=T.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};it&&(c.prototype[it]=c.prototype.inspect);c.prototype.compare=function(t,r,n,i,o){if(b(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,a=n-r,u=Math.min(s,a),h=this.slice(i,o),p=t.slice(r,n);for(let m=0;m<u;++m)if(h[m]!==p[m]){s=h[m],a=p[m];break}return s<a?-1:a<s?1:0};function pt(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,H(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=c.from(t,n)),c.isBuffer(t))return t.length===0?-1:ot(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ot(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ot(e,t,r,n,i){let o=1,s=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,a/=2,r/=2}function u(p,m){return o===1?p[m]:p.readUInt16BE(m*o)}let h;if(i){let p=-1;for(h=r;h<s;h++)if(u(e,h)===u(t,p===-1?0:h-p)){if(p===-1&&(p=h),h-p+1===a)return p*o}else p!==-1&&(h-=h-p),p=-1}else for(r+a>s&&(r=s-a),h=r;h>=0;h--){let p=!0;for(let m=0;m<a;m++)if(u(e,h+m)!==u(t,m)){p=!1;break}if(p)return h}return-1}c.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};c.prototype.indexOf=function(t,r,n){return pt(this,t,r,n,!0)};c.prototype.lastIndexOf=function(t,r,n){return pt(this,t,r,n,!1)};function Xt(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(t.substr(s*2,2),16);if(H(a))return s;e[r+s]=a}return s}function Zt(e,t,r,n){return L(G(t,e.length-r),e,r,n)}function Qt(e,t,r,n){return L(pr(t),e,r,n)}function tr(e,t,r,n){return L(xt(t),e,r,n)}function rr(e,t,r,n){return L(hr(t,e.length-r),e,r,n)}c.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Xt(this,t,r,n);case"utf8":case"utf-8":return Zt(this,t,r,n);case"ascii":case"latin1":case"binary":return Qt(this,t,r,n);case"base64":return tr(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return rr(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function er(e,t,r){return t===0&&r===e.length?j.fromByteArray(e):j.fromByteArray(e.slice(t,r))}function ht(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let u,h,p,m;switch(a){case 1:o<128&&(s=o);break;case 2:u=e[i+1],(u&192)===128&&(m=(o&31)<<6|u&63,m>127&&(s=m));break;case 3:u=e[i+1],h=e[i+2],(u&192)===128&&(h&192)===128&&(m=(o&15)<<12|(u&63)<<6|h&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:u=e[i+1],h=e[i+2],p=e[i+3],(u&192)===128&&(h&192)===128&&(p&192)===128&&(m=(o&15)<<18|(u&63)<<12|(h&63)<<6|p&63,m>65535&&m<1114112&&(s=m))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return nr(n)}var st=4096;function nr(e){let t=e.length;if(t<=st)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=st));return r}function ir(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function or(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function sr(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=lr[e[o]];return i}function cr(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}c.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,c.prototype),i};function f(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||f(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};c.prototype.readUintBE=c.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||f(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};c.prototype.readUint8=c.prototype.readUInt8=function(t,r){return t=t>>>0,r||f(t,1,this.length),this[t]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||f(t,2,this.length),this[t]|this[t+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||f(t,2,this.length),this[t]<<8|this[t+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||f(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||f(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};c.prototype.readBigUInt64LE=I(function(t){t=t>>>0,C(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&N(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});c.prototype.readBigUInt64BE=I(function(t){t=t>>>0,C(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&N(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});c.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||f(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};c.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||f(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};c.prototype.readInt8=function(t,r){return t=t>>>0,r||f(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};c.prototype.readInt16LE=function(t,r){t=t>>>0,r||f(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function(t,r){t=t>>>0,r||f(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function(t,r){return t=t>>>0,r||f(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};c.prototype.readInt32BE=function(t,r){return t=t>>>0,r||f(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};c.prototype.readBigInt64LE=I(function(t){t=t>>>0,C(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&N(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});c.prototype.readBigInt64BE=I(function(t){t=t>>>0,C(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&N(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});c.prototype.readFloatLE=function(t,r){return t=t>>>0,r||f(t,4,this.length),k.read(this,t,!0,23,4)};c.prototype.readFloatBE=function(t,r){return t=t>>>0,r||f(t,4,this.length),k.read(this,t,!1,23,4)};c.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||f(t,8,this.length),k.read(this,t,!0,52,8)};c.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||f(t,8,this.length),k.read(this,t,!1,52,8)};function d(e,t,r,n,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;d(this,t,r,n,a,0)}let o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;d(this,t,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||d(this,t,r,1,255,0),this[r]=t&255,r+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||d(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||d(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||d(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||d(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function lt(e,t,r,n,i){yt(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function ft(e,t,r,n,i){yt(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}c.prototype.writeBigUInt64LE=I(function(t,r=0){return lt(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=I(function(t,r=0){return ft(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);d(this,t,r,n,u-1,-u)}let o=0,s=1,a=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};c.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);d(this,t,r,n,u-1,-u)}let o=n-1,s=1,a=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};c.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||d(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};c.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||d(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};c.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||d(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};c.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||d(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};c.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||d(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};c.prototype.writeBigInt64LE=I(function(t,r=0){return lt(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=I(function(t,r=0){return ft(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function wt(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function dt(e,t,r,n,i){return t=+t,r=r>>>0,i||wt(e,t,r,4,34028234663852886e22,-34028234663852886e22),k.write(e,t,r,n,23,4),r+4}c.prototype.writeFloatLE=function(t,r,n){return dt(this,t,r,!0,n)};c.prototype.writeFloatBE=function(t,r,n){return dt(this,t,r,!1,n)};function gt(e,t,r,n,i){return t=+t,r=r>>>0,i||wt(e,t,r,8,17976931348623157e292,-17976931348623157e292),k.write(e,t,r,n,52,8),r+8}c.prototype.writeDoubleLE=function(t,r,n){return gt(this,t,r,!0,n)};c.prototype.writeDoubleBE=function(t,r,n){return gt(this,t,r,!1,n)};c.prototype.copy=function(t,r,n,i){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};c.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let s=c.isBuffer(t)?t:c.from(t,i),a=s.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var S={};function J(e,t,r){S[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}J("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);J("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);J("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=ct(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=ct(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function ct(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function ar(e,t,r){C(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&N(t,e.length-(r+1))}function yt(e,t,r,n,i,o){if(e>r||e<t){let s=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${t}${s} and <= ${r}${s}`,new S.ERR_OUT_OF_RANGE("value",a,e)}ar(n,i,o)}function C(e,t){if(typeof e!="number")throw new S.ERR_INVALID_ARG_TYPE(t,"number",e)}function N(e,t,r){throw Math.floor(e)!==e?(C(e,r),new S.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new S.ERR_BUFFER_OUT_OF_BOUNDS:new S.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var ur=/[^+/0-9A-Za-z-_]/g;function mr(e){if(e=e.split("=")[0],e=e.trim().replace(ur,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function G(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function pr(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function hr(e,t){let r,n,i,o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function xt(e){return j.toByteArray(mr(e))}function L(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function b(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function H(e){return e!==e}var lr=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function I(e){return typeof BigInt>"u"?fr:e}function fr(){throw new Error("BigInt not supported")}});var Ft={};D(Ft,{useSolanaWallet:()=>gr});var It,gr,At=X(()=>{"use strict";It=Q(require("bs58")),gr=()=>{let e=()=>{if(typeof window<"u"&&"solana"in window){let n=window;if(n.solana?.isPhantom)return n.solana}},t=async()=>{let n=e();if(n)try{return(await n.connect()).publicKey.toString()}catch{throw new Error("User rejected the connection")}else throw new Error("Phantom wallet not found")},r=async n=>{let i=e();if(!i)throw new Error("Wallet not connected");try{let o=new TextEncoder().encode(n),{signature:s}=await i.signMessage(o,"utf8");return It.default.encode(s)}catch(o){throw console.error("Solana Signing Error:",o),new Error(o.message||"Failed to sign message")}};return{isAvailable:!!e(),connect:t,signMessage:r}}});var St={};D(St,{useEVMWallet:()=>yr});var $,Ut,yr,kt=X(()=>{"use strict";$=require("viem"),Ut=require("viem/chains"),yr=()=>{let e=()=>{if(typeof window<"u"&&"ethereum"in window)return window.ethereum},t=async()=>{let n=e();if(n)try{return(await n.request({method:"eth_requestAccounts"}))[0]}catch{throw new Error("User rejected the connection")}else throw new Error("MetaMask or other EVM wallet not found")},r=async(n,i)=>{let o=e();if(!o)throw new Error("Wallet not connected");try{return await(0,$.createWalletClient)({account:n,chain:Ut.base,transport:(0,$.custom)(o)}).signMessage({account:n,message:i})}catch(s){throw console.error("EVM Signing Error:",s),new Error(s.message||"Failed to sign message")}};return{isAvailable:!!e(),connect:t,signMessage:r}}});var br={};D(br,{AuthWidget:()=>dr,default:()=>xr,useCryptoAuth:()=>P});module.exports=Pt(br);var Ct=Q(bt()),K=require("react");var Bt=require("react");var B=require("lucide-react");var wr="*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.mcms-mb-4{margin-bottom:1rem}.mcms-mb-6{margin-bottom:1.5rem}.mcms-mt-4{margin-top:1rem}.mcms-block{display:block}.mcms-flex{display:flex}.mcms-grid{display:grid}.mcms-h-10{height:2.5rem}.mcms-h-4{height:1rem}.mcms-h-5{height:1.25rem}.mcms-h-6{height:1.5rem}.mcms-w-10{width:2.5rem}.mcms-w-4{width:1rem}.mcms-w-5{width:1.25rem}.mcms-w-6{width:1.5rem}.mcms-flex-shrink-0{flex-shrink:0}@keyframes mcms-spin{to{transform:rotate(1turn)}}.mcms-animate-spin{animation:mcms-spin 1s linear infinite}.mcms-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.mcms-flex-col{flex-direction:column}.mcms-items-center{align-items:center}.mcms-justify-center{justify-content:center}.mcms-justify-between{justify-content:space-between}.mcms-gap-2{gap:.5rem}.mcms-gap-3{gap:.75rem}.mcms-gap-4{gap:1rem}.mcms-rounded-full{border-radius:9999px}.mcms-rounded-lg{border-radius:.5rem}.mcms-rounded-xl{border-radius:.75rem}.mcms-border{border-width:1px}.mcms-border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/var(--tw-border-opacity,1))}.mcms-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.mcms-border-green-100{--tw-border-opacity:1;border-color:rgb(220 252 231/var(--tw-border-opacity,1))}.mcms-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.mcms-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.mcms-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.mcms-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.mcms-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.mcms-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.mcms-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.mcms-p-2{padding:.5rem}.mcms-p-3{padding:.75rem}.mcms-p-4{padding:1rem}.mcms-p-6{padding:1.5rem}.mcms-py-8{padding-top:2rem;padding-bottom:2rem}.mcms-text-left{text-align:left}.mcms-text-center{text-align:center}.mcms-font-serif{font-family:ui-serif,Georgia,Cambria,Times New Roman,Times,serif}.mcms-text-lg{font-size:1.125rem;line-height:1.75rem}.mcms-text-sm{font-size:.875rem;line-height:1.25rem}.mcms-text-xs{font-size:.75rem;line-height:1rem}.mcms-font-bold{font-weight:700}.mcms-font-medium{font-weight:500}.mcms-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.mcms-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.mcms-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.mcms-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.mcms-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.mcms-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.mcms-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.mcms-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.mcms-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.mcms-transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover:mcms-border-blue-500:hover{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.hover:mcms-bg-blue-50:hover{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.mcms-group:hover .group-hover:mcms-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}",Et=()=>{if(typeof document>"u"||document.getElementById("mcms-crypto-styles"))return;let e=document.createElement("style");e.id="mcms-crypto-styles",e.textContent=wr,document.head.appendChild(e)};var l=require("react/jsx-runtime"),dr=({onSuccess:e,onError:t,className:r,endpoints:n})=>{let{status:i,error:o,authenticate:s}=P({onSuccess:e,onError:t,endpoints:n});(0,Bt.useEffect)(()=>{Et()},[]);let a=()=>{switch(i){case"connecting":return"Connecting Wallet...";case"requesting_nonce":return"Getting Nonce...";case"pending_signature":return"Please Sign Message...";case"verifying":return"Verifying Signature...";default:return null}};return(0,l.jsxs)("div",{className:`mcms-p-6 mcms-bg-white mcms-rounded-xl mcms-shadow-lg mcms-border mcms-border-gray-100 ${r}`,children:[(0,l.jsxs)("div",{className:"mcms-flex mcms-items-center mcms-gap-3 mcms-mb-6",children:[(0,l.jsx)("div",{className:"mcms-p-2 mcms-bg-blue-50 mcms-rounded-lg",children:(0,l.jsx)(B.Shield,{className:"mcms-w-6 mcms-h-6 mcms-text-blue-600"})}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:"mcms-text-lg mcms-font-bold mcms-text-gray-900",children:"Crypto Login"}),(0,l.jsx)("p",{className:"mcms-text-sm mcms-text-gray-500",children:"Sign in with your wallet"})]})]}),o&&(0,l.jsxs)("div",{className:"mcms-mb-4 mcms-p-3 mcms-bg-red-50 mcms-text-red-700 mcms-rounded-lg mcms-flex mcms-items-center mcms-gap-2 mcms-text-sm mcms-border mcms-border-red-100",children:[(0,l.jsx)(B.AlertCircle,{className:"mcms-w-4 mcms-h-4 mcms-flex-shrink-0"}),(0,l.jsx)("p",{children:o})]}),i!=="idle"&&i!=="error"&&i!=="success"?(0,l.jsxs)("div",{className:"mcms-flex mcms-flex-col mcms-items-center mcms-justify-center mcms-py-8 mcms-gap-4",children:[(0,l.jsx)(B.Loader2,{className:"mcms-w-10 mcms-h-10 mcms-text-blue-600 mcms-animate-spin"}),(0,l.jsx)("p",{className:"mcms-text-sm mcms-font-medium mcms-text-gray-600",children:a()})]}):(0,l.jsxs)("div",{className:"mcms-grid mcms-grid-cols-1 mcms-gap-3",children:[(0,l.jsxs)("button",{onClick:()=>s("solana"),className:"mcms-flex mcms-items-center mcms-justify-between mcms-p-4 mcms-rounded-xl mcms-border mcms-border-gray-200 hover:mcms-border-blue-500 hover:mcms-bg-blue-50 mcms-transition-all mcms-group",children:[(0,l.jsxs)("div",{className:"mcms-flex mcms-items-center mcms-gap-3",children:[(0,l.jsx)("div",{className:"mcms-w-10 mcms-h-10 mcms-bg-black mcms-rounded-full mcms-flex mcms-items-center mcms-justify-center mcms-text-white mcms-font-bold",children:"S"}),(0,l.jsxs)("div",{className:"mcms-text-left",children:[(0,l.jsx)("span",{className:"mcms-block mcms-font-bold mcms-text-gray-900",children:"Solana"}),(0,l.jsx)("span",{className:"mcms-block mcms-text-xs mcms-text-gray-500",children:"Phantom, Solflare, etc."})]})]}),(0,l.jsx)(B.Wallet,{className:"mcms-w-5 mcms-h-5 mcms-text-gray-400 group-hover:mcms-text-blue-500"})]}),(0,l.jsxs)("button",{onClick:()=>s("evm"),className:"mcms-flex mcms-items-center mcms-justify-between mcms-p-4 mcms-rounded-xl mcms-border mcms-border-gray-200 hover:mcms-border-blue-500 hover:mcms-bg-blue-50 mcms-transition-all mcms-group",children:[(0,l.jsxs)("div",{className:"mcms-flex mcms-items-center mcms-gap-3",children:[(0,l.jsx)("div",{className:"mcms-w-10 mcms-h-10 mcms-bg-orange-500 mcms-rounded-full mcms-flex mcms-items-center mcms-justify-center mcms-text-white mcms-font-bold mcms-font-serif",children:"M"}),(0,l.jsxs)("div",{className:"mcms-text-left",children:[(0,l.jsx)("span",{className:"mcms-block mcms-font-bold mcms-text-gray-900",children:"Base / Ethereum"}),(0,l.jsx)("span",{className:"mcms-block mcms-text-xs mcms-text-gray-500",children:"MetaMask, Coinbase Wallet"})]})]}),(0,l.jsx)(B.Wallet,{className:"mcms-w-5 mcms-h-5 mcms-text-gray-400 group-hover:mcms-text-blue-500"})]})]}),i==="success"&&(0,l.jsx)("div",{className:"mcms-mt-4 mcms-p-3 mcms-bg-green-50 mcms-text-green-700 mcms-rounded-lg mcms-text-center mcms-text-sm mcms-border mcms-border-green-100",children:"Login Successful!"})]})};typeof window<"u"&&(window.Buffer||(window.Buffer=Ct.Buffer),window.global||(window.global=window),window.process||(window.process={env:{}}));var P=(e={})=>{let[t,r]=(0,K.useState)("idle"),[n,i]=(0,K.useState)(null);return{status:t,error:n,authenticate:async s=>{try{r("connecting"),i(null);let a,u;if(s==="solana"){let{useSolanaWallet:m}=await Promise.resolve().then(()=>(At(),Ft)),g=m();a=await g.connect(),r("requesting_nonce");let w=await fetch(e.endpoints?.nonce||"/api/auth/crypto/nonce",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({address:a})}),{nonce:F}=await w.json();r("pending_signature"),u=await g.signMessage(`Sign this message to authenticate: ${F}`)}else{let{useEVMWallet:m}=await Promise.resolve().then(()=>(kt(),St)),g=m();a=await g.connect(),r("requesting_nonce");let w=await fetch(e.endpoints?.nonce||"/api/auth/crypto/nonce",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({address:a})}),{nonce:F}=await w.json();r("pending_signature"),u=await g.signMessage(a,`Sign this message to authenticate: ${F}`)}r("verifying");let h=await fetch(e.endpoints?.verify||"/api/auth/crypto/verify",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({address:a,signature:u,network:s})});if(!h.ok)throw new Error("Verification failed");let{token:p}=await h.json();return r("success"),e.onSuccess?.(p),p}catch(a){throw i(a.message||"Authentication failed"),r("error"),e.onError?.(a),a}}}},xr={manifest:{name:"@micro-cms/crypto-auth-ui",version:"1.0.0",provides:["crypto-auth-ui"],requires:[]},async load(e){e.runtime.register("crypto-auth-ui",{useCryptoAuth:P})}};0&&(module.exports={AuthWidget,useCryptoAuth});
1
+ "use strict";var Tt=Object.create;var R=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var _t=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var X=(e,t)=>()=>(e&&(t=e(e=0)),t);var $=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),D=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},Z=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Mt(t))!Lt.call(e,i)&&i!==r&&R(e,i,{get:()=>t[i],enumerable:!(n=Rt(t,i))||n.enumerable});return e};var Q=(e,t,r)=>(r=e!=null?Tt(_t(e)):{},Z(t||!e||!e.__esModule?R(r,"default",{value:e,enumerable:!0}):r,e)),Pt=e=>Z(R({},"__esModule",{value:!0}),e);var et=$(M=>{"use strict";M.byteLength=$t;M.toByteArray=Ot;M.fromByteArray=qt;var x=[],y=[],vt=typeof Uint8Array<"u"?Uint8Array:Array,O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(A=0,tt=O.length;A<tt;++A)x[A]=O[A],y[O.charCodeAt(A)]=A;var A,tt;y[45]=62;y[95]=63;function rt(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function $t(e){var t=rt(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Dt(e,t,r){return(t+r)*3/4-r}function Ot(e){var t,r=rt(e),n=r[0],i=r[1],o=new vt(Dt(e,n,i)),s=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=y[e.charCodeAt(u)]<<18|y[e.charCodeAt(u+1)]<<12|y[e.charCodeAt(u+2)]<<6|y[e.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=y[e.charCodeAt(u)]<<2|y[e.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=y[e.charCodeAt(u)]<<10|y[e.charCodeAt(u+1)]<<4|y[e.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Wt(e){return x[e>>18&63]+x[e>>12&63]+x[e>>6&63]+x[e&63]}function jt(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(Wt(n));return i.join("")}function qt(e){for(var t,r=e.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(jt(e,s,s+o>a?a:s+o));return n===1?(t=e[r-1],i.push(x[t>>2]+x[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(x[t>>10]+x[t>>4&63]+x[t<<2&63]+"=")),i.join("")}});var nt=$(W=>{"use strict";W.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,u=(1<<a)-1,l=u>>1,p=-7,m=r?i-1:0,w=r?-1:1,d=e[t+m];for(m+=w,o=d&(1<<-p)-1,d>>=-p,p+=a;p>0;o=o*256+e[t+m],m+=w,p-=8);for(s=o&(1<<-p)-1,o>>=-p,p+=n;p>0;s=s*256+e[t+m],m+=w,p-=8);if(o===0)o=1-l;else{if(o===u)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-l}return(d?-1:1)*s*Math.pow(2,o-n)};W.write=function(e,t,r,n,i,o){var s,a,u,l=o*8-i-1,p=(1<<l)-1,m=p>>1,w=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,F=n?1:-1,Nt=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=p):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+m>=1?t+=w/u:t+=w*Math.pow(2,1-m),t*u>=2&&(s++,u/=2),s+m>=p?(a=0,s=p):s+m>=1?(a=(t*u-1)*Math.pow(2,i),s=s+m):(a=t*Math.pow(2,m-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=a&255,d+=F,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[r+d]=s&255,d+=F,s/=256,l-=8);e[r+d-F]|=Nt*128}});var bt=$(N=>{"use strict";var j=et(),S=nt(),it=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;N.Buffer=c;N.SlowBuffer=Jt;N.INSPECT_MAX_BYTES=50;var _=2147483647;N.kMaxLength=_;c.TYPED_ARRAY_SUPPORT=zt();!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function zt(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function E(e){if(e>_)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return V(e)}return at(e,t,r)}c.poolSize=8192;function at(e,t,r){if(typeof e=="string")return Vt(e,t);if(ArrayBuffer.isView(e))return Yt(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(b(e,ArrayBuffer)||e&&b(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(b(e,SharedArrayBuffer)||e&&b(e.buffer,SharedArrayBuffer)))return z(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return c.from(n,t,r);let i=Ht(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}c.from=function(e,t,r){return at(e,t,r)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function ut(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function Gt(e,t,r){return ut(e),e<=0?E(e):t!==void 0?typeof r=="string"?E(e).fill(t,r):E(e).fill(t):E(e)}c.alloc=function(e,t,r){return Gt(e,t,r)};function V(e){return ut(e),E(e<0?0:Y(e)|0)}c.allocUnsafe=function(e){return V(e)};c.allocUnsafeSlow=function(e){return V(e)};function Vt(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=mt(e,t)|0,n=E(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function q(e){let t=e.length<0?0:Y(e.length)|0,r=E(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function Yt(e){if(b(e,Uint8Array)){let t=new Uint8Array(e);return z(t.buffer,t.byteOffset,t.byteLength)}return q(e)}function z(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,c.prototype),n}function Ht(e){if(c.isBuffer(e)){let t=Y(e.length)|0,r=E(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||J(e.length)?E(0):q(e);if(e.type==="Buffer"&&Array.isArray(e.data))return q(e.data)}function Y(e){if(e>=_)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_.toString(16)+" bytes");return e|0}function Jt(e){return+e!=e&&(e=0),c.alloc(+e)}c.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==c.prototype};c.compare=function(t,r){if(b(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),b(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(t)||!c.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};c.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return c.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=c.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let s=t[n];if(b(s,Uint8Array))o+s.length>i.length?(c.isBuffer(s)||(s=c.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(c.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function mt(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||b(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return xt(e).length;default:if(i)return n?-1:G(e).length;t=(""+t).toLowerCase(),i=!0}}c.byteLength=mt;function Kt(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return sr(this,t,r);case"utf8":case"utf-8":return lt(this,t,r);case"ascii":return ir(this,t,r);case"latin1":case"binary":return or(this,t,r);case"base64":return er(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cr(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function U(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}c.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)U(this,r,r+1);return this};c.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)U(this,r,r+3),U(this,r+1,r+2);return this};c.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)U(this,r,r+7),U(this,r+1,r+6),U(this,r+2,r+5),U(this,r+3,r+4);return this};c.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?lt(this,0,t):Kt.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:c.compare(this,t)===0};c.prototype.inspect=function(){let t="",r=N.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};it&&(c.prototype[it]=c.prototype.inspect);c.prototype.compare=function(t,r,n,i,o){if(b(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,a=n-r,u=Math.min(s,a),l=this.slice(i,o),p=t.slice(r,n);for(let m=0;m<u;++m)if(l[m]!==p[m]){s=l[m],a=p[m];break}return s<a?-1:a<s?1:0};function pt(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,J(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=c.from(t,n)),c.isBuffer(t))return t.length===0?-1:ot(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ot(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ot(e,t,r,n,i){let o=1,s=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,a/=2,r/=2}function u(p,m){return o===1?p[m]:p.readUInt16BE(m*o)}let l;if(i){let p=-1;for(l=r;l<s;l++)if(u(e,l)===u(t,p===-1?0:l-p)){if(p===-1&&(p=l),l-p+1===a)return p*o}else p!==-1&&(l-=l-p),p=-1}else for(r+a>s&&(r=s-a),l=r;l>=0;l--){let p=!0;for(let m=0;m<a;m++)if(u(e,l+m)!==u(t,m)){p=!1;break}if(p)return l}return-1}c.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};c.prototype.indexOf=function(t,r,n){return pt(this,t,r,n,!0)};c.prototype.lastIndexOf=function(t,r,n){return pt(this,t,r,n,!1)};function Xt(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(t.substr(s*2,2),16);if(J(a))return s;e[r+s]=a}return s}function Zt(e,t,r,n){return L(G(t,e.length-r),e,r,n)}function Qt(e,t,r,n){return L(pr(t),e,r,n)}function tr(e,t,r,n){return L(xt(t),e,r,n)}function rr(e,t,r,n){return L(lr(t,e.length-r),e,r,n)}c.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Xt(this,t,r,n);case"utf8":case"utf-8":return Zt(this,t,r,n);case"ascii":case"latin1":case"binary":return Qt(this,t,r,n);case"base64":return tr(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return rr(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function er(e,t,r){return t===0&&r===e.length?j.fromByteArray(e):j.fromByteArray(e.slice(t,r))}function lt(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let u,l,p,m;switch(a){case 1:o<128&&(s=o);break;case 2:u=e[i+1],(u&192)===128&&(m=(o&31)<<6|u&63,m>127&&(s=m));break;case 3:u=e[i+1],l=e[i+2],(u&192)===128&&(l&192)===128&&(m=(o&15)<<12|(u&63)<<6|l&63,m>2047&&(m<55296||m>57343)&&(s=m));break;case 4:u=e[i+1],l=e[i+2],p=e[i+3],(u&192)===128&&(l&192)===128&&(p&192)===128&&(m=(o&15)<<18|(u&63)<<12|(l&63)<<6|p&63,m>65535&&m<1114112&&(s=m))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return nr(n)}var st=4096;function nr(e){let t=e.length;if(t<=st)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=st));return r}function ir(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function or(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function sr(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=hr[e[o]];return i}function cr(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}c.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,c.prototype),i};function f(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||f(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return i};c.prototype.readUintBE=c.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||f(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};c.prototype.readUint8=c.prototype.readUInt8=function(t,r){return t=t>>>0,r||f(t,1,this.length),this[t]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||f(t,2,this.length),this[t]|this[t+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||f(t,2,this.length),this[t]<<8|this[t+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||f(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||f(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};c.prototype.readBigUInt64LE=I(function(t){t=t>>>0,k(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&T(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});c.prototype.readBigUInt64BE=I(function(t){t=t>>>0,k(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&T(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});c.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||f(t,r,this.length);let i=this[t],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};c.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||f(t,r,this.length);let i=r,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};c.prototype.readInt8=function(t,r){return t=t>>>0,r||f(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};c.prototype.readInt16LE=function(t,r){t=t>>>0,r||f(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function(t,r){t=t>>>0,r||f(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function(t,r){return t=t>>>0,r||f(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};c.prototype.readInt32BE=function(t,r){return t=t>>>0,r||f(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};c.prototype.readBigInt64LE=I(function(t){t=t>>>0,k(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&T(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});c.prototype.readBigInt64BE=I(function(t){t=t>>>0,k(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&T(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});c.prototype.readFloatLE=function(t,r){return t=t>>>0,r||f(t,4,this.length),S.read(this,t,!0,23,4)};c.prototype.readFloatBE=function(t,r){return t=t>>>0,r||f(t,4,this.length),S.read(this,t,!1,23,4)};c.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||f(t,8,this.length),S.read(this,t,!0,52,8)};c.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||f(t,8,this.length),S.read(this,t,!1,52,8)};function g(e,t,r,n,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;g(this,t,r,n,a,0)}let o=1,s=0;for(this[r]=t&255;++s<n&&(o*=256);)this[r+s]=t/o&255;return r+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;g(this,t,r,n,a,0)}let o=n-1,s=1;for(this[r+o]=t&255;--o>=0&&(s*=256);)this[r+o]=t/s&255;return r+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,1,255,0),this[r]=t&255,r+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function ht(e,t,r,n,i){yt(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function ft(e,t,r,n,i){yt(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}c.prototype.writeBigUInt64LE=I(function(t,r=0){return ht(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=I(function(t,r=0){return ft(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);g(this,t,r,n,u-1,-u)}let o=0,s=1,a=0;for(this[r]=t&255;++o<n&&(s*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};c.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);g(this,t,r,n,u-1,-u)}let o=n-1,s=1,a=0;for(this[r+o]=t&255;--o>=0&&(s*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/s>>0)-a&255;return r+n};c.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};c.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};c.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};c.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};c.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};c.prototype.writeBigInt64LE=I(function(t,r=0){return ht(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=I(function(t,r=0){return ft(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function wt(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function dt(e,t,r,n,i){return t=+t,r=r>>>0,i||wt(e,t,r,4,34028234663852886e22,-34028234663852886e22),S.write(e,t,r,n,23,4),r+4}c.prototype.writeFloatLE=function(t,r,n){return dt(this,t,r,!0,n)};c.prototype.writeFloatBE=function(t,r,n){return dt(this,t,r,!1,n)};function gt(e,t,r,n,i){return t=+t,r=r>>>0,i||wt(e,t,r,8,17976931348623157e292,-17976931348623157e292),S.write(e,t,r,n,52,8),r+8}c.prototype.writeDoubleLE=function(t,r,n){return gt(this,t,r,!0,n)};c.prototype.writeDoubleBE=function(t,r,n){return gt(this,t,r,!1,n)};c.prototype.copy=function(t,r,n,i){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};c.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let s=c.isBuffer(t)?t:c.from(t,i),a=s.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var C={};function H(e,t,r){C[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}H("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);H("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);H("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=ct(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=ct(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function ct(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function ar(e,t,r){k(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&T(t,e.length-(r+1))}function yt(e,t,r,n,i,o){if(e>r||e<t){let s=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${t}${s} and <= ${r}${s}`,new C.ERR_OUT_OF_RANGE("value",a,e)}ar(n,i,o)}function k(e,t){if(typeof e!="number")throw new C.ERR_INVALID_ARG_TYPE(t,"number",e)}function T(e,t,r){throw Math.floor(e)!==e?(k(e,r),new C.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new C.ERR_BUFFER_OUT_OF_BOUNDS:new C.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var ur=/[^+/0-9A-Za-z-_]/g;function mr(e){if(e=e.split("=")[0],e=e.trim().replace(ur,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function G(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function pr(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function lr(e,t){let r,n,i,o=[];for(let s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function xt(e){return j.toByteArray(mr(e))}function L(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function b(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function J(e){return e!==e}var hr=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function I(e){return typeof BigInt>"u"?fr:e}function fr(){throw new Error("BigInt not supported")}});var Ft={};D(Ft,{useSolanaWallet:()=>gr});var It,gr,At=X(()=>{"use strict";It=Q(require("bs58")),gr=()=>{let e=()=>{if(typeof window<"u"&&"solana"in window){let n=window;if(n.solana?.isPhantom)return n.solana}},t=async()=>{let n=e();if(n)try{return(await n.connect()).publicKey.toString()}catch{throw new Error("User rejected the connection")}else throw new Error("Phantom wallet not found")},r=async n=>{let i=e();if(!i)throw new Error("Wallet not connected");try{let o=new TextEncoder().encode(n),{signature:s}=await i.signMessage(o,"utf8");return It.default.encode(s)}catch(o){throw console.error("Solana Signing Error:",o),new Error(o.message||"Failed to sign message")}};return{isAvailable:!!e(),connect:t,signMessage:r}}});var Ct={};D(Ct,{useEVMWallet:()=>yr});var v,Ut,yr,St=X(()=>{"use strict";v=require("viem"),Ut=require("viem/chains"),yr=()=>{let e=()=>{if(typeof window<"u"&&"ethereum"in window)return window.ethereum},t=async()=>{let n=e();if(n)try{return(await n.request({method:"eth_requestAccounts"}))[0]}catch{throw new Error("User rejected the connection")}else throw new Error("MetaMask or other EVM wallet not found")},r=async(n,i)=>{let o=e();if(!o)throw new Error("Wallet not connected");try{return await(0,v.createWalletClient)({account:n,chain:Ut.base,transport:(0,v.custom)(o)}).signMessage({account:n,message:i})}catch(s){throw console.error("EVM Signing Error:",s),new Error(s.message||"Failed to sign message")}};return{isAvailable:!!e(),connect:t,signMessage:r}}});var br={};D(br,{AuthWidget:()=>dr,default:()=>xr,useCryptoAuth:()=>P});module.exports=Pt(br);var kt=Q(bt()),K=require("react");var Bt=require("react");var B=require("lucide-react");var wr="*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.mcms-mb-4{margin-bottom:1rem}.mcms-mb-6{margin-bottom:1.5rem}.mcms-mt-4{margin-top:1rem}.mcms-block{display:block}.mcms-flex{display:flex}.mcms-grid{display:grid}.mcms-h-10{height:2.5rem}.mcms-h-4{height:1rem}.mcms-h-5{height:1.25rem}.mcms-h-6{height:1.5rem}.mcms-w-10{width:2.5rem}.mcms-w-4{width:1rem}.mcms-w-5{width:1.25rem}.mcms-w-6{width:1.5rem}.mcms-flex-shrink-0{flex-shrink:0}@keyframes mcms-spin{to{transform:rotate(1turn)}}.mcms-animate-spin{animation:mcms-spin 1s linear infinite}.mcms-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.mcms-flex-col{flex-direction:column}.mcms-items-center{align-items:center}.mcms-justify-center{justify-content:center}.mcms-justify-between{justify-content:space-between}.mcms-gap-2{gap:.5rem}.mcms-gap-3{gap:.75rem}.mcms-gap-4{gap:1rem}.mcms-rounded-full{border-radius:9999px}.mcms-rounded-lg{border-radius:.5rem}.mcms-rounded-xl{border-radius:.75rem}.mcms-border{border-width:1px}.mcms-border-gray-100{--tw-border-opacity:1;border-color:rgb(243 244 246/var(--tw-border-opacity,1))}.mcms-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.mcms-border-green-100{--tw-border-opacity:1;border-color:rgb(220 252 231/var(--tw-border-opacity,1))}.mcms-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.mcms-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.mcms-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.mcms-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.mcms-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.mcms-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.mcms-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.mcms-p-2{padding:.5rem}.mcms-p-3{padding:.75rem}.mcms-p-4{padding:1rem}.mcms-p-6{padding:1.5rem}.mcms-py-8{padding-top:2rem;padding-bottom:2rem}.mcms-text-left{text-align:left}.mcms-text-center{text-align:center}.mcms-font-serif{font-family:ui-serif,Georgia,Cambria,Times New Roman,Times,serif}.mcms-text-lg{font-size:1.125rem;line-height:1.75rem}.mcms-text-sm{font-size:.875rem;line-height:1.25rem}.mcms-text-xs{font-size:.75rem;line-height:1rem}.mcms-font-bold{font-weight:700}.mcms-font-medium{font-weight:500}.mcms-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.mcms-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.mcms-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.mcms-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.mcms-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.mcms-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.mcms-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.mcms-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.mcms-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.mcms-transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover:mcms-border-blue-500:hover{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.hover:mcms-bg-blue-50:hover{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.mcms-group:hover .group-hover:mcms-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}",Et=()=>{if(typeof document>"u"||document.getElementById("mcms-crypto-styles"))return;let e=document.createElement("style");e.id="mcms-crypto-styles",e.textContent=wr,document.head.appendChild(e)};var h=require("react/jsx-runtime"),dr=({onSuccess:e,onError:t,className:r,endpoints:n,headers:i,allowedNetworks:o=["solana","evm"],hideHeader:s=!1,headerComponent:a})=>{let{status:u,error:l,authenticate:p}=P({onSuccess:e,onError:t,endpoints:n,headers:i});(0,Bt.useEffect)(()=>{Et()},[]);let m=()=>{switch(u){case"connecting":return"Connecting Wallet...";case"requesting_nonce":return"Getting Nonce...";case"pending_signature":return"Please Sign Message...";case"verifying":return"Verifying Signature...";default:return null}},w=(0,h.jsxs)("div",{className:"mcms-flex mcms-items-center mcms-gap-3 mcms-mb-6",children:[(0,h.jsx)("div",{className:"mcms-p-2 mcms-bg-blue-50 mcms-rounded-lg",children:(0,h.jsx)(B.Shield,{className:"mcms-w-6 mcms-h-6 mcms-text-blue-600"})}),(0,h.jsxs)("div",{children:[(0,h.jsx)("h3",{className:"mcms-text-lg mcms-font-bold mcms-text-gray-900",children:"Crypto Login"}),(0,h.jsx)("p",{className:"mcms-text-sm mcms-text-gray-500",children:"Sign in with your wallet"})]})]});return(0,h.jsxs)("div",{className:`mcms-p-6 mcms-bg-white mcms-rounded-xl mcms-shadow-lg mcms-border mcms-border-gray-100 ${r}`,children:[!s&&(a||w),l&&(0,h.jsxs)("div",{className:"mcms-mb-4 mcms-p-3 mcms-bg-red-50 mcms-text-red-700 mcms-rounded-lg mcms-flex mcms-items-center mcms-gap-2 mcms-text-sm mcms-border mcms-border-red-100",children:[(0,h.jsx)(B.AlertCircle,{className:"mcms-w-4 mcms-h-4 mcms-flex-shrink-0"}),(0,h.jsx)("p",{children:l})]}),u!=="idle"&&u!=="error"&&u!=="success"?(0,h.jsxs)("div",{className:"mcms-flex mcms-flex-col mcms-items-center mcms-justify-center mcms-py-8 mcms-gap-4",children:[(0,h.jsx)(B.Loader2,{className:"mcms-w-10 mcms-h-10 mcms-text-blue-600 mcms-animate-spin"}),(0,h.jsx)("p",{className:"mcms-text-sm mcms-font-medium mcms-text-gray-600",children:m()})]}):(0,h.jsxs)("div",{className:"mcms-grid mcms-grid-cols-1 mcms-gap-3",children:[o.includes("solana")&&(0,h.jsxs)("button",{onClick:()=>p("solana"),className:"mcms-flex mcms-items-center mcms-justify-between mcms-p-4 mcms-rounded-xl mcms-border mcms-border-gray-200 hover:mcms-border-blue-500 hover:mcms-bg-blue-50 mcms-transition-all mcms-group",children:[(0,h.jsxs)("div",{className:"mcms-flex mcms-items-center mcms-gap-3",children:[(0,h.jsx)("div",{className:"mcms-w-10 mcms-h-10 mcms-bg-black mcms-rounded-full mcms-flex mcms-items-center mcms-justify-center mcms-text-white mcms-font-bold",children:"S"}),(0,h.jsxs)("div",{className:"mcms-text-left",children:[(0,h.jsx)("span",{className:"mcms-block mcms-font-bold mcms-text-gray-900",children:"Solana"}),(0,h.jsx)("span",{className:"mcms-block mcms-text-xs mcms-text-gray-500",children:"Phantom, Solflare, etc."})]})]}),(0,h.jsx)(B.Wallet,{className:"mcms-w-5 mcms-h-5 mcms-text-gray-400 group-hover:mcms-text-blue-500"})]}),o.includes("evm")&&(0,h.jsxs)("button",{onClick:()=>p("evm"),className:"mcms-flex mcms-items-center mcms-justify-between mcms-p-4 mcms-rounded-xl mcms-border mcms-border-gray-200 hover:mcms-border-blue-500 hover:mcms-bg-blue-50 mcms-transition-all mcms-group",children:[(0,h.jsxs)("div",{className:"mcms-flex mcms-items-center mcms-gap-3",children:[(0,h.jsx)("div",{className:"mcms-w-10 mcms-h-10 mcms-bg-orange-500 mcms-rounded-full mcms-flex mcms-items-center mcms-justify-center mcms-text-white mcms-font-bold mcms-font-serif",children:"M"}),(0,h.jsxs)("div",{className:"mcms-text-left",children:[(0,h.jsx)("span",{className:"mcms-block mcms-font-bold mcms-text-gray-900",children:"Base / Ethereum"}),(0,h.jsx)("span",{className:"mcms-block mcms-text-xs mcms-text-gray-500",children:"MetaMask, Coinbase Wallet"})]})]}),(0,h.jsx)(B.Wallet,{className:"mcms-w-5 mcms-h-5 mcms-text-gray-400 group-hover:mcms-text-blue-500"})]})]}),u==="success"&&(0,h.jsx)("div",{className:"mcms-mt-4 mcms-p-3 mcms-bg-green-50 mcms-text-green-700 mcms-rounded-lg mcms-text-center mcms-text-sm mcms-border mcms-border-green-100",children:"Login Successful!"})]})};typeof window<"u"&&(window.Buffer||(window.Buffer=kt.Buffer),window.global||(window.global=window),window.process||(window.process={env:{}}));var P=(e={})=>{let[t,r]=(0,K.useState)("idle"),[n,i]=(0,K.useState)(null);return{status:t,error:n,authenticate:async s=>{try{r("connecting"),i(null);let a,u;if(s==="solana"){let{useSolanaWallet:m}=await Promise.resolve().then(()=>(At(),Ft)),w=m();a=await w.connect(),r("requesting_nonce");let d=await fetch(e.endpoints?.nonce||"/api/auth/crypto/nonce",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({address:a})}),{nonce:F}=await d.json();r("pending_signature"),u=await w.signMessage(`Sign this message to authenticate: ${F}`)}else{let{useEVMWallet:m}=await Promise.resolve().then(()=>(St(),Ct)),w=m();a=await w.connect(),r("requesting_nonce");let d=await fetch(e.endpoints?.nonce||"/api/auth/crypto/nonce",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({address:a})}),{nonce:F}=await d.json();r("pending_signature"),u=await w.signMessage(a,`Sign this message to authenticate: ${F}`)}r("verifying");let l=await fetch(e.endpoints?.verify||"/api/auth/crypto/verify",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({address:a,signature:u,network:s})});if(!l.ok)throw new Error("Verification failed");let{token:p}=await l.json();return r("success"),e.onSuccess?.(p),p}catch(a){throw i(a.message||"Authentication failed"),r("error"),e.onError?.(a),a}}}},xr={manifest:{name:"@micro-cms/crypto-auth-ui",version:"1.0.0",provides:["crypto-auth-ui"],requires:[]},async load(e){e.runtime.register("crypto-auth-ui",{useCryptoAuth:P})}};0&&(module.exports={AuthWidget,useCryptoAuth});
2
2
  /*! Bundled license information:
3
3
 
4
4
  ieee754/index.js: