@cedros/login-react 0.0.41 → 0.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AuthenticationSettings-CSoFp-_2.js → AuthenticationSettings-CxAubcoz.js} +1 -1
- package/dist/{AuthenticationSettings-CSoFp-_2.js.map → AuthenticationSettings-CxAubcoz.js.map} +1 -1
- package/dist/{AuthenticationSettings-Cu5Z2mTC.cjs → AuthenticationSettings-DPr882lj.cjs} +1 -1
- package/dist/{AuthenticationSettings-Cu5Z2mTC.cjs.map → AuthenticationSettings-DPr882lj.cjs.map} +1 -1
- package/dist/{AuthenticationSettings-DABzZHuI.cjs → AuthenticationSettings-Y40T1djV.cjs} +1 -1
- package/dist/{AuthenticationSettings-DABzZHuI.cjs.map → AuthenticationSettings-Y40T1djV.cjs.map} +1 -1
- package/dist/{AuthenticationSettings-D4ExU-2a.js → AuthenticationSettings-aVBFKKZ-.js} +1 -1
- package/dist/{AuthenticationSettings-D4ExU-2a.js.map → AuthenticationSettings-aVBFKKZ-.js.map} +1 -1
- package/dist/AutosaveStatus-ByD01ENa.cjs +1 -0
- package/dist/AutosaveStatus-ByD01ENa.cjs.map +1 -0
- package/dist/{AutosaveStatus-DMjvXzP2.js → AutosaveStatus-DtF_58rC.js} +608 -279
- package/dist/AutosaveStatus-DtF_58rC.js.map +1 -0
- package/dist/{CreditSystemSettings-BjQdysRS.js → CreditSystemSettings-BQek2Ux2.js} +1 -1
- package/dist/{CreditSystemSettings-BjQdysRS.js.map → CreditSystemSettings-BQek2Ux2.js.map} +1 -1
- package/dist/{CreditSystemSettings-DfSfQVE8.cjs → CreditSystemSettings-CbuCce29.cjs} +1 -1
- package/dist/{CreditSystemSettings-DfSfQVE8.cjs.map → CreditSystemSettings-CbuCce29.cjs.map} +1 -1
- package/dist/{CreditSystemSettings-BWuiRTtA.cjs → CreditSystemSettings-DHG_jhz9.cjs} +1 -1
- package/dist/{CreditSystemSettings-BWuiRTtA.cjs.map → CreditSystemSettings-DHG_jhz9.cjs.map} +1 -1
- package/dist/{CreditSystemSettings-Du3ac0ID.js → CreditSystemSettings-GDKgYc7I.js} +1 -1
- package/dist/{CreditSystemSettings-Du3ac0ID.js.map → CreditSystemSettings-GDKgYc7I.js.map} +1 -1
- package/dist/{EmailRegisterForm-CMXsa-_r.js → EmailRegisterForm-p2X5QP58.js} +147 -147
- package/dist/EmailRegisterForm-p2X5QP58.js.map +1 -0
- package/dist/EmailRegisterForm-xFb6MaVA.cjs +1 -0
- package/dist/EmailRegisterForm-xFb6MaVA.cjs.map +1 -0
- package/dist/{EmailSettings-CswtKXhb.cjs → EmailSettings-Cg4Z7139.cjs} +1 -1
- package/dist/{EmailSettings-CswtKXhb.cjs.map → EmailSettings-Cg4Z7139.cjs.map} +1 -1
- package/dist/{EmailSettings-BcHo0cqk.cjs → EmailSettings-CjxBg0cE.cjs} +1 -1
- package/dist/{EmailSettings-BcHo0cqk.cjs.map → EmailSettings-CjxBg0cE.cjs.map} +1 -1
- package/dist/{EmailSettings-CjngJwDS.js → EmailSettings-Ct6nFslP.js} +1 -1
- package/dist/{EmailSettings-CjngJwDS.js.map → EmailSettings-Ct6nFslP.js.map} +1 -1
- package/dist/{EmailSettings-ASDHfI0K.js → EmailSettings-D2pCqTKC.js} +1 -1
- package/dist/{EmailSettings-ASDHfI0K.js.map → EmailSettings-D2pCqTKC.js.map} +1 -1
- package/dist/{EmbeddedWalletSettings-CUY_X7Vj.js → EmbeddedWalletSettings-Bus7UyOX.js} +1 -1
- package/dist/{EmbeddedWalletSettings-CUY_X7Vj.js.map → EmbeddedWalletSettings-Bus7UyOX.js.map} +1 -1
- package/dist/{EmbeddedWalletSettings-BXlboZ9-.cjs → EmbeddedWalletSettings-CfzvFYnn.cjs} +1 -1
- package/dist/{EmbeddedWalletSettings-BXlboZ9-.cjs.map → EmbeddedWalletSettings-CfzvFYnn.cjs.map} +1 -1
- package/dist/{EmbeddedWalletSettings-CPLbqlxJ.js → EmbeddedWalletSettings-PwFgtGmK.js} +1 -1
- package/dist/{EmbeddedWalletSettings-CPLbqlxJ.js.map → EmbeddedWalletSettings-PwFgtGmK.js.map} +1 -1
- package/dist/{EmbeddedWalletSettings-BkwIbTkL.cjs → EmbeddedWalletSettings-t0_5poBu.cjs} +1 -1
- package/dist/{EmbeddedWalletSettings-BkwIbTkL.cjs.map → EmbeddedWalletSettings-t0_5poBu.cjs.map} +1 -1
- package/dist/GoogleLoginButton-2zNTIKMm.cjs +1 -0
- package/dist/GoogleLoginButton-2zNTIKMm.cjs.map +1 -0
- package/dist/{GoogleLoginButton-qf4A_A3G.js → GoogleLoginButton-C1WNu7W3.js} +41 -40
- package/dist/GoogleLoginButton-C1WNu7W3.js.map +1 -0
- package/dist/LoadingSpinner-6vml-zwr.js.map +1 -1
- package/dist/LoadingSpinner-d6sSxgQN.cjs.map +1 -1
- package/dist/{PermissionsSection-BeFhIgQy.js → PermissionsSection-BDDiEfho.js} +81 -77
- package/dist/{PermissionsSection-BeFhIgQy.js.map → PermissionsSection-BDDiEfho.js.map} +1 -1
- package/dist/PermissionsSection-CSB_Ikj9.cjs +1 -0
- package/dist/{PermissionsSection-B-6DJnN8.cjs.map → PermissionsSection-CSB_Ikj9.cjs.map} +1 -1
- package/dist/{ServerSettings-BygCxOTY.cjs → ServerSettings-BjLFs_sb.cjs} +1 -1
- package/dist/{ServerSettings-BygCxOTY.cjs.map → ServerSettings-BjLFs_sb.cjs.map} +1 -1
- package/dist/{ServerSettings-B9PNMse1.js → ServerSettings-COkhan4u.js} +1 -1
- package/dist/{ServerSettings-B9PNMse1.js.map → ServerSettings-COkhan4u.js.map} +1 -1
- package/dist/{ServerSettings-BLoWX7KG.js → ServerSettings-D7WJDTbZ.js} +1 -1
- package/dist/{ServerSettings-BLoWX7KG.js.map → ServerSettings-D7WJDTbZ.js.map} +1 -1
- package/dist/{ServerSettings-CgBdYspU.cjs → ServerSettings-Dmw2rpFA.cjs} +1 -1
- package/dist/{ServerSettings-CgBdYspU.cjs.map → ServerSettings-Dmw2rpFA.cjs.map} +1 -1
- package/dist/SolanaLoginButton-CqdzSSeJ.cjs +1 -0
- package/dist/SolanaLoginButton-CqdzSSeJ.cjs.map +1 -0
- package/dist/{SolanaLoginButton-B04dib6X.js → SolanaLoginButton-CyeX35eU.js} +41 -40
- package/dist/SolanaLoginButton-CyeX35eU.js.map +1 -0
- package/dist/{TeamSection-DbSYDRdI.js → TeamSection-BhsBEckR.js} +1 -1
- package/dist/{TeamSection-DbSYDRdI.js.map → TeamSection-BhsBEckR.js.map} +1 -1
- package/dist/{TeamSection-B1t1tU-_.cjs → TeamSection-DLxtRmta.cjs} +1 -1
- package/dist/{TeamSection-B1t1tU-_.cjs.map → TeamSection-DLxtRmta.cjs.map} +1 -1
- package/dist/{UsersSection-C7aRNkK2.cjs → UsersSection-BEKfbhQ4.cjs} +1 -1
- package/dist/{UsersSection-C7aRNkK2.cjs.map → UsersSection-BEKfbhQ4.cjs.map} +1 -1
- package/dist/{UsersSection--PAE1XRh.js → UsersSection-DbGkmxty.js} +1 -1
- package/dist/{UsersSection--PAE1XRh.js.map → UsersSection-DbGkmxty.js.map} +1 -1
- package/dist/{WebhookSettings-C-7Yxueu.js → WebhookSettings-CpPvGmV7.js} +1 -1
- package/dist/{WebhookSettings-C-7Yxueu.js.map → WebhookSettings-CpPvGmV7.js.map} +1 -1
- package/dist/{WebhookSettings-C923ZSKa.js → WebhookSettings-DEHV2ptf.js} +1 -1
- package/dist/{WebhookSettings-C923ZSKa.js.map → WebhookSettings-DEHV2ptf.js.map} +1 -1
- package/dist/{WebhookSettings-CbU3cfTJ.cjs → WebhookSettings-DbyPJ8V2.cjs} +1 -1
- package/dist/{WebhookSettings-CbU3cfTJ.cjs.map → WebhookSettings-DbyPJ8V2.cjs.map} +1 -1
- package/dist/{WebhookSettings-D19u9Uok.cjs → WebhookSettings-Rq_nNJuw.cjs} +1 -1
- package/dist/{WebhookSettings-D19u9Uok.cjs.map → WebhookSettings-Rq_nNJuw.cjs.map} +1 -1
- package/dist/admin-only.cjs +1 -1
- package/dist/admin-only.js +1 -1
- package/dist/email-only.cjs +1 -1
- package/dist/email-only.d.ts +6 -0
- package/dist/email-only.js +2 -2
- package/dist/google-only.cjs +1 -1
- package/dist/google-only.d.ts +6 -0
- package/dist/google-only.js +2 -2
- package/dist/index.cjs +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +500 -1
- package/dist/index.js +5656 -4205
- package/dist/index.js.map +1 -1
- package/dist/{plugin-BiftIhZe.js → plugin-Bwwe7_ZO.js} +3 -2
- package/dist/plugin-Bwwe7_ZO.js.map +1 -0
- package/dist/plugin-C4bijrSr.cjs +1 -0
- package/dist/plugin-C4bijrSr.cjs.map +1 -0
- package/dist/solana-only.cjs +1 -1
- package/dist/solana-only.d.ts +6 -0
- package/dist/solana-only.js +2 -2
- package/dist/useAuth-B1yS_YiD.cjs +1 -0
- package/dist/{useAuth-U5CYsHEU.cjs.map → useAuth-B1yS_YiD.cjs.map} +1 -1
- package/dist/{useAuth-C-Vw-ggy.js → useAuth-l-itM5am.js} +440 -433
- package/dist/{useAuth-C-Vw-ggy.js.map → useAuth-l-itM5am.js.map} +1 -1
- package/dist/useUsersStatsSummary-9HQDKBU5.js +1879 -0
- package/dist/useUsersStatsSummary-9HQDKBU5.js.map +1 -0
- package/dist/useUsersStatsSummary-DiRC8sGs.cjs +1 -0
- package/dist/useUsersStatsSummary-DiRC8sGs.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/AutosaveStatus-B1A1zORa.cjs +0 -1
- package/dist/AutosaveStatus-B1A1zORa.cjs.map +0 -1
- package/dist/AutosaveStatus-DMjvXzP2.js.map +0 -1
- package/dist/EmailRegisterForm-CMXsa-_r.js.map +0 -1
- package/dist/EmailRegisterForm-i7f4St2N.cjs +0 -1
- package/dist/EmailRegisterForm-i7f4St2N.cjs.map +0 -1
- package/dist/GoogleLoginButton-JtRViYWS.cjs +0 -1
- package/dist/GoogleLoginButton-JtRViYWS.cjs.map +0 -1
- package/dist/GoogleLoginButton-qf4A_A3G.js.map +0 -1
- package/dist/PermissionsSection-B-6DJnN8.cjs +0 -1
- package/dist/SolanaLoginButton-B04dib6X.js.map +0 -1
- package/dist/SolanaLoginButton-nSJHVFpZ.cjs +0 -1
- package/dist/SolanaLoginButton-nSJHVFpZ.cjs.map +0 -1
- package/dist/plugin-BiftIhZe.js.map +0 -1
- package/dist/plugin-BtQdI_Ay.cjs +0 -1
- package/dist/plugin-BtQdI_Ay.cjs.map +0 -1
- package/dist/useAuth-U5CYsHEU.cjs +0 -1
- package/dist/useUsersStatsSummary-5DJwzntC.js +0 -1246
- package/dist/useUsersStatsSummary-5DJwzntC.js.map +0 -1
- package/dist/useUsersStatsSummary-DgKaUIfs.cjs +0 -1
- package/dist/useUsersStatsSummary-DgKaUIfs.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./useAuth-U5CYsHEU.cjs"),T=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),d=require("react"),z=require("./LoadingSpinner-d6sSxgQN.cjs"),Ms=require("./sanitization-Bo_tn-L2.cjs"),Q=require("./EmailRegisterForm-i7f4St2N.cjs"),Ie=require("./validation-BuGQrA-K.cjs"),Z=require("./ErrorMessage-CHbYbVi2.cjs"),Rs=require("./GoogleLoginButton-JtRViYWS.cjs"),ze=require("./SolanaLoginButton-nSJHVFpZ.cjs"),ie=require("./PermissionsSection-B-6DJnN8.cjs"),mn=require("./useSystemSettings-B2jY51ob.cjs"),Ae=require("./AutosaveStatus-B1A1zORa.cjs"),Ts=require("./useOrgs-CNqfn-fk.cjs"),mt=require("./AdminDepositList-B_z6x3j5.cjs"),Be=require("./AdminWithdrawalHistory-B2EY2ZmH.cjs"),et=require("./useUsersStatsSummary-DgKaUIfs.cjs"),gn=require("./StatsBar-DTUZCwDD.cjs"),Me=require("./plugin-BtQdI_Ay.cjs"),wn=require("./AuthenticationSettings-Cu5Z2mTC.cjs"),bn=require("./EmbeddedWalletSettings-BkwIbTkL.cjs"),ut=require("./EmailSettings-BcHo0cqk.cjs"),Is=require("./CreditSystemSettings-BWuiRTtA.cjs"),yn=require("./ServerSettings-BygCxOTY.cjs"),sa=require("./useAdminDeposits-CpLd68oP.cjs"),_s=require("./WebhookSettings-CbU3cfTJ.cjs");var Ut=typeof document<"u"?document.currentScript:null;let Re=null,ra=0;const Je=new Map;function na(){return typeof Worker>"u"?null:(Re||(Re=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/argon2Worker-Bi5TuQvD.js").href:new URL("assets/argon2Worker-Bi5TuQvD.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:Ut&&Ut.tagName.toUpperCase()==="SCRIPT"&&Ut.src||new URL("index.cjs",document.baseURI).href),{type:"module"}),Re.onmessage=t=>{const{id:s,key:r,error:o}=t.data,n=Je.get(s);if(n){if(Je.delete(s),o){n.reject(new Error(o));return}if(!r){n.reject(new Error("Argon2 worker returned no key"));return}n.resolve(r)}},Re.onerror=t=>{const s=t instanceof ErrorEvent?t.error:new Error("Argon2 worker error");for(const r of Je.values())r.reject(s instanceof Error?s:new Error(String(s)));Je.clear(),Re?.terminate(),Re=null}),Re)}async function xn(t,s,r=_.DEFAULT_KDF_PARAMS){_.validateKdfParams(r);const o=na();return o?new Promise((n,a)=>{const l=ra++;Je.set(l,{resolve:n,reject:a});const i={id:l,password:t,salt:s,params:r};o.postMessage(i)}):_.argon2Derive(t,s,r)}function An(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function oa(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var s=t.default;if(typeof s=="function"){var r=function o(){var n=!1;try{n=this instanceof o}catch{}return n?Reflect.construct(s,arguments,this.constructor):s.apply(this,arguments)};r.prototype=s.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r,o,n.get?n:{enumerable:!0,get:function(){return t[o]}})}),r}var ht={exports:{}};const aa=globalThis.crypto,ia=globalThis.crypto,ca=globalThis.crypto.subtle,la=globalThis.crypto.getRandomValues.bind(globalThis.crypto),da=globalThis.crypto.randomUUID.bind(globalThis.crypto),ua=Object.freeze(Object.defineProperty({__proto__:null,default:aa,getRandomValues:la,randomUUID:da,subtle:ca,webcrypto:ia},Symbol.toStringTag,{value:"Module"})),ha=oa(ua);var fa=ht.exports,ur;function pa(){return ur||(ur=1,(function(t,s){(function(r,o){t.exports=o(ha)})(fa,function(r){var o,n,a,l,i;function c(){o={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},n={},a=new Array(1024).join("0"),l=!0,i=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function u(){return!!(n&&n.rng&&typeof n.rng=="function")}function f(g,v){var A;if(v===0||v===1)return g;if(v&&v>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return v=v||n.bits,g&&(A=g.length%v),A?(a+g).slice(-(v-A+g.length)):g}function h(g){var v="",A,y;for(y=g.length-1;y>=0;y--){if(A=parseInt(g[y],16),isNaN(A))throw new Error("Invalid hex character.");v=f(A.toString(2),4)+v}return v}function p(g){var v="",A,y;for(g=f(g,4),y=g.length;y>=4;y-=4){if(A=parseInt(g.slice(y-4,y),2),isNaN(A))throw new Error("Invalid binary character.");v=A.toString(16)+v}return v}function b(){return!!(r&&typeof r=="object"&&(typeof r.getRandomValues=="function"||typeof r.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function w(){return typeof r=="object"&&typeof r.randomBytes=="function"}function m(g){function v(S,B,E,M){var R=0,F,U="",q;for(B&&(F=B.length-1);R<F||U.length<S;)q=Math.abs(parseInt(B[R],E)),U=U+f(q.toString(2),M),R++;return U=U.substr(-S),(U.match(/0/g)||[]).length===U.length?null:U}function A(S){var B,E,M,R,F=null;for(M=16,R=4,E=Math.ceil(S/8);F===null;)B=r.randomBytes(E),F=v(S,B.toString("hex"),M,R);return F}function y(S){var B,E,M,R=null;for(E=10,M=32,B=Math.ceil(S/32);R===null;)R=v(S,r.getRandomValues(new Uint32Array(B)),E,M);return R}function L(S){var B,E,M,R,F,U=null;R=10,F=32,E=Math.ceil(S/32),M=123456789,B=new Uint32Array(E);for(var q=0;q<B.length;q++)B[q]=M;for(;U===null;)U=v(S,B,R,F);return U}if(g&&g==="testRandom")return n.typeCSPRNG=g,L;if(g&&g==="nodeCryptoRandomBytes")return n.typeCSPRNG=g,A;if(g&&g==="browserCryptoGetRandomValues")return n.typeCSPRNG=g,y;if(w())return n.typeCSPRNG="nodeCryptoRandomBytes",A;if(b())return n.typeCSPRNG="browserCryptoGetRandomValues",y}function k(g,v){var A=[],y;for(v&&(g=f(g,v)),y=g.length;y>n.bits;y-=n.bits)A.push(parseInt(g.slice(y-n.bits,y),2));return A.push(parseInt(g.slice(0,y),2)),A}function x(g,v){var A=n.logs[g],y=0,L;for(L=v.length-1;L>=0;L--)y!==0?y=n.exps[(A+n.logs[y])%n.maxShares]^v[L]:y=v[L];return y}function N(g,v,A){var y=0,L,S,B,E;for(B=0,L=v.length;B<L;B++)if(A[B]){for(S=n.logs[A[B]],E=0;E<L;E++)if(B!==E){if(g===v[E]){S=-1;break}S=(S+n.logs[g^v[E]]-n.logs[v[B]^v[E]]+n.maxShares)%n.maxShares}y=S===-1?y:y^n.exps[S]}return y}function j(g,v,A){var y=[],L=[g],S,B;for(S=1;S<A;S++)L[S]=parseInt(n.rng(n.bits),2);for(S=1,B=v+1;S<B;S++)y[S-1]={x:S,y:x(S,L)};return y}function C(g,v,A){var y,L,S,B,E;if(v=parseInt(v,n.radix),g=parseInt(g,10)||n.bits,y=g.toString(36).toUpperCase(),S=Math.pow(2,g)-1,B=S.toString(n.radix).length,L=f(v.toString(n.radix),B),typeof v!="number"||v%1!==0||v<1||v>S)throw new Error("Share id must be an integer between 1 and "+S+", inclusive.");return E=y+L+A,E}var P={init:function(g,v){var A=[],y=[],L=1,S,B;if(c(),g&&(typeof g!="number"||g%1!==0||g<o.minBits||g>o.maxBits))throw new Error("Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(v&&i.indexOf(v)===-1)throw new Error("Invalid RNG type argument : '"+v+"'");for(n.radix=o.radix,n.bits=g||o.bits,n.size=Math.pow(2,n.bits),n.maxShares=n.size-1,S=o.primitivePolynomials[n.bits],B=0;B<n.size;B++)y[B]=L,A[L]=B,L=L<<1,L>=n.size&&(L=L^S,L=L&n.maxShares);if(n.logs=A,n.exps=y,v&&this.setRNG(v),u()||this.setRNG(),!u()||!n.bits||!n.size||!n.maxShares||!n.logs||!n.exps||n.logs.length!==n.size||n.exps.length!==n.size)throw new Error("Initialization failed.")},combine:function(g,v){var A,y,L,S,B="",E,M,R,F=[],U=[];for(v=v||0,A=0,L=g.length;A<L;A++){if(M=this.extractShareComponents(g[A]),E===void 0)E=M.bits;else if(M.bits!==E)throw new Error("Mismatched shares: Different bit settings.");if(n.bits!==E&&this.init(E),F.indexOf(M.id)===-1)for(F.push(M.id),R=k(h(M.data)),y=0,S=R.length;y<S;y++)U[y]=U[y]||[],U[y][F.length-1]=R[y]}for(A=0,L=U.length;A<L;A++)B=f(N(v,F,U[A]).toString(2))+B;return p(v>=1?B:B.slice(B.indexOf("1")+1))},getConfig:function(){var g={};return g.radix=n.radix,g.bits=n.bits,g.maxShares=n.maxShares,g.hasCSPRNG=u(),g.typeCSPRNG=n.typeCSPRNG,g},extractShareComponents:function(g){var v,A,y,L,S={},B,E;if(v=parseInt(g.substr(0,1),36),v&&(typeof v!="number"||v%1!==0||v<o.minBits||v>o.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(L=Math.pow(2,v)-1,y=(Math.pow(2,v)-1).toString(n.radix).length,B="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+y+"})([a-fA-F0-9]+)$",E=new RegExp(B).exec(g),E&&(A=parseInt(E[2],n.radix)),typeof A!="number"||A%1!==0||A<1||A>L)throw new Error("Invalid share : Share id must be an integer between 1 and "+n.maxShares+", inclusive.");if(E&&E[3])return S.bits=v,S.id=A,S.data=E[3],S;throw new Error("The share data provided is invalid : "+g)},setRNG:function(g){var v="Random number generator is invalid ",A=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(g&&typeof g=="string"&&i.indexOf(g)===-1)throw new Error("Invalid RNG type argument : '"+g+"'");if(g||(g=m()),g&&typeof g=="string"&&(g=m(g)),l){if(g&&typeof g!="function")throw new Error(v+"(Not a function)."+A);if(g&&typeof g(n.bits)!="string")throw new Error(v+"(Output is not a string)."+A);if(g&&!parseInt(g(n.bits),2))throw new Error(v+"(Binary string output not parseable to an Integer)."+A);if(g&&g(n.bits).length>n.bits)throw new Error(v+"(Output length is greater than config.bits)."+A);if(g&&g(n.bits).length<n.bits)throw new Error(v+"(Output length is less than config.bits)."+A)}return n.rng=g,!0},str2hex:function(g,v){var A,y,L="",S,B,E,M;if(typeof g!="string")throw new Error("Input must be a character string.");if(v||(v=o.bytesPerChar),typeof v!="number"||v<1||v>o.maxBytesPerChar||v%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(A=2*v,y=Math.pow(16,A)-1,E=0,M=g.length;E<M;E++){if(B=g[E].charCodeAt(),isNaN(B))throw new Error("Invalid character: "+g[E]);if(B>y)throw S=Math.ceil(Math.log(B+1)/Math.log(256)),new Error("Invalid character code ("+B+"). Maximum allowable is 256^bytes-1 ("+y+"). To convert this character, use at least "+S+" bytes.");L=f(B.toString(16),A)+L}return L},hex2str:function(g,v){var A,y="",L,S;if(typeof g!="string")throw new Error("Input must be a hexadecimal string.");if(v=v||o.bytesPerChar,typeof v!="number"||v%1!==0||v<1||v>o.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(A=2*v,g=f(g,A),L=0,S=g.length;L<S;L+=A)y=String.fromCharCode(parseInt(g.slice(L,L+A),16))+y;return y},random:function(g){if(typeof g!="number"||g%1!==0||g<2||g>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return p(n.rng(g))},share:function(g,v,A,y){var L,S,B=new Array(v),E=new Array(v),M,R,F;if(y=y||128,typeof g!="string")throw new Error("Secret must be a string.");if(typeof v!="number"||v%1!==0||v<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(v>n.maxShares)throw L=Math.ceil(Math.log(v+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To create "+v+" shares, use at least "+L+" bits.");if(typeof A!="number"||A%1!==0||A<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(A>n.maxShares)throw L=Math.ceil(Math.log(A+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To use a threshold of "+A+", use at least "+L+" bits.");if(A>v)throw new Error("Threshold number of shares was "+A+" but must be less than or equal to the "+v+" shares specified as the total to generate.");if(typeof y!="number"||y%1!==0||y<0||y>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(g="1"+h(g),g=k(g,y),M=0,F=g.length;M<F;M++)for(S=j(g[M],v,A),R=0;R<v;R++)B[R]=B[R]||S[R].x.toString(n.radix),E[R]=f(S[R].y.toString(2))+(E[R]||"");for(M=0;M<v;M++)B[M]=C(n.bits,B[M],p(E[M]));return B},newShare:function(g,v){var A,y;if(g&&typeof g=="string"&&(g=parseInt(g,n.radix)),y=g.toString(n.radix),g&&y&&v&&v[0])return A=this.extractShareComponents(v[0]),C(A.bits,y,this.combine(v,g));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:c,_padLeft:f,_hex2bin:h,_bin2hex:p,_hasCryptoGetRandomValues:b,_hasCryptoRandomBytes:w,_getRNG:m,_isSetRNG:u,_splitNumStringToIntArray:k,_horner:x,_lagrange:N,_getShares:j,_constructPublicShareString:C};return P.init(),P})})(ht)),ht.exports}var ma=pa();const vn=An(ma);function jn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ds(t,s=""){if(!Number.isSafeInteger(t)||t<0){const r=s&&`"${s}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function se(t,s,r=""){const o=jn(t),n=t?.length,a=s!==void 0;if(!o||a&&n!==s){const l=r&&`"${r}" `,i=a?` of length ${s}`:"",c=o?`length=${n}`:`type=${typeof t}`;throw new Error(l+"expected Uint8Array"+i+", got "+c)}return t}function hr(t,s=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(s&&t.finished)throw new Error("Hash#digest() has already been called")}function ga(t,s){se(t,void 0,"digestInto() output");const r=s.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function vs(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function Ft(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const kn=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",wa=Array.from({length:256},(t,s)=>s.toString(16).padStart(2,"0"));function Us(t){if(se(t),kn)return t.toHex();let s="";for(let r=0;r<t.length;r++)s+=wa[t[r]];return s}const ye={_0:48,_9:57,A:65,F:70,a:97,f:102};function fr(t){if(t>=ye._0&&t<=ye._9)return t-ye._0;if(t>=ye.A&&t<=ye.F)return t-(ye.A-10);if(t>=ye.a&&t<=ye.f)return t-(ye.a-10)}function Nn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(kn)return Uint8Array.fromHex(t);const s=t.length,r=s/2;if(s%2)throw new Error("hex string expected, got unpadded hex of length "+s);const o=new Uint8Array(r);for(let n=0,a=0;n<r;n++,a+=2){const l=fr(t.charCodeAt(a)),i=fr(t.charCodeAt(a+1));if(l===void 0||i===void 0){const c=t[a]+t[a+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+a)}o[n]=l*16+i}return o}function pr(...t){let s=0;for(let o=0;o<t.length;o++){const n=t[o];se(n),s+=n.length}const r=new Uint8Array(s);for(let o=0,n=0;o<t.length;o++){const a=t[o];r.set(a,n),n+=a.length}return r}function ba(t,s={}){const r=(n,a)=>t(a).update(n).digest(),o=t(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=n=>t(n),Object.assign(r,s),Object.freeze(r)}function ya(t=32){const s=typeof globalThis=="object"?globalThis.crypto:null;if(typeof s?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return s.getRandomValues(new Uint8Array(t))}const xa=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});let Aa=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(s,r,o,n){this.blockLen=s,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(s),this.view=Ft(this.buffer)}update(s){hr(this),se(s);const{view:r,buffer:o,blockLen:n}=this,a=s.length;for(let l=0;l<a;){const i=Math.min(n-this.pos,a-l);if(i===n){const c=Ft(s);for(;n<=a-l;l+=n)this.process(c,l);continue}o.set(s.subarray(l,l+i),this.pos),this.pos+=i,l+=i,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){hr(this),ga(s,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:l}=this;r[l++]=128,vs(this.buffer.subarray(l)),this.padOffset>n-l&&(this.process(o,0),l=0);for(let h=l;h<n;h++)r[h]=0;o.setBigUint64(n-8,BigInt(this.length*8),a),this.process(o,0);const i=Ft(s),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)i.setUint32(4*h,f[h],a)}digest(){const{buffer:s,outputLen:r}=this;this.digestInto(s);const o=s.slice(0,r);return this.destroy(),o}_cloneInto(s){s||=new this.constructor,s.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:l,pos:i}=this;return s.destroyed=l,s.finished=a,s.length=n,s.pos=i,n%r&&s.buffer.set(o),s}clone(){return this._cloneInto()}};const re=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),nt=BigInt(2**32-1),mr=BigInt(32);function va(t,s=!1){return s?{h:Number(t&nt),l:Number(t>>mr&nt)}:{h:Number(t>>mr&nt)|0,l:Number(t&nt)|0}}function ja(t,s=!1){const r=t.length;let o=new Uint32Array(r),n=new Uint32Array(r);for(let a=0;a<r;a++){const{h:l,l:i}=va(t[a],s);[o[a],n[a]]=[l,i]}return[o,n]}const gr=(t,s,r)=>t>>>r,wr=(t,s,r)=>t<<32-r|s>>>r,Fe=(t,s,r)=>t>>>r|s<<32-r,Oe=(t,s,r)=>t<<32-r|s>>>r,ot=(t,s,r)=>t<<64-r|s>>>r-32,at=(t,s,r)=>t>>>r-32|s<<64-r;function xe(t,s,r,o){const n=(s>>>0)+(o>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const ka=(t,s,r)=>(t>>>0)+(s>>>0)+(r>>>0),Na=(t,s,r,o)=>s+r+o+(t/2**32|0)|0,Ca=(t,s,r,o)=>(t>>>0)+(s>>>0)+(r>>>0)+(o>>>0),Sa=(t,s,r,o,n)=>s+r+o+n+(t/2**32|0)|0,Ea=(t,s,r,o,n)=>(t>>>0)+(s>>>0)+(r>>>0)+(o>>>0)+(n>>>0),La=(t,s,r,o,n,a)=>s+r+o+n+a+(t/2**32|0)|0,Cn=ja(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Pa=Cn[0],Ba=Cn[1],Ne=new Uint32Array(80),Ce=new Uint32Array(80);class Ma extends Aa{constructor(s){super(128,s,16,!1)}get(){const{Ah:s,Al:r,Bh:o,Bl:n,Ch:a,Cl:l,Dh:i,Dl:c,Eh:u,El:f,Fh:h,Fl:p,Gh:b,Gl:w,Hh:m,Hl:k}=this;return[s,r,o,n,a,l,i,c,u,f,h,p,b,w,m,k]}set(s,r,o,n,a,l,i,c,u,f,h,p,b,w,m,k){this.Ah=s|0,this.Al=r|0,this.Bh=o|0,this.Bl=n|0,this.Ch=a|0,this.Cl=l|0,this.Dh=i|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=h|0,this.Fl=p|0,this.Gh=b|0,this.Gl=w|0,this.Hh=m|0,this.Hl=k|0}process(s,r){for(let j=0;j<16;j++,r+=4)Ne[j]=s.getUint32(r),Ce[j]=s.getUint32(r+=4);for(let j=16;j<80;j++){const C=Ne[j-15]|0,P=Ce[j-15]|0,g=Fe(C,P,1)^Fe(C,P,8)^gr(C,P,7),v=Oe(C,P,1)^Oe(C,P,8)^wr(C,P,7),A=Ne[j-2]|0,y=Ce[j-2]|0,L=Fe(A,y,19)^ot(A,y,61)^gr(A,y,6),S=Oe(A,y,19)^at(A,y,61)^wr(A,y,6),B=Ca(v,S,Ce[j-7],Ce[j-16]),E=Sa(B,g,L,Ne[j-7],Ne[j-16]);Ne[j]=E|0,Ce[j]=B|0}let{Ah:o,Al:n,Bh:a,Bl:l,Ch:i,Cl:c,Dh:u,Dl:f,Eh:h,El:p,Fh:b,Fl:w,Gh:m,Gl:k,Hh:x,Hl:N}=this;for(let j=0;j<80;j++){const C=Fe(h,p,14)^Fe(h,p,18)^ot(h,p,41),P=Oe(h,p,14)^Oe(h,p,18)^at(h,p,41),g=h&b^~h&m,v=p&w^~p&k,A=Ea(N,P,v,Ba[j],Ce[j]),y=La(A,x,C,g,Pa[j],Ne[j]),L=A|0,S=Fe(o,n,28)^ot(o,n,34)^ot(o,n,39),B=Oe(o,n,28)^at(o,n,34)^at(o,n,39),E=o&a^o&i^a&i,M=n&l^n&c^l&c;x=m|0,N=k|0,m=b|0,k=w|0,b=h|0,w=p|0,{h,l:p}=xe(u|0,f|0,y|0,L|0),u=i|0,f=c|0,i=a|0,c=l|0,a=o|0,l=n|0;const R=ka(L,B,M);o=Na(R,y,S,E),n=R|0}({h:o,l:n}=xe(this.Ah|0,this.Al|0,o|0,n|0)),{h:a,l}=xe(this.Bh|0,this.Bl|0,a|0,l|0),{h:i,l:c}=xe(this.Ch|0,this.Cl|0,i|0,c|0),{h:u,l:f}=xe(this.Dh|0,this.Dl|0,u|0,f|0),{h,l:p}=xe(this.Eh|0,this.El|0,h|0,p|0),{h:b,l:w}=xe(this.Fh|0,this.Fl|0,b|0,w|0),{h:m,l:k}=xe(this.Gh|0,this.Gl|0,m|0,k|0),{h:x,l:N}=xe(this.Hh|0,this.Hl|0,x|0,N|0),this.set(o,n,a,l,i,c,u,f,h,p,b,w,m,k,x,N)}roundClean(){vs(Ne,Ce)}destroy(){vs(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Ra extends Ma{Ah=re[0]|0;Al=re[1]|0;Bh=re[2]|0;Bl=re[3]|0;Ch=re[4]|0;Cl=re[5]|0;Dh=re[6]|0;Dl=re[7]|0;Eh=re[8]|0;El=re[9]|0;Fh=re[10]|0;Fl=re[11]|0;Gh=re[12]|0;Gl=re[13]|0;Hh=re[14]|0;Hl=re[15]|0;constructor(){super(64)}}const Ta=ba(()=>new Ra,xa(3));const Sn=BigInt(0),br=BigInt(1);function js(t,s=""){if(typeof t!="boolean"){const r=s&&`"${s}" `;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function Ia(t){if(typeof t=="bigint"){if(!ft(t))throw new Error("positive bigint expected, got "+t)}else Ds(t);return t}function En(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Sn:BigInt("0x"+t)}function _a(t){return En(Us(t))}function gt(t){return En(Us(ks(se(t)).reverse()))}function Ln(t,s){Ds(s),t=Ia(t);const r=Nn(t.toString(16).padStart(s*2,"0"));if(r.length!==s)throw new Error("number too large");return r}function Da(t,s){return Ln(t,s).reverse()}function ks(t){return Uint8Array.from(t)}const ft=t=>typeof t=="bigint"&&Sn<=t;function Ua(t,s,r){return ft(t)&&ft(s)&&ft(r)&&s<=t&&t<r}function yr(t,s,r,o){if(!Ua(s,r,o))throw new Error("expected valid "+t+": "+r+" <= n < "+o+", got "+s)}const Fa=t=>(br<<BigInt(t))-br;function Fs(t,s={},r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function o(a,l,i){const c=t[a];if(i&&c===void 0)return;const u=typeof c;if(u!==l||c===null)throw new Error(`param "${a}" is invalid: expected ${l}, got ${u}`)}const n=(a,l)=>Object.entries(a).forEach(([i,c])=>o(i,c,l));n(s,!1),n(r,!0)}function xr(t){const s=new WeakMap;return(r,...o)=>{const n=s.get(r);if(n!==void 0)return n;const a=t(r,...o);return s.set(r,a),a}}const ce=BigInt(0),ae=BigInt(1),Te=BigInt(2),Pn=BigInt(3),Bn=BigInt(4),Mn=BigInt(5),Oa=BigInt(7),Rn=BigInt(8),Wa=BigInt(9),Tn=BigInt(16);function ee(t,s){const r=t%s;return r>=ce?r:s+r}function me(t,s,r){let o=t;for(;s-- >ce;)o*=o,o%=r;return o}function Ar(t,s){if(t===ce)throw new Error("invert: expected non-zero number");if(s<=ce)throw new Error("invert: expected positive modulus, got "+s);let r=ee(t,s),o=s,n=ce,a=ae;for(;r!==ce;){const i=o/r,c=o%r,u=n-a*i;o=r,r=c,n=a,a=u}if(o!==ae)throw new Error("invert: does not exist");return ee(n,s)}function Os(t,s,r){if(!t.eql(t.sqr(s),r))throw new Error("Cannot find square root")}function In(t,s){const r=(t.ORDER+ae)/Bn,o=t.pow(s,r);return Os(t,o,s),o}function qa(t,s){const r=(t.ORDER-Mn)/Rn,o=t.mul(s,Te),n=t.pow(o,r),a=t.mul(s,n),l=t.mul(t.mul(a,Te),n),i=t.mul(a,t.sub(l,t.ONE));return Os(t,i,s),i}function za(t){const s=Ws(t),r=_n(t),o=r(s,s.neg(s.ONE)),n=r(s,o),a=r(s,s.neg(o)),l=(t+Oa)/Tn;return(i,c)=>{let u=i.pow(c,l),f=i.mul(u,o);const h=i.mul(u,n),p=i.mul(u,a),b=i.eql(i.sqr(f),c),w=i.eql(i.sqr(h),c);u=i.cmov(u,f,b),f=i.cmov(p,h,w);const m=i.eql(i.sqr(f),c),k=i.cmov(u,f,m);return Os(i,k,c),k}}function _n(t){if(t<Pn)throw new Error("sqrt is not defined for small field");let s=t-ae,r=0;for(;s%Te===ce;)s/=Te,r++;let o=Te;const n=Ws(t);for(;vr(n,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return In;let a=n.pow(o,s);const l=(s+ae)/Te;return function(c,u){if(c.is0(u))return u;if(vr(c,u)!==1)throw new Error("Cannot find square root");let f=r,h=c.mul(c.ONE,a),p=c.pow(u,s),b=c.pow(u,l);for(;!c.eql(p,c.ONE);){if(c.is0(p))return c.ZERO;let w=1,m=c.sqr(p);for(;!c.eql(m,c.ONE);)if(w++,m=c.sqr(m),w===f)throw new Error("Cannot find square root");const k=ae<<BigInt(f-w-1),x=c.pow(h,k);f=w,h=c.sqr(x),p=c.mul(p,h),b=c.mul(b,x)}return b}}function Ha(t){return t%Bn===Pn?In:t%Rn===Mn?qa:t%Tn===Wa?za(t):_n(t)}const Va=(t,s)=>(ee(t,s)&ae)===ae,$a=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ga(t){const s={ORDER:"bigint",BYTES:"number",BITS:"number"},r=$a.reduce((o,n)=>(o[n]="function",o),s);return Fs(t,r),t}function Qa(t,s,r){if(r<ce)throw new Error("invalid exponent, negatives unsupported");if(r===ce)return t.ONE;if(r===ae)return s;let o=t.ONE,n=s;for(;r>ce;)r&ae&&(o=t.mul(o,n)),n=t.sqr(n),r>>=ae;return o}function Dn(t,s,r=!1){const o=new Array(s.length).fill(r?t.ZERO:void 0),n=s.reduce((l,i,c)=>t.is0(i)?l:(o[c]=l,t.mul(l,i)),t.ONE),a=t.inv(n);return s.reduceRight((l,i,c)=>t.is0(i)?l:(o[c]=t.mul(l,o[c]),t.mul(l,i)),a),o}function vr(t,s){const r=(t.ORDER-ae)/Te,o=t.pow(s,r),n=t.eql(o,t.ONE),a=t.eql(o,t.ZERO),l=t.eql(o,t.neg(t.ONE));if(!n&&!a&&!l)throw new Error("invalid Legendre symbol result");return n?1:a?0:-1}function Ka(t,s){s!==void 0&&Ds(s);const r=s!==void 0?s:t.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class Ya{ORDER;BITS;BYTES;isLE;ZERO=ce;ONE=ae;_lengths;_sqrt;_mod;constructor(s,r={}){if(s<=ce)throw new Error("invalid field: expected ORDER > 0, got "+s);let o;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(o=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));const{nBitLength:n,nByteLength:a}=Ka(s,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=s,this.BITS=n,this.BYTES=a,this._sqrt=void 0,Object.preventExtensions(this)}create(s){return ee(s,this.ORDER)}isValid(s){if(typeof s!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof s);return ce<=s&&s<this.ORDER}is0(s){return s===ce}isValidNot0(s){return!this.is0(s)&&this.isValid(s)}isOdd(s){return(s&ae)===ae}neg(s){return ee(-s,this.ORDER)}eql(s,r){return s===r}sqr(s){return ee(s*s,this.ORDER)}add(s,r){return ee(s+r,this.ORDER)}sub(s,r){return ee(s-r,this.ORDER)}mul(s,r){return ee(s*r,this.ORDER)}pow(s,r){return Qa(this,s,r)}div(s,r){return ee(s*Ar(r,this.ORDER),this.ORDER)}sqrN(s){return s*s}addN(s,r){return s+r}subN(s,r){return s-r}mulN(s,r){return s*r}inv(s){return Ar(s,this.ORDER)}sqrt(s){return this._sqrt||(this._sqrt=Ha(this.ORDER)),this._sqrt(this,s)}toBytes(s){return this.isLE?Da(s,this.BYTES):Ln(s,this.BYTES)}fromBytes(s,r=!1){se(s);const{_lengths:o,BYTES:n,isLE:a,ORDER:l,_mod:i}=this;if(o){if(!o.includes(s.length)||s.length>n)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+s.length);const u=new Uint8Array(n);u.set(s,a?0:u.length-s.length),s=u}if(s.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+s.length);let c=a?gt(s):_a(s);if(i&&(c=ee(c,l)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(s){return Dn(this,s)}cmov(s,r,o){return o?r:s}}function Ws(t,s={}){return new Ya(t,s)}const wt=BigInt(0),Ns=BigInt(1);function jr(t,s){const r=s.negate();return t?r:s}function Ot(t,s){const r=Dn(t.Fp,s.map(o=>o.Z));return s.map((o,n)=>t.fromAffine(o.toAffine(r[n])))}function Un(t,s){if(!Number.isSafeInteger(t)||t<=0||t>s)throw new Error("invalid window size, expected [1.."+s+"], got W="+t)}function Wt(t,s){Un(t,s);const r=Math.ceil(s/t)+1,o=2**(t-1),n=2**t,a=Fa(t),l=BigInt(t);return{windows:r,windowSize:o,mask:a,maxNumber:n,shiftBy:l}}function kr(t,s,r){const{windowSize:o,mask:n,maxNumber:a,shiftBy:l}=r;let i=Number(t&n),c=t>>l;i>o&&(i-=a,c+=Ns);const u=s*o,f=u+Math.abs(i)-1,h=i===0,p=i<0,b=s%2!==0;return{nextN:c,offset:f,isZero:h,isNeg:p,isNegF:b,offsetF:u}}const qt=new WeakMap,Fn=new WeakMap;function zt(t){return Fn.get(t)||1}function Nr(t){if(t!==wt)throw new Error("invalid wNAF")}class Za{BASE;ZERO;Fn;bits;constructor(s,r){this.BASE=s.BASE,this.ZERO=s.ZERO,this.Fn=s.Fn,this.bits=r}_unsafeLadder(s,r,o=this.ZERO){let n=s;for(;r>wt;)r&Ns&&(o=o.add(n)),n=n.double(),r>>=Ns;return o}precomputeWindow(s,r){const{windows:o,windowSize:n}=Wt(r,this.bits),a=[];let l=s,i=l;for(let c=0;c<o;c++){i=l,a.push(i);for(let u=1;u<n;u++)i=i.add(l),a.push(i);l=i.double()}return a}wNAF(s,r,o){if(!this.Fn.isValid(o))throw new Error("invalid scalar");let n=this.ZERO,a=this.BASE;const l=Wt(s,this.bits);for(let i=0;i<l.windows;i++){const{nextN:c,offset:u,isZero:f,isNeg:h,isNegF:p,offsetF:b}=kr(o,i,l);o=c,f?a=a.add(jr(p,r[b])):n=n.add(jr(h,r[u]))}return Nr(o),{p:n,f:a}}wNAFUnsafe(s,r,o,n=this.ZERO){const a=Wt(s,this.bits);for(let l=0;l<a.windows&&o!==wt;l++){const{nextN:i,offset:c,isZero:u,isNeg:f}=kr(o,l,a);if(o=i,!u){const h=r[c];n=n.add(f?h.negate():h)}}return Nr(o),n}getPrecomputes(s,r,o){let n=qt.get(r);return n||(n=this.precomputeWindow(r,s),s!==1&&(typeof o=="function"&&(n=o(n)),qt.set(r,n))),n}cached(s,r,o){const n=zt(s);return this.wNAF(n,this.getPrecomputes(n,s,o),r)}unsafe(s,r,o,n){const a=zt(s);return a===1?this._unsafeLadder(s,r,n):this.wNAFUnsafe(a,this.getPrecomputes(a,s,o),r,n)}createCache(s,r){Un(r,this.bits),Fn.set(s,r),qt.delete(s)}hasCache(s){return zt(s)!==1}}function Cr(t,s,r){if(s){if(s.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ga(s),s}else return Ws(t,{isLE:r})}function Xa(t,s,r={},o){if(o===void 0&&(o=t==="edwards"),!s||typeof s!="object")throw new Error(`expected valid ${t} CURVE object`);for(const c of["p","n","h"]){const u=s[c];if(!(typeof u=="bigint"&&u>wt))throw new Error(`CURVE.${c} must be positive bigint`)}const n=Cr(s.p,r.Fp,o),a=Cr(s.n,r.Fn,o),i=["Gx","Gy","a","d"];for(const c of i)if(!n.isValid(s[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return s=Object.freeze(Object.assign({},s)),{CURVE:s,Fp:n,Fn:a}}function Ja(t,s){return function(o){const n=t(o);return{secretKey:n,publicKey:s(n)}}}const Se=BigInt(0),te=BigInt(1),Ht=BigInt(2),ei=BigInt(8);function ti(t,s,r,o){const n=t.sqr(r),a=t.sqr(o),l=t.add(t.mul(s.a,n),a),i=t.add(t.ONE,t.mul(s.d,t.mul(n,a)));return t.eql(l,i)}function si(t,s={}){const r=Xa("edwards",t,s,s.FpFnLE),{Fp:o,Fn:n}=r;let a=r.CURVE;const{h:l}=a;Fs(s,{},{uvRatio:"function"});const i=Ht<<BigInt(n.BYTES*8)-te,c=k=>o.create(k),u=s.uvRatio||((k,x)=>{try{return{isValid:!0,value:o.sqrt(o.div(k,x))}}catch{return{isValid:!1,value:Se}}});if(!ti(o,a,a.Gx,a.Gy))throw new Error("bad curve params: generator point");function f(k,x,N=!1){const j=N?te:Se;return yr("coordinate "+k,x,j,i),x}function h(k){if(!(k instanceof w))throw new Error("EdwardsPoint expected")}const p=xr((k,x)=>{const{X:N,Y:j,Z:C}=k,P=k.is0();x==null&&(x=P?ei:o.inv(C));const g=c(N*x),v=c(j*x),A=o.mul(C,x);if(P)return{x:Se,y:te};if(A!==te)throw new Error("invZ was invalid");return{x:g,y:v}}),b=xr(k=>{const{a:x,d:N}=a;if(k.is0())throw new Error("bad point: ZERO");const{X:j,Y:C,Z:P,T:g}=k,v=c(j*j),A=c(C*C),y=c(P*P),L=c(y*y),S=c(v*x),B=c(y*c(S+A)),E=c(L+c(N*c(v*A)));if(B!==E)throw new Error("bad point: equation left != right (1)");const M=c(j*C),R=c(P*g);if(M!==R)throw new Error("bad point: equation left != right (2)");return!0});class w{static BASE=new w(a.Gx,a.Gy,te,c(a.Gx*a.Gy));static ZERO=new w(Se,te,te,Se);static Fp=o;static Fn=n;X;Y;Z;T;constructor(x,N,j,C){this.X=f("x",x),this.Y=f("y",N),this.Z=f("z",j,!0),this.T=f("t",C),Object.freeze(this)}static CURVE(){return a}static fromAffine(x){if(x instanceof w)throw new Error("extended point not allowed");const{x:N,y:j}=x||{};return f("x",N),f("y",j),new w(N,j,te,c(N*j))}static fromBytes(x,N=!1){const j=o.BYTES,{a:C,d:P}=a;x=ks(se(x,j,"point")),js(N,"zip215");const g=ks(x),v=x[j-1];g[j-1]=v&-129;const A=gt(g),y=N?i:o.ORDER;yr("point.y",A,Se,y);const L=c(A*A),S=c(L-te),B=c(P*L-C);let{isValid:E,value:M}=u(S,B);if(!E)throw new Error("bad point: invalid y coordinate");const R=(M&te)===te,F=(v&128)!==0;if(!N&&M===Se&&F)throw new Error("bad point: x=0 and x_0=1");return F!==R&&(M=c(-M)),w.fromAffine({x:M,y:A})}static fromHex(x,N=!1){return w.fromBytes(Nn(x),N)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,N=!0){return m.createCache(this,x),N||this.multiply(Ht),this}assertValidity(){b(this)}equals(x){h(x);const{X:N,Y:j,Z:C}=this,{X:P,Y:g,Z:v}=x,A=c(N*v),y=c(P*C),L=c(j*v),S=c(g*C);return A===y&&L===S}is0(){return this.equals(w.ZERO)}negate(){return new w(c(-this.X),this.Y,this.Z,c(-this.T))}double(){const{a:x}=a,{X:N,Y:j,Z:C}=this,P=c(N*N),g=c(j*j),v=c(Ht*c(C*C)),A=c(x*P),y=N+j,L=c(c(y*y)-P-g),S=A+g,B=S-v,E=A-g,M=c(L*B),R=c(S*E),F=c(L*E),U=c(B*S);return new w(M,R,U,F)}add(x){h(x);const{a:N,d:j}=a,{X:C,Y:P,Z:g,T:v}=this,{X:A,Y:y,Z:L,T:S}=x,B=c(C*A),E=c(P*y),M=c(v*j*S),R=c(g*L),F=c((C+P)*(A+y)-B-E),U=R-M,q=R+M,O=c(E-N*B),I=c(F*U),D=c(q*O),H=c(F*O),Y=c(U*q);return new w(I,D,Y,H)}subtract(x){return this.add(x.negate())}multiply(x){if(!n.isValidNot0(x))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:N,f:j}=m.cached(this,x,C=>Ot(w,C));return Ot(w,[N,j])[0]}multiplyUnsafe(x,N=w.ZERO){if(!n.isValid(x))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return x===Se?w.ZERO:this.is0()||x===te?this:m.unsafe(this,x,j=>Ot(w,j),N)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return m.unsafe(this,a.n).is0()}toAffine(x){return p(this,x)}clearCofactor(){return l===te?this:this.multiplyUnsafe(l)}toBytes(){const{x,y:N}=this.toAffine(),j=o.toBytes(N);return j[j.length-1]|=x&te?128:0,j}toHex(){return Us(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const m=new Za(w,n.BITS);return w.BASE.precompute(8),w}function ri(t,s,r={}){if(typeof s!="function")throw new Error('"hash" function param is required');Fs(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=r,{BASE:n,Fp:a,Fn:l}=t,i=r.randomBytes||ya,c=r.adjustScalarBytes||(A=>A),u=r.domain||((A,y,L)=>{if(js(L,"phflag"),y.length||L)throw new Error("Contexts/pre-hash are not supported");return A});function f(A){return l.create(gt(A))}function h(A){const y=j.secretKey;se(A,j.secretKey,"secretKey");const L=se(s(A),2*y,"hashedSecretKey"),S=c(L.slice(0,y)),B=L.slice(y,2*y),E=f(S);return{head:S,prefix:B,scalar:E}}function p(A){const{head:y,prefix:L,scalar:S}=h(A),B=n.multiply(S),E=B.toBytes();return{head:y,prefix:L,scalar:S,point:B,pointBytes:E}}function b(A){return p(A).pointBytes}function w(A=Uint8Array.of(),...y){const L=pr(...y);return f(s(u(L,se(A,void 0,"context"),!!o)))}function m(A,y,L={}){A=se(A,void 0,"message"),o&&(A=o(A));const{prefix:S,scalar:B,pointBytes:E}=p(y),M=w(L.context,S,A),R=n.multiply(M).toBytes(),F=w(L.context,R,E,A),U=l.create(M+F*B);if(!l.isValid(U))throw new Error("sign failed: invalid s");const q=pr(R,l.toBytes(U));return se(q,j.signature,"result")}const k={zip215:!0};function x(A,y,L,S=k){const{context:B,zip215:E}=S,M=j.signature;A=se(A,M,"signature"),y=se(y,void 0,"message"),L=se(L,j.publicKey,"publicKey"),E!==void 0&&js(E,"zip215"),o&&(y=o(y));const R=M/2,F=A.subarray(0,R),U=gt(A.subarray(R,M));let q,O,I;try{q=t.fromBytes(L,E),O=t.fromBytes(F,E),I=n.multiplyUnsafe(U)}catch{return!1}if(!E&&q.isSmallOrder())return!1;const D=w(B,O.toBytes(),q.toBytes(),y);return O.add(q.multiplyUnsafe(D)).subtract(I).clearCofactor().is0()}const N=a.BYTES,j={secretKey:N,publicKey:N,signature:2*N,seed:N};function C(A=i(j.seed)){return se(A,j.seed,"seed")}function P(A){return jn(A)&&A.length===l.BYTES}function g(A,y){try{return!!t.fromBytes(A,y)}catch{return!1}}const v={getExtendedPublicKey:p,randomSecretKey:C,isValidSecretKey:P,isValidPublicKey:g,toMontgomery(A){const{y}=t.fromBytes(A),L=j.publicKey,S=L===32;if(!S&&L!==57)throw new Error("only defined for 25519 and 448");const B=S?a.div(te+y,te-y):a.div(y-te,y+te);return a.toBytes(B)},toMontgomerySecret(A){const y=j.secretKey;se(A,y);const L=s(A.subarray(0,y));return c(L).subarray(0,y)}};return Object.freeze({keygen:Ja(C,b),getPublicKey:b,sign:m,verify:x,utils:v,Point:t,lengths:j})}const ni=BigInt(1),Sr=BigInt(2),oi=BigInt(5),ai=BigInt(8),qs=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ii={p:qs,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:ai,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ci(t){const s=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),a=qs,i=t*t%a*t%a,c=me(i,Sr,a)*i%a,u=me(c,ni,a)*t%a,f=me(u,oi,a)*u%a,h=me(f,s,a)*f%a,p=me(h,r,a)*h%a,b=me(p,o,a)*p%a,w=me(b,n,a)*b%a,m=me(w,n,a)*b%a,k=me(m,s,a)*f%a;return{pow_p_5_8:me(k,Sr,a)*t%a,b2:i}}function li(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Er=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function di(t,s){const r=qs,o=ee(s*s*s,r),n=ee(o*o*s,r),a=ci(t*n).pow_p_5_8;let l=ee(t*o*a,r);const i=ee(s*l*l,r),c=l,u=ee(l*Er,r),f=i===t,h=i===ee(-t,r),p=i===ee(-t*Er,r);return f&&(l=c),(h||p)&&(l=u),Va(l,r)&&(l=ee(-l,r)),{isValid:f||h,value:l}}const ui=si(ii,{uvRatio:di});function hi(t){return ri(ui,Ta,Object.assign({adjustScalarBytes:li},t))}const fi=hi({});function pi(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ct(t,...s){if(!pi(t))throw new Error("Uint8Array expected");if(s.length>0&&!s.includes(t.length))throw new Error("Uint8Array expected of length "+s+", got length="+t.length)}function Lr(t,s=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(s&&t.finished)throw new Error("Hash#digest() has already been called")}function mi(t,s){Ct(t);const r=s.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Cs(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function Vt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ge(t,s){return t<<32-s|t>>>s}function gi(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function On(t){return typeof t=="string"&&(t=gi(t)),Ct(t),t}class wi{}function bi(t){const s=o=>t().update(On(o)).digest(),r=t();return s.outputLen=r.outputLen,s.blockLen=r.blockLen,s.create=()=>t(),s}function yi(t,s,r,o){if(typeof t.setBigUint64=="function")return t.setBigUint64(s,r,o);const n=BigInt(32),a=BigInt(4294967295),l=Number(r>>n&a),i=Number(r&a),c=o?4:0,u=o?0:4;t.setUint32(s+c,l,o),t.setUint32(s+u,i,o)}function xi(t,s,r){return t&s^~t&r}function Ai(t,s,r){return t&s^t&r^s&r}class vi extends wi{constructor(s,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=s,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(s),this.view=Vt(this.buffer)}update(s){Lr(this),s=On(s),Ct(s);const{view:r,buffer:o,blockLen:n}=this,a=s.length;for(let l=0;l<a;){const i=Math.min(n-this.pos,a-l);if(i===n){const c=Vt(s);for(;n<=a-l;l+=n)this.process(c,l);continue}o.set(s.subarray(l,l+i),this.pos),this.pos+=i,l+=i,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){Lr(this),mi(s,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:l}=this;r[l++]=128,Cs(this.buffer.subarray(l)),this.padOffset>n-l&&(this.process(o,0),l=0);for(let h=l;h<n;h++)r[h]=0;yi(o,n-8,BigInt(this.length*8),a),this.process(o,0);const i=Vt(s),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)i.setUint32(4*h,f[h],a)}digest(){const{buffer:s,outputLen:r}=this;this.digestInto(s);const o=s.slice(0,r);return this.destroy(),o}_cloneInto(s){s||(s=new this.constructor),s.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:l,pos:i}=this;return s.destroyed=l,s.finished=a,s.length=n,s.pos=i,n%r&&s.buffer.set(o),s}clone(){return this._cloneInto()}}const Ee=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ji=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Le=new Uint32Array(64);class ki extends vi{constructor(s=32){super(64,s,8,!1),this.A=Ee[0]|0,this.B=Ee[1]|0,this.C=Ee[2]|0,this.D=Ee[3]|0,this.E=Ee[4]|0,this.F=Ee[5]|0,this.G=Ee[6]|0,this.H=Ee[7]|0}get(){const{A:s,B:r,C:o,D:n,E:a,F:l,G:i,H:c}=this;return[s,r,o,n,a,l,i,c]}set(s,r,o,n,a,l,i,c){this.A=s|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=a|0,this.F=l|0,this.G=i|0,this.H=c|0}process(s,r){for(let h=0;h<16;h++,r+=4)Le[h]=s.getUint32(r,!1);for(let h=16;h<64;h++){const p=Le[h-15],b=Le[h-2],w=ge(p,7)^ge(p,18)^p>>>3,m=ge(b,17)^ge(b,19)^b>>>10;Le[h]=m+Le[h-7]+w+Le[h-16]|0}let{A:o,B:n,C:a,D:l,E:i,F:c,G:u,H:f}=this;for(let h=0;h<64;h++){const p=ge(i,6)^ge(i,11)^ge(i,25),b=f+p+xi(i,c,u)+ji[h]+Le[h]|0,m=(ge(o,2)^ge(o,13)^ge(o,22))+Ai(o,n,a)|0;f=u,u=c,c=i,i=l+b|0,l=a,a=n,n=o,o=b+m|0}o=o+this.A|0,n=n+this.B|0,a=a+this.C|0,l=l+this.D|0,i=i+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(o,n,a,l,i,c,u,f)}roundClean(){Cs(Le)}destroy(){this.set(0,0,0,0,0,0,0,0),Cs(this.buffer)}}const Wn=bi(()=>new ki),Ni=Wn,Ci="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Si(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=Ni(t),r=fi.getPublicKey(s),o=new Uint8Array(64);return o.set(s,0),o.set(r,32),_.wipeBytes(s),{publicKey:r,secretKey:o}}function qn(t){const s=Si(t),r=s.publicKey;return _.wipeBytes(s.secretKey),r}function zn(t){if(t.length!==32)throw new Error(`Invalid public key length: expected 32, got ${t.length}`);return Ei(t)}function Ei(t){let s=0;for(let n=0;n<t.length&&t[n]===0;n++)s++;let r=0n;for(let n=0;n<t.length;n++)r=r*256n+BigInt(t[n]);let o="";for(;r>0n;){const n=Number(r%58n);o=Ci[n]+o,r=r/58n}return"1".repeat(s)+o}const Li=2,Pi=3;function Hn(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=Ss(t),r=vn.share(s,Pi,Li);if(r.length!==3)throw new Error(`Unexpected share count: ${r.length}`);const o=$t(r[0]),n=$t(r[1]),a=$t(r[2]);return{shareA:_.toShamirShare(o),shareB:_.toShamirShare(n),shareC:_.toShamirShare(a)}}function Bi(t,s,r){const o=Pr(t),n=Pr(s);try{const a=vn.combine([o,n]),l=Vn(a);if(l.length!==16)throw new Error(`Reconstructed seed has wrong length: ${l.length}`);return _.toSeed(l)}catch(a){throw a instanceof Error&&a.message.startsWith("Reconstructed seed")||a instanceof Error&&a.message.startsWith("Invalid expectedPublicKey")||a instanceof Error&&a.message.startsWith("Reconstructed seed does not match")?a:new Error("Failed to reconstruct seed from shares")}}function Ss(t){return Array.from(t).map(s=>s.toString(16).padStart(2,"0")).join("")}function Vn(t){if(!/^[0-9a-fA-F]*$/.test(t))throw new Error("Invalid hex string: contains non-hex characters");if(t.length%2!==0)throw new Error(`Invalid hex string: length ${t.length} is odd (must be even)`);const s=new Uint8Array(t.length/2);for(let r=0;r<s.length;r++)s[r]=parseInt(t.substr(r*2,2),16);return s}function $t(t){const s=t.length%2!==0,r=s?"0"+t:t,o=Vn(r),n=new Uint8Array(1+o.length);return n[0]=s?1:0,n.set(o,1),n}function Pr(t){const s=t[0];if(s===0||s===1){const o=s===1,n=t.subarray(1),a=Ss(n),l=o?a.substring(1):a;if(/^[0-9a-f]/.test(l))return l}const r=Ss(t);return r.startsWith("0")&&!r.startsWith("00")?r.substring(1):r}function bt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function $n(t,s){return Array.isArray(s)?s.length===0?!0:t?s.every(r=>typeof r=="string"):s.every(r=>Number.isSafeInteger(r)):!1}function Mi(t){if(typeof t!="function")throw new Error("function expected");return!0}function yt(t,s){if(typeof s!="string")throw new Error(`${t}: string expected`);return!0}function $e(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function xt(t){if(!Array.isArray(t))throw new Error("array expected")}function At(t,s){if(!$n(!0,s))throw new Error(`${t}: array of strings expected`)}function Gn(t,s){if(!$n(!1,s))throw new Error(`${t}: array of numbers expected`)}function Ri(...t){const s=a=>a,r=(a,l)=>i=>a(l(i)),o=t.map(a=>a.encode).reduceRight(r,s),n=t.map(a=>a.decode).reduce(r,s);return{encode:o,decode:n}}function Ti(t){const s=typeof t=="string"?t.split(""):t,r=s.length;At("alphabet",s);const o=new Map(s.map((n,a)=>[n,a]));return{encode:n=>(xt(n),n.map(a=>{if(!Number.isSafeInteger(a)||a<0||a>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${a}". Allowed: ${t}`);return s[a]})),decode:n=>(xt(n),n.map(a=>{yt("alphabet.decode",a);const l=o.get(a);if(l===void 0)throw new Error(`Unknown letter: "${a}". Allowed: ${t}`);return l}))}}function Ii(t=""){return yt("join",t),{encode:s=>(At("join.decode",s),s.join(t)),decode:s=>(yt("join.decode",s),s.split(t))}}function _i(t,s="="){return $e(t),yt("padding",s),{encode(r){for(At("padding.encode",r);r.length*t%8;)r.push(s);return r},decode(r){At("padding.decode",r);let o=r.length;if(o*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===s;o--)if((o-1)*t%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function Es(t,s,r){if(s<2)throw new Error(`convertRadix: invalid from=${s}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(xt(t),!t.length)return[];let o=0;const n=[],a=Array.from(t,i=>{if($e(i),i<0||i>=s)throw new Error(`invalid integer: ${i}`);return i}),l=a.length;for(;;){let i=0,c=!0;for(let u=o;u<l;u++){const f=a[u],h=s*i,p=h+f;if(!Number.isSafeInteger(p)||h/s!==i||p-f!==h)throw new Error("convertRadix: carry overflow");const b=p/r;i=p%r;const w=Math.floor(b);if(a[u]=w,!Number.isSafeInteger(w)||w*r+i!==p)throw new Error("convertRadix: carry overflow");if(c)w?c=!1:o=u;else continue}if(n.push(i),c)break}for(let i=0;i<t.length-1&&t[i]===0;i++)n.push(0);return n.reverse()}const Qn=(t,s)=>s===0?t:Qn(s,t%s),vt=(t,s)=>t+(s-Qn(t,s)),Gt=(()=>{let t=[];for(let s=0;s<40;s++)t.push(2**s);return t})();function Ls(t,s,r,o){if(xt(t),s<=0||s>32)throw new Error(`convertRadix2: wrong from=${s}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(vt(s,r)>32)throw new Error(`convertRadix2: carry overflow from=${s} to=${r} carryBits=${vt(s,r)}`);let n=0,a=0;const l=Gt[s],i=Gt[r]-1,c=[];for(const u of t){if($e(u),u>=l)throw new Error(`convertRadix2: invalid data word=${u} from=${s}`);if(n=n<<s|u,a+s>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${s}`);for(a+=s;a>=r;a-=r)c.push((n>>a-r&i)>>>0);const f=Gt[a];if(f===void 0)throw new Error("invalid carry");n&=f-1}if(n=n<<r-a&i,!o&&a>=s)throw new Error("Excess padding");if(!o&&n>0)throw new Error(`Non-zero padding: ${n}`);return o&&a>0&&c.push(n>>>0),c}function Di(t){$e(t);const s=2**8;return{encode:r=>{if(!bt(r))throw new Error("radix.encode input should be Uint8Array");return Es(Array.from(r),s,t)},decode:r=>(Gn("radix.decode",r),Uint8Array.from(Es(r,t,s)))}}function Ui(t,s=!1){if($e(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(vt(8,t)>32||vt(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!bt(r))throw new Error("radix2.encode input should be Uint8Array");return Ls(Array.from(r),8,t,!s)},decode:r=>(Gn("radix2.decode",r),Uint8Array.from(Ls(r,t,8,s)))}}function Fi(t,s){return $e(t),Mi(s),{encode(r){if(!bt(r))throw new Error("checksum.encode: input should be Uint8Array");const o=s(r).slice(0,t),n=new Uint8Array(r.length+t);return n.set(r),n.set(o,r.length),n},decode(r){if(!bt(r))throw new Error("checksum.decode: input should be Uint8Array");const o=r.slice(0,-t),n=r.slice(-t),a=s(o).slice(0,t);for(let l=0;l<t;l++)if(a[l]!==n[l])throw new Error("Invalid checksum");return o}}}const it={alphabet:Ti,chain:Ri,checksum:Fi,convertRadix:Es,convertRadix2:Ls,radix:Di,radix2:Ui,join:Ii,padding:_i};const Oi=t=>t[0]==="あいこくしん";function Wi(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function qi(t){const s=Wi(t),r=s.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:s,words:r}}function Kn(t){Ct(t,16,20,24,28,32)}const zi=t=>{const s=8-t.length/4;return new Uint8Array([Wn(t)[0]>>s<<s])};function Yn(t){if(!Array.isArray(t)||t.length!==2048||typeof t[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return t.forEach(s=>{if(typeof s!="string")throw new Error("wordlist: non-string element: "+s)}),it.chain(it.checksum(1,zi),it.radix2(11,!0),it.alphabet(t))}function zs(t,s){const{words:r}=qi(t),o=Yn(s).decode(r);return Kn(o),o}function Zn(t,s){return Kn(t),Yn(s).encode(t).join(Oi(s)?" ":" ")}function Hs(t,s){try{zs(t,s)}catch{return!1}return!0}const ve=`abandon
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("./useAuth-B1yS_YiD.cjs"),B=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),d=require("react"),V=require("./LoadingSpinner-d6sSxgQN.cjs"),Vs=require("./sanitization-Bo_tn-L2.cjs"),Q=require("./EmailRegisterForm-xFb6MaVA.cjs"),Oe=require("./validation-BuGQrA-K.cjs"),J=require("./ErrorMessage-CHbYbVi2.cjs"),Hs=require("./GoogleLoginButton-2zNTIKMm.cjs"),Ze=require("./SolanaLoginButton-CqdzSSeJ.cjs"),de=require("./PermissionsSection-CSB_Ikj9.cjs"),Cn=require("./useSystemSettings-B2jY51ob.cjs"),Ne=require("./AutosaveStatus-ByD01ENa.cjs"),$s=require("./useOrgs-CNqfn-fk.cjs"),Ct=require("./AdminDepositList-B_z6x3j5.cjs"),Be=require("./AdminWithdrawalHistory-B2EY2ZmH.cjs"),lt=require("./useUsersStatsSummary-DiRC8sGs.cjs"),En=require("./StatsBar-DTUZCwDD.cjs"),Me=require("./plugin-C4bijrSr.cjs"),_n=require("./AuthenticationSettings-DPr882lj.cjs"),Ln=require("./EmbeddedWalletSettings-t0_5poBu.cjs"),jt=require("./EmailSettings-CjxBg0cE.cjs"),Ks=require("./CreditSystemSettings-DHG_jhz9.cjs"),Pn=require("./ServerSettings-BjLFs_sb.cjs"),pa=require("./useAdminDeposits-CpLd68oP.cjs"),Gs=require("./WebhookSettings-DbyPJ8V2.cjs");var Gt=typeof document<"u"?document.currentScript:null;let Fe=null,ga=0;const ct=new Map;function wa(){return typeof Worker>"u"?null:(Fe||(Fe=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/argon2Worker-Bi5TuQvD.js").href:new URL("assets/argon2Worker-Bi5TuQvD.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:Gt&&Gt.tagName.toUpperCase()==="SCRIPT"&&Gt.src||new URL("index.cjs",document.baseURI).href),{type:"module"}),Fe.onmessage=t=>{const{id:s,key:r,error:o}=t.data,n=ct.get(s);if(n){if(ct.delete(s),o){n.reject(new Error(o));return}if(!r){n.reject(new Error("Argon2 worker returned no key"));return}n.resolve(r)}},Fe.onerror=t=>{const s=t instanceof ErrorEvent?t.error:new Error("Argon2 worker error");for(const r of ct.values())r.reject(s instanceof Error?s:new Error(String(s)));ct.clear(),Fe?.terminate(),Fe=null}),Fe)}async function Rn(t,s,r=U.DEFAULT_KDF_PARAMS){U.validateKdfParams(r);const o=wa();return o?new Promise((n,a)=>{const i=ga++;ct.set(i,{resolve:n,reject:a});const l={id:i,password:t,salt:s,params:r};o.postMessage(l)}):U.argon2Derive(t,s,r)}function Tn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ba(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var s=t.default;if(typeof s=="function"){var r=function o(){var n=!1;try{n=this instanceof o}catch{}return n?Reflect.construct(s,arguments,this.constructor):s.apply(this,arguments)};r.prototype=s.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r,o,n.get?n:{enumerable:!0,get:function(){return t[o]}})}),r}var kt={exports:{}};const ya=globalThis.crypto,xa=globalThis.crypto,Aa=globalThis.crypto.subtle,va=globalThis.crypto.getRandomValues.bind(globalThis.crypto),ja=globalThis.crypto.randomUUID.bind(globalThis.crypto),ka=Object.freeze(Object.defineProperty({__proto__:null,default:ya,getRandomValues:va,randomUUID:ja,subtle:Aa,webcrypto:xa},Symbol.toStringTag,{value:"Module"})),Na=ba(ka);var Sa=kt.exports,xr;function Ca(){return xr||(xr=1,(function(t,s){(function(r,o){t.exports=o(Na)})(Sa,function(r){var o,n,a,i,l;function c(){o={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},n={},a=new Array(1024).join("0"),i=!0,l=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function u(){return!!(n&&n.rng&&typeof n.rng=="function")}function m(f,y){var x;if(y===0||y===1)return f;if(y&&y>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return y=y||n.bits,f&&(x=f.length%y),x?(a+f).slice(-(y-x+f.length)):f}function h(f){var y="",x,v;for(v=f.length-1;v>=0;v--){if(x=parseInt(f[v],16),isNaN(x))throw new Error("Invalid hex character.");y=m(x.toString(2),4)+y}return y}function p(f){var y="",x,v;for(f=m(f,4),v=f.length;v>=4;v-=4){if(x=parseInt(f.slice(v-4,v),2),isNaN(x))throw new Error("Invalid binary character.");y=x.toString(16)+y}return y}function b(){return!!(r&&typeof r=="object"&&(typeof r.getRandomValues=="function"||typeof r.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function w(){return typeof r=="object"&&typeof r.randomBytes=="function"}function g(f){function y(E,P,L,R){var T=0,M,F="",W;for(P&&(M=P.length-1);T<M||F.length<E;)W=Math.abs(parseInt(P[T],L)),F=F+m(W.toString(2),R),T++;return F=F.substr(-E),(F.match(/0/g)||[]).length===F.length?null:F}function x(E){var P,L,R,T,M=null;for(R=16,T=4,L=Math.ceil(E/8);M===null;)P=r.randomBytes(L),M=y(E,P.toString("hex"),R,T);return M}function v(E){var P,L,R,T=null;for(L=10,R=32,P=Math.ceil(E/32);T===null;)T=y(E,r.getRandomValues(new Uint32Array(P)),L,R);return T}function _(E){var P,L,R,T,M,F=null;T=10,M=32,L=Math.ceil(E/32),R=123456789,P=new Uint32Array(L);for(var W=0;W<P.length;W++)P[W]=R;for(;F===null;)F=y(E,P,T,M);return F}if(f&&f==="testRandom")return n.typeCSPRNG=f,_;if(f&&f==="nodeCryptoRandomBytes")return n.typeCSPRNG=f,x;if(f&&f==="browserCryptoGetRandomValues")return n.typeCSPRNG=f,v;if(w())return n.typeCSPRNG="nodeCryptoRandomBytes",x;if(b())return n.typeCSPRNG="browserCryptoGetRandomValues",v}function k(f,y){var x=[],v;for(y&&(f=m(f,y)),v=f.length;v>n.bits;v-=n.bits)x.push(parseInt(f.slice(v-n.bits,v),2));return x.push(parseInt(f.slice(0,v),2)),x}function A(f,y){var x=n.logs[f],v=0,_;for(_=y.length-1;_>=0;_--)v!==0?v=n.exps[(x+n.logs[v])%n.maxShares]^y[_]:v=y[_];return v}function j(f,y,x){var v=0,_,E,P,L;for(P=0,_=y.length;P<_;P++)if(x[P]){for(E=n.logs[x[P]],L=0;L<_;L++)if(P!==L){if(f===y[L]){E=-1;break}E=(E+n.logs[f^y[L]]-n.logs[y[P]^y[L]]+n.maxShares)%n.maxShares}v=E===-1?v:v^n.exps[E]}return v}function N(f,y,x){var v=[],_=[f],E,P;for(E=1;E<x;E++)_[E]=parseInt(n.rng(n.bits),2);for(E=1,P=y+1;E<P;E++)v[E-1]={x:E,y:A(E,_)};return v}function S(f,y,x){var v,_,E,P,L;if(y=parseInt(y,n.radix),f=parseInt(f,10)||n.bits,v=f.toString(36).toUpperCase(),E=Math.pow(2,f)-1,P=E.toString(n.radix).length,_=m(y.toString(n.radix),P),typeof y!="number"||y%1!==0||y<1||y>E)throw new Error("Share id must be an integer between 1 and "+E+", inclusive.");return L=v+_+x,L}var C={init:function(f,y){var x=[],v=[],_=1,E,P;if(c(),f&&(typeof f!="number"||f%1!==0||f<o.minBits||f>o.maxBits))throw new Error("Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(y&&l.indexOf(y)===-1)throw new Error("Invalid RNG type argument : '"+y+"'");for(n.radix=o.radix,n.bits=f||o.bits,n.size=Math.pow(2,n.bits),n.maxShares=n.size-1,E=o.primitivePolynomials[n.bits],P=0;P<n.size;P++)v[P]=_,x[_]=P,_=_<<1,_>=n.size&&(_=_^E,_=_&n.maxShares);if(n.logs=x,n.exps=v,y&&this.setRNG(y),u()||this.setRNG(),!u()||!n.bits||!n.size||!n.maxShares||!n.logs||!n.exps||n.logs.length!==n.size||n.exps.length!==n.size)throw new Error("Initialization failed.")},combine:function(f,y){var x,v,_,E,P="",L,R,T,M=[],F=[];for(y=y||0,x=0,_=f.length;x<_;x++){if(R=this.extractShareComponents(f[x]),L===void 0)L=R.bits;else if(R.bits!==L)throw new Error("Mismatched shares: Different bit settings.");if(n.bits!==L&&this.init(L),M.indexOf(R.id)===-1)for(M.push(R.id),T=k(h(R.data)),v=0,E=T.length;v<E;v++)F[v]=F[v]||[],F[v][M.length-1]=T[v]}for(x=0,_=F.length;x<_;x++)P=m(j(y,M,F[x]).toString(2))+P;return p(y>=1?P:P.slice(P.indexOf("1")+1))},getConfig:function(){var f={};return f.radix=n.radix,f.bits=n.bits,f.maxShares=n.maxShares,f.hasCSPRNG=u(),f.typeCSPRNG=n.typeCSPRNG,f},extractShareComponents:function(f){var y,x,v,_,E={},P,L;if(y=parseInt(f.substr(0,1),36),y&&(typeof y!="number"||y%1!==0||y<o.minBits||y>o.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(_=Math.pow(2,y)-1,v=(Math.pow(2,y)-1).toString(n.radix).length,P="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+v+"})([a-fA-F0-9]+)$",L=new RegExp(P).exec(f),L&&(x=parseInt(L[2],n.radix)),typeof x!="number"||x%1!==0||x<1||x>_)throw new Error("Invalid share : Share id must be an integer between 1 and "+n.maxShares+", inclusive.");if(L&&L[3])return E.bits=y,E.id=x,E.data=L[3],E;throw new Error("The share data provided is invalid : "+f)},setRNG:function(f){var y="Random number generator is invalid ",x=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(f&&typeof f=="string"&&l.indexOf(f)===-1)throw new Error("Invalid RNG type argument : '"+f+"'");if(f||(f=g()),f&&typeof f=="string"&&(f=g(f)),i){if(f&&typeof f!="function")throw new Error(y+"(Not a function)."+x);if(f&&typeof f(n.bits)!="string")throw new Error(y+"(Output is not a string)."+x);if(f&&!parseInt(f(n.bits),2))throw new Error(y+"(Binary string output not parseable to an Integer)."+x);if(f&&f(n.bits).length>n.bits)throw new Error(y+"(Output length is greater than config.bits)."+x);if(f&&f(n.bits).length<n.bits)throw new Error(y+"(Output length is less than config.bits)."+x)}return n.rng=f,!0},str2hex:function(f,y){var x,v,_="",E,P,L,R;if(typeof f!="string")throw new Error("Input must be a character string.");if(y||(y=o.bytesPerChar),typeof y!="number"||y<1||y>o.maxBytesPerChar||y%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(x=2*y,v=Math.pow(16,x)-1,L=0,R=f.length;L<R;L++){if(P=f[L].charCodeAt(),isNaN(P))throw new Error("Invalid character: "+f[L]);if(P>v)throw E=Math.ceil(Math.log(P+1)/Math.log(256)),new Error("Invalid character code ("+P+"). Maximum allowable is 256^bytes-1 ("+v+"). To convert this character, use at least "+E+" bytes.");_=m(P.toString(16),x)+_}return _},hex2str:function(f,y){var x,v="",_,E;if(typeof f!="string")throw new Error("Input must be a hexadecimal string.");if(y=y||o.bytesPerChar,typeof y!="number"||y%1!==0||y<1||y>o.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(x=2*y,f=m(f,x),_=0,E=f.length;_<E;_+=x)v=String.fromCharCode(parseInt(f.slice(_,_+x),16))+v;return v},random:function(f){if(typeof f!="number"||f%1!==0||f<2||f>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return p(n.rng(f))},share:function(f,y,x,v){var _,E,P=new Array(y),L=new Array(y),R,T,M;if(v=v||128,typeof f!="string")throw new Error("Secret must be a string.");if(typeof y!="number"||y%1!==0||y<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(y>n.maxShares)throw _=Math.ceil(Math.log(y+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To create "+y+" shares, use at least "+_+" bits.");if(typeof x!="number"||x%1!==0||x<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(x>n.maxShares)throw _=Math.ceil(Math.log(x+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To use a threshold of "+x+", use at least "+_+" bits.");if(x>y)throw new Error("Threshold number of shares was "+x+" but must be less than or equal to the "+y+" shares specified as the total to generate.");if(typeof v!="number"||v%1!==0||v<0||v>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(f="1"+h(f),f=k(f,v),R=0,M=f.length;R<M;R++)for(E=N(f[R],y,x),T=0;T<y;T++)P[T]=P[T]||E[T].x.toString(n.radix),L[T]=m(E[T].y.toString(2))+(L[T]||"");for(R=0;R<y;R++)P[R]=S(n.bits,P[R],p(L[R]));return P},newShare:function(f,y){var x,v;if(f&&typeof f=="string"&&(f=parseInt(f,n.radix)),v=f.toString(n.radix),f&&v&&y&&y[0])return x=this.extractShareComponents(y[0]),S(x.bits,v,this.combine(y,f));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:c,_padLeft:m,_hex2bin:h,_bin2hex:p,_hasCryptoGetRandomValues:b,_hasCryptoRandomBytes:w,_getRNG:g,_isSetRNG:u,_splitNumStringToIntArray:k,_horner:A,_lagrange:j,_getShares:N,_constructPublicShareString:S};return C.init(),C})})(kt)),kt.exports}var Ea=Ca();const Bn=Tn(Ea);function Mn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Qs(t,s=""){if(!Number.isSafeInteger(t)||t<0){const r=s&&`"${s}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function ne(t,s,r=""){const o=Mn(t),n=t?.length,a=s!==void 0;if(!o||a&&n!==s){const i=r&&`"${r}" `,l=a?` of length ${s}`:"",c=o?`length=${n}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+l+", got "+c)}return t}function Ar(t,s=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(s&&t.finished)throw new Error("Hash#digest() has already been called")}function _a(t,s){ne(t,void 0,"digestInto() output");const r=s.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Bs(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function Qt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const In=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",La=Array.from({length:256},(t,s)=>s.toString(16).padStart(2,"0"));function Ys(t){if(ne(t),In)return t.toHex();let s="";for(let r=0;r<t.length;r++)s+=La[t[r]];return s}const je={_0:48,_9:57,A:65,F:70,a:97,f:102};function vr(t){if(t>=je._0&&t<=je._9)return t-je._0;if(t>=je.A&&t<=je.F)return t-(je.A-10);if(t>=je.a&&t<=je.f)return t-(je.a-10)}function Un(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(In)return Uint8Array.fromHex(t);const s=t.length,r=s/2;if(s%2)throw new Error("hex string expected, got unpadded hex of length "+s);const o=new Uint8Array(r);for(let n=0,a=0;n<r;n++,a+=2){const i=vr(t.charCodeAt(a)),l=vr(t.charCodeAt(a+1));if(i===void 0||l===void 0){const c=t[a]+t[a+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+a)}o[n]=i*16+l}return o}function jr(...t){let s=0;for(let o=0;o<t.length;o++){const n=t[o];ne(n),s+=n.length}const r=new Uint8Array(s);for(let o=0,n=0;o<t.length;o++){const a=t[o];r.set(a,n),n+=a.length}return r}function Pa(t,s={}){const r=(n,a)=>t(a).update(n).digest(),o=t(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=n=>t(n),Object.assign(r,s),Object.freeze(r)}function Ra(t=32){const s=typeof globalThis=="object"?globalThis.crypto:null;if(typeof s?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return s.getRandomValues(new Uint8Array(t))}const Ta=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});let Ba=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(s,r,o,n){this.blockLen=s,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(s),this.view=Qt(this.buffer)}update(s){Ar(this),ne(s);const{view:r,buffer:o,blockLen:n}=this,a=s.length;for(let i=0;i<a;){const l=Math.min(n-this.pos,a-i);if(l===n){const c=Qt(s);for(;n<=a-i;i+=n)this.process(c,i);continue}o.set(s.subarray(i,i+l),this.pos),this.pos+=l,i+=l,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){Ar(this),_a(s,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Bs(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let h=i;h<n;h++)r[h]=0;o.setBigUint64(n-8,BigInt(this.length*8),a),this.process(o,0);const l=Qt(s),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const u=c/4,m=this.get();if(u>m.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)l.setUint32(4*h,m[h],a)}digest(){const{buffer:s,outputLen:r}=this;this.digestInto(s);const o=s.slice(0,r);return this.destroy(),o}_cloneInto(s){s||=new this.constructor,s.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:i,pos:l}=this;return s.destroyed=i,s.finished=a,s.length=n,s.pos=l,n%r&&s.buffer.set(o),s}clone(){return this._cloneInto()}};const oe=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ht=BigInt(2**32-1),kr=BigInt(32);function Ma(t,s=!1){return s?{h:Number(t&ht),l:Number(t>>kr&ht)}:{h:Number(t>>kr&ht)|0,l:Number(t&ht)|0}}function Ia(t,s=!1){const r=t.length;let o=new Uint32Array(r),n=new Uint32Array(r);for(let a=0;a<r;a++){const{h:i,l}=Ma(t[a],s);[o[a],n[a]]=[i,l]}return[o,n]}const Nr=(t,s,r)=>t>>>r,Sr=(t,s,r)=>t<<32-r|s>>>r,Ke=(t,s,r)=>t>>>r|s<<32-r,Ge=(t,s,r)=>t<<32-r|s>>>r,mt=(t,s,r)=>t<<64-r|s>>>r-32,ft=(t,s,r)=>t>>>r-32|s<<64-r;function ke(t,s,r,o){const n=(s>>>0)+(o>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const Ua=(t,s,r)=>(t>>>0)+(s>>>0)+(r>>>0),Da=(t,s,r,o)=>s+r+o+(t/2**32|0)|0,Fa=(t,s,r,o)=>(t>>>0)+(s>>>0)+(r>>>0)+(o>>>0),Wa=(t,s,r,o,n)=>s+r+o+n+(t/2**32|0)|0,Oa=(t,s,r,o,n)=>(t>>>0)+(s>>>0)+(r>>>0)+(o>>>0)+(n>>>0),qa=(t,s,r,o,n,a)=>s+r+o+n+a+(t/2**32|0)|0,Dn=Ia(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),za=Dn[0],Va=Dn[1],Ee=new Uint32Array(80),_e=new Uint32Array(80);class Ha extends Ba{constructor(s){super(128,s,16,!1)}get(){const{Ah:s,Al:r,Bh:o,Bl:n,Ch:a,Cl:i,Dh:l,Dl:c,Eh:u,El:m,Fh:h,Fl:p,Gh:b,Gl:w,Hh:g,Hl:k}=this;return[s,r,o,n,a,i,l,c,u,m,h,p,b,w,g,k]}set(s,r,o,n,a,i,l,c,u,m,h,p,b,w,g,k){this.Ah=s|0,this.Al=r|0,this.Bh=o|0,this.Bl=n|0,this.Ch=a|0,this.Cl=i|0,this.Dh=l|0,this.Dl=c|0,this.Eh=u|0,this.El=m|0,this.Fh=h|0,this.Fl=p|0,this.Gh=b|0,this.Gl=w|0,this.Hh=g|0,this.Hl=k|0}process(s,r){for(let N=0;N<16;N++,r+=4)Ee[N]=s.getUint32(r),_e[N]=s.getUint32(r+=4);for(let N=16;N<80;N++){const S=Ee[N-15]|0,C=_e[N-15]|0,f=Ke(S,C,1)^Ke(S,C,8)^Nr(S,C,7),y=Ge(S,C,1)^Ge(S,C,8)^Sr(S,C,7),x=Ee[N-2]|0,v=_e[N-2]|0,_=Ke(x,v,19)^mt(x,v,61)^Nr(x,v,6),E=Ge(x,v,19)^ft(x,v,61)^Sr(x,v,6),P=Fa(y,E,_e[N-7],_e[N-16]),L=Wa(P,f,_,Ee[N-7],Ee[N-16]);Ee[N]=L|0,_e[N]=P|0}let{Ah:o,Al:n,Bh:a,Bl:i,Ch:l,Cl:c,Dh:u,Dl:m,Eh:h,El:p,Fh:b,Fl:w,Gh:g,Gl:k,Hh:A,Hl:j}=this;for(let N=0;N<80;N++){const S=Ke(h,p,14)^Ke(h,p,18)^mt(h,p,41),C=Ge(h,p,14)^Ge(h,p,18)^ft(h,p,41),f=h&b^~h&g,y=p&w^~p&k,x=Oa(j,C,y,Va[N],_e[N]),v=qa(x,A,S,f,za[N],Ee[N]),_=x|0,E=Ke(o,n,28)^mt(o,n,34)^mt(o,n,39),P=Ge(o,n,28)^ft(o,n,34)^ft(o,n,39),L=o&a^o&l^a&l,R=n&i^n&c^i&c;A=g|0,j=k|0,g=b|0,k=w|0,b=h|0,w=p|0,{h,l:p}=ke(u|0,m|0,v|0,_|0),u=l|0,m=c|0,l=a|0,c=i|0,a=o|0,i=n|0;const T=Ua(_,P,R);o=Da(T,v,E,L),n=T|0}({h:o,l:n}=ke(this.Ah|0,this.Al|0,o|0,n|0)),{h:a,l:i}=ke(this.Bh|0,this.Bl|0,a|0,i|0),{h:l,l:c}=ke(this.Ch|0,this.Cl|0,l|0,c|0),{h:u,l:m}=ke(this.Dh|0,this.Dl|0,u|0,m|0),{h,l:p}=ke(this.Eh|0,this.El|0,h|0,p|0),{h:b,l:w}=ke(this.Fh|0,this.Fl|0,b|0,w|0),{h:g,l:k}=ke(this.Gh|0,this.Gl|0,g|0,k|0),{h:A,l:j}=ke(this.Hh|0,this.Hl|0,A|0,j|0),this.set(o,n,a,i,l,c,u,m,h,p,b,w,g,k,A,j)}roundClean(){Bs(Ee,_e)}destroy(){Bs(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class $a extends Ha{Ah=oe[0]|0;Al=oe[1]|0;Bh=oe[2]|0;Bl=oe[3]|0;Ch=oe[4]|0;Cl=oe[5]|0;Dh=oe[6]|0;Dl=oe[7]|0;Eh=oe[8]|0;El=oe[9]|0;Fh=oe[10]|0;Fl=oe[11]|0;Gh=oe[12]|0;Gl=oe[13]|0;Hh=oe[14]|0;Hl=oe[15]|0;constructor(){super(64)}}const Ka=Pa(()=>new $a,Ta(3));const Fn=BigInt(0),Cr=BigInt(1);function Ms(t,s=""){if(typeof t!="boolean"){const r=s&&`"${s}" `;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function Ga(t){if(typeof t=="bigint"){if(!Nt(t))throw new Error("positive bigint expected, got "+t)}else Qs(t);return t}function Wn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Fn:BigInt("0x"+t)}function Qa(t){return Wn(Ys(t))}function Et(t){return Wn(Ys(Is(ne(t)).reverse()))}function On(t,s){Qs(s),t=Ga(t);const r=Un(t.toString(16).padStart(s*2,"0"));if(r.length!==s)throw new Error("number too large");return r}function Ya(t,s){return On(t,s).reverse()}function Is(t){return Uint8Array.from(t)}const Nt=t=>typeof t=="bigint"&&Fn<=t;function Za(t,s,r){return Nt(t)&&Nt(s)&&Nt(r)&&s<=t&&t<r}function Er(t,s,r,o){if(!Za(s,r,o))throw new Error("expected valid "+t+": "+r+" <= n < "+o+", got "+s)}const Xa=t=>(Cr<<BigInt(t))-Cr;function Zs(t,s={},r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function o(a,i,l){const c=t[a];if(l&&c===void 0)return;const u=typeof c;if(u!==i||c===null)throw new Error(`param "${a}" is invalid: expected ${i}, got ${u}`)}const n=(a,i)=>Object.entries(a).forEach(([l,c])=>o(l,c,i));n(s,!1),n(r,!0)}function _r(t){const s=new WeakMap;return(r,...o)=>{const n=s.get(r);if(n!==void 0)return n;const a=t(r,...o);return s.set(r,a),a}}const ue=BigInt(0),ie=BigInt(1),We=BigInt(2),qn=BigInt(3),zn=BigInt(4),Vn=BigInt(5),Ja=BigInt(7),Hn=BigInt(8),ei=BigInt(9),$n=BigInt(16);function te(t,s){const r=t%s;return r>=ue?r:s+r}function xe(t,s,r){let o=t;for(;s-- >ue;)o*=o,o%=r;return o}function Lr(t,s){if(t===ue)throw new Error("invert: expected non-zero number");if(s<=ue)throw new Error("invert: expected positive modulus, got "+s);let r=te(t,s),o=s,n=ue,a=ie;for(;r!==ue;){const l=o/r,c=o%r,u=n-a*l;o=r,r=c,n=a,a=u}if(o!==ie)throw new Error("invert: does not exist");return te(n,s)}function Xs(t,s,r){if(!t.eql(t.sqr(s),r))throw new Error("Cannot find square root")}function Kn(t,s){const r=(t.ORDER+ie)/zn,o=t.pow(s,r);return Xs(t,o,s),o}function ti(t,s){const r=(t.ORDER-Vn)/Hn,o=t.mul(s,We),n=t.pow(o,r),a=t.mul(s,n),i=t.mul(t.mul(a,We),n),l=t.mul(a,t.sub(i,t.ONE));return Xs(t,l,s),l}function si(t){const s=Js(t),r=Gn(t),o=r(s,s.neg(s.ONE)),n=r(s,o),a=r(s,s.neg(o)),i=(t+Ja)/$n;return(l,c)=>{let u=l.pow(c,i),m=l.mul(u,o);const h=l.mul(u,n),p=l.mul(u,a),b=l.eql(l.sqr(m),c),w=l.eql(l.sqr(h),c);u=l.cmov(u,m,b),m=l.cmov(p,h,w);const g=l.eql(l.sqr(m),c),k=l.cmov(u,m,g);return Xs(l,k,c),k}}function Gn(t){if(t<qn)throw new Error("sqrt is not defined for small field");let s=t-ie,r=0;for(;s%We===ue;)s/=We,r++;let o=We;const n=Js(t);for(;Pr(n,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Kn;let a=n.pow(o,s);const i=(s+ie)/We;return function(c,u){if(c.is0(u))return u;if(Pr(c,u)!==1)throw new Error("Cannot find square root");let m=r,h=c.mul(c.ONE,a),p=c.pow(u,s),b=c.pow(u,i);for(;!c.eql(p,c.ONE);){if(c.is0(p))return c.ZERO;let w=1,g=c.sqr(p);for(;!c.eql(g,c.ONE);)if(w++,g=c.sqr(g),w===m)throw new Error("Cannot find square root");const k=ie<<BigInt(m-w-1),A=c.pow(h,k);m=w,h=c.sqr(A),p=c.mul(p,h),b=c.mul(b,A)}return b}}function ri(t){return t%zn===qn?Kn:t%Hn===Vn?ti:t%$n===ei?si(t):Gn(t)}const ni=(t,s)=>(te(t,s)&ie)===ie,oi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ai(t){const s={ORDER:"bigint",BYTES:"number",BITS:"number"},r=oi.reduce((o,n)=>(o[n]="function",o),s);return Zs(t,r),t}function ii(t,s,r){if(r<ue)throw new Error("invalid exponent, negatives unsupported");if(r===ue)return t.ONE;if(r===ie)return s;let o=t.ONE,n=s;for(;r>ue;)r&ie&&(o=t.mul(o,n)),n=t.sqr(n),r>>=ie;return o}function Qn(t,s,r=!1){const o=new Array(s.length).fill(r?t.ZERO:void 0),n=s.reduce((i,l,c)=>t.is0(l)?i:(o[c]=i,t.mul(i,l)),t.ONE),a=t.inv(n);return s.reduceRight((i,l,c)=>t.is0(l)?i:(o[c]=t.mul(i,o[c]),t.mul(i,l)),a),o}function Pr(t,s){const r=(t.ORDER-ie)/We,o=t.pow(s,r),n=t.eql(o,t.ONE),a=t.eql(o,t.ZERO),i=t.eql(o,t.neg(t.ONE));if(!n&&!a&&!i)throw new Error("invalid Legendre symbol result");return n?1:a?0:-1}function ci(t,s){s!==void 0&&Qs(s);const r=s!==void 0?s:t.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class li{ORDER;BITS;BYTES;isLE;ZERO=ue;ONE=ie;_lengths;_sqrt;_mod;constructor(s,r={}){if(s<=ue)throw new Error("invalid field: expected ORDER > 0, got "+s);let o;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(o=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));const{nBitLength:n,nByteLength:a}=ci(s,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=s,this.BITS=n,this.BYTES=a,this._sqrt=void 0,Object.preventExtensions(this)}create(s){return te(s,this.ORDER)}isValid(s){if(typeof s!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof s);return ue<=s&&s<this.ORDER}is0(s){return s===ue}isValidNot0(s){return!this.is0(s)&&this.isValid(s)}isOdd(s){return(s&ie)===ie}neg(s){return te(-s,this.ORDER)}eql(s,r){return s===r}sqr(s){return te(s*s,this.ORDER)}add(s,r){return te(s+r,this.ORDER)}sub(s,r){return te(s-r,this.ORDER)}mul(s,r){return te(s*r,this.ORDER)}pow(s,r){return ii(this,s,r)}div(s,r){return te(s*Lr(r,this.ORDER),this.ORDER)}sqrN(s){return s*s}addN(s,r){return s+r}subN(s,r){return s-r}mulN(s,r){return s*r}inv(s){return Lr(s,this.ORDER)}sqrt(s){return this._sqrt||(this._sqrt=ri(this.ORDER)),this._sqrt(this,s)}toBytes(s){return this.isLE?Ya(s,this.BYTES):On(s,this.BYTES)}fromBytes(s,r=!1){ne(s);const{_lengths:o,BYTES:n,isLE:a,ORDER:i,_mod:l}=this;if(o){if(!o.includes(s.length)||s.length>n)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+s.length);const u=new Uint8Array(n);u.set(s,a?0:u.length-s.length),s=u}if(s.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+s.length);let c=a?Et(s):Qa(s);if(l&&(c=te(c,i)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(s){return Qn(this,s)}cmov(s,r,o){return o?r:s}}function Js(t,s={}){return new li(t,s)}const _t=BigInt(0),Us=BigInt(1);function Rr(t,s){const r=s.negate();return t?r:s}function Yt(t,s){const r=Qn(t.Fp,s.map(o=>o.Z));return s.map((o,n)=>t.fromAffine(o.toAffine(r[n])))}function Yn(t,s){if(!Number.isSafeInteger(t)||t<=0||t>s)throw new Error("invalid window size, expected [1.."+s+"], got W="+t)}function Zt(t,s){Yn(t,s);const r=Math.ceil(s/t)+1,o=2**(t-1),n=2**t,a=Xa(t),i=BigInt(t);return{windows:r,windowSize:o,mask:a,maxNumber:n,shiftBy:i}}function Tr(t,s,r){const{windowSize:o,mask:n,maxNumber:a,shiftBy:i}=r;let l=Number(t&n),c=t>>i;l>o&&(l-=a,c+=Us);const u=s*o,m=u+Math.abs(l)-1,h=l===0,p=l<0,b=s%2!==0;return{nextN:c,offset:m,isZero:h,isNeg:p,isNegF:b,offsetF:u}}const Xt=new WeakMap,Zn=new WeakMap;function Jt(t){return Zn.get(t)||1}function Br(t){if(t!==_t)throw new Error("invalid wNAF")}class di{BASE;ZERO;Fn;bits;constructor(s,r){this.BASE=s.BASE,this.ZERO=s.ZERO,this.Fn=s.Fn,this.bits=r}_unsafeLadder(s,r,o=this.ZERO){let n=s;for(;r>_t;)r&Us&&(o=o.add(n)),n=n.double(),r>>=Us;return o}precomputeWindow(s,r){const{windows:o,windowSize:n}=Zt(r,this.bits),a=[];let i=s,l=i;for(let c=0;c<o;c++){l=i,a.push(l);for(let u=1;u<n;u++)l=l.add(i),a.push(l);i=l.double()}return a}wNAF(s,r,o){if(!this.Fn.isValid(o))throw new Error("invalid scalar");let n=this.ZERO,a=this.BASE;const i=Zt(s,this.bits);for(let l=0;l<i.windows;l++){const{nextN:c,offset:u,isZero:m,isNeg:h,isNegF:p,offsetF:b}=Tr(o,l,i);o=c,m?a=a.add(Rr(p,r[b])):n=n.add(Rr(h,r[u]))}return Br(o),{p:n,f:a}}wNAFUnsafe(s,r,o,n=this.ZERO){const a=Zt(s,this.bits);for(let i=0;i<a.windows&&o!==_t;i++){const{nextN:l,offset:c,isZero:u,isNeg:m}=Tr(o,i,a);if(o=l,!u){const h=r[c];n=n.add(m?h.negate():h)}}return Br(o),n}getPrecomputes(s,r,o){let n=Xt.get(r);return n||(n=this.precomputeWindow(r,s),s!==1&&(typeof o=="function"&&(n=o(n)),Xt.set(r,n))),n}cached(s,r,o){const n=Jt(s);return this.wNAF(n,this.getPrecomputes(n,s,o),r)}unsafe(s,r,o,n){const a=Jt(s);return a===1?this._unsafeLadder(s,r,n):this.wNAFUnsafe(a,this.getPrecomputes(a,s,o),r,n)}createCache(s,r){Yn(r,this.bits),Zn.set(s,r),Xt.delete(s)}hasCache(s){return Jt(s)!==1}}function Mr(t,s,r){if(s){if(s.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return ai(s),s}else return Js(t,{isLE:r})}function ui(t,s,r={},o){if(o===void 0&&(o=t==="edwards"),!s||typeof s!="object")throw new Error(`expected valid ${t} CURVE object`);for(const c of["p","n","h"]){const u=s[c];if(!(typeof u=="bigint"&&u>_t))throw new Error(`CURVE.${c} must be positive bigint`)}const n=Mr(s.p,r.Fp,o),a=Mr(s.n,r.Fn,o),l=["Gx","Gy","a","d"];for(const c of l)if(!n.isValid(s[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return s=Object.freeze(Object.assign({},s)),{CURVE:s,Fp:n,Fn:a}}function hi(t,s){return function(o){const n=t(o);return{secretKey:n,publicKey:s(n)}}}const Le=BigInt(0),re=BigInt(1),es=BigInt(2),mi=BigInt(8);function fi(t,s,r,o){const n=t.sqr(r),a=t.sqr(o),i=t.add(t.mul(s.a,n),a),l=t.add(t.ONE,t.mul(s.d,t.mul(n,a)));return t.eql(i,l)}function pi(t,s={}){const r=ui("edwards",t,s,s.FpFnLE),{Fp:o,Fn:n}=r;let a=r.CURVE;const{h:i}=a;Zs(s,{},{uvRatio:"function"});const l=es<<BigInt(n.BYTES*8)-re,c=k=>o.create(k),u=s.uvRatio||((k,A)=>{try{return{isValid:!0,value:o.sqrt(o.div(k,A))}}catch{return{isValid:!1,value:Le}}});if(!fi(o,a,a.Gx,a.Gy))throw new Error("bad curve params: generator point");function m(k,A,j=!1){const N=j?re:Le;return Er("coordinate "+k,A,N,l),A}function h(k){if(!(k instanceof w))throw new Error("EdwardsPoint expected")}const p=_r((k,A)=>{const{X:j,Y:N,Z:S}=k,C=k.is0();A==null&&(A=C?mi:o.inv(S));const f=c(j*A),y=c(N*A),x=o.mul(S,A);if(C)return{x:Le,y:re};if(x!==re)throw new Error("invZ was invalid");return{x:f,y}}),b=_r(k=>{const{a:A,d:j}=a;if(k.is0())throw new Error("bad point: ZERO");const{X:N,Y:S,Z:C,T:f}=k,y=c(N*N),x=c(S*S),v=c(C*C),_=c(v*v),E=c(y*A),P=c(v*c(E+x)),L=c(_+c(j*c(y*x)));if(P!==L)throw new Error("bad point: equation left != right (1)");const R=c(N*S),T=c(C*f);if(R!==T)throw new Error("bad point: equation left != right (2)");return!0});class w{static BASE=new w(a.Gx,a.Gy,re,c(a.Gx*a.Gy));static ZERO=new w(Le,re,re,Le);static Fp=o;static Fn=n;X;Y;Z;T;constructor(A,j,N,S){this.X=m("x",A),this.Y=m("y",j),this.Z=m("z",N,!0),this.T=m("t",S),Object.freeze(this)}static CURVE(){return a}static fromAffine(A){if(A instanceof w)throw new Error("extended point not allowed");const{x:j,y:N}=A||{};return m("x",j),m("y",N),new w(j,N,re,c(j*N))}static fromBytes(A,j=!1){const N=o.BYTES,{a:S,d:C}=a;A=Is(ne(A,N,"point")),Ms(j,"zip215");const f=Is(A),y=A[N-1];f[N-1]=y&-129;const x=Et(f),v=j?l:o.ORDER;Er("point.y",x,Le,v);const _=c(x*x),E=c(_-re),P=c(C*_-S);let{isValid:L,value:R}=u(E,P);if(!L)throw new Error("bad point: invalid y coordinate");const T=(R&re)===re,M=(y&128)!==0;if(!j&&R===Le&&M)throw new Error("bad point: x=0 and x_0=1");return M!==T&&(R=c(-R)),w.fromAffine({x:R,y:x})}static fromHex(A,j=!1){return w.fromBytes(Un(A),j)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(A=8,j=!0){return g.createCache(this,A),j||this.multiply(es),this}assertValidity(){b(this)}equals(A){h(A);const{X:j,Y:N,Z:S}=this,{X:C,Y:f,Z:y}=A,x=c(j*y),v=c(C*S),_=c(N*y),E=c(f*S);return x===v&&_===E}is0(){return this.equals(w.ZERO)}negate(){return new w(c(-this.X),this.Y,this.Z,c(-this.T))}double(){const{a:A}=a,{X:j,Y:N,Z:S}=this,C=c(j*j),f=c(N*N),y=c(es*c(S*S)),x=c(A*C),v=j+N,_=c(c(v*v)-C-f),E=x+f,P=E-y,L=x-f,R=c(_*P),T=c(E*L),M=c(_*L),F=c(P*E);return new w(R,T,F,M)}add(A){h(A);const{a:j,d:N}=a,{X:S,Y:C,Z:f,T:y}=this,{X:x,Y:v,Z:_,T:E}=A,P=c(S*x),L=c(C*v),R=c(y*N*E),T=c(f*_),M=c((S+C)*(x+v)-P-L),F=T-R,W=T+R,q=c(L-j*P),I=c(M*F),D=c(W*q),$=c(M*q),Z=c(F*W);return new w(I,D,Z,$)}subtract(A){return this.add(A.negate())}multiply(A){if(!n.isValidNot0(A))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:j,f:N}=g.cached(this,A,S=>Yt(w,S));return Yt(w,[j,N])[0]}multiplyUnsafe(A,j=w.ZERO){if(!n.isValid(A))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return A===Le?w.ZERO:this.is0()||A===re?this:g.unsafe(this,A,N=>Yt(w,N),j)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return g.unsafe(this,a.n).is0()}toAffine(A){return p(this,A)}clearCofactor(){return i===re?this:this.multiplyUnsafe(i)}toBytes(){const{x:A,y:j}=this.toAffine(),N=o.toBytes(j);return N[N.length-1]|=A&re?128:0,N}toHex(){return Ys(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const g=new di(w,n.BITS);return w.BASE.precompute(8),w}function gi(t,s,r={}){if(typeof s!="function")throw new Error('"hash" function param is required');Zs(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=r,{BASE:n,Fp:a,Fn:i}=t,l=r.randomBytes||Ra,c=r.adjustScalarBytes||(x=>x),u=r.domain||((x,v,_)=>{if(Ms(_,"phflag"),v.length||_)throw new Error("Contexts/pre-hash are not supported");return x});function m(x){return i.create(Et(x))}function h(x){const v=N.secretKey;ne(x,N.secretKey,"secretKey");const _=ne(s(x),2*v,"hashedSecretKey"),E=c(_.slice(0,v)),P=_.slice(v,2*v),L=m(E);return{head:E,prefix:P,scalar:L}}function p(x){const{head:v,prefix:_,scalar:E}=h(x),P=n.multiply(E),L=P.toBytes();return{head:v,prefix:_,scalar:E,point:P,pointBytes:L}}function b(x){return p(x).pointBytes}function w(x=Uint8Array.of(),...v){const _=jr(...v);return m(s(u(_,ne(x,void 0,"context"),!!o)))}function g(x,v,_={}){x=ne(x,void 0,"message"),o&&(x=o(x));const{prefix:E,scalar:P,pointBytes:L}=p(v),R=w(_.context,E,x),T=n.multiply(R).toBytes(),M=w(_.context,T,L,x),F=i.create(R+M*P);if(!i.isValid(F))throw new Error("sign failed: invalid s");const W=jr(T,i.toBytes(F));return ne(W,N.signature,"result")}const k={zip215:!0};function A(x,v,_,E=k){const{context:P,zip215:L}=E,R=N.signature;x=ne(x,R,"signature"),v=ne(v,void 0,"message"),_=ne(_,N.publicKey,"publicKey"),L!==void 0&&Ms(L,"zip215"),o&&(v=o(v));const T=R/2,M=x.subarray(0,T),F=Et(x.subarray(T,R));let W,q,I;try{W=t.fromBytes(_,L),q=t.fromBytes(M,L),I=n.multiplyUnsafe(F)}catch{return!1}if(!L&&W.isSmallOrder())return!1;const D=w(P,q.toBytes(),W.toBytes(),v);return q.add(W.multiplyUnsafe(D)).subtract(I).clearCofactor().is0()}const j=a.BYTES,N={secretKey:j,publicKey:j,signature:2*j,seed:j};function S(x=l(N.seed)){return ne(x,N.seed,"seed")}function C(x){return Mn(x)&&x.length===i.BYTES}function f(x,v){try{return!!t.fromBytes(x,v)}catch{return!1}}const y={getExtendedPublicKey:p,randomSecretKey:S,isValidSecretKey:C,isValidPublicKey:f,toMontgomery(x){const{y:v}=t.fromBytes(x),_=N.publicKey,E=_===32;if(!E&&_!==57)throw new Error("only defined for 25519 and 448");const P=E?a.div(re+v,re-v):a.div(v-re,v+re);return a.toBytes(P)},toMontgomerySecret(x){const v=N.secretKey;ne(x,v);const _=s(x.subarray(0,v));return c(_).subarray(0,v)}};return Object.freeze({keygen:hi(S,b),getPublicKey:b,sign:g,verify:A,utils:y,Point:t,lengths:N})}const wi=BigInt(1),Ir=BigInt(2),bi=BigInt(5),yi=BigInt(8),er=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),xi={p:er,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:yi,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Ai(t){const s=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),a=er,l=t*t%a*t%a,c=xe(l,Ir,a)*l%a,u=xe(c,wi,a)*t%a,m=xe(u,bi,a)*u%a,h=xe(m,s,a)*m%a,p=xe(h,r,a)*h%a,b=xe(p,o,a)*p%a,w=xe(b,n,a)*b%a,g=xe(w,n,a)*b%a,k=xe(g,s,a)*m%a;return{pow_p_5_8:xe(k,Ir,a)*t%a,b2:l}}function vi(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Ur=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function ji(t,s){const r=er,o=te(s*s*s,r),n=te(o*o*s,r),a=Ai(t*n).pow_p_5_8;let i=te(t*o*a,r);const l=te(s*i*i,r),c=i,u=te(i*Ur,r),m=l===t,h=l===te(-t,r),p=l===te(-t*Ur,r);return m&&(i=c),(h||p)&&(i=u),ni(i,r)&&(i=te(-i,r)),{isValid:m||h,value:i}}const ki=pi(xi,{uvRatio:ji});function Ni(t){return gi(ki,Ka,Object.assign({adjustScalarBytes:vi},t))}const Si=Ni({});function Ci(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Dt(t,...s){if(!Ci(t))throw new Error("Uint8Array expected");if(s.length>0&&!s.includes(t.length))throw new Error("Uint8Array expected of length "+s+", got length="+t.length)}function Dr(t,s=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(s&&t.finished)throw new Error("Hash#digest() has already been called")}function Ei(t,s){Dt(t);const r=s.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ds(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function ts(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ae(t,s){return t<<32-s|t>>>s}function _i(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Xn(t){return typeof t=="string"&&(t=_i(t)),Dt(t),t}class Li{}function Pi(t){const s=o=>t().update(Xn(o)).digest(),r=t();return s.outputLen=r.outputLen,s.blockLen=r.blockLen,s.create=()=>t(),s}function Ri(t,s,r,o){if(typeof t.setBigUint64=="function")return t.setBigUint64(s,r,o);const n=BigInt(32),a=BigInt(4294967295),i=Number(r>>n&a),l=Number(r&a),c=o?4:0,u=o?0:4;t.setUint32(s+c,i,o),t.setUint32(s+u,l,o)}function Ti(t,s,r){return t&s^~t&r}function Bi(t,s,r){return t&s^t&r^s&r}class Mi extends Li{constructor(s,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=s,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(s),this.view=ts(this.buffer)}update(s){Dr(this),s=Xn(s),Dt(s);const{view:r,buffer:o,blockLen:n}=this,a=s.length;for(let i=0;i<a;){const l=Math.min(n-this.pos,a-i);if(l===n){const c=ts(s);for(;n<=a-i;i+=n)this.process(c,i);continue}o.set(s.subarray(i,i+l),this.pos),this.pos+=l,i+=l,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){Dr(this),Ei(s,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Ds(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let h=i;h<n;h++)r[h]=0;Ri(o,n-8,BigInt(this.length*8),a),this.process(o,0);const l=ts(s),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,m=this.get();if(u>m.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)l.setUint32(4*h,m[h],a)}digest(){const{buffer:s,outputLen:r}=this;this.digestInto(s);const o=s.slice(0,r);return this.destroy(),o}_cloneInto(s){s||(s=new this.constructor),s.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:i,pos:l}=this;return s.destroyed=i,s.finished=a,s.length=n,s.pos=l,n%r&&s.buffer.set(o),s}clone(){return this._cloneInto()}}const Pe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ii=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Re=new Uint32Array(64);class Ui extends Mi{constructor(s=32){super(64,s,8,!1),this.A=Pe[0]|0,this.B=Pe[1]|0,this.C=Pe[2]|0,this.D=Pe[3]|0,this.E=Pe[4]|0,this.F=Pe[5]|0,this.G=Pe[6]|0,this.H=Pe[7]|0}get(){const{A:s,B:r,C:o,D:n,E:a,F:i,G:l,H:c}=this;return[s,r,o,n,a,i,l,c]}set(s,r,o,n,a,i,l,c){this.A=s|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=a|0,this.F=i|0,this.G=l|0,this.H=c|0}process(s,r){for(let h=0;h<16;h++,r+=4)Re[h]=s.getUint32(r,!1);for(let h=16;h<64;h++){const p=Re[h-15],b=Re[h-2],w=Ae(p,7)^Ae(p,18)^p>>>3,g=Ae(b,17)^Ae(b,19)^b>>>10;Re[h]=g+Re[h-7]+w+Re[h-16]|0}let{A:o,B:n,C:a,D:i,E:l,F:c,G:u,H:m}=this;for(let h=0;h<64;h++){const p=Ae(l,6)^Ae(l,11)^Ae(l,25),b=m+p+Ti(l,c,u)+Ii[h]+Re[h]|0,g=(Ae(o,2)^Ae(o,13)^Ae(o,22))+Bi(o,n,a)|0;m=u,u=c,c=l,l=i+b|0,i=a,a=n,n=o,o=b+g|0}o=o+this.A|0,n=n+this.B|0,a=a+this.C|0,i=i+this.D|0,l=l+this.E|0,c=c+this.F|0,u=u+this.G|0,m=m+this.H|0,this.set(o,n,a,i,l,c,u,m)}roundClean(){Ds(Re)}destroy(){this.set(0,0,0,0,0,0,0,0),Ds(this.buffer)}}const Jn=Pi(()=>new Ui),Di=Jn,Fi="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Wi(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=Di(t),r=Si.getPublicKey(s),o=new Uint8Array(64);return o.set(s,0),o.set(r,32),U.wipeBytes(s),{publicKey:r,secretKey:o}}function eo(t){const s=Wi(t),r=s.publicKey;return U.wipeBytes(s.secretKey),r}function to(t){if(t.length!==32)throw new Error(`Invalid public key length: expected 32, got ${t.length}`);return Oi(t)}function Oi(t){let s=0;for(let n=0;n<t.length&&t[n]===0;n++)s++;let r=0n;for(let n=0;n<t.length;n++)r=r*256n+BigInt(t[n]);let o="";for(;r>0n;){const n=Number(r%58n);o=Fi[n]+o,r=r/58n}return"1".repeat(s)+o}const qi=2,zi=3;function so(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=Fs(t),r=Bn.share(s,zi,qi);if(r.length!==3)throw new Error(`Unexpected share count: ${r.length}`);const o=ss(r[0]),n=ss(r[1]),a=ss(r[2]);return{shareA:U.toShamirShare(o),shareB:U.toShamirShare(n),shareC:U.toShamirShare(a)}}function Vi(t,s,r){const o=Fr(t),n=Fr(s);try{const a=Bn.combine([o,n]),i=ro(a);if(i.length!==16)throw new Error(`Reconstructed seed has wrong length: ${i.length}`);return U.toSeed(i)}catch(a){throw a instanceof Error&&a.message.startsWith("Reconstructed seed")||a instanceof Error&&a.message.startsWith("Invalid expectedPublicKey")||a instanceof Error&&a.message.startsWith("Reconstructed seed does not match")?a:new Error("Failed to reconstruct seed from shares")}}function Fs(t){return Array.from(t).map(s=>s.toString(16).padStart(2,"0")).join("")}function ro(t){if(!/^[0-9a-fA-F]*$/.test(t))throw new Error("Invalid hex string: contains non-hex characters");if(t.length%2!==0)throw new Error(`Invalid hex string: length ${t.length} is odd (must be even)`);const s=new Uint8Array(t.length/2);for(let r=0;r<s.length;r++)s[r]=parseInt(t.substr(r*2,2),16);return s}function ss(t){const s=t.length%2!==0,r=s?"0"+t:t,o=ro(r),n=new Uint8Array(1+o.length);return n[0]=s?1:0,n.set(o,1),n}function Fr(t){const s=t[0];if(s===0||s===1){const o=s===1,n=t.subarray(1),a=Fs(n),i=o?a.substring(1):a;if(/^[0-9a-f]/.test(i))return i}const r=Fs(t);return r.startsWith("0")&&!r.startsWith("00")?r.substring(1):r}function Lt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function no(t,s){return Array.isArray(s)?s.length===0?!0:t?s.every(r=>typeof r=="string"):s.every(r=>Number.isSafeInteger(r)):!1}function Hi(t){if(typeof t!="function")throw new Error("function expected");return!0}function Pt(t,s){if(typeof s!="string")throw new Error(`${t}: string expected`);return!0}function et(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Rt(t){if(!Array.isArray(t))throw new Error("array expected")}function Tt(t,s){if(!no(!0,s))throw new Error(`${t}: array of strings expected`)}function oo(t,s){if(!no(!1,s))throw new Error(`${t}: array of numbers expected`)}function $i(...t){const s=a=>a,r=(a,i)=>l=>a(i(l)),o=t.map(a=>a.encode).reduceRight(r,s),n=t.map(a=>a.decode).reduce(r,s);return{encode:o,decode:n}}function Ki(t){const s=typeof t=="string"?t.split(""):t,r=s.length;Tt("alphabet",s);const o=new Map(s.map((n,a)=>[n,a]));return{encode:n=>(Rt(n),n.map(a=>{if(!Number.isSafeInteger(a)||a<0||a>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${a}". Allowed: ${t}`);return s[a]})),decode:n=>(Rt(n),n.map(a=>{Pt("alphabet.decode",a);const i=o.get(a);if(i===void 0)throw new Error(`Unknown letter: "${a}". Allowed: ${t}`);return i}))}}function Gi(t=""){return Pt("join",t),{encode:s=>(Tt("join.decode",s),s.join(t)),decode:s=>(Pt("join.decode",s),s.split(t))}}function Qi(t,s="="){return et(t),Pt("padding",s),{encode(r){for(Tt("padding.encode",r);r.length*t%8;)r.push(s);return r},decode(r){Tt("padding.decode",r);let o=r.length;if(o*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===s;o--)if((o-1)*t%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function Ws(t,s,r){if(s<2)throw new Error(`convertRadix: invalid from=${s}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Rt(t),!t.length)return[];let o=0;const n=[],a=Array.from(t,l=>{if(et(l),l<0||l>=s)throw new Error(`invalid integer: ${l}`);return l}),i=a.length;for(;;){let l=0,c=!0;for(let u=o;u<i;u++){const m=a[u],h=s*l,p=h+m;if(!Number.isSafeInteger(p)||h/s!==l||p-m!==h)throw new Error("convertRadix: carry overflow");const b=p/r;l=p%r;const w=Math.floor(b);if(a[u]=w,!Number.isSafeInteger(w)||w*r+l!==p)throw new Error("convertRadix: carry overflow");if(c)w?c=!1:o=u;else continue}if(n.push(l),c)break}for(let l=0;l<t.length-1&&t[l]===0;l++)n.push(0);return n.reverse()}const ao=(t,s)=>s===0?t:ao(s,t%s),Bt=(t,s)=>t+(s-ao(t,s)),rs=(()=>{let t=[];for(let s=0;s<40;s++)t.push(2**s);return t})();function Os(t,s,r,o){if(Rt(t),s<=0||s>32)throw new Error(`convertRadix2: wrong from=${s}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Bt(s,r)>32)throw new Error(`convertRadix2: carry overflow from=${s} to=${r} carryBits=${Bt(s,r)}`);let n=0,a=0;const i=rs[s],l=rs[r]-1,c=[];for(const u of t){if(et(u),u>=i)throw new Error(`convertRadix2: invalid data word=${u} from=${s}`);if(n=n<<s|u,a+s>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${s}`);for(a+=s;a>=r;a-=r)c.push((n>>a-r&l)>>>0);const m=rs[a];if(m===void 0)throw new Error("invalid carry");n&=m-1}if(n=n<<r-a&l,!o&&a>=s)throw new Error("Excess padding");if(!o&&n>0)throw new Error(`Non-zero padding: ${n}`);return o&&a>0&&c.push(n>>>0),c}function Yi(t){et(t);const s=2**8;return{encode:r=>{if(!Lt(r))throw new Error("radix.encode input should be Uint8Array");return Ws(Array.from(r),s,t)},decode:r=>(oo("radix.decode",r),Uint8Array.from(Ws(r,t,s)))}}function Zi(t,s=!1){if(et(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Bt(8,t)>32||Bt(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Lt(r))throw new Error("radix2.encode input should be Uint8Array");return Os(Array.from(r),8,t,!s)},decode:r=>(oo("radix2.decode",r),Uint8Array.from(Os(r,t,8,s)))}}function Xi(t,s){return et(t),Hi(s),{encode(r){if(!Lt(r))throw new Error("checksum.encode: input should be Uint8Array");const o=s(r).slice(0,t),n=new Uint8Array(r.length+t);return n.set(r),n.set(o,r.length),n},decode(r){if(!Lt(r))throw new Error("checksum.decode: input should be Uint8Array");const o=r.slice(0,-t),n=r.slice(-t),a=s(o).slice(0,t);for(let i=0;i<t;i++)if(a[i]!==n[i])throw new Error("Invalid checksum");return o}}}const pt={alphabet:Ki,chain:$i,checksum:Xi,convertRadix:Ws,convertRadix2:Os,radix:Yi,radix2:Zi,join:Gi,padding:Qi};const Ji=t=>t[0]==="あいこくしん";function ec(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function tc(t){const s=ec(t),r=s.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:s,words:r}}function io(t){Dt(t,16,20,24,28,32)}const sc=t=>{const s=8-t.length/4;return new Uint8Array([Jn(t)[0]>>s<<s])};function co(t){if(!Array.isArray(t)||t.length!==2048||typeof t[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return t.forEach(s=>{if(typeof s!="string")throw new Error("wordlist: non-string element: "+s)}),pt.chain(pt.checksum(1,sc),pt.radix2(11,!0),pt.alphabet(t))}function tr(t,s){const{words:r}=tc(t),o=co(s).decode(r);return io(o),o}function lo(t,s){return io(t),co(s).encode(t).join(Ji(s)?" ":" ")}function sr(t,s){try{tr(t,s)}catch{return!1}return!0}const Se=`abandon
|
|
2
2
|
ability
|
|
3
3
|
able
|
|
4
4
|
about
|
|
@@ -2046,16 +2046,16 @@ zebra
|
|
|
2046
2046
|
zero
|
|
2047
2047
|
zone
|
|
2048
2048
|
zoo`.split(`
|
|
2049
|
-
`),de=12;function Hi(t){if(t.length!==16)throw new Error(`Invalid share length: expected 16, got ${t.length}`);const r=Zn(t,ve).split(" ");if(r.length!==de)throw new Error(`Unexpected word count: expected ${de}, got ${r.length}`);return r}function Vi(t){if(t.length!==de)throw new Error(`Invalid word count: expected ${de}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!Hs(s,ve))throw new Error("Invalid recovery phrase: checksum mismatch");const r=zs(s,ve);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return _.toShamirShare(r)}function $i(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const r=Zn(t,ve).split(" ");if(r.length!==de)throw new Error(`Unexpected word count: expected ${de}, got ${r.length}`);return r}function Gi(t){if(t.length!==de)throw new Error(`Invalid word count: expected ${de}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!Hs(s,ve))throw new Error("Invalid recovery phrase: checksum mismatch");const r=zs(s,ve);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return _.toSeed(r)}function Xn(t){if(t.length!==de)return!1;const s=t.join(" ").toLowerCase().trim();return Hs(s,ve)}function ct(t){return ve.includes(t.toLowerCase().trim())}function Qi(t,s=5){const r=t.toLowerCase().trim();return r.length===0?[]:ve.filter(o=>o.startsWith(r)).slice(0,s)}function Ki(t){const s=[];for(let r=0;r<t.length;r+=4)s.push(t.slice(r,r+4));return s}function Yi(t){return t.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(s=>s.trim()).filter(s=>s.length>0)}function Zi({className:t="",variant:s="default",size:r="md",children:o,menuItems:n=[],hideSignOut:a=!1}){const{user:l,isAuthenticated:i,isLoading:c,openLoginModal:u,logout:f}=_.useAuth(),[h,p]=d.useState(!1),[b,w]=d.useState(-1),m=d.useRef(null),k=d.useRef(null),x=d.useMemo(()=>[...n,...a?[]:[{label:"Sign out",onClick:f}]],[n,a,f]);d.useEffect(()=>{if(!h)return;const g=A=>{m.current&&!m.current.contains(A.target)&&(p(!1),w(-1))},v=A=>{A.key==="Escape"&&(p(!1),w(-1),k.current?.focus())};return document.addEventListener("mousedown",g),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",v)}},[h]);const N=d.useCallback(g=>{if(!(!h||x.length===0))switch(g.key){case"ArrowDown":g.preventDefault(),w(v=>(v+1)%x.length);break;case"ArrowUp":g.preventDefault(),w(v=>(v-1+x.length)%x.length);break;case"Home":g.preventDefault(),w(0);break;case"End":g.preventDefault(),w(x.length-1);break;case"Enter":case" ":b>=0&&(g.preventDefault(),x[b].onClick(),p(!1),w(-1));break}},[h,b,x]),j=d.useCallback(()=>{x.length!==0&&(p(g=>!g),w(-1))},[x.length]),C={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},P={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(c)return e.jsx("button",{type:"button",className:`cedros-button ${P[s]} ${C[r]} ${t}`,disabled:!0,children:e.jsx(z.LoadingSpinner,{size:"sm"})});if(i&&l){const g=l.name||l.email||"User",v=Ms.sanitizeImageUrl(l.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:m,onKeyDown:N,children:[e.jsxs("button",{ref:k,type:"button",className:`cedros-button cedros-user-button ${C[r]} ${t}`,"aria-haspopup":"menu","aria-expanded":h,"aria-label":`User menu for ${g}`,onClick:j,children:[v?e.jsx("img",{src:v,alt:g,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(g[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:g})]}),h&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[n.map((A,y)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${b===y?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===y?0:-1,onClick:()=>{A.onClick(),p(!1)},children:[A.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:A.icon}),A.label]},y)),n.length>0&&!a&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!a&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${b===n.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===n.length?0:-1,onClick:()=>{f(),p(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${P[s]} ${C[r]} ${t}`,onClick:u,children:o||"Sign in"})}function St(){const{config:t}=T.useCedrosLogin(),[s,r]=d.useState(!1),[o,n]=d.useState(!1),[a,l]=d.useState(null),i=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]),{checkLimit:c,getRemainingAttempts:u}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),f=d.useCallback(async w=>{if(!Ie.validateEmail(w)){const m={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw l(m),m}try{c()}catch(m){const k={code:"RATE_LIMITED",message:m instanceof Error?m.message:"Too many attempts"};throw l(k),k}r(!0),l(null),n(!1);try{await i.post("/forgot-password",{email:w}),n(!0)}catch(m){const k=T.handleApiError(m,"Unable to send the reset email. Please try again.");throw l(k),k}finally{r(!1)}},[i,c]),h=d.useCallback(async(w,m)=>{r(!0),l(null),n(!1);try{await i.post("/reset-password",{token:w,newPassword:m}),n(!0)}catch(k){const x=T.handleApiError(k,"Unable to reset your password. Please try again.");throw l(x),x}finally{r(!1)}},[i]),p=d.useCallback(()=>l(null),[]),b=d.useCallback(()=>{l(null),n(!1),r(!1)},[]);return{forgotPassword:f,resetPassword:h,isLoading:s,isSuccess:o,error:a,clearError:p,reset:b,remainingAttempts:u()}}function Xi(t){return typeof t=="object"&&t!==null&&"mfaRequired"in t&&t.mfaRequired===!0}function Jn(){const{config:t,_internal:s}=T.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(!1),[l,i]=d.useState(null),c=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]),{checkLimit:u,getRemainingAttempts:f}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),h=d.useCallback(async m=>{if(!Ie.validateEmail(m)){const k={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw i(k),k}try{u()}catch(k){const x={code:"RATE_LIMITED",message:k instanceof Error?k.message:"Too many attempts"};throw i(x),x}o(!0),i(null),a(!1);try{await c.post("/instant-link",{email:m}),a(!0)}catch(k){const x=T.handleApiError(k,"Unable to send the sign-in link. Please try again.");throw i(x),x}finally{o(!1)}},[c,u]),p=d.useCallback(async m=>{if(!m||m.trim().length===0){const k={code:"VALIDATION_ERROR",message:"Invalid or missing sign-in link token"};throw i(k),k}o(!0),i(null),a(!1);try{const k=await c.post("/instant-link/verify",{token:m});return Xi(k)||(t.callbacks?.onLoginSuccess?.(k.user,"email"),s?.handleLoginSuccess(k.user,k.tokens)),k}catch(k){const x=T.handleApiError(k,"Unable to verify the sign-in link. Please try again.");throw i(x),x}finally{o(!1)}},[c,t.callbacks,s]),b=d.useCallback(()=>i(null),[]),w=d.useCallback(()=>{i(null),a(!1),o(!1)},[]);return{sendInstantLink:h,verifyInstantLink:p,isLoading:r,isSuccess:n,error:l,clearError:b,reset:w,remainingAttempts:f()}}const Ji={reset:{subtitle:"Enter your email address and we'll send you a link to reset your password.",button:"Send reset link",successMessage:t=>e.jsxs(e.Fragment,{children:["If an account exists for ",e.jsx("strong",{children:t}),", you will receive a password reset link shortly."]})},instantLink:{subtitle:"Enter your email and we'll send you a sign-in link. You can change your password in your account settings once signed in.",button:"Send sign-in link",successMessage:t=>e.jsxs(e.Fragment,{children:["We sent a sign-in link to ",e.jsx("strong",{children:t}),". Click the link to sign in."]})}};function eo({mode:t="reset",onSuccess:s,onCancel:r,className:o=""}){const[n,a]=d.useState(""),l=St(),i=Jn(),c=d.useId(),u=t==="instantLink"?{submit:i.sendInstantLink,isLoading:i.isLoading,isSuccess:i.isSuccess,error:i.error,clearError:i.clearError}:{submit:l.forgotPassword,isLoading:l.isLoading,isSuccess:l.isSuccess,error:l.error,clearError:l.clearError},f=Ji[t],h=async p=>{p.preventDefault();try{await u.submit(n),s?.()}catch{}};return u.isSuccess?e.jsxs("div",{className:`cedros-forgot-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Check your email"}),e.jsx("p",{className:"cedros-success-message",children:f.successMessage(n)}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:r,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${o}`,onSubmit:h,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Forgot password?"}),e.jsx("p",{className:"cedros-form-subtitle",children:f.subtitle})]}),e.jsx(Z.ErrorMessage,{error:u.error,onDismiss:u.clearError}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:c,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:c,type:"email",className:"cedros-input",value:n,onChange:p=>a(p.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:u.isLoading})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:u.isLoading||!n,children:u.isLoading?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),"Sending..."]}):f.button}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:u.isLoading,children:"Back to login"})]})]})}const ec={loading:!1,loaded:!1,error:null,callbacks:[],load(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Apple Sign-In script loader cannot run in SSR")):this.loaded?Promise.resolve():this.loading?new Promise((t,s)=>{this.callbacks.push({resolve:t,reject:s})}):(this.loading=!0,new Promise((t,s)=>{this.callbacks.push({resolve:t,reject:s});const r=document.getElementById("apple-signin-script");if(r){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]):r.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]});return}const o=document.createElement("script");o.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",o.async=!0,o.defer=!0,o.id="apple-signin-script",o.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]},o.onerror=()=>{this.loading=!1,o.remove();const n=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(a=>a.reject(n)),this.callbacks=[]},document.head.appendChild(o)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function to(){const{config:t,_internal:s}=T.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(!1),[l,i]=d.useState(null),[c,u]=d.useState(null),f=d.useRef(t),h=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]);d.useEffect(()=>{f.current=t},[t]),d.useEffect(()=>{if(!t.appleClientId)return;let m=!0;const k=()=>{if(m)try{window.AppleID?.auth?.init({clientId:t.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),m&&a(!0)}catch{m&&i({code:"SERVER_ERROR",message:"Unable to initialize Apple sign-in. Please refresh and try again."})}};return ec.load().then(()=>{m&&k()}).catch(()=>{m&&i({code:"SERVER_ERROR",message:"Unable to load Apple sign-in. Please refresh and try again."})}),()=>{m=!1}},[t.appleClientId]);const p=d.useCallback(async()=>{if(!t.appleClientId){const k={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw i(k),k}if(!n){const k={code:"VALIDATION_ERROR",message:"Apple sign-in is not ready yet. Please wait a moment and try again."};throw i(k),k}o(!0),i(null);let m;try{const k=crypto.getRandomValues(new Uint8Array(32)),x=Array.from(k,v=>v.toString(16).padStart(2,"0")).join(""),N=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(x)),j=Array.from(new Uint8Array(N),v=>v.toString(16).padStart(2,"0")).join("");window.AppleID.auth.init({clientId:t.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0,nonce:j});const C=await window.AppleID.auth.signIn();if(m=C.authorization?.id_token,!m)throw new Error("No ID token received from Apple");const P=C.user?.name?`${C.user.name.firstName||""} ${C.user.name.lastName||""}`.trim():void 0,g=await h.post("/apple",{idToken:m,name:P||void 0,nonce:x});return f.current.callbacks?.onLoginSuccess?.(g.user,"apple"),s?.handleLoginSuccess(g.user,g.tokens),o(!1),g}catch(k){if(k.error==="popup_closed_by_user"){const j={code:"SERVER_ERROR",message:"Apple sign-in was cancelled."};throw i(j),o(!1),j}const N=T.handleApiError(k,"Unable to sign in with Apple. Please try again.");throw N.code==="ACCOUNT_LINK_REQUIRED"&&m&&u(m),i(N),o(!1),N}},[t.appleClientId,n,h,s]),b=d.useCallback(()=>i(null),[]),w=d.useCallback(()=>u(null),[]);return{signIn:p,isLoading:r,isInitialized:n,error:l,clearError:b,pendingLinkIdToken:c,clearPendingLink:w}}function so(){if(typeof window>"u"||typeof navigator>"u")return!1;const t=navigator.userAgent.toLowerCase(),s=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(t)||s.includes("mac")||/macintosh/.test(t)||s==="macintel"&&navigator.maxTouchPoints>1)}function ro({onSuccess:t,onError:s,className:r="",variant:o="default",size:n="md",disabled:a=!1,hideOnNonApple:l=!0}){const{signIn:i,isLoading:c,isInitialized:u}=to(),[f]=d.useState(()=>so());if(l&&!f)return null;const h=async()=>{try{await i(),t?.()}catch(w){const m=w instanceof Error?w:new Error(String(w));s?.(m)}},p={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},b={default:"cedros-button-social",outline:"cedros-button-social-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${b[o]} ${p[n]} ${r}`,onClick:h,disabled:a||!u||c,"aria-label":"Sign in with Apple",children:[c?e.jsx(z.LoadingSpinner,{size:"sm"}):e.jsx("svg",{className:"cedros-button-icon",width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),e.jsx("span",{children:"Continue with Apple"})]})}function ne(t,s){if(!t)throw new Error(s)}function tc(t){return t.replace(/-/g,"+").replace(/_/g,"/")}function jt(t){ne(typeof t=="string"&&t.length>0,"Expected base64url string");const s=tc(t),r=s+"=".repeat((4-s.length%4)%4),o=atob(r),n=new Uint8Array(o.length);for(let a=0;a<o.length;a++)n[a]=o.charCodeAt(a);return n.buffer}function We(t){const s=new Uint8Array(t);let r="";for(let n=0;n<s.length;n++)r+=String.fromCharCode(s[n]);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function no(t){ne(typeof t=="object"&&t!==null,"Invalid credential descriptor");const s=t;return ne(typeof s.type=="string","Invalid credential descriptor type"),ne(typeof s.id=="string","Invalid credential descriptor id"),{type:s.type,id:jt(s.id),transports:Array.isArray(s.transports)?s.transports:void 0}}function Qt(t){ne(t&&typeof t=="object","Missing creation options");const s=t.publicKey;ne(s&&typeof s=="object","Missing creation options.publicKey"),ne(typeof s.challenge=="string","Missing creation challenge"),ne(typeof s.rp=="object"&&s.rp!==null,"Missing rp"),ne(typeof s.user=="object"&&s.user!==null,"Missing user");const r=s.rp,o=s.user;ne(typeof r.name=="string","Missing rp.name"),ne(typeof o.id=="string","Missing user.id"),ne(typeof o.name=="string","Missing user.name"),ne(typeof o.displayName=="string","Missing user.displayName");const n=Array.isArray(s.excludeCredentials)?s.excludeCredentials.map(no):void 0,a=Array.isArray(s.pubKeyCredParams)?s.pubKeyCredParams.map(i=>({type:i.type,alg:i.alg})):[],l={challenge:jt(s.challenge),rp:{name:r.name,id:typeof r.id=="string"?r.id:void 0},user:{id:jt(o.id),name:o.name,displayName:o.displayName},pubKeyCredParams:a,timeout:typeof s.timeout=="number"?s.timeout:void 0,attestation:typeof s.attestation=="string"?s.attestation:void 0,authenticatorSelection:typeof s.authenticatorSelection=="object"&&s.authenticatorSelection!==null?s.authenticatorSelection:void 0,excludeCredentials:n,extensions:typeof s.extensions=="object"&&s.extensions!==null?s.extensions:void 0};return l.hints=["client-device"],l}function Br(t){ne(t&&typeof t=="object","Missing request options");const s=t.publicKey;ne(s&&typeof s=="object","Missing request options.publicKey"),ne(typeof s.challenge=="string","Missing request challenge");const r=Array.isArray(s.allowCredentials)?s.allowCredentials.map(no):void 0,o={challenge:jt(s.challenge),rpId:typeof s.rpId=="string"?s.rpId:void 0,timeout:typeof s.timeout=="number"?s.timeout:void 0,userVerification:typeof s.userVerification=="string"?s.userVerification:void 0,allowCredentials:r,extensions:typeof s.extensions=="object"&&s.extensions!==null?s.extensions:void 0};return o.hints=["client-device"],o}function Ke(t){const s=We(t.rawId),r=t.response,n={...{clientDataJSON:We(r.clientDataJSON)}};if("attestationObject"in r){const a=r;if(n.attestationObject=We(a.attestationObject),typeof a.getTransports=="function")try{n.transports=a.getTransports()}catch{}}if("authenticatorData"in r){const a=r;n.authenticatorData=We(a.authenticatorData),n.signature=We(a.signature),a.userHandle&&(n.userHandle=We(a.userHandle))}return{id:t.id,rawId:s,type:t.type,authenticatorAttachment:t.authenticatorAttachment??void 0,clientExtensionResults:t.getClientExtensionResults?.()??{},response:n}}function sc(){if(typeof window<"u"){const t=window.location?.hostname,s=t==="localhost"||t==="127.0.0.1"||t?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!s)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function rc(t){return typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&typeof t.code=="string"&&typeof t.message=="string"}function Ye(t){if(!(t instanceof Error))return null;const s=t.name;return s==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:s==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:s==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function Vs(){const{config:t,_internal:s}=T.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),l=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[s?.getAccessToken,t.serverUrl,t.requestTimeout,t.retryAttempts]),i=d.useCallback(()=>a(null),[]),c=sc(),u=d.useCallback(async k=>{if(!c){const x={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(x),x}o(!0),a(null);try{const x=await l.post("/webauthn/auth/options",{email:k?.email}),N=Br(x.options),j=await navigator.credentials.get({publicKey:N});if(!j)throw new Error("Passkey authentication returned no credential");const C=await l.post("/webauthn/auth/verify",{challengeId:x.challengeId,credential:Ke(j)});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),C}catch(x){const j=Ye(x)??T.handleApiError(x,"Unable to sign in with passkey. Please try again.");throw a(j),j}finally{o(!1)}},[l,t.callbacks,s,c]),f=d.useCallback(async k=>{if(!c){const x={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(x),x}o(!0),a(null);try{const x=await l.post("/webauthn/register/options",{}),N=Qt(x.options),j=await navigator.credentials.create({publicKey:N});if(!j)throw new Error("Passkey registration returned no credential");const C=await l.post("/webauthn/register/verify",{challengeId:x.challengeId,credential:Ke(j),label:k?.label});if(!C.success)throw new Error("Passkey registration failed");return{credentialId:C.credentialId,label:C.label}}catch(x){const j=Ye(x)??T.handleApiError(x,"Unable to register passkey. Please try again.");throw a(j),j}finally{o(!1)}},[l,c]),h=d.useCallback(async k=>{if(!c){const x={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(x),x}o(!0),a(null);try{const x=await l.post("/webauthn/signup/options",{}),N=Qt(x.options),j=await navigator.credentials.create({publicKey:N});if(!j)throw new Error("Passkey signup returned no credential");const C=await l.post("/webauthn/signup/verify",{challengeId:x.challengeId,credential:Ke(j),email:k?.email,name:k?.name,label:k?.label});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),C}catch(x){const j=Ye(x)??T.handleApiError(x,"Unable to sign up with passkey. Please try again.");throw a(j),j}finally{o(!1)}},[l,t.callbacks,s,c]),p=d.useCallback(async()=>{if(!c){const N={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(N),N}o(!0),a(null);const k=typeof localStorage<"u"&&localStorage.getItem("cedros-passkey-registered")==="1",x=()=>{try{localStorage.setItem("cedros-passkey-registered","1")}catch{}};return k?b(x):w(x)},[l,t.callbacks,s,c]),b=d.useCallback(async k=>{try{const x=await l.post("/webauthn/auth/options",{}),N=Br(x.options),j=await navigator.credentials.get({publicKey:N});if(!j)throw new Error("Passkey authentication returned no credential");const C=await l.post("/webauthn/auth/verify",{challengeId:x.challengeId,credential:Ke(j)});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),k(),C}catch(x){if(x instanceof Error&&(x.name==="NotAllowedError"||x.name==="InvalidStateError"))return m(k);if(typeof x=="object"&&x!==null&&"isApiError"in x&&x.data?.code==="INVALID_CREDENTIALS"){const g={code:"INVALID_CREDENTIALS",message:"This passkey is not recognized. Please remove old passkeys for this site and try again, or sign in another way."};throw a(g),g}const P=Ye(x)??T.handleApiError(x,"Unable to sign in with passkey. Please try again.");throw a(P),P}finally{o(!1)}},[l,t.callbacks,s]),w=d.useCallback(async k=>{try{return await m(k)}catch(x){if(x instanceof Error&&(x.name==="InvalidStateError"||x.name==="NotAllowedError"))return b(k);if(!rc(x)){const C=Ye(x)??T.handleApiError(x,"Unable to create passkey. Please try again.");throw a(C),C}throw x}finally{o(!1)}},[l,t.callbacks,s]),m=d.useCallback(async k=>{const x=await l.post("/webauthn/signup/options",{}),N=Qt(x.options),j=await navigator.credentials.create({publicKey:N});if(!j)throw new Error("Passkey signup returned no credential");const C=await l.post("/webauthn/signup/verify",{challengeId:x.challengeId,credential:Ke(j)});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),k(),C},[l,t.callbacks,s]);return{isSupported:c,isLoading:r,error:n,clearError:i,continueWithPasskey:p,authenticatePasskey:u,registerPasskey:f,signupWithPasskey:h}}function oo({onSuccess:t,className:s="",children:r,disabled:o}){const{continueWithPasskey:n,isLoading:a,isSupported:l}=Vs(),i=o||!l||a;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${s}`,onClick:async()=>{try{await n(),t?.()}catch{}},disabled:i,"aria-disabled":i,children:[a?e.jsx(z.LoadingSpinner,{size:"sm"}):e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(nc,{})}),e.jsx("span",{children:r??"Continue with Passkey"})]})}function nc(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}const Ze=["login","register"];function Et({onSuccess:t,className:s="",defaultTab:r="login"}){const{config:o,socialButtonOrder:n}=T.useCedrosLogin(),[a,l]=d.useState(r),[i,c]=d.useState("form"),[u,f]=d.useState(()=>ze.detectSolanaWallets()),[h]=d.useState(()=>so());d.useEffect(()=>{const P=()=>f(ze.detectSolanaWallets());return P(),window.addEventListener("load",P),window.addEventListener("focus",P),()=>{window.removeEventListener("load",P),window.removeEventListener("focus",P)}},[]);const p=o.forms?.forgotPassword?.mode??(o.features?.instantLink?"instantLink":"reset"),b=d.useCallback(P=>{const g=Ze.indexOf(a);let v=g;switch(P.key){case"ArrowLeft":case"ArrowUp":v=g===0?Ze.length-1:g-1;break;case"ArrowRight":case"ArrowDown":v=g===Ze.length-1?0:g+1;break;case"Home":v=0;break;case"End":v=Ze.length-1;break;default:return}P.preventDefault();const A=Ze[v];l(A),document.getElementById(`cedros-tab-${A}`)?.focus()},[a]),w=o.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},m=w.email!==!1,k=w.google!==!1&&o.googleClientId,x=w.apple!==!1&&o.appleClientId&&h,N=w.solana!==!1&&u,j=w.webauthn!==!1,C=m&&(k||x||N||j);return i==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${s}`,children:e.jsx(eo,{mode:p,onCancel:()=>c("form")})}):e.jsxs("div",{className:`cedros-login-form ${s}`,children:[(j||k||x||N)&&(()=>{const P={webauthn:j?e.jsx(oo,{onSuccess:t}):null,google:k?e.jsx(Rs.GoogleLoginButton,{onSuccess:t}):null,apple:x?e.jsx(ro,{onSuccess:t}):null,solana:N?e.jsx(ze.SolanaLoginButton,{onSuccess:t}):null},g=n??["webauthn","google","apple","solana"];return e.jsx("div",{className:"cedros-social-buttons",children:g.map(v=>{const A=P[v];return A?e.jsx(d.Fragment,{children:A},v):null})})})(),C&&e.jsx("div",{className:"cedros-divider",children:e.jsx("span",{children:"Or continue with"})}),m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-tabs",role:"tablist","aria-label":"Authentication method",children:[e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-login",className:`cedros-tab ${a==="login"?"cedros-tab-active":""}`,onClick:()=>l("login"),onKeyDown:b,"aria-selected":a==="login","aria-controls":"cedros-tabpanel-login",tabIndex:a==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${a==="register"?"cedros-tab-active":""}`,onClick:()=>l("register"),onKeyDown:b,"aria-selected":a==="register","aria-controls":"cedros-tabpanel-register",tabIndex:a==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${a}`,"aria-labelledby":`cedros-tab-${a}`,children:a==="login"?e.jsx(Q.EmailLoginForm,{onSuccess:t,onSwitchToRegister:()=>l("register"),onForgotPassword:()=>c("forgotPassword")}):e.jsx(Q.EmailRegisterForm,{onSuccess:t,onSwitchToLogin:()=>l("login")})})]})]})}class ao extends d.Component{constructor(s){super(s),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){this.setState({errorInfo:r}),console.error("[Cedros Login] Error caught by ErrorBoundary:",s),console.error("[Cedros Login] Component stack:",r.componentStack),this.props.onError?.(s,r)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:s,error:r,errorInfo:o}=this.state,{children:n,fallback:a,showDetails:l=!1}=this.props;return s?a||e.jsx("div",{className:"cedros-error-boundary",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"cedros-error-boundary-content",children:[e.jsxs("svg",{className:"cedros-error-boundary-icon",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("h2",{className:"cedros-error-boundary-title",children:"Something went wrong"}),e.jsx("p",{className:"cedros-error-boundary-message",children:"We encountered an unexpected error. Please try again."}),l&&r&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[r.toString(),o?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):n}}function oc({className:t="",title:s="Sign in to your account"}){const{isModalOpen:r,closeModal:o}=T.useCedrosLogin(),n=d.useRef(null),a=d.useRef(null),l=d.useRef(o);if(d.useEffect(()=>{l.current=o},[o]),d.useEffect(()=>{if(!r)return;a.current=document.activeElement,n.current?.focus();const c=f=>{if(f.key==="Escape"&&l.current(),f.key==="Tab"&&n.current){const h=n.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),p=h[0],b=h[h.length-1];f.shiftKey&&document.activeElement===p?(f.preventDefault(),b?.focus()):!f.shiftKey&&document.activeElement===b&&(f.preventDefault(),p?.focus())}};document.addEventListener("keydown",c);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",c),document.body.style.overflow=u,a.current instanceof HTMLElement&&a.current.focus()}},[r]),!r)return null;const i=c=>{c.target===c.currentTarget&&o()};return e.jsx("div",{className:`cedros-modal-backdrop ${t}`,onClick:i,role:"presentation",children:e.jsxs("div",{ref:n,className:"cedros-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cedros-modal-title",tabIndex:-1,children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"cedros-modal-title",className:"cedros-modal-title",children:s}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:o,"aria-label":"Close",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsx("div",{className:"cedros-modal-content",children:e.jsx(ao,{children:e.jsx(Et,{onSuccess:o})})})]})})}function ac({token:t,onSuccess:s,onLoginClick:r,className:o=""}){const[n,a]=d.useState(""),[l,i]=d.useState(""),[c,u]=d.useState(null),{resetPassword:f,isLoading:h,isSuccess:p,error:b,clearError:w}=St(),m=n===l,k=c?.isValid&&m&&n.length>0,x=async N=>{if(N.preventDefault(),!!k)try{await f(t,n),s?.()}catch{}};return p?e.jsxs("div",{className:`cedros-reset-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Password reset successful"}),e.jsx("p",{className:"cedros-success-message",children:"Your password has been reset. You can now log in with your new password."}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:r,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${o}`,onSubmit:x,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Reset your password"}),e.jsx("p",{className:"cedros-form-subtitle",children:"Enter your new password below."})]}),e.jsx(Z.ErrorMessage,{error:b,onDismiss:w}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(Q.PasswordInput,{label:"New password",value:n,onChange:N=>{a(N.target.value),u(Ie.validatePassword(N.target.value))},showStrengthMeter:!0,onValidationChange:u,disabled:h,autoComplete:"new-password",error:c&&!c.isValid?Object.values(c.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(Q.PasswordInput,{label:"Confirm password",value:l,onChange:N=>i(N.target.value),disabled:h,autoComplete:"new-password",error:l&&!m?"Passwords do not match":void 0})}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:h||!k,children:h?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:h,children:"Back to login"})]})]})}function Ps({org:t,size:s="lg",className:r=""}){const o=Ms.sanitizeImageUrl(t.logoUrl),n=s==="lg"?"cedros-org-avatar-lg":"",a=["cedros-org-avatar",n,r].filter(Boolean).join(" "),l=["cedros-org-avatar-placeholder",n,r].filter(Boolean).join(" ");return o?e.jsx("img",{src:o,alt:t.name,className:a,referrerPolicy:"no-referrer"}):e.jsx("div",{className:l,children:t.name[0]?.toUpperCase()||"?"})}function ic({orgs:t,activeOrg:s,isLoading:r=!1,onSelect:o,onCreateClick:n,className:a="",placeholder:l="Select organization"}){const[i,c]=d.useState(!1),u=d.useRef(null);d.useEffect(()=>{const b=w=>{u.current&&!u.current.contains(w.target)&&c(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]),d.useEffect(()=>{const b=w=>{w.key==="Escape"&&c(!1)};if(i)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[i]);const f=d.useCallback(b=>{o(b),c(!1)},[o]),h=d.useCallback(()=>{c(!1),n?.()},[n]),p=d.useCallback(()=>{c(b=>!b)},[]);return r?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${a}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:u,className:`cedros-org-selector ${a}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:p,"aria-haspopup":"listbox","aria-expanded":i,children:[s?e.jsxs(e.Fragment,{children:[e.jsx(Ps,{org:s,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:s.name}),e.jsx(Mr,{role:s.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:l}),e.jsx(cc,{isOpen:i})]}),i&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[t.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:t.map(b=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${b.id===s?.id?"cedros-org-selector-item-active":""}`,onClick:()=>f(b.id),role:"option","aria-selected":b.id===s?.id,children:[e.jsx(Ps,{org:b,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:b.name}),e.jsx(Mr,{role:b.membership.role}),b.id===s?.id&&e.jsx(lc,{})]})},b.id))}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:h,children:[e.jsx(dc,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function Mr({role:t}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${t}`,children:t})}function cc({isOpen:t}){return e.jsx("svg",{className:`cedros-org-chevron ${t?"cedros-org-chevron-open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function lc(){return e.jsx("svg",{className:"cedros-org-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function dc(){return e.jsx("svg",{className:"cedros-org-plus",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 3V13M3 8H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function uc(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function hc(){return e.jsx("svg",{className:"cedros-org-check",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 10L8 14L16 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function fc(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M10 4V16M4 10H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function pc({orgs:t,activeOrg:s,isLoading:r,onSelect:o,onCreateClick:n}){return r?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[t.length===0?e.jsx("div",{className:"cedros-org-switcher-empty",children:e.jsx("p",{children:"You don't belong to any organizations yet."})}):e.jsx("ul",{className:"cedros-org-switcher-list",children:t.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${a.id===s?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>o(a.id),children:[e.jsx(Ps,{org:a}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:a.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",a.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${a.membership.role}`,children:a.membership.role}),a.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),a.id===s?.id&&e.jsx(hc,{})]})},a.id))}),n&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:n,children:[e.jsx(fc,{}),e.jsx("span",{children:"Create new organization"})]})]})}function mc({isLoading:t,onSubmit:s,onCancel:r}){const[o,n]=d.useState(""),[a,l]=d.useState(""),[i,c]=d.useState(null),u=d.useCallback(h=>{n(h);const p=h.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);l(p)},[]),f=d.useCallback(async h=>{if(h.preventDefault(),c(null),!o.trim()){c("Organization name is required");return}if(!a.trim()){c("Organization slug is required");return}try{await s({name:o.trim(),slug:a.trim()})}catch(p){c(p.message||"Failed to create organization")}},[o,a,s]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:f,children:[i&&e.jsx(Z.ErrorMessage,{error:i}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-name",className:"cedros-form-label",children:"Organization Name"}),e.jsx("input",{id:"org-name",type:"text",className:"cedros-form-input",value:o,onChange:h=>u(h.target.value),placeholder:"My Organization",maxLength:255,disabled:t,autoFocus:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-slug",className:"cedros-form-label",children:"URL Slug"}),e.jsxs("div",{className:"cedros-form-input-prefix",children:[e.jsx("span",{className:"cedros-form-prefix",children:"@"}),e.jsx("input",{id:"org-slug",type:"text",className:"cedros-form-input",value:a,onChange:h=>l(h.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:t})]}),e.jsx("span",{className:"cedros-form-hint",children:"Only lowercase letters, numbers, and hyphens"})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:r,disabled:t,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:t||!o.trim()||!a.trim(),children:t?e.jsx(z.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function gc({isOpen:t,onClose:s,orgs:r,activeOrg:o,isLoading:n=!1,error:a,onSelect:l,onCreate:i,className:c=""}){return t?e.jsx(wc,{onClose:s,orgs:r,activeOrg:o,isLoading:n,error:a,onSelect:l,onCreate:i,className:c}):null}function wc({onClose:t,orgs:s,activeOrg:r,isLoading:o=!1,error:n,onSelect:a,onCreate:l,className:i}){const[c,u]=d.useState("list"),f=d.useRef(null),h=d.useRef(null);d.useEffect(()=>(h.current=document.activeElement,f.current?.querySelector(".cedros-modal-close")?.focus(),()=>{h.current?.focus()}),[]),d.useEffect(()=>{const m=k=>{if(k.key==="Escape"){t();return}if(k.key==="Tab"&&f.current){const x=f.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),N=x[0],j=x[x.length-1];k.shiftKey?document.activeElement===N&&(k.preventDefault(),j?.focus()):document.activeElement===j&&(k.preventDefault(),N?.focus())}};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[t]);const p=d.useCallback(m=>{m.target===m.currentTarget&&t()},[t]),b=d.useCallback(m=>{a(m),t()},[a,t]),w=d.useCallback(async m=>{await l?.(m),t()},[l,t]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:p,children:e.jsxs("div",{ref:f,className:`cedros-modal cedros-org-switcher ${i}`,role:"dialog","aria-modal":"true","aria-labelledby":"org-switcher-title",children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"org-switcher-title",className:"cedros-modal-title",children:c==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:t,"aria-label":"Close",children:e.jsx(uc,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[n&&e.jsx(Z.ErrorMessage,{error:n}),c==="list"?e.jsx(pc,{orgs:s,activeOrg:r,isLoading:o,onSelect:b,onCreateClick:l?()=>u("create"):void 0}):e.jsx(mc,{isLoading:o,onSubmit:w,onCancel:()=>u("list")})]})]})})}function io({sessions:t,isLoading:s=!1,error:r,onRevokeAll:o,className:n=""}){const[a,l]=d.useState(!1),[i,c]=d.useState(!1),u=d.useRef(null),f=d.useMemo(()=>t.filter(p=>!p.isCurrent).length,[t]),h=d.useCallback(async()=>{if(!o)return;const p=t.filter(w=>!w.isCurrent).length;if(!(p===0||!window.confirm(`Are you sure you want to sign out of ${p} other device(s)? This will log you out everywhere except this browser.`))){l(!0),c(!1);try{await o(),c(!0),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{c(!1),u.current=null},3e3)}finally{l(!1)}}},[o,t]);return d.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),s&&t.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${n}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):r?e.jsx("div",{className:`cedros-session-list ${n}`,children:e.jsx(Z.ErrorMessage,{error:r})}):t.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${n}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${n}`,children:[i&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(jc,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:t.map(p=>e.jsx(bc,{session:p},p.id))}),o&&f>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:h,disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${f} other device${f>1?"s":""}`})})]})}function bc({session:t}){const s=yc(t.userAgent),r=Ac(t.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${t.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(vc,{userAgent:t.userAgent})}),e.jsxs("div",{className:"cedros-session-item-info",children:[e.jsxs("div",{className:"cedros-session-item-main",children:[e.jsxs("span",{className:"cedros-session-item-device",children:[s.browser," on ",s.os]}),t.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[t.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",t.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",xc(t.createdAt)]}),r&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function yc(t){if(!t)return{browser:"Unknown browser",os:"Unknown device"};let s="Unknown browser";t.includes("Chrome")&&!t.includes("Edg")?s="Chrome":t.includes("Safari")&&!t.includes("Chrome")?s="Safari":t.includes("Firefox")?s="Firefox":t.includes("Edg")&&(s="Edge");let r="Unknown device";return t.includes("Windows")?r="Windows":t.includes("Mac")?r="macOS":t.includes("Linux")?r="Linux":t.includes("iPhone")||t.includes("iPad")?r="iOS":t.includes("Android")&&(r="Android"),{browser:s,os:r}}function xc(t){const s=new Date(t),o=new Date().getTime()-s.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),l=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n} minute${n>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:l<7?`${l} day${l>1?"s":""} ago`:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Ac(t){const s=new Date(t),r=new Date,o=3600*1e3;return s.getTime()-r.getTime()<o}function vc({userAgent:t}){return t?.includes("iPhone")||t?.includes("iPad")||t?.includes("Android")?e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1",fill:"currentColor"})]}):e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 21H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M12 18V21",stroke:"currentColor",strokeWidth:"1.5"})]})}function jc(){return e.jsx("svg",{className:"cedros-session-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function co({words:t,onConfirm:s,className:r=""}){const[o,n]=d.useState(!1),[a,l]=d.useState(!1),i=d.useRef(null),c=Ki(t),u=d.useCallback(async()=>{try{await navigator.clipboard.writeText(t.join(" ")),n(!0),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>n(!1),2e3)}catch{}},[t]);d.useEffect(()=>()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null)},[]);const f=d.useCallback(()=>{a&&s()},[a,s]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${r}`,children:[e.jsxs("div",{className:"cedros-recovery-header",children:[e.jsx("h3",{className:"cedros-recovery-title",children:"Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-warning",children:"Write down these 12 words in order and store them securely. This is the only way to recover your wallet if you lose access."})]}),e.jsx("div",{className:"cedros-recovery-grid",children:c.map((h,p)=>e.jsx("div",{className:"cedros-word-group",children:h.map((b,w)=>{const m=p*4+w+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[m,"."]}),e.jsx("span",{className:"cedros-word-text",children:b})]},m)})},p))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:u,children:o?"Copied!":"Copy to Clipboard"}),e.jsx("div",{className:"cedros-recovery-security",children:e.jsxs("div",{className:"cedros-warning-box",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M10 6v4m0 4h.01M19 10a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsxs("div",{className:"cedros-warning-content",children:[e.jsx("strong",{children:"Security Warning"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Never share this phrase with anyone"}),e.jsx("li",{children:"Store it offline in a secure location"}),e.jsx("li",{children:"Anyone with this phrase can access your wallet"}),e.jsx("li",{children:"Cedros cannot recover this phrase for you"})]})]})]})}),e.jsxs("div",{className:"cedros-recovery-confirm",children:[e.jsxs("label",{className:"cedros-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:h=>l(h.target.checked),className:"cedros-checkbox"}),e.jsx("span",{children:"I have written down and securely stored my recovery phrase"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:f,disabled:!a,children:"Continue"})]})]})}function lo({onSubmit:t,onCancel:s,isSubmitting:r=!1,error:o,className:n=""}){const[a,l]=d.useState(Array(de).fill("")),[i,c]=d.useState(null),[u,f]=d.useState([]),[h,p]=d.useState(null),b=d.useId(),w=d.useRef(null),m=d.useCallback((g,v)=>{const A=[...a];if(A[g]=v.toLowerCase().trim(),l(A),v.length>0){const y=Qi(v,5);f(y)}else f([]);p(null)},[a]),k=d.useCallback(g=>{c(g),f([])},[]),x=d.useCallback(g=>{const v=a[g];v&&!ct(v)&&p(`Word ${g+1} is not in the wordlist`),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{i===g&&f([])},200)},[a,i]);d.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]);const N=d.useCallback(g=>{if(i!==null){const v=[...a];v[i]=g,l(v),f([]),document.querySelector(`[data-word-index="${i+1}"]`)?.focus()}},[i,a]),j=d.useCallback(g=>{const v=g.clipboardData.getData("text"),A=Yi(v);A.length===de&&(g.preventDefault(),l(A),p(null))},[]),C=d.useCallback(g=>{if(g.preventDefault(),a.filter(y=>!y).length>0){p(`Please enter all ${de} words`);return}const A=a.map((y,L)=>({word:y,index:L+1})).filter(({word:y})=>!ct(y));if(A.length>0){p(`Invalid words: ${A.map(y=>`#${y.index}`).join(", ")}`);return}if(!Xn(a)){p("Invalid recovery phrase - please check your words");return}t(a)},[a,t]),P=o||h;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${n}`,onSubmit:C,onPaste:j,children:[e.jsxs("div",{className:"cedros-recovery-input-header",children:[e.jsx("h3",{className:"cedros-recovery-input-title",children:"Enter Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-input-description",children:"Enter your 12-word recovery phrase. You can paste the entire phrase at once."})]}),e.jsx("div",{className:"cedros-word-inputs",children:Array.from({length:de},(g,v)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[v+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${a[v]&&!ct(a[v])?"cedros-word-invalid":a[v]&&ct(a[v])?"cedros-word-valid":""}`,value:a[v],onChange:A=>m(v,A.target.value),onFocus:()=>k(v),onBlur:()=>x(v),"data-word-index":v,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:r,"aria-label":`Word ${v+1}`})]},v))}),i!==null&&u.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${b}-suggestions`,children:u.map(g=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>N(g),role:"option",children:g},g))}),P&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:P}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:s,disabled:r,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:r,children:r?"Recovering...":"Recover Wallet"})]})]})}function kc({capabilities:t,className:s=""}){if(t.allSupported)return null;const r=_.getMissingCapabilitiesMessage(t),o=_.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${s}`,role:"alert",children:[e.jsxs("div",{className:"cedros-warning-header",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsx("h3",{className:"cedros-warning-title",children:"Wallet Feature Unavailable"})]}),e.jsx("p",{className:"cedros-warning-message",children:r}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",o.browser," ",o.version,o.likelySupported?" (likely supported)":" (may not be supported)"]}),e.jsx("h4",{children:"Required Features"}),e.jsxs("ul",{className:"cedros-capability-list",children:[e.jsxs("li",{className:t.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",t.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:t.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",t.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:t.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",t.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:t.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",t.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:t.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",t.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:t.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",t.argon2?"Available":"Missing"]})]})]}),e.jsxs("div",{className:"cedros-capability-help",children:[e.jsx("h4",{children:"Recommended Browsers"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Chrome 116+ on Windows, macOS, or Android"}),e.jsx("li",{children:"Safari 17+ on macOS or iOS"}),e.jsx("li",{children:"Edge 116+ on Windows"})]}),e.jsx("p",{className:"cedros-capability-note",children:"A platform authenticator (Touch ID, Face ID, or Windows Hello) is required."})]})]})}const Nc=["share_c_only","full_seed","none"];function Cc(t){return t&&Nc.includes(t)?t:"share_c_only"}const Sc={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function uo(){const t=T.useCedrosLoginOptional(),[s,r]=d.useState(null),[o,n]=d.useState(!!t),[a,l]=d.useState(null),i=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts}):null,[t]),c=d.useCallback(async()=>{if(i){n(!0),l(null);try{const u=await i.get("/discovery");u.wallet?r({enabled:u.wallet.enabled,recoveryMode:Cc(u.wallet.recoveryMode),unlockTtlSeconds:u.wallet.unlockTtlSeconds}):r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(u){const f=u instanceof Error?u.message:"Failed to fetch wallet config";l(f),r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{n(!1)}}},[i]);return d.useEffect(()=>{i&&c()},[i,c]),t?{walletEnabled:s?.enabled??!1,recoveryMode:s?.recoveryMode??"share_c_only",unlockTtlSeconds:s?.unlockTtlSeconds??900,isLoading:o,error:a,refetch:c}:Sc}function ho(){const{user:t}=T.useCedrosLogin(),{enroll:s}=_.useWalletMaterial(),{recoveryMode:r}=uo(),[o,n]=d.useState({step:"idle"}),[a,l]=d.useState(!1),i=d.useRef([]),c=d.useCallback(()=>{_.wipeAll(...i.current),i.current=[]},[]);d.useEffect(()=>()=>{c()},[c]);const u=d.useCallback(async(w,m,k,x)=>{n({step:"generating_seed"});const N=_.generateSeed();i.current.push(N),n({step:"splitting_shares"});const{shareA:j,shareB:C,shareC:P}=Hn(N);i.current.push(j,C,P),n({step:"encrypting_shares"});const g=await _.aesGcmEncryptToBase64(j,_.toEncryptionKey(m)),v=qn(N),A=zn(v);n({step:"uploading"});const y={solanaPubkey:A,shareAAuthMethod:w,shareACiphertext:g.ciphertext,shareANonce:g.nonce,shareB:_.uint8ArrayToBase64(C)};if(w==="password"){if(!k)throw new Error("KDF salt required for password method");y.shareAKdfSalt=_.uint8ArrayToBase64(k),y.shareAKdfParams=_.DEFAULT_KDF_PARAMS}if(w==="passkey"&&x&&(y.prfSalt=x),await s(y),r==="none")c(),n({step:"complete",solanaPubkey:A});else{const L=r==="full_seed"?$i(N):Hi(_.toShamirShare(P));n({step:"showing_recovery",recoveryPhrase:L,solanaPubkey:A})}},[s,r,c]),f=d.useCallback(async w=>{if(!t){n({step:"error",error:"User not authenticated"});return}l(!0),c();try{const m=_.generateArgon2Salt(),k=await xn(w,m,_.DEFAULT_KDF_PARAMS);i.current.push(k),await u("password",k,m)}catch(m){n({step:"error",error:m instanceof Error?m.message:"Enrollment failed"})}finally{l(!1)}},[t,c,u]),h=d.useCallback(async()=>{if(!t){n({step:"error",error:"User not authenticated"});return}l(!0),c();try{const w=_.generatePrfSalt(),m=_.uint8ArrayToBase64(w);n({step:"encrypting_shares"});const x=(await _.authenticateWithDiscoverablePrf(m)).prfOutput;i.current.push(x);const N=await _.deriveKeyFromPrf(x,w);i.current.push(N),await u("passkey",N,void 0,m)}catch(w){n({step:"error",error:w instanceof Error?w.message:"Enrollment failed"})}finally{l(!1)}},[t,c,u]),p=d.useCallback(()=>{const w=o.solanaPubkey;c(),n({step:"complete",solanaPubkey:w})},[o.solanaPubkey,c]),b=d.useCallback(()=>{c(),n({step:"idle"}),l(!1)},[c]);return{state:o,startEnrollmentWithPassword:f,startEnrollmentWithPasskey:h,confirmRecoveryPhrase:p,cancel:b,isEnrolling:a}}function fo(){const{config:t,_internal:s}=T.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),l=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s?.getAccessToken]);return{setPassword:d.useCallback(async c=>{o(!0),a(null);try{await l.post("/set-password",{password:c})}catch(u){const f=T.handleApiError(u,"Failed to set password");throw a(f),f}finally{o(!1)}},[l]),isLoading:r,error:n}}function Ec(t){return t.includes("email")?"password":t.includes("webauthn")?"passkey":"set-password"}function po({onComplete:t,onCancel:s,className:r=""}){const{user:o}=T.useCedrosLogin(),{state:n,startEnrollmentWithPassword:a,startEnrollmentWithPasskey:l,confirmRecoveryPhrase:i,cancel:c,isEnrolling:u}=ho(),{setPassword:f,isLoading:h}=fo(),p=o?Ec(o.authMethods):"password",[b,w]=d.useState(""),[m,k]=d.useState(""),[x,N]=d.useState(null);d.useEffect(()=>{w(""),k(""),N(null)},[o?.id]);const j=d.useCallback(async y=>{y.preventDefault(),N(null),await a(b)},[b,a]),C=d.useCallback(async y=>{if(y.preventDefault(),b!==m){N("Passwords do not match");return}const L=Ie.validatePassword(b);if(!L.isValid){const S=Object.values(L.errors)[0];N(S??"Password does not meet requirements");return}N(null);try{await f(b),await a(b)}catch{}},[b,m,f,a]),P=d.useCallback(async()=>{await l()},[l]),g=d.useCallback(()=>{i(),n.solanaPubkey&&t?.(n.solanaPubkey)},[i,n.solanaPubkey,t]),v=d.useCallback(()=>{c(),s?.()},[c,s]),A=u||h;return n.step==="generating_seed"||n.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Generating secure wallet..."})]})}):n.step==="encrypting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Encrypting wallet shares..."})]})}):n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Saving wallet..."})]})}):n.step==="showing_recovery"&&n.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsx(co,{words:n.recoveryPhrase,onConfirm:g})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsxs("div",{className:"cedros-enrollment-complete",children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M16 24l6 6 12-12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{children:"Wallet Created!"}),e.jsxs("p",{className:"cedros-pubkey",children:[e.jsx("strong",{children:"Address:"})," ",n.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsxs("div",{className:"cedros-enrollment-error",children:[e.jsxs("svg",{className:"cedros-error-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 16v12m0 6h.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Enrollment Failed"}),e.jsx("p",{className:"cedros-error-message",children:n.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>c(),children:"Try Again"})]})]})}):e.jsxs("div",{className:`cedros-wallet-enrollment ${r}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),p==="password"&&e.jsx("p",{children:"Enter your account password to secure your wallet."}),p==="passkey"&&e.jsx("p",{children:"Authenticate with your passkey to secure your wallet."}),p==="set-password"&&e.jsx("p",{children:"Set a password for your account to secure your wallet."})]}),p==="password"&&e.jsxs("form",{onSubmit:j,className:"cedros-enrollment-form",children:[e.jsx(Q.PasswordInput,{label:"Account Password",value:b,onChange:y=>w(y.target.value),disabled:A,required:!0,placeholder:"Enter your account password"}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:A,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:A||!b,children:A?"Creating...":"Continue"})]})]}),p==="passkey"&&e.jsxs("div",{className:"cedros-enrollment-form",children:[e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:P,disabled:A,children:A?"Creating...":"Use Passkey"})]})]}),p==="set-password"&&e.jsxs("form",{onSubmit:C,className:"cedros-enrollment-form",children:[e.jsx(Q.PasswordInput,{label:"New Password",value:b,onChange:y=>w(y.target.value),showStrengthMeter:!0,disabled:A,required:!0,minLength:8,placeholder:"Choose a strong password"}),e.jsx(Q.PasswordInput,{label:"Confirm Password",value:m,onChange:y=>k(y.target.value),error:x??void 0,disabled:A,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will also be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:A,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:A||!b||!m,children:A?"Creating...":"Continue"})]})]})]})}function mo(){const{user:t}=T.useCedrosLogin(),{signTransaction:s}=_.useWalletMaterial(),[r,o]=d.useState(!1),[n,a]=d.useState(null),l=d.useCallback(async(c,u)=>{if(!t){const f="User not authenticated";throw a(f),new Error(f)}o(!0),a(null);try{const f={transaction:_.uint8ArrayToBase64(c),...u?{credential:_.toCredentialRequest(u)}:{}},h=await s(f);return _.base64ToUint8Array(h.signature)}catch(f){const h=f instanceof Error?f.message:"Signing failed";throw a(h),f}finally{o(!1)}},[t,s]),i=d.useCallback(()=>a(null),[]);return{signTransaction:l,isSigning:r,error:n,clearError:i}}function go(){const{getMaterial:t}=_.useWalletMaterial(),[s,r]=d.useState(!1),[o,n]=d.useState(null),a=d.useCallback(async()=>{r(!0),n(null);try{const i=await t();if(!i)throw new Error("No wallet enrolled");if(i.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!i.prfSalt)throw new Error("No PRF salt configured for wallet");const c=await _.authenticateWithDiscoverablePrf(i.prfSalt);try{return{type:"prfOutput",prfOutput:_.uint8ArrayToBase64(c.prfOutput)}}finally{c.prfOutput.fill(0)}}catch(i){const c=i instanceof Error?i.message:"Passkey authentication failed";return n(c),null}finally{r(!1)}},[t]),l=d.useCallback(()=>n(null),[]);return{getPasskeyCredential:a,isAuthenticating:s,error:o,clearError:l}}function wo({mode:t,isLoading:s=!1,error:r,onPrompt:o,onRetry:n,onCancel:a,title:l,description:i,className:c=""}){const u=d.useCallback(()=>{s||o?.()},[s,o]),f=d.useCallback(()=>{n?.()},[n]),h=t==="register"?"Set Up Passkey":"Verify with Passkey",p=t==="register"?"Create a passkey to securely encrypt your wallet on this device. You will use your fingerprint, face, or device PIN.":"Use your passkey to unlock your wallet. You will be prompted for biometric verification.";return e.jsxs("div",{className:`cedros-passkey-prompt ${c}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:s?e.jsx(Pc,{}):r?e.jsx(Bc,{}):e.jsx(Lc,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:l??h}),e.jsx("p",{className:"cedros-passkey-description",children:i??p}),r&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:r})}),e.jsx("div",{className:"cedros-passkey-actions",children:r?e.jsxs(e.Fragment,{children:[n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:f,children:"Try Again"}),a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:u,disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):t==="register"?"Create Passkey":"Use Passkey"}),a&&!s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]})}),s&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",t==="register"?"create":"verify"," your passkey."]})]})}function Lc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}function Pc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Bc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4M12 16h.01"})]})}function bo({onUnlock:t,onCancel:s,showCancel:r=!0,authMethod:o,className:n=""}){T.useCedrosLogin();const{unlock:a,getMaterial:l,isLoading:i}=_.useWalletMaterial(),{getPasskeyCredential:c,isAuthenticating:u}=go(),[f,h]=d.useState("idle"),[p,b]=d.useState(o??null),[w,m]=d.useState(""),[k,x]=d.useState(null);d.useEffect(()=>{o!==void 0&&b(o)},[o]);const N=p==="password",j=p==="passkey",C=d.useCallback(async()=>{if(h("credential"),x(null),!p)try{const S=await l();S?b(S.shareAAuthMethod):(x("No wallet enrolled"),h("error"))}catch(S){x(S instanceof Error?S.message:"Failed to get wallet info"),h("error")}},[p,l]),P=d.useCallback(async S=>{S.preventDefault(),x(null),h("unlocking");try{let B;if(N)B={type:"password",password:w};else throw new Error("Invalid auth method");await a(B),h("unlocked"),t?.()}catch(B){x(B instanceof Error?B.message:"Failed to unlock wallet"),h("error")}},[N,w,a,t]),g=d.useCallback(async()=>{x(null),h("unlocking");try{const S=await c();if(!S){h("credential");return}await a(S),h("unlocked"),t?.()}catch(S){x(S instanceof Error?S.message:"Failed to unlock wallet"),h("error")}},[c,a,t]),v=d.useCallback(()=>{m(""),h("idle"),x(null),s?.()},[s]),A=d.useCallback(()=>{m(""),h("credential"),x(null)},[]),y=i||u,L=()=>{switch(f){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Mc,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Locked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Unlock your wallet to sign transactions."}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:C,children:"Unlock Wallet"})]});case"credential":return N?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:P,children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Enter Password"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Enter your wallet password to unlock."}),e.jsx(Q.PasswordInput,{label:"Password",value:w,onChange:S=>m(S.target.value),disabled:y,autoComplete:"current-password",error:k??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:y||w.length===0,children:y?"Unlocking...":"Unlock"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:y,children:"Cancel"})]})]}):j?e.jsxs("div",{className:"cedros-wallet-unlock-passkey",children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Verify with Passkey"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Use your passkey to unlock your wallet."}),e.jsx(wo,{mode:"authenticate",isLoading:y,error:k??void 0,onPrompt:g,onRetry:g,onCancel:r?v:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(z.LoadingSpinner,{size:"xl"}),e.jsx("p",{children:"Loading wallet info..."})]});case"unlocking":return e.jsxs("div",{className:"cedros-wallet-unlock-progress",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(z.LoadingSpinner,{size:"xl"})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlocking Wallet"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Verifying your credentials..."})]});case"unlocked":return e.jsxs("div",{className:"cedros-wallet-unlock-success",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Rc,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Unlocked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Your wallet is ready to sign transactions."})]});case"error":return e.jsxs("div",{className:"cedros-wallet-unlock-error",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Tc,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:k??"Failed to unlock wallet. Please try again."}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:A,children:"Try Again"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${n}`,children:L()})}function Mc(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"10",y:"22",width:"28",height:"20",rx:"4",stroke:"currentColor",strokeWidth:"2",fill:"var(--cedros-muted, #f3f4f6)"}),e.jsx("path",{d:"M16 22V16a8 8 0 1 1 16 0v6",stroke:"currentColor",strokeWidth:"2",fill:"none"}),e.jsx("circle",{cx:"24",cy:"32",r:"3",fill:"currentColor"})]})}function Rc(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function Tc(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function yo(){const{recover:t,getShareBForRecovery:s}=_.useWalletMaterial(),{recoveryMode:r}=uo(),[o,n]=d.useState({step:"idle"}),[a,l]=d.useState(!1),i=d.useRef([]),c=d.useCallback(()=>{_.wipeAll(...i.current),i.current=[]},[]);d.useEffect(()=>()=>{c()},[c]);const u=d.useCallback(async(h,p,b)=>{l(!0),c();try{if(n({step:"validating"}),!Xn(h))throw new Error("Invalid recovery phrase. Please check your words.");let w;if(r==="share_c_only"){const A=Vi(h);i.current.push(A);const y=_.uint8ArrayToBase64(A),L=await s({shareC:y}),S=_.base64ToUint8Array(L.shareB);i.current.push(S),w=Bi(_.toShamirShare(S),_.toShamirShare(A)),i.current.push(w)}else w=Gi(h),i.current.push(w);const m=qn(w),k=zn(m),{shareA:x,shareB:N}=Hn(w);i.current.push(x,N),n({step:"encrypting"});let j,C,P;if(p==="passkey"){const A=_.generatePrfSalt();P=_.uint8ArrayToBase64(A);const y=await _.authenticateWithDiscoverablePrf(P);i.current.push(y.prfOutput),j=await _.deriveKeyFromPrf(y.prfOutput,A),i.current.push(j)}else C=_.generateArgon2Salt(),j=await xn(b,C,_.DEFAULT_KDF_PARAMS),i.current.push(j);const g=await _.aesGcmEncryptToBase64(x,_.toEncryptionKey(j));n({step:"uploading"});const v={solanaPubkey:k,shareAAuthMethod:p,shareACiphertext:g.ciphertext,shareANonce:g.nonce,shareB:_.uint8ArrayToBase64(N)};p==="password"&&(v.shareAKdfSalt=_.uint8ArrayToBase64(C),v.shareAKdfParams=_.DEFAULT_KDF_PARAMS),p==="passkey"&&(v.prfSalt=P),await t(v),c(),n({step:"complete"})}catch(w){c(),n({step:"error",error:w instanceof Error?w.message:"Recovery failed"})}finally{l(!1)}},[t,s,r,c]),f=d.useCallback(()=>{c(),n({step:"idle"}),l(!1)},[c]);return{state:o,startRecovery:u,cancel:f,isRecovering:a}}function xo({onComplete:t,onCancel:s,className:r="",defaultAuthMethod:o="password"}){const{state:n,startRecovery:a,cancel:l,isRecovering:i}=yo(),[c,u]=d.useState([]),[f,h]=d.useState(!1),[p,b]=d.useState(o),[w,m]=d.useState(""),[k,x]=d.useState(""),[N,j]=d.useState(null),C=d.useCallback(y=>{u(y),h(!0)},[]),P=d.useCallback(async y=>{if(y.preventDefault(),j(null),p!=="passkey"){if(w!==k){j("Passwords do not match");return}if(p==="password"&&w.length<8){j("Password must be at least 8 characters");return}}await a(c,p,w)},[c,p,w,k,a]),g=d.useCallback(()=>{l(),u([]),h(!1),m(""),x(""),s?.()},[l,s]),v=d.useCallback(()=>{h(!1),m(""),x("")},[]),A=d.useCallback(()=>{t?.()},[t]);return n.step==="validating"||n.step==="encrypting"||n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Ic,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[n.step==="validating"&&"Validating Recovery Phrase",n.step==="encrypting"&&"Encrypting Wallet",n.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[n.step==="validating"&&"Checking your recovery phrase...",n.step==="encrypting"&&"Securing your wallet with new encryption...",n.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(_c,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Wallet Recovered"}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:["Your wallet has been successfully recovered and secured with your new"," ",p==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:A,children:"Done"})})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Dc,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recovery Failed"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:n.error??"An error occurred during recovery. Please try again."}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:g,children:"Start Over"})})]})}):f?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:P,children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Set New Security"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Choose how to secure your recovered wallet."})]}),e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:p==="password",onChange:()=>b("password"),disabled:i}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:p==="passkey",onChange:()=>b("passkey"),disabled:i}),e.jsx("span",{children:"Passkey"})]})]}),p==="password"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password",className:"cedros-label",children:"New Password"}),e.jsx("input",{id:"recovery-password",type:"password",className:"cedros-input",value:w,onChange:y=>m(y.target.value),disabled:i,minLength:8,placeholder:"Enter a strong password"})]}),e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password-confirm",className:"cedros-label",children:"Confirm Password"}),e.jsx("input",{id:"recovery-password-confirm",type:"password",className:"cedros-input",value:k,onChange:y=>x(y.target.value),disabled:i,"aria-invalid":N?"true":void 0,placeholder:"Confirm your password"}),N&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:N})]})]}),p==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(Uc,{}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-wallet-recovery-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:i,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:i||p!=="passkey"&&(w.length===0||k.length===0),children:i?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-phrase",children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recover Your Wallet"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Enter your 12-word recovery phrase to restore your wallet."})]}),e.jsx(lo,{onSubmit:C,onCancel:g,isSubmitting:!1})]})})}function Ic(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-muted, #e5e7eb)",strokeWidth:"3",fill:"none"}),e.jsx("path",{d:"M24 4a20 20 0 0 1 20 20",stroke:"var(--cedros-primary, #6366f1)",strokeWidth:"3",strokeLinecap:"round",fill:"none"})]})}function _c(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function Dc(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function Uc(){return e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Ao({address:t,label:s="Wallet Address",showCopy:r=!0,showExplorerLink:o=!0,allowReveal:n=!0,className:a=""}){const l=T.useCedrosLoginOptional(),[i,c]=d.useState(!1),[u,f]=d.useState(null),[h,p]=d.useState(!1),b=d.useRef(null),w=l?.config.solana?.network??"mainnet-beta",m=d.useMemo(()=>{const j=`https://explorer.solana.com/address/${t}`;return w==="mainnet-beta"?j:`${j}?cluster=${encodeURIComponent(w)}`},[t,w]),k=n&&t.length>18,x=d.useMemo(()=>!k||h?t:`${t.slice(0,8)}...${t.slice(-8)}`,[t,k,h]),N=d.useCallback(async()=>{try{f(null),await navigator.clipboard.writeText(t),c(!0),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{c(!1),b.current=null},2e3)}catch(j){c(!1),f(j instanceof Error?j.message:"Copy failed")}},[t]);return d.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${a}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:s}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[k&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>p(j=>!j),"aria-label":h?"Hide full wallet address":"Show full wallet address",children:h?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10.7 10.7a3 3 0 0 0 4.24 4.24",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9.88 5.09A10.94 10.94 0 0 1 12 5c5 0 9.27 3.11 11 7-0.55 1.23-1.32 2.33-2.27 3.25",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.61 6.61C4.4 7.9 2.74 9.8 1 12c1.73 3.89 6 7 11 7 1.14 0 2.25-0.16 3.3-0.46",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),o&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:m,target:"_blank",rel:"noreferrer",children:"Explorer"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:N,"aria-label":"Copy wallet address",children:i?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:t,children:x}),u&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:u})]})}function vo({status:t,publicKey:s,onLock:r,onEnroll:o,onUnlock:n,onRecover:a,showActions:l=!0,compact:i=!1,className:c=""}){const u=t!==void 0,f=_.useWallet(),h=u?t:f.status,p=u?s??null:f.solanaPubkey,b=u?null:f.error,w=u?()=>{}:f.refresh,m=u?()=>{}:f.clearError,k=Fc(h,b);return i?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${c}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${k.color}`,title:k.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:k.label}),p&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:p,children:Oc(p)})]}):e.jsxs("div",{className:`cedros-wallet-status ${c}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${k.color}`,children:e.jsx(Wc,{status:h})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:k.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:k.description})]})]}),p&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(Ao,{address:p})}),b&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:m,children:"Dismiss"})]}),l&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[h==="not_enrolled"&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:o,children:"Create Wallet"}),h==="enrolled_locked"&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:n,children:"Unlock Wallet"}),(h==="not_enrolled"||h==="error")&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:a,children:"Recover Wallet"}),h==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:w,children:"Retry"})]})]})}function Fc(t,s){switch(t){case"loading":return{label:"Loading",title:"Checking Wallet",description:"Verifying wallet status...",color:"loading"};case"not_enrolled":return{label:"Not Set Up",title:"No Wallet",description:"Create a wallet to start using Solana.",color:"muted"};case"enrolled_locked":return{label:"Locked",title:"Wallet Locked",description:"Unlock your wallet to sign transactions.",color:"warning"};case"enrolled_unlocked":case"unlocked":return{label:"Ready",title:"Wallet Ready",description:"Your wallet is unlocked and ready to use.",color:"success"};case"error":default:return{label:"Error",title:"Wallet Error",description:s??"An error occurred with your wallet.",color:"error"}}}function Oc(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function Wc({status:t}){switch(t){case"loading":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"not_enrolled":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]});case"enrolled_locked":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});case"enrolled_unlocked":case"unlocked":return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});case"error":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4M12 17h.01"})]});default:return null}}function qc({className:t="",showActions:s=!0}){const r=_.useWallet(),[o,n]=d.useState("status"),a=d.useMemo(()=>{switch(o){case"enroll":return{title:"Create Wallet",description:"Set up your embedded wallet."};case"unlock":return{title:"Unlock Wallet",description:"Unlock to sign transactions."};case"recover_intro":case"recover":return{title:"Recover Wallet",description:"Restore access using your recovery phrase."};case"status":default:return null}},[o]),l=d.useCallback(()=>n("status"),[]),i=d.useCallback(async()=>{n("status"),await r.refresh()},[r]),c=d.useCallback(async()=>{n("status"),await r.refresh()},[r]),u=d.useCallback(async()=>{n("status"),await r.refresh()},[r]);return e.jsxs("div",{className:`cedros-wallet-manager ${t}`,children:[o!=="status"&&a&&e.jsxs("div",{className:"cedros-wallet-manager-header",children:[e.jsxs("div",{className:"cedros-wallet-manager-header-text",children:[e.jsx("h3",{className:"cedros-wallet-manager-title",children:a.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:a.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:l,children:"Back"})]}),o==="status"&&e.jsx(vo,{onEnroll:()=>n("enroll"),onUnlock:()=>n("unlock"),onRecover:()=>n("recover_intro"),showActions:s}),o==="enroll"&&e.jsx(po,{onComplete:()=>{i()},onCancel:l}),o==="unlock"&&e.jsx(bo,{onUnlock:()=>{c()},onCancel:l}),o==="recover_intro"&&e.jsx("div",{className:"cedros-wallet-manager-intro",children:e.jsxs("div",{className:"cedros-wallet-manager-intro-card",children:[e.jsx("h4",{className:"cedros-wallet-manager-intro-title",children:"Before you start"}),e.jsxs("ul",{className:"cedros-wallet-manager-intro-list",children:[e.jsx("li",{children:"You’ll need your 12-word recovery phrase."}),e.jsx("li",{children:"You’ll set a new password or passkey for this wallet."}),e.jsx("li",{children:"If you’re on a shared device, avoid copying the phrase into other apps."})]}),e.jsxs("div",{className:"cedros-wallet-manager-intro-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>n("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:l,children:"Cancel"})]})]})}),o==="recover"&&e.jsx(xo,{onComplete:()=>{u()},onCancel:l})]})}function zc({showDescriptions:t=!0,className:s="",onSave:r}){const{settings:o,isLoading:n,isUpdating:a,error:l,fetchSettings:i,updateSettings:c}=mn.useSystemSettings(),[u,f]=d.useState({}),[h,p]=d.useState(null),[b,w]=d.useState(!1);d.useEffect(()=>{i()},[i]),d.useEffect(()=>{if(b){const P=setTimeout(()=>w(!1),3e3);return()=>clearTimeout(P)}},[b]);const m=d.useCallback((P,g)=>{f(v=>({...v,[P]:g})),p(null),w(!1)},[]),k=d.useCallback(async()=>{const P=Object.entries(u).map(([g,v])=>({key:g,value:v}));if(P.length!==0)try{await c(P),f({}),p(null),w(!0),r?.()}catch(g){p(g instanceof Error?g.message:"Failed to save settings")}},[u,c,r]),x=d.useCallback(()=>{f({}),p(null),w(!1)},[]),N=Object.keys(u).length>0,j=Object.keys(u).length;if(n&&Object.keys(o).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(l)return e.jsx("div",{className:`cedros-system-settings ${s}`,children:e.jsx(Z.ErrorMessage,{error:l.message})});const C=Object.keys(o).sort();return C.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${s}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${s}`,children:[h&&e.jsx(Z.ErrorMessage,{error:h}),b&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),C.map(P=>e.jsx(Hc,{category:P,settings:o[P],edits:u,showDescription:t,onChange:m},P)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[N&&e.jsxs("span",{className:"cedros-settings-change-count",children:[j," unsaved change",j!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:x,disabled:!N||a,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:k,disabled:!N||a,children:a?e.jsx(z.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}const Rr=Object.keys(Ae.SETTING_METADATA);function Hc({category:t,settings:s,edits:r,showDescription:o,onChange:n}){const a=Ae.CATEGORY_METADATA[t]||{label:t,description:"",icon:""},l=d.useMemo(()=>[...s].sort((i,c)=>{const u=Rr.indexOf(i.key),f=Rr.indexOf(c.key);return(u===-1?1/0:u)-(f===-1?1/0:f)}),[s]);return e.jsxs("section",{className:"cedros-settings-section",children:[e.jsxs("div",{className:"cedros-settings-section-header",children:[e.jsx("span",{className:"cedros-settings-section-icon",children:a.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:a.label}),o&&a.description&&e.jsx("p",{className:"cedros-settings-section-description",children:a.description})]})]}),e.jsx(Ae.SettingsSection,{settings:l,edits:r,onChange:n})]})}class Vc{client;constructor(s,r,o){this.client=new T.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o})}async getStatus(){try{return await this.client.get("/setup/status")}catch(s){throw T.handleApiError(s,"Failed to check setup status")}}async createFirstAdmin(s){try{return await this.client.post("/setup/admin",s)}catch(r){throw T.handleApiError(r,"Failed to create admin account")}}}function $s(){const{config:t}=T.useCedrosLogin(),[s,r]=d.useState(null),[o,n]=d.useState(!1),[a,l]=d.useState(!1),[i,c]=d.useState(null),u=d.useRef(0),f=d.useMemo(()=>new Vc(t.serverUrl,t.requestTimeout,t.retryAttempts),[t.serverUrl,t.requestTimeout,t.retryAttempts]),h=d.useRef(f);h.current=f;const p=d.useCallback(async()=>{n(!0),c(null);const w=++u.current;try{const m=await h.current.getStatus();if(w!==u.current)return;r(m)}catch(m){if(w!==u.current)return;c(m instanceof Error?m:new Error("Failed to check setup status"))}finally{w===u.current&&n(!1)}},[]),b=d.useCallback(async w=>{l(!0),c(null);try{const m=await h.current.createFirstAdmin(w);return await p(),m}catch(m){const k=m instanceof Error?m:new Error("Failed to create admin");throw c(k),k}finally{l(!1)}},[p]);return{status:s,isLoading:o,isCreating:a,error:i,checkStatus:p,createAdmin:b}}const $c=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Tr=8;function Gc(t){const s={};return t.email?$c.test(t.email)||(s.email="Invalid email format"):s.email="Email is required",t.password?t.password.length<Tr&&(s.password=`Password must be at least ${Tr} characters`):s.password="Password is required",t.confirmPassword?t.password!==t.confirmPassword&&(s.confirmPassword="Passwords do not match"):s.confirmPassword="Please confirm your password",s}function jo({onComplete:t,className:s=""}){const{status:r,isLoading:o,isCreating:n,error:a,checkStatus:l,createAdmin:i}=$s(),[c,u]=d.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[f,h]=d.useState({}),[p,b]=d.useState(!1);d.useEffect(()=>{l()},[l]);const w=d.useCallback(k=>x=>{u(N=>({...N,[k]:x.target.value})),h(N=>({...N,[k]:void 0}))},[]),m=d.useCallback(async k=>{k.preventDefault();const x=Gc(c);if(Object.keys(x).length>0){h(x);return}try{await i({email:c.email,password:c.password,name:c.name||void 0,orgName:c.orgName||void 0}),b(!0),t?.()}catch{}},[c,i,t]);return o?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):r&&!r.needsSetup?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Setup Complete"}),e.jsx("p",{className:"cedros-setup__text",children:"An admin account already exists. You can now log in."})]})}):p?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Admin Account Created"}),e.jsx("p",{className:"cedros-setup__text",children:"Your admin account has been created successfully. You can now log in with your credentials."})]})}):e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__container",children:[e.jsxs("div",{className:"cedros-setup__header",children:[e.jsx("div",{className:"cedros-setup__logo",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),e.jsx("h1",{className:"cedros-setup__title",children:"Welcome to Cedros"}),e.jsx("p",{className:"cedros-setup__subtitle",children:"Let's set up your admin account to get started."})]}),e.jsxs("form",{className:"cedros-setup__form",onSubmit:m,children:[a&&e.jsx(Z.ErrorMessage,{error:a.message}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-email",className:"cedros-setup__label",children:["Email Address ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-email",type:"email",className:`cedros-setup__input ${f.email?"cedros-setup__input--error":""}`,value:c.email,onChange:w("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:n}),f.email&&e.jsx("span",{className:"cedros-setup__error",children:f.email})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-name",className:"cedros-setup__label",children:"Display Name"}),e.jsx("input",{id:"setup-name",type:"text",className:"cedros-setup__input",value:c.name,onChange:w("name"),placeholder:"Admin",autoComplete:"name",disabled:n})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-org-name",className:"cedros-setup__label",children:"Organization Name"}),e.jsx("input",{id:"setup-org-name",type:"text",className:"cedros-setup__input",value:c.orgName,onChange:w("orgName"),placeholder:"My Organization",disabled:n})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-password",className:"cedros-setup__label",children:["Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-password",type:"password",className:`cedros-setup__input ${f.password?"cedros-setup__input--error":""}`,value:c.password,onChange:w("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:n}),f.password&&e.jsx("span",{className:"cedros-setup__error",children:f.password})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-confirm-password",className:"cedros-setup__label",children:["Confirm Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-confirm-password",type:"password",className:`cedros-setup__input ${f.confirmPassword?"cedros-setup__input--error":""}`,value:c.confirmPassword,onChange:w("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:n}),f.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:f.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Creating Account..."})]}):"Create Admin Account"})]}),e.jsxs("div",{className:"cedros-setup__footer",children:[e.jsx("p",{className:"cedros-setup__note",children:"This will be the first administrator account for your installation."}),r?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",r.serverVersion]})]})]})})}const Qc=["security","rate_limit"];function Kc({className:t}){return e.jsx(_s.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:Qc,className:t})}const Ir=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function Yc({className:t}){const{settings:s,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:l,fetchSettings:i,handleChange:c,getEffectiveValue:u}=Ae.useSettingsAutosave(),[f,h]=d.useState("email");d.useEffect(()=>{i()},[i]);const p=Ir.find(C=>C.id===f),b=p?.category??"",m=(u("email_provider")||"custom")==="custom",k=u("email_smtp_host"),x=!m||k!=null&&k!=="",N=d.useMemo(()=>{const C=s[b]??[];if(f!=="email")return C;const P=m?ut.ALL_EMAIL_FIELDS:ut.SIMPLIFIED_EMAIL_FIELDS;return C.filter(g=>P.includes(g.key)).sort((g,v)=>P.indexOf(g.key)-P.indexOf(v.key))},[s,b,f,m]),j=(C,P)=>{if(c(C,P),C==="email_provider"&&P!=="custom"){const g=ut.PROVIDER_SMTP_HOSTS[P];g&&(c("email_smtp_host",g),c("email_smtp_port","587"),c("email_smtp_tls","true"))}};return o&&Object.keys(s).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t??""}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):l?e.jsx("div",{className:`cedros-system-settings ${t??""}`,children:e.jsx(Z.ErrorMessage,{error:l.message})}):e.jsxs("div",{className:`cedros-system-settings ${t??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Auth Messages"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure email delivery for verification emails, password resets, and instant link login. Webhook notifications can be sent to Discord or Slack."})]}),e.jsx(Ae.AutosaveStatus,{status:n,error:a})]}),f==="email"&&!x&&e.jsx("div",{className:"cedros-settings-warning-banner",children:"Email features (verification, password reset, instant link) are disabled until SMTP is configured. Select a provider or enter custom SMTP settings below."}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:Ir.map(C=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${f===C.id?"cedros-admin-tab-active":""}`,onClick:()=>h(C.id),"aria-selected":f===C.id,role:"tab",children:C.label},C.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:N.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",p?.label??"this section","."]})}):e.jsx(Ae.SettingsSection,{settings:N,edits:r,onChange:f==="email"?j:c})})]})}const Kt=["image_storage_enabled","image_storage_provider","image_storage_bucket","image_storage_region","image_storage_endpoint","image_storage_access_key","image_storage_secret_key","image_storage_cdn_url"],_r={nyc3:"https://nyc3.digitaloceanspaces.com",ams3:"https://ams3.digitaloceanspaces.com",sgp1:"https://sgp1.digitaloceanspaces.com",sfo3:"https://sfo3.digitaloceanspaces.com",fra1:"https://fra1.digitaloceanspaces.com",syd1:"https://syd1.digitaloceanspaces.com"};function Zc({className:t}){const{settings:s,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:l,fetchSettings:i,handleChange:c,getEffectiveValue:u}=Ae.useSettingsAutosave();d.useEffect(()=>{i()},[i]);const f=d.useMemo(()=>(s.image_storage??[]).filter(b=>Kt.includes(b.key)).sort((b,w)=>Kt.indexOf(b.key)-Kt.indexOf(w.key)),[s]),h=(p,b)=>{if(c(p,b),p==="image_storage_provider")if(b==="digitalocean"){const w=u("image_storage_region")||"nyc3";c("image_storage_region",w),c("image_storage_endpoint",_r[w]??`https://${w}.digitaloceanspaces.com`)}else b==="s3"&&c("image_storage_endpoint","");p==="image_storage_region"&&u("image_storage_provider")==="digitalocean"&&c("image_storage_endpoint",_r[b]??`https://${b}.digitaloceanspaces.com`)};return o&&Object.keys(s).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t??""}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):l?e.jsx("div",{className:`cedros-system-settings ${t??""}`,children:e.jsx(Z.ErrorMessage,{error:l.message})}):e.jsxs("div",{className:`cedros-system-settings ${t??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Image Storage"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure S3-compatible object storage for user avatars and images. Supports AWS S3, DigitalOcean Spaces, and other S3-compatible providers."})]}),e.jsx(Ae.AutosaveStatus,{status:n,error:a})]}),f.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsx("p",{children:"No image storage settings found."})}):e.jsx(Ae.SettingsSection,{settings:f,edits:r,onChange:h})]})}const le={users:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),members:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),deposits:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}),e.jsx("path",{d:"M12 18V6"})]}),withdrawals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}),e.jsx("path",{d:"M9 22v-4h6v4"}),e.jsx("path",{d:"M8 6h.01"}),e.jsx("path",{d:"M16 6h.01"}),e.jsx("path",{d:"M12 6h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M8 14h.01"})]}),wallet:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),mail:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),coins:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6"}),e.jsx("path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18"}),e.jsx("path",{d:"M7 6h1v4"}),e.jsx("path",{d:"m16.71 13.88.7.71-2.82 2.82"})]}),server:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),image:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})},Xc=[{id:"users",label:"Users",icon:le.users},{id:"team",label:"Team",icon:le.members},{id:"deposits",label:"Deposits",icon:le.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:le.withdrawals,requiredFeature:"credits"},{id:"settings-auth",label:"Authentication",icon:le.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:le.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:le.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:le.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-server",label:"Auth Server",icon:le.server,group:"Configuration"},{id:"settings-images",label:"Image Storage",icon:le.image,group:"Configuration"}];function Jc({title:t="Dashboard",sections:s=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server","settings-images"],defaultSection:r="users",refreshInterval:o=0,pageSize:n=20,onSectionChange:a,onSettingsClick:l,onLogoutClick:i,className:c=""}){const[u,f]=d.useState(r),[h,p]=d.useState(!0),{user:b,logout:w}=T.useCedrosLogin(),{activeOrg:m,role:k,isLoading:x,fetchOrgs:N,hasPermission:j}=Ts.useOrgs(),{status:C,isLoading:P,checkStatus:g}=$s(),{features:v,isLoading:A}=ie.useServerFeatures(),{canAccess:y}=ie.useDashboardPermissions(),L=d.useCallback(R=>{f(R),a?.(R)},[a]),S=Xc.filter(R=>!(!s.includes(R.id)||R.requiredFeature&&!v[R.requiredFeature]||!y(R.id))),B=S.find(R=>R.id===u),E=!B&&!A;return d.useEffect(()=>{N(),g()},[N,g]),d.useEffect(()=>{E&&S.length>0&&f("users")},[E,S.length]),!P&&C?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${c}`,children:e.jsx(jo,{onComplete:()=>g()})}):(x||P||A)&&!m?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${c}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):u==="team"&&!m?e.jsx("div",{className:`cedros-admin cedros-dashboard ${c}`,children:e.jsx(Z.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${c}`,children:[e.jsxs("aside",{className:"cedros-dashboard__sidebar",children:[e.jsx("div",{className:"cedros-dashboard__sidebar-header",children:e.jsxs("div",{className:"cedros-dashboard__logo",children:[le.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:t})]})}),e.jsxs("nav",{className:"cedros-dashboard__nav",children:[e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsx("span",{className:"cedros-dashboard__nav-label",children:"Menu"}),S.filter(R=>!R.group).map(R=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===R.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>L(R.id),"aria-current":u===R.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:R.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:R.label})]},R.id))]}),S.some(R=>R.group==="Configuration")&&e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsxs("button",{type:"button",className:"cedros-dashboard__nav-label cedros-dashboard__nav-label--collapsible",onClick:()=>p(!h),"aria-expanded":h,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${h?"cedros-dashboard__nav-chevron--expanded":""}`,children:le.chevronRight})]}),h&&S.filter(R=>R.group==="Configuration").map(R=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===R.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>L(R.id),"aria-current":u===R.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:R.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:R.label})]},R.id))]})]}),b&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(Me.ProfileDropdown,{name:b.name,email:b.email,picture:b.picture,onSettings:l,onLogout:i??w})})]}),e.jsxs("main",{className:"cedros-dashboard__main",children:[e.jsx("header",{className:"cedros-dashboard__header",children:e.jsxs("div",{className:"cedros-dashboard__breadcrumb",children:[e.jsx("span",{className:"cedros-dashboard__breadcrumb-root",children:t}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:le.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:B?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[u==="users"&&e.jsx(el,{pageSize:n,currentUserId:b?.id}),u==="team"&&m&&e.jsx(tl,{orgId:m.id,currentUserId:b?.id,hasPermission:j,role:k}),u==="deposits"&&e.jsx(sl,{pageSize:n,refreshInterval:o}),u==="withdrawals"&&e.jsx(rl,{pageSize:n,refreshInterval:o}),u==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(wn.AuthenticationSettings,{})}),u==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(bn.EmbeddedWalletSettings,{})}),u==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Yc,{})}),u==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Is.CreditSystemSettings,{})}),u==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(yn.ServerSettings,{})}),u==="settings-images"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Zc,{})})]})]})]})}function el({pageSize:t,currentUserId:s}){const[r,o]=d.useState(null),{statsItems:n,isLoading:a,error:l,refresh:i}=et.useUsersStatsSummary();return r?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(et.AdminUserDetail,{userId:r.id,currentUserId:s,onBack:()=>o(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(gn.StatsBar,{stats:n,isLoading:a,onRefresh:i}),l&&e.jsx("p",{className:"cedros-admin-error-inline",children:l}),e.jsx(et.AdminUserList,{pageSize:t,currentUserId:s,onUserClick:c=>o(c)})]})}function tl({orgId:t,currentUserId:s,hasPermission:r,role:o}){const[n,a]=d.useState("members"),{members:l,isLoading:i,error:c,fetchMembers:u,updateMemberRole:f,removeMember:h}=ie.useMembers(t),{invites:p,isLoading:b,error:w,fetchInvites:m,createInvite:k,cancelInvite:x,resendInvite:N}=ie.useInvites(t);d.useEffect(()=>{u(),m()},[u,m]);const j=r("invite:create"),C=r("invite:cancel"),P=p.length,g=l.reduce((L,S)=>(L[S.role]=(L[S.role]??0)+1,L),{}),v=g.owner??0,A=g.admin??0,y=g.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(gn.StatsBar,{stats:[{label:"Owners",value:v},{label:"Admins",value:A},{label:"Members",value:y},{label:"Pending Invites",value:P}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="members"?"cedros-admin-tab-active":""}`,onClick:()=>a("members"),"aria-selected":n==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${n==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>a("invites"),"aria-selected":n==="invites",role:"tab",children:["Pending Invites",P>0&&` (${P})`]}),o==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>a("permissions"),"aria-selected":n==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[n==="members"&&e.jsx(ie.MemberList,{members:l,currentUserId:s,isLoading:i,error:c?.message,canManage:r("member:remove"),canChangeRoles:r("member:role_change"),onUpdateRole:f,onRemove:h}),n==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[j&&e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx("div",{className:"cedros-dashboard__section-header",children:e.jsx("h3",{className:"cedros-dashboard__section-title",children:"Send Invitation"})}),e.jsx(ie.InviteForm,{onSubmit:k,isLoading:b,error:w?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(ie.InviteList,{invites:p,isLoading:b,error:w?.message,canManage:C||j,onCancel:C?x:void 0,onResend:j?N:void 0})})]}),n==="permissions"&&o==="owner"&&e.jsx(ie.PermissionsSection,{userRole:o})]})]})}function sl({pageSize:t,refreshInterval:s}){const[r,o]=d.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(mt.AdminDepositStats,{refreshInterval:s}),e.jsxs("div",{className:"cedros-dashboard__deposits-list",children:[e.jsx("div",{className:"cedros-dashboard__toolbar",children:e.jsxs("div",{className:"cedros-dashboard__filter",children:[e.jsx("label",{className:"cedros-dashboard__filter-label",htmlFor:"status-filter",children:"Status"}),e.jsxs("select",{id:"status-filter",className:"cedros-dashboard__select",value:r,onChange:n=>o(n.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"detected",children:"Detected"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"withdrawn",children:"Withdrawn"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})}),e.jsx(mt.AdminDepositList,{statusFilter:r||void 0,pageSize:t,refreshInterval:s})]})]})}function rl({pageSize:t,refreshInterval:s}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(Be.AdminWithdrawalStats,{refreshInterval:s}),e.jsx("p",{className:"cedros-dashboard__text-muted",children:"Track deposits through the withdrawal pipeline: privacy period, ready for processing, and completed."}),e.jsxs("div",{className:"cedros-dashboard__pipeline",children:[e.jsx(Be.AdminPrivacyPeriodDeposits,{pageSize:t,refreshInterval:s}),e.jsx(Be.AdminWithdrawalQueue,{pageSize:t,refreshInterval:s}),e.jsx(Be.AdminWithdrawalHistory,{pageSize:t,refreshInterval:s})]})]})}var qe={},Yt,Dr;function nl(){return Dr||(Dr=1,Yt=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Yt}var Zt={},Pe={},Ur;function _e(){if(Ur)return Pe;Ur=1;let t;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Pe.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17},Pe.getSymbolTotalCodewords=function(o){return s[o]},Pe.getBCHDigit=function(r){let o=0;for(;r!==0;)o++,r>>>=1;return o},Pe.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');t=o},Pe.isKanjiModeEnabled=function(){return typeof t<"u"},Pe.toSJIS=function(o){return t(o)},Pe}var Xt={},Fr;function Gs(){return Fr||(Fr=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function s(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+r)}}t.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},t.from=function(o,n){if(t.isValid(o))return o;try{return s(o)}catch{return n}}})(Xt)),Xt}var Jt,Or;function ol(){if(Or)return Jt;Or=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(s){const r=Math.floor(s/8);return(this.buffer[r]>>>7-s%8&1)===1},put:function(s,r){for(let o=0;o<r;o++)this.putBit((s>>>r-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),s&&(this.buffer[r]|=128>>>this.length%8),this.length++}},Jt=t,Jt}var es,Wr;function al(){if(Wr)return es;Wr=1;function t(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return t.prototype.set=function(s,r,o,n){const a=s*this.size+r;this.data[a]=o,n&&(this.reservedBit[a]=!0)},t.prototype.get=function(s,r){return this.data[s*this.size+r]},t.prototype.xor=function(s,r,o){this.data[s*this.size+r]^=o},t.prototype.isReserved=function(s,r){return this.reservedBit[s*this.size+r]},es=t,es}var ts={},qr;function il(){return qr||(qr=1,(function(t){const s=_e().getSymbolSize;t.getRowColCoords=function(o){if(o===1)return[];const n=Math.floor(o/7)+2,a=s(o),l=a===145?26:Math.ceil((a-13)/(2*n-2))*2,i=[a-7];for(let c=1;c<n-1;c++)i[c]=i[c-1]-l;return i.push(6),i.reverse()},t.getPositions=function(o){const n=[],a=t.getRowColCoords(o),l=a.length;for(let i=0;i<l;i++)for(let c=0;c<l;c++)i===0&&c===0||i===0&&c===l-1||i===l-1&&c===0||n.push([a[i],a[c]]);return n}})(ts)),ts}var ss={},zr;function cl(){if(zr)return ss;zr=1;const t=_e().getSymbolSize,s=7;return ss.getPositions=function(o){const n=t(o);return[[0,0],[n-s,0],[0,n-s]]},ss}var rs={},Hr;function ll(){return Hr||(Hr=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};t.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},t.from=function(n){return t.isValid(n)?parseInt(n,10):void 0},t.getPenaltyN1=function(n){const a=n.size;let l=0,i=0,c=0,u=null,f=null;for(let h=0;h<a;h++){i=c=0,u=f=null;for(let p=0;p<a;p++){let b=n.get(h,p);b===u?i++:(i>=5&&(l+=s.N1+(i-5)),u=b,i=1),b=n.get(p,h),b===f?c++:(c>=5&&(l+=s.N1+(c-5)),f=b,c=1)}i>=5&&(l+=s.N1+(i-5)),c>=5&&(l+=s.N1+(c-5))}return l},t.getPenaltyN2=function(n){const a=n.size;let l=0;for(let i=0;i<a-1;i++)for(let c=0;c<a-1;c++){const u=n.get(i,c)+n.get(i,c+1)+n.get(i+1,c)+n.get(i+1,c+1);(u===4||u===0)&&l++}return l*s.N2},t.getPenaltyN3=function(n){const a=n.size;let l=0,i=0,c=0;for(let u=0;u<a;u++){i=c=0;for(let f=0;f<a;f++)i=i<<1&2047|n.get(u,f),f>=10&&(i===1488||i===93)&&l++,c=c<<1&2047|n.get(f,u),f>=10&&(c===1488||c===93)&&l++}return l*s.N3},t.getPenaltyN4=function(n){let a=0;const l=n.data.length;for(let c=0;c<l;c++)a+=n.data[c];return Math.abs(Math.ceil(a*100/l/5)-10)*s.N4};function r(o,n,a){switch(o){case t.Patterns.PATTERN000:return(n+a)%2===0;case t.Patterns.PATTERN001:return n%2===0;case t.Patterns.PATTERN010:return a%3===0;case t.Patterns.PATTERN011:return(n+a)%3===0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(a/3))%2===0;case t.Patterns.PATTERN101:return n*a%2+n*a%3===0;case t.Patterns.PATTERN110:return(n*a%2+n*a%3)%2===0;case t.Patterns.PATTERN111:return(n*a%3+(n+a)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}t.applyMask=function(n,a){const l=a.size;for(let i=0;i<l;i++)for(let c=0;c<l;c++)a.isReserved(c,i)||a.xor(c,i,r(n,c,i))},t.getBestMask=function(n,a){const l=Object.keys(t.Patterns).length;let i=0,c=1/0;for(let u=0;u<l;u++){a(u),t.applyMask(u,n);const f=t.getPenaltyN1(n)+t.getPenaltyN2(n)+t.getPenaltyN3(n)+t.getPenaltyN4(n);t.applyMask(u,n),f<c&&(c=f,i=u)}return i}})(rs)),rs}var lt={},Vr;function ko(){if(Vr)return lt;Vr=1;const t=Gs(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return lt.getBlocksCount=function(n,a){switch(a){case t.L:return s[(n-1)*4+0];case t.M:return s[(n-1)*4+1];case t.Q:return s[(n-1)*4+2];case t.H:return s[(n-1)*4+3];default:return}},lt.getTotalCodewordsCount=function(n,a){switch(a){case t.L:return r[(n-1)*4+0];case t.M:return r[(n-1)*4+1];case t.Q:return r[(n-1)*4+2];case t.H:return r[(n-1)*4+3];default:return}},lt}var ns={},Xe={},$r;function dl(){if($r)return Xe;$r=1;const t=new Uint8Array(512),s=new Uint8Array(256);return(function(){let o=1;for(let n=0;n<255;n++)t[n]=o,s[o]=n,o<<=1,o&256&&(o^=285);for(let n=255;n<512;n++)t[n]=t[n-255]})(),Xe.log=function(o){if(o<1)throw new Error("log("+o+")");return s[o]},Xe.exp=function(o){return t[o]},Xe.mul=function(o,n){return o===0||n===0?0:t[s[o]+s[n]]},Xe}var Gr;function ul(){return Gr||(Gr=1,(function(t){const s=dl();t.mul=function(o,n){const a=new Uint8Array(o.length+n.length-1);for(let l=0;l<o.length;l++)for(let i=0;i<n.length;i++)a[l+i]^=s.mul(o[l],n[i]);return a},t.mod=function(o,n){let a=new Uint8Array(o);for(;a.length-n.length>=0;){const l=a[0];for(let c=0;c<n.length;c++)a[c]^=s.mul(n[c],l);let i=0;for(;i<a.length&&a[i]===0;)i++;a=a.slice(i)}return a},t.generateECPolynomial=function(o){let n=new Uint8Array([1]);for(let a=0;a<o;a++)n=t.mul(n,new Uint8Array([1,s.exp(a)]));return n}})(ns)),ns}var os,Qr;function hl(){if(Qr)return os;Qr=1;const t=ul();function s(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(o){this.degree=o,this.genPoly=t.generateECPolynomial(this.degree)},s.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(o.length+this.degree);n.set(o);const a=t.mod(n,this.genPoly),l=this.degree-a.length;if(l>0){const i=new Uint8Array(this.degree);return i.set(a,l),i}return a},os=s,os}var as={},is={},cs={},Kr;function No(){return Kr||(Kr=1,cs.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),cs}var we={},Yr;function Co(){if(Yr)return we;Yr=1;const t="[0-9]+",s="[A-Z $%*+\\-./:]+";let r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";r=r.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
|
|
2050
|
-
]))+`;
|
|
2051
|
-
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),o.put(a,13)}},
|
|
2052
|
-
Suggested mode is: `+s.toString(
|
|
2049
|
+
`),me=12;function rc(t){if(t.length!==16)throw new Error(`Invalid share length: expected 16, got ${t.length}`);const r=lo(t,Se).split(" ");if(r.length!==me)throw new Error(`Unexpected word count: expected ${me}, got ${r.length}`);return r}function nc(t){if(t.length!==me)throw new Error(`Invalid word count: expected ${me}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!sr(s,Se))throw new Error("Invalid recovery phrase: checksum mismatch");const r=tr(s,Se);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return U.toShamirShare(r)}function oc(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const r=lo(t,Se).split(" ");if(r.length!==me)throw new Error(`Unexpected word count: expected ${me}, got ${r.length}`);return r}function ac(t){if(t.length!==me)throw new Error(`Invalid word count: expected ${me}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!sr(s,Se))throw new Error("Invalid recovery phrase: checksum mismatch");const r=tr(s,Se);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return U.toSeed(r)}function uo(t){if(t.length!==me)return!1;const s=t.join(" ").toLowerCase().trim();return sr(s,Se)}function gt(t){return Se.includes(t.toLowerCase().trim())}function ic(t,s=5){const r=t.toLowerCase().trim();return r.length===0?[]:Se.filter(o=>o.startsWith(r)).slice(0,s)}function cc(t){const s=[];for(let r=0;r<t.length;r+=4)s.push(t.slice(r,r+4));return s}function lc(t){return t.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(s=>s.trim()).filter(s=>s.length>0)}function dc({className:t="",variant:s="default",size:r="md",children:o,menuItems:n=[],hideSignOut:a=!1}){const{user:i,isAuthenticated:l,isLoading:c,openLoginModal:u,logout:m}=U.useAuth(),[h,p]=d.useState(!1),[b,w]=d.useState(-1),g=d.useRef(null),k=d.useRef(null),A=d.useMemo(()=>[...n,...a?[]:[{label:"Sign out",onClick:m}]],[n,a,m]);d.useEffect(()=>{if(!h)return;const f=x=>{g.current&&!g.current.contains(x.target)&&(p(!1),w(-1))},y=x=>{x.key==="Escape"&&(p(!1),w(-1),k.current?.focus())};return document.addEventListener("mousedown",f),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",y)}},[h]);const j=d.useCallback(f=>{if(!(!h||A.length===0))switch(f.key){case"ArrowDown":f.preventDefault(),w(y=>(y+1)%A.length);break;case"ArrowUp":f.preventDefault(),w(y=>(y-1+A.length)%A.length);break;case"Home":f.preventDefault(),w(0);break;case"End":f.preventDefault(),w(A.length-1);break;case"Enter":case" ":b>=0&&(f.preventDefault(),A[b].onClick(),p(!1),w(-1));break}},[h,b,A]),N=d.useCallback(()=>{A.length!==0&&(p(f=>!f),w(-1))},[A.length]),S={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},C={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(c)return e.jsx("button",{type:"button",className:`cedros-button ${C[s]} ${S[r]} ${t}`,disabled:!0,children:e.jsx(V.LoadingSpinner,{size:"sm"})});if(l&&i){const f=i.name||i.email||"User",y=Vs.sanitizeImageUrl(i.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:g,onKeyDown:j,children:[e.jsxs("button",{ref:k,type:"button",className:`cedros-button cedros-user-button ${S[r]} ${t}`,"aria-haspopup":"menu","aria-expanded":h,"aria-label":`User menu for ${f}`,onClick:N,children:[y?e.jsx("img",{src:y,alt:f,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(f[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:f})]}),h&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[n.map((x,v)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${b===v?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===v?0:-1,onClick:()=>{x.onClick(),p(!1)},children:[x.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:x.icon}),x.label]},v)),n.length>0&&!a&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!a&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${b===n.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===n.length?0:-1,onClick:()=>{m(),p(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${C[s]} ${S[r]} ${t}`,onClick:u,children:o||"Sign in"})}function Ft(){const{config:t}=B.useCedrosLogin(),[s,r]=d.useState(!1),[o,n]=d.useState(!1),[a,i]=d.useState(null),l=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]),{checkLimit:c,getRemainingAttempts:u}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),m=d.useCallback(async w=>{if(!Oe.validateEmail(w)){const g={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw i(g),g}try{c()}catch(g){const k={code:"RATE_LIMITED",message:g instanceof Error?g.message:"Too many attempts"};throw i(k),k}r(!0),i(null),n(!1);try{await l.post("/forgot-password",{email:w}),n(!0)}catch(g){const k=B.handleApiError(g,"Unable to send the reset email. Please try again.");throw i(k),k}finally{r(!1)}},[l,c]),h=d.useCallback(async(w,g)=>{r(!0),i(null),n(!1);try{await l.post("/reset-password",{token:w,newPassword:g}),n(!0)}catch(k){const A=B.handleApiError(k,"Unable to reset your password. Please try again.");throw i(A),A}finally{r(!1)}},[l]),p=d.useCallback(()=>i(null),[]),b=d.useCallback(()=>{i(null),n(!1),r(!1)},[]);return{forgotPassword:m,resetPassword:h,isLoading:s,isSuccess:o,error:a,clearError:p,reset:b,remainingAttempts:u()}}function uc(t){return typeof t=="object"&&t!==null&&"mfaRequired"in t&&t.mfaRequired===!0}function ho(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(!1),[i,l]=d.useState(null),c=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]),{checkLimit:u,getRemainingAttempts:m}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),h=d.useCallback(async g=>{if(!Oe.validateEmail(g)){const k={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw l(k),k}try{u()}catch(k){const A={code:"RATE_LIMITED",message:k instanceof Error?k.message:"Too many attempts"};throw l(A),A}o(!0),l(null),a(!1);try{await c.post("/instant-link",{email:g,referral:s?.getReferralCode?.()??void 0}),a(!0)}catch(k){const A=B.handleApiError(k,"Unable to send the sign-in link. Please try again.");throw l(A),A}finally{o(!1)}},[c,u]),p=d.useCallback(async g=>{if(!g||g.trim().length===0){const k={code:"VALIDATION_ERROR",message:"Invalid or missing sign-in link token"};throw l(k),k}o(!0),l(null),a(!1);try{const k=await c.post("/instant-link/verify",{token:g});return uc(k)||(t.callbacks?.onLoginSuccess?.(k.user,"email"),s?.handleLoginSuccess(k.user,k.tokens)),k}catch(k){const A=B.handleApiError(k,"Unable to verify the sign-in link. Please try again.");throw l(A),A}finally{o(!1)}},[c,t.callbacks,s]),b=d.useCallback(()=>l(null),[]),w=d.useCallback(()=>{l(null),a(!1),o(!1)},[]);return{sendInstantLink:h,verifyInstantLink:p,isLoading:r,isSuccess:n,error:i,clearError:b,reset:w,remainingAttempts:m()}}const hc={reset:{subtitle:"Enter your email address and we'll send you a link to reset your password.",button:"Send reset link",successMessage:t=>e.jsxs(e.Fragment,{children:["If an account exists for ",e.jsx("strong",{children:t}),", you will receive a password reset link shortly."]})},instantLink:{subtitle:"Enter your email and we'll send you a sign-in link. You can change your password in your account settings once signed in.",button:"Send sign-in link",successMessage:t=>e.jsxs(e.Fragment,{children:["We sent a sign-in link to ",e.jsx("strong",{children:t}),". Click the link to sign in."]})}};function mo({mode:t="reset",onSuccess:s,onCancel:r,className:o=""}){const[n,a]=d.useState(""),i=Ft(),l=ho(),c=d.useId(),u=t==="instantLink"?{submit:l.sendInstantLink,isLoading:l.isLoading,isSuccess:l.isSuccess,error:l.error,clearError:l.clearError}:{submit:i.forgotPassword,isLoading:i.isLoading,isSuccess:i.isSuccess,error:i.error,clearError:i.clearError},m=hc[t],h=async p=>{p.preventDefault();try{await u.submit(n),s?.()}catch{}};return u.isSuccess?e.jsxs("div",{className:`cedros-forgot-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Check your email"}),e.jsx("p",{className:"cedros-success-message",children:m.successMessage(n)}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:r,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${o}`,onSubmit:h,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Forgot password?"}),e.jsx("p",{className:"cedros-form-subtitle",children:m.subtitle})]}),e.jsx(J.ErrorMessage,{error:u.error,onDismiss:u.clearError}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:c,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:c,type:"email",className:"cedros-input",value:n,onChange:p=>a(p.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:u.isLoading})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:u.isLoading||!n,children:u.isLoading?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),"Sending..."]}):m.button}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:u.isLoading,children:"Back to login"})]})]})}const mc={loading:!1,loaded:!1,error:null,callbacks:[],load(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Apple Sign-In script loader cannot run in SSR")):this.loaded?Promise.resolve():this.loading?new Promise((t,s)=>{this.callbacks.push({resolve:t,reject:s})}):(this.loading=!0,new Promise((t,s)=>{this.callbacks.push({resolve:t,reject:s});const r=document.getElementById("apple-signin-script");if(r){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]):r.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]});return}const o=document.createElement("script");o.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",o.async=!0,o.defer=!0,o.id="apple-signin-script",o.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]},o.onerror=()=>{this.loading=!1,o.remove();const n=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(a=>a.reject(n)),this.callbacks=[]},document.head.appendChild(o)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function fo(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(!1),[i,l]=d.useState(null),[c,u]=d.useState(null),m=d.useRef(t),h=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]);d.useEffect(()=>{m.current=t},[t]),d.useEffect(()=>{if(!t.appleClientId)return;let g=!0;const k=()=>{if(g)try{window.AppleID?.auth?.init({clientId:t.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),g&&a(!0)}catch{g&&l({code:"SERVER_ERROR",message:"Unable to initialize Apple sign-in. Please refresh and try again."})}};return mc.load().then(()=>{g&&k()}).catch(()=>{g&&l({code:"SERVER_ERROR",message:"Unable to load Apple sign-in. Please refresh and try again."})}),()=>{g=!1}},[t.appleClientId]);const p=d.useCallback(async()=>{if(!t.appleClientId){const k={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw l(k),k}if(!n){const k={code:"VALIDATION_ERROR",message:"Apple sign-in is not ready yet. Please wait a moment and try again."};throw l(k),k}o(!0),l(null);let g;try{const k=crypto.getRandomValues(new Uint8Array(32)),A=Array.from(k,y=>y.toString(16).padStart(2,"0")).join(""),j=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(A)),N=Array.from(new Uint8Array(j),y=>y.toString(16).padStart(2,"0")).join("");window.AppleID.auth.init({clientId:t.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0,nonce:N});const S=await window.AppleID.auth.signIn();if(g=S.authorization?.id_token,!g)throw new Error("No ID token received from Apple");const C=S.user?.name?`${S.user.name.firstName||""} ${S.user.name.lastName||""}`.trim():void 0,f=await h.post("/apple",{idToken:g,name:C||void 0,nonce:A,referral:s?.getReferralCode?.()??void 0});return m.current.callbacks?.onLoginSuccess?.(f.user,"apple"),s?.handleLoginSuccess(f.user,f.tokens),o(!1),f}catch(k){if(k.error==="popup_closed_by_user"){const N={code:"SERVER_ERROR",message:"Apple sign-in was cancelled."};throw l(N),o(!1),N}const j=B.handleApiError(k,"Unable to sign in with Apple. Please try again.");throw j.code==="ACCOUNT_LINK_REQUIRED"&&g&&u(g),l(j),o(!1),j}},[t.appleClientId,n,h,s]),b=d.useCallback(()=>l(null),[]),w=d.useCallback(()=>u(null),[]);return{signIn:p,isLoading:r,isInitialized:n,error:i,clearError:b,pendingLinkIdToken:c,clearPendingLink:w}}function po(){if(typeof window>"u"||typeof navigator>"u")return!1;const t=navigator.userAgent.toLowerCase(),s=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(t)||s.includes("mac")||/macintosh/.test(t)||s==="macintel"&&navigator.maxTouchPoints>1)}function go({onSuccess:t,onError:s,className:r="",variant:o="default",size:n="md",disabled:a=!1,hideOnNonApple:i=!0}){const{signIn:l,isLoading:c,isInitialized:u}=fo(),[m]=d.useState(()=>po());if(i&&!m)return null;const h=async()=>{try{await l(),t?.()}catch(w){const g=w instanceof Error?w:new Error(String(w));s?.(g)}},p={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},b={default:"cedros-button-social",outline:"cedros-button-social-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${b[o]} ${p[n]} ${r}`,onClick:h,disabled:a||!u||c,"aria-label":"Sign in with Apple",children:[c?e.jsx(V.LoadingSpinner,{size:"sm"}):e.jsx("svg",{className:"cedros-button-icon",width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),e.jsx("span",{children:"Continue with Apple"})]})}function ae(t,s){if(!t)throw new Error(s)}function fc(t){return t.replace(/-/g,"+").replace(/_/g,"/")}function Mt(t){ae(typeof t=="string"&&t.length>0,"Expected base64url string");const s=fc(t),r=s+"=".repeat((4-s.length%4)%4),o=atob(r),n=new Uint8Array(o.length);for(let a=0;a<o.length;a++)n[a]=o.charCodeAt(a);return n.buffer}function Qe(t){const s=new Uint8Array(t);let r="";for(let n=0;n<s.length;n++)r+=String.fromCharCode(s[n]);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function wo(t){ae(typeof t=="object"&&t!==null,"Invalid credential descriptor");const s=t;return ae(typeof s.type=="string","Invalid credential descriptor type"),ae(typeof s.id=="string","Invalid credential descriptor id"),{type:s.type,id:Mt(s.id),transports:Array.isArray(s.transports)?s.transports:void 0}}function ns(t){ae(t&&typeof t=="object","Missing creation options");const s=t.publicKey;ae(s&&typeof s=="object","Missing creation options.publicKey"),ae(typeof s.challenge=="string","Missing creation challenge"),ae(typeof s.rp=="object"&&s.rp!==null,"Missing rp"),ae(typeof s.user=="object"&&s.user!==null,"Missing user");const r=s.rp,o=s.user;ae(typeof r.name=="string","Missing rp.name"),ae(typeof o.id=="string","Missing user.id"),ae(typeof o.name=="string","Missing user.name"),ae(typeof o.displayName=="string","Missing user.displayName");const n=Array.isArray(s.excludeCredentials)?s.excludeCredentials.map(wo):void 0,a=Array.isArray(s.pubKeyCredParams)?s.pubKeyCredParams.map(l=>({type:l.type,alg:l.alg})):[],i={challenge:Mt(s.challenge),rp:{name:r.name,id:typeof r.id=="string"?r.id:void 0},user:{id:Mt(o.id),name:o.name,displayName:o.displayName},pubKeyCredParams:a,timeout:typeof s.timeout=="number"?s.timeout:void 0,attestation:typeof s.attestation=="string"?s.attestation:void 0,authenticatorSelection:typeof s.authenticatorSelection=="object"&&s.authenticatorSelection!==null?s.authenticatorSelection:void 0,excludeCredentials:n,extensions:typeof s.extensions=="object"&&s.extensions!==null?s.extensions:void 0};return i.hints=["client-device"],i}function Wr(t){ae(t&&typeof t=="object","Missing request options");const s=t.publicKey;ae(s&&typeof s=="object","Missing request options.publicKey"),ae(typeof s.challenge=="string","Missing request challenge");const r=Array.isArray(s.allowCredentials)?s.allowCredentials.map(wo):void 0,o={challenge:Mt(s.challenge),rpId:typeof s.rpId=="string"?s.rpId:void 0,timeout:typeof s.timeout=="number"?s.timeout:void 0,userVerification:typeof s.userVerification=="string"?s.userVerification:void 0,allowCredentials:r,extensions:typeof s.extensions=="object"&&s.extensions!==null?s.extensions:void 0};return o.hints=["client-device"],o}function nt(t){const s=Qe(t.rawId),r=t.response,n={...{clientDataJSON:Qe(r.clientDataJSON)}};if("attestationObject"in r){const a=r;if(n.attestationObject=Qe(a.attestationObject),typeof a.getTransports=="function")try{n.transports=a.getTransports()}catch{}}if("authenticatorData"in r){const a=r;n.authenticatorData=Qe(a.authenticatorData),n.signature=Qe(a.signature),a.userHandle&&(n.userHandle=Qe(a.userHandle))}return{id:t.id,rawId:s,type:t.type,authenticatorAttachment:t.authenticatorAttachment??void 0,clientExtensionResults:t.getClientExtensionResults?.()??{},response:n}}function pc(){if(typeof window<"u"){const t=window.location?.hostname,s=t==="localhost"||t==="127.0.0.1"||t?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!s)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function gc(t){return typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&typeof t.code=="string"&&typeof t.message=="string"}function ot(t){if(!(t instanceof Error))return null;const s=t.name;return s==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:s==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:s==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function rr(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),i=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[s?.getAccessToken,t.serverUrl,t.requestTimeout,t.retryAttempts]),l=d.useCallback(()=>a(null),[]),c=pc(),u=d.useCallback(async k=>{if(!c){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/auth/options",{email:k?.email}),j=Wr(A.options),N=await navigator.credentials.get({publicKey:j});if(!N)throw new Error("Passkey authentication returned no credential");const S=await i.post("/webauthn/auth/verify",{challengeId:A.challengeId,credential:nt(N)});return t.callbacks?.onLoginSuccess?.(S.user,"webauthn"),s?.handleLoginSuccess(S.user,S.tokens),S}catch(A){const N=ot(A)??B.handleApiError(A,"Unable to sign in with passkey. Please try again.");throw a(N),N}finally{o(!1)}},[i,t.callbacks,s,c]),m=d.useCallback(async k=>{if(!c){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/register/options",{}),j=ns(A.options),N=await navigator.credentials.create({publicKey:j});if(!N)throw new Error("Passkey registration returned no credential");const S=await i.post("/webauthn/register/verify",{challengeId:A.challengeId,credential:nt(N),label:k?.label});if(!S.success)throw new Error("Passkey registration failed");return{credentialId:S.credentialId,label:S.label}}catch(A){const N=ot(A)??B.handleApiError(A,"Unable to register passkey. Please try again.");throw a(N),N}finally{o(!1)}},[i,c]),h=d.useCallback(async k=>{if(!c){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/signup/options",{}),j=ns(A.options),N=await navigator.credentials.create({publicKey:j});if(!N)throw new Error("Passkey signup returned no credential");const S=await i.post("/webauthn/signup/verify",{challengeId:A.challengeId,credential:nt(N),email:k?.email,name:k?.name,label:k?.label,referral:s?.getReferralCode?.()??void 0});return t.callbacks?.onLoginSuccess?.(S.user,"webauthn"),s?.handleLoginSuccess(S.user,S.tokens),S}catch(A){const N=ot(A)??B.handleApiError(A,"Unable to sign up with passkey. Please try again.");throw a(N),N}finally{o(!1)}},[i,t.callbacks,s,c]),p=d.useCallback(async()=>{if(!c){const j={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(j),j}o(!0),a(null);const k=typeof localStorage<"u"&&localStorage.getItem("cedros-passkey-registered")==="1",A=()=>{try{localStorage.setItem("cedros-passkey-registered","1")}catch{}};return k?b(A):w(A)},[i,t.callbacks,s,c]),b=d.useCallback(async k=>{try{const A=await i.post("/webauthn/auth/options",{}),j=Wr(A.options),N=await navigator.credentials.get({publicKey:j});if(!N)throw new Error("Passkey authentication returned no credential");const S=await i.post("/webauthn/auth/verify",{challengeId:A.challengeId,credential:nt(N)});return t.callbacks?.onLoginSuccess?.(S.user,"webauthn"),s?.handleLoginSuccess(S.user,S.tokens),k(),S}catch(A){if(A instanceof Error&&(A.name==="NotAllowedError"||A.name==="InvalidStateError"))return g(k);if(typeof A=="object"&&A!==null&&"isApiError"in A&&A.data?.code==="INVALID_CREDENTIALS"){const f={code:"INVALID_CREDENTIALS",message:"This passkey is not recognized. Please remove old passkeys for this site and try again, or sign in another way."};throw a(f),f}const C=ot(A)??B.handleApiError(A,"Unable to sign in with passkey. Please try again.");throw a(C),C}finally{o(!1)}},[i,t.callbacks,s]),w=d.useCallback(async k=>{try{return await g(k)}catch(A){if(A instanceof Error&&(A.name==="InvalidStateError"||A.name==="NotAllowedError"))return b(k);if(!gc(A)){const S=ot(A)??B.handleApiError(A,"Unable to create passkey. Please try again.");throw a(S),S}throw A}finally{o(!1)}},[i,t.callbacks,s]),g=d.useCallback(async k=>{const A=await i.post("/webauthn/signup/options",{}),j=ns(A.options),N=await navigator.credentials.create({publicKey:j});if(!N)throw new Error("Passkey signup returned no credential");const S=await i.post("/webauthn/signup/verify",{challengeId:A.challengeId,credential:nt(N),referral:s?.getReferralCode?.()??void 0});return t.callbacks?.onLoginSuccess?.(S.user,"webauthn"),s?.handleLoginSuccess(S.user,S.tokens),k(),S},[i,t.callbacks,s]);return{isSupported:c,isLoading:r,error:n,clearError:l,continueWithPasskey:p,authenticatePasskey:u,registerPasskey:m,signupWithPasskey:h}}function bo({onSuccess:t,className:s="",children:r,disabled:o}){const{continueWithPasskey:n,isLoading:a,isSupported:i}=rr(),l=o||!i||a;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${s}`,onClick:async()=>{try{await n(),t?.()}catch{}},disabled:l,"aria-disabled":l,children:[a?e.jsx(V.LoadingSpinner,{size:"sm"}):e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(wc,{})}),e.jsx("span",{children:r??"Continue with Passkey"})]})}function wc(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}const at=["login","register"];function Wt({onSuccess:t,className:s="",defaultTab:r="login"}){const{config:o,socialButtonOrder:n}=B.useCedrosLogin(),[a,i]=d.useState(r),[l,c]=d.useState("form"),[u,m]=d.useState(()=>Ze.detectSolanaWallets()),[h]=d.useState(()=>po());d.useEffect(()=>{const C=()=>m(Ze.detectSolanaWallets());return C(),window.addEventListener("load",C),window.addEventListener("focus",C),()=>{window.removeEventListener("load",C),window.removeEventListener("focus",C)}},[]);const p=o.forms?.forgotPassword?.mode??(o.features?.instantLink?"instantLink":"reset"),b=d.useCallback(C=>{const f=at.indexOf(a);let y=f;switch(C.key){case"ArrowLeft":case"ArrowUp":y=f===0?at.length-1:f-1;break;case"ArrowRight":case"ArrowDown":y=f===at.length-1?0:f+1;break;case"Home":y=0;break;case"End":y=at.length-1;break;default:return}C.preventDefault();const x=at[y];i(x),document.getElementById(`cedros-tab-${x}`)?.focus()},[a]),w=o.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},g=w.email!==!1,k=w.google!==!1&&o.googleClientId,A=w.apple!==!1&&o.appleClientId&&h,j=w.solana!==!1&&u,N=w.webauthn!==!1,S=g&&(k||A||j||N);return l==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${s}`,children:e.jsx(mo,{mode:p,onCancel:()=>c("form")})}):e.jsxs("div",{className:`cedros-login-form ${s}`,children:[(N||k||A||j)&&(()=>{const C={webauthn:N?e.jsx(bo,{onSuccess:t}):null,google:k?e.jsx(Hs.GoogleLoginButton,{onSuccess:t}):null,apple:A?e.jsx(go,{onSuccess:t}):null,solana:j?e.jsx(Ze.SolanaLoginButton,{onSuccess:t}):null},f=n??["webauthn","google","apple","solana"];return e.jsx("div",{className:"cedros-social-buttons",children:f.map(y=>{const x=C[y];return x?e.jsx(d.Fragment,{children:x},y):null})})})(),S&&e.jsx("div",{className:"cedros-divider",children:e.jsx("span",{children:"Or continue with"})}),g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-tabs",role:"tablist","aria-label":"Authentication method",children:[e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-login",className:`cedros-tab ${a==="login"?"cedros-tab-active":""}`,onClick:()=>i("login"),onKeyDown:b,"aria-selected":a==="login","aria-controls":"cedros-tabpanel-login",tabIndex:a==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${a==="register"?"cedros-tab-active":""}`,onClick:()=>i("register"),onKeyDown:b,"aria-selected":a==="register","aria-controls":"cedros-tabpanel-register",tabIndex:a==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${a}`,"aria-labelledby":`cedros-tab-${a}`,children:a==="login"?e.jsx(Q.EmailLoginForm,{onSuccess:t,onSwitchToRegister:()=>i("register"),onForgotPassword:()=>c("forgotPassword")}):e.jsx(Q.EmailRegisterForm,{onSuccess:t,onSwitchToLogin:()=>i("login")})})]})]})}class yo extends d.Component{constructor(s){super(s),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){this.setState({errorInfo:r}),console.error("[Cedros Login] Error caught by ErrorBoundary:",s),console.error("[Cedros Login] Component stack:",r.componentStack),this.props.onError?.(s,r)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:s,error:r,errorInfo:o}=this.state,{children:n,fallback:a,showDetails:i=!1}=this.props;return s?a||e.jsx("div",{className:"cedros-error-boundary",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"cedros-error-boundary-content",children:[e.jsxs("svg",{className:"cedros-error-boundary-icon",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("h2",{className:"cedros-error-boundary-title",children:"Something went wrong"}),e.jsx("p",{className:"cedros-error-boundary-message",children:"We encountered an unexpected error. Please try again."}),i&&r&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[r.toString(),o?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):n}}function bc({className:t="",title:s="Sign in to your account"}){const{isModalOpen:r,closeModal:o}=B.useCedrosLogin(),n=d.useRef(null),a=d.useRef(null),i=d.useRef(o);if(d.useEffect(()=>{i.current=o},[o]),d.useEffect(()=>{if(!r)return;a.current=document.activeElement,n.current?.focus();const c=m=>{if(m.key==="Escape"&&i.current(),m.key==="Tab"&&n.current){const h=n.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),p=h[0],b=h[h.length-1];m.shiftKey&&document.activeElement===p?(m.preventDefault(),b?.focus()):!m.shiftKey&&document.activeElement===b&&(m.preventDefault(),p?.focus())}};document.addEventListener("keydown",c);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",c),document.body.style.overflow=u,a.current instanceof HTMLElement&&a.current.focus()}},[r]),!r)return null;const l=c=>{c.target===c.currentTarget&&o()};return e.jsx("div",{className:`cedros-modal-backdrop ${t}`,onClick:l,role:"presentation",children:e.jsxs("div",{ref:n,className:"cedros-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cedros-modal-title",tabIndex:-1,children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"cedros-modal-title",className:"cedros-modal-title",children:s}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:o,"aria-label":"Close",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsx("div",{className:"cedros-modal-content",children:e.jsx(yo,{children:e.jsx(Wt,{onSuccess:o})})})]})})}function yc({token:t,onSuccess:s,onLoginClick:r,className:o=""}){const[n,a]=d.useState(""),[i,l]=d.useState(""),[c,u]=d.useState(null),{resetPassword:m,isLoading:h,isSuccess:p,error:b,clearError:w}=Ft(),g=n===i,k=c?.isValid&&g&&n.length>0,A=async j=>{if(j.preventDefault(),!!k)try{await m(t,n),s?.()}catch{}};return p?e.jsxs("div",{className:`cedros-reset-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Password reset successful"}),e.jsx("p",{className:"cedros-success-message",children:"Your password has been reset. You can now log in with your new password."}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:r,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${o}`,onSubmit:A,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Reset your password"}),e.jsx("p",{className:"cedros-form-subtitle",children:"Enter your new password below."})]}),e.jsx(J.ErrorMessage,{error:b,onDismiss:w}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(Q.PasswordInput,{label:"New password",value:n,onChange:j=>{a(j.target.value),u(Oe.validatePassword(j.target.value))},showStrengthMeter:!0,onValidationChange:u,disabled:h,autoComplete:"new-password",error:c&&!c.isValid?Object.values(c.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(Q.PasswordInput,{label:"Confirm password",value:i,onChange:j=>l(j.target.value),disabled:h,autoComplete:"new-password",error:i&&!g?"Passwords do not match":void 0})}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:h||!k,children:h?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:h,children:"Back to login"})]})]})}function qs({org:t,size:s="lg",className:r=""}){const o=Vs.sanitizeImageUrl(t.logoUrl),n=s==="lg"?"cedros-org-avatar-lg":"",a=["cedros-org-avatar",n,r].filter(Boolean).join(" "),i=["cedros-org-avatar-placeholder",n,r].filter(Boolean).join(" ");return o?e.jsx("img",{src:o,alt:t.name,className:a,referrerPolicy:"no-referrer"}):e.jsx("div",{className:i,children:t.name[0]?.toUpperCase()||"?"})}function xc({orgs:t,activeOrg:s,isLoading:r=!1,onSelect:o,onCreateClick:n,className:a="",placeholder:i="Select organization"}){const[l,c]=d.useState(!1),u=d.useRef(null);d.useEffect(()=>{const b=w=>{u.current&&!u.current.contains(w.target)&&c(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]),d.useEffect(()=>{const b=w=>{w.key==="Escape"&&c(!1)};if(l)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[l]);const m=d.useCallback(b=>{o(b),c(!1)},[o]),h=d.useCallback(()=>{c(!1),n?.()},[n]),p=d.useCallback(()=>{c(b=>!b)},[]);return r?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${a}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:u,className:`cedros-org-selector ${a}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:p,"aria-haspopup":"listbox","aria-expanded":l,children:[s?e.jsxs(e.Fragment,{children:[e.jsx(qs,{org:s,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:s.name}),e.jsx(Or,{role:s.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:i}),e.jsx(Ac,{isOpen:l})]}),l&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[t.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:t.map(b=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${b.id===s?.id?"cedros-org-selector-item-active":""}`,onClick:()=>m(b.id),role:"option","aria-selected":b.id===s?.id,children:[e.jsx(qs,{org:b,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:b.name}),e.jsx(Or,{role:b.membership.role}),b.id===s?.id&&e.jsx(vc,{})]})},b.id))}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:h,children:[e.jsx(jc,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function Or({role:t}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${t}`,children:t})}function Ac({isOpen:t}){return e.jsx("svg",{className:`cedros-org-chevron ${t?"cedros-org-chevron-open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function vc(){return e.jsx("svg",{className:"cedros-org-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function jc(){return e.jsx("svg",{className:"cedros-org-plus",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 3V13M3 8H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function kc(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Nc(){return e.jsx("svg",{className:"cedros-org-check",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 10L8 14L16 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Sc(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M10 4V16M4 10H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Cc({orgs:t,activeOrg:s,isLoading:r,onSelect:o,onCreateClick:n}){return r?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[t.length===0?e.jsx("div",{className:"cedros-org-switcher-empty",children:e.jsx("p",{children:"You don't belong to any organizations yet."})}):e.jsx("ul",{className:"cedros-org-switcher-list",children:t.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${a.id===s?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>o(a.id),children:[e.jsx(qs,{org:a}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:a.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",a.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${a.membership.role}`,children:a.membership.role}),a.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),a.id===s?.id&&e.jsx(Nc,{})]})},a.id))}),n&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:n,children:[e.jsx(Sc,{}),e.jsx("span",{children:"Create new organization"})]})]})}function Ec({isLoading:t,onSubmit:s,onCancel:r}){const[o,n]=d.useState(""),[a,i]=d.useState(""),[l,c]=d.useState(null),u=d.useCallback(h=>{n(h);const p=h.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);i(p)},[]),m=d.useCallback(async h=>{if(h.preventDefault(),c(null),!o.trim()){c("Organization name is required");return}if(!a.trim()){c("Organization slug is required");return}try{await s({name:o.trim(),slug:a.trim()})}catch(p){c(p.message||"Failed to create organization")}},[o,a,s]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:m,children:[l&&e.jsx(J.ErrorMessage,{error:l}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-name",className:"cedros-form-label",children:"Organization Name"}),e.jsx("input",{id:"org-name",type:"text",className:"cedros-form-input",value:o,onChange:h=>u(h.target.value),placeholder:"My Organization",maxLength:255,disabled:t,autoFocus:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-slug",className:"cedros-form-label",children:"URL Slug"}),e.jsxs("div",{className:"cedros-form-input-prefix",children:[e.jsx("span",{className:"cedros-form-prefix",children:"@"}),e.jsx("input",{id:"org-slug",type:"text",className:"cedros-form-input",value:a,onChange:h=>i(h.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:t})]}),e.jsx("span",{className:"cedros-form-hint",children:"Only lowercase letters, numbers, and hyphens"})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:r,disabled:t,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:t||!o.trim()||!a.trim(),children:t?e.jsx(V.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function _c({isOpen:t,onClose:s,orgs:r,activeOrg:o,isLoading:n=!1,error:a,onSelect:i,onCreate:l,className:c=""}){return t?e.jsx(Lc,{onClose:s,orgs:r,activeOrg:o,isLoading:n,error:a,onSelect:i,onCreate:l,className:c}):null}function Lc({onClose:t,orgs:s,activeOrg:r,isLoading:o=!1,error:n,onSelect:a,onCreate:i,className:l}){const[c,u]=d.useState("list"),m=d.useRef(null),h=d.useRef(null);d.useEffect(()=>(h.current=document.activeElement,m.current?.querySelector(".cedros-modal-close")?.focus(),()=>{h.current?.focus()}),[]),d.useEffect(()=>{const g=k=>{if(k.key==="Escape"){t();return}if(k.key==="Tab"&&m.current){const A=m.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),j=A[0],N=A[A.length-1];k.shiftKey?document.activeElement===j&&(k.preventDefault(),N?.focus()):document.activeElement===N&&(k.preventDefault(),j?.focus())}};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const p=d.useCallback(g=>{g.target===g.currentTarget&&t()},[t]),b=d.useCallback(g=>{a(g),t()},[a,t]),w=d.useCallback(async g=>{await i?.(g),t()},[i,t]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:p,children:e.jsxs("div",{ref:m,className:`cedros-modal cedros-org-switcher ${l}`,role:"dialog","aria-modal":"true","aria-labelledby":"org-switcher-title",children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"org-switcher-title",className:"cedros-modal-title",children:c==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:t,"aria-label":"Close",children:e.jsx(kc,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[n&&e.jsx(J.ErrorMessage,{error:n}),c==="list"?e.jsx(Cc,{orgs:s,activeOrg:r,isLoading:o,onSelect:b,onCreateClick:i?()=>u("create"):void 0}):e.jsx(Ec,{isLoading:o,onSubmit:w,onCancel:()=>u("list")})]})]})})}function xo({sessions:t,isLoading:s=!1,error:r,onRevokeAll:o,className:n=""}){const[a,i]=d.useState(!1),[l,c]=d.useState(!1),u=d.useRef(null),m=d.useMemo(()=>t.filter(p=>!p.isCurrent).length,[t]),h=d.useCallback(async()=>{if(!o)return;const p=t.filter(w=>!w.isCurrent).length;if(!(p===0||!window.confirm(`Are you sure you want to sign out of ${p} other device(s)? This will log you out everywhere except this browser.`))){i(!0),c(!1);try{await o(),c(!0),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{c(!1),u.current=null},3e3)}finally{i(!1)}}},[o,t]);return d.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),s&&t.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${n}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):r?e.jsx("div",{className:`cedros-session-list ${n}`,children:e.jsx(J.ErrorMessage,{error:r})}):t.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${n}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${n}`,children:[l&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(Ic,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:t.map(p=>e.jsx(Pc,{session:p},p.id))}),o&&m>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:h,disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${m} other device${m>1?"s":""}`})})]})}function Pc({session:t}){const s=Rc(t.userAgent),r=Bc(t.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${t.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(Mc,{userAgent:t.userAgent})}),e.jsxs("div",{className:"cedros-session-item-info",children:[e.jsxs("div",{className:"cedros-session-item-main",children:[e.jsxs("span",{className:"cedros-session-item-device",children:[s.browser," on ",s.os]}),t.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[t.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",t.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",Tc(t.createdAt)]}),r&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function Rc(t){if(!t)return{browser:"Unknown browser",os:"Unknown device"};let s="Unknown browser";t.includes("Chrome")&&!t.includes("Edg")?s="Chrome":t.includes("Safari")&&!t.includes("Chrome")?s="Safari":t.includes("Firefox")?s="Firefox":t.includes("Edg")&&(s="Edge");let r="Unknown device";return t.includes("Windows")?r="Windows":t.includes("Mac")?r="macOS":t.includes("Linux")?r="Linux":t.includes("iPhone")||t.includes("iPad")?r="iOS":t.includes("Android")&&(r="Android"),{browser:s,os:r}}function Tc(t){const s=new Date(t),o=new Date().getTime()-s.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),i=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n} minute${n>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:i<7?`${i} day${i>1?"s":""} ago`:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Bc(t){const s=new Date(t),r=new Date,o=3600*1e3;return s.getTime()-r.getTime()<o}function Mc({userAgent:t}){return t?.includes("iPhone")||t?.includes("iPad")||t?.includes("Android")?e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1",fill:"currentColor"})]}):e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 21H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M12 18V21",stroke:"currentColor",strokeWidth:"1.5"})]})}function Ic(){return e.jsx("svg",{className:"cedros-session-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ao({words:t,onConfirm:s,className:r=""}){const[o,n]=d.useState(!1),[a,i]=d.useState(!1),l=d.useRef(null),c=cc(t),u=d.useCallback(async()=>{try{await navigator.clipboard.writeText(t.join(" ")),n(!0),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>n(!1),2e3)}catch{}},[t]);d.useEffect(()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},[]);const m=d.useCallback(()=>{a&&s()},[a,s]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${r}`,children:[e.jsxs("div",{className:"cedros-recovery-header",children:[e.jsx("h3",{className:"cedros-recovery-title",children:"Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-warning",children:"Write down these 12 words in order and store them securely. This is the only way to recover your wallet if you lose access."})]}),e.jsx("div",{className:"cedros-recovery-grid",children:c.map((h,p)=>e.jsx("div",{className:"cedros-word-group",children:h.map((b,w)=>{const g=p*4+w+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[g,"."]}),e.jsx("span",{className:"cedros-word-text",children:b})]},g)})},p))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:u,children:o?"Copied!":"Copy to Clipboard"}),e.jsx("div",{className:"cedros-recovery-security",children:e.jsxs("div",{className:"cedros-warning-box",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M10 6v4m0 4h.01M19 10a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsxs("div",{className:"cedros-warning-content",children:[e.jsx("strong",{children:"Security Warning"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Never share this phrase with anyone"}),e.jsx("li",{children:"Store it offline in a secure location"}),e.jsx("li",{children:"Anyone with this phrase can access your wallet"}),e.jsx("li",{children:"Cedros cannot recover this phrase for you"})]})]})]})}),e.jsxs("div",{className:"cedros-recovery-confirm",children:[e.jsxs("label",{className:"cedros-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:h=>i(h.target.checked),className:"cedros-checkbox"}),e.jsx("span",{children:"I have written down and securely stored my recovery phrase"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:m,disabled:!a,children:"Continue"})]})]})}function vo({onSubmit:t,onCancel:s,isSubmitting:r=!1,error:o,className:n=""}){const[a,i]=d.useState(Array(me).fill("")),[l,c]=d.useState(null),[u,m]=d.useState([]),[h,p]=d.useState(null),b=d.useId(),w=d.useRef(null),g=d.useCallback((f,y)=>{const x=[...a];if(x[f]=y.toLowerCase().trim(),i(x),y.length>0){const v=ic(y,5);m(v)}else m([]);p(null)},[a]),k=d.useCallback(f=>{c(f),m([])},[]),A=d.useCallback(f=>{const y=a[f];y&&!gt(y)&&p(`Word ${f+1} is not in the wordlist`),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{l===f&&m([])},200)},[a,l]);d.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]);const j=d.useCallback(f=>{if(l!==null){const y=[...a];y[l]=f,i(y),m([]),document.querySelector(`[data-word-index="${l+1}"]`)?.focus()}},[l,a]),N=d.useCallback(f=>{const y=f.clipboardData.getData("text"),x=lc(y);x.length===me&&(f.preventDefault(),i(x),p(null))},[]),S=d.useCallback(f=>{if(f.preventDefault(),a.filter(v=>!v).length>0){p(`Please enter all ${me} words`);return}const x=a.map((v,_)=>({word:v,index:_+1})).filter(({word:v})=>!gt(v));if(x.length>0){p(`Invalid words: ${x.map(v=>`#${v.index}`).join(", ")}`);return}if(!uo(a)){p("Invalid recovery phrase - please check your words");return}t(a)},[a,t]),C=o||h;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${n}`,onSubmit:S,onPaste:N,children:[e.jsxs("div",{className:"cedros-recovery-input-header",children:[e.jsx("h3",{className:"cedros-recovery-input-title",children:"Enter Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-input-description",children:"Enter your 12-word recovery phrase. You can paste the entire phrase at once."})]}),e.jsx("div",{className:"cedros-word-inputs",children:Array.from({length:me},(f,y)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[y+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${a[y]&&!gt(a[y])?"cedros-word-invalid":a[y]&>(a[y])?"cedros-word-valid":""}`,value:a[y],onChange:x=>g(y,x.target.value),onFocus:()=>k(y),onBlur:()=>A(y),"data-word-index":y,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:r,"aria-label":`Word ${y+1}`})]},y))}),l!==null&&u.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${b}-suggestions`,children:u.map(f=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>j(f),role:"option",children:f},f))}),C&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:C}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:s,disabled:r,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:r,children:r?"Recovering...":"Recover Wallet"})]})]})}function Uc({capabilities:t,className:s=""}){if(t.allSupported)return null;const r=U.getMissingCapabilitiesMessage(t),o=U.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${s}`,role:"alert",children:[e.jsxs("div",{className:"cedros-warning-header",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsx("h3",{className:"cedros-warning-title",children:"Wallet Feature Unavailable"})]}),e.jsx("p",{className:"cedros-warning-message",children:r}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",o.browser," ",o.version,o.likelySupported?" (likely supported)":" (may not be supported)"]}),e.jsx("h4",{children:"Required Features"}),e.jsxs("ul",{className:"cedros-capability-list",children:[e.jsxs("li",{className:t.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",t.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:t.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",t.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:t.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",t.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:t.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",t.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:t.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",t.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:t.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",t.argon2?"Available":"Missing"]})]})]}),e.jsxs("div",{className:"cedros-capability-help",children:[e.jsx("h4",{children:"Recommended Browsers"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Chrome 116+ on Windows, macOS, or Android"}),e.jsx("li",{children:"Safari 17+ on macOS or iOS"}),e.jsx("li",{children:"Edge 116+ on Windows"})]}),e.jsx("p",{className:"cedros-capability-note",children:"A platform authenticator (Touch ID, Face ID, or Windows Hello) is required."})]})]})}const Dc=["share_c_only","full_seed","none"];function Fc(t){return t&&Dc.includes(t)?t:"share_c_only"}const Wc={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function jo(){const t=B.useCedrosLoginOptional(),[s,r]=d.useState(null),[o,n]=d.useState(!!t),[a,i]=d.useState(null),l=d.useMemo(()=>t?new B.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts}):null,[t]),c=d.useCallback(async()=>{if(l){n(!0),i(null);try{const u=await l.get("/discovery");u.wallet?r({enabled:u.wallet.enabled,recoveryMode:Fc(u.wallet.recoveryMode),unlockTtlSeconds:u.wallet.unlockTtlSeconds}):r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(u){const m=u instanceof Error?u.message:"Failed to fetch wallet config";i(m),r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{n(!1)}}},[l]);return d.useEffect(()=>{l&&c()},[l,c]),t?{walletEnabled:s?.enabled??!1,recoveryMode:s?.recoveryMode??"share_c_only",unlockTtlSeconds:s?.unlockTtlSeconds??900,isLoading:o,error:a,refetch:c}:Wc}function ko(){const{user:t}=B.useCedrosLogin(),{enroll:s}=U.useWalletMaterial(),{recoveryMode:r}=jo(),[o,n]=d.useState({step:"idle"}),[a,i]=d.useState(!1),l=d.useRef([]),c=d.useCallback(()=>{U.wipeAll(...l.current),l.current=[]},[]);d.useEffect(()=>()=>{c()},[c]);const u=d.useCallback(async(w,g,k,A)=>{n({step:"generating_seed"});const j=U.generateSeed();l.current.push(j),n({step:"splitting_shares"});const{shareA:N,shareB:S,shareC:C}=so(j);l.current.push(N,S,C),n({step:"encrypting_shares"});const f=await U.aesGcmEncryptToBase64(N,U.toEncryptionKey(g)),y=eo(j),x=to(y);n({step:"uploading"});const v={solanaPubkey:x,shareAAuthMethod:w,shareACiphertext:f.ciphertext,shareANonce:f.nonce,shareB:U.uint8ArrayToBase64(S)};if(w==="password"){if(!k)throw new Error("KDF salt required for password method");v.shareAKdfSalt=U.uint8ArrayToBase64(k),v.shareAKdfParams=U.DEFAULT_KDF_PARAMS}if(w==="passkey"&&A&&(v.prfSalt=A),await s(v),r==="none")c(),n({step:"complete",solanaPubkey:x});else{const _=r==="full_seed"?oc(j):rc(U.toShamirShare(C));n({step:"showing_recovery",recoveryPhrase:_,solanaPubkey:x})}},[s,r,c]),m=d.useCallback(async w=>{if(!t){n({step:"error",error:"User not authenticated"});return}i(!0),c();try{const g=U.generateArgon2Salt(),k=await Rn(w,g,U.DEFAULT_KDF_PARAMS);l.current.push(k),await u("password",k,g)}catch(g){n({step:"error",error:g instanceof Error?g.message:"Enrollment failed"})}finally{i(!1)}},[t,c,u]),h=d.useCallback(async()=>{if(!t){n({step:"error",error:"User not authenticated"});return}i(!0),c();try{const w=U.generatePrfSalt(),g=U.uint8ArrayToBase64(w);n({step:"encrypting_shares"});const A=(await U.authenticateWithDiscoverablePrf(g)).prfOutput;l.current.push(A);const j=await U.deriveKeyFromPrf(A,w);l.current.push(j),await u("passkey",j,void 0,g)}catch(w){n({step:"error",error:w instanceof Error?w.message:"Enrollment failed"})}finally{i(!1)}},[t,c,u]),p=d.useCallback(()=>{const w=o.solanaPubkey;c(),n({step:"complete",solanaPubkey:w})},[o.solanaPubkey,c]),b=d.useCallback(()=>{c(),n({step:"idle"}),i(!1)},[c]);return{state:o,startEnrollmentWithPassword:m,startEnrollmentWithPasskey:h,confirmRecoveryPhrase:p,cancel:b,isEnrolling:a}}function No(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),i=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s?.getAccessToken]);return{setPassword:d.useCallback(async c=>{o(!0),a(null);try{await i.post("/set-password",{password:c})}catch(u){const m=B.handleApiError(u,"Failed to set password");throw a(m),m}finally{o(!1)}},[i]),isLoading:r,error:n}}function Oc(t){return t.includes("email")?"password":t.includes("webauthn")?"passkey":"set-password"}function So({onComplete:t,onCancel:s,className:r=""}){const{user:o}=B.useCedrosLogin(),{state:n,startEnrollmentWithPassword:a,startEnrollmentWithPasskey:i,confirmRecoveryPhrase:l,cancel:c,isEnrolling:u}=ko(),{setPassword:m,isLoading:h}=No(),p=o?Oc(o.authMethods):"password",[b,w]=d.useState(""),[g,k]=d.useState(""),[A,j]=d.useState(null);d.useEffect(()=>{w(""),k(""),j(null)},[o?.id]);const N=d.useCallback(async v=>{v.preventDefault(),j(null),await a(b)},[b,a]),S=d.useCallback(async v=>{if(v.preventDefault(),b!==g){j("Passwords do not match");return}const _=Oe.validatePassword(b);if(!_.isValid){const E=Object.values(_.errors)[0];j(E??"Password does not meet requirements");return}j(null);try{await m(b),await a(b)}catch{}},[b,g,m,a]),C=d.useCallback(async()=>{await i()},[i]),f=d.useCallback(()=>{l(),n.solanaPubkey&&t?.(n.solanaPubkey)},[l,n.solanaPubkey,t]),y=d.useCallback(()=>{c(),s?.()},[c,s]),x=u||h;return n.step==="generating_seed"||n.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Generating secure wallet..."})]})}):n.step==="encrypting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Encrypting wallet shares..."})]})}):n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Saving wallet..."})]})}):n.step==="showing_recovery"&&n.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsx(Ao,{words:n.recoveryPhrase,onConfirm:f})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsxs("div",{className:"cedros-enrollment-complete",children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M16 24l6 6 12-12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{children:"Wallet Created!"}),e.jsxs("p",{className:"cedros-pubkey",children:[e.jsx("strong",{children:"Address:"})," ",n.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsxs("div",{className:"cedros-enrollment-error",children:[e.jsxs("svg",{className:"cedros-error-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 16v12m0 6h.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Enrollment Failed"}),e.jsx("p",{className:"cedros-error-message",children:n.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>c(),children:"Try Again"})]})]})}):e.jsxs("div",{className:`cedros-wallet-enrollment ${r}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),p==="password"&&e.jsx("p",{children:"Enter your account password to secure your wallet."}),p==="passkey"&&e.jsx("p",{children:"Authenticate with your passkey to secure your wallet."}),p==="set-password"&&e.jsx("p",{children:"Set a password for your account to secure your wallet."})]}),p==="password"&&e.jsxs("form",{onSubmit:N,className:"cedros-enrollment-form",children:[e.jsx(Q.PasswordInput,{label:"Account Password",value:b,onChange:v=>w(v.target.value),disabled:x,required:!0,placeholder:"Enter your account password"}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||!b,children:x?"Creating...":"Continue"})]})]}),p==="passkey"&&e.jsxs("div",{className:"cedros-enrollment-form",children:[e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:C,disabled:x,children:x?"Creating...":"Use Passkey"})]})]}),p==="set-password"&&e.jsxs("form",{onSubmit:S,className:"cedros-enrollment-form",children:[e.jsx(Q.PasswordInput,{label:"New Password",value:b,onChange:v=>w(v.target.value),showStrengthMeter:!0,disabled:x,required:!0,minLength:8,placeholder:"Choose a strong password"}),e.jsx(Q.PasswordInput,{label:"Confirm Password",value:g,onChange:v=>k(v.target.value),error:A??void 0,disabled:x,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will also be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||!b||!g,children:x?"Creating...":"Continue"})]})]})]})}function Co(){const{user:t}=B.useCedrosLogin(),{signTransaction:s}=U.useWalletMaterial(),[r,o]=d.useState(!1),[n,a]=d.useState(null),i=d.useCallback(async(c,u)=>{if(!t){const m="User not authenticated";throw a(m),new Error(m)}o(!0),a(null);try{const m={transaction:U.uint8ArrayToBase64(c),...u?{credential:U.toCredentialRequest(u)}:{}},h=await s(m);return U.base64ToUint8Array(h.signature)}catch(m){const h=m instanceof Error?m.message:"Signing failed";throw a(h),m}finally{o(!1)}},[t,s]),l=d.useCallback(()=>a(null),[]);return{signTransaction:i,isSigning:r,error:n,clearError:l}}function Eo(){const{getMaterial:t}=U.useWalletMaterial(),[s,r]=d.useState(!1),[o,n]=d.useState(null),a=d.useCallback(async()=>{r(!0),n(null);try{const l=await t();if(!l)throw new Error("No wallet enrolled");if(l.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!l.prfSalt)throw new Error("No PRF salt configured for wallet");const c=await U.authenticateWithDiscoverablePrf(l.prfSalt);try{return{type:"prfOutput",prfOutput:U.uint8ArrayToBase64(c.prfOutput)}}finally{c.prfOutput.fill(0)}}catch(l){const c=l instanceof Error?l.message:"Passkey authentication failed";return n(c),null}finally{r(!1)}},[t]),i=d.useCallback(()=>n(null),[]);return{getPasskeyCredential:a,isAuthenticating:s,error:o,clearError:i}}function _o({mode:t,isLoading:s=!1,error:r,onPrompt:o,onRetry:n,onCancel:a,title:i,description:l,className:c=""}){const u=d.useCallback(()=>{s||o?.()},[s,o]),m=d.useCallback(()=>{n?.()},[n]),h=t==="register"?"Set Up Passkey":"Verify with Passkey",p=t==="register"?"Create a passkey to securely encrypt your wallet on this device. You will use your fingerprint, face, or device PIN.":"Use your passkey to unlock your wallet. You will be prompted for biometric verification.";return e.jsxs("div",{className:`cedros-passkey-prompt ${c}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:s?e.jsx(zc,{}):r?e.jsx(Vc,{}):e.jsx(qc,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:i??h}),e.jsx("p",{className:"cedros-passkey-description",children:l??p}),r&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:r})}),e.jsx("div",{className:"cedros-passkey-actions",children:r?e.jsxs(e.Fragment,{children:[n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:m,children:"Try Again"}),a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:u,disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):t==="register"?"Create Passkey":"Use Passkey"}),a&&!s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]})}),s&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",t==="register"?"create":"verify"," your passkey."]})]})}function qc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}function zc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Vc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4M12 16h.01"})]})}function Lo({onUnlock:t,onCancel:s,showCancel:r=!0,authMethod:o,className:n=""}){B.useCedrosLogin();const{unlock:a,getMaterial:i,isLoading:l}=U.useWalletMaterial(),{getPasskeyCredential:c,isAuthenticating:u}=Eo(),[m,h]=d.useState("idle"),[p,b]=d.useState(o??null),[w,g]=d.useState(""),[k,A]=d.useState(null);d.useEffect(()=>{o!==void 0&&b(o)},[o]);const j=p==="password",N=p==="passkey",S=d.useCallback(async()=>{if(h("credential"),A(null),!p)try{const E=await i();E?b(E.shareAAuthMethod):(A("No wallet enrolled"),h("error"))}catch(E){A(E instanceof Error?E.message:"Failed to get wallet info"),h("error")}},[p,i]),C=d.useCallback(async E=>{E.preventDefault(),A(null),h("unlocking");try{let P;if(j)P={type:"password",password:w};else throw new Error("Invalid auth method");await a(P),h("unlocked"),t?.()}catch(P){A(P instanceof Error?P.message:"Failed to unlock wallet"),h("error")}},[j,w,a,t]),f=d.useCallback(async()=>{A(null),h("unlocking");try{const E=await c();if(!E){h("credential");return}await a(E),h("unlocked"),t?.()}catch(E){A(E instanceof Error?E.message:"Failed to unlock wallet"),h("error")}},[c,a,t]),y=d.useCallback(()=>{g(""),h("idle"),A(null),s?.()},[s]),x=d.useCallback(()=>{g(""),h("credential"),A(null)},[]),v=l||u,_=()=>{switch(m){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Hc,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Locked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Unlock your wallet to sign transactions."}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,children:"Unlock Wallet"})]});case"credential":return j?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:C,children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Enter Password"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Enter your wallet password to unlock."}),e.jsx(Q.PasswordInput,{label:"Password",value:w,onChange:E=>g(E.target.value),disabled:v,autoComplete:"current-password",error:k??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:v||w.length===0,children:v?"Unlocking...":"Unlock"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:v,children:"Cancel"})]})]}):N?e.jsxs("div",{className:"cedros-wallet-unlock-passkey",children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Verify with Passkey"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Use your passkey to unlock your wallet."}),e.jsx(_o,{mode:"authenticate",isLoading:v,error:k??void 0,onPrompt:f,onRetry:f,onCancel:r?y:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(V.LoadingSpinner,{size:"xl"}),e.jsx("p",{children:"Loading wallet info..."})]});case"unlocking":return e.jsxs("div",{className:"cedros-wallet-unlock-progress",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(V.LoadingSpinner,{size:"xl"})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlocking Wallet"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Verifying your credentials..."})]});case"unlocked":return e.jsxs("div",{className:"cedros-wallet-unlock-success",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx($c,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Unlocked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Your wallet is ready to sign transactions."})]});case"error":return e.jsxs("div",{className:"cedros-wallet-unlock-error",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Kc,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:k??"Failed to unlock wallet. Please try again."}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,children:"Try Again"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${n}`,children:_()})}function Hc(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"10",y:"22",width:"28",height:"20",rx:"4",stroke:"currentColor",strokeWidth:"2",fill:"var(--cedros-muted, #f3f4f6)"}),e.jsx("path",{d:"M16 22V16a8 8 0 1 1 16 0v6",stroke:"currentColor",strokeWidth:"2",fill:"none"}),e.jsx("circle",{cx:"24",cy:"32",r:"3",fill:"currentColor"})]})}function $c(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function Kc(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function Po(){const{recover:t,getShareBForRecovery:s}=U.useWalletMaterial(),{recoveryMode:r}=jo(),[o,n]=d.useState({step:"idle"}),[a,i]=d.useState(!1),l=d.useRef([]),c=d.useCallback(()=>{U.wipeAll(...l.current),l.current=[]},[]);d.useEffect(()=>()=>{c()},[c]);const u=d.useCallback(async(h,p,b)=>{i(!0),c();try{if(n({step:"validating"}),!uo(h))throw new Error("Invalid recovery phrase. Please check your words.");let w;if(r==="share_c_only"){const x=nc(h);l.current.push(x);const v=U.uint8ArrayToBase64(x),_=await s({shareC:v}),E=U.base64ToUint8Array(_.shareB);l.current.push(E),w=Vi(U.toShamirShare(E),U.toShamirShare(x)),l.current.push(w)}else w=ac(h),l.current.push(w);const g=eo(w),k=to(g),{shareA:A,shareB:j}=so(w);l.current.push(A,j),n({step:"encrypting"});let N,S,C;if(p==="passkey"){const x=U.generatePrfSalt();C=U.uint8ArrayToBase64(x);const v=await U.authenticateWithDiscoverablePrf(C);l.current.push(v.prfOutput),N=await U.deriveKeyFromPrf(v.prfOutput,x),l.current.push(N)}else S=U.generateArgon2Salt(),N=await Rn(b,S,U.DEFAULT_KDF_PARAMS),l.current.push(N);const f=await U.aesGcmEncryptToBase64(A,U.toEncryptionKey(N));n({step:"uploading"});const y={solanaPubkey:k,shareAAuthMethod:p,shareACiphertext:f.ciphertext,shareANonce:f.nonce,shareB:U.uint8ArrayToBase64(j)};p==="password"&&(y.shareAKdfSalt=U.uint8ArrayToBase64(S),y.shareAKdfParams=U.DEFAULT_KDF_PARAMS),p==="passkey"&&(y.prfSalt=C),await t(y),c(),n({step:"complete"})}catch(w){c(),n({step:"error",error:w instanceof Error?w.message:"Recovery failed"})}finally{i(!1)}},[t,s,r,c]),m=d.useCallback(()=>{c(),n({step:"idle"}),i(!1)},[c]);return{state:o,startRecovery:u,cancel:m,isRecovering:a}}function Ro({onComplete:t,onCancel:s,className:r="",defaultAuthMethod:o="password"}){const{state:n,startRecovery:a,cancel:i,isRecovering:l}=Po(),[c,u]=d.useState([]),[m,h]=d.useState(!1),[p,b]=d.useState(o),[w,g]=d.useState(""),[k,A]=d.useState(""),[j,N]=d.useState(null),S=d.useCallback(v=>{u(v),h(!0)},[]),C=d.useCallback(async v=>{if(v.preventDefault(),N(null),p!=="passkey"){if(w!==k){N("Passwords do not match");return}if(p==="password"&&w.length<8){N("Password must be at least 8 characters");return}}await a(c,p,w)},[c,p,w,k,a]),f=d.useCallback(()=>{i(),u([]),h(!1),g(""),A(""),s?.()},[i,s]),y=d.useCallback(()=>{h(!1),g(""),A("")},[]),x=d.useCallback(()=>{t?.()},[t]);return n.step==="validating"||n.step==="encrypting"||n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Gc,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[n.step==="validating"&&"Validating Recovery Phrase",n.step==="encrypting"&&"Encrypting Wallet",n.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[n.step==="validating"&&"Checking your recovery phrase...",n.step==="encrypting"&&"Securing your wallet with new encryption...",n.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Qc,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Wallet Recovered"}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:["Your wallet has been successfully recovered and secured with your new"," ",p==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,children:"Done"})})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Yc,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recovery Failed"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:n.error??"An error occurred during recovery. Please try again."}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:f,children:"Start Over"})})]})}):m?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:C,children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Set New Security"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Choose how to secure your recovered wallet."})]}),e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:p==="password",onChange:()=>b("password"),disabled:l}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:p==="passkey",onChange:()=>b("passkey"),disabled:l}),e.jsx("span",{children:"Passkey"})]})]}),p==="password"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password",className:"cedros-label",children:"New Password"}),e.jsx("input",{id:"recovery-password",type:"password",className:"cedros-input",value:w,onChange:v=>g(v.target.value),disabled:l,minLength:8,placeholder:"Enter a strong password"})]}),e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password-confirm",className:"cedros-label",children:"Confirm Password"}),e.jsx("input",{id:"recovery-password-confirm",type:"password",className:"cedros-input",value:k,onChange:v=>A(v.target.value),disabled:l,"aria-invalid":j?"true":void 0,placeholder:"Confirm your password"}),j&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:j})]})]}),p==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(Zc,{}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-wallet-recovery-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:l,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:l||p!=="passkey"&&(w.length===0||k.length===0),children:l?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-phrase",children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recover Your Wallet"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Enter your 12-word recovery phrase to restore your wallet."})]}),e.jsx(vo,{onSubmit:S,onCancel:f,isSubmitting:!1})]})})}function Gc(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-muted, #e5e7eb)",strokeWidth:"3",fill:"none"}),e.jsx("path",{d:"M24 4a20 20 0 0 1 20 20",stroke:"var(--cedros-primary, #6366f1)",strokeWidth:"3",strokeLinecap:"round",fill:"none"})]})}function Qc(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function Yc(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function Zc(){return e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function To({address:t,label:s="Wallet Address",showCopy:r=!0,showExplorerLink:o=!0,allowReveal:n=!0,className:a=""}){const i=B.useCedrosLoginOptional(),[l,c]=d.useState(!1),[u,m]=d.useState(null),[h,p]=d.useState(!1),b=d.useRef(null),w=i?.config.solana?.network??"mainnet-beta",g=d.useMemo(()=>{const N=`https://explorer.solana.com/address/${t}`;return w==="mainnet-beta"?N:`${N}?cluster=${encodeURIComponent(w)}`},[t,w]),k=n&&t.length>18,A=d.useMemo(()=>!k||h?t:`${t.slice(0,8)}...${t.slice(-8)}`,[t,k,h]),j=d.useCallback(async()=>{try{m(null),await navigator.clipboard.writeText(t),c(!0),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{c(!1),b.current=null},2e3)}catch(N){c(!1),m(N instanceof Error?N.message:"Copy failed")}},[t]);return d.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${a}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:s}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[k&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>p(N=>!N),"aria-label":h?"Hide full wallet address":"Show full wallet address",children:h?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10.7 10.7a3 3 0 0 0 4.24 4.24",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9.88 5.09A10.94 10.94 0 0 1 12 5c5 0 9.27 3.11 11 7-0.55 1.23-1.32 2.33-2.27 3.25",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.61 6.61C4.4 7.9 2.74 9.8 1 12c1.73 3.89 6 7 11 7 1.14 0 2.25-0.16 3.3-0.46",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),o&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:g,target:"_blank",rel:"noreferrer",children:"Explorer"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:j,"aria-label":"Copy wallet address",children:l?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:t,children:A}),u&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:u})]})}function Bo({status:t,publicKey:s,onLock:r,onEnroll:o,onUnlock:n,onRecover:a,showActions:i=!0,compact:l=!1,className:c=""}){const u=t!==void 0,m=U.useWallet(),h=u?t:m.status,p=u?s??null:m.solanaPubkey,b=u?null:m.error,w=u?()=>{}:m.refresh,g=u?()=>{}:m.clearError,k=Xc(h,b);return l?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${c}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${k.color}`,title:k.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:k.label}),p&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:p,children:Jc(p)})]}):e.jsxs("div",{className:`cedros-wallet-status ${c}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${k.color}`,children:e.jsx(el,{status:h})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:k.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:k.description})]})]}),p&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(To,{address:p})}),b&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:g,children:"Dismiss"})]}),i&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[h==="not_enrolled"&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:o,children:"Create Wallet"}),h==="enrolled_locked"&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:n,children:"Unlock Wallet"}),(h==="not_enrolled"||h==="error")&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:a,children:"Recover Wallet"}),h==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:w,children:"Retry"})]})]})}function Xc(t,s){switch(t){case"loading":return{label:"Loading",title:"Checking Wallet",description:"Verifying wallet status...",color:"loading"};case"not_enrolled":return{label:"Not Set Up",title:"No Wallet",description:"Create a wallet to start using Solana.",color:"muted"};case"enrolled_locked":return{label:"Locked",title:"Wallet Locked",description:"Unlock your wallet to sign transactions.",color:"warning"};case"enrolled_unlocked":case"unlocked":return{label:"Ready",title:"Wallet Ready",description:"Your wallet is unlocked and ready to use.",color:"success"};case"error":default:return{label:"Error",title:"Wallet Error",description:s??"An error occurred with your wallet.",color:"error"}}}function Jc(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function el({status:t}){switch(t){case"loading":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"not_enrolled":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]});case"enrolled_locked":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});case"enrolled_unlocked":case"unlocked":return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});case"error":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4M12 17h.01"})]});default:return null}}function tl({className:t="",showActions:s=!0}){const r=U.useWallet(),[o,n]=d.useState("status"),a=d.useMemo(()=>{switch(o){case"enroll":return{title:"Create Wallet",description:"Set up your embedded wallet."};case"unlock":return{title:"Unlock Wallet",description:"Unlock to sign transactions."};case"recover_intro":case"recover":return{title:"Recover Wallet",description:"Restore access using your recovery phrase."};case"status":default:return null}},[o]),i=d.useCallback(()=>n("status"),[]),l=d.useCallback(async()=>{n("status"),await r.refresh()},[r]),c=d.useCallback(async()=>{n("status"),await r.refresh()},[r]),u=d.useCallback(async()=>{n("status"),await r.refresh()},[r]);return e.jsxs("div",{className:`cedros-wallet-manager ${t}`,children:[o!=="status"&&a&&e.jsxs("div",{className:"cedros-wallet-manager-header",children:[e.jsxs("div",{className:"cedros-wallet-manager-header-text",children:[e.jsx("h3",{className:"cedros-wallet-manager-title",children:a.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:a.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:i,children:"Back"})]}),o==="status"&&e.jsx(Bo,{onEnroll:()=>n("enroll"),onUnlock:()=>n("unlock"),onRecover:()=>n("recover_intro"),showActions:s}),o==="enroll"&&e.jsx(So,{onComplete:()=>{l()},onCancel:i}),o==="unlock"&&e.jsx(Lo,{onUnlock:()=>{c()},onCancel:i}),o==="recover_intro"&&e.jsx("div",{className:"cedros-wallet-manager-intro",children:e.jsxs("div",{className:"cedros-wallet-manager-intro-card",children:[e.jsx("h4",{className:"cedros-wallet-manager-intro-title",children:"Before you start"}),e.jsxs("ul",{className:"cedros-wallet-manager-intro-list",children:[e.jsx("li",{children:"You’ll need your 12-word recovery phrase."}),e.jsx("li",{children:"You’ll set a new password or passkey for this wallet."}),e.jsx("li",{children:"If you’re on a shared device, avoid copying the phrase into other apps."})]}),e.jsxs("div",{className:"cedros-wallet-manager-intro-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>n("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:i,children:"Cancel"})]})]})}),o==="recover"&&e.jsx(Ro,{onComplete:()=>{u()},onCancel:i})]})}function sl({showDescriptions:t=!0,className:s="",onSave:r}){const{settings:o,isLoading:n,isUpdating:a,error:i,fetchSettings:l,updateSettings:c}=Cn.useSystemSettings(),[u,m]=d.useState({}),[h,p]=d.useState(null),[b,w]=d.useState(!1);d.useEffect(()=>{l()},[l]),d.useEffect(()=>{if(b){const C=setTimeout(()=>w(!1),3e3);return()=>clearTimeout(C)}},[b]);const g=d.useCallback((C,f)=>{m(y=>({...y,[C]:f})),p(null),w(!1)},[]),k=d.useCallback(async()=>{const C=Object.entries(u).map(([f,y])=>({key:f,value:y}));if(C.length!==0)try{await c(C),m({}),p(null),w(!0),r?.()}catch(f){p(f instanceof Error?f.message:"Failed to save settings")}},[u,c,r]),A=d.useCallback(()=>{m({}),p(null),w(!1)},[]),j=Object.keys(u).length>0,N=Object.keys(u).length;if(n&&Object.keys(o).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(i)return e.jsx("div",{className:`cedros-system-settings ${s}`,children:e.jsx(J.ErrorMessage,{error:i.message})});const S=Object.keys(o).sort();return S.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${s}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${s}`,children:[h&&e.jsx(J.ErrorMessage,{error:h}),b&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),S.map(C=>e.jsx(rl,{category:C,settings:o[C],edits:u,showDescription:t,onChange:g},C)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[j&&e.jsxs("span",{className:"cedros-settings-change-count",children:[N," unsaved change",N!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:A,disabled:!j||a,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:k,disabled:!j||a,children:a?e.jsx(V.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}const qr=Object.keys(Ne.SETTING_METADATA);function rl({category:t,settings:s,edits:r,showDescription:o,onChange:n}){const a=Ne.CATEGORY_METADATA[t]||{label:t,description:"",icon:""},i=d.useMemo(()=>[...s].sort((l,c)=>{const u=qr.indexOf(l.key),m=qr.indexOf(c.key);return(u===-1?1/0:u)-(m===-1?1/0:m)}),[s]);return e.jsxs("section",{className:"cedros-settings-section",children:[e.jsxs("div",{className:"cedros-settings-section-header",children:[e.jsx("span",{className:"cedros-settings-section-icon",children:a.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:a.label}),o&&a.description&&e.jsx("p",{className:"cedros-settings-section-description",children:a.description})]})]}),e.jsx(Ne.SettingsSection,{settings:i,edits:r,onChange:n})]})}class nl{client;constructor(s,r,o){this.client=new B.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o})}async getStatus(){try{return await this.client.get("/setup/status")}catch(s){throw B.handleApiError(s,"Failed to check setup status")}}async createFirstAdmin(s){try{return await this.client.post("/setup/admin",s)}catch(r){throw B.handleApiError(r,"Failed to create admin account")}}}function nr(){const{config:t}=B.useCedrosLogin(),[s,r]=d.useState(null),[o,n]=d.useState(!1),[a,i]=d.useState(!1),[l,c]=d.useState(null),u=d.useRef(0),m=d.useMemo(()=>new nl(t.serverUrl,t.requestTimeout,t.retryAttempts),[t.serverUrl,t.requestTimeout,t.retryAttempts]),h=d.useRef(m);h.current=m;const p=d.useCallback(async()=>{n(!0),c(null);const w=++u.current;try{const g=await h.current.getStatus();if(w!==u.current)return;r(g)}catch(g){if(w!==u.current)return;c(g instanceof Error?g:new Error("Failed to check setup status"))}finally{w===u.current&&n(!1)}},[]),b=d.useCallback(async w=>{i(!0),c(null);try{const g=await h.current.createFirstAdmin(w);return await p(),g}catch(g){const k=g instanceof Error?g:new Error("Failed to create admin");throw c(k),k}finally{i(!1)}},[p]);return{status:s,isLoading:o,isCreating:a,error:l,checkStatus:p,createAdmin:b}}const ol=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,zr=8;function al(t){const s={};return t.email?ol.test(t.email)||(s.email="Invalid email format"):s.email="Email is required",t.password?t.password.length<zr&&(s.password=`Password must be at least ${zr} characters`):s.password="Password is required",t.confirmPassword?t.password!==t.confirmPassword&&(s.confirmPassword="Passwords do not match"):s.confirmPassword="Please confirm your password",s}function Mo({onComplete:t,className:s=""}){const{status:r,isLoading:o,isCreating:n,error:a,checkStatus:i,createAdmin:l}=nr(),[c,u]=d.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[m,h]=d.useState({}),[p,b]=d.useState(!1);d.useEffect(()=>{i()},[i]);const w=d.useCallback(k=>A=>{u(j=>({...j,[k]:A.target.value})),h(j=>({...j,[k]:void 0}))},[]),g=d.useCallback(async k=>{k.preventDefault();const A=al(c);if(Object.keys(A).length>0){h(A);return}try{await l({email:c.email,password:c.password,name:c.name||void 0,orgName:c.orgName||void 0}),b(!0),t?.()}catch{}},[c,l,t]);return o?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):r&&!r.needsSetup?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Setup Complete"}),e.jsx("p",{className:"cedros-setup__text",children:"An admin account already exists. You can now log in."})]})}):p?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Admin Account Created"}),e.jsx("p",{className:"cedros-setup__text",children:"Your admin account has been created successfully. You can now log in with your credentials."})]})}):e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__container",children:[e.jsxs("div",{className:"cedros-setup__header",children:[e.jsx("div",{className:"cedros-setup__logo",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),e.jsx("h1",{className:"cedros-setup__title",children:"Welcome to Cedros"}),e.jsx("p",{className:"cedros-setup__subtitle",children:"Let's set up your admin account to get started."})]}),e.jsxs("form",{className:"cedros-setup__form",onSubmit:g,children:[a&&e.jsx(J.ErrorMessage,{error:a.message}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-email",className:"cedros-setup__label",children:["Email Address ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-email",type:"email",className:`cedros-setup__input ${m.email?"cedros-setup__input--error":""}`,value:c.email,onChange:w("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:n}),m.email&&e.jsx("span",{className:"cedros-setup__error",children:m.email})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-name",className:"cedros-setup__label",children:"Display Name"}),e.jsx("input",{id:"setup-name",type:"text",className:"cedros-setup__input",value:c.name,onChange:w("name"),placeholder:"Admin",autoComplete:"name",disabled:n})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-org-name",className:"cedros-setup__label",children:"Organization Name"}),e.jsx("input",{id:"setup-org-name",type:"text",className:"cedros-setup__input",value:c.orgName,onChange:w("orgName"),placeholder:"My Organization",disabled:n})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-password",className:"cedros-setup__label",children:["Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-password",type:"password",className:`cedros-setup__input ${m.password?"cedros-setup__input--error":""}`,value:c.password,onChange:w("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:n}),m.password&&e.jsx("span",{className:"cedros-setup__error",children:m.password})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-confirm-password",className:"cedros-setup__label",children:["Confirm Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-confirm-password",type:"password",className:`cedros-setup__input ${m.confirmPassword?"cedros-setup__input--error":""}`,value:c.confirmPassword,onChange:w("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:n}),m.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:m.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Creating Account..."})]}):"Create Admin Account"})]}),e.jsxs("div",{className:"cedros-setup__footer",children:[e.jsx("p",{className:"cedros-setup__note",children:"This will be the first administrator account for your installation."}),r?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",r.serverVersion]})]})]})})}const il=["security","rate_limit"];function cl({className:t}){return e.jsx(Gs.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:il,className:t})}const Vr=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function ll({className:t}){const{settings:s,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:i,fetchSettings:l,handleChange:c,getEffectiveValue:u}=Ne.useSettingsAutosave(),[m,h]=d.useState("email");d.useEffect(()=>{l()},[l]);const p=Vr.find(S=>S.id===m),b=p?.category??"",g=(u("email_provider")||"custom")==="custom",k=u("email_smtp_host"),A=!g||k!=null&&k!=="",j=d.useMemo(()=>{const S=s[b]??[];if(m!=="email")return S;const C=g?jt.ALL_EMAIL_FIELDS:jt.SIMPLIFIED_EMAIL_FIELDS;return S.filter(f=>C.includes(f.key)).sort((f,y)=>C.indexOf(f.key)-C.indexOf(y.key))},[s,b,m,g]),N=(S,C)=>{if(c(S,C),S==="email_provider"&&C!=="custom"){const f=jt.PROVIDER_SMTP_HOSTS[C];f&&(c("email_smtp_host",f),c("email_smtp_port","587"),c("email_smtp_tls","true"))}};return o&&Object.keys(s).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t??""}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):i?e.jsx("div",{className:`cedros-system-settings ${t??""}`,children:e.jsx(J.ErrorMessage,{error:i.message})}):e.jsxs("div",{className:`cedros-system-settings ${t??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Auth Messages"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure email delivery for verification emails, password resets, and instant link login. Webhook notifications can be sent to Discord or Slack."})]}),e.jsx(Ne.AutosaveStatus,{status:n,error:a})]}),m==="email"&&!A&&e.jsx("div",{className:"cedros-settings-warning-banner",children:"Email features (verification, password reset, instant link) are disabled until SMTP is configured. Select a provider or enter custom SMTP settings below."}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:Vr.map(S=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${m===S.id?"cedros-admin-tab-active":""}`,onClick:()=>h(S.id),"aria-selected":m===S.id,role:"tab",children:S.label},S.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:j.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",p?.label??"this section","."]})}):e.jsx(Ne.SettingsSection,{settings:j,edits:r,onChange:m==="email"?N:c})})]})}const os=["image_storage_enabled","image_storage_provider","image_storage_bucket","image_storage_region","image_storage_endpoint","image_storage_access_key","image_storage_secret_key","image_storage_cdn_url"],Hr={nyc3:"https://nyc3.digitaloceanspaces.com",ams3:"https://ams3.digitaloceanspaces.com",sgp1:"https://sgp1.digitaloceanspaces.com",sfo3:"https://sfo3.digitaloceanspaces.com",fra1:"https://fra1.digitaloceanspaces.com",syd1:"https://syd1.digitaloceanspaces.com"};function dl({className:t}){const{settings:s,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:i,fetchSettings:l,handleChange:c,getEffectiveValue:u}=Ne.useSettingsAutosave();d.useEffect(()=>{l()},[l]);const m=d.useMemo(()=>(s.image_storage??[]).filter(b=>os.includes(b.key)).sort((b,w)=>os.indexOf(b.key)-os.indexOf(w.key)),[s]),h=(p,b)=>{if(c(p,b),p==="image_storage_provider")if(b==="digitalocean"){const w=u("image_storage_region")||"nyc3";c("image_storage_region",w),c("image_storage_endpoint",Hr[w]??`https://${w}.digitaloceanspaces.com`)}else b==="s3"&&c("image_storage_endpoint","");p==="image_storage_region"&&u("image_storage_provider")==="digitalocean"&&c("image_storage_endpoint",Hr[b]??`https://${b}.digitaloceanspaces.com`)};return o&&Object.keys(s).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t??""}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):i?e.jsx("div",{className:`cedros-system-settings ${t??""}`,children:e.jsx(J.ErrorMessage,{error:i.message})}):e.jsxs("div",{className:`cedros-system-settings ${t??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Image Storage"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure S3-compatible object storage for user avatars and images. Supports AWS S3, DigitalOcean Spaces, and other S3-compatible providers."})]}),e.jsx(Ne.AutosaveStatus,{status:n,error:a})]}),m.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsx("p",{children:"No image storage settings found."})}):e.jsx(Ne.SettingsSection,{settings:m,edits:r,onChange:h})]})}function ul(t,s){return s.toUpperCase()==="SOL"?`${(t/1e9).toFixed(4)} SOL`:`${t} ${s}`}function $r(t){return t.length<=16?t:`${t.slice(0,8)}...${t.slice(-6)}`}function hl(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const ml=["all","pending","completed","failed","cancelled"];function fl(){const{config:t,_internal:s}=B.useCedrosLogin(),r=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),[o,n]=d.useState("all"),[a,i]=d.useState(0),l=20,[c,u]=d.useState(null),[m,h]=d.useState(!1),[p,b]=d.useState(null),[w,g]=d.useState(null),[k,A]=d.useState(null),j=d.useCallback(async()=>{h(!0),b(null);try{const f=new URLSearchParams;o!=="all"&&f.set("status",o),f.set("limit",String(l)),f.set("offset",String(a*l));const y=await r.get(`/admin/referral-payouts/list?${f.toString()}`);u(y)}catch(f){const y=B.handleApiError(f,"Failed to load payouts");b(y.message)}finally{h(!1)}},[r,o,a]);d.useEffect(()=>{j()},[j]);const N=d.useCallback(async f=>{A(f),g(null);try{const y=await r.post(`/admin/referral-payouts/${f}/process`,{});g(`Processed: ${y.txSignature}`),j()}catch(y){const x=B.handleApiError(y,"Failed to process payout");g(x.message)}finally{A(null)}},[r,j]),S=d.useCallback(async f=>{A(f),g(null);try{await r.post(`/admin/referral-payouts/${f}/cancel`,{}),g("Payout cancelled."),j()}catch(y){const x=B.handleApiError(y,"Failed to cancel payout");g(x.message)}finally{A(null)}},[r,j]),C=c?Math.ceil(c.total/l):0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__filter-bar",children:[e.jsxs("label",{className:"cedros-admin-referral-payouts__filter-label",children:["Status:",e.jsx("select",{value:o,onChange:f=>{n(f.target.value),i(0)},className:"cedros-admin-referral-payouts__filter-select",children:ml.map(f=>e.jsx("option",{value:f,children:f.charAt(0).toUpperCase()+f.slice(1)},f))})]}),c&&e.jsxs("span",{className:"cedros-admin-referral-payouts__filter-count",children:[c.total," total"]})]}),w&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--info",children:w}),m&&!c&&e.jsxs("div",{className:"cedros-admin-referral-payouts--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading payouts..."})]}),p&&e.jsxs("div",{className:"cedros-admin-referral-payouts--error",children:[e.jsx("p",{className:"cedros-admin-error",children:p}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:j,children:"Retry"})]}),c&&c.payouts.length===0&&e.jsx("div",{className:"cedros-admin-empty-message",children:"No payouts found."}),c&&c.payouts.length>0&&e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"All referral payouts",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Referrer"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Trigger"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"TX / Error"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Actions"})]}),c.payouts.map(f=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:hl(f.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:f.referrerEmail||f.referrerName||$r(f.referrerId)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:f.triggerType}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:ul(f.amount,f.currency)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-referral-payouts__status cedros-admin-referral-payouts__status--${f.status}`,children:f.status})}),e.jsxs("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:[f.txSignature&&$r(f.txSignature),f.errorMessage&&e.jsx("span",{className:"cedros-admin-list-td-muted",title:f.errorMessage,children:f.errorMessage.slice(0,40)})]}),e.jsxs("div",{className:"cedros-admin-list-td",role:"cell",children:[(f.status==="pending"||f.status==="failed")&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-xs",onClick:()=>N(f.id),disabled:k!==null,children:k===f.id?"...":"Process"}),f.status==="pending"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",onClick:()=>S(f.id),disabled:k!==null,style:{marginLeft:4},children:"Cancel"})]})]},f.id))]}),C>1&&e.jsxs("div",{className:"cedros-admin-referral-payouts__pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",disabled:a===0,onClick:()=>i(f=>f-1),children:"Previous"}),e.jsxs("span",{className:"cedros-admin-referral-payouts__page-info",children:["Page ",a+1," of ",C]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",disabled:a>=C-1,onClick:()=>i(f=>f+1),children:"Next"})]})]})}function as(t,s){return s.toUpperCase()==="SOL"?`${(t/1e9).toFixed(4)} SOL`:`${t} ${s}`}function Kr(t){return t.length<=16?t:`${t.slice(0,8)}...${t.slice(-6)}`}function Io({className:t=""}){const[s,r]=d.useState("summary");return e.jsxs("div",{className:`cedros-admin-referral-payouts ${t}`,children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__tabs",children:[e.jsx("button",{type:"button",className:`cedros-admin-referral-payouts__tab ${s==="summary"?"cedros-admin-referral-payouts__tab--active":""}`,onClick:()=>r("summary"),children:"Summary"}),e.jsx("button",{type:"button",className:`cedros-admin-referral-payouts__tab ${s==="all"?"cedros-admin-referral-payouts__tab--active":""}`,onClick:()=>r("all"),children:"All Payouts"})]}),s==="summary"?e.jsx(pl,{}):e.jsx(fl,{})]})}function pl(){const{config:t,_internal:s}=B.useCedrosLogin(),r=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),[o,n]=d.useState(null),[a,i]=d.useState(!1),[l,c]=d.useState(null),[u,m]=d.useState(!1),[h,p]=d.useState(null),[b,w]=d.useState(null),[g,k]=d.useState(!1),[A,j]=d.useState(null),[N,S]=d.useState(null),[C,f]=d.useState(null),y=d.useCallback(async()=>{i(!0),c(null);try{const M=await r.get("/admin/referral-payouts");n(M)}catch(M){const F=B.handleApiError(M,"Failed to load referral payouts");c(F.message)}finally{i(!1)}},[r]),x=d.useCallback(async()=>{try{const F=(await r.get("/admin/settings"))?.payout_auto_enabled?.value;f(F==="true")}catch{}},[r]);d.useEffect(()=>{y(),x()},[y,x]);const v=d.useCallback(async()=>{m(!0),p(null),w(null);try{const M=await r.post("/admin/referral-payouts/process",{});p(M),y()}catch(M){const F=B.handleApiError(M,"Failed to process payouts");w(F.message)}finally{m(!1)}},[r,y]),_=d.useCallback(async()=>{k(!0),j(null),S(null);try{const M=await r.post("/admin/referral-payouts/retry-failed",{});j(M),y()}catch(M){const F=B.handleApiError(M,"Failed to retry failed payouts");S(F.message)}finally{k(!1)}},[r,y]),E=u||g;if(a&&!o)return e.jsxs("div",{className:"cedros-admin-referral-payouts cedros-admin-referral-payouts--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading referral payouts..."})]});if(l)return e.jsxs("div",{className:"cedros-admin-referral-payouts cedros-admin-referral-payouts--error",children:[e.jsx("p",{className:"cedros-admin-error",children:l}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:y,children:"Retry"})]});const P=o?.referrers??[],L=o?.total??0,R=P[0]?.currency??"SOL",T=P.reduce((M,F)=>M+F.totalPendingAmount,0);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__header",children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__summary",children:[e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Pending Referrers"}),e.jsx("span",{className:"cedros-admin-stat-value",children:L})]}),L>0&&e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Total Pending Amount"}),e.jsx("span",{className:"cedros-admin-stat-value",children:as(T,R)})]}),C!==null&&e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Auto-Processing"}),e.jsx("span",{className:"cedros-admin-stat-value",children:C?"ON":"OFF"})]})]}),e.jsxs("div",{className:"cedros-admin-referral-payouts__actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:v,disabled:E||L===0,"aria-busy":u,children:u?"Processing...":"Process All Payouts"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:_,disabled:E,"aria-busy":g,children:g?"Retrying...":"Retry Failed"})]})]}),h&&e.jsxs("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--success",children:["Processed ",h.processed," payout(s) totalling"," ",as(h.totalAmount,R),".",h.failed>0&&` ${h.failed} failed.`,h.skippedNoWallet>0&&` ${h.skippedNoWallet} skipped (no wallet).`]}),b&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--error",children:b}),A&&e.jsxs("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--success",children:["Reset ",A.resetCount," failed payout(s) for retry."]}),N&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--error",children:N}),P.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No pending referral payouts."}):e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Pending referral payouts",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Referrer ID"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Wallet Address"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Pending Referrals"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Total Amount"})]}),P.map(M=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:e.jsx("button",{type:"button",className:"cedros-admin-user-uuid-link",onClick:()=>navigator.clipboard?.writeText(M.referrerId),title:`Click to copy: ${M.referrerId}`,children:Kr(M.referrerId)})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:M.payoutWalletAddress?e.jsx("button",{type:"button",className:"cedros-admin-user-uuid-link cedros-admin-list-td-mono",onClick:()=>navigator.clipboard?.writeText(M.payoutWalletAddress),title:`Click to copy: ${M.payoutWalletAddress}`,children:Kr(M.payoutWalletAddress)}):e.jsx("span",{className:"cedros-admin-list-td-muted",children:"No wallet"})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:M.pendingCount}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:as(M.totalPendingAmount,M.currency)})]},M.referrerId))]})]})}const le={users:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),members:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),deposits:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}),e.jsx("path",{d:"M12 18V6"})]}),withdrawals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}),e.jsx("path",{d:"M9 22v-4h6v4"}),e.jsx("path",{d:"M8 6h.01"}),e.jsx("path",{d:"M16 6h.01"}),e.jsx("path",{d:"M12 6h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M8 14h.01"})]}),wallet:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),mail:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),coins:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6"}),e.jsx("path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18"}),e.jsx("path",{d:"M7 6h1v4"}),e.jsx("path",{d:"m16.71 13.88.7.71-2.82 2.82"})]}),server:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),image:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]}),referrals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})},gl=[{id:"users",label:"Users",icon:le.users},{id:"team",label:"Team",icon:le.members},{id:"referrals",label:"Referrals",icon:le.referrals},{id:"deposits",label:"Deposits",icon:le.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:le.withdrawals,requiredFeature:"credits"},{id:"settings-auth",label:"Authentication",icon:le.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:le.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:le.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:le.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-server",label:"Auth Server",icon:le.server,group:"Configuration"},{id:"settings-images",label:"Image Storage",icon:le.image,group:"Configuration"}];function wl({title:t="Dashboard",sections:s=["users","team","referrals","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server","settings-images"],defaultSection:r="users",refreshInterval:o=0,pageSize:n=20,onSectionChange:a,onSettingsClick:i,onLogoutClick:l,className:c=""}){const[u,m]=d.useState(r),[h,p]=d.useState(!0),{user:b,logout:w}=B.useCedrosLogin(),{activeOrg:g,role:k,isLoading:A,fetchOrgs:j,hasPermission:N}=$s.useOrgs(),{status:S,isLoading:C,checkStatus:f}=nr(),{features:y,isLoading:x}=de.useServerFeatures(),{canAccess:v}=de.useDashboardPermissions(),_=d.useCallback(T=>{m(T),a?.(T)},[a]),E=gl.filter(T=>!(!s.includes(T.id)||T.requiredFeature&&!y[T.requiredFeature]||!v(T.id))),P=E.find(T=>T.id===u),L=!P&&!x;return d.useEffect(()=>{j(),f()},[j,f]),d.useEffect(()=>{L&&E.length>0&&m("users")},[L,E.length]),!C&&S?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${c}`,children:e.jsx(Mo,{onComplete:()=>f()})}):(A||C||x)&&!g?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${c}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):u==="team"&&!g?e.jsx("div",{className:`cedros-admin cedros-dashboard ${c}`,children:e.jsx(J.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${c}`,children:[e.jsxs("aside",{className:"cedros-dashboard__sidebar",children:[e.jsx("div",{className:"cedros-dashboard__sidebar-header",children:e.jsxs("div",{className:"cedros-dashboard__logo",children:[le.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:t})]})}),e.jsxs("nav",{className:"cedros-dashboard__nav",children:[e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsx("span",{className:"cedros-dashboard__nav-label",children:"Menu"}),E.filter(T=>!T.group).map(T=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===T.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>_(T.id),"aria-current":u===T.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:T.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:T.label})]},T.id))]}),E.some(T=>T.group==="Configuration")&&e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsxs("button",{type:"button",className:"cedros-dashboard__nav-label cedros-dashboard__nav-label--collapsible",onClick:()=>p(!h),"aria-expanded":h,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${h?"cedros-dashboard__nav-chevron--expanded":""}`,children:le.chevronRight})]}),h&&E.filter(T=>T.group==="Configuration").map(T=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===T.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>_(T.id),"aria-current":u===T.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:T.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:T.label})]},T.id))]})]}),b&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(Me.ProfileDropdown,{name:b.name,email:b.email,picture:b.picture,onSettings:i,onLogout:l??w})})]}),e.jsxs("main",{className:"cedros-dashboard__main",children:[e.jsx("header",{className:"cedros-dashboard__header",children:e.jsxs("div",{className:"cedros-dashboard__breadcrumb",children:[e.jsx("span",{className:"cedros-dashboard__breadcrumb-root",children:t}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:le.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:P?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[u==="users"&&e.jsx(bl,{pageSize:n,currentUserId:b?.id}),u==="team"&&g&&e.jsx(yl,{orgId:g.id,currentUserId:b?.id,hasPermission:N,role:k}),u==="referrals"&&e.jsx(vl,{}),u==="deposits"&&e.jsx(xl,{pageSize:n,refreshInterval:o}),u==="withdrawals"&&e.jsx(Al,{pageSize:n,refreshInterval:o}),u==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(_n.AuthenticationSettings,{})}),u==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ln.EmbeddedWalletSettings,{})}),u==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(ll,{})}),u==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ks.CreditSystemSettings,{})}),u==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Pn.ServerSettings,{})}),u==="settings-images"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(dl,{})})]})]})]})}function bl({pageSize:t,currentUserId:s}){const[r,o]=d.useState(null),{statsItems:n,isLoading:a,error:i,refresh:l}=lt.useUsersStatsSummary();return r?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(lt.AdminUserDetail,{userId:r.id,currentUserId:s,onBack:()=>o(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(En.StatsBar,{stats:n,isLoading:a,onRefresh:l}),i&&e.jsx("p",{className:"cedros-admin-error-inline",children:i}),e.jsx(lt.AdminUserList,{pageSize:t,currentUserId:s,onUserClick:c=>o(c)})]})}function yl({orgId:t,currentUserId:s,hasPermission:r,role:o}){const[n,a]=d.useState("members"),{members:i,isLoading:l,error:c,fetchMembers:u,updateMemberRole:m,removeMember:h}=de.useMembers(t),{invites:p,isLoading:b,error:w,fetchInvites:g,createInvite:k,cancelInvite:A,resendInvite:j}=de.useInvites(t);d.useEffect(()=>{u(),g()},[u,g]);const N=r("invite:create"),S=r("invite:cancel"),C=p.length,f=i.reduce((_,E)=>(_[E.role]=(_[E.role]??0)+1,_),{}),y=f.owner??0,x=f.admin??0,v=f.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(En.StatsBar,{stats:[{label:"Owners",value:y},{label:"Admins",value:x},{label:"Members",value:v},{label:"Pending Invites",value:C}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="members"?"cedros-admin-tab-active":""}`,onClick:()=>a("members"),"aria-selected":n==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${n==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>a("invites"),"aria-selected":n==="invites",role:"tab",children:["Pending Invites",C>0&&` (${C})`]}),o==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>a("permissions"),"aria-selected":n==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[n==="members"&&e.jsx(de.MemberList,{members:i,currentUserId:s,isLoading:l,error:c?.message,canManage:r("member:remove"),canChangeRoles:r("member:role_change"),onUpdateRole:m,onRemove:h}),n==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[N&&e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx("div",{className:"cedros-dashboard__section-header",children:e.jsx("h3",{className:"cedros-dashboard__section-title",children:"Send Invitation"})}),e.jsx(de.InviteForm,{onSubmit:k,isLoading:b,error:w?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(de.InviteList,{invites:p,isLoading:b,error:w?.message,canManage:S||N,onCancel:S?A:void 0,onResend:N?j:void 0})})]}),n==="permissions"&&o==="owner"&&e.jsx(de.PermissionsSection,{userRole:o})]})]})}function xl({pageSize:t,refreshInterval:s}){const[r,o]=d.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(Ct.AdminDepositStats,{refreshInterval:s}),e.jsxs("div",{className:"cedros-dashboard__deposits-list",children:[e.jsx("div",{className:"cedros-dashboard__toolbar",children:e.jsxs("div",{className:"cedros-dashboard__filter",children:[e.jsx("label",{className:"cedros-dashboard__filter-label",htmlFor:"status-filter",children:"Status"}),e.jsxs("select",{id:"status-filter",className:"cedros-dashboard__select",value:r,onChange:n=>o(n.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"detected",children:"Detected"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"withdrawn",children:"Withdrawn"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})}),e.jsx(Ct.AdminDepositList,{statusFilter:r||void 0,pageSize:t,refreshInterval:s})]})]})}function Al({pageSize:t,refreshInterval:s}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(Be.AdminWithdrawalStats,{refreshInterval:s}),e.jsx("p",{className:"cedros-dashboard__text-muted",children:"Track deposits through the withdrawal pipeline: privacy period, ready for processing, and completed."}),e.jsxs("div",{className:"cedros-dashboard__pipeline",children:[e.jsx(Be.AdminPrivacyPeriodDeposits,{pageSize:t,refreshInterval:s}),e.jsx(Be.AdminWithdrawalQueue,{pageSize:t,refreshInterval:s}),e.jsx(Be.AdminWithdrawalHistory,{pageSize:t,refreshInterval:s})]})]})}function vl(){return e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Io,{})})}var Ye={},is,Gr;function jl(){return Gr||(Gr=1,is=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),is}var cs={},Te={},Qr;function qe(){if(Qr)return Te;Qr=1;let t;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Te.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17},Te.getSymbolTotalCodewords=function(o){return s[o]},Te.getBCHDigit=function(r){let o=0;for(;r!==0;)o++,r>>>=1;return o},Te.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');t=o},Te.isKanjiModeEnabled=function(){return typeof t<"u"},Te.toSJIS=function(o){return t(o)},Te}var ls={},Yr;function or(){return Yr||(Yr=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function s(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+r)}}t.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},t.from=function(o,n){if(t.isValid(o))return o;try{return s(o)}catch{return n}}})(ls)),ls}var ds,Zr;function kl(){if(Zr)return ds;Zr=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(s){const r=Math.floor(s/8);return(this.buffer[r]>>>7-s%8&1)===1},put:function(s,r){for(let o=0;o<r;o++)this.putBit((s>>>r-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),s&&(this.buffer[r]|=128>>>this.length%8),this.length++}},ds=t,ds}var us,Xr;function Nl(){if(Xr)return us;Xr=1;function t(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return t.prototype.set=function(s,r,o,n){const a=s*this.size+r;this.data[a]=o,n&&(this.reservedBit[a]=!0)},t.prototype.get=function(s,r){return this.data[s*this.size+r]},t.prototype.xor=function(s,r,o){this.data[s*this.size+r]^=o},t.prototype.isReserved=function(s,r){return this.reservedBit[s*this.size+r]},us=t,us}var hs={},Jr;function Sl(){return Jr||(Jr=1,(function(t){const s=qe().getSymbolSize;t.getRowColCoords=function(o){if(o===1)return[];const n=Math.floor(o/7)+2,a=s(o),i=a===145?26:Math.ceil((a-13)/(2*n-2))*2,l=[a-7];for(let c=1;c<n-1;c++)l[c]=l[c-1]-i;return l.push(6),l.reverse()},t.getPositions=function(o){const n=[],a=t.getRowColCoords(o),i=a.length;for(let l=0;l<i;l++)for(let c=0;c<i;c++)l===0&&c===0||l===0&&c===i-1||l===i-1&&c===0||n.push([a[l],a[c]]);return n}})(hs)),hs}var ms={},en;function Cl(){if(en)return ms;en=1;const t=qe().getSymbolSize,s=7;return ms.getPositions=function(o){const n=t(o);return[[0,0],[n-s,0],[0,n-s]]},ms}var fs={},tn;function El(){return tn||(tn=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};t.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},t.from=function(n){return t.isValid(n)?parseInt(n,10):void 0},t.getPenaltyN1=function(n){const a=n.size;let i=0,l=0,c=0,u=null,m=null;for(let h=0;h<a;h++){l=c=0,u=m=null;for(let p=0;p<a;p++){let b=n.get(h,p);b===u?l++:(l>=5&&(i+=s.N1+(l-5)),u=b,l=1),b=n.get(p,h),b===m?c++:(c>=5&&(i+=s.N1+(c-5)),m=b,c=1)}l>=5&&(i+=s.N1+(l-5)),c>=5&&(i+=s.N1+(c-5))}return i},t.getPenaltyN2=function(n){const a=n.size;let i=0;for(let l=0;l<a-1;l++)for(let c=0;c<a-1;c++){const u=n.get(l,c)+n.get(l,c+1)+n.get(l+1,c)+n.get(l+1,c+1);(u===4||u===0)&&i++}return i*s.N2},t.getPenaltyN3=function(n){const a=n.size;let i=0,l=0,c=0;for(let u=0;u<a;u++){l=c=0;for(let m=0;m<a;m++)l=l<<1&2047|n.get(u,m),m>=10&&(l===1488||l===93)&&i++,c=c<<1&2047|n.get(m,u),m>=10&&(c===1488||c===93)&&i++}return i*s.N3},t.getPenaltyN4=function(n){let a=0;const i=n.data.length;for(let c=0;c<i;c++)a+=n.data[c];return Math.abs(Math.ceil(a*100/i/5)-10)*s.N4};function r(o,n,a){switch(o){case t.Patterns.PATTERN000:return(n+a)%2===0;case t.Patterns.PATTERN001:return n%2===0;case t.Patterns.PATTERN010:return a%3===0;case t.Patterns.PATTERN011:return(n+a)%3===0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(a/3))%2===0;case t.Patterns.PATTERN101:return n*a%2+n*a%3===0;case t.Patterns.PATTERN110:return(n*a%2+n*a%3)%2===0;case t.Patterns.PATTERN111:return(n*a%3+(n+a)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}t.applyMask=function(n,a){const i=a.size;for(let l=0;l<i;l++)for(let c=0;c<i;c++)a.isReserved(c,l)||a.xor(c,l,r(n,c,l))},t.getBestMask=function(n,a){const i=Object.keys(t.Patterns).length;let l=0,c=1/0;for(let u=0;u<i;u++){a(u),t.applyMask(u,n);const m=t.getPenaltyN1(n)+t.getPenaltyN2(n)+t.getPenaltyN3(n)+t.getPenaltyN4(n);t.applyMask(u,n),m<c&&(c=m,l=u)}return l}})(fs)),fs}var wt={},sn;function Uo(){if(sn)return wt;sn=1;const t=or(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return wt.getBlocksCount=function(n,a){switch(a){case t.L:return s[(n-1)*4+0];case t.M:return s[(n-1)*4+1];case t.Q:return s[(n-1)*4+2];case t.H:return s[(n-1)*4+3];default:return}},wt.getTotalCodewordsCount=function(n,a){switch(a){case t.L:return r[(n-1)*4+0];case t.M:return r[(n-1)*4+1];case t.Q:return r[(n-1)*4+2];case t.H:return r[(n-1)*4+3];default:return}},wt}var ps={},it={},rn;function _l(){if(rn)return it;rn=1;const t=new Uint8Array(512),s=new Uint8Array(256);return(function(){let o=1;for(let n=0;n<255;n++)t[n]=o,s[o]=n,o<<=1,o&256&&(o^=285);for(let n=255;n<512;n++)t[n]=t[n-255]})(),it.log=function(o){if(o<1)throw new Error("log("+o+")");return s[o]},it.exp=function(o){return t[o]},it.mul=function(o,n){return o===0||n===0?0:t[s[o]+s[n]]},it}var nn;function Ll(){return nn||(nn=1,(function(t){const s=_l();t.mul=function(o,n){const a=new Uint8Array(o.length+n.length-1);for(let i=0;i<o.length;i++)for(let l=0;l<n.length;l++)a[i+l]^=s.mul(o[i],n[l]);return a},t.mod=function(o,n){let a=new Uint8Array(o);for(;a.length-n.length>=0;){const i=a[0];for(let c=0;c<n.length;c++)a[c]^=s.mul(n[c],i);let l=0;for(;l<a.length&&a[l]===0;)l++;a=a.slice(l)}return a},t.generateECPolynomial=function(o){let n=new Uint8Array([1]);for(let a=0;a<o;a++)n=t.mul(n,new Uint8Array([1,s.exp(a)]));return n}})(ps)),ps}var gs,on;function Pl(){if(on)return gs;on=1;const t=Ll();function s(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(o){this.degree=o,this.genPoly=t.generateECPolynomial(this.degree)},s.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(o.length+this.degree);n.set(o);const a=t.mod(n,this.genPoly),i=this.degree-a.length;if(i>0){const l=new Uint8Array(this.degree);return l.set(a,i),l}return a},gs=s,gs}var ws={},bs={},ys={},an;function Do(){return an||(an=1,ys.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),ys}var ve={},cn;function Fo(){if(cn)return ve;cn=1;const t="[0-9]+",s="[A-Z $%*+\\-./:]+";let r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";r=r.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
|
|
2050
|
+
]))+`;ve.KANJI=new RegExp(r,"g"),ve.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),ve.BYTE=new RegExp(o,"g"),ve.NUMERIC=new RegExp(t,"g"),ve.ALPHANUMERIC=new RegExp(s,"g");const n=new RegExp("^"+r+"$"),a=new RegExp("^"+t+"$"),i=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return ve.testKanji=function(c){return n.test(c)},ve.testNumeric=function(c){return a.test(c)},ve.testAlphanumeric=function(c){return i.test(c)},ve}var ln;function ze(){return ln||(ln=1,(function(t){const s=Do(),r=Fo();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(a,i){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!s.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?a.ccBits[0]:i<27?a.ccBits[1]:a.ccBits[2]},t.getBestModeForData=function(a){return r.testNumeric(a)?t.NUMERIC:r.testAlphanumeric(a)?t.ALPHANUMERIC:r.testKanji(a)?t.KANJI:t.BYTE},t.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},t.isValid=function(a){return a&&a.bit&&a.ccBits};function o(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+n)}}t.from=function(a,i){if(t.isValid(a))return a;try{return o(a)}catch{return i}}})(bs)),bs}var dn;function Rl(){return dn||(dn=1,(function(t){const s=qe(),r=Uo(),o=or(),n=ze(),a=Do(),i=7973,l=s.getBCHDigit(i);function c(p,b,w){for(let g=1;g<=40;g++)if(b<=t.getCapacity(g,w,p))return g}function u(p,b){return n.getCharCountIndicator(p,b)+4}function m(p,b){let w=0;return p.forEach(function(g){const k=u(g.mode,b);w+=k+g.getBitsLength()}),w}function h(p,b){for(let w=1;w<=40;w++)if(m(p,w)<=t.getCapacity(w,b,n.MIXED))return w}t.from=function(b,w){return a.isValid(b)?parseInt(b,10):w},t.getCapacity=function(b,w,g){if(!a.isValid(b))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=n.BYTE);const k=s.getSymbolTotalCodewords(b),A=r.getTotalCodewordsCount(b,w),j=(k-A)*8;if(g===n.MIXED)return j;const N=j-u(g,b);switch(g){case n.NUMERIC:return Math.floor(N/10*3);case n.ALPHANUMERIC:return Math.floor(N/11*2);case n.KANJI:return Math.floor(N/13);case n.BYTE:default:return Math.floor(N/8)}},t.getBestVersionForData=function(b,w){let g;const k=o.from(w,o.M);if(Array.isArray(b)){if(b.length>1)return h(b,k);if(b.length===0)return 1;g=b[0]}else g=b;return c(g.mode,g.getLength(),k)},t.getEncodedBits=function(b){if(!a.isValid(b)||b<7)throw new Error("Invalid QR Code version");let w=b<<12;for(;s.getBCHDigit(w)-l>=0;)w^=i<<s.getBCHDigit(w)-l;return b<<12|w}})(ws)),ws}var xs={},un;function Tl(){if(un)return xs;un=1;const t=qe(),s=1335,r=21522,o=t.getBCHDigit(s);return xs.getEncodedBits=function(a,i){const l=a.bit<<3|i;let c=l<<10;for(;t.getBCHDigit(c)-o>=0;)c^=s<<t.getBCHDigit(c)-o;return(l<<10|c)^r},xs}var As={},vs,hn;function Bl(){if(hn)return vs;hn=1;const t=ze();function s(r){this.mode=t.NUMERIC,this.data=r.toString()}return s.getBitsLength=function(o){return 10*Math.floor(o/3)+(o%3?o%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(o){let n,a,i;for(n=0;n+3<=this.data.length;n+=3)a=this.data.substr(n,3),i=parseInt(a,10),o.put(i,10);const l=this.data.length-n;l>0&&(a=this.data.substr(n),i=parseInt(a,10),o.put(i,l*3+1))},vs=s,vs}var js,mn;function Ml(){if(mn)return js;mn=1;const t=ze(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function r(o){this.mode=t.ALPHANUMERIC,this.data=o}return r.getBitsLength=function(n){return 11*Math.floor(n/2)+6*(n%2)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(n){let a;for(a=0;a+2<=this.data.length;a+=2){let i=s.indexOf(this.data[a])*45;i+=s.indexOf(this.data[a+1]),n.put(i,11)}this.data.length%2&&n.put(s.indexOf(this.data[a]),6)},js=r,js}var ks,fn;function Il(){if(fn)return ks;fn=1;const t=ze();function s(r){this.mode=t.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}return s.getBitsLength=function(o){return o*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(r){for(let o=0,n=this.data.length;o<n;o++)r.put(this.data[o],8)},ks=s,ks}var Ns,pn;function Ul(){if(pn)return Ns;pn=1;const t=ze(),s=qe();function r(o){this.mode=t.KANJI,this.data=o}return r.getBitsLength=function(n){return n*13},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(o){let n;for(n=0;n<this.data.length;n++){let a=s.toSJIS(this.data[n]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[n]+`
|
|
2051
|
+
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),o.put(a,13)}},Ns=r,Ns}var Ss={exports:{}},gn;function Dl(){return gn||(gn=1,(function(t){var s={single_source_shortest_paths:function(r,o,n){var a={},i={};i[o]=0;var l=s.PriorityQueue.make();l.push(o,0);for(var c,u,m,h,p,b,w,g,k;!l.empty();){c=l.pop(),u=c.value,h=c.cost,p=r[u]||{};for(m in p)p.hasOwnProperty(m)&&(b=p[m],w=h+b,g=i[m],k=typeof i[m]>"u",(k||g>w)&&(i[m]=w,l.push(m,w),a[m]=u))}if(typeof n<"u"&&typeof i[n]>"u"){var A=["Could not find a path from ",o," to ",n,"."].join("");throw new Error(A)}return a},extract_shortest_path_from_predecessor_list:function(r,o){for(var n=[],a=o;a;)n.push(a),r[a],a=r[a];return n.reverse(),n},find_path:function(r,o,n){var a=s.single_source_shortest_paths(r,o,n);return s.extract_shortest_path_from_predecessor_list(a,n)},PriorityQueue:{make:function(r){var o=s.PriorityQueue,n={},a;r=r||{};for(a in o)o.hasOwnProperty(a)&&(n[a]=o[a]);return n.queue=[],n.sorter=r.sorter||o.default_sorter,n},default_sorter:function(r,o){return r.cost-o.cost},push:function(r,o){var n={value:r,cost:o};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=s})(Ss)),Ss.exports}var wn;function Fl(){return wn||(wn=1,(function(t){const s=ze(),r=Bl(),o=Ml(),n=Il(),a=Ul(),i=Fo(),l=qe(),c=Dl();function u(A){return unescape(encodeURIComponent(A)).length}function m(A,j,N){const S=[];let C;for(;(C=A.exec(N))!==null;)S.push({data:C[0],index:C.index,mode:j,length:C[0].length});return S}function h(A){const j=m(i.NUMERIC,s.NUMERIC,A),N=m(i.ALPHANUMERIC,s.ALPHANUMERIC,A);let S,C;return l.isKanjiModeEnabled()?(S=m(i.BYTE,s.BYTE,A),C=m(i.KANJI,s.KANJI,A)):(S=m(i.BYTE_KANJI,s.BYTE,A),C=[]),j.concat(N,S,C).sort(function(y,x){return y.index-x.index}).map(function(y){return{data:y.data,mode:y.mode,length:y.length}})}function p(A,j){switch(j){case s.NUMERIC:return r.getBitsLength(A);case s.ALPHANUMERIC:return o.getBitsLength(A);case s.KANJI:return a.getBitsLength(A);case s.BYTE:return n.getBitsLength(A)}}function b(A){return A.reduce(function(j,N){const S=j.length-1>=0?j[j.length-1]:null;return S&&S.mode===N.mode?(j[j.length-1].data+=N.data,j):(j.push(N),j)},[])}function w(A){const j=[];for(let N=0;N<A.length;N++){const S=A[N];switch(S.mode){case s.NUMERIC:j.push([S,{data:S.data,mode:s.ALPHANUMERIC,length:S.length},{data:S.data,mode:s.BYTE,length:S.length}]);break;case s.ALPHANUMERIC:j.push([S,{data:S.data,mode:s.BYTE,length:S.length}]);break;case s.KANJI:j.push([S,{data:S.data,mode:s.BYTE,length:u(S.data)}]);break;case s.BYTE:j.push([{data:S.data,mode:s.BYTE,length:u(S.data)}])}}return j}function g(A,j){const N={},S={start:{}};let C=["start"];for(let f=0;f<A.length;f++){const y=A[f],x=[];for(let v=0;v<y.length;v++){const _=y[v],E=""+f+v;x.push(E),N[E]={node:_,lastCount:0},S[E]={};for(let P=0;P<C.length;P++){const L=C[P];N[L]&&N[L].node.mode===_.mode?(S[L][E]=p(N[L].lastCount+_.length,_.mode)-p(N[L].lastCount,_.mode),N[L].lastCount+=_.length):(N[L]&&(N[L].lastCount=_.length),S[L][E]=p(_.length,_.mode)+4+s.getCharCountIndicator(_.mode,j))}}C=x}for(let f=0;f<C.length;f++)S[C[f]].end=0;return{map:S,table:N}}function k(A,j){let N;const S=s.getBestModeForData(A);if(N=s.from(j,S),N!==s.BYTE&&N.bit<S.bit)throw new Error('"'+A+'" cannot be encoded with mode '+s.toString(N)+`.
|
|
2052
|
+
Suggested mode is: `+s.toString(S));switch(N===s.KANJI&&!l.isKanjiModeEnabled()&&(N=s.BYTE),N){case s.NUMERIC:return new r(A);case s.ALPHANUMERIC:return new o(A);case s.KANJI:return new a(A);case s.BYTE:return new n(A)}}t.fromArray=function(j){return j.reduce(function(N,S){return typeof S=="string"?N.push(k(S,null)):S.data&&N.push(k(S.data,S.mode)),N},[])},t.fromString=function(j,N){const S=h(j,l.isKanjiModeEnabled()),C=w(S),f=g(C,N),y=c.find_path(f.map,"start","end"),x=[];for(let v=1;v<y.length-1;v++)x.push(f.table[y[v]].node);return t.fromArray(b(x))},t.rawSplit=function(j){return t.fromArray(h(j,l.isKanjiModeEnabled()))}})(As)),As}var bn;function Wl(){if(bn)return cs;bn=1;const t=qe(),s=or(),r=kl(),o=Nl(),n=Sl(),a=Cl(),i=El(),l=Uo(),c=Pl(),u=Rl(),m=Tl(),h=ze(),p=Fl();function b(f,y){const x=f.size,v=a.getPositions(y);for(let _=0;_<v.length;_++){const E=v[_][0],P=v[_][1];for(let L=-1;L<=7;L++)if(!(E+L<=-1||x<=E+L))for(let R=-1;R<=7;R++)P+R<=-1||x<=P+R||(L>=0&&L<=6&&(R===0||R===6)||R>=0&&R<=6&&(L===0||L===6)||L>=2&&L<=4&&R>=2&&R<=4?f.set(E+L,P+R,!0,!0):f.set(E+L,P+R,!1,!0))}}function w(f){const y=f.size;for(let x=8;x<y-8;x++){const v=x%2===0;f.set(x,6,v,!0),f.set(6,x,v,!0)}}function g(f,y){const x=n.getPositions(y);for(let v=0;v<x.length;v++){const _=x[v][0],E=x[v][1];for(let P=-2;P<=2;P++)for(let L=-2;L<=2;L++)P===-2||P===2||L===-2||L===2||P===0&&L===0?f.set(_+P,E+L,!0,!0):f.set(_+P,E+L,!1,!0)}}function k(f,y){const x=f.size,v=u.getEncodedBits(y);let _,E,P;for(let L=0;L<18;L++)_=Math.floor(L/3),E=L%3+x-8-3,P=(v>>L&1)===1,f.set(_,E,P,!0),f.set(E,_,P,!0)}function A(f,y,x){const v=f.size,_=m.getEncodedBits(y,x);let E,P;for(E=0;E<15;E++)P=(_>>E&1)===1,E<6?f.set(E,8,P,!0):E<8?f.set(E+1,8,P,!0):f.set(v-15+E,8,P,!0),E<8?f.set(8,v-E-1,P,!0):E<9?f.set(8,15-E-1+1,P,!0):f.set(8,15-E-1,P,!0);f.set(v-8,8,1,!0)}function j(f,y){const x=f.size;let v=-1,_=x-1,E=7,P=0;for(let L=x-1;L>0;L-=2)for(L===6&&L--;;){for(let R=0;R<2;R++)if(!f.isReserved(_,L-R)){let T=!1;P<y.length&&(T=(y[P]>>>E&1)===1),f.set(_,L-R,T),E--,E===-1&&(P++,E=7)}if(_+=v,_<0||x<=_){_-=v,v=-v;break}}}function N(f,y,x){const v=new r;x.forEach(function(R){v.put(R.mode.bit,4),v.put(R.getLength(),h.getCharCountIndicator(R.mode,f)),R.write(v)});const _=t.getSymbolTotalCodewords(f),E=l.getTotalCodewordsCount(f,y),P=(_-E)*8;for(v.getLengthInBits()+4<=P&&v.put(0,4);v.getLengthInBits()%8!==0;)v.putBit(0);const L=(P-v.getLengthInBits())/8;for(let R=0;R<L;R++)v.put(R%2?17:236,8);return S(v,f,y)}function S(f,y,x){const v=t.getSymbolTotalCodewords(y),_=l.getTotalCodewordsCount(y,x),E=v-_,P=l.getBlocksCount(y,x),L=v%P,R=P-L,T=Math.floor(v/P),M=Math.floor(E/P),F=M+1,W=T-M,q=new c(W);let I=0;const D=new Array(P),$=new Array(P);let Z=0;const se=new Uint8Array(f.buffer);for(let X=0;X<P;X++){const ce=X<R?M:F;D[X]=se.slice(I,I+ce),$[X]=q.encode(D[X]),I+=ce,Z=Math.max(Z,ce)}const pe=new Uint8Array(v);let he=0,K,z;for(K=0;K<Z;K++)for(z=0;z<P;z++)K<D[z].length&&(pe[he++]=D[z][K]);for(K=0;K<W;K++)for(z=0;z<P;z++)pe[he++]=$[z][K];return pe}function C(f,y,x,v){let _;if(Array.isArray(f))_=p.fromArray(f);else if(typeof f=="string"){let T=y;if(!T){const M=p.rawSplit(f);T=u.getBestVersionForData(M,x)}_=p.fromString(f,T||40)}else throw new Error("Invalid data");const E=u.getBestVersionForData(_,x);if(!E)throw new Error("The amount of data is too big to be stored in a QR Code");if(!y)y=E;else if(y<E)throw new Error(`
|
|
2053
2053
|
The chosen QR Code version cannot contain this amount of data.
|
|
2054
|
-
Minimum version required to store current data is: `+
|
|
2055
|
-
`);const
|
|
2056
|
-
`;return typeof
|
|
2057
|
-
`);await navigator.clipboard.writeText(
|
|
2058
|
-
`))};return o&&!r?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(z.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):n&&!r?e.jsxs("div",{className:`cedros-totp-settings ${s}`,children:[e.jsx(Z.ErrorMessage,{error:n,onDismiss:c}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>a(),children:"Retry"})]}):u==="setup"?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsx(Ks,{onSuccess:P,onCancel:()=>f("status")})}):u==="disable"?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Disable two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description cedros-totp-warning",children:"This will make your account less secure. Enter your password to confirm."}),j&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:j},onDismiss:()=>C(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.PasswordInput,{label:"Password",placeholder:"Enter your password",value:h,onChange:y=>p(y.target.value),disabled:x,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{f("status"),p(""),C(null)},disabled:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:g,disabled:x||h.length===0,children:x?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):u==="regenerate"?m?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"New recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. Your old codes are no longer valid."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:m.map((y,L)=>e.jsx("code",{className:"cedros-totp-backup-code",children:y},L))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:A,children:"Copy all codes"}),e.jsx("div",{className:"cedros-totp-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>{f("status"),k(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Regenerate recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"This will invalidate all existing recovery codes. Enter your authenticator code to confirm."}),j&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:j},onDismiss:()=>C(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.OtpInput,{value:b,onChange:w,onComplete:v,disabled:x,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{f("status"),w(""),C(null)},disabled:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:v,disabled:x||b.length!==6,children:x?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsxs("div",{className:"cedros-totp-status-header",children:[e.jsxs("div",{className:"cedros-totp-status-info",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description",children:"Add an extra layer of security to your account by requiring a verification code from your authenticator app when signing in with email and password. Other sign-in methods (Google, Apple, passkeys) use their own built-in verification."})]}),e.jsx("div",{className:`cedros-totp-badge ${r?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:r?.enabled?"Enabled":"Disabled"})]}),r?.enabled?e.jsxs("div",{className:"cedros-totp-enabled-actions",children:[e.jsxs("div",{className:"cedros-totp-description",style:{marginTop:"0.25rem"},children:["Recovery codes remaining: ",e.jsx("strong",{children:r.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>f("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>f("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>f("setup"),children:"Enable two-factor authentication"})]})})}class El{client;constructor(s,r,o,n){this.client=new T.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async changePassword(s){try{return await this.client.post("/auth/change-password",s)}catch(r){throw T.handleApiError(r,"Failed to change password")}}async updateProfile(s){try{return await this.client.patch("/auth/me",s)}catch(r){throw T.handleApiError(r,"Failed to update profile")}}}function tt(){const{config:t,authState:s,_internal:r}=T.useCedrosLogin(),[o,n]=d.useState(!1),[a,l]=d.useState(null),i=d.useMemo(()=>new El(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),c=d.useCallback(()=>{l(null)},[]),u=d.useCallback(async h=>{if(s!=="authenticated")throw new Error("Must be authenticated to update profile");n(!0),l(null);try{return await i.updateProfile(h)}catch(p){const b=p instanceof Error?p:new Error("Failed to update profile");throw l(b),b}finally{n(!1)}},[s,i]),f=d.useCallback(async h=>{if(s!=="authenticated")throw new Error("Must be authenticated to change password");n(!0),l(null);try{await i.changePassword(h)}catch(p){const b=p instanceof Error?p:new Error("Failed to change password");throw l(b),b}finally{n(!1)}},[s,i]);return{isLoading:o,error:a,updateProfile:u,changePassword:f,clearError:c}}function Ll({onPasswordChange:t,onClose:s,className:r=""}){const{user:o,refreshUser:n}=_.useAuth(),{config:a,_internal:l}=T.useCedrosLogin(),{isLoading:i,error:c,changePassword:u,clearError:f}=tt(),[h,p]=d.useState("main"),[b,w]=d.useState(""),[m,k]=d.useState(""),[x,N]=d.useState(""),[j,C]=d.useState(null),[P,g]=d.useState(null),[v,A]=d.useState(!1),y=d.useRef(null),L=Ie.validatePassword(m),S=m===x,B=b.length>0&&m.length>0&&x.length>0&&L.isValid&&S,E=d.useCallback(async U=>{const q=U.target.files?.[0];if(q){C(null),A(!0);try{const O=new FormData;O.append("file",q);const I=l?.getAccessToken?.(),D={};I&&(D.Authorization=`Bearer ${I}`);const H=await fetch(`${a.serverUrl}/auth/upload/avatar`,{method:"POST",headers:D,body:O,credentials:"include"});if(!H.ok){const Y=await H.json().catch(()=>null);throw new Error(Y?.message||Y?.error||`Upload failed (${H.status})`)}await n()}catch(O){C(O instanceof Error?O.message:"Failed to upload avatar")}finally{A(!1),y.current&&(y.current.value="")}}},[a.serverUrl,l,n]),M=d.useCallback(async()=>{if(B){C(null),g(null);try{await u({currentPassword:b,newPassword:m}),w(""),k(""),N(""),g("Password changed successfully. Other sessions have been logged out."),t?.(),setTimeout(()=>{p("main"),g(null)},2e3)}catch(U){C(U instanceof Error?U.message:"Failed to change password")}}},[B,b,m,u,t]),R=d.useCallback(()=>{p("main"),w(""),k(""),N(""),C(null),f()},[f]),F=()=>o?.name?o.name.split(" ").map(U=>U[0]).join("").toUpperCase().slice(0,2):o?.email?o.email[0].toUpperCase():"?";return h==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(j||c)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:j||c?.message||""},onDismiss:()=>{C(null),f()}})}),P&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),P]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:b,onChange:U=>w(U.target.value),disabled:i,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"New password",placeholder:"Enter new password",value:m,onChange:U=>k(U.target.value),disabled:i,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:x,onChange:U=>N(U.target.value),disabled:i,error:x.length>0&&!S?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:R,disabled:i,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:M,disabled:i||!B,children:i?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})}):e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsxs("div",{className:"cedros-profile-avatar-container cedros-profile-avatar-container--clickable",onClick:()=>y.current?.click(),role:"button",tabIndex:0,onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),y.current?.click())},"aria-label":"Change profile picture",children:[v?e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:e.jsx(z.LoadingSpinner,{size:"sm"})}):o?.picture?e.jsx("img",{src:o.picture,alt:o.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:F()}),e.jsx("div",{className:"cedros-profile-avatar-overlay",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),e.jsx("circle",{cx:"12",cy:"13",r:"4"})]})}),e.jsx("input",{ref:y,type:"file",accept:"image/jpeg,image/png,image/gif,image/webp",onChange:E,className:"cedros-profile-avatar-input","aria-hidden":"true",tabIndex:-1})]}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:o?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:o?.email})]})]}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:o?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:"••••••••"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>p("change-password"),children:"Change"})]})]}),s&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:s,children:"Close"})})]})})}class Pl{client;constructor(s,r,o,n){this.client=new T.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listCredentials(){try{return(await this.client.get("/credentials")).credentials}catch(s){throw T.handleApiError(s,"Failed to list credentials")}}async unlinkCredential(s){try{await this.client.delete(`/credentials/${encodeURIComponent(s)}`)}catch(r){throw T.handleApiError(r,"Failed to unlink credential")}}}function Ys(){const{config:t,authState:s,_internal:r}=T.useCedrosLogin(),[o,n]=d.useState([]),[a,l]=d.useState(!1),[i,c]=d.useState(null),u=d.useMemo(()=>new Pl(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),f=d.useCallback(()=>{c(null)},[]),h=d.useCallback(async()=>{if(s!=="authenticated"){n([]);return}l(!0),c(null);try{const b=await u.listCredentials();n(b)}catch(b){c(b)}finally{l(!1)}},[s,u]);d.useEffect(()=>{s==="authenticated"?h():n([])},[s,h]);const p=d.useCallback(async b=>{l(!0),c(null);try{await u.unlinkCredential(b),await h()}catch(w){throw c(w),w}finally{l(!1)}},[u,h]);return{credentials:o,isLoading:a,error:i,fetchCredentials:h,unlinkCredential:p,clearError:f}}function Bl({onPasswordChange:t,onCancel:s,className:r=""}){const{isLoading:o,error:n,changePassword:a,clearError:l}=tt(),[i,c]=d.useState(""),[u,f]=d.useState(""),[h,p]=d.useState(""),[b,w]=d.useState(null),[m,k]=d.useState(null),x=Ie.validatePassword(u),N=u===h,j=i.length>0&&u.length>0&&h.length>0&&x.isValid&&N,C=d.useCallback(async()=>{if(j){w(null),k(null);try{await a({currentPassword:i,newPassword:u}),c(""),f(""),p(""),k("Password changed successfully. Other sessions have been logged out."),t?.(),setTimeout(()=>s(),2e3)}catch(g){w(g instanceof Error?g.message:"Failed to change password")}}},[j,i,u,a,t,s]),P=d.useCallback(()=>{w(null),l(),s()},[l,s]);return e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(b||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:b||n?.message||""},onDismiss:()=>{w(null),l()}})}),m&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),m]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:i,onChange:g=>c(g.target.value),disabled:o,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"New password",placeholder:"Enter new password",value:u,onChange:g=>f(g.target.value),disabled:o,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:h,onChange:g=>p(g.target.value),disabled:o,error:h.length>0&&!N?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:P,disabled:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:C,disabled:o||!j,children:o?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})})}function Lo({onPasswordChange:t,className:s=""}){const{user:r,refreshUser:o}=_.useAuth(),{isLoading:n,error:a,updateProfile:l,clearError:i}=tt(),{credentials:c}=Ys(),{forgotPassword:u,isLoading:f,isSuccess:h,reset:p}=St(),b=c.some(y=>y.credentialType==="password"),[w,m]=d.useState("view"),[k,x]=d.useState(""),[N,j]=d.useState(null),C=()=>r?.name?r.name.split(" ").map(y=>y[0]).join("").toUpperCase().slice(0,2):r?.email?r.email[0].toUpperCase():"?",P=d.useCallback(()=>{x(r?.name||""),m("edit"),j(null)},[r?.name]),g=d.useCallback(async()=>{const y=k.trim();if(y){j(null);try{await l({name:y}),await o(),m("view")}catch(L){j(L instanceof Error?L.message:"Failed to update name")}}},[k,l,o]),v=d.useCallback(()=>{m("view"),x(""),j(null),i()},[i]),A=d.useCallback(async()=>{if(r?.email){j(null);try{await u(r.email)}catch(y){j(y instanceof Error?y.message:"Failed to send password setup email")}}},[r?.email,u]);return w==="change-password"?e.jsx(Bl,{onPasswordChange:t,onCancel:()=>m("view"),className:s}):e.jsx("div",{className:`cedros-profile-settings ${s}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children:r?.picture?e.jsx("img",{src:r.picture,alt:r.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:C()})}),e.jsxs("div",{className:"cedros-profile-info",children:[w==="edit"?e.jsxs("div",{className:"cedros-profile-name-edit",children:[e.jsx("input",{type:"text",className:"cedros-input",value:k,onChange:y=>x(y.target.value),disabled:n,autoFocus:!0,onKeyDown:y=>{y.key==="Enter"&&g(),y.key==="Escape"&&v()}}),e.jsxs("div",{className:"cedros-profile-name-edit-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:g,disabled:n||!k.trim(),children:n?e.jsx(z.LoadingSpinner,{size:"sm"}):"Save"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:v,disabled:n,children:"Cancel"})]})]}):e.jsxs("div",{className:"cedros-profile-name-row",children:[e.jsx("h3",{className:"cedros-profile-name",children:r?.name||"User"}),e.jsx("button",{type:"button",className:"cedros-profile-edit-btn",onClick:P,title:"Edit name","aria-label":"Edit name",children:e.jsx(Ml,{})})]}),e.jsx("p",{className:"cedros-profile-email",children:r?.email})]})]}),(N||a)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:N||a?.message||""},onDismiss:()=>{j(null),i()}})}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:r?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:b?"••••••••":"Not set"})]}),b?e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{m("change-password"),j(null)},children:"Change"}):h?e.jsxs("span",{className:"cedros-profile-row-sent",children:["Check your email",e.jsx("button",{type:"button",className:"cedros-profile-row-sent-dismiss",onClick:p,"aria-label":"Dismiss",children:"×"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:A,disabled:f,children:f?e.jsx(z.LoadingSpinner,{size:"sm"}):"Add password"})]})]})]})})}function Ml(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M16.474 5.408l2.118 2.117m-.756-3.982L12.109 9.27a2.118 2.118 0 00-.58 1.082L11 13l2.648-.53c.41-.082.786-.283 1.082-.579l5.727-5.727a1.853 1.853 0 10-2.621-2.621z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M19 15v3a2 2 0 01-2 2H6a2 2 0 01-2-2V7a2 2 0 012-2h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Po={password:"Email & Password",oauth_google:"Google",oauth_apple:"Apple",solana:"Solana Wallet",webauthn_passkey:"Passkey",webauthn_security_key:"Security Key",totp:"Authenticator App (2FA)",sso_oidc:"Single Sign-On"};function Bo({onLinkGoogle:t,onLinkApple:s,onAddPasskey:r,onLinkSolana:o,className:n=""}){const{credentials:a,isLoading:l,error:i,unlinkCredential:c,clearError:u,fetchCredentials:f}=Ys(),{registerPasskey:h,isSupported:p}=Vs(),[b,w]=d.useState(null),[m,k]=d.useState(!1),x=d.useCallback(async()=>{if(r){r();return}k(!0);try{await h(),await f()}catch{}finally{k(!1)}},[r,h,f]),N=d.useCallback(async y=>{const L=y.label||Po[y.credentialType];if(window.confirm(`Remove "${L}" as a sign-in method? You won't be able to sign in with it anymore.`)){w(y.id);try{await c(y.id)}catch{}finally{w(null)}}},[c]),j=new Set(a.map(y=>y.credentialType)),C=t&&!j.has("oauth_google"),P=s&&!j.has("oauth_apple"),g=(r||p)&&!j.has("webauthn_passkey"),v=o&&!j.has("solana"),A=C||P||g||v;return l&&a.length===0?e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading linked accounts..."})]}):e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[i&&e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:i.message},onDismiss:u}),a.length===0&&!l&&e.jsx("p",{className:"cedros-linked-accounts-empty",children:"No linked sign-in methods found."}),a.length>0&&e.jsx("ul",{className:"cedros-linked-credential-list",children:a.map(y=>e.jsx(Rl,{credential:y,isUnlinking:b===y.id,onUnlink:N},y.id))}),A&&e.jsxs("div",{className:"cedros-linked-add",children:[e.jsx("p",{className:"cedros-linked-add-label",children:"Link a new sign-in method"}),e.jsxs("div",{className:"cedros-linked-add-buttons",children:[C&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:[e.jsx(Mo,{})," Google"]}),P&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(Ro,{})," Apple"]}),g&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:x,disabled:m,children:m?e.jsx(z.LoadingSpinner,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(Bs,{})," Passkey"]})}),v&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:[e.jsx(To,{})," Solana"]})]})]})]})}function Rl({credential:t,isUnlinking:s,onUnlink:r}){const o=t.label||Po[t.credentialType],n=Tl[t.credentialType]||Il;return e.jsxs("li",{className:"cedros-linked-credential",children:[e.jsx("div",{className:"cedros-linked-credential__icon",children:e.jsx(n,{})}),e.jsxs("div",{className:"cedros-linked-credential__info",children:[e.jsx("span",{className:"cedros-linked-credential__name",children:o}),e.jsxs("span",{className:"cedros-linked-credential__meta",children:["Added ",hn(t.createdAt),t.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",hn(t.lastUsedAt)]}),t.isPrimary&&e.jsx(e.Fragment,{children:" · Primary"})]})]}),e.jsx("div",{className:"cedros-linked-credential__action",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-button-danger-outline",onClick:()=>r(t),disabled:s,title:t.isPrimary?"Cannot remove primary sign-in method":"Remove",children:s?e.jsx(z.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function hn(t){const s=new Date(t),o=new Date().getTime()-s.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),l=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n}m ago`:a<24?`${a}h ago`:l<30?`${l}d ago`:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const Tl={password:_l,oauth_google:Mo,oauth_apple:Ro,solana:To,webauthn_passkey:Bs,webauthn_security_key:Bs,totp:Dl,sso_oidc:Ul};function Il(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M12 8v4m0 4h.01",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function _l(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M7 11V7a5 5 0 0110 0v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"16",r:"1.5",fill:"currentColor"})]})}function Mo(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M21.8 12.2c0-.7-.1-1.4-.2-2H12v3.8h5.5a4.7 4.7 0 01-2 3.1v2.5h3.3c1.9-1.7 3-4.3 3-7.4z",fill:"#4285F4"}),e.jsx("path",{d:"M12 22c2.7 0 5-.9 6.6-2.4l-3.3-2.5c-.9.6-2 1-3.3 1-2.5 0-4.7-1.7-5.4-4H3.2v2.6A10 10 0 0012 22z",fill:"#34A853"}),e.jsx("path",{d:"M6.6 14.1a6 6 0 010-4.2V7.3H3.2a10 10 0 000 9.4l3.4-2.6z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.9c1.4 0 2.7.5 3.7 1.4l2.8-2.8A10 10 0 0012 2 10 10 0 003.2 7.3l3.4 2.6C7.3 7.6 9.5 5.9 12 5.9z",fill:"#EA4335"})]})}function Ro(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C3.79 16.16 4.36 9.53 8.72 9.28c1.3.07 2.2.74 2.96.8.93-.2 1.82-.92 3.03-.83 1.47.12 2.57.72 3.28 1.83-3.02 1.8-2.3 5.75.5 6.86-.6 1.53-1.37 3.04-2.44 4.34zM12.03 9.2C11.88 7.17 13.5 5.5 15.4 5.35c.29 2.28-2.08 3.98-3.37 3.85z",fill:"currentColor"})})}function To(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M2 10h20",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"17",cy:"14",r:"1.5",fill:"currentColor"})]})}function Bs(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"10",cy:"7",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M3 21v-2a7 7 0 017-7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M17 14v4m0 0v2m0-2h-2m2 0h2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Dl(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M9 12h6M12 9v6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Ul(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"})]})}class Fl{client;constructor(s,r,o,n){this.client=new T.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(s){throw T.handleApiError(s,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(s){throw T.handleApiError(s,"Failed to revoke sessions")}}}function Io(){const{config:t,authState:s,_internal:r}=T.useCedrosLogin(),[o,n]=d.useState([]),[a,l]=d.useState(!1),[i,c]=d.useState(null),u=d.useMemo(()=>new Fl(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),f=d.useCallback(async()=>{if(s!=="authenticated"){n([]);return}l(!0),c(null);try{const b=await u.listSessions();n(b)}catch(b){c(b)}finally{l(!1)}},[s,u]);d.useEffect(()=>{s==="authenticated"?f():n([])},[s,f]);const h=d.useCallback(async()=>{l(!0),c(null);try{const b=await u.revokeAllSessions();return await f(),b}catch(b){throw c(b),b}finally{l(!1)}},[u,f]),p=d.useMemo(()=>o.filter(b=>!b.isCurrent).length,[o]);return{sessions:o,isLoading:a,error:i,fetchSessions:f,revokeAllSessions:h,otherSessionCount:p}}const Ol={profile:"Profile",security:"Security",linked:"Linked Accounts"},Wl=["profile","security","linked"];function ql({defaultTab:t="profile",onClose:s,onPasswordChange:r,onTotpChange:o,onLinkGoogle:n,onLinkApple:a,onAddPasskey:l,onLinkSolana:i,className:c=""}){const[u,f]=d.useState(t),{sessions:h,isLoading:p,error:b,revokeAllSessions:w}=Io();return e.jsxs("div",{className:`cedros-account-settings ${c}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:Wl.map(m=>e.jsx("button",{type:"button",role:"tab","aria-selected":u===m,className:`cedros-account-tab ${u===m?"cedros-account-tab-active":""}`,onClick:()=>f(m),children:Ol[m]},m))}),e.jsxs("div",{className:"cedros-account-tab-content",role:"tabpanel",children:[u==="profile"&&e.jsx(Lo,{onPasswordChange:r}),u==="security"&&e.jsxs("div",{className:"cedros-account-security",children:[e.jsx(Eo,{onStatusChange:o}),e.jsx(io,{sessions:h,isLoading:p,error:b??void 0,onRevokeAll:async()=>{await w()}})]}),u==="linked"&&e.jsx(Bo,{onLinkGoogle:n,onLinkApple:a,onAddPasskey:l,onLinkSolana:i})]}),s&&e.jsx("div",{className:"cedros-account-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:s,children:"Close"})})]})}function zl({onComplete:t,className:s}){return e.jsxs("div",{className:`cedros-mfa-setup-prompt ${s??""}`,children:[e.jsxs("div",{className:"cedros-mfa-setup-prompt__header",children:[e.jsx("h2",{className:"cedros-mfa-setup-prompt__title",children:"Two-factor authentication required"}),e.jsx("p",{className:"cedros-mfa-setup-prompt__description",children:"Your administrator requires you to set up two-factor authentication before continuing. This adds an extra layer of security to your account."})]}),e.jsx("div",{className:"cedros-mfa-setup-prompt__body",children:e.jsx(Ks,{onSuccess:t})})]})}function Hl({onComplete:t,onSkip:s,className:r}){const{user:o}=_.useAuth(),{isLoading:n,error:a,updateProfile:l,clearError:i}=tt(),[c,u]=d.useState(o?.name??""),f=d.useCallback(async p=>{p.preventDefault(),i();const b=c.trim();if(!b){t?.();return}try{await l({name:b}),t?.()}catch{}},[c,l,i,t]),h=c.trim().length>0;return e.jsxs("div",{className:`cedros-complete-account ${r??""}`,children:[e.jsxs("div",{className:"cedros-complete-account__header",children:[e.jsx("h2",{className:"cedros-complete-account__title",children:"Complete Your Profile"}),e.jsx("p",{className:"cedros-complete-account__description",children:"Please fill in your name to get started."})]}),e.jsxs("form",{onSubmit:f,className:"cedros-complete-account__form",children:[e.jsxs("div",{className:"cedros-complete-account__field",children:[e.jsx("label",{htmlFor:"cedros-complete-name",className:"cedros-complete-account__label",children:"Name"}),e.jsx("input",{id:"cedros-complete-name",type:"text",value:c,onChange:p=>u(p.target.value),placeholder:"Enter your name",className:"cedros-complete-account__input",maxLength:100,autoFocus:!0})]}),a&&e.jsx("div",{className:"cedros-complete-account__error",role:"alert",children:a.message}),e.jsxs("div",{className:"cedros-complete-account__actions",children:[e.jsx("button",{type:"submit",className:"cedros-complete-account__button cedros-complete-account__button--primary",disabled:n||!h,children:n?"Saving...":"Save"}),e.jsx("button",{type:"button",className:"cedros-complete-account__button cedros-complete-account__button--secondary",onClick:s,disabled:n,children:"Skip"})]})]})]})}function _o(){const{config:t,_internal:s}=T.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),l=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),i=d.useCallback(async f=>await l.get(`/username/available?username=${encodeURIComponent(f)}`,{credentials:"include"}),[l]),c=d.useCallback(async()=>{try{return(await l.get("/username/available?username=",{credentials:"include"})).suggestion??null}catch{return null}},[l]),u=d.useCallback(async f=>{o(!0),a(null);try{await l.patch("/me",{username:f})}catch(h){const p=h instanceof Error?h:new Error(String(h));throw a(p),p}finally{o(!1)}},[l]);return{checkAvailability:i,getSuggestion:c,setUsername:u,isLoading:r,error:n}}function Vl({onComplete:t,onSkip:s,className:r}){const{checkAvailability:o,getSuggestion:n,setUsername:a,isLoading:l,error:i}=_o(),[c,u]=d.useState(""),[f,h]=d.useState("idle"),[p,b]=d.useState(""),w=d.useRef(null),m=d.useRef(!0);d.useEffect(()=>(m.current=!0,n().then(j=>{m.current&&j&&(u(j),h("available"),b("Available"))}),()=>{m.current=!1}),[n]);const k=d.useCallback(j=>{const C=j.toLowerCase().replace(/[^a-z0-9_]/g,"");if(u(C),h("idle"),b(""),w.current&&clearTimeout(w.current),C.length<3){C.length>0&&(h("error"),b("At least 3 characters"));return}h("checking"),w.current=setTimeout(async()=>{try{const P=await o(C);if(!m.current)return;P.error?(h("error"),b(P.error)):P.available?(h("available"),b("Available")):(h("taken"),b("Already taken"),P.suggestion)}catch{if(!m.current)return;h("error"),b("Could not check availability")}},400)},[o]),x=d.useCallback(async j=>{if(j.preventDefault(),!(f!=="available"||!c.trim()))try{await a(c.trim()),t?.()}catch{}},[c,f,a,t]),N=f==="available"&&!l;return e.jsxs("div",{className:`cedros-choose-username ${r??""}`,children:[e.jsxs("div",{className:"cedros-choose-username__header",children:[e.jsx("h2",{className:"cedros-choose-username__title",children:"Choose a Username"}),e.jsx("p",{className:"cedros-choose-username__description",children:"Pick a unique handle for your account."})]}),e.jsxs("form",{onSubmit:x,className:"cedros-choose-username__form",children:[e.jsxs("div",{className:"cedros-choose-username__field",children:[e.jsx("label",{htmlFor:"cedros-choose-username",className:"cedros-choose-username__label",children:"Username"}),e.jsxs("div",{className:"cedros-choose-username__input-wrapper",children:[e.jsx("span",{className:"cedros-choose-username__prefix",children:"@"}),e.jsx("input",{id:"cedros-choose-username",type:"text",value:c,onChange:j=>k(j.target.value),placeholder:"swift_falcon_42",className:"cedros-choose-username__input",maxLength:30,autoFocus:!0,autoComplete:"off",spellCheck:!1})]}),p&&e.jsx("span",{className:`cedros-choose-username__status cedros-choose-username__status--${f}`,role:f==="error"||f==="taken"?"alert":void 0,children:f==="checking"?"Checking...":p})]}),i&&e.jsx("div",{className:"cedros-choose-username__error",role:"alert",children:i.message}),e.jsxs("div",{className:"cedros-choose-username__actions",children:[e.jsx("button",{type:"submit",className:"cedros-choose-username__button cedros-choose-username__button--primary",disabled:!N,children:l?"Saving...":"Continue"}),e.jsx("button",{type:"button",className:"cedros-choose-username__button cedros-choose-username__button--secondary",onClick:s,disabled:l,children:"Skip"})]})]})]})}function Do(){const t=T.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),a=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),l=d.useCallback(()=>{n(null)},[]),i=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(w)||w<=0){const m=new Error(`Invalid deposit amount: ${w}. Must be a positive integer (lamports).`);throw n(m.message),m}r(!0),n(null);try{return await a.post("/deposit",{amount_lamports:w})}catch(m){const k=T.handleApiError(m,"Failed to execute deposit");throw n(k.message),k}finally{r(!1)}},[a]),c=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");return await a.get(`/deposit/status/${encodeURIComponent(w)}`)},[a]),u=d.useCallback(async()=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/deposit/config")}catch(w){const m=T.handleApiError(w,"Failed to get deposit config");throw n(m.message),m}finally{r(!1)}},[a]),f=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const m=new URLSearchParams;w?.limit!==void 0&&m.set("limit",String(w.limit)),w?.offset!==void 0&&m.set("offset",String(w.offset));const k=m.toString(),x=k?`/deposits?${k}`:"/deposits";return await a.get(x)}catch(m){const k=T.handleApiError(m,"Failed to list deposits");throw n(k.message),k}finally{r(!1)}},[a]),h=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const m=new URLSearchParams({input_mint:w.inputMint,amount:String(w.amount),taker:w.taker});return await a.get(`/deposit/quote?${m}`)}catch(m){const k=T.handleApiError(m,"Failed to get deposit quote");throw n(k.message),k}finally{r(!1)}},[a]),p=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/public",w)}catch(m){const k=T.handleApiError(m,"Failed to execute public deposit");throw n(k.message),k}finally{r(!1)}},[a]),b=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/micro",w)}catch(m){const k=T.handleApiError(m,"Failed to execute micro deposit");throw n(k.message),k}finally{r(!1)}},[a]);return{deposit:i,getQuote:h,publicDeposit:p,microDeposit:b,getStatus:c,getConfig:u,listDeposits:f,isLoading:s,error:o,clearError:l}}function Zs({tokens:t,selectedToken:s,onSelect:r,openSignal:o,placeholder:n="Select token",disabled:a=!1,className:l="",searchable:i=!0}){const[c,u]=d.useState(!1),[f,h]=d.useState(""),p=d.useRef(null),b=d.useRef(null),w=d.useMemo(()=>{if(!f.trim())return t;const N=f.toLowerCase();return t.filter(j=>j.symbol.toLowerCase().includes(N)||j.name.toLowerCase().includes(N)||j.mint.toLowerCase().includes(N))},[t,f]);d.useEffect(()=>{const N=j=>{p.current&&!p.current.contains(j.target)&&(u(!1),h(""))};if(c)return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[c]),d.useEffect(()=>{c&&i&&b.current&&b.current.focus()},[c,i]),d.useEffect(()=>{o===void 0||a||(u(!0),h(""))},[o,a]);const m=d.useCallback(()=>{a||(u(N=>!N),c&&h(""))},[a,c]),k=d.useCallback(N=>{r(N),u(!1),h("")},[r]),x=d.useCallback(N=>{N.key==="Escape"?(u(!1),h("")):N.key==="Enter"&&w.length===1&&k(w[0])},[w,k]);return e.jsxs("div",{ref:p,className:`cedros-token-selector ${c?"cedros-token-selector-open":""} ${a?"cedros-token-selector-disabled":""} ${l}`,onKeyDown:x,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:m,disabled:a,"aria-haspopup":"listbox","aria-expanded":c,children:[s?e.jsxs("span",{className:"cedros-token-selector-selected",children:[s.logoUrl&&e.jsx("img",{src:s.logoUrl,alt:s.symbol,className:"cedros-token-icon",onError:N=>{N.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:s.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:n}),e.jsx("span",{className:"cedros-token-selector-arrow",children:c?"▲":"▼"})]}),c&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[i&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:b,type:"text",value:f,onChange:N=>h(N.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:w.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:w.map(N=>e.jsxs("button",{type:"button",className:`cedros-token-option ${s?.mint===N.mint?"cedros-token-option-selected":""}`,onClick:()=>k(N),role:"option","aria-selected":s?.mint===N.mint,children:[N.logoUrl&&e.jsx("img",{src:N.logoUrl,alt:N.symbol,className:"cedros-token-icon",onError:j=>{j.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:N.symbol}),e.jsx("span",{className:"cedros-token-name",children:N.name})]}),s?.mint===N.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},N.mint))})})]})]})}function Lt(t,s){return s.privateDepositsEnabled&&t>=s.privateMinUsd?"private":t>=s.publicMinUsd?"public":"sol_micro"}const Xs="data:image/webp;base64,UklGRkACAABXRUJQVlA4IDQCAACQDQCdASo8ADwAPjEWiUMiISEUBFQgAwSgB4Z/TeLt3XMAoQH23eph0gPMB+sn+M9tvngOsA9ADwgPg3/cH9sfZciikEBuA1AB+nf+84CUkAVvA2x4xvyobR+mBaYhjUv/ewHb4hTqOnP38rzsxZX2inOSciAA/v7uqvqGdpWcjjrfMDFaNHumTog38t3yor0kbjn631VsX61cAC749wWuAX74u/f/hpeDFqS/ci8E1g94wk9UVs7BHqtv7f/M9iT1u5ITJV0Gv6tE/CW5j/nVR6yExJ6JoDRDOWQ8zVpWH92r3Lnbnc4WJpOchbRT3H5rv//6PP+F//4ehLUlR/4tkRUKZu/yOa26+sywmY+Xc1X2lXMcUv7+eQ7+FBE7bhKc7htieBfH4eR134AVaILL7PWA2FjzAjfaP1Lgirqoq/ZooE8jVD/b4g3J3O3/TG/4ajHe6clnAI/4NdwrnHX0P/quBU03HqSsQ0qsEMAuhrH/jn+YtDzmjm8q/cGJ44qvi24Hn+G1kxz2XP2S/Gp7ri5cMlo+muuwBjyNJnnEcTt/5cRdYS2cbEBZtpINWj3PuC1EOsd/8cTepSpxODcJHLzktfC1PHW3Pgoh3J5PHjW3TCQ1Wlu/wP8e8OPfNm48BODGChioj3ezblqrOBV+cI+hLi7ReJdvBF/4jY+/Un0asuWnrA6kRNpgOeO8wyl4Ryhkrff+9R1SpyPYP+5T3EuWWLZaCn0bGzyk97S3VAAAAAA=",$l=1e4,kt=1e3,Uo=3;function Gl(t){return Number.isFinite(t)?`$${Math.round(t)}`:"$0"}function Ql(t,s){switch(t){case"private":return{label:"Private",detail:"Private transaction, instant credit",note:null};case"public":return{label:"Public",detail:"Visible on-chain, instant credit",note:null};case"sol_micro":return{label:"SOL Only",detail:`SOL only under ${Gl(s.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function Js(t,s,r){return Math.min(Math.max(t,s),r)}function Kl(t,s){if(s<=0)return 0;const r=Js(t/s,0,1);return Math.round(Math.pow(r,1/Uo)*kt)}function Yl(t,s){const r=Js(t/kt,0,1);return s*Math.pow(r,Uo)}function Fo(t){return t<10?.01:t<100?1:t<500?5:t<1e3?10:t<5e3?25:50}function Zl(t){return t<1?2:0}function fn(t){const s=Fo(t),r=Math.round(t/s)*s,o=Zl(s);return Number(r.toFixed(o))}function er({config:t,valueUsd:s,onChange:r,maxUsd:o=$l,disabled:n=!1,className:a=""}){const l=Js(Number.isFinite(s)?s:0,0,o),i=d.useMemo(()=>Lt(l,t),[l,t]),c=Ql(i,t),u=Kl(l,o),f=u/kt*100;return e.jsxs("div",{className:`cedros-tiered-slider ${a}`,children:[e.jsxs("div",{className:"cedros-tiered-slider-input-row",children:[e.jsxs("div",{className:"cedros-tiered-slider-input",children:[e.jsx("span",{className:"cedros-tiered-slider-currency",children:"$"}),e.jsx("input",{type:"number",value:l||"",onChange:h=>r(fn(Math.max(0,Math.min(parseFloat(h.target.value)||0,o)))),placeholder:"Enter amount",disabled:n,min:0,step:Fo(l),className:"cedros-deposit-flow-input cedros-tiered-slider-input-field","aria-label":"Deposit amount"})]}),e.jsxs("div",{className:"cedros-tiered-slider-tier",children:[e.jsxs("span",{className:`cedros-tiered-slider-badge cedros-tiered-slider-badge-${i}`,children:[i==="sol_micro"&&e.jsx("img",{src:Xs,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),c.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:c.detail})]})]}),e.jsx("input",{type:"range",min:0,max:kt,step:1,value:u,onChange:h=>r(fn(Yl(parseFloat(h.target.value),o))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${f}%, var(--cedros-border) ${f}%, var(--cedros-border) 100%)`},disabled:n,"aria-label":"Deposit amount slider"}),c.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:c.note})]})}const Xl="data:image/webp;base64,UklGRmIEAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IIIDAADwDwCdASo8ADwAPm0qkUWkIqGWDVeYQAbEtgBOmZMBu+H816ov3b8R8R2g2FXtxdyh5s3+A60v0APLi9ktgGB/LZjWNAXqgpE6jfW0NF+P4xEhH2L7M+26iGwrTjjcQegyCZqxs+ifvZANjWd279diqZNKUrgOTVtjJGtW4IVtRhMECd5aWVgAAP7nDv3UY/8f1l//xTP/FM/8NU8c9g//sC3+bX/1HZXsNsM57VKG2LVf1a0KdncWO8uPo/Oh79m9ZqjJZwXfPXuvwkK+WDOl6+N8C2Ux6no/V/zkoucKK/JZek7MR5sS8TknXB+6BuVDXou9Rx4aUea2q2IzvLvFIujjKsVYLMab7j9zo48fhgm9YOtjmWuS0WZ4c+6ta0mr3xF4fcdAIFf6oXRSlqovOX0HUiMV//hXwSX1cfP5cLj8c7OTyT/4ce4olJARV95GoY8oF+2uU0blGul3ItlG7c2Hl2/uC6s2WZc7Zukwojx6ed8t97bZ68N1uzCLzPlG7BuYS17F19e0wXnc6vEl3q7ft0K7OEl7r8mY6Kh+Nt/5V/Lp68mFBjLem1JjvC371+lKwez4KCdXwNo2Z04FqyzGpFutY6YQ/r5Tfu7Oi+oNfN0R/W+D4aj1nqHhlqYJzpx2NK4mj0gJIXmX8EArelSQI8mV4Ux9MRPwC2PuZhLTjQZv+Vl4p0D8bSB+Z0rek3hS6G1r80fW3cn767Pz/bXanjVmm34wt1nQPqdJObrZ7vv2NWcEuQKj9d+V6DzeDrq0CtGNcanEB5MY9agi1E6BprEScTdfPXjBeMnPbpD+QO6P7IW4UZ9etCCHtX++S/fl5Iz5RzUr10ojRMw//35C0yTjSEhbe884dPwor64n//KByjUFEGsCPAAXPJp1+O+SiKfUaODq6ncjKayTHXjoXgM7XP1z4sBhIKJZJRiM7vGC/+v/Sk8/jbgZLZDAVz1vLou93y7Yd8hxcWM/BesxgWgeKvl8fjE/Ud8tQKp4425hWh66lzzwxa4J3ctA4/E50wX/eoBOgq0B7+7S6FK4wvPHSNgfh+vwSWIJsJLt/3yjBeb41RRyMDMZqFQTZPEdFpXp48ExEyDayZ6objbjTHoS5WQDnDQpRyqMNKfvd41nhEPdb/hxpzXeTIjWmfHHCT+CQYWXDqLehCh1cRyeYOBwsSlSw5PiquAbsgAARVhJRroAAABFeGlmAABJSSoACAAAAAYAEgEDAAEAAAABAAAAGgEFAAEAAABWAAAAGwEFAAEAAABeAAAAKAEDAAEAAAACAAAAEwIDAAEAAAABAAAAaYcEAAEAAABmAAAAAAAAAEgAAAABAAAASAAAAAEAAAAGAACQBwAEAAAAMDIxMAGRBwAEAAAAAQIDAACgBwAEAAAAMDEwMAGgAwABAAAA//8AAAKgBAABAAAAPAAAAAOgBAABAAAAPAAAAAAAAAA=",Jl="data:image/webp;base64,UklGRtgCAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IPgBAABQCwCdASo8ADwAPm0wk0ekIqGhKBQMqIANiWkADPF3uV2D8VcQGk1mg+P36i9SLnZvYAQxszEWYzEwX1RVkqG/4BGbJgMSHqhKDFsjWsGfPPrvfef11goNmCDDlBJHVVD+8gAA/vu4q03kl+E7FpjtZ2gc8pQ619Hjv9NywoRZ6az43C1wcrRr/lWzJlJhLWMHN0MkVl1ueAf6Hn8StVzeUfMBXOKkgfe2msx7QWR5PnHW/5c6/35yrtWnrURc2q6UYlGin+v8C2dQqexkW6rX2EEijTI9eEQ46PWH3/59fM2AlMvvR2abaRk5XX7V1triQncRxvMfz5YmYDN+PY/ikcZUNaiFucKoUq5riv0eKCezuFNHecE11ojwJqWRSTWpalkz5autXp6vFS+FT1tWUsB/fs1CCOZxaA1vR1grOEaiuKe1RYm7e05psWtqbXLVmm1bA8Ly9PFkVdCbc6hR3UuBBsFGnVeGOUeMn2onnfvYhBMcM9YPxGdQkwZLXOk1VuQSTk01Shf3fZrFyRlFauftFdPYhKXwqrr+meav1P+KLKBVosqmHnFFfgExsQ/rOf3TSd+mOqQfJA+cF+HojNU7nmM3uDkoCBi+//Gqp+gPNNW8M4LFrol8rxE+7WsjqMgfwv1f+Nr25RtG1Wa/KkniRCAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",ed="data:image/webp;base64,UklGRhYJAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSGICAAABkJz9nzon3/nNJGnBXRvBI0sDkR7slpRBaMDl5LByx7cEyBWHtWd+8/uiK/95uEfEBKBnFwRwk6Wjm89PW2Tj9OWNo7VxASQ4DDoIML9fbdLYpbFR21tykDAY8ZCLT9okqZrsD0uqJNl5sj6CIAPwDmdqRlNlz6o0vroE5/vlPObv0kyN/dVE3pmHd31xgt0P1MgBauTHLYjrg2DoClM0DtRi4kmA6ylgrMq2cuDaZm0CoQePyTqVhVTWJ+G7EozXqSyosj4K6cIhVBhZ2MjyMNy/BFcZWeDIE8g/PLaoLLRyF/4vgrlPTMVK/DQH+cPjGpUFV17/i6BEZeGVF+Dh4F/kUYGDR4nKDBPX4AX381Deh2C1Q8vB2F4CDqnMUrkPlPMpY+obLQ/j9+k1GjNNLB0z5hJ5fD0f5Y2XTLkkPn9Hy8X4vsGMW/xvt3JqvKflYnz3nCmXxJc3qLlEXj9mzOe4xJSLcW36Oy0P47cplKl5KMvAfj6HwFKbloOxswrBfWoOyvsQjzWmPErwcKhQi6d84eHgcSGPEgSA4Dq1aMpr8PjL3CemYiV+moP8AY9darGUW/D4u+CEsUiRVyH4p8NwmbE4kZUA9y8IRuvUoijr4xB06zFZpxZDWZ+ER/cBEzW2dXDaZnUMAb06hBOmaIOxmHhlCILenWDrI6MOIio/7kIc+uk85u+SSftkasZ78/AOffYOl17RqNqbqtFqZ+A8+i8BI+tPOiRNNdkfllSNZPvJRYEXDDQI3NJerUFjl8ZmbX8ekIBBuyCAjK8d3Xh52iBbp89vHl2ecIAEh54BVlA4IMwFAADQGwCdASo8ADwAPm0qkkYkIiGhLhtqqIANiWwAqSdaNo+beZFT37f+J9yXOd2J6HfQh5gH6edIDzAfst6vXoO9AD/Lf4DrAP2V9gDzY/+57F39p/3/7k+0RmjvYp/meic9ieyvJnZVfquF/a23ZOCHGT/sfDDjQ89zOL9Gewd+s3Vh/b32Gf28Ejb5ttLg9hoDiFb2tMW81eZU9Z1LHfdRSCsRMzHz0WT4BNgUakGf9oJtrGtVJFxHJfxAatIxnW1qjDi9i3DQtJp9pVNKlMoJEWdPKv3KaaFSlhd/aMGiir9CPcex5QAA+fpjxA6zfUamE3wS2zWwLVrt/fXA5+Wvx9j5SID0zuEHU2LisPUxvtRuIUwNrsUis8zy+IMpzft+ZSg+9gdx9e6+ZvPmtj4OByz5qo26J3rXhPy8LBXSpuPb+f+mP4CoTvYDhzQXh/SIGj8Ez1+W5MJ/Tkdw09wPCs3JuR3yoqO63FH/j81xW5Abr7tCdwfXwv3CXDtOcHwUqPCd1aiU2uT6XwgdnYqYygEXGKFx8nmaUvqSn9p8HmIA9dVTOoEnqYFjrNfWY034N2vjohd16cxnkP4PYvHkIOWa/FEUug7/qbJ/GFLPxNh6y9eQ//MzzXbcPwsT2chWXPBXNVF1S9dxv5NUuEueiw2kdebblQuvUSRLN+zx3VyT2lOzWBUqrzsTmeOlxjVcTA83H99r35O4X7WXNq7HExiWXxrdM/Ih4CvPJaEHPxUE/i6WIz6+VGq4RB3sBKl3P4M7/DLWAwCnwcpX228XezqQ4cS2tttWxLTc9cPd1ofek9qF9lpB8RvakdPnj2PruFA9W3iKbNdmgnb+mIpohHuUR73KdDDOHbyfAiOjPzzqomnIU3jcSt7LKOB/Op97sCk0yd18mVG3prs351B+xmCE2Zd3RFKL+mpMz5qcuAFAfRyodbggdgmFGkEGQ33VryYFl/upr31FGdI52sqzuxd7jZIsqCcznUH/gu+xaBw7wla49EmFNf+Ss+91i9Hsys0FS//Ktru1xWgkeEweX77y6Oot5tHQsDxgy0sAI85V7FmlpiiWXQdM12MGfCBfyRM+N23SjOdReeSILYCgsM3r33/54X+lfDVNj427MvbDFtKccqazlQ+iKqC//MvYwqyiJPL1ZbVoCEP774fKZA3D3qvsVPGlp9LPchpTs4mTJugt8qXl82RwXQCDNZXnbEois53E35hkRr+IJhndoRo1o2sZDoTgykbeOKiynPH03+BcUQ8zmxTmiVlHQym/LL3kRREnUlxs2zPPGb2E+Rpdib+LxOvFSmj9RfTZoYIJnrqNnBIXV2lt7xeZ0srf98JymJxrtr8lx69oSNZIReDddL+3iiUjh6lm7EcYuclqBaKp8q68geo7H1EvKy4nSRx5Q+uz4l/ypo2hVdwi9l+BHjZZmJ7lXkpNTRJ0gZpzquzN2vh/MZQALV6FZ6q4aofA9AJy1DVLdNjV8n6s9eFA5pazxwhLW4tgWMciGf5x6G7HqFPTL1ZL3l447zLGUkqAXjkeVaNmxZ2oNKIuTy6JDc0Z61Z2dgbsg6HwCX1/ux5sk82WsnNIO4CTnWKI1aCtQZaEsBf6hIl9n7VBsgZGIcPpqn7P4mbyf3EbfdfQ32qlawLuAxmDlwRsVsPkw7j4aKbvIBykNcsVXv0/X6UXXaAtw3feJnTwDak2qY6QpMLE9e7PJeuQQ8FXpqI5HoR82kd+DOwGH5F3OpuWsmEt8v7WQG8q1LMkg6vrl3I8047zMl1Yq0VwotbrsKJocsHgsbs/PGOO9v2s8U0Sju/71XRtG5skcy2msae3wixjlGR4i6ZfldMehQD1zf/FbWN9hnHfpq1Fh8+PSA9AzUi33qli8ixISbH+tw7CcumxvegMk88HMNZlVdnIEzIfyHrSdZ2S98yX2OYZw0+JyaBbQxI0fOr6KpuMD6FVGLrdN9dgOTgOPQgAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAADwAAAADoAQAAQAAADwAAAAAAAAA",td="data:image/webp;base64,UklGRo4EAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSA4CAAABkGXb2to2V9/v6D1Jmd5CQ5GXPYXAJMrtPOJMoMzMzDgIPYY5+vVds6T/m0BEOGzAtm1IBlR2d8kXUMyaADjeuHr9V7qj3E5/XrvaOA5AHCqzFgHTFz9tUTmEyq1PF6cBqVWDOLjkwS6VPsu8KqnaewRU7j5KIjipgFiQfCf1IGch8wMlv9QhcWk4nLlL9Z4l6b3y7hmUvGQkmF1nnrMC85zrc5CozDUQtwamisNSDCmxjL5jpqxMzfhutFCCY3+5110CaI9/jhVIcPg/DxiIB/x/eKgijLxkRobTyxFEw7zVm0NqcYg5LNAzKD3n4QbmyRVqWCiXJyD9uN7z0Ha9Dw4N5gzOnHU4IMJ7egt8HuYWasIJnlg46fkYgul9qgWU+9PA2Z7b2FngnR3e49Qm1QbKzVPNnltZ8wozK2S8et0SN34wt0LOnynVCsp02xI7tKSqqXYsV7ZtD/lpeaEfNyw/k9evWuKK7XfQ9ruP9/RW/s74t872N1bw2MY8n0Acmlb/KQ04AJ8t5PkeEbpDnbmR2/5392FiOfRFlCuTkIGsMh/aPBeGZFLBYuiM1IIUZLOD0NnMNBMWZdE/4bLo32MQ0wxcJnsvhcnerRhSLvPPhcj8s5DIsmtU6Tj1L1U6zvcEElfrVlHyqGy3epC4om5Vsg3OlO50UQ2V6Qa65LWf6TZ1J/11faBLlpgAVlA4IJgBAADwCQCdASo8ADwAPm0ylEckIyIhKAoAgA2JaQATzh4OcBkEByVmbl5z9gD9U/+J2APQgLaX4twLu19/UVxAWN1IKXE4cIqJBhoyQ0yDYn61m3zk6T7FMg0AAP78+EMvGgC8jLXmcbbmqvufKjG8Tv1M9Krl47vOW74O/Rapv2DgXbg9iK6PrRQG/9d9+rF/ESxzbszVFn3GThrMBmsklj/LPWDQ0pKzG7EyjQL6p6gfUwMze+wPhzJpn8tMqlUVgq6/QSUVcgG+ztsi73rA3vl3n4baeF1INsbuosTXtnsotVYuTii6rscx9OUTvevYcPNvcL9MPhyWeCQw0qynnGtzCIw+oFRN0+TN1mqXkFyk/rFBcH+FHiI6s9XX5EWCKn5vTRt/0RbS687PiXPFC5Zk/Gk4+538IYi+HZDjvlQQWOH/vddfYTerQ5QqWJt1YuaZNThQ2u+/DtXfZPRy1iWWLR9SKFFtlGrqBKWF5nPRPWWMNA3OssvUtvCNBLBA4cn1whzy+SpbgLvnaepxiykjKsU/MhzgAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",sd="data:image/webp;base64,UklGRqwEAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSL8BAAABkGvbtmlLc5997yvbmW19gBnbDm2kjF5UmW3bthXZVZFdZ+81r+87Z1XlEaHIbSNlMstwos4XUBSTLAFQo/u01Zdf/yLDDze3zB/YwADJEoOoJAKg7oTdH4SF+XxiZlMgSESzwAJdVn2iUJzzOUMiLhQKf+/va2FtBLMBuu1zpHcsincUXhtoTKLsCTVX/KF3wrLhPLm/OWzZtjQWfZ7RhYyAC/lxMowpSzJYJAyFkZDQc21FBMUT7BqGjpHxf3m+XlEPUHE/f3vGgPzmw4awRUaTexkyJhwfNShctVgZXyJDXq4CUyjNy6Y4fVOBIkAPR2GcOE7Jm2NQ/RE9YzXht3a5VYvlOX0xF0fy+tp/ozBuQg6DzZYb6Bi7ed4rB5Mp/1Co4cNhLUo1StLxDIDqrynUoRswiF6nFnIxsDpnZ5WBW0GFZ1qZ8HfLDk5txHHsGDpSa6B0cXZEa+DsTr1M+P4qPdXwjynU4+1/a7oN3Sm6G+meSd27oHsHde++7puj+tYpv7G6b7vun6L7l6n+oZp/t7JmUNUqqhpJV5upakJVLaqqgVW1t6rmV401NGMc1djqH4rpIseSfyPFkgAAVlA4IAQCAABQDACdASo8ADwAPm0yk0akIyGhJgzogA2JaQAThroHvLxu+aPf5G2BYxv+B6XHzx6GPon/o+qz/tOAA/TM82gR0vnExWoiQRM36jlg2UIvwCSqySErzuguz9EP2x/7hsNazr91aIworWI7AAD+/TZ+6Ipl444OdT+2wU0Ov+T8oJuVP/vUbT/w1Jsv6Awnl6rvF/xetfOPt3gTQZZi0Y/AOx563J7CJkqTR/fc/n34zyeKzR80fhfv4ef+Hjhz/CX5aQo+58zg/FdE+7bLoophGfG0szI513EH+q+Gc73H1PFdJYf7CF8v5dhr3tMwEVX5Ji2ZxejK8xrf/E6nVXqlA4DrYNRP09InHc+fEqO/fH8xr+rMf4y1F9TOnwVffZblLoTP6lot0m/sh7sTiDQr0mIA8TiHoOffGDG6KzV+B3239udfhzD740gkRi/m53abX0Ku3vAgadgFFqL0vk8M/4aI+cI+0fbLW17mWGeMu21wSRRQiv5iNgGKR3vEGXAItcLDft1uUzWAfbe1X3zK/ymT7bA/76PB6UUknm+Y5MM4osurUXU/k7P38pN/3slnGfpFzjl4c3USY4mH9ZCJYUuC/kGEnq/yRPalPdODNFvW6s8MiQeQejYNRY0LsJ0WXkK8vXiDmihCivYAOPoSovesL7on+WAArDNM/BcQSQvCYABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",rd="data:image/webp;base64,UklGRnIIAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSK4BAAABkHPbtrE9+z73/RTbqWw7Lf+BbbNKbTudbZe2qy+VbVv3PmeHj05G6ohg4LaRounNMtN1voB42ABA5R7TNlx5+O7du9e3Tiwb0b4EgFyAOCQM1Z16+DWFUZC7m3uVB2zKQGBhe+77RGHonJffCL1zQuHDxQ1hrEmTatDjHIXOC2MgzpNf1tVJkWgsGhyihI7JIE74aUYp2ITFAoz9QO+ZAs7zanvkEilKbIkMJS5ANwoJmrCodYVOmBqh5zIEJjZc9xods4A4rrPGxGitrJSU71yNyH4Myl7JTEl+5zzYSH9nlkrxHBzxWUzLVEnhh+YI/gq3+UphpvA8m/s7/wg9M4bjFNg/0vplrxQ+rQEDg/xihmT23jxYJZ8UPq8OA5z77Wt405FDR4poSMjiAJhPRxUIu8D+UVonOhfNPEVHPM9juFacwo+1V6kJQ3Y9Sa8ljhPuUvRk4UdNWU9ST3b9n0W3iG5DumdS9y7o3kHVu6/75ii/dbpvrO7brvtPUf2X6f5DVf/dmpxBmauociRVbqbKCXW5qCoHVuXempxf1dZQtXFUbat/yKZTtSUBVlA4INwFAABwGgCdASo8ADwAPm0qj0WkIqEZ+zYAQAbEtgBOmZoZF+E8zGoP3X8VbcdLvma8t+jH0E+YB+ofSA8wH7VdQv0AP75/iOsG9ADy3/Y5/b/91fgI/Y7MOesb0e/q+TUR1vt7VO6mwG0imO70GM5/0P7BX6qelv7EP209lz9oDRea09ZR+SjhX7sBu/ZS7tG917rPgI3Q7XsB7luy2hAg/95C2Z1L362OH1oFziDY/K5gWoSytSAtiKvA/jW1MehBzdLzJfszPPBvGa15IYwIVRTjO2Hz5ZS9HjLMehwAAP64SgjD3qeg6NRe/Ok+iFhrG3pgglCfbam3yBaDUH36sUiQx0PB1ZZyOHq0ky+f97h6tJMvo0p9LkfXecWOFJ8J5G7yRPuL4tzGLT09QulTJw42xp2hd+lMgIa51XoHx/iftn8B2D3k92H5jOQr+uIXFHHK5FpcTG+qGEF+np0LiQa+vdW7/+ZzOLVRf7jR5X3ANPt93Ng92DW7NflVr6kMr88O/v2ZNb0vtgao2Am/R3CDKiNq89f86CT6r2L2g1oTui7H3E1yhSPQpEOz01I3fhfiMMv4weqKuoedxn/xLg5uzHa6Gte4C/dQYkG3ZFSy4CXQtRjftBrjX/Oj+HpSUPDsv0wPW+ml5NbBKDCj2f3SD8TVMf2ZfHrOkR602RVk2UmKC+H0Y9iK6k98vsgPINtz0II8X7Mj2nJkTC6IMLuQ8dNTUq9VXOnhXrdhNZoaH94ePo6baBl3hTGFAnD3/b+gR/vtbqV7wktuX6fpnjeTBe/Drp6z3neeANj/aX4CsU9w67nwYOjZhueCjxaDKUnNjLPjI1e0BoTbcOzOQ0wHJHZJ+Pt608StBu4HiJ8NjH46fnvXL3yiMoSvkAuwCE1AakA+eU1u3unyjl1/MnZQmbp8fzfsfrFesehLPcIkYdCiZ+52QbmINNTjEsvjuBuZRubBE+Laihppsxoo4efGIo0xkw0etu1+yzvkqp88w3pBq0mRl13gnnc+2zl6SmhwgmNFbz+F8qAqmdfJL8iaNSGEWlPlpczDDe62GBZMlBhQmq/XCn/1b+VazHvJXkoIFDF+wktMg+rKfLyfTlXdK0cs+Kn8h+rjMakkf3WLo1TftMLn+O+x/Gat+BGstJrM1xvCSSnHQY+NV4B4gRqyZ55gRNnqN/0lWrATOcHUaGXpkTIM/yxFjxcePcSFo+t2aJ5lShtVukETzRxaIXgRkpROeWQHWpTHOaexmXOzF0b833qJSoXMk2zB/uMrgDzKd7d3ohUz8Ra08WYKlAuMQD08bF4+jUepEspqPLoYLQ73TfmL+1LwKxyTV3gEu6WnxBPWPLnYIGYN9U47ZNlB+NgHgYtKTyii6060RAG+wN32WUVFxCZw0HMHnHFgwxD34L/anlpS7mOrjKgyuGYhFC7iHqTQHuoAO1ekBHV+rndnbETKfa1F7LxNLYq+dmJyytmQrJUCGjelorI1m/TMQNiFVrY4FCI1Gl2W1JsZsw9zA+Bh3JmjkC0H5/0JV6JotNMatJIZ4v5PqwJe3r8xd+FNS3ynccdu+xtVdc27qwVdoomciZD5oXYey9KAFSAKO594sBKZNWUJTLXnt0BJbdF8FkQYvg3DQajYY2p+ixd5Ag7o92gw0pVVDDOP+WQxiEmKqgWJyTBsnsBk2Bxi2Unsv8S/4PmE8Hy/vy+Mij+aTAKZvg716IHfHX0/JMeFfmAnsZ39Q0qkfdPtq6+CxbGZ7wKDsK/8l/MVGuyd6faJFt5wyoOXuNrr3JC9EoBmjcOzkVw/6RNP49poZ1xzsX3q7B4HGfI/XSfRQq3HeZ2j12d0E3gCAube4oExaT1sx/v8F+f61QOsGdSaqM2im6qOGkSRkrRQ7L8hvS8vEYJeVkAbFvX5ov7e/egYYNToMHj651c5/rCVYtB9Ned6GvGN8R0x3t7+lsf8+ofhHRzpyvwxd6c5pREZVOKnXzplhJ61mki4JmAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",nd="data:image/svg+xml,%3csvg%20width='88'%20height='88'%20viewBox='0%200%2088%2088'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='88'%20height='88'%20fill='url(%23paint0_linear_170_79)'/%3e%3crect%20x='25.6665'%20y='25.6667'%20width='11'%20height='36.6667'%20rx='1.83333'%20fill='white'/%3e%3crect%20x='51.3335'%20y='25.6667'%20width='11'%20height='36.6667'%20rx='1.83333'%20fill='white'/%3e%3crect%20x='29.3335'%20y='40.3333'%20width='29.3333'%20height='7.33333'%20fill='white'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_170_79'%20x1='-75.3077'%20y1='-55'%20x2='146.302'%20y2='148.167'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF00FF'/%3e%3cstop%20offset='0.531673'%20stop-color='%237A84FF'/%3e%3cstop%20offset='1'%20stop-color='%2305FAFF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",od="data:image/webp;base64,UklGRh4HAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSNwBAAABkFxbexpJnyR3z8y+ajXMkAnjnnOgbUUxEAHjkpldWQwzFUn6v3PGVNI/AUQEA7dt49gN3PXavTlfQDeNAeyqg4PL5buRyOhteXlwcJWtHU8qzUIBs+30g7/s4N8Hp7cZFAtpDc7Bbr8xplB8iFJBYvBC4fjGdgvnElqdwc6XFPGRnQxehC93wjgzbxRYf1UYA+dkiJSrG1DMV6zDoW+MkQmMkd8Owdl5AsvOM3gm0geeXwY7R/Tu0EcmM3re6cF2Rr/kTJiBMmPZh+2q/wtm4ozD9qrB0tucMhunvL0Upg1n6JmRnmda4HCckVkZeRyuMWjjF0peCD9vhK3jAgMzM/BCDQ576225m/bCwcA+qzS/PLUwDrsr1ZDdcAa3KtWQWzDYPKZoQDjeDJyoVEdOAPf0cA/Lf1F0IPy1fG8VWmXvgF4LnoOLDFoIvPiaUQuRr99pNr8dUZEj0YToQnfjreaQd7oL6T6Tuu+C7juo++6rfnOUv3W631jNb7v+P8U+1ZDAZxZG9R+q/e+GxcbPuRcRftkIq+pVVD2Srjdr94TDnJ6w7MGqedFhH1bVA6t67zk9/3ctzw+YAhvSc431KExyjjNHQ2zLcTRzq/8op0vKJd+OREbvUnJJAFZQOCBaBAAA8BUAnQEqPAA8AD5tMJRHJCMiISgb+1CADYlsAJ0zIUCfxfmY2f+0b2AbztDnPeKX0qPMp+wHrDehz0AP7J/o+tP9ADy3f23+C79yPYA/aqK9mONrQbuszbsEyALJNTfg+Z6NjG2v+ETCuvlr1q6QUqEiAMUndG/WwfnjJIOTfOBS4W1w0HjOJa1XQ2K33n2b07EOjOBapwKzyoA2erTBTnEKlFjllBy68GBjZ+UKnlzN/f5ibbb4gAD+i9OsnW0xUnmTpyhVasIKzTu0BsXnfBm4rHJqGMFJBUgTESDXEPcNjAeaHP8ck9qdNBH4L/h53tXgHeZttc7c4lwTa6U4Lziz8qUoy8ce0IMc5TFElawGj16tME0GzSSbUqgH7/tYA6huPsWM2z3GjP8b9y7paRbINxwYRtuE90I6QVsNrEkbhL1YfwxRXnuobOfSe3KFVamrvsOqwTCMqlNfjsR3pyoiZ+lYt3+AH6x4ZVNltbYI5KiVhgCu1isooK324ldloH3zhlefYKEwTCYfNjbeH5UiL7JSev+t/C+ftc3TkAHcsvrLCU6n5pYYY2Yr1kRq+r6XVzI6iXuA/TqwMk6xq1PmdzHOwKavncLjWJrk0uU/5E5WKqXM0tgl5s3pduHjb5aiAt0ikEisMyYwnIhDiSemPRdGON4RlwSb3OEpZjhuZqoyen4Sw/fULewt3hAZizeiPZx1o9LS3M/4r3v/M6/o5925VJcmxAf/yjsyjCz0mV+6NuIeWp8shrFaIGgeduVJoZ0Kys1WjSLuFg9QvF5LlkOZ2k7WrzSu4ucsUOS/X4wnQvB0RCnR1PCsU4NDdLfxvQITUgGIuVTJ7LR73PHzZam/Z21oy3euiU55ffITekwjR4SgVoPvhxbdBSyVePf/twm62pSK9IfgPGN+ttubhQub1ooVZymdQCrS3goEs6dlnl/6TVfkgxFyBfAORkZafeu/Va2vIgUBNUQd48W8oPiMFjx+SAKx1qm2IwCLnuhJGf9M4nCzu7oo43f+nBeT07IjB+FpFKRGFNvlpLEXhPclSgFkqeU1W2eNqW2zShCWkQkgfE1HAoNX3z+CQcRQJq+HkC2nSjFdFYT8UNYNS6lYcyVWzEnOos1qpsNRxnLqY2Dl5CCT3Yeg/qT8chfF9ZadFvzNTEIDlARoN//7IU23MtuLdpsAjsiGfBHuR7y4lemYPdD/9Cuff9Qn/r/xlhmB5x2Y9Z1yME3aANAb5+u3lYz01zUlWwakKVmv9fhaeu/YzQ7BXLlcb+cbaIF5t/COmObnt20zaTfjad542f7p7f2Xea134nvyPYS+EAgjM+GufHvl9tXCrrRbH0pn7kH2XEGx9VbO4mY54+QZa5kPr0j3AOEtKd7SJWjlg5TQfgIuB6KoLGainSwF+pPdiCmzEzAOa1eFwn//2VdDMeq42/bKH8U4orewhLh60ci/S0BRBuItNMc+v1+vxl0YyS5it4AAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAADwAAAADoAQAAQAAADwAAAAAAAAA",ad="data:image/svg+xml,%3csvg%20width='868'%20height='868'%20viewBox='0%200%20868%20868'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='434'%20cy='434'%20r='434'%20fill='%231B262D'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M234.563%20184H640.697C650.387%20184%20659.339%20189.164%20664.172%20197.542L782.495%20402.657C788.631%20413.294%20786.808%20426.72%20778.056%20435.346L452.368%20756.327C441.818%20766.724%20424.846%20766.724%20414.296%20756.327L89.0484%20435.78C80.0927%20426.954%2078.4157%20413.136%2085.0013%20402.433L211.48%20196.884C216.405%20188.879%20225.146%20184%20234.563%20184ZM588.257%20275.577V333.129H472.567V373.032C553.82%20377.296%20614.782%20394.81%20615.234%20415.802L615.231%20459.563C614.779%20480.556%20553.82%20498.069%20472.567%20502.333V600.259H395.746V502.333C314.492%20498.069%20253.531%20480.555%20253.078%20459.563L253.081%20415.802C253.533%20394.81%20314.492%20377.296%20395.746%20373.032V333.129H280.055V275.577H588.257ZM434.156%20472.268C520.868%20472.268%20593.345%20457.459%20611.082%20437.683C596.041%20420.912%20541.636%20407.713%20472.567%20404.089V445.867C460.187%20446.516%20447.336%20446.858%20434.156%20446.858C420.976%20446.858%20408.125%20446.516%20395.746%20445.867V404.089C326.676%20407.713%20272.271%20420.912%20257.23%20437.683C274.968%20457.459%20347.444%20472.268%20434.156%20472.268Z'%20fill='%23009393'/%3e%3c/svg%3e";function Oo(t){const s=t.toUpperCase();return Pt.find(o=>o.symbol===s)?.decimals??6}function id(t,s){const r=t.toUpperCase(),n=Pt.find(a=>a.symbol===r)?.decimals??s;return n===void 0?2:r==="SOL"?4:n===6&&r!=="SOL"?2:n>6?6:n}const Pt=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:Xs},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:rd},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:ad},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:ed},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:od},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:sd},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:nd},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Jl},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Xl},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:td}];function cd(t){return t.companyFeePercent>0||t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap"||t.feePolicy==="user_pays_privacy"}function ld(t,s,r){const{feePolicy:o,privacyFeePercent:n,swapFeePercent:a,companyFeePercent:l}=t;let i=l;return r||(o==="user_pays_all"?(i+=a,s&&(i+=n)):o==="user_pays_privacy"&&s?i+=n:o==="user_pays_swap"&&(i+=a)),i}const pt=1e9,He={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:Xs},Ve={mint:"other",symbol:"OTHER",name:"Other",decimals:6},Wo=1e4;function dd(t,s){const r=s<t.publicMinUsd,o=s>=t.privateMinUsd,n=[],a=!r&&o&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_privacy")&&(t.privacyFeeFixedLamports>0||t.privacyFeePercent>0),l=!r&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap")&&(t.swapFeeFixedLamports>0||t.swapFeePercent>0),i=t.companyFeeFixedLamports>0||t.companyFeePercent>0;if(a){const c=t.privacyFeeFixedLamports/pt,u=t.privacyFeePercent,f=c*t.solPriceUsd,h=s*(u/100);n.push({label:"Privacy",solAmount:c,percent:u,usdAmount:f+h})}if(l){const c=t.swapFeeFixedLamports/pt,u=t.swapFeePercent,f=c*t.solPriceUsd,h=s*(u/100);n.push({label:"Swap",solAmount:c,percent:u,usdAmount:f+h})}if(i){const c=t.companyFeeFixedLamports/pt,u=t.companyFeePercent,f=c*t.solPriceUsd,h=s*(u/100);n.push({label:"Service",solAmount:c,percent:u,usdAmount:f+h})}return n}function qo(t,s,r){const o=dd(t,s),n=r===0?0:r<.01?.01:r;if(o.length===0)return r===0?"No fees":`Total: $${n.toFixed(2)}`;const a=o.reduce((w,m)=>w+m.solAmount,0),l=o.reduce((w,m)=>w+m.percent,0),i={fee:7,sol:8,rate:7,usd:8},c=w=>{const m=w.label.padEnd(i.fee),k=w.solAmount.toFixed(4).padStart(6).padEnd(i.sol),x=(w.percent.toFixed(2)+"%").padStart(5).padEnd(i.rate),j=("$"+(w.usdAmount===0?0:Math.max(w.usdAmount,.01)).toFixed(2)).padEnd(i.usd);return`${m} │ ${k} │ ${x} │ ${j}`},u=`${"Fee".padEnd(i.fee)} │ ${"SOL".padEnd(i.sol)} │ ${"+ Rate".padEnd(i.rate)} │ ${"= Total".padEnd(i.usd)}`,f=`${"─".repeat(i.fee)}─┼─${"─".repeat(i.sol)}─┼─${"─".repeat(i.rate)}─┼─${"─".repeat(i.usd)}`,h=("$"+n.toFixed(2)).padEnd(i.usd),p=`${"TOTAL".padEnd(i.fee)} │ ${a.toFixed(4).padStart(6).padEnd(i.sol)} │ ${(l.toFixed(2)+"%").padStart(5).padEnd(i.rate)} │ ${h}`;return[u,f,...o.map(c),f,p].join(`
|
|
2059
|
-
`)}function ud(t){const s=[],r=t.privacyFeeFixedLamports>0||t.privacyFeePercent>0,o=t.swapFeeFixedLamports>0||t.swapFeePercent>0,n=t.companyFeeFixedLamports>0||t.companyFeePercent>0;return r&&s.push("Privacy Cash fee"),o&&s.push("swap fee"),n&&s.push("company service fee"),s.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function Bt(t,s){if(s<=0)return 0;const r=s<t.publicMinUsd,o=s>=t.privateMinUsd,n=ld(t,o,r);let a=t.companyFeeFixedLamports;r||(o&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_privacy")&&(a+=t.privacyFeeFixedLamports),(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap")&&(a+=t.swapFeeFixedLamports));const l=a/pt*t.solPriceUsd,i=s*(n/100);return l+i}function zo(t,s,r){return t==="sol"?"SOL":t==="single-token"?s.symbol:r.some(n=>n.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function pn(t){return t.map(s=>s.trim()).filter(Boolean)}const hd=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function tr(t,s,r){if(hd.has(t.symbol))return 1;const o=s.tokenPrices?.[t.symbol];if(o&&o>0)return o;if(t.symbol==="SOL")return s.solPriceUsd||null;const n=r?.[t.symbol];return n&&n>0?n:null}function Ho(t,s){return t.toFixed(id(s))}function fd({config:t,currencyMode:s,depositMethod:r,tokens:o=[],defaultToken:n,minAmount:a,maxAmount:l=1e4,onSuccess:i,onError:c,onCancel:u,onUnlockRequired:f,onAuthorize:h,className:p="",showStepIndicator:b=!0,pollInterval:w=5e3,demoMode:m=!1,demoAutoConfirmMs:k,tokenPriceUsd:x,showExplainer:N=!1,siteName:j,explainerConfig:C}){const{deposit:P,getStatus:g,error:v,clearError:A}=Do(),y=_.useWallet(),L=pn(t.quickActionTokens),S=pn(t.customTokenSymbols),B=d.useMemo(()=>{const W=t.customTokens??[];if(W.length===0)return o;const G=new Set(o.map(J=>J.symbol)),K=[...o];for(const J of W)G.has(J.symbol)||(K.push({mint:J.mint,symbol:J.symbol,name:J.symbol,decimals:J.decimals,logoUrl:J.logoUrl}),G.add(J.symbol));return K},[o,t.customTokens]),E=d.useMemo(()=>{if(S.length===0)return B;const W=B.filter(G=>S.includes(G.symbol));return W.length>0?W:B},[B,S]),M=t.privateDepositsEnabled,R=r?r==="sign"&&!M?"receive":r:M&&y.hasExternalWallet?"sign":"receive",F=L[0]?B.find(W=>W.symbol===L[0]):void 0,U=s==="sol"?He:s==="single-token"?F??B.find(W=>W.symbol==="USDC")??B[0]??He:n??F??B.find(W=>W.symbol==="USDC")??B.find(W=>W.symbol!=="SOL")??B[0]??He,q=d.useCallback(()=>N?"explainer":"unlock",[N]),[O,I]=d.useState(q),[D,H]=d.useState(U),[Y,oe]=d.useState(""),[be,fe]=d.useState(null),[$,V]=d.useState(null),[X,ue]=d.useState(null),[je,or]=d.useState(null),[Mt,Ge]=d.useState(!1),[Go,Rt]=d.useState(!1),[st,ar]=d.useState(null),Ue=d.useRef(null);d.useEffect(()=>()=>{Ue.current&&clearTimeout(Ue.current)},[]),d.useEffect(()=>{I(q()),H(U),oe(""),fe(null),V(null),ue(null),or(null),Ge(!1),Rt(!1),ar(null),A()},[s,R,U,A]);const Qo=a??t.privateMinSol,Ko=l,rt=parseFloat(Y),ir=y.status==="enrolled_locked"||y.status==="enrolled_unlocked"||y.status==="unlocked",Tt=ir&&y.isUnlocked,It=ir&&!y.isUnlocked,cr=d.useCallback(()=>{let K=R==="sign"?[{key:"unlock",label:"Authorize"},{key:"confirm",label:"Send"},{key:"signing",label:"Signing"},{key:"success",label:"Complete"}]:[{key:"unlock",label:"Authorize"},{key:"show-address",label:"Send"},{key:"waiting",label:"Confirming"},{key:"success",label:"Complete"}];return N&&(K=[{key:"explainer",label:"Info"},...K]),K},[R,N])(),Yo=cr.findIndex(W=>W.key===O),lr=d.useCallback(W=>{H(W)},[]),Zo=d.useCallback(async W=>{if(!h){I(R==="sign"?"confirm":"show-address");return}Rt(!0),V(null);try{const K=await h(W,R==="sign"?rt:null,D);ue(K.sessionId),or(K.depositAddress),I(R==="sign"?"confirm":"show-address")}catch(G){const K=G instanceof Error?G:new Error("Authorization failed");V(K.message)}finally{Rt(!1)}},[h,R,rt,D]),Xo=d.useCallback(async(W,G)=>{A(),V(null),I("signing");const K=W??rt,J=G??D;if(!m){if(It&&f){f(),I("confirm");return}if(!Tt){V("Wallet not ready"),I("error");return}}try{const he=Math.round(K*Math.pow(10,J.decimals));if(m){await new Promise(Dt=>setTimeout(Dt,1500));const pe={token:s==="sol"?null:J,amount:K,amountSmallestUnit:he,txSignature:`demo-tx-${Date.now()}`,sessionId:X||`demo-session-${Date.now()}`,response:{sessionId:X||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:he,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};fe(pe),I("success"),i?.(pe);return}const ke=await P(he),Qe={token:s==="sol"?null:J,amount:K,amountSmallestUnit:he,txSignature:ke.txSignature,sessionId:ke.sessionId,response:ke,method:"sign"};fe(Qe),I("success"),i?.(Qe)}catch(he){const ke=he instanceof Error?he:new Error("Deposit failed");V(ke.message),I("error"),c?.(ke)}},[P,rt,D,s,m,X,Tt,It,f,i,c,A]),Jo=d.useCallback(()=>{I("waiting")},[]),_t=d.useCallback(async()=>{const W=je||y.solanaPubkey;if(W){Ue.current&&clearTimeout(Ue.current);try{await navigator.clipboard.writeText(W),Ge(!0),Ue.current=setTimeout(()=>Ge(!1),2e3)}catch{const G=document.createElement("textarea");G.value=W,document.body.appendChild(G),G.select(),document.execCommand("copy"),document.body.removeChild(G),Ge(!0),Ue.current=setTimeout(()=>Ge(!1),2e3)}}},[je,y.solanaPubkey]);d.useEffect(()=>{if(!(O==="confirm"||O==="show-address"||O==="waiting")||!X||m)return;let G=!1,K=0,J=0;const he=360,ke=5,Qe=async()=>{if(!(G||K>=he)){K++;try{const pe=await g(X);if(J=0,pe.status==="completed"||pe.status==="detected"){const Dt=pe.amountLamports?pe.amountLamports/Math.pow(10,D.decimals):0,ta=pe.amountLamports||0,dr={token:s==="sol"?null:D,amount:Dt,amountSmallestUnit:ta,txSignature:pe.txSignature||"",sessionId:X,response:pe,method:"receive",depositAddress:y.solanaPubkey??void 0};fe(dr),I("success"),i?.(dr);return}}catch{if(J++,J>=ke){V("Unable to check deposit status. Please check your connection and try again.");return}}G||setTimeout(Qe,w)}};return Qe(),()=>{G=!0}},[O,X,m,g,D,s,y.solanaPubkey,i,w]),d.useEffect(()=>{if(!m||!k||O!=="waiting"||R!=="receive"||!je)return;const W=window.setTimeout(()=>{const G=st??t.privateMinUsd,K=D.symbol==="SOL"&&t.solPriceUsd>0?G/t.solPriceUsd:G,J=Math.round(K*Math.pow(10,D.decimals)),he={token:s==="sol"?null:D,amount:K,amountSmallestUnit:J,txSignature:`demo-tx-${Date.now()}`,sessionId:X||`demo-session-${Date.now()}`,response:{sessionId:X||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:J,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:je??void 0};fe(he),I("success"),i?.(he)},k);return()=>window.clearTimeout(W)},[m,k,O,R,je,st,t,D,s,X,i]);const ea=d.useCallback(()=>{I(q()),oe(""),fe(null),V(null),A()},[q,A]);return t.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${p}`,children:[b&&O!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:cr.map((W,G)=>{const K=Yo>=G,J=W.key===O;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${K?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${K?"active":""} ${J?"current":""}`,children:G+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${K?"active":""}`,children:W.label})]},W.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[O==="explainer"&&e.jsx(pd,{siteName:j,config:C,depositConfig:t,currencyMode:s,token:D,tokens:E,onContinue:()=>I("unlock"),onCancel:u}),O==="unlock"&&e.jsx(md,{token:D,tokens:E,currencyMode:s,depositMethod:R,isAuthorizing:Go,error:$,onAuthorize:Zo,onBack:N?()=>I("explainer"):void 0,onCancel:u}),O==="confirm"&&R==="sign"&&e.jsx(gd,{token:D,tokens:B,quickActionSymbols:L,customTokenSymbols:S,currencyMode:s,minAmount:Qo,maxAmount:Ko,depositAddress:je||y.solanaPubkey,walletReady:Tt||m,needsUnlock:It&&!m,copied:Mt,isListening:!!X&&!m,config:t,onCopy:_t,onTokenSelect:lr,onUnlockRequired:f,onConfirm:(W,G)=>Xo(W,G),onBack:()=>I("unlock"),onCancel:u}),O==="signing"&&e.jsx(wd,{depositAddress:y.solanaPubkey}),O==="show-address"&&e.jsx(bd,{token:D,tokens:B,quickActionSymbols:L,customTokenSymbols:S,tokenPriceUsd:x,currencyMode:s,depositAddress:je||y.solanaPubkey,copied:Mt,isListening:!!X&&!m,config:t,onCopy:_t,onTokenSelect:lr,onAmountChange:ar,onSent:Jo,onBack:()=>I("unlock"),onCancel:u}),O==="waiting"&&e.jsx(yd,{token:D,depositAddress:je||y.solanaPubkey,copied:Mt,feeLine:st?(()=>{const W=Bt(t,st);return W===0?"No fees":`Fees: $${Math.max(W,.01).toFixed(2)} total`})():"Fees: calculated after deposit",onCopy:_t}),O==="success"&&be&&e.jsx(xd,{result:be,config:t,onNewDeposit:ea}),O==="error"&&e.jsx(Ad,{error:$||v||"An error occurred",onRetry:()=>I("confirm"),onCancel:u})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${p}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function pd({siteName:t,config:s,depositConfig:r,currencyMode:o,token:n,tokens:a,onContinue:l,onCancel:i}){const c=s?.title??"How Deposits Work",u=s?.exchangeName??"Coinbase",f=Ms.sanitizeExternalUrl(s?.exchangeUrl)??"https://www.coinbase.com",h=s?.showExchangeSuggestion!==!1,p=zo(o,n,a),b=t?`${t} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",w=s?.body??b,m=cd(r),k=ud(r);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:c}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:w}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-content",children:[e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-shield"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Private & Secure"}),e.jsx("p",{children:"Your deposits are protected by cryptographic privacy technology."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-bolt"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Fast Transactions"}),e.jsx("p",{children:"Solana transactions confirm in seconds, not minutes."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-coin"}),e.jsxs("div",{children:[e.jsx("strong",{children:m?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:k})]})]})]}),h&&e.jsx("div",{className:"cedros-deposit-flow-explainer-exchange",children:e.jsxs("p",{className:"cedros-deposit-flow-explainer-exchange-text",children:[e.jsx("strong",{children:"New to Solana?"})," You can purchase ",p," using your credit card at"," ",e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:u}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[i&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:i,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:l,children:"Continue"})]})]})}function md({token:t,tokens:s,currencyMode:r,depositMethod:o,isAuthorizing:n,error:a,onAuthorize:l,onBack:i}){const[c,u]=d.useState(""),f=zo(r,t,s),h=p=>{p.preventDefault(),c.trim()&&(l(c),u(""))};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Authorize Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:o==="sign"?r==="multi-token"?"Enter your password to authorize a deposit. This allows us to process your withdrawal when the privacy period ends.":`Enter your password to authorize a ${f} deposit. This allows us to process your withdrawal when the privacy period ends.`:r==="multi-token"?"Enter your password to get your deposit address. Any supported token sent to this address will be credited to your account.":`Enter your password to get your deposit address. Any ${f} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",htmlFor:"deposit-password",children:"Password"}),e.jsx("input",{id:"deposit-password",type:"password",value:c,onChange:p=>u(p.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:n,autoComplete:"current-password"})]}),a&&e.jsx("p",{className:"cedros-deposit-flow-error",children:a}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:i,disabled:n,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!c.trim()||n,children:n?"Authorizing...":"Continue"})]})]})]})}function gd({token:t,tokens:s,quickActionSymbols:r,customTokenSymbols:o,currencyMode:n,minAmount:a,maxAmount:l,depositAddress:i,walletReady:c,needsUnlock:u,copied:f,isListening:h,config:p,onCopy:b,onTokenSelect:w,onUnlockRequired:m,onConfirm:k,onBack:x}){const[N,j]=d.useState(p.privateMinUsd),[C,P]=d.useState(!1),[g,v]=d.useState(!1),[A,y]=d.useState(0),[L,S]=d.useState(null),E=Lt(N,p)==="sol_micro",M=t.symbol===Ve.symbol,R=d.useMemo(()=>{const $=o.length===0?s:s.filter(ue=>o.includes(ue.symbol)),V=$.length>0?$:s;return V.some(ue=>ue.symbol===Ve.symbol)?V:[...V,Ve]},[s,o]),F=Bt(p,N),U=F===0?0:F<.01?.01:F,q=M?"Fees: calculated after deposit":F===0?"No fees":`Fees: $${U.toFixed(2)} total`,O=M?"":qo(p,N,F),I=tr(E?He:t,p),D=I?N/I:t.symbol==="SOL"&&p.solPriceUsd>0?N/p.solPriceUsd:null,H=D!=null?Ho(D,E?"SOL":t.symbol):null,oe=N-F<=0&&N>0,be=!M&&N>0&&!oe&&D!=null&&D>=a&&D<=l;d.useEffect(()=>{if(n==="multi-token")if(E&&t.symbol!=="SOL"){S(t);const $=s.find(V=>V.symbol==="SOL");$&&w($)}else!E&&L&&t.symbol==="SOL"&&(w(L),S(null))},[E,t.symbol,n,s,w,L,t]);const fe=()=>{be&&D!=null&&k(D,t)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Choose Amount"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Set how much you want to deposit. Higher tiers unlock privacy."}),n==="multi-token"&&!E&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[r.map($=>{const V=s.find(ue=>ue.symbol===$),X=t.symbol===$;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${X?"is-active":""}`,onClick:()=>{V&&(P(!1),w(V))},disabled:!V,children:[V?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:V.logoUrl,alt:`${$} logo`}),$]},$)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${C?"is-active":""}`,onClick:()=>{P(!0),y($=>$+1)},children:"Custom"})]}),C&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(Zs,{tokens:R,selectedToken:t,onSelect:w,openSignal:A})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(er,{config:p,valueUsd:N,onChange:j,maxUsd:Wo})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:M?"Sign to send tokens to this address":`Sign to send ${H??"--"} ${E?"SOL":t.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:i||"Loading..."}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:b,title:"Copy address",disabled:!i,children:f?"✓":"⧉"}),i&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${i}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),f&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),oe&&e.jsx("div",{className:"cedros-deposit-flow-warning",children:e.jsx("p",{children:"Deposit amount is less than the fees. Increase the amount to proceed."})}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[q,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${g?"is-open":""}`,"data-tooltip":O,"aria-label":`Fee breakdown: ${O.replaceAll(`
|
|
2060
|
-
`,", ")}`,"aria-expanded":
|
|
2061
|
-
`,", ")}`,"aria-expanded":j,onClick:D=>{D.stopPropagation(),C(H=>!H)},onBlur:()=>C(!1),onKeyDown:D=>{D.key==="Escape"&&C(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after confirmation (typically ~30s)."})]})]}),c&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for your deposit. We'll notify you when it arrives."}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:w,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:b,disabled:!U,children:"I've Sent It"})]})]}):e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"!"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Wallet Not Ready"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Your embedded wallet is not set up. Please complete wallet enrollment first."})]})}function yd({token:t,depositAddress:s,copied:r,feeLine:o,onCopy:n}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Waiting for Deposit"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Looking for incoming ",e.jsx("strong",{children:t.symbol})," deposits..."]}),e.jsxs("div",{className:"cedros-deposit-flow-waiting-info",children:[e.jsx("p",{className:"cedros-deposit-flow-waiting-text",children:"Once your transaction is confirmed on the Solana network, your account will be credited automatically. This usually takes 20-30 seconds."}),s&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit address"}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsxs("code",{className:"cedros-deposit-flow-address",children:[s.slice(0,6),"...",s.slice(-6)]}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:n,title:"Copy address",children:r?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${s}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:o})]})]})]})]})}function xd({result:t,config:s,onNewDeposit:r}){const o=t.token??He,n=tr(o,s),a=n?t.amount*n:t.amount,l=Bt(s,a),i=Math.max(a-l,0),c=l===0?0:l<.01?.01:l;return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-success-icon",children:"✓"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Successful!"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Your deposit of ",t.amount.toLocaleString()," ",o.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[t.txSignature&&e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Transaction"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-tx",children:[e.jsxs("a",{href:`https://orbmarkets.io/tx/${t.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[t.txSignature.slice(0,8),"...",t.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${t.txSignature}`,target:"_blank",rel:"noopener noreferrer","aria-label":"View transaction on Orb Markets",title:"View transaction",children:"↗"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Deposit Amount"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value",children:["$",a.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Total Fees"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-fee",children:["-$",c.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Credits Added"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-credit",children:["+$",i.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Available"}),e.jsx("span",{className:"cedros-deposit-flow-summary-value",children:"Immediately"})]})]}),e.jsx("div",{className:"cedros-deposit-flow-actions",children:e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:r,children:"Make Another Deposit"})})]})}function Ad({error:t,onRetry:s,onCancel:r}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"✕"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Failed"}),e.jsx("p",{className:"cedros-deposit-flow-error-message",children:t}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[r&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:s,children:"Try Again"})]})]})}function sr(){const t=T.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),a=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),l=d.useCallback(()=>{n(null)},[]),i=d.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/credits/balance/sol")}catch(f){const h=T.handleApiError(f,"Failed to fetch credit balance");throw n(h.message),h}finally{r(!1)}},[a]),c=d.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return(await a.get("/credits/balance")).balances}catch(f){const h=T.handleApiError(f,"Failed to fetch credit balances");throw n(h.message),h}finally{r(!1)}},[a]),u=d.useCallback(async f=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{const h=new URLSearchParams;f?.currency&&h.set("currency",f.currency),f?.limit!==void 0&&h.set("limit",f.limit.toString()),f?.offset!==void 0&&h.set("offset",f.offset.toString());const p=h.toString(),b=p?`/credits/history?${p}`:"/credits/history";return await a.get(b)}catch(h){const p=T.handleApiError(h,"Failed to fetch transaction history");throw n(p.message),p}finally{r(!1)}},[a]);return{getBalance:i,getAllBalances:c,getHistory:u,isLoading:s,error:o,clearError:l}}function vd({showAllCurrencies:t=!1,refreshInterval:s=0,compact:r=!1,className:o="",onLoad:n}){const{getBalance:a,getAllBalances:l,isLoading:i,error:c,clearError:u}=sr(),[f,h]=d.useState([]),[p,b]=d.useState(null),w=d.useCallback(async()=>{try{if(t){const m=await l();h(m),n?.(m)}else{const m=await a();h([m]),n?.([m])}b(null)}catch(m){b(m instanceof Error?m.message:"Failed to load balance")}},[t,a,l,n]);if(d.useEffect(()=>{w()},[w]),d.useEffect(()=>{if(s<=0)return;const m=setInterval(w,s);return()=>clearInterval(m)},[s,w]),p||c)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${o}`,children:[e.jsx("p",{className:"cedros-credit-error",children:p||c}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{u(),b(null),w()},children:"Retry"})]});if(i&&f.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${o}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(r){const m=f[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${o}`,children:[m?e.jsx("span",{className:"cedros-credit-value",title:`${m.balanceLamports} lamports`,children:m.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),i&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${o}`,children:[e.jsxs("div",{className:"cedros-credit-header",children:[e.jsx("h4",{className:"cedros-credit-title",children:"Credit Balance"}),e.jsx("button",{type:"button",className:"cedros-credit-refresh",onClick:w,disabled:i,title:"Refresh balance",children:i?"...":"↻"})]}),f.length===0?e.jsxs("div",{className:"cedros-credit-empty",children:[e.jsx("p",{className:"cedros-credit-empty-message",children:"No credit balance yet."}),e.jsx("p",{className:"cedros-credit-empty-hint",children:"Make a deposit to get started."})]}):e.jsx("div",{className:"cedros-credit-list",children:f.map(m=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:m.currency}),e.jsx("span",{className:"cedros-credit-amount",children:m.display})]},m.currency))})]})}const ys=[{key:"all",label:"All",txTypes:null},{key:"deposits",label:"Deposits",txTypes:["deposit"]},{key:"usage",label:"Usage",txTypes:["spend","usage","charge"]},{key:"adjustments",label:"Adjustments",txTypes:["refund","adjustment","bonus","credit"]}];function jd(t,s){const r=t<0,o=Math.abs(t),n=Oo(s),a=o/Math.pow(10,n),l=r?"-":"+";return s.toUpperCase()==="SOL"?`${l}${a.toFixed(4)} SOL`:`${l}$${a.toFixed(2)}`}function kd(t){const s=new Date(t),r=new Date,o=r.getTime()-s.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const l=Math.floor(o/6e4);return l<1?"Just now":`${l}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==r.getFullYear()?"numeric":void 0})}function Nd(t){return t?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[t.toLowerCase()]||t:"Transaction"}function Cd(t,s){const r=(t||"").toLowerCase();return r==="deposit"?"↓":r==="spend"||r==="usage"||r==="charge"?"↑":r==="refund"?"←":r==="bonus"||r==="credit"?"★":s?"+":"−"}function Sd({defaultTab:t="all",pageSize:s=10,refreshInterval:r=0,className:o="",onLoad:n,onTransactionClick:a}){const{getHistory:l,isLoading:i,error:c,clearError:u}=sr(),[f,h]=d.useState(t),[p,b]=d.useState([]),[w,m]=d.useState(0),[k,x]=d.useState(0),[N,j]=d.useState(null),C=ys.find(E=>E.key===f)||ys[0],P=d.useMemo(()=>C.txTypes===null?p:p.filter(E=>{const M=E.txType||"";return C.txTypes.some(R=>M.toLowerCase()===R.toLowerCase())}),[p,C.txTypes]),g=d.useCallback(async()=>{try{const E=await l({limit:s*3,offset:k});b(E.transactions),m(E.total),n?.(E),j(null)}catch(E){j(E instanceof Error?E.message:"Failed to load history")}},[s,k,l,n]);d.useEffect(()=>{x(0)},[f]),d.useEffect(()=>{g()},[g]),d.useEffect(()=>{if(r<=0)return;const E=setInterval(g,r);return()=>clearInterval(E)},[r,g]);const v=C.txTypes===null?w:P.length,A=Math.ceil(v/s),y=Math.floor(k/s)+1,L=E=>{const M=(E-1)*s;x(Math.max(0,Math.min(M,Math.max(0,v-s))))},S=E=>{h(E)};if(N||c)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${o}`,children:[e.jsx("p",{className:"cedros-tx-error",children:N||c}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{u(),j(null),g()},children:"Retry"})]});if(i&&p.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${o}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const B=E=>E.txTypes===null?p.length:p.filter(M=>{const R=M.txType||"";return E.txTypes.some(F=>R.toLowerCase()===F.toLowerCase())}).length;return e.jsxs("div",{className:`cedros-tx-history ${o}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Transaction History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:g,disabled:i,title:"Refresh",children:i?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:ys.map(E=>{const M=B(E),R=f===E.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${R?"cedros-tx-tab-active":""}`,onClick:()=>S(E.key),children:[E.label,M>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:M})]},E.key)})}),P.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:f==="all"?"No transactions yet.":`No ${C.label.toLowerCase()} found.`}),f==="all"&&e.jsx("p",{className:"cedros-tx-empty-hint",children:"Make a deposit to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:P.slice(0,s).map(E=>{const M=E.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${M?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>a?.(E),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),a?.(E))},role:a?"button":void 0,tabIndex:a?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${M?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:Cd(E.txType,M)}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsx("span",{className:"cedros-tx-type",children:Nd(E.txType)}),e.jsx("span",{className:`cedros-tx-amount ${M?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:jd(E.amountLamports,E.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:E.description}),e.jsx("span",{className:"cedros-tx-date",children:kd(E.createdAt)})]})]})]},E.id)})}),A>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>L(y-1),disabled:y<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",y," of ",A]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>L(y+1),disabled:y>=A,children:"Next"})]})]})]})}function rr(){const t=T.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),[a,l]=d.useState(null),i=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),c=d.useCallback(()=>{n(null)},[]),u=d.useCallback(async()=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await i.get("/wallet/withdraw/balances")}catch(b){const w=T.handleApiError(b,"Failed to fetch wallet balances");throw n(w.message),w}},[i]),f=d.useCallback(async(b,w)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const m=await i.post("/wallet/withdraw/sol",{destination:b,amount_lamports:w});return l(m),m}catch(m){const k=T.handleApiError(m,"Failed to withdraw SOL");throw n(k.message),k}finally{r(!1)}},[i]),h=d.useCallback(async(b,w,m)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const k=await i.post("/wallet/withdraw/spl",{destination:b,token_mint:w,amount:m});return l(k),k}catch(k){const x=T.handleApiError(k,"Failed to withdraw token");throw n(x.message),x}finally{r(!1)}},[i]),p=d.useCallback(async(b=10,w=0)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const m=Math.max(1,Math.min(100,Math.trunc(b))),k=Math.max(0,Math.trunc(w)),x=new URLSearchParams({limit:String(m),offset:String(k)});return await i.get(`/wallet/withdraw/history?${x}`)}catch(m){const k=T.handleApiError(m,"Failed to fetch withdrawal history");throw n(k.message),k}},[i]);return{withdrawSol:f,withdrawSpl:h,getBalances:u,getHistory:p,isSubmitting:s,error:o,clearError:c,lastResult:a}}const xs="So11111111111111111111111111111111111111112",Ed={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function Ld(t){return t.length<32||t.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(t)}function As(t){return t.length<=16?t:`${t.slice(0,6)}...${t.slice(-6)}`}function dt(t,s){return(Number(t)/Math.pow(10,s)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(s,6)})}function Pd({onSuccess:t,onError:s,onCancel:r,className:o=""}){const n=T.useCedrosLoginOptional(),{withdrawSol:a,withdrawSpl:l,getBalances:i,isSubmitting:c,error:u,clearError:f}=rr(),[h,p]=d.useState("loading"),[b,w]=d.useState([]),[m,k]=d.useState(null),[x,N]=d.useState(""),[j,C]=d.useState(""),[P,g]=d.useState(null),[v,A]=d.useState(null),[y,L]=d.useState(null),S=n?.config.solana?.network??"mainnet-beta",B=d.useMemo(()=>{if(!P?.txSignature)return"";const I=`https://explorer.solana.com/tx/${P.txSignature}`;return S==="mainnet-beta"?I:`${I}?cluster=${encodeURIComponent(S)}`},[P,S]),E=d.useMemo(()=>{if(!m||!j)return"0";const I=parseFloat(j);return isNaN(I)||I<=0?"0":Math.floor(I*Math.pow(10,m.decimals)).toString()},[j,m]);d.useEffect(()=>{if(!n)return;let I=!1;return(async()=>{try{const D=await i();if(I)return;const H=[];D.solLamports>0&&H.push({symbol:"SOL",mint:xs,decimals:9,rawBalance:String(D.solLamports),displayBalance:dt(String(D.solLamports),9)});for(const Y of D.tokens){const oe=Ed[Y.mint]??As(Y.mint);H.push({symbol:oe,mint:Y.mint,decimals:Y.decimals,rawBalance:Y.amount,displayBalance:dt(Y.amount,Y.decimals)})}w(H),p((H.length>0,"select"))}catch{I||(L("Failed to load wallet balances"),p("select"))}})(),()=>{I=!0}},[n,i]);const M=d.useCallback(I=>{k(I),p("form"),f(),A(null),C("")},[f]),R=d.useCallback(()=>{if(!m)return;const I=Number(m.rawBalance)/Math.pow(10,m.decimals);m.mint===xs?C(String(Math.max(0,I-.01))):C(String(I))},[m]),F=d.useCallback(()=>{if(A(null),!x.trim()){A("Destination address is required");return}if(!Ld(x.trim())){A("Invalid Solana address");return}if(!j||parseFloat(j)<=0||isNaN(parseFloat(j))){A("Please enter a valid amount");return}if(E==="0"){A("Amount is too small");return}p("confirm")},[x,j,E]),U=d.useCallback(async()=>{if(m){p("processing"),f();try{let I;m.mint===xs?I=await a(x.trim(),Number(E)):I=await l(x.trim(),m.mint,E),g(I),p("success"),t?.(I)}catch(I){p("confirm"),s?.(I instanceof Error?I:new Error(String(I)))}}},[m,x,E,a,l,f,t,s]),q=d.useCallback(()=>{f(),A(null),h==="form"?(p("select"),k(null),C(""),N("")):h==="confirm"&&p("form")},[h,f]),O=d.useCallback(()=>{p("select"),k(null),N(""),C(""),g(null),f(),A(null)},[f]);return n?e.jsxs("div",{className:`cedros-withdrawal ${o}`,children:[h==="loading"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(z.LoadingSpinner,{}),e.jsx("p",{className:"cedros-withdrawal-processing-text",children:"Loading wallet balances..."})]}),h==="select"&&e.jsxs("div",{className:"cedros-withdrawal-select",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdraw"}),e.jsx("p",{className:"cedros-withdrawal-subtitle",children:"Select a token to withdraw"})]}),y&&e.jsx(Z.ErrorMessage,{error:y}),b.length===0&&!y&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:b.map(I=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>M(I),children:[e.jsx("span",{className:"cedros-withdrawal-token-symbol",children:I.symbol}),e.jsx("span",{className:"cedros-withdrawal-token-balance",children:I.displayBalance})]},I.mint))}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:r,children:"Cancel"})]}),h==="form"&&m&&e.jsxs("div",{className:"cedros-withdrawal-form",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:q,children:"Back"}),e.jsxs("h3",{className:"cedros-withdrawal-title",children:["Withdraw ",m.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",m.displayBalance," ",m.symbol]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsx("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-destination",children:"Destination Address"}),e.jsx("input",{id:"cedros-withdrawal-destination",type:"text",className:"cedros-input",placeholder:"Solana address (base58)",value:x,onChange:I=>N(I.target.value),autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsxs("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-amount",children:["Amount (",m.symbol,")"]}),e.jsxs("div",{className:"cedros-withdrawal-amount-row",children:[e.jsx("input",{id:"cedros-withdrawal-amount",type:"number",className:"cedros-input",placeholder:"0.00",value:j,onChange:I=>C(I.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:R,children:"Max"})]})]}),(v||u)&&e.jsx(Z.ErrorMessage,{error:v||u||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:F,children:"Review Withdrawal"})]}),h==="confirm"&&m&&e.jsxs("div",{className:"cedros-withdrawal-confirm",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:q,disabled:c,children:"Back"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Confirm Withdrawal"})]}),e.jsxs("div",{className:"cedros-withdrawal-summary",children:[e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Token"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:m.symbol})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Amount"}),e.jsxs("span",{className:"cedros-withdrawal-summary-value",children:[dt(E,m.decimals)," ",m.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Destination"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",title:x,children:As(x)})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Est. Fee"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:"~0.000005 SOL"})]})]}),u&&e.jsx(Z.ErrorMessage,{error:u}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:q,disabled:c,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:U,disabled:c,children:c?"Sending...":"Confirm & Send"})]})]}),h==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(z.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",m?.symbol,"..."]})]}),h==="success"&&P&&e.jsxs("div",{className:"cedros-withdrawal-success",children:[e.jsx("div",{className:"cedros-withdrawal-success-icon",children:"✓"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdrawal Complete"}),e.jsxs("p",{className:"cedros-withdrawal-subtitle",children:[dt(E,m?.decimals??9)," ",m?.symbol," ","sent"]}),e.jsxs("div",{className:"cedros-withdrawal-tx",children:[e.jsx("span",{className:"cedros-withdrawal-tx-label",children:"Transaction"}),e.jsx("a",{className:"cedros-withdrawal-tx-link",href:B,target:"_blank",rel:"noreferrer",children:As(P.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:O,children:"Done"})]})]}):null}function Bd(t,s){if(t==="sol")return"SOL";if(!s)return"SPL";const r=Pt.find(o=>o.mint===s);return r?r.symbol:`${s.slice(0,4)}...${s.slice(-4)}`}function Md(t,s){const r=Number(t);if(Number.isNaN(r))return t;const o=Oo(s),n=r/Math.pow(10,o);return s==="SOL"?`${n.toFixed(4)} SOL`:`${n.toFixed(2)} ${s}`}function Rd(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function Td(t){const s=new Date(t),r=new Date,o=r.getTime()-s.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const l=Math.floor(o/6e4);return l<1?"Just now":`${l}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==r.getFullYear()?"numeric":void 0})}function Id({pageSize:t=10,className:s="",onTransactionClick:r,explorerUrl:o="https://solscan.io"}){const n=o.startsWith("https://")?o:"https://solscan.io",{getHistory:a,error:l,clearError:i}=rr(),[c,u]=d.useState([]),[f,h]=d.useState(0),[p,b]=d.useState(0),[w,m]=d.useState(!1),[k,x]=d.useState(null),N=d.useCallback(async()=>{m(!0);try{const g=await a(t,p);u(g.items),h(g.total),x(null)}catch(g){x(g instanceof Error?g.message:"Failed to load withdrawal history")}finally{m(!1)}},[t,p,a]);d.useEffect(()=>{N()},[N]);const j=Math.ceil(f/t),C=Math.floor(p/t)+1,P=g=>{const v=(g-1)*t;b(Math.max(0,Math.min(v,Math.max(0,f-t))))};return k||l?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${s}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:k||l}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{i(),x(null),N()},children:"Retry"})]}):w&&c.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${s}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-withdrawal-history ${s}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Withdrawal History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:N,disabled:w,title:"Refresh",children:w?"...":"↻"})]}),c.length===0?e.jsx("div",{className:"cedros-tx-empty",children:e.jsx("p",{className:"cedros-tx-empty-message",children:"No withdrawal history yet."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:c.map(g=>{const v=Bd(g.tokenType,g.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>r?.(g),onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),r?.(g))},role:r?"button":void 0,tabIndex:r?0:void 0,children:[e.jsx("div",{className:"cedros-tx-icon cedros-tx-icon-negative",children:"↑"}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsxs("span",{className:"cedros-tx-type",children:[v," Withdrawal"]}),e.jsx("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:Md(g.amount,v)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${n}/account/${g.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:A=>A.stopPropagation(),children:Rd(g.destination)})," · ",e.jsx("a",{href:`${n}/tx/${g.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:A=>A.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:Td(g.createdAt)})]})]})]},g.id)})}),j>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>P(C-1),disabled:C<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",C," of ",j]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>P(C+1),disabled:C>=j,children:"Next"})]})]})]})}function _d({brandLogo:t,brandName:s,title:r="Welcome back",subtitle:o="Login with your Apple or Google account",termsText:n,onSuccess:a,defaultTab:l="login",children:i,className:c=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${c}`,children:[(t||s)&&e.jsxs("div",{className:"cedros-brand-header",children:[t,s&&e.jsx("span",{className:"cedros-brand-name",children:s})]}),e.jsxs("div",{className:"cedros-full-page-card",children:[e.jsxs("div",{className:"cedros-full-page-header",children:[e.jsx("h1",{className:"cedros-full-page-title",children:r}),o&&e.jsx("p",{className:"cedros-full-page-subtitle",children:o})]}),i??e.jsx(Et,{defaultTab:l,onSuccess:a})]}),n&&e.jsx("p",{className:"cedros-terms-footer",children:n})]})}function Dd({brandName:t="Your Brand",brandLogo:s,tagline:r="Your tagline goes here. Make it compelling.",title:o="Sign in",subtitle:n="Enter your credentials to access your account",onSuccess:a,defaultTab:l="login",children:i,className:c=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${c}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[s??e.jsx("div",{className:"cedros-split-page-logo",children:t.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:t}),r&&e.jsx("p",{className:"cedros-split-page-tagline",children:r})]})}),e.jsx("div",{className:"cedros-split-page-form",children:e.jsxs("div",{className:"cedros-split-page-form-content",children:[e.jsx("h2",{className:"cedros-split-page-title",children:o}),n&&e.jsx("p",{className:"cedros-split-page-subtitle",children:n}),i??e.jsx(Et,{defaultTab:l,onSuccess:a})]})})]})}function Ud(){const{config:t,_internal:s}=T.useCedrosLogin(),[r,o]=d.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),n=d.useMemo(()=>new Ts.OrgApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,s?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),a=d.useCallback(async c=>{o(u=>({...u,isLoading:!0,error:null}));try{const u=await n.authorize(c),f={allowed:u.allowed,reason:u.reason,isLoading:!1,error:null};return o(f),f}catch(u){const f={allowed:!1,reason:void 0,isLoading:!1,error:u};return o(f),f}},[n]),l=d.useCallback(async c=>(await a(c)).allowed,[a]),i=d.useCallback(()=>{o({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:l,lastCheck:r,clearCheck:i,checkAuthorization:a}}function Fd(){const{listAllWallets:t,createDerivedWallet:s,deleteDerivedWallet:r}=_.useWalletMaterial(),[o,n]=d.useState([]),[a,l]=d.useState(!1),[i,c]=d.useState(null),u=d.useCallback(async()=>{l(!0),c(null);try{const b=await t();n(b.wallets)}catch(b){const w=b instanceof Error?b.message:"Failed to list wallets";c(w)}finally{l(!1)}},[t]),f=d.useCallback(async b=>{l(!0),c(null);try{const w=await s({label:b});return await u(),w}catch(w){const m=w instanceof Error?w.message:"Failed to create wallet";throw c(m),w}finally{l(!1)}},[s,u]),h=d.useCallback(async b=>{l(!0),c(null);try{await r(b),await u()}catch(w){const m=w instanceof Error?w.message:"Failed to delete wallet";throw c(m),w}finally{l(!1)}},[r,u]),p=d.useCallback(()=>c(null),[]);return{wallets:o,isLoading:a,createWallet:f,deleteWallet:h,refresh:u,error:i,clearError:p}}function Od(){const t=T.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),[a,l]=d.useState(null),i=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),c=d.useCallback(async()=>{if(!i)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const h=await i.get("/wallet/pending-recovery");l(h)}catch(h){const p=T.handleApiError(h,"Failed to fetch pending recovery");throw n(p.message),p}finally{r(!1)}},[i]),u=d.useCallback(async()=>{if(!i)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const h={confirmed:!0};await i.post("/wallet/acknowledge-recovery",h),l(null)}catch(h){const p=T.handleApiError(h,"Failed to acknowledge recovery");throw n(p.message),p}finally{r(!1)}},[i]),f=d.useCallback(()=>n(null),[]);return d.useEffect(()=>{i&&t?.authState==="authenticated"&&c().catch(()=>{})},[i,t?.authState,c]),{hasPendingRecovery:a?.hasPendingRecovery??!1,recoveryType:a?.recoveryType??null,recoveryPhrase:a?.recoveryPhrase??null,expiresAt:a?.expiresAt?new Date(a.expiresAt):null,fetchPendingRecovery:c,acknowledgeRecovery:u,isLoading:s,error:o,clearError:f}}function Wd(t={}){const{onExternalSign:s}=t,{solanaPubkey:r,hasExternalWallet:o,status:n,isUnlocked:a}=_.useWallet(),{signTransaction:l,isSigning:i,error:c,clearError:u}=mo(),f=d.useMemo(()=>o&&s?"external":n==="enrolled_locked"||n==="enrolled_unlocked"?"sss":"none",[o,s,n]),h=f!=="none",p=n==="enrolled_locked"||n==="enrolled_unlocked";return{signTransaction:d.useCallback(async(w,m)=>{if(f==="external"){if(!s)throw new Error("External wallet signing callback not provided");return s(w)}if(f==="sss"){if(!m&&!a)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return m?l(w,m):l(w)}throw new Error("No signing method available. Enroll a wallet first.")},[f,s,a,l]),signingMethod:f,canSign:h,isSigning:i,publicKey:r,hasExternalWallet:o,hasSssWallet:p,isSssUnlocked:a,error:c,clearError:u}}function qd(){const{config:t,_internal:s}=T.useCedrosLogin(),[r,o]=d.useState(null),[n,a]=d.useState(!1),[l,i]=d.useState(null),c=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),u=d.useCallback(async()=>{a(!0),i(null);try{await c.post("/welcome-completed",{})}catch(h){const p=h instanceof Error?h:new Error(String(h));throw i(p),p}finally{a(!1)}},[c]),f=d.useCallback(()=>{o(null)},[]);return{postLoginAction:r,setPostLoginAction:o,markWelcomeCompleted:u,clearPostLogin:f,isLoading:n,error:l}}const nr=d.createContext(null),Nt={auth:{email:"Email",password:"Password",confirmPassword:"Confirm Password",name:"Name",optional:"(optional)",createPassword:"Create a password",confirmYourPassword:"Confirm your password",emailPlaceholder:"you@example.com",namePlaceholder:"Your name"},buttons:{signIn:"Sign in",signUp:"Sign up",signOut:"Sign out",createAccount:"Create account",continueWithGoogle:"Continue with Google",continueWithSolana:"Connect Wallet",forgotPassword:"Forgot password?",resetPassword:"Reset password",sendVerification:"Send verification email"},messages:{signingIn:"Signing in...",signingUp:"Signing up...",creatingAccount:"Creating account...",connectingWallet:"Connecting wallet...",verifyingSignature:"Verifying signature...",passwordsDoNotMatch:"Passwords do not match",alreadyHaveAccount:"Already have an account?",dontHaveAccount:"Don't have an account?",orContinueWith:"Or continue with"},errors:{invalidCredentials:"Invalid email or password",emailExists:"An account with this email already exists",invalidEmail:"Please enter a valid email address",weakPassword:"Password does not meet requirements",networkError:"Network error. Please try again.",unknownError:"An error occurred. Please try again.",walletNotFound:"No wallet found. Please install a Solana wallet.",signatureRejected:"Signature request was rejected",challengeExpired:"Challenge expired. Please try again."},passwordValidation:{minLength:"At least 10 characters",uppercase:"At least 1 uppercase letter",lowercase:"At least 1 lowercase letter",number:"At least 1 number",special:"At least 1 special character",weak:"Weak",fair:"Fair",good:"Good",strong:"Strong"}};function Vo(t,s){return $o(t,s)}function $o(t,s){const r={...t};for(const o in s)if(Object.prototype.hasOwnProperty.call(s,o)){const n=t[o],a=s[o];typeof n=="object"&&n!==null&&typeof a=="object"&&a!==null?r[o]=$o(n,a):a!==void 0&&(r[o]=a)}return r}function zd({children:t,locale:s="en",translations:r}){const o=d.useMemo(()=>({t:r?Vo(Nt,r):Nt,locale:s}),[r,s]);return e.jsx(nr.Provider,{value:o,children:t})}function Hd(){return d.useContext(nr)?.t??Nt}function Vd(){return d.useContext(nr)?.locale??"en"}exports.CedrosLoginProvider=_.CedrosLoginProvider;exports.getEmbeddedWalletInfo=_.getEmbeddedWalletInfo;exports.isEmbeddedWalletAvailable=_.isEmbeddedWalletAvailable;exports.useAuth=_.useAuth;exports.useWallet=_.useWallet;exports.useWalletMaterial=_.useWalletMaterial;exports.useAuthState=T.useAuthState;exports.useAuthUI=T.useAuthUI;exports.useCedrosLogin=T.useCedrosLogin;exports.LoadingSpinner=z.LoadingSpinner;exports.EmailLoginForm=Q.EmailLoginForm;exports.EmailRegisterForm=Q.EmailRegisterForm;exports.OtpInput=Q.OtpInput;exports.PasswordInput=Q.PasswordInput;exports.TotpVerify=Q.TotpVerify;exports.useEmailAuth=Q.useEmailAuth;exports.useTotpVerify=Q.useTotpVerify;exports.validatePassword=Ie.validatePassword;exports.ErrorMessage=Z.ErrorMessage;exports.GoogleLoginButton=Rs.GoogleLoginButton;exports.useGoogleAuth=Rs.useGoogleAuth;exports.SolanaLoginButton=ze.SolanaLoginButton;exports.registerMobileWallet=ze.registerMobileWallet;exports.useSolanaAuth=ze.useSolanaAuth;exports.InviteForm=ie.InviteForm;exports.InviteList=ie.InviteList;exports.MemberList=ie.MemberList;exports.useInvites=ie.useInvites;exports.useMembers=ie.useMembers;exports.useServerFeatures=ie.useServerFeatures;exports.useSystemSettings=mn.useSystemSettings;exports.useOrgs=Ts.useOrgs;exports.AdminDepositList=mt.AdminDepositList;exports.AdminDepositStats=mt.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=Be.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=Be.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=Be.AdminWithdrawalQueue;exports.AdminWithdrawalStats=Be.AdminWithdrawalStats;exports.AdminUserList=et.AdminUserList;exports.useAdminUsers=et.useAdminUsers;exports.AdminIcons=Me.Icons;exports.AdminShell=Me.AdminShell;exports.CEDROS_LOGIN_SECTION_IDS=Me.CEDROS_LOGIN_SECTION_IDS;exports.ProfileDropdown=Me.ProfileDropdown;exports.cedrosLoginPlugin=Me.cedrosLoginPlugin;exports.loginPlugin=Me.cedrosLoginPlugin;exports.useAdminShell=Me.useAdminShell;exports.AuthenticationSettings=wn.AuthenticationSettings;exports.EmbeddedWalletSettings=bn.EmbeddedWalletSettings;exports.EmailSettings=ut.EmailSettings;exports.CreditSystemSettings=Is.CreditSystemSettings;exports.PrivacyCashSettings=Is.CreditSystemSettings;exports.ServerSettings=yn.ServerSettings;exports.useAdminDeposits=sa.useAdminDeposits;exports.SettingsPageLayout=_s.SettingsPageLayout;exports.WebhookSettings=_s.WebhookSettings;exports.AccountSettings=ql;exports.AppleLoginButton=ro;exports.CapabilityWarning=kc;exports.CedrosAdminDashboard=Jc;exports.ChooseUsernamePrompt=Vl;exports.CompleteAccountPrompt=Hl;exports.CreditBalance=vd;exports.DepositFlow=fd;exports.ErrorBoundary=ao;exports.ForgotPasswordForm=eo;exports.FullPageLayout=_d;exports.History=Sd;exports.I18nProvider=zd;exports.LinkedAccounts=Bo;exports.LoginButton=Zi;exports.LoginForm=Et;exports.LoginModal=oc;exports.MfaSetupPrompt=zl;exports.OrgSelector=ic;exports.OrgSwitcher=gc;exports.PasskeyLoginButton=oo;exports.PasskeyPrompt=wo;exports.ProfileTab=Lo;exports.RecoveryPhraseDisplay=co;exports.RecoveryPhraseInput=lo;exports.ResetPasswordForm=ac;exports.SUPPORTED_TOKENS=Pt;exports.SecuritySettings=Kc;exports.SessionList=io;exports.SetupWizard=jo;exports.SplitPageLayout=Dd;exports.SystemSettings=zc;exports.TieredAmountSlider=er;exports.TokenSelector=Zs;exports.TotpSettings=Eo;exports.TotpSetup=Ks;exports.UserProfileSettings=Ll;exports.WalletAddressRow=Ao;exports.WalletEnrollment=po;exports.WalletManager=qc;exports.WalletRecovery=xo;exports.WalletStatus=vo;exports.WalletUnlock=bo;exports.WithdrawalFlow=Pd;exports.WithdrawalHistory=Id;exports.defaultTranslations=Nt;exports.getTierForAmount=Lt;exports.mergeTranslations=Vo;exports.useAppleAuth=to;exports.useAuthorize=Ud;exports.useCredentials=Ys;exports.useCredits=sr;exports.useDeposit=Do;exports.useInstantLink=Jn;exports.useLocale=Vd;exports.usePasskeySigning=go;exports.usePasswordReset=St;exports.usePendingRecovery=Od;exports.usePostLogin=qd;exports.useProfile=tt;exports.useSessions=Io;exports.useSetPassword=fo;exports.useSetup=$s;exports.useTotp=Qs;exports.useTransactionSigning=Wd;exports.useTranslations=Hd;exports.useUsername=_o;exports.useWalletEnrollment=ho;exports.useWalletRecovery=yo;exports.useWalletSigning=mo;exports.useWallets=Fd;exports.useWebAuthn=Vs;exports.useWithdrawal=rr;
|
|
2054
|
+
Minimum version required to store current data is: `+E+`.
|
|
2055
|
+
`);const P=N(y,x,_),L=t.getSymbolSize(y),R=new o(L);return b(R,y),w(R),g(R,y),A(R,x,0),y>=7&&k(R,y),j(R,P),isNaN(v)&&(v=i.getBestMask(R,A.bind(null,R,x))),i.applyMask(v,R),A(R,x,v),{modules:R,version:y,errorCorrectionLevel:x,maskPattern:v,segments:_}}return cs.create=function(y,x){if(typeof y>"u"||y==="")throw new Error("No input text");let v=s.M,_,E;return typeof x<"u"&&(v=s.from(x.errorCorrectionLevel,s.M),_=u.from(x.version),E=i.from(x.maskPattern),x.toSJISFunc&&t.setToSJISFunction(x.toSJISFunc)),C(y,_,v,E)},cs}var Cs={},Es={},yn;function Wo(){return yn||(yn=1,(function(t){function s(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let o=r.slice().replace("#","").split("");if(o.length<3||o.length===5||o.length>8)throw new Error("Invalid hex color: "+r);(o.length===3||o.length===4)&&(o=Array.prototype.concat.apply([],o.map(function(a){return[a,a]}))),o.length===6&&o.push("F","F");const n=parseInt(o.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+o.slice(0,6).join("")}}t.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=typeof o.margin>"u"||o.margin===null||o.margin<0?4:o.margin,a=o.width&&o.width>=21?o.width:void 0,i=o.scale||4;return{width:a,scale:a?4:i,margin:n,color:{dark:s(o.color.dark||"#000000ff"),light:s(o.color.light||"#ffffffff")},type:o.type,rendererOpts:o.rendererOpts||{}}},t.getScale=function(o,n){return n.width&&n.width>=o+n.margin*2?n.width/(o+n.margin*2):n.scale},t.getImageWidth=function(o,n){const a=t.getScale(o,n);return Math.floor((o+n.margin*2)*a)},t.qrToImageData=function(o,n,a){const i=n.modules.size,l=n.modules.data,c=t.getScale(i,a),u=Math.floor((i+a.margin*2)*c),m=a.margin*c,h=[a.color.light,a.color.dark];for(let p=0;p<u;p++)for(let b=0;b<u;b++){let w=(p*u+b)*4,g=a.color.light;if(p>=m&&b>=m&&p<u-m&&b<u-m){const k=Math.floor((p-m)/c),A=Math.floor((b-m)/c);g=h[l[k*i+A]?1:0]}o[w++]=g.r,o[w++]=g.g,o[w++]=g.b,o[w]=g.a}}})(Es)),Es}var xn;function Ol(){return xn||(xn=1,(function(t){const s=Wo();function r(n,a,i){n.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=i,a.width=i,a.style.height=i+"px",a.style.width=i+"px"}function o(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(a,i,l){let c=l,u=i;typeof c>"u"&&(!i||!i.getContext)&&(c=i,i=void 0),i||(u=o()),c=s.getOptions(c);const m=s.getImageWidth(a.modules.size,c),h=u.getContext("2d"),p=h.createImageData(m,m);return s.qrToImageData(p.data,a,c),r(h,u,m),h.putImageData(p,0,0),u},t.renderToDataURL=function(a,i,l){let c=l;typeof c>"u"&&(!i||!i.getContext)&&(c=i,i=void 0),c||(c={});const u=t.render(a,i,c),m=c.type||"image/png",h=c.rendererOpts||{};return u.toDataURL(m,h.quality)}})(Cs)),Cs}var _s={},An;function ql(){if(An)return _s;An=1;const t=Wo();function s(n,a){const i=n.a/255,l=a+'="'+n.hex+'"';return i<1?l+" "+a+'-opacity="'+i.toFixed(2).slice(1)+'"':l}function r(n,a,i){let l=n+a;return typeof i<"u"&&(l+=" "+i),l}function o(n,a,i){let l="",c=0,u=!1,m=0;for(let h=0;h<n.length;h++){const p=Math.floor(h%a),b=Math.floor(h/a);!p&&!u&&(u=!0),n[h]?(m++,h>0&&p>0&&n[h-1]||(l+=u?r("M",p+i,.5+b+i):r("m",c,0),c=0,u=!1),p+1<a&&n[h+1]||(l+=r("h",m),m=0)):c++}return l}return _s.render=function(a,i,l){const c=t.getOptions(i),u=a.modules.size,m=a.modules.data,h=u+c.margin*2,p=c.color.light.a?"<path "+s(c.color.light,"fill")+' d="M0 0h'+h+"v"+h+'H0z"/>':"",b="<path "+s(c.color.dark,"stroke")+' d="'+o(m,u,c.margin)+'"/>',w='viewBox="0 0 '+h+" "+h+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+w+' shape-rendering="crispEdges">'+p+b+`</svg>
|
|
2056
|
+
`;return typeof l=="function"&&l(null,k),k},_s}var vn;function zl(){if(vn)return Ye;vn=1;const t=jl(),s=Wl(),r=Ol(),o=ql();function n(a,i,l,c,u){const m=[].slice.call(arguments,1),h=m.length,p=typeof m[h-1]=="function";if(!p&&!t())throw new Error("Callback required as last argument");if(p){if(h<2)throw new Error("Too few arguments provided");h===2?(u=l,l=i,i=c=void 0):h===3&&(i.getContext&&typeof u>"u"?(u=c,c=void 0):(u=c,c=l,l=i,i=void 0))}else{if(h<1)throw new Error("Too few arguments provided");return h===1?(l=i,i=c=void 0):h===2&&!i.getContext&&(c=l,l=i,i=void 0),new Promise(function(b,w){try{const g=s.create(l,c);b(a(g,i,c))}catch(g){w(g)}})}try{const b=s.create(l,c);u(null,a(b,i,c))}catch(b){u(b)}}return Ye.create=s.create,Ye.toCanvas=n.bind(null,r.render),Ye.toDataURL=n.bind(null,r.renderToDataURL),Ye.toString=n.bind(null,function(a,i,l){return o.render(a,l)}),Ye}var Vl=zl();const Hl=Tn(Vl);function $l({value:t,size:s=200,alt:r="QR code",className:o=""}){const n=d.useRef(null),[a,i]=d.useState(null);return d.useEffect(()=>{!n.current||!t||Hl.toCanvas(n.current,t,{width:s,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{i(null)}).catch(l=>{i(l instanceof Error?l.message:"Failed to generate QR code")})},[t,s]),a?e.jsx("div",{className:`cedros-qr-error ${o}`,style:{width:s,height:s},role:"img","aria-label":r,children:e.jsx("p",{children:"Failed to generate QR code"})}):e.jsx("canvas",{ref:n,className:`cedros-totp-qr-image ${o}`,role:"img","aria-label":r,style:{borderRadius:"0.5rem"}})}function ar(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(null),[n,a]=d.useState("idle"),[i,l]=d.useState(null),[c,u]=d.useState(!1),[m,h]=d.useState(null),p=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),b=d.useCallback(async()=>{u(!0),h(null);try{const S=await p.get("/mfa/status");return o(S),S}catch(S){const C=B.handleApiError(S,"Unable to load two-factor authentication status. Please try again.");throw h(C),C}finally{u(!1)}},[p]),w=d.useCallback(async()=>{u(!0),h(null),a("loading");try{const S=await p.post("/mfa/setup",{});return l(S),a("setup"),S}catch(S){const C=B.handleApiError(S,"Unable to start two-factor setup. Please try again.");throw h(C),a("error"),C}finally{u(!1)}},[p]),g=d.useCallback(async S=>{if(!/^\d{6}$/.test(S)){const C={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw h(C),C}u(!0),h(null),a("verifying");try{await p.post("/mfa/enable",{code:S}),a("success");try{const C=await p.get("/mfa/status");o(C)}catch{o({enabled:!0,recoveryCodesRemaining:0})}}catch(C){const f=B.handleApiError(C,"Incorrect verification code. Please check and try again.");throw h(f),a("error"),f}finally{u(!1)}},[p]),k=d.useCallback(async S=>{if(!S){const C={code:"VALIDATION_ERROR",message:"Please enter your password"};throw h(C),C}u(!0),h(null);try{await p.post("/mfa/disable",{password:S}),o({enabled:!1,recoveryCodesRemaining:0}),l(null),a("idle")}catch(C){const f=B.handleApiError(C,"Unable to disable two-factor authentication. Please try again.");throw h(f),f}finally{u(!1)}},[p]),A=d.useCallback(async S=>{if(!/^\d{6}$/.test(S)){const C={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw h(C),C}u(!0),h(null);try{return await p.post("/mfa/recovery-codes/regenerate",{code:S})}catch(C){const f=B.handleApiError(C,"Unable to regenerate recovery codes. Please try again.");throw h(f),f}finally{u(!1)}},[p]),j=d.useCallback(()=>h(null),[]),N=d.useCallback(()=>{h(null),l(null),a("idle"),u(!1)},[]);return{status:r,setupState:n,setupData:i,isLoading:c,error:m,getStatus:b,beginSetup:w,enableTotp:g,disableTotp:k,regenerateBackupCodes:A,clearError:j,reset:N}}function ir({onSuccess:t,onCancel:s,className:r=""}){const{setupState:o,setupData:n,isLoading:a,error:i,beginSetup:l,enableTotp:c,clearError:u,reset:m}=ar(),[h,p]=d.useState("qr"),[b,w]=d.useState(""),[g,k]=d.useState(!1),[A,j]=d.useState(!1),N=d.useRef(null);d.useEffect(()=>{o==="idle"&&l().catch(()=>{})},[o,l]),d.useEffect(()=>{o==="success"&&t?.()},[o,t]);const S=async()=>{n?.secret&&(await navigator.clipboard.writeText(n.secret),k(!0),N.current!==null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>k(!1),2e3))},C=async()=>{if(n?.recoveryCodes){const x=n.recoveryCodes.join(`
|
|
2057
|
+
`);await navigator.clipboard.writeText(x)}},f=async()=>{try{await c(b)}catch{w("")}},y=()=>{m(),s?.()};return d.useEffect(()=>()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null)},[]),o==="loading"||o==="idle"&&a?e.jsx("div",{className:`cedros-totp-setup ${r}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(V.LoadingSpinner,{size:"lg",label:"Setting up two-factor authentication"})})}):o==="error"&&!n?e.jsxs("div",{className:`cedros-totp-setup ${r}`,children:[e.jsx(J.ErrorMessage,{error:i,onDismiss:u}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>l(),children:"Try again"})]})]}):o==="success"?e.jsx("div",{className:`cedros-totp-setup ${r}`,children:e.jsxs("div",{className:"cedros-totp-success",children:[e.jsxs("svg",{className:"cedros-totp-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"var(--cedros-success)",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"var(--cedros-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication enabled"}),e.jsx("p",{className:"cedros-totp-description",children:"Your account is now protected with an additional layer of security."})]})}):n?e.jsxs("div",{className:`cedros-totp-setup ${r}`,children:[h==="qr"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Scan QR code"}),e.jsx("p",{className:"cedros-totp-description",children:"Use your authenticator app to scan this QR code."}),e.jsx("div",{className:"cedros-totp-qr",children:e.jsx($l,{value:n.otpauthUri,size:200,alt:"QR code for authenticator app"})}),e.jsxs("div",{className:"cedros-totp-manual",children:[e.jsx("p",{className:"cedros-totp-manual-label",children:"Or enter this code manually:"}),e.jsxs("div",{className:"cedros-totp-secret",children:[e.jsx("code",{className:"cedros-totp-secret-code",children:n.secret}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:S,"aria-label":"Copy secret",children:g?"Copied!":"Copy"})]})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>p("backup"),children:"Continue"})]})]}),h==="backup"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Save recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. You can use them to access your account if you lose your authenticator device."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:n.recoveryCodes.map((x,v)=>e.jsx("code",{className:"cedros-totp-backup-code",children:x},v))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:C,children:"Copy all codes"}),e.jsxs("label",{className:"cedros-checkbox-label cedros-totp-confirm",children:[e.jsx("input",{type:"checkbox",className:"cedros-checkbox",checked:A,onChange:x=>j(x.target.checked)}),e.jsx("span",{className:"cedros-checkbox-text",children:"I have saved these recovery codes"})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>p("qr"),children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>p("verify"),disabled:!A,children:"Continue"})]})]}),h==="verify"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Verify setup"}),e.jsx("p",{className:"cedros-totp-description",children:"Enter the 6-digit code from your authenticator app to complete setup."}),e.jsx(Q.OtpInput,{value:b,onChange:w,onComplete:f,disabled:a,error:i?.message,autoFocus:!0}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>p("backup"),disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:f,disabled:a||b.length!==6,children:a?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Verifying..."})]}):"Enable 2FA"})]})]})]}):null}function Oo({onStatusChange:t,className:s=""}){const{status:r,isLoading:o,error:n,getStatus:a,disableTotp:i,regenerateBackupCodes:l,clearError:c}=ar(),[u,m]=d.useState("status"),[h,p]=d.useState(""),[b,w]=d.useState(""),[g,k]=d.useState(null),[A,j]=d.useState(!1),[N,S]=d.useState(null);d.useEffect(()=>{a().catch(()=>{})},[a]);const C=d.useCallback(()=>{m("status"),t?.(!0)},[t]),f=async()=>{j(!0),S(null);try{await i(h),m("status"),p(""),t?.(!1)}catch(v){S(v instanceof Error?v.message:"Failed to disable 2FA"),p("")}finally{j(!1)}},y=async()=>{j(!0),S(null);try{const v=await l(b);k(v.recoveryCodes),w("")}catch(v){S(v instanceof Error?v.message:"Failed to regenerate codes"),w("")}finally{j(!1)}},x=async()=>{g&&await navigator.clipboard.writeText(g.join(`
|
|
2058
|
+
`))};return o&&!r?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(V.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):n&&!r?e.jsxs("div",{className:`cedros-totp-settings ${s}`,children:[e.jsx(J.ErrorMessage,{error:n,onDismiss:c}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>a(),children:"Retry"})]}):u==="setup"?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsx(ir,{onSuccess:C,onCancel:()=>m("status")})}):u==="disable"?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Disable two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description cedros-totp-warning",children:"This will make your account less secure. Enter your password to confirm."}),N&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(J.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:N},onDismiss:()=>S(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.PasswordInput,{label:"Password",placeholder:"Enter your password",value:h,onChange:v=>p(v.target.value),disabled:A,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{m("status"),p(""),S(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:f,disabled:A||h.length===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):u==="regenerate"?g?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"New recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. Your old codes are no longer valid."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:g.map((v,_)=>e.jsx("code",{className:"cedros-totp-backup-code",children:v},_))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:x,children:"Copy all codes"}),e.jsx("div",{className:"cedros-totp-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>{m("status"),k(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Regenerate recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"This will invalidate all existing recovery codes. Enter your authenticator code to confirm."}),N&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(J.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:N},onDismiss:()=>S(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.OtpInput,{value:b,onChange:w,onComplete:y,disabled:A,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{m("status"),w(""),S(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:y,disabled:A||b.length!==6,children:A?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsxs("div",{className:"cedros-totp-status-header",children:[e.jsxs("div",{className:"cedros-totp-status-info",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description",children:"Add an extra layer of security to your account by requiring a verification code from your authenticator app when signing in with email and password. Other sign-in methods (Google, Apple, passkeys) use their own built-in verification."})]}),e.jsx("div",{className:`cedros-totp-badge ${r?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:r?.enabled?"Enabled":"Disabled"})]}),r?.enabled?e.jsxs("div",{className:"cedros-totp-enabled-actions",children:[e.jsxs("div",{className:"cedros-totp-description",style:{marginTop:"0.25rem"},children:["Recovery codes remaining: ",e.jsx("strong",{children:r.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>m("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>m("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>m("setup"),children:"Enable two-factor authentication"})]})})}class Kl{client;constructor(s,r,o,n){this.client=new B.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async changePassword(s){try{return await this.client.post("/auth/change-password",s)}catch(r){throw B.handleApiError(r,"Failed to change password")}}async updateProfile(s){try{return await this.client.patch("/auth/me",s)}catch(r){throw B.handleApiError(r,"Failed to update profile")}}}function dt(){const{config:t,authState:s,_internal:r}=B.useCedrosLogin(),[o,n]=d.useState(!1),[a,i]=d.useState(null),l=d.useMemo(()=>new Kl(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),c=d.useCallback(()=>{i(null)},[]),u=d.useCallback(async h=>{if(s!=="authenticated")throw new Error("Must be authenticated to update profile");n(!0),i(null);try{return await l.updateProfile(h)}catch(p){const b=p instanceof Error?p:new Error("Failed to update profile");throw i(b),b}finally{n(!1)}},[s,l]),m=d.useCallback(async h=>{if(s!=="authenticated")throw new Error("Must be authenticated to change password");n(!0),i(null);try{await l.changePassword(h)}catch(p){const b=p instanceof Error?p:new Error("Failed to change password");throw i(b),b}finally{n(!1)}},[s,l]);return{isLoading:o,error:a,updateProfile:u,changePassword:m,clearError:c}}function qo(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),i=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),l=d.useCallback(async()=>{o(!0),a(null);try{return await i.get("/referral",{credentials:"include"})}catch(u){const m=u instanceof Error?u:new Error(String(u));throw a(m),m}finally{o(!1)}},[i]),c=d.useCallback(async()=>{o(!0),a(null);try{return(await i.post("/referral/regenerate",void 0,{credentials:"include"})).referralCode}catch(u){const m=u instanceof Error?u:new Error(String(u));throw a(m),m}finally{o(!1)}},[i]);return{getReferral:l,regenerateCode:c,isLoading:r,error:n}}function Gl({onPasswordChange:t,onClose:s,className:r=""}){const{user:o,refreshUser:n}=U.useAuth(),{config:a,_internal:i}=B.useCedrosLogin(),{isLoading:l,error:c,changePassword:u,updateProfile:m,clearError:h}=dt(),[p,b]=d.useState("main"),[w,g]=d.useState(""),[k,A]=d.useState(""),[j,N]=d.useState(""),[S,C]=d.useState(null),[f,y]=d.useState(null),[x,v]=d.useState(!1),_=d.useRef(null),[E,P]=d.useState(o?.payoutWalletAddress??""),[L,R]=d.useState(!1),[T,M]=d.useState(!1),[F,W]=d.useState(null),q=d.useCallback(async()=>{const H=E.trim();if(H.length>0&&(H.length<32||H.length>44)){W("Invalid Solana address — must be 32–44 characters.");return}const ge=/^[1-9A-HJ-NP-Za-km-z]+$/;if(H.length>0&&!ge.test(H)){W("Invalid Solana address — contains non-base58 characters.");return}W(null),R(!0);try{await m({payoutWalletAddress:H||void 0}),await n(),M(!0),setTimeout(()=>M(!1),2e3)}catch(be){W(be instanceof Error?be.message:"Failed to save payout wallet")}finally{R(!1)}},[E,m,n]),{getReferral:I,regenerateCode:D,isLoading:$}=qo(),[Z,se]=d.useState(null),[pe,he]=d.useState(0),[K,z]=d.useState(!1),[X,ce]=d.useState(!1);d.useEffect(()=>{I().then(H=>{se(H.referralCode),he(H.referralCount),ce(H.directPayoutEnabled)}).catch(()=>{})},[]);const we=Oe.validatePassword(k),tt=k===j,Ie=w.length>0&&k.length>0&&j.length>0&&we.isValid&&tt,Ue=d.useCallback(async H=>{const ge=H.target.files?.[0];if(ge){C(null),v(!0);try{const be=new FormData;be.append("file",ge);const ut=i?.getAccessToken?.(),De={};ut&&(De.Authorization=`Bearer ${ut}`);const He=await fetch(`${a.serverUrl}/auth/upload/avatar`,{method:"POST",headers:De,body:be,credentials:"include"});if(!He.ok){const $e=await He.json().catch(()=>null);throw new Error($e?.message||$e?.error||`Upload failed (${He.status})`)}await n()}catch(be){C(be instanceof Error?be.message:"Failed to upload avatar")}finally{v(!1),_.current&&(_.current.value="")}}},[a.serverUrl,i,n]),Vt=d.useCallback(async()=>{if(Ie){C(null),y(null);try{await u({currentPassword:w,newPassword:k}),g(""),A(""),N(""),y("Password changed successfully. Other sessions have been logged out."),t?.(),setTimeout(()=>{b("main"),y(null)},2e3)}catch(H){C(H instanceof Error?H.message:"Failed to change password")}}},[Ie,w,k,u,t]),st=d.useCallback(()=>{b("main"),g(""),A(""),N(""),C(null),h()},[h]),Ve=()=>o?.name?o.name.split(" ").map(H=>H[0]).join("").toUpperCase().slice(0,2):o?.email?o.email[0].toUpperCase():"?";return p==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(S||c)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(J.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:S||c?.message||""},onDismiss:()=>{C(null),h()}})}),f&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),f]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:w,onChange:H=>g(H.target.value),disabled:l,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"New password",placeholder:"Enter new password",value:k,onChange:H=>A(H.target.value),disabled:l,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:j,onChange:H=>N(H.target.value),disabled:l,error:j.length>0&&!tt?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:st,disabled:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:Vt,disabled:l||!Ie,children:l?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})}):e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsxs("div",{className:"cedros-profile-avatar-container cedros-profile-avatar-container--clickable",onClick:()=>_.current?.click(),role:"button",tabIndex:0,onKeyDown:H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),_.current?.click())},"aria-label":"Change profile picture",children:[x?e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:e.jsx(V.LoadingSpinner,{size:"sm"})}):o?.picture?e.jsx("img",{src:o.picture,alt:o.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:Ve()}),e.jsx("div",{className:"cedros-profile-avatar-overlay",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),e.jsx("circle",{cx:"12",cy:"13",r:"4"})]})}),e.jsx("input",{ref:_,type:"file",accept:"image/jpeg,image/png,image/gif,image/webp",onChange:Ue,className:"cedros-profile-avatar-input","aria-hidden":"true",tabIndex:-1})]}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:o?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:o?.email})]})]}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:o?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:"••••••••"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>b("change-password"),children:"Change"})]})]}),Z&&e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Referral"}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Your code"}),e.jsx("span",{className:"cedros-profile-row-value cedros-profile-row-value--mono",children:Z})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{navigator.clipboard.writeText(Z),z(!0),setTimeout(()=>z(!1),2e3)},children:K?"Copied":"Copy"})]}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Referrals"}),e.jsx("span",{className:"cedros-profile-row-value",children:pe})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:async()=>{try{const H=await D();se(H)}catch{}},disabled:$,children:$?"Regenerating...":"Regenerate"})]})]}),X&&e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Payout wallet"}),e.jsx("p",{className:"cedros-profile-description",children:"Solana wallet address to receive direct referral payouts when enabled by the platform."}),e.jsxs("div",{className:"cedros-profile-row cedros-profile-row--column",children:[e.jsx("input",{type:"text",className:"cedros-input",placeholder:"Solana wallet address (base58)",value:E,onChange:H=>{P(H.target.value),W(null)},disabled:L,maxLength:44}),F&&e.jsx("span",{className:"cedros-profile-error-text",children:F}),T&&e.jsx("span",{className:"cedros-profile-success-text",children:"Saved."})]}),e.jsx("div",{className:"cedros-profile-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:q,disabled:L,children:L?"Saving...":"Save wallet"})})]}),s&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:s,children:"Close"})})]})})}class Ql{client;constructor(s,r,o,n){this.client=new B.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listCredentials(){try{return(await this.client.get("/credentials")).credentials}catch(s){throw B.handleApiError(s,"Failed to list credentials")}}async unlinkCredential(s){try{await this.client.delete(`/credentials/${encodeURIComponent(s)}`)}catch(r){throw B.handleApiError(r,"Failed to unlink credential")}}}function cr(){const{config:t,authState:s,_internal:r}=B.useCedrosLogin(),[o,n]=d.useState([]),[a,i]=d.useState(!1),[l,c]=d.useState(null),u=d.useMemo(()=>new Ql(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),m=d.useCallback(()=>{c(null)},[]),h=d.useCallback(async()=>{if(s!=="authenticated"){n([]);return}i(!0),c(null);try{const b=await u.listCredentials();n(b)}catch(b){c(b)}finally{i(!1)}},[s,u]);d.useEffect(()=>{s==="authenticated"?h():n([])},[s,h]);const p=d.useCallback(async b=>{i(!0),c(null);try{await u.unlinkCredential(b),await h()}catch(w){throw c(w),w}finally{i(!1)}},[u,h]);return{credentials:o,isLoading:a,error:l,fetchCredentials:h,unlinkCredential:p,clearError:m}}function Yl({onPasswordChange:t,onCancel:s,className:r=""}){const{isLoading:o,error:n,changePassword:a,clearError:i}=dt(),[l,c]=d.useState(""),[u,m]=d.useState(""),[h,p]=d.useState(""),[b,w]=d.useState(null),[g,k]=d.useState(null),A=Oe.validatePassword(u),j=u===h,N=l.length>0&&u.length>0&&h.length>0&&A.isValid&&j,S=d.useCallback(async()=>{if(N){w(null),k(null);try{await a({currentPassword:l,newPassword:u}),c(""),m(""),p(""),k("Password changed successfully. Other sessions have been logged out."),t?.(),setTimeout(()=>s(),2e3)}catch(f){w(f instanceof Error?f.message:"Failed to change password")}}},[N,l,u,a,t,s]),C=d.useCallback(()=>{w(null),i(),s()},[i,s]);return e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(b||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(J.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:b||n?.message||""},onDismiss:()=>{w(null),i()}})}),g&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),g]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:l,onChange:f=>c(f.target.value),disabled:o,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"New password",placeholder:"Enter new password",value:u,onChange:f=>m(f.target.value),disabled:o,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:h,onChange:f=>p(f.target.value),disabled:o,error:h.length>0&&!j?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:C,disabled:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:S,disabled:o||!N,children:o?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})})}function zo({onPasswordChange:t,className:s=""}){const{user:r,refreshUser:o}=U.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:l}=dt(),{credentials:c}=cr(),{forgotPassword:u,isLoading:m,isSuccess:h,reset:p}=Ft(),b=c.some(v=>v.credentialType==="password"),[w,g]=d.useState("view"),[k,A]=d.useState(""),[j,N]=d.useState(null),S=()=>r?.name?r.name.split(" ").map(v=>v[0]).join("").toUpperCase().slice(0,2):r?.email?r.email[0].toUpperCase():"?",C=d.useCallback(()=>{A(r?.name||""),g("edit"),N(null)},[r?.name]),f=d.useCallback(async()=>{const v=k.trim();if(v){N(null);try{await i({name:v}),await o(),g("view")}catch(_){N(_ instanceof Error?_.message:"Failed to update name")}}},[k,i,o]),y=d.useCallback(()=>{g("view"),A(""),N(null),l()},[l]),x=d.useCallback(async()=>{if(r?.email){N(null);try{await u(r.email)}catch(v){N(v instanceof Error?v.message:"Failed to send password setup email")}}},[r?.email,u]);return w==="change-password"?e.jsx(Yl,{onPasswordChange:t,onCancel:()=>g("view"),className:s}):e.jsx("div",{className:`cedros-profile-settings ${s}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children:r?.picture?e.jsx("img",{src:r.picture,alt:r.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:S()})}),e.jsxs("div",{className:"cedros-profile-info",children:[w==="edit"?e.jsxs("div",{className:"cedros-profile-name-edit",children:[e.jsx("input",{type:"text",className:"cedros-input",value:k,onChange:v=>A(v.target.value),disabled:n,autoFocus:!0,onKeyDown:v=>{v.key==="Enter"&&f(),v.key==="Escape"&&y()}}),e.jsxs("div",{className:"cedros-profile-name-edit-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:f,disabled:n||!k.trim(),children:n?e.jsx(V.LoadingSpinner,{size:"sm"}):"Save"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:y,disabled:n,children:"Cancel"})]})]}):e.jsxs("div",{className:"cedros-profile-name-row",children:[e.jsx("h3",{className:"cedros-profile-name",children:r?.name||"User"}),e.jsx("button",{type:"button",className:"cedros-profile-edit-btn",onClick:C,title:"Edit name","aria-label":"Edit name",children:e.jsx(Zl,{})})]}),e.jsx("p",{className:"cedros-profile-email",children:r?.email})]})]}),(j||a)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(J.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:j||a?.message||""},onDismiss:()=>{N(null),l()}})}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:r?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:b?"••••••••":"Not set"})]}),b?e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{g("change-password"),N(null)},children:"Change"}):h?e.jsxs("span",{className:"cedros-profile-row-sent",children:["Check your email",e.jsx("button",{type:"button",className:"cedros-profile-row-sent-dismiss",onClick:p,"aria-label":"Dismiss",children:"×"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:x,disabled:m,children:m?e.jsx(V.LoadingSpinner,{size:"sm"}):"Add password"})]})]})]})})}function Zl(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M16.474 5.408l2.118 2.117m-.756-3.982L12.109 9.27a2.118 2.118 0 00-.58 1.082L11 13l2.648-.53c.41-.082.786-.283 1.082-.579l5.727-5.727a1.853 1.853 0 10-2.621-2.621z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M19 15v3a2 2 0 01-2 2H6a2 2 0 01-2-2V7a2 2 0 012-2h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Vo={password:"Email & Password",oauth_google:"Google",oauth_apple:"Apple",solana:"Solana Wallet",webauthn_passkey:"Passkey",webauthn_security_key:"Security Key",totp:"Authenticator App (2FA)",sso_oidc:"Single Sign-On"};function Ho({onLinkGoogle:t,onLinkApple:s,onAddPasskey:r,onLinkSolana:o,className:n=""}){const{credentials:a,isLoading:i,error:l,unlinkCredential:c,clearError:u,fetchCredentials:m}=cr(),{registerPasskey:h,isSupported:p}=rr(),[b,w]=d.useState(null),[g,k]=d.useState(!1),A=d.useCallback(async()=>{if(r){r();return}k(!0);try{await h(),await m()}catch{}finally{k(!1)}},[r,h,m]),j=d.useCallback(async v=>{const _=v.label||Vo[v.credentialType];if(window.confirm(`Remove "${_}" as a sign-in method? You won't be able to sign in with it anymore.`)){w(v.id);try{await c(v.id)}catch{}finally{w(null)}}},[c]),N=new Set(a.map(v=>v.credentialType)),S=t&&!N.has("oauth_google"),C=s&&!N.has("oauth_apple"),f=(r||p)&&!N.has("webauthn_passkey"),y=o&&!N.has("solana"),x=S||C||f||y;return i&&a.length===0?e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading linked accounts..."})]}):e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[l&&e.jsx(J.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:l.message},onDismiss:u}),a.length===0&&!i&&e.jsx("p",{className:"cedros-linked-accounts-empty",children:"No linked sign-in methods found."}),a.length>0&&e.jsx("ul",{className:"cedros-linked-credential-list",children:a.map(v=>e.jsx(Xl,{credential:v,isUnlinking:b===v.id,onUnlink:j},v.id))}),x&&e.jsxs("div",{className:"cedros-linked-add",children:[e.jsx("p",{className:"cedros-linked-add-label",children:"Link a new sign-in method"}),e.jsxs("div",{className:"cedros-linked-add-buttons",children:[S&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:[e.jsx($o,{})," Google"]}),C&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(Ko,{})," Apple"]}),f&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:A,disabled:g,children:g?e.jsx(V.LoadingSpinner,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(zs,{})," Passkey"]})}),y&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:[e.jsx(Go,{})," Solana"]})]})]})]})}function Xl({credential:t,isUnlinking:s,onUnlink:r}){const o=t.label||Vo[t.credentialType],n=Jl[t.credentialType]||ed;return e.jsxs("li",{className:"cedros-linked-credential",children:[e.jsx("div",{className:"cedros-linked-credential__icon",children:e.jsx(n,{})}),e.jsxs("div",{className:"cedros-linked-credential__info",children:[e.jsx("span",{className:"cedros-linked-credential__name",children:o}),e.jsxs("span",{className:"cedros-linked-credential__meta",children:["Added ",jn(t.createdAt),t.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",jn(t.lastUsedAt)]}),t.isPrimary&&e.jsx(e.Fragment,{children:" · Primary"})]})]}),e.jsx("div",{className:"cedros-linked-credential__action",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-button-danger-outline",onClick:()=>r(t),disabled:s,title:t.isPrimary?"Cannot remove primary sign-in method":"Remove",children:s?e.jsx(V.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function jn(t){const s=new Date(t),o=new Date().getTime()-s.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),i=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n}m ago`:a<24?`${a}h ago`:i<30?`${i}d ago`:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const Jl={password:td,oauth_google:$o,oauth_apple:Ko,solana:Go,webauthn_passkey:zs,webauthn_security_key:zs,totp:sd,sso_oidc:rd};function ed(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M12 8v4m0 4h.01",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function td(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M7 11V7a5 5 0 0110 0v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"16",r:"1.5",fill:"currentColor"})]})}function $o(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M21.8 12.2c0-.7-.1-1.4-.2-2H12v3.8h5.5a4.7 4.7 0 01-2 3.1v2.5h3.3c1.9-1.7 3-4.3 3-7.4z",fill:"#4285F4"}),e.jsx("path",{d:"M12 22c2.7 0 5-.9 6.6-2.4l-3.3-2.5c-.9.6-2 1-3.3 1-2.5 0-4.7-1.7-5.4-4H3.2v2.6A10 10 0 0012 22z",fill:"#34A853"}),e.jsx("path",{d:"M6.6 14.1a6 6 0 010-4.2V7.3H3.2a10 10 0 000 9.4l3.4-2.6z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.9c1.4 0 2.7.5 3.7 1.4l2.8-2.8A10 10 0 0012 2 10 10 0 003.2 7.3l3.4 2.6C7.3 7.6 9.5 5.9 12 5.9z",fill:"#EA4335"})]})}function Ko(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C3.79 16.16 4.36 9.53 8.72 9.28c1.3.07 2.2.74 2.96.8.93-.2 1.82-.92 3.03-.83 1.47.12 2.57.72 3.28 1.83-3.02 1.8-2.3 5.75.5 6.86-.6 1.53-1.37 3.04-2.44 4.34zM12.03 9.2C11.88 7.17 13.5 5.5 15.4 5.35c.29 2.28-2.08 3.98-3.37 3.85z",fill:"currentColor"})})}function Go(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M2 10h20",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"17",cy:"14",r:"1.5",fill:"currentColor"})]})}function zs(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"10",cy:"7",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M3 21v-2a7 7 0 017-7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M17 14v4m0 0v2m0-2h-2m2 0h2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function sd(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M9 12h6M12 9v6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function rd(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"})]})}class nd{client;constructor(s,r,o,n){this.client=new B.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(s){throw B.handleApiError(s,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(s){throw B.handleApiError(s,"Failed to revoke sessions")}}}function Qo(){const{config:t,authState:s,_internal:r}=B.useCedrosLogin(),[o,n]=d.useState([]),[a,i]=d.useState(!1),[l,c]=d.useState(null),u=d.useMemo(()=>new nd(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),m=d.useCallback(async()=>{if(s!=="authenticated"){n([]);return}i(!0),c(null);try{const b=await u.listSessions();n(b)}catch(b){c(b)}finally{i(!1)}},[s,u]);d.useEffect(()=>{s==="authenticated"?m():n([])},[s,m]);const h=d.useCallback(async()=>{i(!0),c(null);try{const b=await u.revokeAllSessions();return await m(),b}catch(b){throw c(b),b}finally{i(!1)}},[u,m]),p=d.useMemo(()=>o.filter(b=>!b.isCurrent).length,[o]);return{sessions:o,isLoading:a,error:l,fetchSessions:m,revokeAllSessions:h,otherSessionCount:p}}const od={profile:"Profile",security:"Security",linked:"Linked Accounts"},ad=["profile","security","linked"];function id({defaultTab:t="profile",onClose:s,onPasswordChange:r,onTotpChange:o,onLinkGoogle:n,onLinkApple:a,onAddPasskey:i,onLinkSolana:l,className:c=""}){const[u,m]=d.useState(t),{sessions:h,isLoading:p,error:b,revokeAllSessions:w}=Qo();return e.jsxs("div",{className:`cedros-account-settings ${c}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:ad.map(g=>e.jsx("button",{type:"button",role:"tab","aria-selected":u===g,className:`cedros-account-tab ${u===g?"cedros-account-tab-active":""}`,onClick:()=>m(g),children:od[g]},g))}),e.jsxs("div",{className:"cedros-account-tab-content",role:"tabpanel",children:[u==="profile"&&e.jsx(zo,{onPasswordChange:r}),u==="security"&&e.jsxs("div",{className:"cedros-account-security",children:[e.jsx(Oo,{onStatusChange:o}),e.jsx(xo,{sessions:h,isLoading:p,error:b??void 0,onRevokeAll:async()=>{await w()}})]}),u==="linked"&&e.jsx(Ho,{onLinkGoogle:n,onLinkApple:a,onAddPasskey:i,onLinkSolana:l})]}),s&&e.jsx("div",{className:"cedros-account-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:s,children:"Close"})})]})}function cd({onComplete:t,className:s}){return e.jsxs("div",{className:`cedros-mfa-setup-prompt ${s??""}`,children:[e.jsxs("div",{className:"cedros-mfa-setup-prompt__header",children:[e.jsx("h2",{className:"cedros-mfa-setup-prompt__title",children:"Two-factor authentication required"}),e.jsx("p",{className:"cedros-mfa-setup-prompt__description",children:"Your administrator requires you to set up two-factor authentication before continuing. This adds an extra layer of security to your account."})]}),e.jsx("div",{className:"cedros-mfa-setup-prompt__body",children:e.jsx(ir,{onSuccess:t})})]})}function ld({onComplete:t,onSkip:s,className:r}){const{user:o}=U.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:l}=dt(),[c,u]=d.useState(o?.name??""),m=d.useCallback(async p=>{p.preventDefault(),l();const b=c.trim();if(!b){t?.();return}try{await i({name:b}),t?.()}catch{}},[c,i,l,t]),h=c.trim().length>0;return e.jsxs("div",{className:`cedros-complete-account ${r??""}`,children:[e.jsxs("div",{className:"cedros-complete-account__header",children:[e.jsx("h2",{className:"cedros-complete-account__title",children:"Complete Your Profile"}),e.jsx("p",{className:"cedros-complete-account__description",children:"Please fill in your name to get started."})]}),e.jsxs("form",{onSubmit:m,className:"cedros-complete-account__form",children:[e.jsxs("div",{className:"cedros-complete-account__field",children:[e.jsx("label",{htmlFor:"cedros-complete-name",className:"cedros-complete-account__label",children:"Name"}),e.jsx("input",{id:"cedros-complete-name",type:"text",value:c,onChange:p=>u(p.target.value),placeholder:"Enter your name",className:"cedros-complete-account__input",maxLength:100,autoFocus:!0})]}),a&&e.jsx("div",{className:"cedros-complete-account__error",role:"alert",children:a.message}),e.jsxs("div",{className:"cedros-complete-account__actions",children:[e.jsx("button",{type:"submit",className:"cedros-complete-account__button cedros-complete-account__button--primary",disabled:n||!h,children:n?"Saving...":"Save"}),e.jsx("button",{type:"button",className:"cedros-complete-account__button cedros-complete-account__button--secondary",onClick:s,disabled:n,children:"Skip"})]})]})]})}function Yo(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),i=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),l=d.useCallback(async m=>await i.get(`/username/available?username=${encodeURIComponent(m)}`,{credentials:"include"}),[i]),c=d.useCallback(async()=>{try{return(await i.get("/username/available?username=",{credentials:"include"})).suggestion??null}catch{return null}},[i]),u=d.useCallback(async m=>{o(!0),a(null);try{await i.patch("/me",{username:m})}catch(h){const p=h instanceof Error?h:new Error(String(h));throw a(p),p}finally{o(!1)}},[i]);return{checkAvailability:l,getSuggestion:c,setUsername:u,isLoading:r,error:n}}function dd({onComplete:t,onSkip:s,className:r}){const{checkAvailability:o,getSuggestion:n,setUsername:a,isLoading:i,error:l}=Yo(),[c,u]=d.useState(""),[m,h]=d.useState("idle"),[p,b]=d.useState(""),w=d.useRef(null),g=d.useRef(!0);d.useEffect(()=>(g.current=!0,n().then(N=>{g.current&&N&&(u(N),h("available"),b("Available"))}),()=>{g.current=!1}),[n]);const k=d.useCallback(N=>{const S=N.toLowerCase().replace(/[^a-z0-9_]/g,"");if(u(S),h("idle"),b(""),w.current&&clearTimeout(w.current),S.length<3){S.length>0&&(h("error"),b("At least 3 characters"));return}h("checking"),w.current=setTimeout(async()=>{try{const C=await o(S);if(!g.current)return;C.error?(h("error"),b(C.error)):C.available?(h("available"),b("Available")):(h("taken"),b("Already taken"),C.suggestion)}catch{if(!g.current)return;h("error"),b("Could not check availability")}},400)},[o]),A=d.useCallback(async N=>{if(N.preventDefault(),!(m!=="available"||!c.trim()))try{await a(c.trim()),t?.()}catch{}},[c,m,a,t]),j=m==="available"&&!i;return e.jsxs("div",{className:`cedros-choose-username ${r??""}`,children:[e.jsxs("div",{className:"cedros-choose-username__header",children:[e.jsx("h2",{className:"cedros-choose-username__title",children:"Choose a Username"}),e.jsx("p",{className:"cedros-choose-username__description",children:"Pick a unique handle for your account."})]}),e.jsxs("form",{onSubmit:A,className:"cedros-choose-username__form",children:[e.jsxs("div",{className:"cedros-choose-username__field",children:[e.jsx("label",{htmlFor:"cedros-choose-username",className:"cedros-choose-username__label",children:"Username"}),e.jsxs("div",{className:"cedros-choose-username__input-wrapper",children:[e.jsx("span",{className:"cedros-choose-username__prefix",children:"@"}),e.jsx("input",{id:"cedros-choose-username",type:"text",value:c,onChange:N=>k(N.target.value),placeholder:"swift_falcon_42",className:"cedros-choose-username__input",maxLength:30,autoFocus:!0,autoComplete:"off",spellCheck:!1})]}),p&&e.jsx("span",{className:`cedros-choose-username__status cedros-choose-username__status--${m}`,role:m==="error"||m==="taken"?"alert":void 0,children:m==="checking"?"Checking...":p})]}),l&&e.jsx("div",{className:"cedros-choose-username__error",role:"alert",children:l.message}),e.jsxs("div",{className:"cedros-choose-username__actions",children:[e.jsx("button",{type:"submit",className:"cedros-choose-username__button cedros-choose-username__button--primary",disabled:!j,children:i?"Saving...":"Continue"}),e.jsx("button",{type:"button",className:"cedros-choose-username__button cedros-choose-username__button--secondary",onClick:s,disabled:i,children:"Skip"})]})]})]})}function Zo(){const t=B.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),a=d.useMemo(()=>t?new B.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),i=d.useCallback(()=>{n(null)},[]),l=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(w)||w<=0){const g=new Error(`Invalid deposit amount: ${w}. Must be a positive integer (lamports).`);throw n(g.message),g}r(!0),n(null);try{return await a.post("/deposit",{amount_lamports:w})}catch(g){const k=B.handleApiError(g,"Failed to execute deposit");throw n(k.message),k}finally{r(!1)}},[a]),c=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");return await a.get(`/deposit/status/${encodeURIComponent(w)}`)},[a]),u=d.useCallback(async()=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/deposit/config")}catch(w){const g=B.handleApiError(w,"Failed to get deposit config");throw n(g.message),g}finally{r(!1)}},[a]),m=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=new URLSearchParams;w?.limit!==void 0&&g.set("limit",String(w.limit)),w?.offset!==void 0&&g.set("offset",String(w.offset));const k=g.toString(),A=k?`/deposits?${k}`:"/deposits";return await a.get(A)}catch(g){const k=B.handleApiError(g,"Failed to list deposits");throw n(k.message),k}finally{r(!1)}},[a]),h=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=new URLSearchParams({input_mint:w.inputMint,amount:String(w.amount),taker:w.taker});return await a.get(`/deposit/quote?${g}`)}catch(g){const k=B.handleApiError(g,"Failed to get deposit quote");throw n(k.message),k}finally{r(!1)}},[a]),p=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/public",w)}catch(g){const k=B.handleApiError(g,"Failed to execute public deposit");throw n(k.message),k}finally{r(!1)}},[a]),b=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/micro",w)}catch(g){const k=B.handleApiError(g,"Failed to execute micro deposit");throw n(k.message),k}finally{r(!1)}},[a]);return{deposit:l,getQuote:h,publicDeposit:p,microDeposit:b,getStatus:c,getConfig:u,listDeposits:m,isLoading:s,error:o,clearError:i}}function lr({tokens:t,selectedToken:s,onSelect:r,openSignal:o,placeholder:n="Select token",disabled:a=!1,className:i="",searchable:l=!0}){const[c,u]=d.useState(!1),[m,h]=d.useState(""),p=d.useRef(null),b=d.useRef(null),w=d.useMemo(()=>{if(!m.trim())return t;const j=m.toLowerCase();return t.filter(N=>N.symbol.toLowerCase().includes(j)||N.name.toLowerCase().includes(j)||N.mint.toLowerCase().includes(j))},[t,m]);d.useEffect(()=>{const j=N=>{p.current&&!p.current.contains(N.target)&&(u(!1),h(""))};if(c)return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[c]),d.useEffect(()=>{c&&l&&b.current&&b.current.focus()},[c,l]),d.useEffect(()=>{o===void 0||a||(u(!0),h(""))},[o,a]);const g=d.useCallback(()=>{a||(u(j=>!j),c&&h(""))},[a,c]),k=d.useCallback(j=>{r(j),u(!1),h("")},[r]),A=d.useCallback(j=>{j.key==="Escape"?(u(!1),h("")):j.key==="Enter"&&w.length===1&&k(w[0])},[w,k]);return e.jsxs("div",{ref:p,className:`cedros-token-selector ${c?"cedros-token-selector-open":""} ${a?"cedros-token-selector-disabled":""} ${i}`,onKeyDown:A,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:g,disabled:a,"aria-haspopup":"listbox","aria-expanded":c,children:[s?e.jsxs("span",{className:"cedros-token-selector-selected",children:[s.logoUrl&&e.jsx("img",{src:s.logoUrl,alt:s.symbol,className:"cedros-token-icon",onError:j=>{j.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:s.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:n}),e.jsx("span",{className:"cedros-token-selector-arrow",children:c?"▲":"▼"})]}),c&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[l&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:b,type:"text",value:m,onChange:j=>h(j.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:w.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:w.map(j=>e.jsxs("button",{type:"button",className:`cedros-token-option ${s?.mint===j.mint?"cedros-token-option-selected":""}`,onClick:()=>k(j),role:"option","aria-selected":s?.mint===j.mint,children:[j.logoUrl&&e.jsx("img",{src:j.logoUrl,alt:j.symbol,className:"cedros-token-icon",onError:N=>{N.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:j.symbol}),e.jsx("span",{className:"cedros-token-name",children:j.name})]}),s?.mint===j.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},j.mint))})})]})]})}function Ot(t,s){return s.privateDepositsEnabled&&t>=s.privateMinUsd?"private":t>=s.publicMinUsd?"public":"sol_micro"}const dr="data:image/webp;base64,UklGRkACAABXRUJQVlA4IDQCAACQDQCdASo8ADwAPjEWiUMiISEUBFQgAwSgB4Z/TeLt3XMAoQH23eph0gPMB+sn+M9tvngOsA9ADwgPg3/cH9sfZciikEBuA1AB+nf+84CUkAVvA2x4xvyobR+mBaYhjUv/ewHb4hTqOnP38rzsxZX2inOSciAA/v7uqvqGdpWcjjrfMDFaNHumTog38t3yor0kbjn631VsX61cAC749wWuAX74u/f/hpeDFqS/ci8E1g94wk9UVs7BHqtv7f/M9iT1u5ITJV0Gv6tE/CW5j/nVR6yExJ6JoDRDOWQ8zVpWH92r3Lnbnc4WJpOchbRT3H5rv//6PP+F//4ehLUlR/4tkRUKZu/yOa26+sywmY+Xc1X2lXMcUv7+eQ7+FBE7bhKc7htieBfH4eR134AVaILL7PWA2FjzAjfaP1Lgirqoq/ZooE8jVD/b4g3J3O3/TG/4ajHe6clnAI/4NdwrnHX0P/quBU03HqSsQ0qsEMAuhrH/jn+YtDzmjm8q/cGJ44qvi24Hn+G1kxz2XP2S/Gp7ri5cMlo+muuwBjyNJnnEcTt/5cRdYS2cbEBZtpINWj3PuC1EOsd/8cTepSpxODcJHLzktfC1PHW3Pgoh3J5PHjW3TCQ1Wlu/wP8e8OPfNm48BODGChioj3ezblqrOBV+cI+hLi7ReJdvBF/4jY+/Un0asuWnrA6kRNpgOeO8wyl4Ryhkrff+9R1SpyPYP+5T3EuWWLZaCn0bGzyk97S3VAAAAAA=",ud=1e4,It=1e3,Xo=3;function hd(t){return Number.isFinite(t)?`$${Math.round(t)}`:"$0"}function md(t,s){switch(t){case"private":return{label:"Private",detail:"Private transaction, instant credit",note:null};case"public":return{label:"Public",detail:"Visible on-chain, instant credit",note:null};case"sol_micro":return{label:"SOL Only",detail:`SOL only under ${hd(s.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function ur(t,s,r){return Math.min(Math.max(t,s),r)}function fd(t,s){if(s<=0)return 0;const r=ur(t/s,0,1);return Math.round(Math.pow(r,1/Xo)*It)}function pd(t,s){const r=ur(t/It,0,1);return s*Math.pow(r,Xo)}function Jo(t){return t<10?.01:t<100?1:t<500?5:t<1e3?10:t<5e3?25:50}function gd(t){return t<1?2:0}function kn(t){const s=Jo(t),r=Math.round(t/s)*s,o=gd(s);return Number(r.toFixed(o))}function hr({config:t,valueUsd:s,onChange:r,maxUsd:o=ud,disabled:n=!1,className:a=""}){const i=ur(Number.isFinite(s)?s:0,0,o),l=d.useMemo(()=>Ot(i,t),[i,t]),c=md(l,t),u=fd(i,o),m=u/It*100;return e.jsxs("div",{className:`cedros-tiered-slider ${a}`,children:[e.jsxs("div",{className:"cedros-tiered-slider-input-row",children:[e.jsxs("div",{className:"cedros-tiered-slider-input",children:[e.jsx("span",{className:"cedros-tiered-slider-currency",children:"$"}),e.jsx("input",{type:"number",value:i||"",onChange:h=>r(kn(Math.max(0,Math.min(parseFloat(h.target.value)||0,o)))),placeholder:"Enter amount",disabled:n,min:0,step:Jo(i),className:"cedros-deposit-flow-input cedros-tiered-slider-input-field","aria-label":"Deposit amount"})]}),e.jsxs("div",{className:"cedros-tiered-slider-tier",children:[e.jsxs("span",{className:`cedros-tiered-slider-badge cedros-tiered-slider-badge-${l}`,children:[l==="sol_micro"&&e.jsx("img",{src:dr,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),c.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:c.detail})]})]}),e.jsx("input",{type:"range",min:0,max:It,step:1,value:u,onChange:h=>r(kn(pd(parseFloat(h.target.value),o))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${m}%, var(--cedros-border) ${m}%, var(--cedros-border) 100%)`},disabled:n,"aria-label":"Deposit amount slider"}),c.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:c.note})]})}const wd="data:image/webp;base64,UklGRmIEAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IIIDAADwDwCdASo8ADwAPm0qkUWkIqGWDVeYQAbEtgBOmZMBu+H816ov3b8R8R2g2FXtxdyh5s3+A60v0APLi9ktgGB/LZjWNAXqgpE6jfW0NF+P4xEhH2L7M+26iGwrTjjcQegyCZqxs+ifvZANjWd279diqZNKUrgOTVtjJGtW4IVtRhMECd5aWVgAAP7nDv3UY/8f1l//xTP/FM/8NU8c9g//sC3+bX/1HZXsNsM57VKG2LVf1a0KdncWO8uPo/Oh79m9ZqjJZwXfPXuvwkK+WDOl6+N8C2Ux6no/V/zkoucKK/JZek7MR5sS8TknXB+6BuVDXou9Rx4aUea2q2IzvLvFIujjKsVYLMab7j9zo48fhgm9YOtjmWuS0WZ4c+6ta0mr3xF4fcdAIFf6oXRSlqovOX0HUiMV//hXwSX1cfP5cLj8c7OTyT/4ce4olJARV95GoY8oF+2uU0blGul3ItlG7c2Hl2/uC6s2WZc7Zukwojx6ed8t97bZ68N1uzCLzPlG7BuYS17F19e0wXnc6vEl3q7ft0K7OEl7r8mY6Kh+Nt/5V/Lp68mFBjLem1JjvC371+lKwez4KCdXwNo2Z04FqyzGpFutY6YQ/r5Tfu7Oi+oNfN0R/W+D4aj1nqHhlqYJzpx2NK4mj0gJIXmX8EArelSQI8mV4Ux9MRPwC2PuZhLTjQZv+Vl4p0D8bSB+Z0rek3hS6G1r80fW3cn767Pz/bXanjVmm34wt1nQPqdJObrZ7vv2NWcEuQKj9d+V6DzeDrq0CtGNcanEB5MY9agi1E6BprEScTdfPXjBeMnPbpD+QO6P7IW4UZ9etCCHtX++S/fl5Iz5RzUr10ojRMw//35C0yTjSEhbe884dPwor64n//KByjUFEGsCPAAXPJp1+O+SiKfUaODq6ncjKayTHXjoXgM7XP1z4sBhIKJZJRiM7vGC/+v/Sk8/jbgZLZDAVz1vLou93y7Yd8hxcWM/BesxgWgeKvl8fjE/Ud8tQKp4425hWh66lzzwxa4J3ctA4/E50wX/eoBOgq0B7+7S6FK4wvPHSNgfh+vwSWIJsJLt/3yjBeb41RRyMDMZqFQTZPEdFpXp48ExEyDayZ6objbjTHoS5WQDnDQpRyqMNKfvd41nhEPdb/hxpzXeTIjWmfHHCT+CQYWXDqLehCh1cRyeYOBwsSlSw5PiquAbsgAARVhJRroAAABFeGlmAABJSSoACAAAAAYAEgEDAAEAAAABAAAAGgEFAAEAAABWAAAAGwEFAAEAAABeAAAAKAEDAAEAAAACAAAAEwIDAAEAAAABAAAAaYcEAAEAAABmAAAAAAAAAEgAAAABAAAASAAAAAEAAAAGAACQBwAEAAAAMDIxMAGRBwAEAAAAAQIDAACgBwAEAAAAMDEwMAGgAwABAAAA//8AAAKgBAABAAAAPAAAAAOgBAABAAAAPAAAAAAAAAA=",bd="data:image/webp;base64,UklGRtgCAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IPgBAABQCwCdASo8ADwAPm0wk0ekIqGhKBQMqIANiWkADPF3uV2D8VcQGk1mg+P36i9SLnZvYAQxszEWYzEwX1RVkqG/4BGbJgMSHqhKDFsjWsGfPPrvfef11goNmCDDlBJHVVD+8gAA/vu4q03kl+E7FpjtZ2gc8pQ619Hjv9NywoRZ6az43C1wcrRr/lWzJlJhLWMHN0MkVl1ueAf6Hn8StVzeUfMBXOKkgfe2msx7QWR5PnHW/5c6/35yrtWnrURc2q6UYlGin+v8C2dQqexkW6rX2EEijTI9eEQ46PWH3/59fM2AlMvvR2abaRk5XX7V1triQncRxvMfz5YmYDN+PY/ikcZUNaiFucKoUq5riv0eKCezuFNHecE11ojwJqWRSTWpalkz5autXp6vFS+FT1tWUsB/fs1CCOZxaA1vR1grOEaiuKe1RYm7e05psWtqbXLVmm1bA8Ly9PFkVdCbc6hR3UuBBsFGnVeGOUeMn2onnfvYhBMcM9YPxGdQkwZLXOk1VuQSTk01Shf3fZrFyRlFauftFdPYhKXwqrr+meav1P+KLKBVosqmHnFFfgExsQ/rOf3TSd+mOqQfJA+cF+HojNU7nmM3uDkoCBi+//Gqp+gPNNW8M4LFrol8rxE+7WsjqMgfwv1f+Nr25RtG1Wa/KkniRCAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",yd="data:image/webp;base64,UklGRhYJAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSGICAAABkJz9nzon3/nNJGnBXRvBI0sDkR7slpRBaMDl5LByx7cEyBWHtWd+8/uiK/95uEfEBKBnFwRwk6Wjm89PW2Tj9OWNo7VxASQ4DDoIML9fbdLYpbFR21tykDAY8ZCLT9okqZrsD0uqJNl5sj6CIAPwDmdqRlNlz6o0vroE5/vlPObv0kyN/dVE3pmHd31xgt0P1MgBauTHLYjrg2DoClM0DtRi4kmA6ylgrMq2cuDaZm0CoQePyTqVhVTWJ+G7EozXqSyosj4K6cIhVBhZ2MjyMNy/BFcZWeDIE8g/PLaoLLRyF/4vgrlPTMVK/DQH+cPjGpUFV17/i6BEZeGVF+Dh4F/kUYGDR4nKDBPX4AX381Deh2C1Q8vB2F4CDqnMUrkPlPMpY+obLQ/j9+k1GjNNLB0z5hJ5fD0f5Y2XTLkkPn9Hy8X4vsGMW/xvt3JqvKflYnz3nCmXxJc3qLlEXj9mzOe4xJSLcW36Oy0P47cplKl5KMvAfj6HwFKbloOxswrBfWoOyvsQjzWmPErwcKhQi6d84eHgcSGPEgSA4Dq1aMpr8PjL3CemYiV+moP8AY9darGUW/D4u+CEsUiRVyH4p8NwmbE4kZUA9y8IRuvUoijr4xB06zFZpxZDWZ+ER/cBEzW2dXDaZnUMAb06hBOmaIOxmHhlCILenWDrI6MOIio/7kIc+uk85u+SSftkasZ78/AOffYOl17RqNqbqtFqZ+A8+i8BI+tPOiRNNdkfllSNZPvJRYEXDDQI3NJerUFjl8ZmbX8ekIBBuyCAjK8d3Xh52iBbp89vHl2ecIAEh54BVlA4IMwFAADQGwCdASo8ADwAPm0qkkYkIiGhLhtqqIANiWwAqSdaNo+beZFT37f+J9yXOd2J6HfQh5gH6edIDzAfst6vXoO9AD/Lf4DrAP2V9gDzY/+57F39p/3/7k+0RmjvYp/meic9ieyvJnZVfquF/a23ZOCHGT/sfDDjQ89zOL9Gewd+s3Vh/b32Gf28Ejb5ttLg9hoDiFb2tMW81eZU9Z1LHfdRSCsRMzHz0WT4BNgUakGf9oJtrGtVJFxHJfxAatIxnW1qjDi9i3DQtJp9pVNKlMoJEWdPKv3KaaFSlhd/aMGiir9CPcex5QAA+fpjxA6zfUamE3wS2zWwLVrt/fXA5+Wvx9j5SID0zuEHU2LisPUxvtRuIUwNrsUis8zy+IMpzft+ZSg+9gdx9e6+ZvPmtj4OByz5qo26J3rXhPy8LBXSpuPb+f+mP4CoTvYDhzQXh/SIGj8Ez1+W5MJ/Tkdw09wPCs3JuR3yoqO63FH/j81xW5Abr7tCdwfXwv3CXDtOcHwUqPCd1aiU2uT6XwgdnYqYygEXGKFx8nmaUvqSn9p8HmIA9dVTOoEnqYFjrNfWY034N2vjohd16cxnkP4PYvHkIOWa/FEUug7/qbJ/GFLPxNh6y9eQ//MzzXbcPwsT2chWXPBXNVF1S9dxv5NUuEueiw2kdebblQuvUSRLN+zx3VyT2lOzWBUqrzsTmeOlxjVcTA83H99r35O4X7WXNq7HExiWXxrdM/Ih4CvPJaEHPxUE/i6WIz6+VGq4RB3sBKl3P4M7/DLWAwCnwcpX228XezqQ4cS2tttWxLTc9cPd1ofek9qF9lpB8RvakdPnj2PruFA9W3iKbNdmgnb+mIpohHuUR73KdDDOHbyfAiOjPzzqomnIU3jcSt7LKOB/Op97sCk0yd18mVG3prs351B+xmCE2Zd3RFKL+mpMz5qcuAFAfRyodbggdgmFGkEGQ33VryYFl/upr31FGdI52sqzuxd7jZIsqCcznUH/gu+xaBw7wla49EmFNf+Ss+91i9Hsys0FS//Ktru1xWgkeEweX77y6Oot5tHQsDxgy0sAI85V7FmlpiiWXQdM12MGfCBfyRM+N23SjOdReeSILYCgsM3r33/54X+lfDVNj427MvbDFtKccqazlQ+iKqC//MvYwqyiJPL1ZbVoCEP774fKZA3D3qvsVPGlp9LPchpTs4mTJugt8qXl82RwXQCDNZXnbEois53E35hkRr+IJhndoRo1o2sZDoTgykbeOKiynPH03+BcUQ8zmxTmiVlHQym/LL3kRREnUlxs2zPPGb2E+Rpdib+LxOvFSmj9RfTZoYIJnrqNnBIXV2lt7xeZ0srf98JymJxrtr8lx69oSNZIReDddL+3iiUjh6lm7EcYuclqBaKp8q68geo7H1EvKy4nSRx5Q+uz4l/ypo2hVdwi9l+BHjZZmJ7lXkpNTRJ0gZpzquzN2vh/MZQALV6FZ6q4aofA9AJy1DVLdNjV8n6s9eFA5pazxwhLW4tgWMciGf5x6G7HqFPTL1ZL3l447zLGUkqAXjkeVaNmxZ2oNKIuTy6JDc0Z61Z2dgbsg6HwCX1/ux5sk82WsnNIO4CTnWKI1aCtQZaEsBf6hIl9n7VBsgZGIcPpqn7P4mbyf3EbfdfQ32qlawLuAxmDlwRsVsPkw7j4aKbvIBykNcsVXv0/X6UXXaAtw3feJnTwDak2qY6QpMLE9e7PJeuQQ8FXpqI5HoR82kd+DOwGH5F3OpuWsmEt8v7WQG8q1LMkg6vrl3I8047zMl1Yq0VwotbrsKJocsHgsbs/PGOO9v2s8U0Sju/71XRtG5skcy2msae3wixjlGR4i6ZfldMehQD1zf/FbWN9hnHfpq1Fh8+PSA9AzUi33qli8ixISbH+tw7CcumxvegMk88HMNZlVdnIEzIfyHrSdZ2S98yX2OYZw0+JyaBbQxI0fOr6KpuMD6FVGLrdN9dgOTgOPQgAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAADwAAAADoAQAAQAAADwAAAAAAAAA",xd="data:image/webp;base64,UklGRo4EAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSA4CAAABkGXb2to2V9/v6D1Jmd5CQ5GXPYXAJMrtPOJMoMzMzDgIPYY5+vVds6T/m0BEOGzAtm1IBlR2d8kXUMyaADjeuHr9V7qj3E5/XrvaOA5AHCqzFgHTFz9tUTmEyq1PF6cBqVWDOLjkwS6VPsu8KqnaewRU7j5KIjipgFiQfCf1IGch8wMlv9QhcWk4nLlL9Z4l6b3y7hmUvGQkmF1nnrMC85zrc5CozDUQtwamisNSDCmxjL5jpqxMzfhutFCCY3+5110CaI9/jhVIcPg/DxiIB/x/eKgijLxkRobTyxFEw7zVm0NqcYg5LNAzKD3n4QbmyRVqWCiXJyD9uN7z0Ha9Dw4N5gzOnHU4IMJ7egt8HuYWasIJnlg46fkYgul9qgWU+9PA2Z7b2FngnR3e49Qm1QbKzVPNnltZ8wozK2S8et0SN34wt0LOnynVCsp02xI7tKSqqXYsV7ZtD/lpeaEfNyw/k9evWuKK7XfQ9ruP9/RW/s74t872N1bw2MY8n0Acmlb/KQ04AJ8t5PkeEbpDnbmR2/5392FiOfRFlCuTkIGsMh/aPBeGZFLBYuiM1IIUZLOD0NnMNBMWZdE/4bLo32MQ0wxcJnsvhcnerRhSLvPPhcj8s5DIsmtU6Tj1L1U6zvcEElfrVlHyqGy3epC4om5Vsg3OlO50UQ2V6Qa65LWf6TZ1J/11faBLlpgAVlA4IJgBAADwCQCdASo8ADwAPm0ylEckIyIhKAoAgA2JaQATzh4OcBkEByVmbl5z9gD9U/+J2APQgLaX4twLu19/UVxAWN1IKXE4cIqJBhoyQ0yDYn61m3zk6T7FMg0AAP78+EMvGgC8jLXmcbbmqvufKjG8Tv1M9Krl47vOW74O/Rapv2DgXbg9iK6PrRQG/9d9+rF/ESxzbszVFn3GThrMBmsklj/LPWDQ0pKzG7EyjQL6p6gfUwMze+wPhzJpn8tMqlUVgq6/QSUVcgG+ztsi73rA3vl3n4baeF1INsbuosTXtnsotVYuTii6rscx9OUTvevYcPNvcL9MPhyWeCQw0qynnGtzCIw+oFRN0+TN1mqXkFyk/rFBcH+FHiI6s9XX5EWCKn5vTRt/0RbS687PiXPFC5Zk/Gk4+538IYi+HZDjvlQQWOH/vddfYTerQ5QqWJt1YuaZNThQ2u+/DtXfZPRy1iWWLR9SKFFtlGrqBKWF5nPRPWWMNA3OssvUtvCNBLBA4cn1whzy+SpbgLvnaepxiykjKsU/MhzgAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",Ad="data:image/webp;base64,UklGRqwEAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSL8BAAABkGvbtmlLc5997yvbmW19gBnbDm2kjF5UmW3bthXZVZFdZ+81r+87Z1XlEaHIbSNlMstwos4XUBSTLAFQo/u01Zdf/yLDDze3zB/YwADJEoOoJAKg7oTdH4SF+XxiZlMgSESzwAJdVn2iUJzzOUMiLhQKf+/va2FtBLMBuu1zpHcsincUXhtoTKLsCTVX/KF3wrLhPLm/OWzZtjQWfZ7RhYyAC/lxMowpSzJYJAyFkZDQc21FBMUT7BqGjpHxf3m+XlEPUHE/f3vGgPzmw4awRUaTexkyJhwfNShctVgZXyJDXq4CUyjNy6Y4fVOBIkAPR2GcOE7Jm2NQ/RE9YzXht3a5VYvlOX0xF0fy+tp/ozBuQg6DzZYb6Bi7ed4rB5Mp/1Co4cNhLUo1StLxDIDqrynUoRswiF6nFnIxsDpnZ5WBW0GFZ1qZ8HfLDk5txHHsGDpSa6B0cXZEa+DsTr1M+P4qPdXwjynU4+1/a7oN3Sm6G+meSd27oHsHde++7puj+tYpv7G6b7vun6L7l6n+oZp/t7JmUNUqqhpJV5upakJVLaqqgVW1t6rmV401NGMc1djqH4rpIseSfyPFkgAAVlA4IAQCAABQDACdASo8ADwAPm0yk0akIyGhJgzogA2JaQAThroHvLxu+aPf5G2BYxv+B6XHzx6GPon/o+qz/tOAA/TM82gR0vnExWoiQRM36jlg2UIvwCSqySErzuguz9EP2x/7hsNazr91aIworWI7AAD+/TZ+6Ipl444OdT+2wU0Ov+T8oJuVP/vUbT/w1Jsv6Awnl6rvF/xetfOPt3gTQZZi0Y/AOx563J7CJkqTR/fc/n34zyeKzR80fhfv4ef+Hjhz/CX5aQo+58zg/FdE+7bLoophGfG0szI513EH+q+Gc73H1PFdJYf7CF8v5dhr3tMwEVX5Ji2ZxejK8xrf/E6nVXqlA4DrYNRP09InHc+fEqO/fH8xr+rMf4y1F9TOnwVffZblLoTP6lot0m/sh7sTiDQr0mIA8TiHoOffGDG6KzV+B3239udfhzD740gkRi/m53abX0Ku3vAgadgFFqL0vk8M/4aI+cI+0fbLW17mWGeMu21wSRRQiv5iNgGKR3vEGXAItcLDft1uUzWAfbe1X3zK/ymT7bA/76PB6UUknm+Y5MM4osurUXU/k7P38pN/3slnGfpFzjl4c3USY4mH9ZCJYUuC/kGEnq/yRPalPdODNFvW6s8MiQeQejYNRY0LsJ0WXkK8vXiDmihCivYAOPoSovesL7on+WAArDNM/BcQSQvCYABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",vd="data:image/webp;base64,UklGRnIIAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSK4BAAABkHPbtrE9+z73/RTbqWw7Lf+BbbNKbTudbZe2qy+VbVv3PmeHj05G6ohg4LaRounNMtN1voB42ABA5R7TNlx5+O7du9e3Tiwb0b4EgFyAOCQM1Z16+DWFUZC7m3uVB2zKQGBhe+77RGHonJffCL1zQuHDxQ1hrEmTatDjHIXOC2MgzpNf1tVJkWgsGhyihI7JIE74aUYp2ITFAoz9QO+ZAs7zanvkEilKbIkMJS5ANwoJmrCodYVOmBqh5zIEJjZc9xods4A4rrPGxGitrJSU71yNyH4Myl7JTEl+5zzYSH9nlkrxHBzxWUzLVEnhh+YI/gq3+UphpvA8m/s7/wg9M4bjFNg/0vplrxQ+rQEDg/xihmT23jxYJZ8UPq8OA5z77Wt405FDR4poSMjiAJhPRxUIu8D+UVonOhfNPEVHPM9juFacwo+1V6kJQ3Y9Sa8ljhPuUvRk4UdNWU9ST3b9n0W3iG5DumdS9y7o3kHVu6/75ii/dbpvrO7brvtPUf2X6f5DVf/dmpxBmauociRVbqbKCXW5qCoHVuXempxf1dZQtXFUbat/yKZTtSUBVlA4INwFAABwGgCdASo8ADwAPm0qj0WkIqEZ+zYAQAbEtgBOmZoZF+E8zGoP3X8VbcdLvma8t+jH0E+YB+ofSA8wH7VdQv0AP75/iOsG9ADy3/Y5/b/91fgI/Y7MOesb0e/q+TUR1vt7VO6mwG0imO70GM5/0P7BX6qelv7EP209lz9oDRea09ZR+SjhX7sBu/ZS7tG917rPgI3Q7XsB7luy2hAg/95C2Z1L362OH1oFziDY/K5gWoSytSAtiKvA/jW1MehBzdLzJfszPPBvGa15IYwIVRTjO2Hz5ZS9HjLMehwAAP64SgjD3qeg6NRe/Ok+iFhrG3pgglCfbam3yBaDUH36sUiQx0PB1ZZyOHq0ky+f97h6tJMvo0p9LkfXecWOFJ8J5G7yRPuL4tzGLT09QulTJw42xp2hd+lMgIa51XoHx/iftn8B2D3k92H5jOQr+uIXFHHK5FpcTG+qGEF+np0LiQa+vdW7/+ZzOLVRf7jR5X3ANPt93Ng92DW7NflVr6kMr88O/v2ZNb0vtgao2Am/R3CDKiNq89f86CT6r2L2g1oTui7H3E1yhSPQpEOz01I3fhfiMMv4weqKuoedxn/xLg5uzHa6Gte4C/dQYkG3ZFSy4CXQtRjftBrjX/Oj+HpSUPDsv0wPW+ml5NbBKDCj2f3SD8TVMf2ZfHrOkR602RVk2UmKC+H0Y9iK6k98vsgPINtz0II8X7Mj2nJkTC6IMLuQ8dNTUq9VXOnhXrdhNZoaH94ePo6baBl3hTGFAnD3/b+gR/vtbqV7wktuX6fpnjeTBe/Drp6z3neeANj/aX4CsU9w67nwYOjZhueCjxaDKUnNjLPjI1e0BoTbcOzOQ0wHJHZJ+Pt608StBu4HiJ8NjH46fnvXL3yiMoSvkAuwCE1AakA+eU1u3unyjl1/MnZQmbp8fzfsfrFesehLPcIkYdCiZ+52QbmINNTjEsvjuBuZRubBE+Laihppsxoo4efGIo0xkw0etu1+yzvkqp88w3pBq0mRl13gnnc+2zl6SmhwgmNFbz+F8qAqmdfJL8iaNSGEWlPlpczDDe62GBZMlBhQmq/XCn/1b+VazHvJXkoIFDF+wktMg+rKfLyfTlXdK0cs+Kn8h+rjMakkf3WLo1TftMLn+O+x/Gat+BGstJrM1xvCSSnHQY+NV4B4gRqyZ55gRNnqN/0lWrATOcHUaGXpkTIM/yxFjxcePcSFo+t2aJ5lShtVukETzRxaIXgRkpROeWQHWpTHOaexmXOzF0b833qJSoXMk2zB/uMrgDzKd7d3ohUz8Ra08WYKlAuMQD08bF4+jUepEspqPLoYLQ73TfmL+1LwKxyTV3gEu6WnxBPWPLnYIGYN9U47ZNlB+NgHgYtKTyii6060RAG+wN32WUVFxCZw0HMHnHFgwxD34L/anlpS7mOrjKgyuGYhFC7iHqTQHuoAO1ekBHV+rndnbETKfa1F7LxNLYq+dmJyytmQrJUCGjelorI1m/TMQNiFVrY4FCI1Gl2W1JsZsw9zA+Bh3JmjkC0H5/0JV6JotNMatJIZ4v5PqwJe3r8xd+FNS3ynccdu+xtVdc27qwVdoomciZD5oXYey9KAFSAKO594sBKZNWUJTLXnt0BJbdF8FkQYvg3DQajYY2p+ixd5Ag7o92gw0pVVDDOP+WQxiEmKqgWJyTBsnsBk2Bxi2Unsv8S/4PmE8Hy/vy+Mij+aTAKZvg716IHfHX0/JMeFfmAnsZ39Q0qkfdPtq6+CxbGZ7wKDsK/8l/MVGuyd6faJFt5wyoOXuNrr3JC9EoBmjcOzkVw/6RNP49poZ1xzsX3q7B4HGfI/XSfRQq3HeZ2j12d0E3gCAube4oExaT1sx/v8F+f61QOsGdSaqM2im6qOGkSRkrRQ7L8hvS8vEYJeVkAbFvX5ov7e/egYYNToMHj651c5/rCVYtB9Ned6GvGN8R0x3t7+lsf8+ofhHRzpyvwxd6c5pREZVOKnXzplhJ61mki4JmAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",jd="data:image/svg+xml,%3csvg%20width='88'%20height='88'%20viewBox='0%200%2088%2088'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='88'%20height='88'%20fill='url(%23paint0_linear_170_79)'/%3e%3crect%20x='25.6665'%20y='25.6667'%20width='11'%20height='36.6667'%20rx='1.83333'%20fill='white'/%3e%3crect%20x='51.3335'%20y='25.6667'%20width='11'%20height='36.6667'%20rx='1.83333'%20fill='white'/%3e%3crect%20x='29.3335'%20y='40.3333'%20width='29.3333'%20height='7.33333'%20fill='white'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_170_79'%20x1='-75.3077'%20y1='-55'%20x2='146.302'%20y2='148.167'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF00FF'/%3e%3cstop%20offset='0.531673'%20stop-color='%237A84FF'/%3e%3cstop%20offset='1'%20stop-color='%2305FAFF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",kd="data:image/webp;base64,UklGRh4HAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSNwBAAABkFxbexpJnyR3z8y+ajXMkAnjnnOgbUUxEAHjkpldWQwzFUn6v3PGVNI/AUQEA7dt49gN3PXavTlfQDeNAeyqg4PL5buRyOhteXlwcJWtHU8qzUIBs+30g7/s4N8Hp7cZFAtpDc7Bbr8xplB8iFJBYvBC4fjGdgvnElqdwc6XFPGRnQxehC93wjgzbxRYf1UYA+dkiJSrG1DMV6zDoW+MkQmMkd8Owdl5AsvOM3gm0geeXwY7R/Tu0EcmM3re6cF2Rr/kTJiBMmPZh+2q/wtm4ozD9qrB0tucMhunvL0Upg1n6JmRnmda4HCckVkZeRyuMWjjF0peCD9vhK3jAgMzM/BCDQ576225m/bCwcA+qzS/PLUwDrsr1ZDdcAa3KtWQWzDYPKZoQDjeDJyoVEdOAPf0cA/Lf1F0IPy1fG8VWmXvgF4LnoOLDFoIvPiaUQuRr99pNr8dUZEj0YToQnfjreaQd7oL6T6Tuu+C7juo++6rfnOUv3W631jNb7v+P8U+1ZDAZxZG9R+q/e+GxcbPuRcRftkIq+pVVD2Srjdr94TDnJ6w7MGqedFhH1bVA6t67zk9/3ctzw+YAhvSc431KExyjjNHQ2zLcTRzq/8op0vKJd+OREbvUnJJAFZQOCBaBAAA8BUAnQEqPAA8AD5tMJRHJCMiISgb+1CADYlsAJ0zIUCfxfmY2f+0b2AbztDnPeKX0qPMp+wHrDehz0AP7J/o+tP9ADy3f23+C79yPYA/aqK9mONrQbuszbsEyALJNTfg+Z6NjG2v+ETCuvlr1q6QUqEiAMUndG/WwfnjJIOTfOBS4W1w0HjOJa1XQ2K33n2b07EOjOBapwKzyoA2erTBTnEKlFjllBy68GBjZ+UKnlzN/f5ibbb4gAD+i9OsnW0xUnmTpyhVasIKzTu0BsXnfBm4rHJqGMFJBUgTESDXEPcNjAeaHP8ck9qdNBH4L/h53tXgHeZttc7c4lwTa6U4Lziz8qUoy8ce0IMc5TFElawGj16tME0GzSSbUqgH7/tYA6huPsWM2z3GjP8b9y7paRbINxwYRtuE90I6QVsNrEkbhL1YfwxRXnuobOfSe3KFVamrvsOqwTCMqlNfjsR3pyoiZ+lYt3+AH6x4ZVNltbYI5KiVhgCu1isooK324ldloH3zhlefYKEwTCYfNjbeH5UiL7JSev+t/C+ftc3TkAHcsvrLCU6n5pYYY2Yr1kRq+r6XVzI6iXuA/TqwMk6xq1PmdzHOwKavncLjWJrk0uU/5E5WKqXM0tgl5s3pduHjb5aiAt0ikEisMyYwnIhDiSemPRdGON4RlwSb3OEpZjhuZqoyen4Sw/fULewt3hAZizeiPZx1o9LS3M/4r3v/M6/o5925VJcmxAf/yjsyjCz0mV+6NuIeWp8shrFaIGgeduVJoZ0Kys1WjSLuFg9QvF5LlkOZ2k7WrzSu4ucsUOS/X4wnQvB0RCnR1PCsU4NDdLfxvQITUgGIuVTJ7LR73PHzZam/Z21oy3euiU55ffITekwjR4SgVoPvhxbdBSyVePf/twm62pSK9IfgPGN+ttubhQub1ooVZymdQCrS3goEs6dlnl/6TVfkgxFyBfAORkZafeu/Va2vIgUBNUQd48W8oPiMFjx+SAKx1qm2IwCLnuhJGf9M4nCzu7oo43f+nBeT07IjB+FpFKRGFNvlpLEXhPclSgFkqeU1W2eNqW2zShCWkQkgfE1HAoNX3z+CQcRQJq+HkC2nSjFdFYT8UNYNS6lYcyVWzEnOos1qpsNRxnLqY2Dl5CCT3Yeg/qT8chfF9ZadFvzNTEIDlARoN//7IU23MtuLdpsAjsiGfBHuR7y4lemYPdD/9Cuff9Qn/r/xlhmB5x2Y9Z1yME3aANAb5+u3lYz01zUlWwakKVmv9fhaeu/YzQ7BXLlcb+cbaIF5t/COmObnt20zaTfjad542f7p7f2Xea134nvyPYS+EAgjM+GufHvl9tXCrrRbH0pn7kH2XEGx9VbO4mY54+QZa5kPr0j3AOEtKd7SJWjlg5TQfgIuB6KoLGainSwF+pPdiCmzEzAOa1eFwn//2VdDMeq42/bKH8U4orewhLh60ci/S0BRBuItNMc+v1+vxl0YyS5it4AAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAADwAAAADoAQAAQAAADwAAAAAAAAA",Nd="data:image/svg+xml,%3csvg%20width='868'%20height='868'%20viewBox='0%200%20868%20868'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='434'%20cy='434'%20r='434'%20fill='%231B262D'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M234.563%20184H640.697C650.387%20184%20659.339%20189.164%20664.172%20197.542L782.495%20402.657C788.631%20413.294%20786.808%20426.72%20778.056%20435.346L452.368%20756.327C441.818%20766.724%20424.846%20766.724%20414.296%20756.327L89.0484%20435.78C80.0927%20426.954%2078.4157%20413.136%2085.0013%20402.433L211.48%20196.884C216.405%20188.879%20225.146%20184%20234.563%20184ZM588.257%20275.577V333.129H472.567V373.032C553.82%20377.296%20614.782%20394.81%20615.234%20415.802L615.231%20459.563C614.779%20480.556%20553.82%20498.069%20472.567%20502.333V600.259H395.746V502.333C314.492%20498.069%20253.531%20480.555%20253.078%20459.563L253.081%20415.802C253.533%20394.81%20314.492%20377.296%20395.746%20373.032V333.129H280.055V275.577H588.257ZM434.156%20472.268C520.868%20472.268%20593.345%20457.459%20611.082%20437.683C596.041%20420.912%20541.636%20407.713%20472.567%20404.089V445.867C460.187%20446.516%20447.336%20446.858%20434.156%20446.858C420.976%20446.858%20408.125%20446.516%20395.746%20445.867V404.089C326.676%20407.713%20272.271%20420.912%20257.23%20437.683C274.968%20457.459%20347.444%20472.268%20434.156%20472.268Z'%20fill='%23009393'/%3e%3c/svg%3e";function ea(t){const s=t.toUpperCase();return qt.find(o=>o.symbol===s)?.decimals??6}function Sd(t,s){const r=t.toUpperCase(),n=qt.find(a=>a.symbol===r)?.decimals??s;return n===void 0?2:r==="SOL"?4:n===6&&r!=="SOL"?2:n>6?6:n}const qt=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:dr},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:vd},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:Nd},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:yd},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:kd},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Ad},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:jd},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:bd},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:wd},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:xd}];function Cd(t){return t.companyFeePercent>0||t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap"||t.feePolicy==="user_pays_privacy"}function Ed(t,s,r){const{feePolicy:o,privacyFeePercent:n,swapFeePercent:a,companyFeePercent:i}=t;let l=i;return r||(o==="user_pays_all"?(l+=a,s&&(l+=n)):o==="user_pays_privacy"&&s?l+=n:o==="user_pays_swap"&&(l+=a)),l}const St=1e9,Xe={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:dr},Je={mint:"other",symbol:"OTHER",name:"Other",decimals:6},ta=1e4;function _d(t,s){const r=s<t.publicMinUsd,o=s>=t.privateMinUsd,n=[],a=!r&&o&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_privacy")&&(t.privacyFeeFixedLamports>0||t.privacyFeePercent>0),i=!r&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap")&&(t.swapFeeFixedLamports>0||t.swapFeePercent>0),l=t.companyFeeFixedLamports>0||t.companyFeePercent>0;if(a){const c=t.privacyFeeFixedLamports/St,u=t.privacyFeePercent,m=c*t.solPriceUsd,h=s*(u/100);n.push({label:"Privacy",solAmount:c,percent:u,usdAmount:m+h})}if(i){const c=t.swapFeeFixedLamports/St,u=t.swapFeePercent,m=c*t.solPriceUsd,h=s*(u/100);n.push({label:"Swap",solAmount:c,percent:u,usdAmount:m+h})}if(l){const c=t.companyFeeFixedLamports/St,u=t.companyFeePercent,m=c*t.solPriceUsd,h=s*(u/100);n.push({label:"Service",solAmount:c,percent:u,usdAmount:m+h})}return n}function sa(t,s,r){const o=_d(t,s),n=r===0?0:r<.01?.01:r;if(o.length===0)return r===0?"No fees":`Total: $${n.toFixed(2)}`;const a=o.reduce((w,g)=>w+g.solAmount,0),i=o.reduce((w,g)=>w+g.percent,0),l={fee:7,sol:8,rate:7,usd:8},c=w=>{const g=w.label.padEnd(l.fee),k=w.solAmount.toFixed(4).padStart(6).padEnd(l.sol),A=(w.percent.toFixed(2)+"%").padStart(5).padEnd(l.rate),N=("$"+(w.usdAmount===0?0:Math.max(w.usdAmount,.01)).toFixed(2)).padEnd(l.usd);return`${g} │ ${k} │ ${A} │ ${N}`},u=`${"Fee".padEnd(l.fee)} │ ${"SOL".padEnd(l.sol)} │ ${"+ Rate".padEnd(l.rate)} │ ${"= Total".padEnd(l.usd)}`,m=`${"─".repeat(l.fee)}─┼─${"─".repeat(l.sol)}─┼─${"─".repeat(l.rate)}─┼─${"─".repeat(l.usd)}`,h=("$"+n.toFixed(2)).padEnd(l.usd),p=`${"TOTAL".padEnd(l.fee)} │ ${a.toFixed(4).padStart(6).padEnd(l.sol)} │ ${(i.toFixed(2)+"%").padStart(5).padEnd(l.rate)} │ ${h}`;return[u,m,...o.map(c),m,p].join(`
|
|
2059
|
+
`)}function Ld(t){const s=[],r=t.privacyFeeFixedLamports>0||t.privacyFeePercent>0,o=t.swapFeeFixedLamports>0||t.swapFeePercent>0,n=t.companyFeeFixedLamports>0||t.companyFeePercent>0;return r&&s.push("Privacy Cash fee"),o&&s.push("swap fee"),n&&s.push("company service fee"),s.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function zt(t,s){if(s<=0)return 0;const r=s<t.publicMinUsd,o=s>=t.privateMinUsd,n=Ed(t,o,r);let a=t.companyFeeFixedLamports;r||(o&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_privacy")&&(a+=t.privacyFeeFixedLamports),(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap")&&(a+=t.swapFeeFixedLamports));const i=a/St*t.solPriceUsd,l=s*(n/100);return i+l}function ra(t,s,r){return t==="sol"?"SOL":t==="single-token"?s.symbol:r.some(n=>n.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function Nn(t){return t.map(s=>s.trim()).filter(Boolean)}const Pd=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function mr(t,s,r){if(Pd.has(t.symbol))return 1;const o=s.tokenPrices?.[t.symbol];if(o&&o>0)return o;if(t.symbol==="SOL")return s.solPriceUsd||null;const n=r?.[t.symbol];return n&&n>0?n:null}function na(t,s){return t.toFixed(Sd(s))}function Rd({config:t,currencyMode:s,depositMethod:r,tokens:o=[],defaultToken:n,minAmount:a,maxAmount:i=1e4,onSuccess:l,onError:c,onCancel:u,onUnlockRequired:m,onAuthorize:h,className:p="",showStepIndicator:b=!0,pollInterval:w=5e3,demoMode:g=!1,demoAutoConfirmMs:k,tokenPriceUsd:A,showExplainer:j=!1,siteName:N,explainerConfig:S}){const{deposit:C,getStatus:f,error:y,clearError:x}=Zo(),v=U.useWallet(),_=Nn(t.quickActionTokens),E=Nn(t.customTokenSymbols),P=d.useMemo(()=>{const O=t.customTokens??[];if(O.length===0)return o;const G=new Set(o.map(ee=>ee.symbol)),Y=[...o];for(const ee of O)G.has(ee.symbol)||(Y.push({mint:ee.mint,symbol:ee.symbol,name:ee.symbol,decimals:ee.decimals,logoUrl:ee.logoUrl}),G.add(ee.symbol));return Y},[o,t.customTokens]),L=d.useMemo(()=>{if(E.length===0)return P;const O=P.filter(G=>E.includes(G.symbol));return O.length>0?O:P},[P,E]),R=t.privateDepositsEnabled,T=r?r==="sign"&&!R?"receive":r:R&&v.hasExternalWallet?"sign":"receive",M=_[0]?P.find(O=>O.symbol===_[0]):void 0,F=s==="sol"?Xe:s==="single-token"?M??P.find(O=>O.symbol==="USDC")??P[0]??Xe:n??M??P.find(O=>O.symbol==="USDC")??P.find(O=>O.symbol!=="SOL")??P[0]??Xe,W=d.useCallback(()=>j?"explainer":"unlock",[j]),[q,I]=d.useState(W),[D,$]=d.useState(F),[Z,se]=d.useState(""),[pe,he]=d.useState(null),[K,z]=d.useState(null),[X,ce]=d.useState(null),[we,tt]=d.useState(null),[Ie,Ue]=d.useState(!1),[Vt,st]=d.useState(!1),[Ve,H]=d.useState(null),ge=d.useRef(null);d.useEffect(()=>()=>{ge.current&&clearTimeout(ge.current)},[]),d.useEffect(()=>{I(W()),$(F),se(""),he(null),z(null),ce(null),tt(null),Ue(!1),st(!1),H(null),x()},[s,T,F,x]);const be=a??t.privateMinSol,ut=i,De=parseFloat(Z),He=v.status==="enrolled_locked"||v.status==="enrolled_unlocked"||v.status==="unlocked",$e=He&&v.isUnlocked,Ht=He&&!v.isUnlocked,wr=d.useCallback(()=>{let Y=T==="sign"?[{key:"unlock",label:"Authorize"},{key:"confirm",label:"Send"},{key:"signing",label:"Signing"},{key:"success",label:"Complete"}]:[{key:"unlock",label:"Authorize"},{key:"show-address",label:"Send"},{key:"waiting",label:"Confirming"},{key:"success",label:"Complete"}];return j&&(Y=[{key:"explainer",label:"Info"},...Y]),Y},[T,j])(),la=wr.findIndex(O=>O.key===q),br=d.useCallback(O=>{$(O)},[]),da=d.useCallback(async O=>{if(!h){I(T==="sign"?"confirm":"show-address");return}st(!0),z(null);try{const Y=await h(O,T==="sign"?De:null,D);ce(Y.sessionId),tt(Y.depositAddress),I(T==="sign"?"confirm":"show-address")}catch(G){const Y=G instanceof Error?G:new Error("Authorization failed");z(Y.message)}finally{st(!1)}},[h,T,De,D]),ua=d.useCallback(async(O,G)=>{x(),z(null),I("signing");const Y=O??De,ee=G??D;if(!g){if(Ht&&m){m(),I("confirm");return}if(!$e){z("Wallet not ready"),I("error");return}}try{const fe=Math.round(Y*Math.pow(10,ee.decimals));if(g){await new Promise(Kt=>setTimeout(Kt,1500));const ye={token:s==="sol"?null:ee,amount:Y,amountSmallestUnit:fe,txSignature:`demo-tx-${Date.now()}`,sessionId:X||`demo-session-${Date.now()}`,response:{sessionId:X||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:fe,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};he(ye),I("success"),l?.(ye);return}const Ce=await C(fe),rt={token:s==="sol"?null:ee,amount:Y,amountSmallestUnit:fe,txSignature:Ce.txSignature,sessionId:Ce.sessionId,response:Ce,method:"sign"};he(rt),I("success"),l?.(rt)}catch(fe){const Ce=fe instanceof Error?fe:new Error("Deposit failed");z(Ce.message),I("error"),c?.(Ce)}},[C,De,D,s,g,X,$e,Ht,m,l,c,x]),ha=d.useCallback(()=>{I("waiting")},[]),$t=d.useCallback(async()=>{const O=we||v.solanaPubkey;if(O){ge.current&&clearTimeout(ge.current);try{await navigator.clipboard.writeText(O),Ue(!0),ge.current=setTimeout(()=>Ue(!1),2e3)}catch{const G=document.createElement("textarea");G.value=O,document.body.appendChild(G),G.select(),document.execCommand("copy"),document.body.removeChild(G),Ue(!0),ge.current=setTimeout(()=>Ue(!1),2e3)}}},[we,v.solanaPubkey]);d.useEffect(()=>{if(!(q==="confirm"||q==="show-address"||q==="waiting")||!X||g)return;let G=!1,Y=0,ee=0;const fe=360,Ce=5,rt=async()=>{if(!(G||Y>=fe)){Y++;try{const ye=await f(X);if(ee=0,ye.status==="completed"||ye.status==="detected"){const Kt=ye.amountLamports?ye.amountLamports/Math.pow(10,D.decimals):0,fa=ye.amountLamports||0,yr={token:s==="sol"?null:D,amount:Kt,amountSmallestUnit:fa,txSignature:ye.txSignature||"",sessionId:X,response:ye,method:"receive",depositAddress:v.solanaPubkey??void 0};he(yr),I("success"),l?.(yr);return}}catch{if(ee++,ee>=Ce){z("Unable to check deposit status. Please check your connection and try again.");return}}G||setTimeout(rt,w)}};return rt(),()=>{G=!0}},[q,X,g,f,D,s,v.solanaPubkey,l,w]),d.useEffect(()=>{if(!g||!k||q!=="waiting"||T!=="receive"||!we)return;const O=window.setTimeout(()=>{const G=Ve??t.privateMinUsd,Y=D.symbol==="SOL"&&t.solPriceUsd>0?G/t.solPriceUsd:G,ee=Math.round(Y*Math.pow(10,D.decimals)),fe={token:s==="sol"?null:D,amount:Y,amountSmallestUnit:ee,txSignature:`demo-tx-${Date.now()}`,sessionId:X||`demo-session-${Date.now()}`,response:{sessionId:X||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:ee,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:we??void 0};he(fe),I("success"),l?.(fe)},k);return()=>window.clearTimeout(O)},[g,k,q,T,we,Ve,t,D,s,X,l]);const ma=d.useCallback(()=>{I(W()),se(""),he(null),z(null),x()},[W,x]);return t.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${p}`,children:[b&&q!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:wr.map((O,G)=>{const Y=la>=G,ee=O.key===q;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${Y?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${Y?"active":""} ${ee?"current":""}`,children:G+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${Y?"active":""}`,children:O.label})]},O.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[q==="explainer"&&e.jsx(Td,{siteName:N,config:S,depositConfig:t,currencyMode:s,token:D,tokens:L,onContinue:()=>I("unlock"),onCancel:u}),q==="unlock"&&e.jsx(Bd,{token:D,tokens:L,currencyMode:s,depositMethod:T,isAuthorizing:Vt,error:K,onAuthorize:da,onBack:j?()=>I("explainer"):void 0,onCancel:u}),q==="confirm"&&T==="sign"&&e.jsx(Md,{token:D,tokens:P,quickActionSymbols:_,customTokenSymbols:E,currencyMode:s,minAmount:be,maxAmount:ut,depositAddress:we||v.solanaPubkey,walletReady:$e||g,needsUnlock:Ht&&!g,copied:Ie,isListening:!!X&&!g,config:t,onCopy:$t,onTokenSelect:br,onUnlockRequired:m,onConfirm:(O,G)=>ua(O,G),onBack:()=>I("unlock"),onCancel:u}),q==="signing"&&e.jsx(Id,{depositAddress:v.solanaPubkey}),q==="show-address"&&e.jsx(Ud,{token:D,tokens:P,quickActionSymbols:_,customTokenSymbols:E,tokenPriceUsd:A,currencyMode:s,depositAddress:we||v.solanaPubkey,copied:Ie,isListening:!!X&&!g,config:t,onCopy:$t,onTokenSelect:br,onAmountChange:H,onSent:ha,onBack:()=>I("unlock"),onCancel:u}),q==="waiting"&&e.jsx(Dd,{token:D,depositAddress:we||v.solanaPubkey,copied:Ie,feeLine:Ve?(()=>{const O=zt(t,Ve);return O===0?"No fees":`Fees: $${Math.max(O,.01).toFixed(2)} total`})():"Fees: calculated after deposit",onCopy:$t}),q==="success"&&pe&&e.jsx(Fd,{result:pe,config:t,onNewDeposit:ma}),q==="error"&&e.jsx(Wd,{error:K||y||"An error occurred",onRetry:()=>I("confirm"),onCancel:u})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${p}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function Td({siteName:t,config:s,depositConfig:r,currencyMode:o,token:n,tokens:a,onContinue:i,onCancel:l}){const c=s?.title??"How Deposits Work",u=s?.exchangeName??"Coinbase",m=Vs.sanitizeExternalUrl(s?.exchangeUrl)??"https://www.coinbase.com",h=s?.showExchangeSuggestion!==!1,p=ra(o,n,a),b=t?`${t} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",w=s?.body??b,g=Cd(r),k=Ld(r);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:c}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:w}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-content",children:[e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-shield"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Private & Secure"}),e.jsx("p",{children:"Your deposits are protected by cryptographic privacy technology."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-bolt"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Fast Transactions"}),e.jsx("p",{children:"Solana transactions confirm in seconds, not minutes."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-coin"}),e.jsxs("div",{children:[e.jsx("strong",{children:g?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:k})]})]})]}),h&&e.jsx("div",{className:"cedros-deposit-flow-explainer-exchange",children:e.jsxs("p",{className:"cedros-deposit-flow-explainer-exchange-text",children:[e.jsx("strong",{children:"New to Solana?"})," You can purchase ",p," using your credit card at"," ",e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",children:u}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[l&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:i,children:"Continue"})]})]})}function Bd({token:t,tokens:s,currencyMode:r,depositMethod:o,isAuthorizing:n,error:a,onAuthorize:i,onBack:l}){const[c,u]=d.useState(""),m=ra(r,t,s),h=p=>{p.preventDefault(),c.trim()&&(i(c),u(""))};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Authorize Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:o==="sign"?r==="multi-token"?"Enter your password to authorize a deposit. This allows us to process your withdrawal when the privacy period ends.":`Enter your password to authorize a ${m} deposit. This allows us to process your withdrawal when the privacy period ends.`:r==="multi-token"?"Enter your password to get your deposit address. Any supported token sent to this address will be credited to your account.":`Enter your password to get your deposit address. Any ${m} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",htmlFor:"deposit-password",children:"Password"}),e.jsx("input",{id:"deposit-password",type:"password",value:c,onChange:p=>u(p.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:n,autoComplete:"current-password"})]}),a&&e.jsx("p",{className:"cedros-deposit-flow-error",children:a}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:l,disabled:n,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!c.trim()||n,children:n?"Authorizing...":"Continue"})]})]})]})}function Md({token:t,tokens:s,quickActionSymbols:r,customTokenSymbols:o,currencyMode:n,minAmount:a,maxAmount:i,depositAddress:l,walletReady:c,needsUnlock:u,copied:m,isListening:h,config:p,onCopy:b,onTokenSelect:w,onUnlockRequired:g,onConfirm:k,onBack:A}){const[j,N]=d.useState(p.privateMinUsd),[S,C]=d.useState(!1),[f,y]=d.useState(!1),[x,v]=d.useState(0),[_,E]=d.useState(null),L=Ot(j,p)==="sol_micro",R=t.symbol===Je.symbol,T=d.useMemo(()=>{const K=o.length===0?s:s.filter(ce=>o.includes(ce.symbol)),z=K.length>0?K:s;return z.some(ce=>ce.symbol===Je.symbol)?z:[...z,Je]},[s,o]),M=zt(p,j),F=M===0?0:M<.01?.01:M,W=R?"Fees: calculated after deposit":M===0?"No fees":`Fees: $${F.toFixed(2)} total`,q=R?"":sa(p,j,M),I=mr(L?Xe:t,p),D=I?j/I:t.symbol==="SOL"&&p.solPriceUsd>0?j/p.solPriceUsd:null,$=D!=null?na(D,L?"SOL":t.symbol):null,se=j-M<=0&&j>0,pe=!R&&j>0&&!se&&D!=null&&D>=a&&D<=i;d.useEffect(()=>{if(n==="multi-token")if(L&&t.symbol!=="SOL"){E(t);const K=s.find(z=>z.symbol==="SOL");K&&w(K)}else!L&&_&&t.symbol==="SOL"&&(w(_),E(null))},[L,t.symbol,n,s,w,_,t]);const he=()=>{pe&&D!=null&&k(D,t)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Choose Amount"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Set how much you want to deposit. Higher tiers unlock privacy."}),n==="multi-token"&&!L&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[r.map(K=>{const z=s.find(ce=>ce.symbol===K),X=t.symbol===K;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${X?"is-active":""}`,onClick:()=>{z&&(C(!1),w(z))},disabled:!z,children:[z?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:z.logoUrl,alt:`${K} logo`}),K]},K)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${S?"is-active":""}`,onClick:()=>{C(!0),v(K=>K+1)},children:"Custom"})]}),S&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(lr,{tokens:T,selectedToken:t,onSelect:w,openSignal:x})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(hr,{config:p,valueUsd:j,onChange:N,maxUsd:ta})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:R?"Sign to send tokens to this address":`Sign to send ${$??"--"} ${L?"SOL":t.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:l||"Loading..."}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:b,title:"Copy address",disabled:!l,children:m?"✓":"⧉"}),l&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${l}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),m&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),se&&e.jsx("div",{className:"cedros-deposit-flow-warning",children:e.jsx("p",{children:"Deposit amount is less than the fees. Increase the amount to proceed."})}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[W,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${f?"is-open":""}`,"data-tooltip":q,"aria-label":`Fee breakdown: ${q.replaceAll(`
|
|
2060
|
+
`,", ")}`,"aria-expanded":f,onClick:K=>{K.stopPropagation(),y(z=>!z)},onBlur:()=>y(!1),onKeyDown:K=>{K.key==="Escape"&&y(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after network confirmation."})]})]}),h&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for incoming transfers. We will confirm automatically."}),u&&e.jsxs("div",{className:"cedros-deposit-flow-warning",children:[e.jsx("p",{children:"Your wallet is locked. Unlock it to continue."}),g&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:g,children:"Unlock Wallet"})]}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:A,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:he,disabled:!pe||!c||!l,children:"Deposit"})]})]})}function Id({depositAddress:t}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Signing Transfer"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Approve the transfer in your wallet extension..."}),t&&e.jsxs("p",{className:"cedros-deposit-flow-signing-dest",children:["Sending to:"," ",e.jsxs("code",{children:[t.slice(0,6),"...",t.slice(-4)]})]})]})}function Ud({token:t,tokens:s,quickActionSymbols:r,customTokenSymbols:o,tokenPriceUsd:n,currencyMode:a,depositAddress:i,copied:l,isListening:c,config:u,onCopy:m,onTokenSelect:h,onAmountChange:p,onSent:b,onBack:w}){const[g,k]=d.useState(u.privateMinUsd),[A,j]=d.useState(!1),[N,S]=d.useState(!1),[C,f]=d.useState(0),[y,x]=d.useState(null),_=Ot(g,u)==="sol_micro",E=t.symbol===Je.symbol,P=d.useMemo(()=>{const D=o.length===0?s:s.filter(se=>o.includes(se.symbol)),$=D.length>0?D:s;return $.some(se=>se.symbol===Je.symbol)?$:[...$,Je]},[s,o]),L=zt(u,g),R=L===0?0:L<.01?.01:L,T=E?"Fees: calculated after deposit":L===0?"No fees":`Fees: $${R.toFixed(2)} total`,M=E?"":sa(u,g,L),F=E||g>0,W=mr(_?Xe:t,u,n),q=W?g/W:null,I=q?na(q,t.symbol):null;return d.useEffect(()=>{if(a==="multi-token")if(_&&t.symbol!=="SOL"){x(t);const D=s.find($=>$.symbol==="SOL");D&&h(D)}else!_&&y&&t.symbol==="SOL"&&(h(y),x(null))},[_,t.symbol,a,s,h,y,t]),d.useEffect(()=>{p(g)},[g,p]),i?e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Send Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Send funds to your deposit address. We'll confirm automatically."}),a==="multi-token"&&!_&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[r.map(D=>{const $=s.find(se=>se.symbol===D),Z=t.symbol===D;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${Z?"is-active":""}`,onClick:()=>{$&&(j(!1),h($))},disabled:!$,children:[$?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:$.logoUrl,alt:`${D} logo`}),D]},D)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${A?"is-active":""}`,onClick:()=>{j(!0),f(D=>D+1)},children:"Custom"})]}),A&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(lr,{tokens:P,selectedToken:t,onSelect:h,openSignal:C})})]}),!E&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit Amount"}),e.jsx(hr,{config:u,valueUsd:g,onChange:k,maxUsd:ta})]}),E&&e.jsx("div",{className:"cedros-deposit-flow-note",children:"Send any token you want. We'll detect the deposit, swap it, and credit your balance automatically."}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:E?"Send any token to this address":`Send ${I??"--"} ${_?"SOL":t.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:i}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:m,title:"Copy address",children:l?"✓":"📋"})]}),l&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[T,!E&&e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${N?"is-open":""}`,"data-tooltip":M,"aria-label":`Fee breakdown: ${M.replaceAll(`
|
|
2061
|
+
`,", ")}`,"aria-expanded":N,onClick:D=>{D.stopPropagation(),S($=>!$)},onBlur:()=>S(!1),onKeyDown:D=>{D.key==="Escape"&&S(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after confirmation (typically ~30s)."})]})]}),c&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for your deposit. We'll notify you when it arrives."}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:w,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:b,disabled:!F,children:"I've Sent It"})]})]}):e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"!"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Wallet Not Ready"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Your embedded wallet is not set up. Please complete wallet enrollment first."})]})}function Dd({token:t,depositAddress:s,copied:r,feeLine:o,onCopy:n}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Waiting for Deposit"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Looking for incoming ",e.jsx("strong",{children:t.symbol})," deposits..."]}),e.jsxs("div",{className:"cedros-deposit-flow-waiting-info",children:[e.jsx("p",{className:"cedros-deposit-flow-waiting-text",children:"Once your transaction is confirmed on the Solana network, your account will be credited automatically. This usually takes 20-30 seconds."}),s&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit address"}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsxs("code",{className:"cedros-deposit-flow-address",children:[s.slice(0,6),"...",s.slice(-6)]}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:n,title:"Copy address",children:r?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${s}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:o})]})]})]})]})}function Fd({result:t,config:s,onNewDeposit:r}){const o=t.token??Xe,n=mr(o,s),a=n?t.amount*n:t.amount,i=zt(s,a),l=Math.max(a-i,0),c=i===0?0:i<.01?.01:i;return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-success-icon",children:"✓"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Successful!"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Your deposit of ",t.amount.toLocaleString()," ",o.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[t.txSignature&&e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Transaction"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-tx",children:[e.jsxs("a",{href:`https://orbmarkets.io/tx/${t.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[t.txSignature.slice(0,8),"...",t.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${t.txSignature}`,target:"_blank",rel:"noopener noreferrer","aria-label":"View transaction on Orb Markets",title:"View transaction",children:"↗"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Deposit Amount"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value",children:["$",a.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Total Fees"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-fee",children:["-$",c.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Credits Added"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-credit",children:["+$",l.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Available"}),e.jsx("span",{className:"cedros-deposit-flow-summary-value",children:"Immediately"})]})]}),e.jsx("div",{className:"cedros-deposit-flow-actions",children:e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:r,children:"Make Another Deposit"})})]})}function Wd({error:t,onRetry:s,onCancel:r}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"✕"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Failed"}),e.jsx("p",{className:"cedros-deposit-flow-error-message",children:t}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[r&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:s,children:"Try Again"})]})]})}function fr(){const t=B.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),a=d.useMemo(()=>t?new B.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),i=d.useCallback(()=>{n(null)},[]),l=d.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/credits/balance/sol")}catch(m){const h=B.handleApiError(m,"Failed to fetch credit balance");throw n(h.message),h}finally{r(!1)}},[a]),c=d.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return(await a.get("/credits/balance")).balances}catch(m){const h=B.handleApiError(m,"Failed to fetch credit balances");throw n(h.message),h}finally{r(!1)}},[a]),u=d.useCallback(async m=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{const h=new URLSearchParams;m?.currency&&h.set("currency",m.currency),m?.limit!==void 0&&h.set("limit",m.limit.toString()),m?.offset!==void 0&&h.set("offset",m.offset.toString());const p=h.toString(),b=p?`/credits/history?${p}`:"/credits/history";return await a.get(b)}catch(h){const p=B.handleApiError(h,"Failed to fetch transaction history");throw n(p.message),p}finally{r(!1)}},[a]);return{getBalance:l,getAllBalances:c,getHistory:u,isLoading:s,error:o,clearError:i}}function Od({showAllCurrencies:t=!1,refreshInterval:s=0,compact:r=!1,className:o="",onLoad:n}){const{getBalance:a,getAllBalances:i,isLoading:l,error:c,clearError:u}=fr(),[m,h]=d.useState([]),[p,b]=d.useState(null),w=d.useCallback(async()=>{try{if(t){const g=await i();h(g),n?.(g)}else{const g=await a();h([g]),n?.([g])}b(null)}catch(g){b(g instanceof Error?g.message:"Failed to load balance")}},[t,a,i,n]);if(d.useEffect(()=>{w()},[w]),d.useEffect(()=>{if(s<=0)return;const g=setInterval(w,s);return()=>clearInterval(g)},[s,w]),p||c)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${o}`,children:[e.jsx("p",{className:"cedros-credit-error",children:p||c}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{u(),b(null),w()},children:"Retry"})]});if(l&&m.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${o}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(r){const g=m[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${o}`,children:[g?e.jsx("span",{className:"cedros-credit-value",title:`${g.balanceLamports} lamports`,children:g.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),l&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${o}`,children:[e.jsxs("div",{className:"cedros-credit-header",children:[e.jsx("h4",{className:"cedros-credit-title",children:"Credit Balance"}),e.jsx("button",{type:"button",className:"cedros-credit-refresh",onClick:w,disabled:l,title:"Refresh balance",children:l?"...":"↻"})]}),m.length===0?e.jsxs("div",{className:"cedros-credit-empty",children:[e.jsx("p",{className:"cedros-credit-empty-message",children:"No credit balance yet."}),e.jsx("p",{className:"cedros-credit-empty-hint",children:"Make a deposit to get started."})]}):e.jsx("div",{className:"cedros-credit-list",children:m.map(g=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:g.currency}),e.jsx("span",{className:"cedros-credit-amount",children:g.display})]},g.currency))})]})}const Ls=[{key:"all",label:"All",txTypes:null},{key:"deposits",label:"Deposits",txTypes:["deposit"]},{key:"usage",label:"Usage",txTypes:["spend","usage","charge"]},{key:"adjustments",label:"Adjustments",txTypes:["refund","adjustment","bonus","credit"]}];function qd(t,s){const r=t<0,o=Math.abs(t),n=ea(s),a=o/Math.pow(10,n),i=r?"-":"+";return s.toUpperCase()==="SOL"?`${i}${a.toFixed(4)} SOL`:`${i}$${a.toFixed(2)}`}function zd(t){const s=new Date(t),r=new Date,o=r.getTime()-s.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const i=Math.floor(o/6e4);return i<1?"Just now":`${i}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==r.getFullYear()?"numeric":void 0})}function Vd(t){return t?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[t.toLowerCase()]||t:"Transaction"}function Hd(t,s){const r=(t||"").toLowerCase();return r==="deposit"?"↓":r==="spend"||r==="usage"||r==="charge"?"↑":r==="refund"?"←":r==="bonus"||r==="credit"?"★":s?"+":"−"}function $d({defaultTab:t="all",pageSize:s=10,refreshInterval:r=0,className:o="",onLoad:n,onTransactionClick:a}){const{getHistory:i,isLoading:l,error:c,clearError:u}=fr(),[m,h]=d.useState(t),[p,b]=d.useState([]),[w,g]=d.useState(0),[k,A]=d.useState(0),[j,N]=d.useState(null),S=Ls.find(L=>L.key===m)||Ls[0],C=d.useMemo(()=>S.txTypes===null?p:p.filter(L=>{const R=L.txType||"";return S.txTypes.some(T=>R.toLowerCase()===T.toLowerCase())}),[p,S.txTypes]),f=d.useCallback(async()=>{try{const L=await i({limit:s*3,offset:k});b(L.transactions),g(L.total),n?.(L),N(null)}catch(L){N(L instanceof Error?L.message:"Failed to load history")}},[s,k,i,n]);d.useEffect(()=>{A(0)},[m]),d.useEffect(()=>{f()},[f]),d.useEffect(()=>{if(r<=0)return;const L=setInterval(f,r);return()=>clearInterval(L)},[r,f]);const y=S.txTypes===null?w:C.length,x=Math.ceil(y/s),v=Math.floor(k/s)+1,_=L=>{const R=(L-1)*s;A(Math.max(0,Math.min(R,Math.max(0,y-s))))},E=L=>{h(L)};if(j||c)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${o}`,children:[e.jsx("p",{className:"cedros-tx-error",children:j||c}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{u(),N(null),f()},children:"Retry"})]});if(l&&p.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${o}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const P=L=>L.txTypes===null?p.length:p.filter(R=>{const T=R.txType||"";return L.txTypes.some(M=>T.toLowerCase()===M.toLowerCase())}).length;return e.jsxs("div",{className:`cedros-tx-history ${o}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Transaction History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:f,disabled:l,title:"Refresh",children:l?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:Ls.map(L=>{const R=P(L),T=m===L.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${T?"cedros-tx-tab-active":""}`,onClick:()=>E(L.key),children:[L.label,R>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:R})]},L.key)})}),C.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:m==="all"?"No transactions yet.":`No ${S.label.toLowerCase()} found.`}),m==="all"&&e.jsx("p",{className:"cedros-tx-empty-hint",children:"Make a deposit to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:C.slice(0,s).map(L=>{const R=L.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${R?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>a?.(L),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),a?.(L))},role:a?"button":void 0,tabIndex:a?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${R?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:Hd(L.txType,R)}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsx("span",{className:"cedros-tx-type",children:Vd(L.txType)}),e.jsx("span",{className:`cedros-tx-amount ${R?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:qd(L.amountLamports,L.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:L.description}),e.jsx("span",{className:"cedros-tx-date",children:zd(L.createdAt)})]})]})]},L.id)})}),x>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>_(v-1),disabled:v<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",v," of ",x]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>_(v+1),disabled:v>=x,children:"Next"})]})]})]})}function pr(){const t=B.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),[a,i]=d.useState(null),l=d.useMemo(()=>t?new B.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),c=d.useCallback(()=>{n(null)},[]),u=d.useCallback(async()=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await l.get("/wallet/withdraw/balances")}catch(b){const w=B.handleApiError(b,"Failed to fetch wallet balances");throw n(w.message),w}},[l]),m=d.useCallback(async(b,w)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=await l.post("/wallet/withdraw/sol",{destination:b,amount_lamports:w});return i(g),g}catch(g){const k=B.handleApiError(g,"Failed to withdraw SOL");throw n(k.message),k}finally{r(!1)}},[l]),h=d.useCallback(async(b,w,g)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const k=await l.post("/wallet/withdraw/spl",{destination:b,token_mint:w,amount:g});return i(k),k}catch(k){const A=B.handleApiError(k,"Failed to withdraw token");throw n(A.message),A}finally{r(!1)}},[l]),p=d.useCallback(async(b=10,w=0)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const g=Math.max(1,Math.min(100,Math.trunc(b))),k=Math.max(0,Math.trunc(w)),A=new URLSearchParams({limit:String(g),offset:String(k)});return await l.get(`/wallet/withdraw/history?${A}`)}catch(g){const k=B.handleApiError(g,"Failed to fetch withdrawal history");throw n(k.message),k}},[l]);return{withdrawSol:m,withdrawSpl:h,getBalances:u,getHistory:p,isSubmitting:s,error:o,clearError:c,lastResult:a}}const Ps="So11111111111111111111111111111111111111112",Kd={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function Gd(t){return t.length<32||t.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(t)}function Rs(t){return t.length<=16?t:`${t.slice(0,6)}...${t.slice(-6)}`}function bt(t,s){return(Number(t)/Math.pow(10,s)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(s,6)})}function Qd({onSuccess:t,onError:s,onCancel:r,className:o=""}){const n=B.useCedrosLoginOptional(),{withdrawSol:a,withdrawSpl:i,getBalances:l,isSubmitting:c,error:u,clearError:m}=pr(),[h,p]=d.useState("loading"),[b,w]=d.useState([]),[g,k]=d.useState(null),[A,j]=d.useState(""),[N,S]=d.useState(""),[C,f]=d.useState(null),[y,x]=d.useState(null),[v,_]=d.useState(null),E=n?.config.solana?.network??"mainnet-beta",P=d.useMemo(()=>{if(!C?.txSignature)return"";const I=`https://explorer.solana.com/tx/${C.txSignature}`;return E==="mainnet-beta"?I:`${I}?cluster=${encodeURIComponent(E)}`},[C,E]),L=d.useMemo(()=>{if(!g||!N)return"0";const I=parseFloat(N);return isNaN(I)||I<=0?"0":Math.floor(I*Math.pow(10,g.decimals)).toString()},[N,g]);d.useEffect(()=>{if(!n)return;let I=!1;return(async()=>{try{const D=await l();if(I)return;const $=[];D.solLamports>0&&$.push({symbol:"SOL",mint:Ps,decimals:9,rawBalance:String(D.solLamports),displayBalance:bt(String(D.solLamports),9)});for(const Z of D.tokens){const se=Kd[Z.mint]??Rs(Z.mint);$.push({symbol:se,mint:Z.mint,decimals:Z.decimals,rawBalance:Z.amount,displayBalance:bt(Z.amount,Z.decimals)})}w($),p(($.length>0,"select"))}catch{I||(_("Failed to load wallet balances"),p("select"))}})(),()=>{I=!0}},[n,l]);const R=d.useCallback(I=>{k(I),p("form"),m(),x(null),S("")},[m]),T=d.useCallback(()=>{if(!g)return;const I=Number(g.rawBalance)/Math.pow(10,g.decimals);g.mint===Ps?S(String(Math.max(0,I-.01))):S(String(I))},[g]),M=d.useCallback(()=>{if(x(null),!A.trim()){x("Destination address is required");return}if(!Gd(A.trim())){x("Invalid Solana address");return}if(!N||parseFloat(N)<=0||isNaN(parseFloat(N))){x("Please enter a valid amount");return}if(L==="0"){x("Amount is too small");return}p("confirm")},[A,N,L]),F=d.useCallback(async()=>{if(g){p("processing"),m();try{let I;g.mint===Ps?I=await a(A.trim(),Number(L)):I=await i(A.trim(),g.mint,L),f(I),p("success"),t?.(I)}catch(I){p("confirm"),s?.(I instanceof Error?I:new Error(String(I)))}}},[g,A,L,a,i,m,t,s]),W=d.useCallback(()=>{m(),x(null),h==="form"?(p("select"),k(null),S(""),j("")):h==="confirm"&&p("form")},[h,m]),q=d.useCallback(()=>{p("select"),k(null),j(""),S(""),f(null),m(),x(null)},[m]);return n?e.jsxs("div",{className:`cedros-withdrawal ${o}`,children:[h==="loading"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(V.LoadingSpinner,{}),e.jsx("p",{className:"cedros-withdrawal-processing-text",children:"Loading wallet balances..."})]}),h==="select"&&e.jsxs("div",{className:"cedros-withdrawal-select",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdraw"}),e.jsx("p",{className:"cedros-withdrawal-subtitle",children:"Select a token to withdraw"})]}),v&&e.jsx(J.ErrorMessage,{error:v}),b.length===0&&!v&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:b.map(I=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>R(I),children:[e.jsx("span",{className:"cedros-withdrawal-token-symbol",children:I.symbol}),e.jsx("span",{className:"cedros-withdrawal-token-balance",children:I.displayBalance})]},I.mint))}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:r,children:"Cancel"})]}),h==="form"&&g&&e.jsxs("div",{className:"cedros-withdrawal-form",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:W,children:"Back"}),e.jsxs("h3",{className:"cedros-withdrawal-title",children:["Withdraw ",g.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",g.displayBalance," ",g.symbol]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsx("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-destination",children:"Destination Address"}),e.jsx("input",{id:"cedros-withdrawal-destination",type:"text",className:"cedros-input",placeholder:"Solana address (base58)",value:A,onChange:I=>j(I.target.value),autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsxs("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-amount",children:["Amount (",g.symbol,")"]}),e.jsxs("div",{className:"cedros-withdrawal-amount-row",children:[e.jsx("input",{id:"cedros-withdrawal-amount",type:"number",className:"cedros-input",placeholder:"0.00",value:N,onChange:I=>S(I.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:T,children:"Max"})]})]}),(y||u)&&e.jsx(J.ErrorMessage,{error:y||u||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:M,children:"Review Withdrawal"})]}),h==="confirm"&&g&&e.jsxs("div",{className:"cedros-withdrawal-confirm",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:W,disabled:c,children:"Back"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Confirm Withdrawal"})]}),e.jsxs("div",{className:"cedros-withdrawal-summary",children:[e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Token"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:g.symbol})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Amount"}),e.jsxs("span",{className:"cedros-withdrawal-summary-value",children:[bt(L,g.decimals)," ",g.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Destination"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",title:A,children:Rs(A)})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Est. Fee"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:"~0.000005 SOL"})]})]}),u&&e.jsx(J.ErrorMessage,{error:u}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:W,disabled:c,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:F,disabled:c,children:c?"Sending...":"Confirm & Send"})]})]}),h==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(V.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",g?.symbol,"..."]})]}),h==="success"&&C&&e.jsxs("div",{className:"cedros-withdrawal-success",children:[e.jsx("div",{className:"cedros-withdrawal-success-icon",children:"✓"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdrawal Complete"}),e.jsxs("p",{className:"cedros-withdrawal-subtitle",children:[bt(L,g?.decimals??9)," ",g?.symbol," ","sent"]}),e.jsxs("div",{className:"cedros-withdrawal-tx",children:[e.jsx("span",{className:"cedros-withdrawal-tx-label",children:"Transaction"}),e.jsx("a",{className:"cedros-withdrawal-tx-link",href:P,target:"_blank",rel:"noreferrer",children:Rs(C.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:q,children:"Done"})]})]}):null}function Yd(t,s){if(t==="sol")return"SOL";if(!s)return"SPL";const r=qt.find(o=>o.mint===s);return r?r.symbol:`${s.slice(0,4)}...${s.slice(-4)}`}function Zd(t,s){const r=Number(t);if(Number.isNaN(r))return t;const o=ea(s),n=r/Math.pow(10,o);return s==="SOL"?`${n.toFixed(4)} SOL`:`${n.toFixed(2)} ${s}`}function Xd(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function Jd(t){const s=new Date(t),r=new Date,o=r.getTime()-s.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const i=Math.floor(o/6e4);return i<1?"Just now":`${i}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==r.getFullYear()?"numeric":void 0})}function eu({pageSize:t=10,className:s="",onTransactionClick:r,explorerUrl:o="https://solscan.io"}){const n=o.startsWith("https://")?o:"https://solscan.io",{getHistory:a,error:i,clearError:l}=pr(),[c,u]=d.useState([]),[m,h]=d.useState(0),[p,b]=d.useState(0),[w,g]=d.useState(!1),[k,A]=d.useState(null),j=d.useCallback(async()=>{g(!0);try{const f=await a(t,p);u(f.items),h(f.total),A(null)}catch(f){A(f instanceof Error?f.message:"Failed to load withdrawal history")}finally{g(!1)}},[t,p,a]);d.useEffect(()=>{j()},[j]);const N=Math.ceil(m/t),S=Math.floor(p/t)+1,C=f=>{const y=(f-1)*t;b(Math.max(0,Math.min(y,Math.max(0,m-t))))};return k||i?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${s}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:k||i}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{l(),A(null),j()},children:"Retry"})]}):w&&c.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${s}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-withdrawal-history ${s}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Withdrawal History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:j,disabled:w,title:"Refresh",children:w?"...":"↻"})]}),c.length===0?e.jsx("div",{className:"cedros-tx-empty",children:e.jsx("p",{className:"cedros-tx-empty-message",children:"No withdrawal history yet."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:c.map(f=>{const y=Yd(f.tokenType,f.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>r?.(f),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),r?.(f))},role:r?"button":void 0,tabIndex:r?0:void 0,children:[e.jsx("div",{className:"cedros-tx-icon cedros-tx-icon-negative",children:"↑"}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsxs("span",{className:"cedros-tx-type",children:[y," Withdrawal"]}),e.jsx("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:Zd(f.amount,y)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${n}/account/${f.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),children:Xd(f.destination)})," · ",e.jsx("a",{href:`${n}/tx/${f.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:Jd(f.createdAt)})]})]})]},f.id)})}),N>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>C(S-1),disabled:S<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",S," of ",N]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>C(S+1),disabled:S>=N,children:"Next"})]})]})]})}function tu({brandLogo:t,brandName:s,title:r="Welcome back",subtitle:o="Login with your Apple or Google account",termsText:n,onSuccess:a,defaultTab:i="login",children:l,className:c=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${c}`,children:[(t||s)&&e.jsxs("div",{className:"cedros-brand-header",children:[t,s&&e.jsx("span",{className:"cedros-brand-name",children:s})]}),e.jsxs("div",{className:"cedros-full-page-card",children:[e.jsxs("div",{className:"cedros-full-page-header",children:[e.jsx("h1",{className:"cedros-full-page-title",children:r}),o&&e.jsx("p",{className:"cedros-full-page-subtitle",children:o})]}),l??e.jsx(Wt,{defaultTab:i,onSuccess:a})]}),n&&e.jsx("p",{className:"cedros-terms-footer",children:n})]})}function su({brandName:t="Your Brand",brandLogo:s,tagline:r="Your tagline goes here. Make it compelling.",title:o="Sign in",subtitle:n="Enter your credentials to access your account",onSuccess:a,defaultTab:i="login",children:l,className:c=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${c}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[s??e.jsx("div",{className:"cedros-split-page-logo",children:t.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:t}),r&&e.jsx("p",{className:"cedros-split-page-tagline",children:r})]})}),e.jsx("div",{className:"cedros-split-page-form",children:e.jsxs("div",{className:"cedros-split-page-form-content",children:[e.jsx("h2",{className:"cedros-split-page-title",children:o}),n&&e.jsx("p",{className:"cedros-split-page-subtitle",children:n}),l??e.jsx(Wt,{defaultTab:i,onSuccess:a})]})})]})}function ru(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),n=d.useMemo(()=>new $s.OrgApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,s?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),a=d.useCallback(async c=>{o(u=>({...u,isLoading:!0,error:null}));try{const u=await n.authorize(c),m={allowed:u.allowed,reason:u.reason,isLoading:!1,error:null};return o(m),m}catch(u){const m={allowed:!1,reason:void 0,isLoading:!1,error:u};return o(m),m}},[n]),i=d.useCallback(async c=>(await a(c)).allowed,[a]),l=d.useCallback(()=>{o({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:i,lastCheck:r,clearCheck:l,checkAuthorization:a}}function nu(){const{listAllWallets:t,createDerivedWallet:s,deleteDerivedWallet:r}=U.useWalletMaterial(),[o,n]=d.useState([]),[a,i]=d.useState(!1),[l,c]=d.useState(null),u=d.useCallback(async()=>{i(!0),c(null);try{const b=await t();n(b.wallets)}catch(b){const w=b instanceof Error?b.message:"Failed to list wallets";c(w)}finally{i(!1)}},[t]),m=d.useCallback(async b=>{i(!0),c(null);try{const w=await s({label:b});return await u(),w}catch(w){const g=w instanceof Error?w.message:"Failed to create wallet";throw c(g),w}finally{i(!1)}},[s,u]),h=d.useCallback(async b=>{i(!0),c(null);try{await r(b),await u()}catch(w){const g=w instanceof Error?w.message:"Failed to delete wallet";throw c(g),w}finally{i(!1)}},[r,u]),p=d.useCallback(()=>c(null),[]);return{wallets:o,isLoading:a,createWallet:m,deleteWallet:h,refresh:u,error:l,clearError:p}}function ou(){const t=B.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),[a,i]=d.useState(null),l=d.useMemo(()=>t?new B.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),c=d.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const h=await l.get("/wallet/pending-recovery");i(h)}catch(h){const p=B.handleApiError(h,"Failed to fetch pending recovery");throw n(p.message),p}finally{r(!1)}},[l]),u=d.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const h={confirmed:!0};await l.post("/wallet/acknowledge-recovery",h),i(null)}catch(h){const p=B.handleApiError(h,"Failed to acknowledge recovery");throw n(p.message),p}finally{r(!1)}},[l]),m=d.useCallback(()=>n(null),[]);return d.useEffect(()=>{l&&t?.authState==="authenticated"&&c().catch(()=>{})},[l,t?.authState,c]),{hasPendingRecovery:a?.hasPendingRecovery??!1,recoveryType:a?.recoveryType??null,recoveryPhrase:a?.recoveryPhrase??null,expiresAt:a?.expiresAt?new Date(a.expiresAt):null,fetchPendingRecovery:c,acknowledgeRecovery:u,isLoading:s,error:o,clearError:m}}function au(t={}){const{onExternalSign:s}=t,{solanaPubkey:r,hasExternalWallet:o,status:n,isUnlocked:a}=U.useWallet(),{signTransaction:i,isSigning:l,error:c,clearError:u}=Co(),m=d.useMemo(()=>o&&s?"external":n==="enrolled_locked"||n==="enrolled_unlocked"?"sss":"none",[o,s,n]),h=m!=="none",p=n==="enrolled_locked"||n==="enrolled_unlocked";return{signTransaction:d.useCallback(async(w,g)=>{if(m==="external"){if(!s)throw new Error("External wallet signing callback not provided");return s(w)}if(m==="sss"){if(!g&&!a)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return g?i(w,g):i(w)}throw new Error("No signing method available. Enroll a wallet first.")},[m,s,a,i]),signingMethod:m,canSign:h,isSigning:l,publicKey:r,hasExternalWallet:o,hasSssWallet:p,isSssUnlocked:a,error:c,clearError:u}}function iu(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(null),[n,a]=d.useState(!1),[i,l]=d.useState(null),c=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),u=d.useCallback(async()=>{a(!0),l(null);try{await c.post("/welcome-completed",{})}catch(h){const p=h instanceof Error?h:new Error(String(h));throw l(p),p}finally{a(!1)}},[c]),m=d.useCallback(()=>{o(null)},[]);return{postLoginAction:r,setPostLoginAction:o,markWelcomeCompleted:u,clearPostLogin:m,isLoading:n,error:i}}function cu(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(null),[m,h]=d.useState(null),[p,b]=d.useState(null),w=p!==null&&p!=="none",g=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),k=d.useCallback(async()=>{o(!0),a(null);try{const j=await g.get("/kyc/status",{credentials:"include"});return l(j.status),u(j.verifiedAt??null),h(j.expiresAt??null),b(j.enforcementMode),j}catch(j){const N=j instanceof Error?j:new Error(String(j));throw a(N),N}finally{o(!1)}},[g]),A=d.useCallback(async()=>{o(!0),a(null);try{const j=await g.post("/kyc/start",void 0,{credentials:"include"});return l("pending"),j.redirectUrl}catch(j){const N=j instanceof Error?j:new Error(String(j));throw a(N),N}finally{o(!1)}},[g]);return{status:i,verifiedAt:c,expiresAt:m,isRequired:w,enforcementMode:p,fetchStatus:k,startVerification:A,isLoading:r,error:n}}function oa(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState([]),[m,h]=d.useState(0),p=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),b=d.useCallback(async()=>{o(!0),a(null);try{const k=await p.get("/referral/rewards",{credentials:"include"});return l(k),k}catch(k){const A=k instanceof Error?k:new Error(String(k));throw a(A),A}finally{o(!1)}},[p]),w=d.useCallback(async(k=10,A=0)=>{o(!0),a(null);try{const j=await p.get(`/referral/rewards/history?limit=${k}&offset=${A}`,{credentials:"include"});return u(j.items),h(j.total),j}catch(j){const N=j instanceof Error?j:new Error(String(j));throw a(N),N}finally{o(!1)}},[p]),g=d.useCallback(async k=>{o(!0),a(null);try{await p.post("/referral/payout-wallet",{walletAddress:k},{credentials:"include"}),l(A=>A&&{...A,payoutWalletAddress:k})}catch(A){const j=A instanceof Error?A:new Error(String(A));throw a(j),j}finally{o(!1)}},[p]);return{rewards:i,history:c,historyTotal:m,fetchRewards:b,fetchHistory:w,setPayoutWallet:g,isLoading:r,error:n}}function Ts(t,s){return s==="SOL"?(t/1e9).toFixed(4)+" SOL":"$"+(t/1e6).toFixed(2)}function lu(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return t}}const du=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function uu(t){return du.test(t)}function hu(t){switch(t){case"signup":return"Sign-up";case"spend":return"Spend";case"first_spend":return"First Spend";default:return t}}function mu({status:t}){const r={pending:"cedros-rewards-panel__badge--pending",completed:"cedros-rewards-panel__badge--completed",failed:"cedros-rewards-panel__badge--failed",credited:"cedros-rewards-panel__badge--credited"}[t]??"cedros-rewards-panel__badge--pending";return e.jsx("span",{className:`cedros-rewards-panel__badge ${r}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}const yt=10;function fu({explorerUrl:t="https://explorer.solana.com",className:s}){const{rewards:r,history:o,historyTotal:n,fetchRewards:a,fetchHistory:i,setPayoutWallet:l,isLoading:c,error:u}=oa(),[m,h]=d.useState(0),[p,b]=d.useState(""),[w,g]=d.useState(null),[k,A]=d.useState(!1),[j,N]=d.useState(!1);d.useEffect(()=>{a().catch(()=>{}),i(yt,0).catch(()=>{})},[a,i]),d.useEffect(()=>{r?.payoutWalletAddress!=null&&b(r.payoutWalletAddress)},[r?.payoutWalletAddress]);const S=d.useCallback(x=>{h(x),i(yt,x*yt).catch(()=>{})},[i]),C=Math.ceil(n/yt),f=d.useCallback(async()=>{const x=p.trim();if(x!==""&&!uu(x)){g("Invalid address. Must be a base58 string between 32 and 44 characters.");return}g(null),A(!0),N(!1);try{await l(x===""?null:x),N(!0)}catch(v){g(v instanceof Error?v.message:"Failed to save wallet address.")}finally{A(!1)}},[p,l]),y=r?.rewardType==="direct_payout"?"Direct Payout":"Credits";return e.jsxs("div",{className:`cedros-rewards-panel ${s??""}`.trim(),"aria-label":"Rewards dashboard",children:[u&&e.jsx("div",{className:"cedros-rewards-panel__error",role:"alert",children:u.message}),e.jsxs("section",{className:"cedros-rewards-panel__summary","aria-label":"Rewards summary",children:[e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Total Earned"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?Ts(r.totalEarned,r.currency):"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Pending Payouts"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?`${Ts(r.pendingAmount,r.currency)} (${r.pendingCount})`:"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Referrals"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?String(r.referralCount):"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Reward Type"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:e.jsx("span",{className:"cedros-rewards-panel__type-badge",children:y})})]})]}),r?.rewardType==="direct_payout"&&e.jsxs("section",{className:"cedros-rewards-panel__wallet-section","aria-label":"Payout wallet",children:[e.jsx("h3",{className:"cedros-rewards-panel__section-title",children:"Payout Wallet"}),e.jsxs("div",{className:"cedros-rewards-panel__wallet-current",children:[e.jsx("span",{className:"cedros-rewards-panel__wallet-label",children:"Current address:"}),e.jsx("span",{className:"cedros-rewards-panel__wallet-address",children:r.payoutWalletAddress??"Not set"})]}),e.jsxs("div",{className:"cedros-rewards-panel__wallet-form",children:[e.jsx("label",{htmlFor:"cedros-payout-wallet-input",className:"cedros-rewards-panel__wallet-input-label",children:"Wallet address"}),e.jsx("input",{id:"cedros-payout-wallet-input",type:"text",className:"cedros-rewards-panel__wallet-input",value:p,onChange:x=>{b(x.target.value),g(null),N(!1)},placeholder:"Base58 Solana address","aria-describedby":w?"cedros-wallet-error":void 0,disabled:k}),e.jsx("button",{type:"button",className:"cedros-rewards-panel__wallet-save-btn",onClick:f,disabled:k||c,children:k?"Saving...":"Save"})]}),w&&e.jsx("div",{id:"cedros-wallet-error",className:"cedros-rewards-panel__wallet-error",role:"alert",children:w}),j&&!w&&e.jsx("div",{className:"cedros-rewards-panel__wallet-success",role:"status",children:"Wallet address saved."})]}),e.jsxs("section",{className:"cedros-rewards-panel__history-section","aria-label":"Reward history",children:[e.jsx("h3",{className:"cedros-rewards-panel__section-title",children:"History"}),c&&o.length===0?e.jsx("div",{className:"cedros-rewards-panel__loading","aria-busy":"true",children:"Loading..."}):o.length===0?e.jsx("div",{className:"cedros-rewards-panel__empty",children:"No rewards yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-rewards-panel__table-wrapper",role:"region","aria-label":"Reward history table",tabIndex:0,children:e.jsxs("table",{className:"cedros-rewards-panel__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Date"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Type"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Amount"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Status"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Transaction"})]})}),e.jsx("tbody",{children:o.map(x=>e.jsxs("tr",{className:"cedros-rewards-panel__tr",children:[e.jsx("td",{className:"cedros-rewards-panel__td",children:lu(x.createdAt)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:hu(x.triggerType)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:Ts(x.amount,x.currency)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:e.jsx(mu,{status:x.status})}),e.jsx("td",{className:"cedros-rewards-panel__td",children:x.txSignature?e.jsxs("a",{href:`${t}/tx/${x.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-rewards-panel__tx-link","aria-label":`View transaction ${x.txSignature.slice(0,8)}... on Solana explorer`,children:[x.txSignature.slice(0,8),"..."]}):e.jsx("span",{className:"cedros-rewards-panel__tx-none",children:"—"})})]},x.id))})]})}),C>1&&e.jsxs("div",{className:"cedros-rewards-panel__pagination",role:"navigation","aria-label":"History pagination",children:[e.jsx("button",{type:"button",className:"cedros-rewards-panel__page-btn",onClick:()=>S(m-1),disabled:m===0||c,"aria-label":"Previous page",children:"Previous"}),e.jsxs("span",{className:"cedros-rewards-panel__page-info",children:[m+1," / ",C]}),e.jsx("button",{type:"button",className:"cedros-rewards-panel__page-btn",onClick:()=>S(m+1),disabled:m>=C-1||c,"aria-label":"Next page",children:"Next"})]})]})]})]})}function pu({status:t,startVerification:s,className:r}){const[o,n]=d.useState(!1),[a,i]=d.useState(null),l=d.useCallback(async()=>{n(!0),i(null);try{const m=await s();m&&(window.location.href=m)}catch(m){i(m instanceof Error?m.message:"Failed to start verification")}finally{n(!1)}},[s]);if(t==="verified")return null;let c;switch(t){case"pending":c="Your identity verification is being processed.";break;case"failed":c="Identity verification failed. Please try again.";break;case"expired":c="Your identity verification has expired. Please verify again.";break;case"canceled":c="Verification was canceled. Please try again.";break;default:c="Identity verification is required to continue.";break}const u=t!=="pending";return e.jsxs("div",{className:`cedros-kyc-banner ${r??""}`,role:"alert",children:[e.jsxs("div",{className:"cedros-kyc-banner-content",children:[e.jsx("span",{className:"cedros-kyc-banner-message",children:c}),u&&e.jsx("button",{type:"button",className:"cedros-kyc-banner-button",onClick:l,disabled:o,children:o?"Starting...":"Verify Identity"})]}),a&&e.jsx("div",{className:"cedros-kyc-banner-error",children:a})]})}const gu=3e3,wu=6e4;function bu(t){switch(t){case"verified":return"Identity verified successfully!";case"failed":return"Verification failed. You can try again.";case"expired":return"Your identity verification has expired.";case"canceled":return"Verification was canceled.";default:return"Verification was canceled."}}function yu({fetchStatus:t,onComplete:s,className:r}){const[o,n]=d.useState(null),[a,i]=d.useState(!1),l=d.useRef(s);l.current=s;const c=d.useRef(t);c.current=t,d.useEffect(()=>{let m=!1,h=null;const p=setTimeout(()=>{i(!0),h!==null&&clearInterval(h)},wu),b=async()=>{try{const w=await c.current();if(m)return;n(w.status),w.status!=="pending"&&(clearTimeout(p),h!==null&&clearInterval(h),l.current?.(w.status))}catch{}};return b(),h=setInterval(b,gu),()=>{m=!0,clearTimeout(p),h!==null&&clearInterval(h)}},[]);const u=!o||o==="pending";return e.jsx("div",{className:`cedros-kyc-callback ${r??""}`,role:"status","aria-live":"polite",children:a&&u?e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("p",{className:"cedros-kyc-callback-message",children:"Verification is taking longer than expected. Please refresh or check back later."}),s&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>s("pending"),children:"Continue"})]}):u?e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("span",{className:"cedros-kyc-callback-spinner","aria-hidden":"true"}),e.jsx("p",{className:"cedros-kyc-callback-message",children:"Processing your verification..."})]}):e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("p",{className:`cedros-kyc-callback-message cedros-kyc-callback-message--${o}`,children:bu(o)}),s&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>s(o),children:"Continue"})]})})}function aa(){const{config:t,_internal:s}=B.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(null),[m,h]=d.useState(null),[p,b]=d.useState(null),w=p!==null&&p!=="none",g=d.useMemo(()=>new B.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),k=d.useCallback(async()=>{o(!0),a(null);try{const S=await g.get("/accreditation/status",{credentials:"include"});return l(S.status),u(S.verifiedAt??null),h(S.expiresAt??null),b(S.enforcementMode),S}catch(S){const C=S instanceof Error?S:new Error(String(S));throw a(C),C}finally{o(!1)}},[g]),A=d.useCallback(async(S,C)=>{o(!0),a(null);try{const f=await g.post("/accreditation/submit",{method:S,...C},{credentials:"include"});return l("pending"),f}catch(f){const y=f instanceof Error?f:new Error(String(f));throw a(y),y}finally{o(!1)}},[g]),j=d.useCallback(async(S,C,f)=>{o(!0),a(null);try{const y=new FormData;y.append("submissionId",S),y.append("documentType",f),y.append("file",C);const x=s?.getAccessToken?.(),v={};x&&(v.Authorization=`Bearer ${x}`);const _=await fetch(`${t.serverUrl}/accreditation/upload`,{method:"POST",headers:v,credentials:"include",body:y});if(!_.ok){const E=await _.text().catch(()=>_.statusText);throw new Error(`Upload failed (${_.status}): ${E}`)}return _.json()}catch(y){const x=y instanceof Error?y:new Error(String(y));throw a(x),x}finally{o(!1)}},[t.serverUrl,s]),N=d.useCallback(async()=>{o(!0),a(null);try{return(await g.get("/accreditation/submissions",{credentials:"include"})).submissions}catch(S){const C=S instanceof Error?S:new Error(String(S));throw a(C),C}finally{o(!1)}},[g]);return{status:i,verifiedAt:c,expiresAt:m,isRequired:w,enforcementMode:p,fetchStatus:k,submitVerification:A,uploadDocument:j,listSubmissions:N,isLoading:r,error:n}}const Sn=[{method:"income",label:"Income",description:"Verify via annual income ($200K+ individual / $300K+ joint)"},{method:"net_worth",label:"Net Worth",description:"Verify via net worth ($1M+ excluding primary residence)"},{method:"credential",label:"Professional Credential",description:"Verify via FINRA license (Series 7, 65, or 82)"},{method:"third_party_letter",label:"Third-Party Letter",description:"Upload a verification letter from a CPA, attorney, or RIA"},{method:"insider",label:"Insider / Officer",description:"Self-certify as a director, executive officer, or general partner"},{method:"investment_threshold",label:"Investment Threshold",description:"Qualify via investment commitment ($200K+ individual / $1M+ entity)"}];function xt({label:t,acceptedTypes:s=".pdf,.jpg,.jpeg,.png,.tiff",documentType:r,files:o,onFilesChange:n,maxFiles:a=5}){const i=d.useRef(null),[l,c]=d.useState(!1),u=d.useCallback(h=>{if(!h)return;const p=Array.from(h),b=[...o,...p].slice(0,a);n(b)},[o,a,n]),m=h=>{n(o.filter((p,b)=>b!==h))};return e.jsxs("div",{className:"cedros-accreditation-wizard__upload-zone",children:[e.jsx("p",{className:"cedros-accreditation-wizard__upload-label",children:t}),e.jsxs("div",{className:`cedros-accreditation-wizard__drop-area${l?" cedros-accreditation-wizard__drop-area--active":""}`,role:"button",tabIndex:0,"aria-label":`Upload files: ${t}`,onClick:()=>i.current?.click(),onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&i.current?.click()},onDragOver:h=>{h.preventDefault(),c(!0)},onDragLeave:()=>c(!1),onDrop:h=>{h.preventDefault(),c(!1),u(h.dataTransfer.files)},children:[e.jsx("span",{children:"Click or drag files here"}),e.jsx("span",{className:"cedros-accreditation-wizard__upload-hint",children:s})]}),e.jsx("input",{ref:i,type:"file",accept:s,multiple:a>1,style:{display:"none"},onChange:h=>u(h.target.files),"aria-hidden":"true"}),o.length>0&&e.jsx("ul",{className:"cedros-accreditation-wizard__file-list","aria-label":"Uploaded files",children:o.map((h,p)=>e.jsxs("li",{className:"cedros-accreditation-wizard__file-item",children:[e.jsx("span",{children:h.name}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__file-remove",onClick:()=>m(p),"aria-label":`Remove ${h.name}`,children:"Remove"})]},`${h.name}-${p}`))})]})}function xu(t,s,r,o){s({...t,[r]:o})}function At(t,s){return t.filter(r=>r.documentType===s).map(r=>r.file)}function vt(t,s,r,o){const n=t.filter(a=>a.documentType!==s);o([...n,...r.map(a=>({file:a,documentType:s}))])}function Au({method:t,formData:s,onFormDataChange:r,fileEntries:o,onFileEntriesChange:n}){const a=(i,l)=>xu(s,r,i,l);return t==="income"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Income Details"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",children:"Income type"}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"incomeType",value:"individual",checked:s.incomeType==="individual",onChange:()=>a("incomeType","individual")})," ","Individual ($200K+)"]}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"incomeType",value:"joint",checked:s.incomeType==="joint",onChange:()=>a("incomeType","joint")})," ","Joint with spouse ($300K+)"]})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"statedAmount",children:"Stated annual income (USD)"}),e.jsx("input",{id:"statedAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:s.statedAmountUsd??"",onChange:i=>a("statedAmountUsd",i.target.valueAsNumber)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"userStatement",children:"Statement about current year income expectation"}),e.jsx("textarea",{id:"userStatement",className:"cedros-accreditation-wizard__textarea",rows:3,value:s.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx(xt,{label:"Upload tax documents (W-2, 1040, 1099, K-1) from the last 2 years",documentType:"tax_return",files:At(o,"tax_return"),onFilesChange:i=>vt(o,"tax_return",i,n)})]}):t==="net_worth"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Net Worth Details"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"netWorthAmount",children:"Stated net worth (USD, excluding primary residence)"}),e.jsx("input",{id:"netWorthAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:s.statedAmountUsd??"",onChange:i=>a("statedAmountUsd",i.target.valueAsNumber)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Documents must be dated within the last 90 days."}),e.jsx(xt,{label:"Upload asset documents (bank/brokerage statements, property appraisals)",documentType:"asset_statement",files:At(o,"asset_statement"),onFilesChange:i=>vt(o,"asset_statement",i,n)}),e.jsx(xt,{label:"Upload liability documents (credit report)",documentType:"liability_statement",files:At(o,"liability_statement"),onFilesChange:i=>vt(o,"liability_statement",i,n)})]}):t==="credential"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Professional Credential"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"crdNumber",children:"FINRA CRD Number"}),e.jsx("input",{id:"crdNumber",type:"text",className:"cedros-accreditation-wizard__input",value:s.crdNumber??"",onChange:i=>a("crdNumber",i.target.value)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"licenseType",children:"License type"}),e.jsxs("select",{id:"licenseType",className:"cedros-accreditation-wizard__select",value:s.licenseType??"",onChange:i=>a("licenseType",i.target.value),children:[e.jsx("option",{value:"",children:"Select a license"}),e.jsx("option",{value:"series_7",children:"Series 7"}),e.jsx("option",{value:"series_65",children:"Series 65"}),e.jsx("option",{value:"series_82",children:"Series 82"})]})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Your license will be verified via FINRA BrokerCheck."})]}):t==="third_party_letter"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Third-Party Letter"}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Letter must be dated within the last 90 days."}),e.jsx(xt,{label:"Upload verification letter from a CPA, attorney, RIA, or broker-dealer",documentType:"letter",files:At(o,"letter"),onFilesChange:i=>vt(o,"letter",i,n),maxFiles:1})]}):t==="insider"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Insider / Officer"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"insiderStatement",children:"Describe your role as director, executive officer, or general partner"}),e.jsx("textarea",{id:"insiderStatement",className:"cedros-accreditation-wizard__textarea",rows:4,value:s.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"An administrator will verify your status."})]}):e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Investment Threshold"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",children:"Entity type"}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"entityType",value:"individual",checked:s.entityType==="individual",onChange:()=>a("entityType","individual")})," ","Individual ($200K+)"]}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"entityType",value:"entity",checked:s.entityType==="entity",onChange:()=>a("entityType","entity")})," ","Entity ($1M+)"]})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"commitmentAmount",children:"Investment commitment amount (USD)"}),e.jsx("input",{id:"commitmentAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:s.investmentCommitmentUsd??"",onChange:i=>a("investmentCommitmentUsd",i.target.valueAsNumber)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"commitmentStatement",children:"Written representation of commitment"}),e.jsx("textarea",{id:"commitmentStatement",className:"cedros-accreditation-wizard__textarea",rows:3,value:s.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Per 2025 SEC guidance, a minimum investment commitment serves as evidence of accredited status."})]})}function vu({onComplete:t,onCancel:s,className:r}){const{submitVerification:o,uploadDocument:n,isLoading:a,error:i}=aa(),[l,c]=d.useState(1),[u,m]=d.useState(null),[h,p]=d.useState({}),[b,w]=d.useState([]),[g,k]=d.useState(!1),[A,j]=d.useState(null),N=y=>{m(y),c(2)},S=()=>{l===2?c(1):l===3?c(2):s?.()},C=d.useCallback(async()=>{if(u){j(null);try{const{submissionId:y}=await o(u,h);for(const x of b)await n(y,x.file,x.documentType);k(!0),t?.(y)}catch(y){j(y instanceof Error?y.message:"Submission failed. Please try again.")}}},[u,h,b,o,n,t]),f=Sn.find(y=>y.method===u);return g?e.jsx("div",{className:`cedros-accreditation-wizard cedros-accreditation-wizard--success ${r??""}`,role:"status",children:e.jsx("p",{className:"cedros-accreditation-wizard__success-message",children:"Submitted for review. You will be notified once your accreditation is verified."})}):e.jsxs("div",{className:`cedros-accreditation-wizard ${r??""}`,children:[e.jsx("div",{className:"cedros-accreditation-wizard__header",children:e.jsx("nav",{className:"cedros-accreditation-wizard__steps","aria-label":"Wizard steps",children:["Choose Method","Fill Details","Review & Submit"].map((y,x)=>e.jsxs("span",{className:`cedros-accreditation-wizard__step${l===x+1?" cedros-accreditation-wizard__step--active":""}`,"aria-current":l===x+1?"step":void 0,children:[x+1,". ",y]},y))})}),l===1&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step1-heading",children:[e.jsx("h2",{id:"step1-heading",className:"cedros-accreditation-wizard__section-title",children:"Choose Verification Method"}),e.jsx("div",{className:"cedros-accreditation-wizard__method-grid",role:"list",children:Sn.map(y=>e.jsxs("button",{type:"button",role:"listitem",className:"cedros-accreditation-wizard__method-card",onClick:()=>N(y.method),children:[e.jsx("span",{className:"cedros-accreditation-wizard__method-title",children:y.label}),e.jsx("span",{className:"cedros-accreditation-wizard__method-desc",children:y.description})]},y.method))}),s&&e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__cancel",onClick:s,children:"Cancel"})]}),l===2&&u&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step2-heading",children:[e.jsx("h2",{id:"step2-heading",className:"cedros-accreditation-wizard__section-title",children:f?.label}),e.jsx(Au,{method:u,formData:h,onFormDataChange:p,fileEntries:b,onFileEntriesChange:w}),e.jsxs("div",{className:"cedros-accreditation-wizard__actions",children:[e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__back",onClick:S,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__next",onClick:()=>c(3),children:"Review"})]})]}),l===3&&u&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step3-heading",children:[e.jsx("h2",{id:"step3-heading",className:"cedros-accreditation-wizard__section-title",children:"Review & Submit"}),e.jsxs("dl",{className:"cedros-accreditation-wizard__review-list",children:[e.jsx("dt",{className:"cedros-accreditation-wizard__review-term",children:"Method"}),e.jsx("dd",{className:"cedros-accreditation-wizard__review-detail",children:f?.label}),Object.entries(h).filter(([,y])=>y!==void 0&&y!==""&&y!==null).map(([y,x])=>e.jsxs("div",{children:[e.jsx("dt",{className:"cedros-accreditation-wizard__review-term",children:y}),e.jsx("dd",{className:"cedros-accreditation-wizard__review-detail",children:String(x)})]},y))]}),b.length>0&&e.jsxs("div",{className:"cedros-accreditation-wizard__review-files",children:[e.jsx("p",{className:"cedros-accreditation-wizard__review-files-heading",children:"Documents to upload:"}),e.jsx("ul",{children:b.map((y,x)=>e.jsxs("li",{children:[y.file.name," ",e.jsxs("span",{className:"cedros-accreditation-wizard__doc-type",children:["(",y.documentType,")"]})]},`${y.file.name}-${x}`))})]}),(i||A)&&e.jsx("div",{className:"cedros-accreditation-wizard__error",role:"alert",children:A??i?.message}),e.jsxs("div",{className:"cedros-accreditation-wizard__actions",children:[e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__back",onClick:S,disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__submit",onClick:C,disabled:a,children:a?"Submitting...":"Submit Verification"})]})]})]})}function ju({status:t,onStartVerification:s,className:r}){if(t==="approved")return null;let o,n=!0;switch(t){case"pending":o="Your accreditation is under review.",n=!1;break;case"rejected":o="Accreditation was not approved. You can resubmit.";break;case"expired":o="Your accreditation has expired. Please verify again.";break;default:o="Accredited investor verification is required.";break}return e.jsx("div",{className:`cedros-accreditation-banner ${r??""}`,role:"alert",children:e.jsxs("div",{className:"cedros-accreditation-banner__content",children:[e.jsx("span",{className:"cedros-accreditation-banner__message",children:o}),n&&s&&e.jsx("button",{type:"button",className:"cedros-accreditation-banner__button",onClick:s,children:t==="rejected"||t==="expired"?"Resubmit Verification":"Start Verification"})]})})}const gr=d.createContext(null),Ut={auth:{email:"Email",password:"Password",confirmPassword:"Confirm Password",name:"Name",optional:"(optional)",createPassword:"Create a password",confirmYourPassword:"Confirm your password",emailPlaceholder:"you@example.com",namePlaceholder:"Your name"},buttons:{signIn:"Sign in",signUp:"Sign up",signOut:"Sign out",createAccount:"Create account",continueWithGoogle:"Continue with Google",continueWithSolana:"Connect Wallet",forgotPassword:"Forgot password?",resetPassword:"Reset password",sendVerification:"Send verification email"},messages:{signingIn:"Signing in...",signingUp:"Signing up...",creatingAccount:"Creating account...",connectingWallet:"Connecting wallet...",verifyingSignature:"Verifying signature...",passwordsDoNotMatch:"Passwords do not match",alreadyHaveAccount:"Already have an account?",dontHaveAccount:"Don't have an account?",orContinueWith:"Or continue with"},errors:{invalidCredentials:"Invalid email or password",emailExists:"An account with this email already exists",invalidEmail:"Please enter a valid email address",weakPassword:"Password does not meet requirements",networkError:"Network error. Please try again.",unknownError:"An error occurred. Please try again.",walletNotFound:"No wallet found. Please install a Solana wallet.",signatureRejected:"Signature request was rejected",challengeExpired:"Challenge expired. Please try again."},passwordValidation:{minLength:"At least 10 characters",uppercase:"At least 1 uppercase letter",lowercase:"At least 1 lowercase letter",number:"At least 1 number",special:"At least 1 special character",weak:"Weak",fair:"Fair",good:"Good",strong:"Strong"}};function ia(t,s){return ca(t,s)}function ca(t,s){const r={...t};for(const o in s)if(Object.prototype.hasOwnProperty.call(s,o)){const n=t[o],a=s[o];typeof n=="object"&&n!==null&&typeof a=="object"&&a!==null?r[o]=ca(n,a):a!==void 0&&(r[o]=a)}return r}function ku({children:t,locale:s="en",translations:r}){const o=d.useMemo(()=>({t:r?ia(Ut,r):Ut,locale:s}),[r,s]);return e.jsx(gr.Provider,{value:o,children:t})}function Nu(){return d.useContext(gr)?.t??Ut}function Su(){return d.useContext(gr)?.locale??"en"}exports.CedrosLoginProvider=U.CedrosLoginProvider;exports.getEmbeddedWalletInfo=U.getEmbeddedWalletInfo;exports.isEmbeddedWalletAvailable=U.isEmbeddedWalletAvailable;exports.useAuth=U.useAuth;exports.useWallet=U.useWallet;exports.useWalletMaterial=U.useWalletMaterial;exports.useAuthState=B.useAuthState;exports.useAuthUI=B.useAuthUI;exports.useCedrosLogin=B.useCedrosLogin;exports.LoadingSpinner=V.LoadingSpinner;exports.EmailLoginForm=Q.EmailLoginForm;exports.EmailRegisterForm=Q.EmailRegisterForm;exports.OtpInput=Q.OtpInput;exports.PasswordInput=Q.PasswordInput;exports.TotpVerify=Q.TotpVerify;exports.useEmailAuth=Q.useEmailAuth;exports.useTotpVerify=Q.useTotpVerify;exports.validatePassword=Oe.validatePassword;exports.ErrorMessage=J.ErrorMessage;exports.GoogleLoginButton=Hs.GoogleLoginButton;exports.useGoogleAuth=Hs.useGoogleAuth;exports.SolanaLoginButton=Ze.SolanaLoginButton;exports.registerMobileWallet=Ze.registerMobileWallet;exports.useSolanaAuth=Ze.useSolanaAuth;exports.InviteForm=de.InviteForm;exports.InviteList=de.InviteList;exports.MemberList=de.MemberList;exports.useInvites=de.useInvites;exports.useMembers=de.useMembers;exports.useServerFeatures=de.useServerFeatures;exports.useSystemSettings=Cn.useSystemSettings;exports.useOrgs=$s.useOrgs;exports.AdminDepositList=Ct.AdminDepositList;exports.AdminDepositStats=Ct.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=Be.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=Be.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=Be.AdminWithdrawalQueue;exports.AdminWithdrawalStats=Be.AdminWithdrawalStats;exports.AdminUserList=lt.AdminUserList;exports.useAdminUsers=lt.useAdminUsers;exports.AdminIcons=Me.Icons;exports.AdminShell=Me.AdminShell;exports.CEDROS_LOGIN_SECTION_IDS=Me.CEDROS_LOGIN_SECTION_IDS;exports.ProfileDropdown=Me.ProfileDropdown;exports.cedrosLoginPlugin=Me.cedrosLoginPlugin;exports.loginPlugin=Me.cedrosLoginPlugin;exports.useAdminShell=Me.useAdminShell;exports.AuthenticationSettings=_n.AuthenticationSettings;exports.EmbeddedWalletSettings=Ln.EmbeddedWalletSettings;exports.EmailSettings=jt.EmailSettings;exports.CreditSystemSettings=Ks.CreditSystemSettings;exports.PrivacyCashSettings=Ks.CreditSystemSettings;exports.ServerSettings=Pn.ServerSettings;exports.useAdminDeposits=pa.useAdminDeposits;exports.SettingsPageLayout=Gs.SettingsPageLayout;exports.WebhookSettings=Gs.WebhookSettings;exports.AccountSettings=id;exports.AccreditationBanner=ju;exports.AccreditationWizard=vu;exports.AdminReferralPayouts=Io;exports.AppleLoginButton=go;exports.CapabilityWarning=Uc;exports.CedrosAdminDashboard=wl;exports.ChooseUsernamePrompt=dd;exports.CompleteAccountPrompt=ld;exports.CreditBalance=Od;exports.DepositFlow=Rd;exports.ErrorBoundary=yo;exports.ForgotPasswordForm=mo;exports.FullPageLayout=tu;exports.History=$d;exports.I18nProvider=ku;exports.KycBanner=pu;exports.KycCallback=yu;exports.LinkedAccounts=Ho;exports.LoginButton=dc;exports.LoginForm=Wt;exports.LoginModal=bc;exports.MfaSetupPrompt=cd;exports.OrgSelector=xc;exports.OrgSwitcher=_c;exports.PasskeyLoginButton=bo;exports.PasskeyPrompt=_o;exports.ProfileTab=zo;exports.RecoveryPhraseDisplay=Ao;exports.RecoveryPhraseInput=vo;exports.ResetPasswordForm=yc;exports.RewardsPanel=fu;exports.SUPPORTED_TOKENS=qt;exports.SecuritySettings=cl;exports.SessionList=xo;exports.SetupWizard=Mo;exports.SplitPageLayout=su;exports.SystemSettings=sl;exports.TieredAmountSlider=hr;exports.TokenSelector=lr;exports.TotpSettings=Oo;exports.TotpSetup=ir;exports.UserProfileSettings=Gl;exports.WalletAddressRow=To;exports.WalletEnrollment=So;exports.WalletManager=tl;exports.WalletRecovery=Ro;exports.WalletStatus=Bo;exports.WalletUnlock=Lo;exports.WithdrawalFlow=Qd;exports.WithdrawalHistory=eu;exports.defaultTranslations=Ut;exports.getTierForAmount=Ot;exports.mergeTranslations=ia;exports.useAccreditation=aa;exports.useAppleAuth=fo;exports.useAuthorize=ru;exports.useCredentials=cr;exports.useCredits=fr;exports.useDeposit=Zo;exports.useInstantLink=ho;exports.useKyc=cu;exports.useLocale=Su;exports.usePasskeySigning=Eo;exports.usePasswordReset=Ft;exports.usePendingRecovery=ou;exports.usePostLogin=iu;exports.useProfile=dt;exports.useReferral=qo;exports.useRewards=oa;exports.useSessions=Qo;exports.useSetPassword=No;exports.useSetup=nr;exports.useTotp=ar;exports.useTransactionSigning=au;exports.useTranslations=Nu;exports.useUsername=Yo;exports.useWalletEnrollment=ko;exports.useWalletRecovery=Po;exports.useWalletSigning=Co;exports.useWallets=nu;exports.useWebAuthn=rr;exports.useWithdrawal=pr;
|