@cedros/login-react 0.0.2 → 0.0.4

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.
Files changed (48) hide show
  1. package/dist/{AuthenticationSettings-CMQhep61.js → AuthenticationSettings-BKvfIsUy.js} +1 -1
  2. package/dist/{AuthenticationSettings-CMQhep61.js.map → AuthenticationSettings-BKvfIsUy.js.map} +1 -1
  3. package/dist/{AuthenticationSettings-Cro76kIC.cjs → AuthenticationSettings-CEVF1qTV.cjs} +1 -1
  4. package/dist/{AuthenticationSettings-Cro76kIC.cjs.map → AuthenticationSettings-CEVF1qTV.cjs.map} +1 -1
  5. package/dist/{CreditSystemSettings-AM7qDk1E.js → CreditSystemSettings-BL7Lx9MI.js} +1 -1
  6. package/dist/{CreditSystemSettings-AM7qDk1E.js.map → CreditSystemSettings-BL7Lx9MI.js.map} +1 -1
  7. package/dist/{CreditSystemSettings-CGR-uzuh.cjs → CreditSystemSettings-CVxamkZ8.cjs} +1 -1
  8. package/dist/{CreditSystemSettings-CGR-uzuh.cjs.map → CreditSystemSettings-CVxamkZ8.cjs.map} +1 -1
  9. package/dist/{DepositsSection-Ct1gjgIg.cjs → DepositsSection-BzlzofEm.cjs} +1 -1
  10. package/dist/{DepositsSection-Ct1gjgIg.cjs.map → DepositsSection-BzlzofEm.cjs.map} +1 -1
  11. package/dist/{DepositsSection-BVNd63B7.js → DepositsSection-b-VfjqkR.js} +1 -1
  12. package/dist/{DepositsSection-BVNd63B7.js.map → DepositsSection-b-VfjqkR.js.map} +1 -1
  13. package/dist/{EmailSettings-DFZ13JbX.cjs → EmailSettings-D2Y_T3ea.cjs} +1 -1
  14. package/dist/{EmailSettings-DFZ13JbX.cjs.map → EmailSettings-D2Y_T3ea.cjs.map} +1 -1
  15. package/dist/{EmailSettings-Di4GSWgb.js → EmailSettings-D4kz8cRX.js} +1 -1
  16. package/dist/{EmailSettings-Di4GSWgb.js.map → EmailSettings-D4kz8cRX.js.map} +1 -1
  17. package/dist/{EmbeddedWalletSettings-Cmn_aVL7.js → EmbeddedWalletSettings-BAAnDY3_.js} +1 -1
  18. package/dist/{EmbeddedWalletSettings-Cmn_aVL7.js.map → EmbeddedWalletSettings-BAAnDY3_.js.map} +1 -1
  19. package/dist/{EmbeddedWalletSettings-DRWeIJKb.cjs → EmbeddedWalletSettings-D8oqefzm.cjs} +1 -1
  20. package/dist/{EmbeddedWalletSettings-DRWeIJKb.cjs.map → EmbeddedWalletSettings-D8oqefzm.cjs.map} +1 -1
  21. package/dist/{ServerSettings-Wg_odW46.js → ServerSettings-BRcS4sht.js} +1 -1
  22. package/dist/{ServerSettings-Wg_odW46.js.map → ServerSettings-BRcS4sht.js.map} +1 -1
  23. package/dist/{ServerSettings-D8w8EpoE.cjs → ServerSettings-Yrumq_CL.cjs} +1 -1
  24. package/dist/{ServerSettings-D8w8EpoE.cjs.map → ServerSettings-Yrumq_CL.cjs.map} +1 -1
  25. package/dist/{TeamSection-DQ4nfUHN.cjs → TeamSection-BgFEYBD7.cjs} +1 -1
  26. package/dist/{TeamSection-DQ4nfUHN.cjs.map → TeamSection-BgFEYBD7.cjs.map} +1 -1
  27. package/dist/{TeamSection-Bj89WSC0.js → TeamSection-Dec3HxDj.js} +1 -1
  28. package/dist/{TeamSection-Bj89WSC0.js.map → TeamSection-Dec3HxDj.js.map} +1 -1
  29. package/dist/{UsersSection-BiZceDV3.cjs → UsersSection-BImSsHRA.cjs} +1 -1
  30. package/dist/{UsersSection-BiZceDV3.cjs.map → UsersSection-BImSsHRA.cjs.map} +1 -1
  31. package/dist/{UsersSection-W19ddPsw.js → UsersSection-D1uLBhoF.js} +1 -1
  32. package/dist/{UsersSection-W19ddPsw.js.map → UsersSection-D1uLBhoF.js.map} +1 -1
  33. package/dist/{WebhookSettings-a1c4iMvr.js → WebhookSettings-BD-PNXDX.js} +1 -1
  34. package/dist/{WebhookSettings-a1c4iMvr.js.map → WebhookSettings-BD-PNXDX.js.map} +1 -1
  35. package/dist/{WebhookSettings-onJWLytD.cjs → WebhookSettings-fOHCAQqx.cjs} +1 -1
  36. package/dist/{WebhookSettings-onJWLytD.cjs.map → WebhookSettings-fOHCAQqx.cjs.map} +1 -1
  37. package/dist/{WithdrawalsSection-BBw9gWMR.js → WithdrawalsSection-CLlPpKHf.js} +1 -1
  38. package/dist/{WithdrawalsSection-BBw9gWMR.js.map → WithdrawalsSection-CLlPpKHf.js.map} +1 -1
  39. package/dist/{WithdrawalsSection-Cws8inf6.cjs → WithdrawalsSection-_7gHudQ8.cjs} +1 -1
  40. package/dist/{WithdrawalsSection-Cws8inf6.cjs.map → WithdrawalsSection-_7gHudQ8.cjs.map} +1 -1
  41. package/dist/{index-BHR_WTP2.js → index-BRvCMGd5.js} +999 -997
  42. package/dist/{index-BHR_WTP2.js.map → index-BRvCMGd5.js.map} +1 -1
  43. package/dist/{index-JsIJkPin.cjs → index-Ca3FT7KM.cjs} +11 -11
  44. package/dist/{index-JsIJkPin.cjs.map → index-Ca3FT7KM.cjs.map} +1 -1
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.js +1 -1
  47. package/dist/login-react.css +1 -1
  48. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- "use strict";const N=require("./ErrorMessage-CntMyn93.cjs"),e=require("react/jsx-runtime"),i=require("react"),X=require("./EmailRegisterForm-B-ys4E3C.cjs"),ns=require("./validation-BeXIfuHB.cjs"),_n=require("./GoogleLoginButton-CJNJ-THo.cjs"),gs=require("./SolanaLoginButton-BlSgPW50.cjs"),le=require("./solanaKeypair-CBQxm2hw.cjs");function Ye(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function or(s,t){return Array.isArray(t)?t.length===0?!0:s?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function En(s){if(typeof s!="function")throw new Error("function expected");return!0}function Je(s,t){if(typeof t!="string")throw new Error(`${s}: string expected`);return!0}function _e(s){if(!Number.isSafeInteger(s))throw new Error(`invalid integer: ${s}`)}function Xe(s){if(!Array.isArray(s))throw new Error("array expected")}function Ze(s,t){if(!or(!0,t))throw new Error(`${s}: array of strings expected`)}function ir(s,t){if(!or(!1,t))throw new Error(`${s}: array of numbers expected`)}function Pn(...s){const t=o=>o,r=(o,c)=>l=>o(c(l)),a=s.map(o=>o.encode).reduceRight(r,t),n=s.map(o=>o.decode).reduce(r,t);return{encode:a,decode:n}}function Tn(s){const t=typeof s=="string"?s.split(""):s,r=t.length;Ze("alphabet",t);const a=new Map(t.map((n,o)=>[n,o]));return{encode:n=>(Xe(n),n.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${s}`);return t[o]})),decode:n=>(Xe(n),n.map(o=>{Je("alphabet.decode",o);const c=a.get(o);if(c===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${s}`);return c}))}}function Ln(s=""){return Je("join",s),{encode:t=>(Ze("join.decode",t),t.join(s)),decode:t=>(Je("join.decode",t),t.split(s))}}function Mn(s,t="="){return _e(s),Je("padding",t),{encode(r){for(Ze("padding.encode",r);r.length*s%8;)r.push(t);return r},decode(r){Ze("padding.decode",r);let a=r.length;if(a*s%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;a>0&&r[a-1]===t;a--)if((a-1)*s%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,a)}}}function zs(s,t,r){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Xe(s),!s.length)return[];let a=0;const n=[],o=Array.from(s,l=>{if(_e(l),l<0||l>=t)throw new Error(`invalid integer: ${l}`);return l}),c=o.length;for(;;){let l=0,d=!0;for(let u=a;u<c;u++){const f=o[u],m=t*l,h=m+f;if(!Number.isSafeInteger(h)||m/t!==l||h-f!==m)throw new Error("convertRadix: carry overflow");const b=h/r;l=h%r;const g=Math.floor(b);if(o[u]=g,!Number.isSafeInteger(g)||g*r+l!==h)throw new Error("convertRadix: carry overflow");if(d)g?d=!1:a=u;else continue}if(n.push(l),d)break}for(let l=0;l<s.length-1&&s[l]===0;l++)n.push(0);return n.reverse()}const lr=(s,t)=>t===0?s:lr(t,s%t),es=(s,t)=>s+(t-lr(s,t)),bs=(()=>{let s=[];for(let t=0;t<40;t++)s.push(2**t);return s})();function Vs(s,t,r,a){if(Xe(s),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(es(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${es(t,r)}`);let n=0,o=0;const c=bs[t],l=bs[r]-1,d=[];for(const u of s){if(_e(u),u>=c)throw new Error(`convertRadix2: invalid data word=${u} from=${t}`);if(n=n<<t|u,o+t>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=r;o-=r)d.push((n>>o-r&l)>>>0);const f=bs[o];if(f===void 0)throw new Error("invalid carry");n&=f-1}if(n=n<<r-o&l,!a&&o>=t)throw new Error("Excess padding");if(!a&&n>0)throw new Error(`Non-zero padding: ${n}`);return a&&o>0&&d.push(n>>>0),d}function Dn(s){_e(s);const t=2**8;return{encode:r=>{if(!Ye(r))throw new Error("radix.encode input should be Uint8Array");return zs(Array.from(r),t,s)},decode:r=>(ir("radix.decode",r),Uint8Array.from(zs(r,s,t)))}}function Rn(s,t=!1){if(_e(s),s<=0||s>32)throw new Error("radix2: bits should be in (0..32]");if(es(8,s)>32||es(s,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Ye(r))throw new Error("radix2.encode input should be Uint8Array");return Vs(Array.from(r),8,s,!t)},decode:r=>(ir("radix2.decode",r),Uint8Array.from(Vs(r,s,8,t)))}}function In(s,t){return _e(s),En(t),{encode(r){if(!Ye(r))throw new Error("checksum.encode: input should be Uint8Array");const a=t(r).slice(0,s),n=new Uint8Array(r.length+s);return n.set(r),n.set(a,r.length),n},decode(r){if(!Ye(r))throw new Error("checksum.decode: input should be Uint8Array");const a=r.slice(0,-s),n=r.slice(-s),o=t(a).slice(0,s);for(let c=0;c<s;c++)if(o[c]!==n[c])throw new Error("Invalid checksum");return a}}}const $e={alphabet:Tn,chain:Pn,checksum:In,convertRadix:zs,convertRadix2:Vs,radix:Dn,radix2:Rn,join:Ln,padding:Mn};const Un=s=>s[0]==="あいこくしん";function Fn(s){if(typeof s!="string")throw new TypeError("invalid mnemonic type: "+typeof s);return s.normalize("NFKD")}function Bn(s){const t=Fn(s),r=t.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:r}}function cr(s){le.abytes(s,16,20,24,28,32)}const On=s=>{const t=8-s.length/4;return new Uint8Array([le.sha256(s)[0]>>t<<t])};function dr(s){if(!Array.isArray(s)||s.length!==2048||typeof s[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return s.forEach(t=>{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),$e.chain($e.checksum(1,On),$e.radix2(11,!0),$e.alphabet(s))}function Qs(s,t){const{words:r}=Bn(s),a=dr(t).decode(r);return cr(a),a}function ur(s,t){return cr(s),dr(t).encode(s).join(Un(t)?" ":" ")}function Ks(s,t){try{Qs(s,t)}catch{return!1}return!0}const me=`abandon
1
+ "use strict";const N=require("./ErrorMessage-CntMyn93.cjs"),e=require("react/jsx-runtime"),i=require("react"),X=require("./EmailRegisterForm-B-ys4E3C.cjs"),ns=require("./validation-BeXIfuHB.cjs"),Cn=require("./GoogleLoginButton-CJNJ-THo.cjs"),gs=require("./SolanaLoginButton-BlSgPW50.cjs"),le=require("./solanaKeypair-CBQxm2hw.cjs");function Ye(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function ar(s,t){return Array.isArray(t)?t.length===0?!0:s?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function _n(s){if(typeof s!="function")throw new Error("function expected");return!0}function Je(s,t){if(typeof t!="string")throw new Error(`${s}: string expected`);return!0}function _e(s){if(!Number.isSafeInteger(s))throw new Error(`invalid integer: ${s}`)}function Xe(s){if(!Array.isArray(s))throw new Error("array expected")}function Ze(s,t){if(!ar(!0,t))throw new Error(`${s}: array of strings expected`)}function or(s,t){if(!ar(!1,t))throw new Error(`${s}: array of numbers expected`)}function En(...s){const t=o=>o,r=(o,c)=>l=>o(c(l)),a=s.map(o=>o.encode).reduceRight(r,t),n=s.map(o=>o.decode).reduce(r,t);return{encode:a,decode:n}}function Pn(s){const t=typeof s=="string"?s.split(""):s,r=t.length;Ze("alphabet",t);const a=new Map(t.map((n,o)=>[n,o]));return{encode:n=>(Xe(n),n.map(o=>{if(!Number.isSafeInteger(o)||o<0||o>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${s}`);return t[o]})),decode:n=>(Xe(n),n.map(o=>{Je("alphabet.decode",o);const c=a.get(o);if(c===void 0)throw new Error(`Unknown letter: "${o}". Allowed: ${s}`);return c}))}}function Tn(s=""){return Je("join",s),{encode:t=>(Ze("join.decode",t),t.join(s)),decode:t=>(Je("join.decode",t),t.split(s))}}function Ln(s,t="="){return _e(s),Je("padding",t),{encode(r){for(Ze("padding.encode",r);r.length*s%8;)r.push(t);return r},decode(r){Ze("padding.decode",r);let a=r.length;if(a*s%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;a>0&&r[a-1]===t;a--)if((a-1)*s%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,a)}}}function zs(s,t,r){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Xe(s),!s.length)return[];let a=0;const n=[],o=Array.from(s,l=>{if(_e(l),l<0||l>=t)throw new Error(`invalid integer: ${l}`);return l}),c=o.length;for(;;){let l=0,d=!0;for(let u=a;u<c;u++){const f=o[u],m=t*l,h=m+f;if(!Number.isSafeInteger(h)||m/t!==l||h-f!==m)throw new Error("convertRadix: carry overflow");const b=h/r;l=h%r;const g=Math.floor(b);if(o[u]=g,!Number.isSafeInteger(g)||g*r+l!==h)throw new Error("convertRadix: carry overflow");if(d)g?d=!1:a=u;else continue}if(n.push(l),d)break}for(let l=0;l<s.length-1&&s[l]===0;l++)n.push(0);return n.reverse()}const ir=(s,t)=>t===0?s:ir(t,s%t),es=(s,t)=>s+(t-ir(s,t)),bs=(()=>{let s=[];for(let t=0;t<40;t++)s.push(2**t);return s})();function Vs(s,t,r,a){if(Xe(s),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(es(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${es(t,r)}`);let n=0,o=0;const c=bs[t],l=bs[r]-1,d=[];for(const u of s){if(_e(u),u>=c)throw new Error(`convertRadix2: invalid data word=${u} from=${t}`);if(n=n<<t|u,o+t>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=r;o-=r)d.push((n>>o-r&l)>>>0);const f=bs[o];if(f===void 0)throw new Error("invalid carry");n&=f-1}if(n=n<<r-o&l,!a&&o>=t)throw new Error("Excess padding");if(!a&&n>0)throw new Error(`Non-zero padding: ${n}`);return a&&o>0&&d.push(n>>>0),d}function Mn(s){_e(s);const t=2**8;return{encode:r=>{if(!Ye(r))throw new Error("radix.encode input should be Uint8Array");return zs(Array.from(r),t,s)},decode:r=>(or("radix.decode",r),Uint8Array.from(zs(r,s,t)))}}function Dn(s,t=!1){if(_e(s),s<=0||s>32)throw new Error("radix2: bits should be in (0..32]");if(es(8,s)>32||es(s,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Ye(r))throw new Error("radix2.encode input should be Uint8Array");return Vs(Array.from(r),8,s,!t)},decode:r=>(or("radix2.decode",r),Uint8Array.from(Vs(r,s,8,t)))}}function Rn(s,t){return _e(s),_n(t),{encode(r){if(!Ye(r))throw new Error("checksum.encode: input should be Uint8Array");const a=t(r).slice(0,s),n=new Uint8Array(r.length+s);return n.set(r),n.set(a,r.length),n},decode(r){if(!Ye(r))throw new Error("checksum.decode: input should be Uint8Array");const a=r.slice(0,-s),n=r.slice(-s),o=t(a).slice(0,s);for(let c=0;c<s;c++)if(o[c]!==n[c])throw new Error("Invalid checksum");return a}}}const $e={alphabet:Pn,chain:En,checksum:Rn,convertRadix:zs,convertRadix2:Vs,radix:Mn,radix2:Dn,join:Tn,padding:Ln};const In=s=>s[0]==="あいこくしん";function Un(s){if(typeof s!="string")throw new TypeError("invalid mnemonic type: "+typeof s);return s.normalize("NFKD")}function Fn(s){const t=Un(s),r=t.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:r}}function lr(s){le.abytes(s,16,20,24,28,32)}const Bn=s=>{const t=8-s.length/4;return new Uint8Array([le.sha256(s)[0]>>t<<t])};function cr(s){if(!Array.isArray(s)||s.length!==2048||typeof s[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return s.forEach(t=>{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),$e.chain($e.checksum(1,Bn),$e.radix2(11,!0),$e.alphabet(s))}function Qs(s,t){const{words:r}=Fn(s),a=cr(t).decode(r);return lr(a),a}function dr(s,t){return lr(s),cr(t).encode(s).join(In(t)?" ":" ")}function Ks(s,t){try{Qs(s,t)}catch{return!1}return!0}const me=`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
- `),oe=12;function qn(s){if(s.length!==16)throw new Error(`Invalid share length: expected 16, got ${s.length}`);const r=ur(s,me).split(" ");if(r.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${r.length}`);return r}function Wn(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Ks(t,me))throw new Error("Invalid recovery phrase: checksum mismatch");const r=Qs(t,me);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return N.toShamirShare(r)}function $n(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const r=ur(s,me).split(" ");if(r.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${r.length}`);return r}function zn(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Ks(t,me))throw new Error("Invalid recovery phrase: checksum mismatch");const r=Qs(t,me);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return N.toSeed(r)}function hr(s){if(s.length!==oe)return!1;const t=s.join(" ").toLowerCase().trim();return Ks(t,me)}function ze(s){return me.includes(s.toLowerCase().trim())}function Vn(s,t=5){const r=s.toLowerCase().trim();return r.length===0?[]:me.filter(a=>a.startsWith(r)).slice(0,t)}function Hn(s){const t=[];for(let r=0;r<s.length;r+=4)t.push(s.slice(r,r+4));return t}function Qn(s){return s.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function Kn({className:s="",variant:t="default",size:r="md",children:a,menuItems:n=[],hideSignOut:o=!1}){const{user:c,isAuthenticated:l,isLoading:d,openLoginModal:u,logout:f}=N.useAuth(),[m,h]=i.useState(!1),[b,g]=i.useState(-1),p=i.useRef(null),x=i.useRef(null),j=i.useMemo(()=>[...n,...o?[]:[{label:"Sign out",onClick:f}]],[n,o,f]);i.useEffect(()=>{if(!m)return;const w=T=>{p.current&&!p.current.contains(T.target)&&(h(!1),g(-1))},C=T=>{T.key==="Escape"&&(h(!1),g(-1),x.current?.focus())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",C)}},[m]);const y=i.useCallback(w=>{if(!(!m||j.length===0))switch(w.key){case"ArrowDown":w.preventDefault(),g(C=>(C+1)%j.length);break;case"ArrowUp":w.preventDefault(),g(C=>(C-1+j.length)%j.length);break;case"Home":w.preventDefault(),g(0);break;case"End":w.preventDefault(),g(j.length-1);break;case"Enter":case" ":b>=0&&(w.preventDefault(),j[b].onClick(),h(!1),g(-1));break}},[m,b,j]),A=i.useCallback(()=>{j.length!==0&&(h(w=>!w),g(-1))},[j.length]),v={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},S={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(d)return e.jsx("button",{type:"button",className:`cedros-button ${S[t]} ${v[r]} ${s}`,disabled:!0,children:e.jsx(N.LoadingSpinner,{size:"sm"})});if(l&&c){const w=c.name||c.email||"User",C=X.sanitizeImageUrl(c.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:p,onKeyDown:y,children:[e.jsxs("button",{ref:x,type:"button",className:`cedros-button cedros-user-button ${v[r]} ${s}`,"aria-haspopup":"menu","aria-expanded":m,"aria-label":`User menu for ${w}`,onClick:A,children:[C?e.jsx("img",{src:C,alt:w,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(w[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:w})]}),m&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[n.map((T,L)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${b===L?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===L?0:-1,onClick:()=>{T.onClick(),h(!1)},children:[T.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:T.icon}),T.label]},L)),n.length>0&&!o&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!o&&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(),h(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${S[t]} ${v[r]} ${s}`,onClick:u,children:a||"Sign in"})}function Gs(){const{config:s}=N.useCedrosLogin(),[t,r]=i.useState(!1),[a,n]=i.useState(!1),[o,c]=i.useState(null),l=i.useMemo(()=>new N.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:d,getRemainingAttempts:u}=X.useRateLimiter({maxAttempts:3,windowMs:3e5}),f=i.useCallback(async g=>{if(!ns.validateEmail(g)){const p={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw c(p),p}try{d()}catch(p){const x={code:"RATE_LIMITED",message:p instanceof Error?p.message:"Too many attempts"};throw c(x),x}r(!0),c(null),n(!1);try{await l.post("/forgot-password",{email:g}),n(!0)}catch(p){const x=N.handleApiError(p,"Failed to send reset email");throw c(x),x}finally{r(!1)}},[l,d]),m=i.useCallback(async(g,p)=>{r(!0),c(null),n(!1);try{await l.post("/reset-password",{token:g,newPassword:p}),n(!0)}catch(x){const j=N.handleApiError(x,"Failed to reset password");throw c(j),j}finally{r(!1)}},[l]),h=i.useCallback(()=>c(null),[]),b=i.useCallback(()=>{c(null),n(!1),r(!1)},[]);return{forgotPassword:f,resetPassword:m,isLoading:t,isSuccess:a,error:o,clearError:h,reset:b,remainingAttempts:u()}}function mr({onSuccess:s,onCancel:t,className:r=""}){const[a,n]=i.useState(""),{forgotPassword:o,isLoading:c,isSuccess:l,error:d,clearError:u}=Gs(),f=i.useId(),m=async h=>{h.preventDefault();try{await o(a),s?.()}catch{}};return l?e.jsxs("div",{className:`cedros-forgot-password-success ${r}`,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.jsxs("p",{className:"cedros-success-message",children:["If an account exists for ",e.jsx("strong",{children:a}),", you will receive a password reset link shortly."]}),t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:t,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${r}`,onSubmit:m,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:"Enter your email address and we'll send you a link to reset your password."})]}),e.jsx(N.ErrorMessage,{error:d,onDismiss:u}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:f,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:f,type:"email",className:"cedros-input",value:a,onChange:h=>n(h.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:c})]}),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:c||!a,children:c?e.jsxs(e.Fragment,{children:[e.jsx(N.LoadingSpinner,{size:"sm"}),"Sending..."]}):"Send reset link"}),t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:t,disabled:c,children:"Back to login"})]})]})}const Gn={loading:!1,loaded:!1,error:null,callbacks:[],load(){return this.loaded?Promise.resolve():this.loading?new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t})}):(this.loading=!0,new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t});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 a=document.createElement("script");a.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",a.async=!0,a.defer=!0,a.id="apple-signin-script",a.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]},a.onerror=()=>{this.loading=!1,a.remove();const n=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(o=>o.reject(n)),this.callbacks=[]},document.head.appendChild(a)}))}};function pr(){const{config:s,_internal:t}=N.useCedrosLogin(),[r,a]=i.useState(!1),[n,o]=i.useState(!1),[c,l]=i.useState(null),d=i.useRef(s),u=i.useMemo(()=>new N.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]);i.useEffect(()=>{d.current=s},[s]),i.useEffect(()=>{if(!s.appleClientId)return;let h=!0;const b=()=>{if(h)try{window.AppleID?.auth?.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),h&&o(!0)}catch{h&&l({code:"SERVER_ERROR",message:"Failed to initialize Apple Sign In"})}};return Gn.load().then(()=>{h&&b()}).catch(()=>{h&&l({code:"SERVER_ERROR",message:"Failed to load Apple Sign In"})}),()=>{h=!1}},[s.appleClientId]);const f=i.useCallback(async()=>{if(!s.appleClientId){const h={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw l(h),h}if(!n){const h={code:"VALIDATION_ERROR",message:"Apple Sign In not initialized"};throw l(h),h}a(!0),l(null);try{const h=await window.AppleID.auth.signIn(),b=h.authorization?.id_token;if(!b)throw new Error("No ID token received from Apple");const g=h.user?.name?`${h.user.name.firstName||""} ${h.user.name.lastName||""}`.trim():void 0,p=await u.post("/apple",{idToken:b,name:g||void 0});return d.current.callbacks?.onLoginSuccess?.(p.user,"apple"),t?.handleLoginSuccess(p.user,p.tokens),a(!1),p}catch(h){if(h.error==="popup_closed_by_user"){const p={code:"SERVER_ERROR",message:"Apple Sign In was cancelled"};throw l(p),a(!1),p}const g=N.handleApiError(h,"Apple sign-in failed");throw l(g),a(!1),g}},[s.appleClientId,n,u,t]),m=i.useCallback(()=>l(null),[]);return{signIn:f,isLoading:r,isInitialized:n,error:c,clearError:m}}function fr(){if(typeof window>"u"||typeof navigator>"u")return!1;const s=navigator.userAgent.toLowerCase(),t=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(s)||t.includes("mac")||/macintosh/.test(s)||t==="macintel"&&navigator.maxTouchPoints>1)}function gr({onSuccess:s,onError:t,className:r="",variant:a="default",size:n="md",disabled:o=!1,hideOnNonApple:c=!0}){const{signIn:l,isLoading:d,isInitialized:u}=pr(),[f]=i.useState(()=>fr());if(c&&!f)return null;const m=async()=>{try{await l(),s?.()}catch(g){const p=g instanceof Error?g:new Error(String(g));t?.(p)}},h={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},b={default:"cedros-button-apple",outline:"cedros-button-apple-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${b[a]} ${h[n]} ${r}`,onClick:m,disabled:o||!u||d,"aria-label":"Sign in with Apple",children:[d?e.jsx(N.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 se(s,t){if(!s)throw new Error(t)}function Yn(s){return s.replace(/-/g,"+").replace(/_/g,"/")}function ss(s){se(typeof s=="string"&&s.length>0,"Expected base64url string");const t=Yn(s),r=t+"=".repeat((4-t.length%4)%4),a=atob(r),n=new Uint8Array(a.length);for(let o=0;o<a.length;o++)n[o]=a.charCodeAt(o);return n.buffer}function je(s){const t=new Uint8Array(s);let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function br(s){se(typeof s=="object"&&s!==null,"Invalid credential descriptor");const t=s;return se(typeof t.type=="string","Invalid credential descriptor type"),se(typeof t.id=="string","Invalid credential descriptor id"),{type:t.type,id:ss(t.id),transports:Array.isArray(t.transports)?t.transports:void 0}}function Jn(s){se(s&&typeof s=="object","Missing creation options");const t=s.publicKey;se(t&&typeof t=="object","Missing creation options.publicKey"),se(typeof t.challenge=="string","Missing creation challenge"),se(typeof t.rp=="object"&&t.rp!==null,"Missing rp"),se(typeof t.user=="object"&&t.user!==null,"Missing user");const r=t.rp,a=t.user;se(typeof r.name=="string","Missing rp.name"),se(typeof a.id=="string","Missing user.id"),se(typeof a.name=="string","Missing user.name"),se(typeof a.displayName=="string","Missing user.displayName");const n=Array.isArray(t.excludeCredentials)?t.excludeCredentials.map(br):void 0,o=Array.isArray(t.pubKeyCredParams)?t.pubKeyCredParams.map(c=>({type:c.type,alg:c.alg})):[];return{challenge:ss(t.challenge),rp:{name:r.name,id:typeof r.id=="string"?r.id:void 0},user:{id:ss(a.id),name:a.name,displayName:a.displayName},pubKeyCredParams:o,timeout:typeof t.timeout=="number"?t.timeout:void 0,attestation:typeof t.attestation=="string"?t.attestation:void 0,authenticatorSelection:typeof t.authenticatorSelection=="object"&&t.authenticatorSelection!==null?t.authenticatorSelection:void 0,excludeCredentials:n,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0}}function Xn(s){se(s&&typeof s=="object","Missing request options");const t=s.publicKey;se(t&&typeof t=="object","Missing request options.publicKey"),se(typeof t.challenge=="string","Missing request challenge");const r=Array.isArray(t.allowCredentials)?t.allowCredentials.map(br):void 0;return{challenge:ss(t.challenge),rpId:typeof t.rpId=="string"?t.rpId:void 0,timeout:typeof t.timeout=="number"?t.timeout:void 0,userVerification:typeof t.userVerification=="string"?t.userVerification:void 0,allowCredentials:r,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0}}function ut(s){const t=je(s.rawId),r=s.response,n={...{clientDataJSON:je(r.clientDataJSON)}};if("attestationObject"in r){const o=r;if(n.attestationObject=je(o.attestationObject),typeof o.getTransports=="function")try{n.transports=o.getTransports()}catch{}}if("authenticatorData"in r){const o=r;n.authenticatorData=je(o.authenticatorData),n.signature=je(o.signature),o.userHandle&&(n.userHandle=je(o.userHandle))}return{id:s.id,rawId:t,type:s.type,authenticatorAttachment:s.authenticatorAttachment??void 0,clientExtensionResults:s.getClientExtensionResults?.()??{},response:n}}function Zn(){if(typeof window<"u"){const s=window.location?.hostname,t=s==="localhost"||s==="127.0.0.1"||s?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!t)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function ht(s){if(!(s instanceof Error))return null;const t=s.name;return t==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:t==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:t==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function yr(){const{config:s,_internal:t}=N.useCedrosLogin(),[r,a]=i.useState(!1),[n,o]=i.useState(null),c=i.useMemo(()=>new N.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[t?.getAccessToken,s.serverUrl,s.requestTimeout,s.retryAttempts]),l=i.useCallback(()=>o(null),[]),d=Zn(),u=i.useCallback(async m=>{if(!d){const h={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw o(h),h}a(!0),o(null);try{const h=await c.post("/webauthn/auth/options",{email:m?.email}),b=Xn(h.options),g=await navigator.credentials.get({publicKey:b});if(!g)throw new Error("Passkey authentication returned no credential");const p=await c.post("/webauthn/auth/verify",{challengeId:h.challengeId,credential:ut(g)});return s.callbacks?.onLoginSuccess?.(p.user,"webauthn"),t?.handleLoginSuccess(p.user,p.tokens),p}catch(h){const g=ht(h)??N.handleApiError(h,"Passkey sign-in failed");throw o(g),g}finally{a(!1)}},[c,s.callbacks,t,d]),f=i.useCallback(async m=>{if(!d){const h={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw o(h),h}a(!0),o(null);try{const h=await c.post("/webauthn/register/options",{}),b=Jn(h.options),g=await navigator.credentials.create({publicKey:b});if(!g)throw new Error("Passkey registration returned no credential");const p=await c.post("/webauthn/register/verify",{challengeId:h.challengeId,credential:ut(g),label:m?.label});if(!p.success)throw new Error("Passkey registration failed");return{credentialId:p.credentialId,label:p.label}}catch(h){const g=ht(h)??N.handleApiError(h,"Passkey registration failed");throw o(g),g}finally{a(!1)}},[c,d]);return{isSupported:d,isLoading:r,error:n,clearError:l,authenticatePasskey:u,registerPasskey:f}}function wr({onSuccess:s,className:t="",children:r,disabled:a}){const{authenticatePasskey:n,isLoading:o,isSupported:c}=yr(),l=a||!c||o;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${t}`,onClick:async()=>{await n(),s?.()},disabled:l,"aria-disabled":l,children:[e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(ea,{})}),e.jsx("span",{children:r??(o?"Continuing...":"Continue with Passkey")})]})}function ea(){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 Re=["login","register"];function as({onSuccess:s,className:t="",defaultTab:r="login"}){const{config:a}=N.useCedrosLogin(),[n,o]=i.useState(r),[c,l]=i.useState("form"),[d,u]=i.useState(()=>gs.detectSolanaWallets()),[f]=i.useState(()=>fr());i.useEffect(()=>{const v=()=>u(gs.detectSolanaWallets());return v(),window.addEventListener("load",v),window.addEventListener("focus",v),()=>{window.removeEventListener("load",v),window.removeEventListener("focus",v)}},[]);const m=a.forms?.forgotPassword?.mode??"reset",h=i.useCallback(v=>{const S=Re.indexOf(n);let w=S;switch(v.key){case"ArrowLeft":case"ArrowUp":w=S===0?Re.length-1:S-1;break;case"ArrowRight":case"ArrowDown":w=S===Re.length-1?0:S+1;break;case"Home":w=0;break;case"End":w=Re.length-1;break;default:return}v.preventDefault();const C=Re[w];o(C),document.getElementById(`cedros-tab-${C}`)?.focus()},[n]),b=a.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},g=b.email!==!1,p=b.google!==!1&&a.googleClientId,x=b.apple!==!1&&a.appleClientId&&f,j=b.solana!==!1&&d,y=b.webauthn!==!1,A=g&&(p||x||j||y);return c==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${t}`,children:e.jsx(mr,{onCancel:()=>l("form")})}):e.jsxs("div",{className:`cedros-login-form ${t}`,children:[(y||p||x||j)&&e.jsxs("div",{className:"cedros-social-buttons",children:[y&&e.jsx(wr,{onSuccess:s}),p&&e.jsx(_n.GoogleLoginButton,{onSuccess:s}),x&&e.jsx(gr,{onSuccess:s}),j&&e.jsx(gs.SolanaLoginButton,{onSuccess:s})]}),A&&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 ${n==="login"?"cedros-tab-active":""}`,onClick:()=>o("login"),onKeyDown:h,"aria-selected":n==="login","aria-controls":"cedros-tabpanel-login",tabIndex:n==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${n==="register"?"cedros-tab-active":""}`,onClick:()=>o("register"),onKeyDown:h,"aria-selected":n==="register","aria-controls":"cedros-tabpanel-register",tabIndex:n==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${n}`,"aria-labelledby":`cedros-tab-${n}`,children:n==="login"?e.jsx(X.EmailLoginForm,{onSuccess:s,onSwitchToRegister:()=>o("register"),onForgotPassword:m==="reset"?()=>l("forgotPassword"):void 0}):e.jsx(X.EmailRegisterForm,{onSuccess:s,onSwitchToLogin:()=>o("login")})})]})]})}class xr extends i.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){this.setState({errorInfo:r}),process.env.NODE_ENV==="development"&&(console.error("[Cedros Login] Error caught by ErrorBoundary:",t),console.error("[Cedros Login] Component stack:",r.componentStack)),this.props.onError?.(t,r)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:t,error:r,errorInfo:a}=this.state,{children:n,fallback:o,showDetails:c=!1}=this.props;return t?o||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."}),c&&r&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[r.toString(),a?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):n}}function sa({className:s="",title:t="Sign in to your account"}){const{isModalOpen:r,closeModal:a}=N.useCedrosLogin(),n=i.useRef(null),o=i.useRef(null),c=i.useRef(a);if(i.useEffect(()=>{c.current=a},[a]),i.useEffect(()=>{if(!r)return;o.current=document.activeElement,n.current?.focus();const d=f=>{if(f.key==="Escape"&&c.current(),f.key==="Tab"&&n.current){const m=n.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),h=m[0],b=m[m.length-1];f.shiftKey&&document.activeElement===h?(f.preventDefault(),b?.focus()):!f.shiftKey&&document.activeElement===b&&(f.preventDefault(),h?.focus())}};document.addEventListener("keydown",d);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",d),document.body.style.overflow=u,o.current instanceof HTMLElement&&o.current.focus()}},[r]),!r)return null;const l=d=>{d.target===d.currentTarget&&a()};return e.jsx("div",{className:`cedros-modal-backdrop ${s}`,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:t}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:a,"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(xr,{children:e.jsx(as,{onSuccess:a})})})]})})}function ta({token:s,onSuccess:t,onLoginClick:r,className:a=""}){const[n,o]=i.useState(""),[c,l]=i.useState(""),[d,u]=i.useState(null),{resetPassword:f,isLoading:m,isSuccess:h,error:b,clearError:g}=Gs(),p=n===c,x=d?.isValid&&p&&n.length>0,j=async y=>{if(y.preventDefault(),!!x)try{await f(s,n),t?.()}catch{}};return h?e.jsxs("div",{className:`cedros-reset-password-success ${a}`,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 ${a}`,onSubmit:j,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(N.ErrorMessage,{error:b,onDismiss:g}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(X.PasswordInput,{label:"New password",value:n,onChange:y=>{o(y.target.value),u(ns.validatePassword(y.target.value))},showStrengthMeter:!0,onValidationChange:u,disabled:m,autoComplete:"new-password",error:d&&!d.isValid?Object.values(d.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(X.PasswordInput,{label:"Confirm password",value:c,onChange:y=>l(y.target.value),disabled:m,autoComplete:"new-password",error:c&&!p?"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:m||!x,children:m?e.jsxs(e.Fragment,{children:[e.jsx(N.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:m,children:"Back to login"})]})]})}function Hs({org:s,size:t="lg",className:r=""}){const a=X.sanitizeImageUrl(s.logoUrl),n=t==="lg"?"cedros-org-avatar-lg":"",o=["cedros-org-avatar",n,r].filter(Boolean).join(" "),c=["cedros-org-avatar-placeholder",n,r].filter(Boolean).join(" ");return a?e.jsx("img",{src:a,alt:s.name,className:o,referrerPolicy:"no-referrer"}):e.jsx("div",{className:c,children:s.name[0]?.toUpperCase()||"?"})}function ra({orgs:s,activeOrg:t,isLoading:r=!1,onSelect:a,onCreateClick:n,className:o="",placeholder:c="Select organization"}){const[l,d]=i.useState(!1),u=i.useRef(null);i.useEffect(()=>{const b=g=>{u.current&&!u.current.contains(g.target)&&d(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]),i.useEffect(()=>{const b=g=>{g.key==="Escape"&&d(!1)};if(l)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[l]);const f=i.useCallback(b=>{a(b),d(!1)},[a]),m=i.useCallback(()=>{d(!1),n?.()},[n]),h=i.useCallback(()=>{d(b=>!b)},[]);return r?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${o}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(N.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:u,className:`cedros-org-selector ${o}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:h,"aria-haspopup":"listbox","aria-expanded":l,children:[t?e.jsxs(e.Fragment,{children:[e.jsx(Hs,{org:t,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:t.name}),e.jsx(mt,{role:t.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:c}),e.jsx(na,{isOpen:l})]}),l&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[s.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:s.map(b=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${b.id===t?.id?"cedros-org-selector-item-active":""}`,onClick:()=>f(b.id),role:"option","aria-selected":b.id===t?.id,children:[e.jsx(Hs,{org:b,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:b.name}),e.jsx(mt,{role:b.membership.role}),b.id===t?.id&&e.jsx(aa,{})]})},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:m,children:[e.jsx(oa,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function mt({role:s}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${s}`,children:s})}function na({isOpen:s}){return e.jsx("svg",{className:`cedros-org-chevron ${s?"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 aa(){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 oa(){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 ia(){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 la(){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 ca(){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 da({orgs:s,activeOrg:t,isLoading:r,onSelect:a,onCreateClick:n}){return r?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[s.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:s.map(o=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${o.id===t?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>a(o.id),children:[e.jsx(Hs,{org:o}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:o.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",o.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${o.membership.role}`,children:o.membership.role}),o.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),o.id===t?.id&&e.jsx(la,{})]})},o.id))}),n&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:n,children:[e.jsx(ca,{}),e.jsx("span",{children:"Create new organization"})]})]})}function ua({isLoading:s,onSubmit:t,onCancel:r}){const[a,n]=i.useState(""),[o,c]=i.useState(""),[l,d]=i.useState(null),u=i.useCallback(m=>{n(m);const h=m.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);c(h)},[]),f=i.useCallback(async m=>{if(m.preventDefault(),d(null),!a.trim()){d("Organization name is required");return}if(!o.trim()){d("Organization slug is required");return}try{await t({name:a.trim(),slug:o.trim()})}catch(h){d(h.message||"Failed to create organization")}},[a,o,t]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:f,children:[l&&e.jsx(N.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:a,onChange:m=>u(m.target.value),placeholder:"My Organization",maxLength:255,disabled:s,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:o,onChange:m=>c(m.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:s})]}),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:s,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:s||!a.trim()||!o.trim(),children:s?e.jsx(N.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function ha({isOpen:s,onClose:t,orgs:r,activeOrg:a,isLoading:n=!1,error:o,onSelect:c,onCreate:l,className:d=""}){return s?e.jsx(ma,{onClose:t,orgs:r,activeOrg:a,isLoading:n,error:o,onSelect:c,onCreate:l,className:d}):null}function ma({onClose:s,orgs:t,activeOrg:r,isLoading:a=!1,error:n,onSelect:o,onCreate:c,className:l}){const[d,u]=i.useState("list"),f=i.useRef(null),m=i.useRef(null);i.useEffect(()=>(m.current=document.activeElement,f.current?.querySelector(".cedros-modal-close")?.focus(),()=>{m.current?.focus()}),[]),i.useEffect(()=>{const p=x=>{if(x.key==="Escape"){s();return}if(x.key==="Tab"&&f.current){const j=f.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),y=j[0],A=j[j.length-1];x.shiftKey?document.activeElement===y&&(x.preventDefault(),A?.focus()):document.activeElement===A&&(x.preventDefault(),y?.focus())}};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[s]);const h=i.useCallback(p=>{p.target===p.currentTarget&&s()},[s]),b=i.useCallback(p=>{o(p),s()},[o,s]),g=i.useCallback(async p=>{await c?.(p),s()},[c,s]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:h,children:e.jsxs("div",{ref:f,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:d==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:s,"aria-label":"Close",children:e.jsx(ia,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[n&&e.jsx(N.ErrorMessage,{error:n}),d==="list"?e.jsx(da,{orgs:t,activeOrg:r,isLoading:a,onSelect:b,onCreateClick:c?()=>u("create"):void 0}):e.jsx(ua,{isLoading:a,onSubmit:g,onCancel:()=>u("list")})]})]})})}const pa=["owner","admin","member"];function vr({members:s,currentUserId:t,isLoading:r=!1,error:a,canManage:n=!1,canChangeRoles:o=!1,onUpdateRole:c,onRemove:l,className:d=""}){const[u,f]=i.useState("name"),[m,h]=i.useState("asc"),b=p=>{u===p?h(m==="asc"?"desc":"asc"):(f(p),h("asc"))},g=i.useMemo(()=>{const p={owner:0,admin:1,member:2};return[...s].sort((x,j)=>{let y,A;switch(u){case"name":y=(x.user.name||x.user.email||"").toLowerCase(),A=(j.user.name||j.user.email||"").toLowerCase();break;case"role":y=p[x.role]??99,A=p[j.role]??99;break;case"joinedAt":y=new Date(x.joinedAt).getTime(),A=new Date(j.joinedAt).getTime();break;default:return 0}return y<A?m==="asc"?-1:1:y>A?m==="asc"?1:-1:0})},[s,u,m]);return r&&s.length===0?e.jsxs("div",{className:`cedros-member-list cedros-member-list-loading ${d}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading members..."})]}):a?e.jsx("div",{className:`cedros-member-list ${d}`,children:e.jsx(N.ErrorMessage,{error:a})}):s.length===0?e.jsx("div",{className:`cedros-member-list cedros-member-list-empty ${d}`,children:e.jsx("p",{children:"No members found."})}):e.jsx("div",{className:`cedros-member-list ${d}`,children:e.jsxs("table",{className:"cedros-member-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${u==="name"?"cedros-admin-sort-active":""}`,onClick:()=>b("name"),children:["Member"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:u==="name"?m==="asc"?"↑":"↓":"↕"})]})}),e.jsx("th",{children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${u==="role"?"cedros-admin-sort-active":""}`,onClick:()=>b("role"),children:["Role"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:u==="role"?m==="asc"?"↑":"↓":"↕"})]})}),e.jsx("th",{children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${u==="joinedAt"?"cedros-admin-sort-active":""}`,onClick:()=>b("joinedAt"),children:["Joined"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:u==="joinedAt"?m==="asc"?"↑":"↓":"↕"})]})}),(n||o)&&e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:g.map(p=>e.jsx(fa,{member:p,isCurrentUser:p.userId===t,canManage:n,canChangeRoles:o,onUpdateRole:c,onRemove:l},p.id))})]})})}function fa({member:s,isCurrentUser:t,canManage:r,canChangeRoles:a,onUpdateRole:n,onRemove:o}){const[c,l]=i.useState(!1),[d,u]=i.useState(s.role),f=i.useCallback(async g=>{if(!(!n||g===s.role)){l(!0);try{await n(s.userId,g),u(g)}catch{u(s.role)}finally{l(!1)}}},[s.userId,s.role,n]),m=i.useCallback(async()=>{if(!(!o||!window.confirm(`Are you sure you want to remove ${s.user.name||s.user.email} from this organization?`))){l(!0);try{await o(s.userId)}finally{l(!1)}}},[s.userId,s.user.name,s.user.email,o]),h=s.role==="owner",b=!t&&!h;return e.jsxs("tr",{className:`cedros-member-row ${t?"cedros-member-row-current":""}`,children:[e.jsxs("td",{className:"cedros-member-info",children:[e.jsx(ga,{user:s.user}),e.jsxs("div",{className:"cedros-member-details",children:[e.jsxs("span",{className:"cedros-member-name",children:[s.user.name||"Unknown",t&&e.jsx("span",{className:"cedros-member-you",children:"(you)"})]}),e.jsx("span",{className:"cedros-member-email",children:s.user.email})]})]}),e.jsx("td",{className:"cedros-member-role",children:a&&b&&n?e.jsx("select",{value:d,onChange:g=>f(g.target.value),disabled:c,className:"cedros-role-select",children:pa.map(g=>e.jsx("option",{value:g,children:g.charAt(0).toUpperCase()+g.slice(1)},g))}):e.jsx("span",{className:`cedros-role-badge cedros-role-badge-${s.role}`,children:s.role.charAt(0).toUpperCase()+s.role.slice(1)})}),e.jsx("td",{className:"cedros-member-joined",children:ba(s.joinedAt)}),(r||a)&&e.jsx("td",{className:"cedros-member-actions",children:r&&b&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:m,disabled:c,"aria-label":`Remove ${s.user.name||s.user.email}`,children:c?e.jsx(N.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function ga({user:s}){const t=X.sanitizeImageUrl(s.picture);if(t)return e.jsx("img",{src:t,alt:s.name||s.email||"Member",className:"cedros-member-avatar",referrerPolicy:"no-referrer"});const r=(s.name?.[0]||s.email?.[0]||"?").toUpperCase();return e.jsx("div",{className:"cedros-member-avatar-placeholder",children:r})}function ba(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const ya=["admin","member"];function jr({onSubmit:s,isLoading:t=!1,error:r,availableRoles:a=ya,defaultRole:n="member",className:o=""}){const[c,l]=i.useState(""),[d,u]=i.useState(n),[f,m]=i.useState(null),[h,b]=i.useState(!1),g=i.useRef(null),p=i.useRef(!0);i.useEffect(()=>(p.current=!0,()=>{p.current=!1,g.current!==null&&(window.clearTimeout(g.current),g.current=null)}),[]);const x=i.useCallback(async j=>{j.preventDefault(),m(null),b(!1);const y=c.trim();if(!y){m("Email is required");return}if(!ns.validateEmail(y)){m("Please enter a valid email address");return}try{await s(y,d),l(""),u(n),b(!0),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{p.current&&b(!1),g.current=null},3e3)}catch{}},[c,d,n,s]);return e.jsxs("form",{className:`cedros-invite-form ${o}`,onSubmit:x,children:[(r||f)&&e.jsx(N.ErrorMessage,{error:f??r??null}),h&&e.jsxs("div",{className:"cedros-invite-success",role:"status",children:[e.jsx(wa,{}),e.jsx("span",{children:"Invitation sent successfully!"})]}),e.jsxs("div",{className:"cedros-invite-form-row",children:[e.jsxs("div",{className:"cedros-form-group cedros-invite-email-group",children:[e.jsx("label",{htmlFor:"invite-email",className:"cedros-form-label",children:"Email Address"}),e.jsx("input",{id:"invite-email",type:"email",className:"cedros-form-input",value:c,onChange:j=>l(j.target.value),placeholder:"colleague@example.com",disabled:t,autoComplete:"email"})]}),e.jsxs("div",{className:"cedros-form-group cedros-invite-role-group",children:[e.jsx("label",{htmlFor:"invite-role",className:"cedros-form-label",children:"Role"}),e.jsx("select",{id:"invite-role",className:"cedros-form-select",value:d,onChange:j=>u(j.target.value),disabled:t,children:a.map(j=>e.jsx("option",{value:j,children:j.charAt(0).toUpperCase()+j.slice(1)},j))})]}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary cedros-invite-submit",disabled:t||!c.trim(),children:t?e.jsx(N.LoadingSpinner,{size:"sm"}):"Send Invite"})]}),e.jsx("p",{className:"cedros-form-hint",children:"The invited user will receive an email with a link to join your organization."})]})}function wa(){return e.jsx("svg",{className:"cedros-invite-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 Ar({invites:s,isLoading:t=!1,error:r,canManage:a=!1,onCancel:n,onResend:o,className:c=""}){return t&&s.length===0?e.jsxs("div",{className:`cedros-invite-list cedros-invite-list-loading ${c}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading invites..."})]}):r?e.jsx("div",{className:`cedros-invite-list ${c}`,children:e.jsx(N.ErrorMessage,{error:r})}):s.length===0?e.jsx("div",{className:`cedros-invite-list cedros-invite-list-empty ${c}`,children:e.jsx("p",{children:"No pending invites."})}):e.jsx("div",{className:`cedros-invite-list ${c}`,children:e.jsx("ul",{className:"cedros-invite-items",children:s.map(l=>e.jsx(xa,{invite:l,canManage:a,onCancel:n,onResend:o},l.id))})})}function xa({invite:s,canManage:t,onCancel:r,onResend:a}){const[n,o]=i.useState(!1),[c,l]=i.useState(!1),d=i.useRef(null),u=new Date(s.expiresAt)<new Date,f=i.useCallback(async()=>{if(!(!r||!window.confirm(`Are you sure you want to cancel the invite for ${s.email}?`))){o(!0);try{await r(s.id)}finally{o(!1)}}},[s.id,s.email,r]),m=i.useCallback(async()=>{if(a){o(!0),l(!1);try{await a(s.id),l(!0),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{l(!1),d.current=null},3e3)}finally{o(!1)}}},[s.id,a]);return i.useEffect(()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},[]),e.jsxs("li",{className:`cedros-invite-item ${u?"cedros-invite-item-expired":""}`,children:[e.jsxs("div",{className:"cedros-invite-item-info",children:[e.jsxs("div",{className:"cedros-invite-item-main",children:[e.jsx("span",{className:"cedros-invite-item-email",children:s.email}),e.jsx("span",{className:`cedros-role-badge cedros-role-badge-${s.role}`,children:s.role.charAt(0).toUpperCase()+s.role.slice(1)}),u&&e.jsx("span",{className:"cedros-invite-expired-badge",children:"Expired"})]}),e.jsxs("div",{className:"cedros-invite-item-meta",children:[e.jsxs("span",{className:"cedros-invite-item-date",children:["Invited ",kr(s.createdAt)]}),!u&&e.jsxs("span",{className:"cedros-invite-item-expires",children:["Expires ",va(s.expiresAt)]})]})]}),t&&e.jsxs("div",{className:"cedros-invite-item-actions",children:[c&&e.jsx("span",{className:"cedros-invite-resend-success",children:"Sent!"}),a&&!u&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:m,disabled:n,"aria-label":`Resend invite to ${s.email}`,children:n?e.jsx(N.LoadingSpinner,{size:"sm"}):"Resend"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:f,disabled:n,"aria-label":`Cancel invite for ${s.email}`,children:"Cancel"})]})]})}function kr(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function va(s){const t=new Date(s),r=new Date,a=t.getTime()-r.getTime(),n=Math.ceil(a/(1e3*60*60*24));return n<0?"expired":n===0?"today":n===1?"tomorrow":n<7?`in ${n} days`:kr(s)}function ja({sessions:s,isLoading:t=!1,error:r,onRevokeAll:a,className:n=""}){const[o,c]=i.useState(!1),[l,d]=i.useState(!1),u=i.useRef(null),f=i.useMemo(()=>s.filter(h=>!h.isCurrent).length,[s]),m=i.useCallback(async()=>{if(!a)return;const h=s.filter(g=>!g.isCurrent).length;if(!(h===0||!window.confirm(`Are you sure you want to sign out of ${h} other device(s)? This will log you out everywhere except this browser.`))){c(!0),d(!1);try{await a(),d(!0),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{d(!1),u.current=null},3e3)}finally{c(!1)}}},[a,s]);return i.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),t&&s.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${n}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):r?e.jsx("div",{className:`cedros-session-list ${n}`,children:e.jsx(N.ErrorMessage,{error:r})}):s.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(_a,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:s.map(h=>e.jsx(Aa,{session:h},h.id))}),a&&f>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:m,disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(N.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${f} other device${f>1?"s":""}`})})]})}function Aa({session:s}){const t=ka(s.userAgent),r=Sa(s.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${s.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(Ca,{userAgent:s.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:[t.browser," on ",t.os]}),s.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[s.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",s.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",Na(s.createdAt)]}),r&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function ka(s){if(!s)return{browser:"Unknown browser",os:"Unknown device"};let t="Unknown browser";s.includes("Chrome")&&!s.includes("Edg")?t="Chrome":s.includes("Safari")&&!s.includes("Chrome")?t="Safari":s.includes("Firefox")?t="Firefox":s.includes("Edg")&&(t="Edge");let r="Unknown device";return s.includes("Windows")?r="Windows":s.includes("Mac")?r="macOS":s.includes("Linux")?r="Linux":s.includes("iPhone")||s.includes("iPad")?r="iOS":s.includes("Android")&&(r="Android"),{browser:t,os:r}}function Na(s){const t=new Date(s),a=new Date().getTime()-t.getTime(),n=Math.floor(a/(1e3*60)),o=Math.floor(a/(1e3*60*60)),c=Math.floor(a/(1e3*60*60*24));return n<1?"just now":n<60?`${n} minute${n>1?"s":""} ago`:o<24?`${o} hour${o>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Sa(s){const t=new Date(s),r=new Date,a=3600*1e3;return t.getTime()-r.getTime()<a}function Ca({userAgent:s}){return s?.includes("iPhone")||s?.includes("iPad")||s?.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 _a(){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 Nr({words:s,onConfirm:t,className:r=""}){const[a,n]=i.useState(!1),[o,c]=i.useState(!1),l=i.useRef(null),d=Hn(s),u=i.useCallback(async()=>{try{await navigator.clipboard.writeText(s.join(" ")),n(!0),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>n(!1),2e3)}catch{}},[s]);i.useEffect(()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},[]);const f=i.useCallback(()=>{o&&t()},[o,t]);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:d.map((m,h)=>e.jsx("div",{className:"cedros-word-group",children:m.map((b,g)=>{const p=h*4+g+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[p,"."]}),e.jsx("span",{className:"cedros-word-text",children:b})]},p)})},h))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:u,children:a?"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:o,onChange:m=>c(m.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:!o,children:"Continue"})]})]})}function Sr({onSubmit:s,onCancel:t,isSubmitting:r=!1,error:a,className:n=""}){const[o,c]=i.useState(Array(oe).fill("")),[l,d]=i.useState(null),[u,f]=i.useState([]),[m,h]=i.useState(null),b=i.useId(),g=i.useRef(null),p=i.useCallback((w,C)=>{const T=[...o];if(T[w]=C.toLowerCase().trim(),c(T),C.length>0){const L=Vn(C,5);f(L)}else f([]);h(null)},[o]),x=i.useCallback(w=>{d(w),f([])},[]),j=i.useCallback(w=>{const C=o[w];C&&!ze(C)&&h(`Word ${w+1} is not in the wordlist`),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{l===w&&f([])},200)},[o,l]);i.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]);const y=i.useCallback(w=>{if(l!==null){const C=[...o];C[l]=w,c(C),f([]),document.querySelector(`[data-word-index="${l+1}"]`)?.focus()}},[l,o]),A=i.useCallback(w=>{const C=w.clipboardData.getData("text"),T=Qn(C);T.length===oe&&(w.preventDefault(),c(T),h(null))},[]),v=i.useCallback(w=>{if(w.preventDefault(),o.filter(L=>!L).length>0){h(`Please enter all ${oe} words`);return}const T=o.map((L,E)=>({word:L,index:E+1})).filter(({word:L})=>!ze(L));if(T.length>0){h(`Invalid words: ${T.map(L=>`#${L.index}`).join(", ")}`);return}if(!hr(o)){h("Invalid recovery phrase - please check your words");return}s(o)},[o,s]),S=a||m;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${n}`,onSubmit:v,onPaste:A,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:oe},(w,C)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[C+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${o[C]&&!ze(o[C])?"cedros-word-invalid":o[C]&&ze(o[C])?"cedros-word-valid":""}`,value:o[C],onChange:T=>p(C,T.target.value),onFocus:()=>x(C),onBlur:()=>j(C),"data-word-index":C,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:r,"aria-label":`Word ${C+1}`})]},C))}),l!==null&&u.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${b}-suggestions`,children:u.map(w=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>y(w),role:"option",children:w},w))}),S&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:S}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:t,disabled:r,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:r,children:r?"Recovering...":"Recover Wallet"})]})]})}function Ea({capabilities:s,className:t=""}){if(s.allSupported)return null;const r=N.getMissingCapabilitiesMessage(s),a=N.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${t}`,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: ",a.browser," ",a.version,a.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:s.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",s.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:s.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",s.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:s.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",s.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",s.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",s.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:s.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",s.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 Pa=["share_c_only","full_seed","none"];function Ta(s){return s&&Pa.includes(s)?s:"share_c_only"}const La={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function Cr(){const s=N.useCedrosLoginOptional(),[t,r]=i.useState(null),[a,n]=i.useState(!!s),[o,c]=i.useState(null),l=i.useMemo(()=>s?new N.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts}):null,[s]),d=i.useCallback(async()=>{if(l){n(!0),c(null);try{const u=await l.get("/discovery");u.wallet?r({enabled:u.wallet.enabled,recoveryMode:Ta(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";c(f),r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{n(!1)}}},[l]);return i.useEffect(()=>{l&&d()},[l,d]),s?{walletEnabled:t?.enabled??!1,recoveryMode:t?.recoveryMode??"share_c_only",unlockTtlSeconds:t?.unlockTtlSeconds??900,isLoading:a,error:o,refetch:d}:La}function _r(){const{user:s}=N.useCedrosLogin(),{enroll:t}=N.useWalletMaterial(),{recoveryMode:r}=Cr(),[a,n]=i.useState({step:"idle"}),[o,c]=i.useState(!1),l=i.useRef([]),d=i.useCallback(()=>{N.wipeAll(...l.current),l.current=[]},[]);i.useEffect(()=>()=>{d()},[d]);const u=i.useCallback(async(g,p,x,j)=>{n({step:"generating_seed"});const y=N.generateSeed();l.current.push(y),n({step:"splitting_shares"});const{shareA:A,shareB:v,shareC:S}=le.splitSecret(y);l.current.push(A,v,S),n({step:"encrypting_shares"});const w=await N.aesGcmEncryptToBase64(A,N.toEncryptionKey(p)),C=le.getPublicKeyFromSeed(y),T=le.publicKeyToBase58(C);n({step:"uploading"});const L={solanaPubkey:T,shareAAuthMethod:g,shareACiphertext:w.ciphertext,shareANonce:w.nonce,shareB:N.uint8ArrayToBase64(v)};if(g==="password"){if(!x)throw new Error("KDF salt required for password method");L.shareAKdfSalt=N.uint8ArrayToBase64(x),L.shareAKdfParams=N.DEFAULT_KDF_PARAMS}if(g==="passkey"&&j&&(L.prfSalt=j),await t(L),r==="none")d(),n({step:"complete",solanaPubkey:T});else{const E=r==="full_seed"?$n(y):qn(N.toShamirShare(S));n({step:"showing_recovery",recoveryPhrase:E,solanaPubkey:T})}},[t,r,d]),f=i.useCallback(async g=>{if(!s){n({step:"error",error:"User not authenticated"});return}c(!0),d();try{const p=N.generateArgon2Salt(),x=await le.argon2DeriveInWorker(g,p,N.DEFAULT_KDF_PARAMS);l.current.push(x),await u("password",x,p)}catch(p){n({step:"error",error:p instanceof Error?p.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),m=i.useCallback(async()=>{if(!s){n({step:"error",error:"User not authenticated"});return}c(!0),d();try{const g=N.generatePrfSalt(),p=N.uint8ArrayToBase64(g);n({step:"registering_passkey"});let x;try{const y=new TextEncoder().encode(s.id),A=s.name??s.email??"User",v=s.email??s.id;x=(await N.registerPasskeyWithPrf(y,v,A,g)).prfOutput}catch(y){if(y?.name!=="InvalidStateError")throw y;x=(await N.authenticateWithDiscoverablePrf(p)).prfOutput}l.current.push(x);const j=await N.deriveKeyFromPrf(x,g);l.current.push(j),await u("passkey",j,void 0,p)}catch(g){n({step:"error",error:g instanceof Error?g.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),h=i.useCallback(()=>{const g=a.solanaPubkey;d(),n({step:"complete",solanaPubkey:g})},[a.solanaPubkey,d]),b=i.useCallback(()=>{d(),n({step:"idle"}),c(!1)},[d]);return{state:a,startEnrollmentWithPassword:f,startEnrollmentWithPasskey:m,confirmRecoveryPhrase:h,cancel:b,isEnrolling:o}}function Er({onComplete:s,onCancel:t,className:r="",forceAuthMethod:a}){const{user:n}=N.useCedrosLogin(),{state:o,startEnrollmentWithPassword:c,startEnrollmentWithPasskey:l,confirmRecoveryPhrase:d,cancel:u,isEnrolling:f}=_r(),m=()=>a||"password",[h,b]=i.useState(m),[g,p]=i.useState(""),[x,j]=i.useState(""),[y,A]=i.useState(null);i.useEffect(()=>{b(m())},[n?.id,a]);const v=i.useCallback(async T=>{if(T.preventDefault(),g!==x){A("Passwords do not match");return}if(g.length<8){A("Password must be at least 8 characters");return}A(null),await c(g)},[g,x,c]),S=i.useCallback(async()=>{await l()},[l]),w=i.useCallback(()=>{d(),o.solanaPubkey&&s?.(o.solanaPubkey)},[d,o.solanaPubkey,s]),C=i.useCallback(()=>{u(),t?.()},[u,t]);return o.step==="generating_seed"||o.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..."})]})}):o.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..."})]})}):o.step==="registering_passkey"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsx("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:e.jsxs("div",{className:"cedros-passkey-prompt",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("h3",{children:"Authenticate with Passkey"}),e.jsx("p",{children:"Follow your browser's prompt to use your passkey."})]})})}):o.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..."})]})}):o.step==="showing_recovery"&&o.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsx(Nr,{words:o.recoveryPhrase,onConfirm:w})}):o.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:"})," ",o.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):o.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:o.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:C,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>u(),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"}),e.jsxs("p",{children:["Secure your wallet with a ",h==="passkey"?"passkey":"password","."]})]}),!a&&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:h==="password",onChange:()=>b("password"),disabled:f}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:h==="passkey",onChange:()=>b("passkey"),disabled:f}),e.jsx("span",{children:"Passkey"})]})]}),h==="password"&&e.jsxs("form",{onSubmit:v,className:"cedros-enrollment-form",children:[e.jsx(X.PasswordInput,{label:"Password",value:g,onChange:T=>p(T.target.value),showStrengthMeter:!0,disabled:f,required:!0,minLength:8,placeholder:"Enter a strong password"}),e.jsx(X.PasswordInput,{label:"Confirm Password",value:x,onChange:T=>j(T.target.value),error:y??void 0,disabled:f,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:C,disabled:f,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:f||!g||!x,children:f?"Creating...":"Continue"})]})]}),h==="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.jsx("p",{children:"You'll use the same passkey to sign transactions."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:C,disabled:f,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,disabled:f,children:f?"Creating...":"Use Passkey"})]})]})]})}function Pr(){const{user:s}=N.useCedrosLogin(),{signTransaction:t}=N.useWalletMaterial(),[r,a]=i.useState(!1),[n,o]=i.useState(null),c=i.useCallback(async(d,u)=>{if(!s){const f="User not authenticated";throw o(f),new Error(f)}a(!0),o(null);try{const f={transaction:N.uint8ArrayToBase64(d),...u?{credential:N.toCredentialRequest(u)}:{}},m=await t(f);return N.base64ToUint8Array(m.signature)}catch(f){const m=f instanceof Error?f.message:"Signing failed";throw o(m),f}finally{a(!1)}},[s,t]),l=i.useCallback(()=>o(null),[]);return{signTransaction:c,isSigning:r,error:n,clearError:l}}function Tr(){const{getMaterial:s}=N.useWalletMaterial(),[t,r]=i.useState(!1),[a,n]=i.useState(null),o=i.useCallback(async()=>{r(!0),n(null);try{const l=await s();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 d=await N.authenticateWithDiscoverablePrf(l.prfSalt);return{type:"prfOutput",prfOutput:N.uint8ArrayToBase64(d.prfOutput)}}catch(l){const d=l instanceof Error?l.message:"Passkey authentication failed";return n(d),null}finally{r(!1)}},[s]),c=i.useCallback(()=>n(null),[]);return{getPasskeyCredential:o,isAuthenticating:t,error:a,clearError:c}}function Lr({mode:s,isLoading:t=!1,error:r,onPrompt:a,onRetry:n,onCancel:o,title:c,description:l,className:d=""}){const u=i.useCallback(()=>{t||a?.()},[t,a]),f=i.useCallback(()=>{n?.()},[n]),m=s==="register"?"Set Up Passkey":"Verify with Passkey",h=s==="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 ${d}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:t?e.jsx(Da,{}):r?e.jsx(Ra,{}):e.jsx(Ma,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:c??m}),e.jsx("p",{className:"cedros-passkey-description",children:l??h}),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"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:o,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:u,disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):s==="register"?"Create Passkey":"Use Passkey"}),o&&!t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:o,children:"Cancel"})]})}),t&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",s==="register"?"create":"verify"," your passkey."]})]})}function Ma(){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 Da(){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 Ra(){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 Mr({onUnlock:s,onCancel:t,showCancel:r=!0,authMethod:a,className:n=""}){N.useCedrosLogin();const{unlock:o,getMaterial:c,isLoading:l}=N.useWalletMaterial(),{getPasskeyCredential:d,isAuthenticating:u}=Tr(),[f,m]=i.useState("idle"),[h,b]=i.useState(a??null),[g,p]=i.useState(""),[x,j]=i.useState(null);i.useEffect(()=>{a!==void 0&&b(a)},[a]);const y=h==="password",A=h==="passkey",v=i.useCallback(async()=>{if(m("credential"),j(null),!h)try{const P=await c();P?b(P.shareAAuthMethod):(j("No wallet enrolled"),m("error"))}catch(P){j(P instanceof Error?P.message:"Failed to get wallet info"),m("error")}},[h,c]),S=i.useCallback(async P=>{P.preventDefault(),j(null),m("unlocking");try{let k;if(y)k={type:"password",password:g};else throw new Error("Invalid auth method");await o(k),m("unlocked"),s?.()}catch(k){j(k instanceof Error?k.message:"Failed to unlock wallet"),m("error")}},[y,g,o,s]),w=i.useCallback(async()=>{j(null),m("unlocking");try{const P=await d();if(!P){m("credential");return}await o(P),m("unlocked"),s?.()}catch(P){j(P instanceof Error?P.message:"Failed to unlock wallet"),m("error")}},[d,o,s]),C=i.useCallback(()=>{p(""),m("idle"),j(null),t?.()},[t]),T=i.useCallback(()=>{p(""),m("credential"),j(null)},[]),L=l||u,E=()=>{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(Ia,{})}),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:v,children:"Unlock Wallet"})]});case"credential":return y?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:S,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(X.PasswordInput,{label:"Password",value:g,onChange:P=>p(P.target.value),disabled:L,autoComplete:"current-password",error:x??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:L||g.length===0,children:L?"Unlocking...":"Unlock"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:C,disabled:L,children:"Cancel"})]})]}):A?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(Lr,{mode:"authenticate",isLoading:L,error:x??void 0,onPrompt:w,onRetry:w,onCancel:r?C:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(N.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(N.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(Ua,{})}),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(Fa,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:x??"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:T,children:"Try Again"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:C,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${n}`,children:E()})}function Ia(){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 Ua(){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 Fa(){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 Dr(){const{recover:s,getShareBForRecovery:t}=N.useWalletMaterial(),{recoveryMode:r}=Cr(),[a,n]=i.useState({step:"idle"}),[o,c]=i.useState(!1),l=i.useRef([]),d=i.useCallback(()=>{N.wipeAll(...l.current),l.current=[]},[]);i.useEffect(()=>()=>{d()},[d]);const u=i.useCallback(async(m,h,b)=>{c(!0),d();try{if(n({step:"validating"}),!hr(m))throw new Error("Invalid recovery phrase. Please check your words.");let g;if(r==="share_c_only"){const T=Wn(m);l.current.push(T);const L=N.uint8ArrayToBase64(T),E=await t({shareC:L}),P=N.base64ToUint8Array(E.shareB);l.current.push(P),g=le.combineShares(N.toShamirShare(P),N.toShamirShare(T)),l.current.push(g)}else g=zn(m),l.current.push(g);const p=le.getPublicKeyFromSeed(g),x=le.publicKeyToBase58(p),{shareA:j,shareB:y}=le.splitSecret(g);l.current.push(j,y),n({step:"encrypting"});let A,v,S;if(h==="passkey"){const T=N.generatePrfSalt();S=N.uint8ArrayToBase64(T);const L=await N.authenticateWithDiscoverablePrf(S);l.current.push(L.prfOutput),A=await N.deriveKeyFromPrf(L.prfOutput,T),l.current.push(A)}else v=N.generateArgon2Salt(),A=await le.argon2DeriveInWorker(b,v,N.DEFAULT_KDF_PARAMS),l.current.push(A);const w=await N.aesGcmEncryptToBase64(j,N.toEncryptionKey(A));n({step:"uploading"});const C={solanaPubkey:x,shareAAuthMethod:h,shareACiphertext:w.ciphertext,shareANonce:w.nonce,shareB:N.uint8ArrayToBase64(y)};h==="password"&&(C.shareAKdfSalt=N.uint8ArrayToBase64(v),C.shareAKdfParams=N.DEFAULT_KDF_PARAMS),h==="passkey"&&(C.prfSalt=S),await s(C),d(),n({step:"complete"})}catch(g){d(),n({step:"error",error:g instanceof Error?g.message:"Recovery failed"})}finally{c(!1)}},[s,t,r,d]),f=i.useCallback(()=>{d(),n({step:"idle"}),c(!1)},[d]);return{state:a,startRecovery:u,cancel:f,isRecovering:o}}function Rr({onComplete:s,onCancel:t,className:r="",defaultAuthMethod:a="password"}){const{state:n,startRecovery:o,cancel:c,isRecovering:l}=Dr(),[d,u]=i.useState([]),[f,m]=i.useState(!1),[h,b]=i.useState(a),[g,p]=i.useState(""),[x,j]=i.useState(""),[y,A]=i.useState(null),v=i.useCallback(L=>{u(L),m(!0)},[]),S=i.useCallback(async L=>{if(L.preventDefault(),A(null),h!=="passkey"){if(g!==x){A("Passwords do not match");return}if(h==="password"&&g.length<8){A("Password must be at least 8 characters");return}}await o(d,h,g)},[d,h,g,x,o]),w=i.useCallback(()=>{c(),u([]),m(!1),p(""),j(""),t?.()},[c,t]),C=i.useCallback(()=>{m(!1),p(""),j("")},[]),T=i.useCallback(()=>{s?.()},[s]);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(Ba,{})}),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(Oa,{})}),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"," ",h==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:T,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(qa,{})}),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:w,children:"Start Over"})})]})}):f?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:S,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:h==="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:h==="passkey",onChange:()=>b("passkey"),disabled:l}),e.jsx("span",{children:"Passkey"})]})]}),h==="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:g,onChange:L=>p(L.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:x,onChange:L=>j(L.target.value),disabled:l,"aria-invalid":y?"true":void 0,placeholder:"Confirm your password"}),y&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:y})]})]}),h==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(Wa,{}),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:C,disabled:l,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:l||h!=="passkey"&&(g.length===0||x.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(Sr,{onSubmit:v,onCancel:w,isSubmitting:!1})]})})}function Ba(){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 Oa(){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 qa(){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 Wa(){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 Ir({address:s,label:t="Wallet Address",showCopy:r=!0,showExplorerLink:a=!0,allowReveal:n=!0,className:o=""}){const c=N.useCedrosLoginOptional(),[l,d]=i.useState(!1),[u,f]=i.useState(null),[m,h]=i.useState(!1),b=i.useRef(null),g=c?.config.solana?.network??"mainnet-beta",p=i.useMemo(()=>{const A=`https://explorer.solana.com/address/${s}`;return g==="mainnet-beta"?A:`${A}?cluster=${encodeURIComponent(g)}`},[s,g]),x=n&&s.length>18,j=i.useMemo(()=>!x||m?s:`${s.slice(0,8)}...${s.slice(-8)}`,[s,x,m]),y=i.useCallback(async()=>{try{f(null),await navigator.clipboard.writeText(s),d(!0),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{d(!1),b.current=null},2e3)}catch(A){d(!1),f(A instanceof Error?A.message:"Copy failed")}},[s]);return i.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${o}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:t}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[x&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>h(A=>!A),"aria-label":m?"Hide full wallet address":"Show full wallet address",children:m?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"})]})}),a&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:p,target:"_blank",rel:"noreferrer",children:"Explorer"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:y,"aria-label":"Copy wallet address",children:l?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:s,children:j}),u&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:u})]})}function Ur({status:s,publicKey:t,onLock:r,onEnroll:a,onUnlock:n,onRecover:o,showActions:c=!0,compact:l=!1,className:d=""}){const u=s!==void 0,f=N.useWallet(),m=u?s:f.status,h=u?t??null:f.solanaPubkey,b=u?null:f.error,g=u?()=>{}:f.refresh,p=u?()=>{}:f.clearError,x=$a(m,b);return l?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${d}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${x.color}`,title:x.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:x.label}),h&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:h,children:za(h)})]}):e.jsxs("div",{className:`cedros-wallet-status ${d}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${x.color}`,children:e.jsx(Va,{status:m})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:x.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:x.description})]})]}),h&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(Ir,{address:h})}),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:p,children:"Dismiss"})]}),c&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[m==="not_enrolled"&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:a,children:"Create Wallet"}),m==="enrolled_locked"&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:n,children:"Unlock Wallet"}),(m==="not_enrolled"||m==="error")&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:"Recover Wallet"}),m==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:g,children:"Retry"})]})]})}function $a(s,t){switch(s){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:t??"An error occurred with your wallet.",color:"error"}}}function za(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function Va({status:s}){switch(s){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 Ha({className:s="",showActions:t=!0}){const r=N.useWallet(),[a,n]=i.useState("status"),o=i.useMemo(()=>{switch(a){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}},[a]),c=i.useCallback(()=>n("status"),[]),l=i.useCallback(async()=>{n("status"),await r.refresh()},[r]),d=i.useCallback(async()=>{n("status"),await r.refresh()},[r]),u=i.useCallback(async()=>{n("status"),await r.refresh()},[r]);return e.jsxs("div",{className:`cedros-wallet-manager ${s}`,children:[a!=="status"&&o&&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:o.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:o.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:c,children:"Back"})]}),a==="status"&&e.jsx(Ur,{onEnroll:()=>n("enroll"),onUnlock:()=>n("unlock"),onRecover:()=>n("recover_intro"),showActions:t}),a==="enroll"&&e.jsx(Er,{onComplete:()=>{l()},onCancel:c}),a==="unlock"&&e.jsx(Mr,{onUnlock:()=>{d()},onCancel:c}),a==="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:c,children:"Cancel"})]})]})}),a==="recover"&&e.jsx(Rr,{onComplete:()=>{u()},onCancel:c})]})}class Qa{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async getSettings(){try{return await this.client.get("/admin/settings")}catch(t){throw N.handleApiError(t,"Failed to fetch system settings")}}async updateSettings(t){try{return await this.client.patch("/admin/settings",{settings:t})}catch(r){throw N.handleApiError(r,"Failed to update system settings")}}}function Ue(){const{config:s,authState:t,_internal:r}=N.useCedrosLogin(),[a,n]=i.useState({}),[o,c]=i.useState(!1),[l,d]=i.useState(!1),[u,f]=i.useState(null),m=i.useRef(0),h=i.useMemo(()=>new Qa(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),b=i.useRef(h);b.current=h;const g=i.useCallback(async()=>{if(t!=="authenticated"){n({});return}c(!0),f(null);const j=++m.current;try{const y=await b.current.getSettings();if(j!==m.current)return;n(y.settings)}catch(y){if(j!==m.current)return;f(y instanceof Error?y:new Error("Failed to fetch settings"))}finally{j===m.current&&c(!1)}},[t]),p=i.useCallback(async j=>{if(t!=="authenticated")throw new Error("Not authenticated");d(!0),f(null);try{await b.current.updateSettings(j),await g()}catch(y){const A=y instanceof Error?y:new Error("Failed to update settings");throw f(A),A}finally{d(!1)}},[t,g]),x=i.useCallback(j=>{for(const y of Object.values(a)){const A=y.find(v=>v.key===j);if(A)return A.value}},[a]);return{settings:a,isLoading:o,isUpdating:l,error:u,fetchSettings:g,updateSettings:p,getValue:x}}function Ka(s){const t=Math.floor(s/86400),r=Math.floor(s%86400/3600),a=Math.floor(s%3600/60),n=s%60;return{days:t,hours:r,minutes:a,seconds:n}}function Ga(s){const{days:t,hours:r,minutes:a}=Ka(s),n=[];return t>0&&n.push(`${t}d`),r>0&&n.push(`${r}h`),a>0&&n.push(`${a}m`),n.length===0&&n.push(`${s}s`),n.join(" ")}const Ya={auth_email_enabled:{key:"auth_email_enabled",label:"Enable Email Authentication",description:"Allow users to sign up and log in with email/password.",inputType:"boolean"},auth_email_require_verification:{key:"auth_email_require_verification",label:"Require Email Verification",description:"Users must verify their email address before they can log in.",inputType:"boolean"},auth_email_block_disposable:{key:"auth_email_block_disposable",label:"Block Disposable Emails",description:"Reject registrations from known disposable email providers.",inputType:"boolean"},auth_google_enabled:{key:"auth_google_enabled",label:"Enable Google Sign-In",description:"Allow users to authenticate with their Google account.",inputType:"boolean"},auth_google_client_id:{key:"auth_google_client_id",label:"Google Client ID",description:"OAuth 2.0 client ID from Google Cloud Console.",inputType:"text"},auth_google_client_secret:{key:"auth_google_client_secret",label:"Google Client Secret",description:"OAuth 2.0 client secret from Google Cloud Console.",inputType:"secret"},auth_apple_enabled:{key:"auth_apple_enabled",label:"Enable Sign in with Apple",description:"Allow users to authenticate with their Apple ID.",inputType:"boolean"},auth_apple_client_id:{key:"auth_apple_client_id",label:"Apple Services ID",description:"The Services ID configured in your Apple Developer account.",inputType:"text"},auth_apple_team_id:{key:"auth_apple_team_id",label:"Apple Team ID",description:"Your Apple Developer Team ID.",inputType:"text"},auth_apple_key_id:{key:"auth_apple_key_id",label:"Apple Key ID",description:"The Key ID for your Sign in with Apple private key.",inputType:"text"},auth_apple_private_key:{key:"auth_apple_private_key",label:"Apple Private Key",description:"The private key file contents (PEM format) for Sign in with Apple.",inputType:"secret",multiline:!0},auth_solana_enabled:{key:"auth_solana_enabled",label:"Enable Solana Wallet Auth",description:"Allow users to authenticate by signing with their Solana wallet.",inputType:"boolean"},auth_solana_challenge_expiry:{key:"auth_solana_challenge_expiry",label:"Challenge Expiry",description:"How long a wallet signature challenge is valid.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"10 minutes",value:"600"}]},auth_webauthn_enabled:{key:"auth_webauthn_enabled",label:"Enable WebAuthn/Passkeys",description:"Allow passwordless authentication with FIDO2/WebAuthn credentials.",inputType:"boolean"},auth_webauthn_rp_id:{key:"auth_webauthn_rp_id",label:"Relying Party ID",description:"Usually your domain (e.g., example.com). Passkeys are bound to this.",inputType:"text"},auth_webauthn_rp_name:{key:"auth_webauthn_rp_name",label:"Relying Party Name",description:"Display name shown to users during passkey registration.",inputType:"text"},auth_webauthn_rp_origin:{key:"auth_webauthn_rp_origin",label:"Allowed Origins",description:"Comma-separated origins allowed for WebAuthn (e.g., https://example.com).",inputType:"text"},feature_privacy_cash:{key:"feature_privacy_cash",label:"Privacy Cash",description:"Enable Privacy Cash deposits and timed withdrawals.",inputType:"boolean"},feature_wallet_signing:{key:"feature_wallet_signing",label:"Embedded Wallet Signing",description:"Enable the embedded wallet for transaction signing.",inputType:"boolean"},feature_sso:{key:"feature_sso",label:"Enterprise SSO",description:"Enable SAML/OIDC single sign-on for enterprise customers.",inputType:"boolean"},feature_organizations:{key:"feature_organizations",label:"Organizations",description:"Enable multi-user organizations with role-based access.",inputType:"boolean"},feature_mfa:{key:"feature_mfa",label:"Two-Factor Authentication",description:"Allow users to enable TOTP-based two-factor authentication.",inputType:"boolean"},feature_instant_link:{key:"feature_instant_link",label:"Instant Link Login",description:"Allow passwordless login via magic link sent to email.",inputType:"boolean"},security_cors_origins:{key:"security_cors_origins",label:"CORS Origins",description:"Allowed origins for cross-origin requests (comma-separated). Empty = same origin only.",inputType:"text"},security_cookie_domain:{key:"security_cookie_domain",label:"Cookie Domain",description:"Domain for auth cookies. Empty uses the request origin.",inputType:"text"},security_cookie_secure:{key:"security_cookie_secure",label:"Secure Cookies",description:"Require HTTPS for cookies. Disable only for local development.",inputType:"boolean"},security_cookie_same_site:{key:"security_cookie_same_site",label:"Cookie SameSite",description:'SameSite policy for cookies. Use "none" only if needed for cross-site embeds.',inputType:"select",presets:[{label:"Strict",value:"strict"},{label:"Lax (Recommended)",value:"lax"},{label:"None (cross-site)",value:"none"}]},security_session_timeout:{key:"security_session_timeout",label:"Session Timeout",description:"How long sessions remain valid before requiring re-authentication.",inputType:"duration",min:300,presets:[{label:"1 hour",value:"3600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"30 days",value:"2592000"}]},security_jwt_issuer:{key:"security_jwt_issuer",label:"JWT Issuer",description:"Issuer claim for JWTs. Empty uses the server URL.",inputType:"text"},security_jwt_audience:{key:"security_jwt_audience",label:"JWT Audience",description:"Audience claim for JWTs. Empty uses default.",inputType:"text"},email_smtp_host:{key:"email_smtp_host",label:"SMTP Host",description:"SMTP server hostname (e.g., smtp.sendgrid.net).",inputType:"text"},email_smtp_port:{key:"email_smtp_port",label:"SMTP Port",description:"SMTP server port. Common: 587 (TLS), 465 (SSL), 25 (unencrypted).",inputType:"select",presets:[{label:"587 (TLS)",value:"587"},{label:"465 (SSL)",value:"465"},{label:"25 (Plain)",value:"25"}]},email_smtp_user:{key:"email_smtp_user",label:"SMTP Username",description:"Username for SMTP authentication.",inputType:"text"},email_smtp_password:{key:"email_smtp_password",label:"SMTP Password",description:"Password or API key for SMTP authentication.",inputType:"secret"},email_smtp_tls:{key:"email_smtp_tls",label:"Use TLS",description:"Enable TLS encryption for SMTP connections.",inputType:"boolean"},email_from_address:{key:"email_from_address",label:"From Address",description:"Default sender email address (e.g., noreply@example.com).",inputType:"text"},email_from_name:{key:"email_from_name",label:"From Name",description:'Default sender display name (e.g., "My App").',inputType:"text"},webhook_enabled:{key:"webhook_enabled",label:"Enable Webhooks",description:"Send HTTP notifications for auth events (signup, login, etc.).",inputType:"boolean"},webhook_url:{key:"webhook_url",label:"Webhook URL",description:"Endpoint to receive webhook POST requests.",inputType:"text"},webhook_secret:{key:"webhook_secret",label:"Webhook Secret",description:"Secret used to sign webhook payloads (HMAC-SHA256).",inputType:"secret"},webhook_timeout:{key:"webhook_timeout",label:"Timeout",description:"Maximum time to wait for webhook response.",inputType:"duration",min:5,presets:[{label:"10 seconds",value:"10"},{label:"30 seconds",value:"30"},{label:"60 seconds",value:"60"}]},webhook_retries:{key:"webhook_retries",label:"Max Retries",description:"Number of retry attempts for failed webhooks.",inputType:"select",presets:[{label:"0 (No retries)",value:"0"},{label:"3 (Recommended)",value:"3"},{label:"5",value:"5"}]},server_frontend_url:{key:"server_frontend_url",label:"Frontend URL",description:"URL of your frontend app (for redirects and email links).",inputType:"text"},server_base_path:{key:"server_base_path",label:"Base Path",description:"Base path for auth endpoints (e.g., /auth).",inputType:"text"},server_trust_proxy:{key:"server_trust_proxy",label:"Trust Proxy",description:"Trust X-Forwarded-For headers. Enable if behind a reverse proxy.",inputType:"boolean"},privacy_period_secs:{key:"privacy_period_secs",label:"Privacy Period",description:"How long deposits are held before withdrawal to provide timing privacy. Longer periods provide better privacy but delay user access to funds.",inputType:"duration",min:0,presets:[{label:"Disabled",value:"0"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"14 days",value:"1209600"},{label:"30 days",value:"2592000"}],warningThreshold:{below:3600,message:"Very short privacy periods may not provide adequate timing protection."}},withdrawal_poll_interval_secs:{key:"withdrawal_poll_interval_secs",label:"Worker Poll Interval",description:"How often the withdrawal worker checks for deposits ready to process. Lower values process faster but increase server load.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"}],warningThreshold:{below:60,message:"Polling more than once per minute may cause excessive load."}},withdrawal_batch_size:{key:"withdrawal_batch_size",label:"Batch Size",description:"Maximum number of withdrawals to process in a single batch. Higher values improve throughput but may cause timeouts.",inputType:"select",min:1,max:100,presets:[{label:"1 (Sequential)",value:"1"},{label:"5",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100 (Max)",value:"100"}]},withdrawal_timeout_secs:{key:"withdrawal_timeout_secs",label:"Transaction Timeout",description:"How long to wait for a withdrawal transaction to confirm before considering it failed.",inputType:"duration",min:30,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"2 minutes",value:"120"},{label:"5 minutes",value:"300"}],warningThreshold:{below:30,message:"Very short timeouts may cause premature failure on slow networks."}},withdrawal_max_retries:{key:"withdrawal_max_retries",label:"Max Retries",description:"Number of times to retry a failed withdrawal before marking it as permanently failed.",inputType:"select",min:0,max:10,presets:[{label:"0 (No retries)",value:"0"},{label:"1",value:"1"},{label:"3 (Recommended)",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},withdrawal_percentage:{key:"withdrawal_percentage",label:"Withdrawal Percentage",description:"Percentage of ready funds to withdraw each cycle. Lower values spread withdrawals over time for better privacy.",inputType:"percentage",min:1,max:100,step:5,presets:[{label:"25%",value:"25"},{label:"50%",value:"50"},{label:"75%",value:"75"},{label:"100% (All at once)",value:"100"}],warningThreshold:{above:75,message:"High percentages may reduce timing privacy by processing most withdrawals together."}},partial_withdrawal_count:{key:"partial_withdrawal_count",label:"Partial Withdrawals",description:"Maximum partial withdrawals per batch. Partial withdrawals add noise to timing analysis. Set to 0 to disable.",inputType:"select",min:0,presets:[{label:"Disabled",value:"0"},{label:"1",value:"1"},{label:"3",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},partial_withdrawal_min_lamports:{key:"partial_withdrawal_min_lamports",label:"Min Balance for Partial",description:"Minimum account balance (in lamports) required before partial withdrawals are considered. 1 SOL = 1,000,000,000 lamports.",inputType:"select",min:0,presets:[{label:"0.1 SOL",value:"100000000"},{label:"0.5 SOL",value:"500000000"},{label:"1 SOL",value:"1000000000"},{label:"5 SOL",value:"5000000000"},{label:"10 SOL",value:"10000000000"}]},rate_limit_auth:{key:"rate_limit_auth",label:"Auth Request Limit",description:"Maximum authentication attempts (login, register, password reset) per IP per window. Protects against brute force attacks.",inputType:"select",min:1,unit:"requests",presets:[{label:"5 (Strict)",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"20",value:"20"},{label:"50 (Permissive)",value:"50"}],warningThreshold:{above:20,message:"High auth limits may allow brute force attempts."}},rate_limit_general:{key:"rate_limit_general",label:"General Request Limit",description:"Maximum general API requests per IP per window. Affects all non-auth endpoints.",inputType:"select",min:1,unit:"requests",presets:[{label:"30",value:"30"},{label:"60 (Recommended)",value:"60"},{label:"120",value:"120"},{label:"300",value:"300"}]},rate_limit_credit:{key:"rate_limit_credit",label:"Credit Request Limit",description:"Maximum credit/balance check requests per IP per window. Higher for apps that poll balance frequently.",inputType:"select",min:1,unit:"requests",presets:[{label:"10",value:"10"},{label:"30 (Recommended)",value:"30"},{label:"60",value:"60"},{label:"120",value:"120"}]},rate_limit_window:{key:"rate_limit_window",label:"Rate Limit Window",description:'Time window for rate limiting. All limits above are "per window". Shorter windows are stricter.',inputType:"duration",min:1,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"}]},deposit_quick_action_tokens:{key:"deposit_quick_action_tokens",label:"Quick Action Tokens",description:"Comma-separated token symbols shown as quick action buttons. First token is the default.",inputType:"tokenSymbolList"},deposit_custom_tokens:{key:"deposit_custom_tokens",label:"Custom Dropdown Tokens",description:'Comma-separated token symbols shown in the "Custom" dropdown. Leave empty to show all.',inputType:"tokenSymbolList"},deposit_custom_tokens_json:{key:"deposit_custom_tokens_json",label:"Custom Token Definitions",description:"Add tokens beyond the built-in list. Define symbol, mint address, decimals, and logo URL.",inputType:"tokenList"}},Ja={"auth.apple":{label:"Apple Sign-In",description:"Configure Sign in with Apple OAuth integration.",icon:""},"auth.email":{label:"Email Authentication",description:"Configure email/password authentication settings.",icon:""},"auth.google":{label:"Google Sign-In",description:"Configure Google OAuth integration.",icon:""},"auth.solana":{label:"Solana Wallet Auth",description:"Configure Solana wallet signature authentication.",icon:""},"auth.webauthn":{label:"WebAuthn / Passkeys",description:"Configure FIDO2/WebAuthn passwordless authentication.",icon:""},deposit:{label:"Deposit Settings",description:"Configure token lists and deposit flow display options.",icon:""},email:{label:"Email / SMTP",description:"Configure outbound email delivery for verification, password reset, and notifications.",icon:""},features:{label:"Feature Flags",description:"Enable or disable major platform features.",icon:""},privacy:{label:"Privacy Settings",description:"Control the privacy period for deposits. Longer periods provide better timing privacy but delay fund availability.",icon:""},rate_limit:{label:"Rate Limiting",description:"Protect the system from abuse by limiting request rates. Balance security with user experience.",icon:""},security:{label:"Security",description:"Configure CORS, cookies, sessions, and JWT settings.",icon:""},server:{label:"Server",description:"Server infrastructure settings. Some may be overridden by environment variables.",icon:""},webhook:{label:"Webhooks",description:"Configure HTTP webhook notifications for auth events.",icon:""},withdrawal:{label:"Withdrawal Worker",description:"Configure how the automated withdrawal processor handles pending withdrawals. These settings affect throughput and privacy.",icon:""}};function Xa({showDescriptions:s=!0,className:t="",onSave:r}){const{settings:a,isLoading:n,isUpdating:o,error:c,fetchSettings:l,updateSettings:d}=Ue(),[u,f]=i.useState({}),[m,h]=i.useState(null),[b,g]=i.useState(!1);i.useEffect(()=>{l()},[l]),i.useEffect(()=>{if(b){const S=setTimeout(()=>g(!1),3e3);return()=>clearTimeout(S)}},[b]);const p=i.useCallback((S,w)=>{f(C=>({...C,[S]:w})),h(null),g(!1)},[]),x=i.useCallback(async()=>{const S=Object.entries(u).map(([w,C])=>({key:w,value:C}));if(S.length!==0)try{await d(S),f({}),h(null),g(!0),r?.()}catch(w){h(w instanceof Error?w.message:"Failed to save settings")}},[u,d,r]),j=i.useCallback(()=>{f({}),h(null),g(!1)},[]),y=Object.keys(u).length>0,A=Object.keys(u).length;if(n&&Object.keys(a).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(c)return e.jsx("div",{className:`cedros-system-settings ${t}`,children:e.jsx(N.ErrorMessage,{error:c.message})});const v=Object.keys(a).sort();return v.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${t}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${t}`,children:[m&&e.jsx(N.ErrorMessage,{error:m}),b&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),v.map(S=>e.jsx(Za,{category:S,settings:a[S],edits:u,showDescription:s,onChange:p},S)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[y&&e.jsxs("span",{className:"cedros-settings-change-count",children:[A," unsaved change",A!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:j,disabled:!y||o,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,disabled:!y||o,children:o?e.jsx(N.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}function Za({category:s,settings:t,edits:r,showDescription:a,onChange:n}){const o=Ja[s]||{label:s,description:"",icon:"⚙️"};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:o.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:o.label}),a&&o.description&&e.jsx("p",{className:"cedros-settings-section-description",children:o.description})]})]}),e.jsx("div",{className:"cedros-settings-grid",children:t.map(c=>e.jsx(eo,{setting:c,editValue:r[c.key],onChange:n},c.key))})]})}function eo({setting:s,editValue:t,onChange:r}){const a=Ya[s.key],n=t??s.value,o=t!==void 0&&t!==s.value,c=i.useMemo(()=>{if(!a?.warningThreshold)return null;const l=parseInt(n,10);if(isNaN(l))return null;const{above:d,below:u,message:f}=a.warningThreshold;return d!==void 0&&l>d||u!==void 0&&l<u?f:null},[n,a?.warningThreshold]);return a?e.jsxs("div",{className:`cedros-setting-row ${o?"cedros-setting-row-changed":""} ${c?"cedros-setting-row-warning":""}`,children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:a.label}),e.jsx("span",{className:"cedros-setting-description",children:a.description})]}),e.jsxs("div",{className:"cedros-setting-control",children:[a.inputType==="duration"&&e.jsx(so,{value:n,onChange:l=>r(s.key,l),presets:a.presets,min:a.min}),a.inputType==="percentage"&&e.jsx(to,{value:n,onChange:l=>r(s.key,l),min:a.min??1,max:a.max??100,step:a.step??5,presets:a.presets}),a.inputType==="select"&&e.jsx(ro,{value:n,onChange:l=>r(s.key,l),presets:a.presets??[],unit:a.unit}),a.inputType==="number"&&e.jsx(no,{value:n,onChange:l=>r(s.key,l),min:a.min,max:a.max,unit:a.unit}),a.inputType==="tokenList"&&e.jsx(io,{value:n,onChange:l=>r(s.key,l)}),a.inputType==="text"&&e.jsx("input",{type:"text",value:n,onChange:l=>r(s.key,l.target.value),className:"cedros-setting-input",placeholder:a.label}),a.inputType==="boolean"&&e.jsx(ao,{value:n,onChange:l=>r(s.key,l)}),a.inputType==="secret"&&e.jsx(oo,{value:n,onChange:l=>r(s.key,l),multiline:a.multiline}),a.inputType==="tokenSymbolList"&&e.jsx(lo,{value:n,onChange:l=>r(s.key,l)}),c&&e.jsx("div",{className:"cedros-setting-warning",children:c})]})]}):e.jsxs("div",{className:`cedros-setting-row ${o?"cedros-setting-row-changed":""}`,children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:s.key}),s.description&&e.jsx("span",{className:"cedros-setting-description",children:s.description})]}),e.jsx("div",{className:"cedros-setting-input-wrapper",children:e.jsx("input",{type:"text",value:n,onChange:l=>r(s.key,l.target.value),className:"cedros-setting-input"})})]})}function so({value:s,onChange:t,presets:r,min:a=0}){const n=parseInt(s,10)||0,o=Ga(n),c=i.useCallback(d=>{d.target.value&&t(d.target.value)},[t]),l=i.useCallback(d=>{const u=Math.max(a,parseInt(d.target.value,10)||0);t(String(u))},[t,a]);return e.jsxs("div",{className:"cedros-duration-input",children:[r&&r.length>0&&e.jsxs("select",{value:r.find(d=>d.value===s)?.value??"",onChange:c,className:"cedros-setting-select",children:[e.jsx("option",{value:"",children:"Custom..."}),r.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))]}),e.jsxs("div",{className:"cedros-duration-custom",children:[e.jsx("input",{type:"number",value:n,onChange:l,min:a,className:"cedros-setting-input cedros-setting-input-sm"}),e.jsx("span",{className:"cedros-setting-unit",children:"seconds"}),e.jsxs("span",{className:"cedros-duration-display",children:["= ",o]})]})]})}function to({value:s,onChange:t,min:r,max:a,step:n,presets:o}){const c=parseInt(s,10)||r,l=i.useCallback(u=>{t(u.target.value)},[t]),d=i.useCallback(u=>{t(u)},[t]);return e.jsxs("div",{className:"cedros-percentage-input",children:[e.jsxs("div",{className:"cedros-percentage-slider-row",children:[e.jsx("input",{type:"range",value:c,onChange:l,min:r,max:a,step:n,className:"cedros-percentage-slider"}),e.jsxs("span",{className:"cedros-percentage-value",children:[c,"%"]})]}),o&&o.length>0&&e.jsx("div",{className:"cedros-preset-buttons",children:o.map(u=>e.jsx("button",{type:"button",className:`cedros-preset-button ${u.value===s?"cedros-preset-button-active":""}`,onClick:()=>d(u.value),children:u.label},u.value))})]})}function ro({value:s,onChange:t,presets:r,unit:a}){const n=!r.some(l=>l.value===s),o=i.useCallback(l=>{l.target.value!=="__custom__"&&t(l.target.value)},[t]),c=i.useCallback(l=>{t(l.target.value)},[t]);return e.jsxs("div",{className:"cedros-select-input",children:[e.jsxs("select",{value:n?"__custom__":s,onChange:o,className:"cedros-setting-select",children:[r.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value)),e.jsx("option",{value:"__custom__",children:"Custom..."})]}),n&&e.jsxs("div",{className:"cedros-select-custom",children:[e.jsx("input",{type:"number",value:s,onChange:c,className:"cedros-setting-input cedros-setting-input-sm"}),a&&e.jsx("span",{className:"cedros-setting-unit",children:a})]})]})}function no({value:s,onChange:t,min:r,max:a,unit:n}){const o=i.useCallback(c=>{t(c.target.value)},[t]);return e.jsxs("div",{className:"cedros-number-input",children:[e.jsx("input",{type:"number",value:s,onChange:o,min:r,max:a,className:"cedros-setting-input"}),n&&e.jsx("span",{className:"cedros-setting-unit",children:n})]})}function ao({value:s,onChange:t}){const r=s==="true",a=i.useCallback(()=>{t(r?"false":"true")},[r,t]);return e.jsxs("button",{type:"button",role:"switch","aria-checked":r,className:`cedros-toggle ${r?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:a,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:r?"Enabled":"Disabled"})]})}function oo({value:s,onChange:t,multiline:r}){const[a,n]=i.useState(!1),[o,c]=i.useState(!1),l=s&&s.length>0,d=i.useCallback(()=>{n(!0),c(!0)},[]),u=i.useCallback(()=>{n(!1),c(!1)},[]),f=i.useCallback(m=>{t(m.target.value)},[t]);return!a&&l?e.jsxs("div",{className:"cedros-secret-input cedros-secret-input-masked",children:[e.jsx("span",{className:"cedros-secret-masked",children:"•".repeat(Math.min(s.length,20))}),e.jsx("button",{type:"button",className:"cedros-secret-edit-btn",onClick:d,children:"Edit"})]}):e.jsxs("div",{className:"cedros-secret-input",children:[r?e.jsx("textarea",{value:s,onChange:f,className:"cedros-setting-input cedros-setting-textarea",placeholder:"Enter secret value...",rows:4}):e.jsx("input",{type:o?"text":"password",value:s,onChange:f,className:"cedros-setting-input",placeholder:"Enter secret value..."}),e.jsxs("div",{className:"cedros-secret-actions",children:[!r&&e.jsx("button",{type:"button",className:"cedros-secret-toggle-btn",onClick:()=>c(!o),children:o?"Hide":"Show"}),a&&e.jsx("button",{type:"button",className:"cedros-secret-done-btn",onClick:u,children:"Done"})]})]})}const Fr=["SOL","USDC","USDT","EURC","USD1","PYUSD","USDH","CASH","BONK","ORE"];function io({value:s,onChange:t}){const r=i.useMemo(()=>{try{return JSON.parse(s||"[]")}catch{return[]}},[s]),a=i.useCallback(l=>{t(JSON.stringify(l))},[t]),n=i.useCallback(()=>{a([...r,{symbol:"",mint:"",decimals:6}])},[r,a]),o=i.useCallback((l,d,u)=>{const f=[...r];f[l]={...f[l],[d]:u},a(f)},[r,a]),c=i.useCallback(l=>{a(r.filter((d,u)=>u!==l))},[r,a]);return e.jsxs("div",{className:"cedros-token-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Built-in tokens:"}),e.jsx("div",{className:"cedros-token-presets-list",children:Fr.map(l=>e.jsx("span",{className:"cedros-token-preset-chip",children:l},l))})]}),r.length===0&&e.jsx("p",{className:"cedros-token-list-empty",children:"No custom tokens added. Use the built-in tokens above or add your own."}),r.map((l,d)=>e.jsxs("div",{className:"cedros-token-row",children:[e.jsxs("div",{className:"cedros-token-row-fields",children:[e.jsx("input",{type:"text",placeholder:"Symbol",value:l.symbol,onChange:u=>o(d,"symbol",u.target.value.toUpperCase()),className:"cedros-setting-input cedros-token-input-symbol",maxLength:10}),e.jsx("input",{type:"text",placeholder:"Mint address",value:l.mint,onChange:u=>o(d,"mint",u.target.value),className:"cedros-setting-input cedros-token-input-mint"}),e.jsx("input",{type:"number",placeholder:"Decimals",value:l.decimals,onChange:u=>o(d,"decimals",parseInt(u.target.value,10)||0),className:"cedros-setting-input cedros-token-input-decimals",min:0,max:18}),e.jsx("input",{type:"text",placeholder:"Logo URL (optional)",value:l.logoUrl||"",onChange:u=>o(d,"logoUrl",u.target.value||void 0),className:"cedros-setting-input cedros-token-input-logo"})]}),e.jsx("button",{type:"button",className:"cedros-token-remove-btn",onClick:()=>c(d),title:"Remove token",children:"×"})]},d)),e.jsx("button",{type:"button",className:"cedros-token-add-btn",onClick:n,children:"+ Add Token"})]})}function lo({value:s,onChange:t}){const r=i.useMemo(()=>s.split(",").map(o=>o.trim()).filter(Boolean),[s]),a=i.useCallback(o=>{if(!o||r.includes(o))return;const c=[...r,o].join(", ");t(c)},[r,t]),n=i.useCallback(o=>{const c=r.filter(l=>l!==o).join(", ");t(c)},[r,t]);return e.jsxs("div",{className:"cedros-token-symbol-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Click to add:"}),e.jsx("div",{className:"cedros-token-presets-list",children:Fr.map(o=>{const c=r.includes(o);return e.jsxs("button",{type:"button",className:`cedros-token-preset-chip ${c?"cedros-token-preset-chip-selected":""}`,onClick:()=>c?n(o):a(o),title:c?`Remove ${o}`:`Add ${o}`,children:[o,c&&e.jsx("span",{className:"cedros-token-chip-check",children:"✓"})]},o)})})]}),e.jsx("input",{type:"text",value:s,onChange:o=>t(o.target.value),className:"cedros-setting-input",placeholder:"USDC, SOL, BONK..."})]})}class co{client;constructor(t,r,a){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a})}async getStatus(){try{return await this.client.get("/setup/status")}catch(t){throw N.handleApiError(t,"Failed to check setup status")}}async createFirstAdmin(t){try{return await this.client.post("/setup/admin",t)}catch(r){throw N.handleApiError(r,"Failed to create admin account")}}}function Ys(){const{config:s}=N.useCedrosLogin(),[t,r]=i.useState(null),[a,n]=i.useState(!1),[o,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useRef(0),f=i.useMemo(()=>new co(s.serverUrl,s.requestTimeout,s.retryAttempts),[s.serverUrl,s.requestTimeout,s.retryAttempts]),m=i.useRef(f);m.current=f;const h=i.useCallback(async()=>{n(!0),d(null);const g=++u.current;try{const p=await m.current.getStatus();if(g!==u.current)return;r(p)}catch(p){if(g!==u.current)return;d(p instanceof Error?p:new Error("Failed to check setup status"))}finally{g===u.current&&n(!1)}},[]),b=i.useCallback(async g=>{c(!0),d(null);try{const p=await m.current.createFirstAdmin(g);return await h(),p}catch(p){const x=p instanceof Error?p:new Error("Failed to create admin");throw d(x),x}finally{c(!1)}},[h]);return{status:t,isLoading:a,isCreating:o,error:l,checkStatus:h,createAdmin:b}}const uo=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,pt=8;function ho(s){const t={};return s.email?uo.test(s.email)||(t.email="Invalid email format"):t.email="Email is required",s.password?s.password.length<pt&&(t.password=`Password must be at least ${pt} characters`):t.password="Password is required",s.confirmPassword?s.password!==s.confirmPassword&&(t.confirmPassword="Passwords do not match"):t.confirmPassword="Please confirm your password",t}function Br({onComplete:s,className:t=""}){const{status:r,isLoading:a,isCreating:n,error:o,checkStatus:c,createAdmin:l}=Ys(),[d,u]=i.useState({email:"",password:"",confirmPassword:"",name:""}),[f,m]=i.useState({}),[h,b]=i.useState(!1);i.useEffect(()=>{c()},[c]);const g=i.useCallback(x=>j=>{u(y=>({...y,[x]:j.target.value})),m(y=>({...y,[x]:void 0}))},[]),p=i.useCallback(async x=>{x.preventDefault();const j=ho(d);if(Object.keys(j).length>0){m(j);return}try{await l({email:d.email,password:d.password,name:d.name||void 0}),b(!0),s?.()}catch{}},[d,l,s]);return a?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):r&&!r.needsSetup?e.jsx("div",{className:`cedros-setup ${t}`,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."})]})}):h?e.jsx("div",{className:`cedros-setup ${t}`,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 ${t}`,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:p,children:[o&&e.jsx(N.ErrorMessage,{error:o.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:d.email,onChange:g("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:d.name,onChange:g("name"),placeholder:"Admin",autoComplete:"name",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:d.password,onChange:g("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:d.confirmPassword,onChange:g("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(N.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 mo=800,po=2e3;function Ee(){const{settings:s,isLoading:t,error:r,fetchSettings:a,updateSettings:n}=Ue(),[o,c]=i.useState({}),[l,d]=i.useState("idle"),[u,f]=i.useState(null),m=i.useRef(null),h=i.useRef(null),b=i.useRef({});i.useEffect(()=>()=>{m.current&&clearTimeout(m.current),h.current&&clearTimeout(h.current)},[]);const g=i.useCallback(async()=>{const j={...b.current};if(Object.keys(j).length===0){d("idle");return}d("saving"),f(null);const y=Object.entries(j).map(([A,v])=>({key:A,value:v}));try{await n(y),c(A=>{const v={...A};for(const S of Object.keys(j))delete v[S];return v});for(const A of Object.keys(j))delete b.current[A];d("saved"),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{d("idle")},po)}catch(A){d("error"),f(A instanceof Error?A.message:"Failed to save")}},[n]),p=i.useCallback((j,y)=>{c(A=>({...A,[j]:y})),b.current[j]=y,f(null),d("pending"),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{g()},mo)},[g]),x=i.useCallback(j=>{if(o[j]!==void 0)return o[j];for(const y of Object.values(s)){const A=y.find(v=>v.key===j);if(A)return A.value}return""},[o,s]);return{settings:s,edits:o,isLoading:t,autosaveStatus:l,autosaveError:u,error:r,fetchSettings:a,handleChange:p,getEffectiveValue:x}}function fo(s){const t=Math.floor(s/86400),r=Math.floor(s%86400/3600),a=Math.floor(s%3600/60),n=s%60;return{days:t,hours:r,minutes:a,seconds:n}}function go(s){const{days:t,hours:r,minutes:a}=fo(s),n=[];return t>0&&n.push(`${t}d`),r>0&&n.push(`${r}h`),a>0&&n.push(`${a}m`),n.length===0&&n.push(`${s}s`),n.join(" ")}const bo={auth_email_enabled:{key:"auth_email_enabled",label:"Enable Email Authentication",description:"Allow users to sign up and log in with email/password.",inputType:"boolean"},auth_email_require_verification:{key:"auth_email_require_verification",label:"Require Email Verification",description:"Users must verify their email address before they can log in.",inputType:"boolean"},auth_email_block_disposable:{key:"auth_email_block_disposable",label:"Block Disposable Emails",description:"Reject registrations from known disposable email providers.",inputType:"boolean"},auth_google_enabled:{key:"auth_google_enabled",label:"Enable Google Sign-In",description:"Allow users to authenticate with their Google account.",inputType:"boolean"},auth_google_client_id:{key:"auth_google_client_id",label:"Google Client ID",description:"OAuth 2.0 client ID from Google Cloud Console.",inputType:"text"},auth_google_client_secret:{key:"auth_google_client_secret",label:"Google Client Secret",description:"OAuth 2.0 client secret from Google Cloud Console.",inputType:"secret"},auth_apple_enabled:{key:"auth_apple_enabled",label:"Enable Sign in with Apple",description:"Allow users to authenticate with their Apple ID.",inputType:"boolean"},auth_apple_client_id:{key:"auth_apple_client_id",label:"Apple Services ID",description:"The Services ID configured in your Apple Developer account.",inputType:"text"},auth_apple_team_id:{key:"auth_apple_team_id",label:"Apple Team ID",description:"Your Apple Developer Team ID.",inputType:"text"},auth_apple_key_id:{key:"auth_apple_key_id",label:"Apple Key ID",description:"The Key ID for your Sign in with Apple private key.",inputType:"text"},auth_apple_private_key:{key:"auth_apple_private_key",label:"Apple Private Key",description:"The private key file contents (PEM format) for Sign in with Apple.",inputType:"secret",multiline:!0},auth_solana_enabled:{key:"auth_solana_enabled",label:"Enable Solana Wallet Auth",description:"Allow users to authenticate by signing with their Solana wallet.",inputType:"boolean"},auth_solana_challenge_expiry:{key:"auth_solana_challenge_expiry",label:"Challenge Expiry",description:"How long a wallet signature challenge is valid.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"10 minutes",value:"600"}]},auth_webauthn_enabled:{key:"auth_webauthn_enabled",label:"Enable WebAuthn/Passkeys",description:"Allow passwordless authentication with FIDO2/WebAuthn credentials.",inputType:"boolean"},auth_webauthn_rp_id:{key:"auth_webauthn_rp_id",label:"Relying Party ID",description:"Usually your domain (e.g., example.com). Passkeys are bound to this.",inputType:"text"},auth_webauthn_rp_name:{key:"auth_webauthn_rp_name",label:"Relying Party Name",description:"Display name shown to users during passkey registration.",inputType:"text"},auth_webauthn_rp_origin:{key:"auth_webauthn_rp_origin",label:"Allowed Origins",description:"Comma-separated origins allowed for WebAuthn (e.g., https://example.com).",inputType:"text"},auth_instantlink_enabled:{key:"auth_instantlink_enabled",label:"Enable Instant Link",description:"Allow passwordless login via magic link sent to email.",inputType:"boolean"},auth_instantlink_expiry:{key:"auth_instantlink_expiry",label:"Link Expiry",description:"How long the magic link remains valid.",inputType:"duration",min:60,presets:[{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"},{label:"30 minutes",value:"1800"},{label:"1 hour",value:"3600"}]},auth_instantlink_rate_limit:{key:"auth_instantlink_rate_limit",label:"Rate Limit",description:"Maximum instant link requests per email per hour.",inputType:"select",presets:[{label:"3 per hour",value:"3"},{label:"5 per hour",value:"5"},{label:"10 per hour",value:"10"}]},feature_organizations:{key:"feature_organizations",label:"Organizations",description:"Enable multi-user organizations with role-based access.",inputType:"boolean"},feature_sso:{key:"feature_sso",label:"Enterprise SSO",description:"Enable SAML/OIDC single sign-on for enterprise customers.",inputType:"boolean"},feature_mfa:{key:"feature_mfa",label:"Two-Factor Authentication",description:"Allow users to enable TOTP-based two-factor authentication.",inputType:"boolean"},feature_wallet_signing:{key:"feature_wallet_signing",label:"Enable Embedded Wallet",description:"Enable the embedded wallet for transaction signing.",inputType:"boolean"},wallet_recovery_mode:{key:"wallet_recovery_mode",label:"Recovery Mode",description:"How users can recover their wallet if they lose access.",inputType:"select",presets:[{label:"Share C Only (Recommended)",value:"share_c_only"},{label:"Full Seed Phrase",value:"full_seed"},{label:"No Recovery",value:"none"}]},feature_credits:{key:"feature_credits",label:"Credit System",description:"Enable the deposits and credits system. Users can deposit tokens to receive platform credits.",inputType:"boolean"},security_cors_origins:{key:"security_cors_origins",label:"CORS Origins",description:"Allowed origins for cross-origin requests (comma-separated). Empty = same origin only.",inputType:"text"},security_cookie_domain:{key:"security_cookie_domain",label:"Cookie Domain",description:"Domain for auth cookies. Empty uses the request origin.",inputType:"text"},security_cookie_secure:{key:"security_cookie_secure",label:"Secure Cookies",description:"Require HTTPS for cookies. Disable only for local development.",inputType:"boolean"},security_cookie_same_site:{key:"security_cookie_same_site",label:"Cookie SameSite",description:'SameSite policy for cookies. Use "none" only if needed for cross-site embeds.',inputType:"select",presets:[{label:"Strict",value:"strict"},{label:"Lax (Recommended)",value:"lax"},{label:"None (cross-site)",value:"none"}]},security_session_timeout:{key:"security_session_timeout",label:"Session Timeout",description:"How long sessions remain valid before requiring re-authentication.",inputType:"duration",min:300,presets:[{label:"1 hour",value:"3600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"30 days",value:"2592000"}]},security_jwt_issuer:{key:"security_jwt_issuer",label:"JWT Issuer",description:"Issuer claim for JWTs. Empty uses the server URL.",inputType:"text"},security_jwt_audience:{key:"security_jwt_audience",label:"JWT Audience",description:"Audience claim for JWTs. Empty uses default.",inputType:"text"},email_provider:{key:"email_provider",label:"Email Provider",description:"Select your email service provider for automatic configuration.",inputType:"select",presets:[{label:"Mailgun",value:"mailgun"},{label:"SendGrid",value:"sendgrid"},{label:"Postmark",value:"postmark"},{label:"AWS SES",value:"ses"},{label:"Resend",value:"resend"},{label:"Custom SMTP",value:"custom"}]},email_smtp_host:{key:"email_smtp_host",label:"SMTP Host",description:"SMTP server hostname (e.g., smtp.sendgrid.net).",inputType:"text"},email_smtp_port:{key:"email_smtp_port",label:"SMTP Port",description:"SMTP server port. Common: 587 (TLS), 465 (SSL), 25 (unencrypted).",inputType:"select",presets:[{label:"587 (TLS)",value:"587"},{label:"465 (SSL)",value:"465"},{label:"25 (Plain)",value:"25"}]},email_smtp_user:{key:"email_smtp_user",label:"SMTP Username",description:"Username for SMTP authentication.",inputType:"text"},email_smtp_password:{key:"email_smtp_password",label:"API Key",description:"API key or password for your email provider.",inputType:"secret"},email_smtp_tls:{key:"email_smtp_tls",label:"Use TLS",description:"Enable TLS encryption for SMTP connections.",inputType:"boolean"},email_from_address:{key:"email_from_address",label:"From Address",description:"Default sender email address (e.g., noreply@example.com).",inputType:"text"},email_from_name:{key:"email_from_name",label:"From Name",description:'Default sender display name (e.g., "My App").',inputType:"text"},webhook_enabled:{key:"webhook_enabled",label:"Enable Webhooks",description:"Send notifications to a Discord or Slack webhook URL.",inputType:"boolean"},webhook_url:{key:"webhook_url",label:"Webhook URL",description:"Discord or Slack webhook URL to receive notifications.",inputType:"text",placeholder:"https://discord.com/api/webhooks/..."},webhook_notify_registrations:{key:"webhook_notify_registrations",label:"New Registrations",description:"Notify when a new user registers.",inputType:"boolean"},webhook_notify_signins:{key:"webhook_notify_signins",label:"Sign-Ins",description:"Notify when a user signs in.",inputType:"boolean"},webhook_notify_deposits:{key:"webhook_notify_deposits",label:"Deposits",description:"Notify when a user makes a deposit.",inputType:"boolean"},server_frontend_url:{key:"server_frontend_url",label:"Frontend URL",description:"URL of your frontend app (for redirects and email links).",inputType:"text"},server_base_path:{key:"server_base_path",label:"Base Path",description:"Base path for auth endpoints (e.g., /auth).",inputType:"text"},server_trust_proxy:{key:"server_trust_proxy",label:"Trust Proxy",description:"Trust X-Forwarded-For headers. Enable if behind a reverse proxy.",inputType:"boolean"},server_cedros_pay_api_key:{key:"server_cedros_pay_api_key",label:"Cedros Pay API Key",description:"API key for Cedros Pay to authenticate with this server. Copy this into your Cedros Pay settings.",inputType:"secret"},jupiter_api_key:{key:"jupiter_api_key",label:"Jupiter API Key",description:'API key for Jupiter Ultra API (gasless swaps). Get a free key at <a href="https://portal.jup.ag" target="_blank" rel="noopener">portal.jup.ag</a>.',inputType:"secret"},server_metrics_api_key:{key:"server_metrics_api_key",label:"Metrics API Key",description:"API key for Prometheus/Grafana to scrape the /metrics endpoint. Use with Authorization: Bearer header.",inputType:"secret"},server_log_level:{key:"server_log_level",label:"Log Level",description:"Minimum severity level for log output. Lower levels are more verbose.",inputType:"select",presets:[{label:"Trace (most verbose)",value:"trace"},{label:"Debug",value:"debug"},{label:"Info",value:"info"},{label:"Warn",value:"warn"},{label:"Error (least verbose)",value:"error"}]},server_log_format:{key:"server_log_format",label:"Log Format",description:"Output format for log messages.",inputType:"select",presets:[{label:"JSON (structured)",value:"json"},{label:"Pretty (human-readable)",value:"pretty"}]},server_environment:{key:"server_environment",label:"Environment",description:"Deployment environment. Affects default behaviors and log verbosity.",inputType:"select",presets:[{label:"Development",value:"development"},{label:"Staging",value:"staging"},{label:"Production",value:"production"}]},privacy_period_secs:{key:"privacy_period_secs",label:"Privacy Period",description:"How long deposits are held before withdrawal to provide timing privacy. Longer periods provide better privacy but delay user access to funds.",inputType:"duration",min:0,presets:[{label:"Disabled",value:"0"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"14 days",value:"1209600"},{label:"30 days",value:"2592000"}],warningThreshold:{below:3600,message:"Very short privacy periods may not provide adequate timing protection."}},treasury_wallet_address:{key:"treasury_wallet_address",label:"Treasury Wallet Address",description:"Solana wallet address where funds are sent. Used for privacy cash withdrawals, micro payment batches, and direct payments.",inputType:"text",placeholder:"e.g., 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU"},withdrawal_poll_interval_secs:{key:"withdrawal_poll_interval_secs",label:"Worker Poll Interval",description:"How often the withdrawal worker checks for deposits ready to process. Lower values process faster but increase server load.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"}],warningThreshold:{below:60,message:"Polling more than once per minute may cause excessive load."}},withdrawal_batch_size:{key:"withdrawal_batch_size",label:"Batch Size",description:"Maximum number of withdrawals to process in a single batch. Higher values improve throughput but may cause timeouts.",inputType:"select",min:1,max:100,presets:[{label:"1 (Sequential)",value:"1"},{label:"5",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100 (Max)",value:"100"}]},withdrawal_timeout_secs:{key:"withdrawal_timeout_secs",label:"Transaction Timeout",description:"How long to wait for a withdrawal transaction to confirm before considering it failed.",inputType:"duration",min:30,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"2 minutes",value:"120"},{label:"5 minutes",value:"300"}],warningThreshold:{below:30,message:"Very short timeouts may cause premature failure on slow networks."}},withdrawal_max_retries:{key:"withdrawal_max_retries",label:"Max Retries",description:"Number of times to retry a failed withdrawal before marking it as permanently failed.",inputType:"select",min:0,max:10,presets:[{label:"0 (No retries)",value:"0"},{label:"1",value:"1"},{label:"3 (Recommended)",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},withdrawal_percentage:{key:"withdrawal_percentage",label:"Withdrawal Percentage",description:"Percentage of ready funds to withdraw each cycle. Lower values spread withdrawals over time for better privacy.",inputType:"percentage",min:1,max:100,step:5,presets:[{label:"25%",value:"25"},{label:"50%",value:"50"},{label:"75%",value:"75"},{label:"100% (All at once)",value:"100"}],warningThreshold:{above:75,message:"High percentages may reduce timing privacy by processing most withdrawals together."}},partial_withdrawal_count:{key:"partial_withdrawal_count",label:"Partial Withdrawals",description:"Maximum partial withdrawals per batch. Partial withdrawals add noise to timing analysis. Set to 0 to disable.",inputType:"select",min:0,presets:[{label:"Disabled",value:"0"},{label:"1",value:"1"},{label:"3",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},partial_withdrawal_min_lamports:{key:"partial_withdrawal_min_lamports",label:"Min Balance for Partial",description:"Minimum account balance (in lamports) required before partial withdrawals are considered. 1 SOL = 1,000,000,000 lamports.",inputType:"select",min:0,presets:[{label:"0.1 SOL",value:"100000000"},{label:"0.5 SOL",value:"500000000"},{label:"1 SOL",value:"1000000000"},{label:"5 SOL",value:"5000000000"},{label:"10 SOL",value:"10000000000"}]},rate_limit_auth:{key:"rate_limit_auth",label:"Auth Request Limit",description:"Maximum authentication attempts (login, register, password reset) per IP per window. Protects against brute force attacks.",inputType:"select",min:1,unit:"requests",presets:[{label:"5 (Strict)",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"20",value:"20"},{label:"50 (Permissive)",value:"50"}],warningThreshold:{above:20,message:"High auth limits may allow brute force attempts."}},rate_limit_general:{key:"rate_limit_general",label:"General Request Limit",description:"Maximum general API requests per IP per window. Affects all non-auth endpoints.",inputType:"select",min:1,unit:"requests",presets:[{label:"30",value:"30"},{label:"60 (Recommended)",value:"60"},{label:"120",value:"120"},{label:"300",value:"300"}]},rate_limit_credit:{key:"rate_limit_credit",label:"Credit Request Limit",description:"Maximum credit/balance check requests per IP per window. Higher for apps that poll balance frequently.",inputType:"select",min:1,unit:"requests",presets:[{label:"10",value:"10"},{label:"30 (Recommended)",value:"30"},{label:"60",value:"60"},{label:"120",value:"120"}]},rate_limit_window:{key:"rate_limit_window",label:"Rate Limit Window",description:'Time window for rate limiting. All limits above are "per window". Shorter windows are stricter.',inputType:"duration",min:1,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"}]},solana_rpc_url:{key:"solana_rpc_url",label:"Solana RPC URL",description:'Get a fast RPC endpoint from <a href="https://helius.dev" target="_blank" rel="noopener">Helius</a> or <a href="https://quicknode.com" target="_blank" rel="noopener">QuickNode</a>.',inputType:"text",placeholder:"https://api.mainnet-beta.solana.com"},solana_network:{key:"solana_network",label:"Solana Network",description:"The Solana network to use for deposits and withdrawals.",inputType:"select",presets:[{label:"Mainnet",value:"mainnet-beta"},{label:"Devnet",value:"devnet"}]},deposit_privacy_enabled:{key:"deposit_privacy_enabled",label:"Enable Private Deposits",description:"When enabled, deposits are held for a privacy period before withdrawal. Provides timing privacy but delays fund availability.",inputType:"boolean"},deposit_company_token:{key:"deposit_company_token",label:"Platform Token",description:"The token that represents platform credits. Deposits are converted to this token. Common choices: USDC, SOL.",inputType:"select",presets:[{label:"USDC",value:"USDC"},{label:"USDT",value:"USDT"},{label:"SOL",value:"SOL"},{label:"EURC",value:"EURC"}]},deposit_micro_enabled:{key:"deposit_micro_enabled",label:"SOL Micro Payments",description:"Allow small SOL deposits (under $10) that are batched together for efficiency.",inputType:"boolean"},deposit_gasless_swap_enabled:{key:"deposit_gasless_swap_enabled",label:"Gasless Swap Payments",description:"Allow deposits via Jupiter swaps.",inputType:"boolean"},deposit_min_usd:{key:"deposit_min_usd",label:"Minimum Deposit",description:"Minimum deposit amount in USD equivalent.",inputType:"select",unit:"USD",presets:[{label:"$1",value:"1"},{label:"$5",value:"5"},{label:"$10",value:"10"},{label:"$25",value:"25"}]},deposit_max_usd:{key:"deposit_max_usd",label:"Maximum Deposit",description:"Maximum deposit amount per transaction in USD equivalent. Set to 0 for unlimited.",inputType:"select",unit:"USD",presets:[{label:"Unlimited",value:"0"},{label:"$1,000",value:"1000"},{label:"$10,000",value:"10000"},{label:"$100,000",value:"100000"}]},deposit_show_explainer:{key:"deposit_show_explainer",label:"Show Explainer Screen",description:"Show the introductory explainer screen at the start of the deposit flow.",inputType:"boolean"},deposit_quick_action_tokens:{key:"deposit_quick_action_tokens",label:"Quick Action Tokens",description:"Comma-separated token symbols shown as quick action buttons. First token is the default.",inputType:"tokenSymbolList"},deposit_custom_tokens:{key:"deposit_custom_tokens",label:"Custom Dropdown Tokens",description:'Comma-separated token symbols shown in the "Custom" dropdown. Leave empty to show all.',inputType:"tokenSymbolList"},deposit_custom_tokens_json:{key:"deposit_custom_tokens_json",label:"Custom Token Definitions",description:"Add tokens beyond the built-in list. Define symbol, mint address, decimals, and logo URL.",inputType:"tokenList"},deposit_fee_policy:{key:"deposit_fee_policy",label:"Fee Policy",description:"Who pays deposit fees: company absorbs all, or user pays swap/privacy/all fees.",inputType:"select",presets:[{label:"Company Pays All",value:"company_pays_all"},{label:"User Pays Swap Fees",value:"user_pays_swap"},{label:"User Pays Privacy Fees",value:"user_pays_privacy"},{label:"User Pays All Fees",value:"user_pays_all"}]},privacy_fee_fixed_lamports:{key:"privacy_fee_fixed_lamports",label:"Privacy Fixed Fee",description:"Fixed fee for Privacy Cash deposits in lamports. 1 SOL = 1,000,000,000 lamports.",inputType:"select",unit:"lamports",presets:[{label:"0 SOL",value:"0"},{label:"0.001 SOL",value:"1000000"},{label:"0.005 SOL",value:"5000000"},{label:"0.006 SOL (Default)",value:"6000000"},{label:"0.01 SOL",value:"10000000"}]},privacy_fee_percent_bps:{key:"privacy_fee_percent_bps",label:"Privacy Percentage Fee",description:"Percentage fee for Privacy Cash deposits in basis points. 100 bps = 1%.",inputType:"select",unit:"bps",presets:[{label:"0%",value:"0"},{label:"0.25%",value:"25"},{label:"0.35% (Default)",value:"35"},{label:"0.5%",value:"50"},{label:"1%",value:"100"}]},swap_fee_fixed_lamports:{key:"swap_fee_fixed_lamports",label:"Swap Fixed Fee",description:"Fixed fee for Jupiter swaps in lamports. Covers transaction costs.",inputType:"select",unit:"lamports",presets:[{label:"0 SOL",value:"0"},{label:"0.001 SOL (Default)",value:"1000000"},{label:"0.002 SOL",value:"2000000"},{label:"0.005 SOL",value:"5000000"}]},swap_fee_percent_bps:{key:"swap_fee_percent_bps",label:"Swap Percentage Fee",description:"Percentage fee for Jupiter swaps in basis points. 100 bps = 1%.",inputType:"select",unit:"bps",presets:[{label:"0%",value:"0"},{label:"0.1% (Default)",value:"10"},{label:"0.25%",value:"25"},{label:"0.5%",value:"50"}]},company_fee_fixed_lamports:{key:"company_fee_fixed_lamports",label:"Company Fixed Fee",description:"Additional fixed processing fee in lamports. Set to 0 to disable.",inputType:"select",unit:"lamports",presets:[{label:"Disabled",value:"0"},{label:"0.001 SOL",value:"1000000"},{label:"0.005 SOL",value:"5000000"},{label:"0.01 SOL",value:"10000000"}]},company_fee_percent_bps:{key:"company_fee_percent_bps",label:"Company Percentage Fee",description:"Additional percentage processing fee in basis points. 100 bps = 1%.",inputType:"select",unit:"bps",presets:[{label:"Disabled",value:"0"},{label:"0.1%",value:"10"},{label:"0.25%",value:"25"},{label:"0.5%",value:"50"},{label:"1%",value:"100"}]},micro_batch_threshold_usd:{key:"micro_batch_threshold_usd",label:"Batch Threshold",description:"Minimum accumulated USD value before triggering a batch swap. Jupiter requires ~$10 minimum.",inputType:"select",unit:"USD",presets:[{label:"$10 (Minimum)",value:"10"},{label:"$25",value:"25"},{label:"$50",value:"50"},{label:"$100",value:"100"}]},micro_batch_poll_secs:{key:"micro_batch_poll_secs",label:"Batch Poll Interval",description:"How often to check for batchable micro deposits. Lower values process faster but increase load.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes (Default)",value:"300"},{label:"15 minutes",value:"900"},{label:"1 hour",value:"3600"}]},private_deposit_min_lamports:{key:"private_deposit_min_lamports",label:"Min Private Deposit",description:"Minimum amount for Privacy Cash deposits in lamports. Smaller deposits use micro batching.",inputType:"select",unit:"lamports",presets:[{label:"0.1 SOL",value:"100000000"},{label:"0.25 SOL (Default)",value:"250000000"},{label:"0.5 SOL",value:"500000000"},{label:"1 SOL",value:"1000000000"}]},withdrawal_min_lamports:{key:"withdrawal_min_lamports",label:"Min Withdrawal Amount",description:"Minimum amount to withdraw in lamports. Deposits below this remain pending. Fees are ~0.006 SOL + 0.35% + Jupiter.",inputType:"select",unit:"lamports",presets:[{label:"0.5 SOL",value:"500000000"},{label:"1 SOL (Default)",value:"1000000000"},{label:"2 SOL",value:"2000000000"},{label:"5 SOL",value:"5000000000"}],warningThreshold:{below:5e8,message:"Very small withdrawals may lose significant value to fees."}}},Or=["SOL","USDC","USDT","EURC","USD1","PYUSD","USDH","CASH","BONK","ORE"];function be({settings:s,edits:t,onChange:r,externalWarnings:a}){return e.jsx("div",{className:"cedros-settings-grid",children:s.map(n=>e.jsx(yo,{setting:n,editValue:t[n.key],onChange:r,externalWarning:a?.[n.key]},n.key))})}function yo({setting:s,editValue:t,onChange:r,externalWarning:a}){const n=bo[s.key],o=t??s.value,c=t!==void 0&&t!==s.value,l=n?.inputType==="boolean",d=i.useMemo(()=>{if(a)return a;if(!n?.warningThreshold)return null;const u=parseInt(o,10);if(isNaN(u))return null;const{above:f,below:m,message:h}=n.warningThreshold;return f!==void 0&&u>f||m!==void 0&&u<m?h:null},[o,n?.warningThreshold,a]);return n?e.jsx("div",{className:`cedros-setting-row ${c?"cedros-setting-row-changed":""} ${d?"cedros-setting-row-warning":""} ${l?"cedros-setting-row-toggle":""}`,children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-setting-control cedros-setting-control-toggle",children:[e.jsx(ft,{meta:n,value:o,onChange:u=>r(s.key,u)}),d&&e.jsx("div",{className:"cedros-setting-warning",children:d})]}),e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:n.label}),e.jsx("span",{className:"cedros-setting-description",dangerouslySetInnerHTML:{__html:n.description}})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:n.label}),e.jsx("span",{className:"cedros-setting-description",dangerouslySetInnerHTML:{__html:n.description}})]}),e.jsxs("div",{className:"cedros-setting-control",children:[e.jsx(ft,{meta:n,value:o,onChange:u=>r(s.key,u)}),d&&e.jsx("div",{className:"cedros-setting-warning",children:d})]})]})}):e.jsxs("div",{className:`cedros-setting-row ${c?"cedros-setting-row-changed":""}`,children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:s.key}),s.description&&e.jsx("span",{className:"cedros-setting-description",children:s.description})]}),e.jsx("div",{className:"cedros-setting-input-wrapper",children:e.jsx("input",{type:"text",value:o,onChange:u=>r(s.key,u.target.value),className:"cedros-setting-input"})})]})}function ft({meta:s,value:t,onChange:r}){switch(s.inputType){case"duration":return e.jsx(wo,{value:t,onChange:r,presets:s.presets,min:s.min});case"percentage":return e.jsx(xo,{value:t,onChange:r,min:s.min??1,max:s.max??100,step:s.step??5,presets:s.presets});case"select":return e.jsx(vo,{value:t,onChange:r,presets:s.presets??[],unit:s.unit});case"number":return e.jsx(jo,{value:t,onChange:r,min:s.min,max:s.max,unit:s.unit});case"tokenList":return e.jsx(No,{value:t,onChange:r});case"text":return e.jsx("input",{type:"text",value:t,onChange:a=>r(a.target.value),className:"cedros-setting-input",placeholder:s.label});case"boolean":return e.jsx(Ao,{value:t,onChange:r});case"secret":return e.jsx(ko,{value:t,onChange:r,multiline:s.multiline});case"tokenSymbolList":return e.jsx(So,{value:t,onChange:r});default:return e.jsx("input",{type:"text",value:t,onChange:a=>r(a.target.value),className:"cedros-setting-input"})}}function wo({value:s,onChange:t,presets:r,min:a=0}){const n=parseInt(s,10)||0,o=go(n),c=i.useCallback(d=>{d.target.value&&t(d.target.value)},[t]),l=i.useCallback(d=>{const u=Math.max(a,parseInt(d.target.value,10)||0);t(String(u))},[t,a]);return e.jsxs("div",{className:"cedros-duration-input",children:[r&&r.length>0&&e.jsxs("select",{value:r.find(d=>d.value===s)?.value??"",onChange:c,className:"cedros-setting-select",children:[e.jsx("option",{value:"",children:"Custom..."}),r.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))]}),e.jsxs("div",{className:"cedros-duration-custom",children:[e.jsx("input",{type:"number",value:n,onChange:l,min:a,className:"cedros-setting-input cedros-setting-input-sm"}),e.jsx("span",{className:"cedros-setting-unit",children:"seconds"}),e.jsxs("span",{className:"cedros-duration-display",children:["= ",o]})]})]})}function xo({value:s,onChange:t,min:r,max:a,step:n,presets:o}){const c=parseInt(s,10)||r,l=i.useCallback(u=>{t(u.target.value)},[t]),d=i.useCallback(u=>{t(u)},[t]);return e.jsxs("div",{className:"cedros-percentage-input",children:[e.jsxs("div",{className:"cedros-percentage-slider-row",children:[e.jsx("input",{type:"range",value:c,onChange:l,min:r,max:a,step:n,className:"cedros-percentage-slider"}),e.jsxs("span",{className:"cedros-percentage-value",children:[c,"%"]})]}),o&&o.length>0&&e.jsx("div",{className:"cedros-preset-buttons",children:o.map(u=>e.jsx("button",{type:"button",className:`cedros-preset-button ${u.value===s?"cedros-preset-button-active":""}`,onClick:()=>d(u.value),children:u.label},u.value))})]})}function vo({value:s,onChange:t,presets:r,unit:a}){const n=!r.some(l=>l.value===s),o=i.useCallback(l=>{l.target.value!=="__custom__"&&t(l.target.value)},[t]),c=i.useCallback(l=>{t(l.target.value)},[t]);return e.jsxs("div",{className:"cedros-select-input",children:[e.jsxs("select",{value:n?"__custom__":s,onChange:o,className:"cedros-setting-select",children:[r.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value)),e.jsx("option",{value:"__custom__",children:"Custom..."})]}),n&&e.jsxs("div",{className:"cedros-select-custom",children:[e.jsx("input",{type:"number",value:s,onChange:c,className:"cedros-setting-input cedros-setting-input-sm"}),a&&e.jsx("span",{className:"cedros-setting-unit",children:a})]})]})}function jo({value:s,onChange:t,min:r,max:a,unit:n}){const o=i.useCallback(c=>{t(c.target.value)},[t]);return e.jsxs("div",{className:"cedros-number-input",children:[e.jsx("input",{type:"number",value:s,onChange:o,min:r,max:a,className:"cedros-setting-input"}),n&&e.jsx("span",{className:"cedros-setting-unit",children:n})]})}function Ao({value:s,onChange:t}){const r=s==="true",a=i.useCallback(()=>{t(r?"false":"true")},[r,t]);return e.jsxs("button",{type:"button",role:"switch","aria-checked":r,className:`cedros-toggle ${r?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:a,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:r?"Enabled":"Disabled"})]})}function ko({value:s,onChange:t,multiline:r}){const[a,n]=i.useState(!1),[o,c]=i.useState(!1),l=s&&s.length>0,d=i.useCallback(()=>{n(!0),c(!0)},[]),u=i.useCallback(()=>{n(!1),c(!1)},[]),f=i.useCallback(m=>{t(m.target.value)},[t]);return!a&&l?e.jsxs("div",{className:"cedros-secret-input cedros-secret-input-masked",children:[e.jsx("span",{className:"cedros-secret-masked",children:"•".repeat(Math.min(s.length,20))}),e.jsx("button",{type:"button",className:"cedros-secret-edit-btn",onClick:d,children:"Edit"})]}):e.jsxs("div",{className:"cedros-secret-input",children:[r?e.jsx("textarea",{value:s,onChange:f,className:"cedros-setting-input cedros-setting-textarea",placeholder:"Enter secret value...",rows:4}):e.jsx("input",{type:o?"text":"password",value:s,onChange:f,className:"cedros-setting-input",placeholder:"Enter secret value..."}),e.jsxs("div",{className:"cedros-secret-actions",children:[!r&&e.jsx("button",{type:"button",className:"cedros-secret-toggle-btn",onClick:()=>c(!o),children:o?"Hide":"Show"}),a&&e.jsx("button",{type:"button",className:"cedros-secret-done-btn",onClick:u,children:"Done"})]})]})}function No({value:s,onChange:t}){const r=i.useMemo(()=>{try{return JSON.parse(s||"[]")}catch{return[]}},[s]),a=i.useCallback(l=>{t(JSON.stringify(l))},[t]),n=i.useCallback(()=>{a([...r,{symbol:"",mint:"",decimals:6}])},[r,a]),o=i.useCallback((l,d,u)=>{const f=[...r];f[l]={...f[l],[d]:u},a(f)},[r,a]),c=i.useCallback(l=>{a(r.filter((d,u)=>u!==l))},[r,a]);return e.jsxs("div",{className:"cedros-token-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Built-in tokens:"}),e.jsx("div",{className:"cedros-token-presets-list",children:Or.map(l=>e.jsx("span",{className:"cedros-token-preset-chip",children:l},l))})]}),r.length===0&&e.jsx("p",{className:"cedros-token-list-empty",children:"No custom tokens added. Use the built-in tokens above or add your own."}),r.map((l,d)=>e.jsxs("div",{className:"cedros-token-row",children:[e.jsxs("div",{className:"cedros-token-row-fields",children:[e.jsx("input",{type:"text",placeholder:"Symbol",value:l.symbol,onChange:u=>o(d,"symbol",u.target.value.toUpperCase()),className:"cedros-setting-input cedros-token-input-symbol",maxLength:10}),e.jsx("input",{type:"text",placeholder:"Mint address",value:l.mint,onChange:u=>o(d,"mint",u.target.value),className:"cedros-setting-input cedros-token-input-mint"}),e.jsx("input",{type:"number",placeholder:"Decimals",value:l.decimals,onChange:u=>o(d,"decimals",parseInt(u.target.value,10)||0),className:"cedros-setting-input cedros-token-input-decimals",min:0,max:18}),e.jsx("input",{type:"text",placeholder:"Logo URL (optional)",value:l.logoUrl||"",onChange:u=>o(d,"logoUrl",u.target.value||void 0),className:"cedros-setting-input cedros-token-input-logo"})]}),e.jsx("button",{type:"button",className:"cedros-token-remove-btn",onClick:()=>c(d),title:"Remove token",children:"×"})]},d)),e.jsx("button",{type:"button",className:"cedros-token-add-btn",onClick:n,children:"+ Add Token"})]})}function So({value:s,onChange:t}){const r=i.useMemo(()=>s.split(",").map(o=>o.trim()).filter(Boolean),[s]),a=i.useCallback(o=>{if(!o||r.includes(o))return;const c=[...r,o].join(", ");t(c)},[r,t]),n=i.useCallback(o=>{const c=r.filter(l=>l!==o).join(", ");t(c)},[r,t]);return e.jsxs("div",{className:"cedros-token-symbol-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Click to add:"}),e.jsx("div",{className:"cedros-token-presets-list",children:Or.map(o=>{const c=r.includes(o);return e.jsxs("button",{type:"button",className:`cedros-token-preset-chip ${c?"cedros-token-preset-chip-selected":""}`,onClick:()=>c?n(o):a(o),title:c?`Remove ${o}`:`Add ${o}`,children:[o,c&&e.jsx("span",{className:"cedros-token-chip-check",children:"✓"})]},o)})})]}),e.jsx("input",{type:"text",value:s,onChange:o=>t(o.target.value),className:"cedros-setting-input",placeholder:"USDC, SOL, BONK..."})]})}function Pe({status:s,error:t}){return s==="idle"?null:e.jsxs("div",{className:`cedros-autosave-status cedros-autosave-status--${s}`,children:[s==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-autosave-dot"}),e.jsx("span",{children:"Unsaved changes"})]}),s==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-autosave-spinner"}),e.jsx("span",{children:"Saving..."})]}),s==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-autosave-check",children:"✓"}),e.jsx("span",{children:"Saved"})]}),s==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-autosave-error-icon",children:"!"}),e.jsx("span",{children:t||"Save failed"})]})]})}function os({title:s,description:t,categories:r,className:a=""}){const{settings:n,edits:o,isLoading:c,autosaveStatus:l,autosaveError:d,error:u,fetchSettings:f,handleChange:m}=Ee();i.useEffect(()=>{f()},[f]);const h=r.filter(b=>n[b]?.length>0);return c&&Object.keys(n).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${a}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):u?e.jsx("div",{className:`cedros-system-settings ${a}`,children:e.jsx(N.ErrorMessage,{error:u.message})}):e.jsxs("div",{className:`cedros-system-settings ${a}`,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:s}),e.jsx("p",{className:"cedros-settings-page-description",children:t})]}),e.jsx(Pe,{status:l,error:d})]}),h.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsx("p",{children:"No settings found for this section."})}):h.map(b=>e.jsx(be,{settings:n[b],edits:o,onChange:m},b))]})}function Co(){const{config:s,_internal:t}=N.useCedrosLogin(),r=s.serverUrl,a=i.useRef(t?.getAccessToken??(()=>null));a.current=t?.getAccessToken??(()=>null);const[n,o]=i.useState([]),[c,l]=i.useState(0),[d,u]=i.useState(!1),[f,m]=i.useState(null),h=i.useCallback(()=>{const y=a.current();return{"Content-Type":"application/json",...y?{Authorization:`Bearer ${y}`}:{}}},[]),b=i.useCallback(async(y,A=50,v=0)=>{u(!0),m(null);try{const S=new URLSearchParams;y&&S.set("org_id",y),S.set("limit",String(A)),S.set("offset",String(v));const w=await fetch(`${r}/admin/sso-providers?${S}`,{headers:h()});if(!w.ok){const T=await w.json().catch(()=>({}));throw new Error(T.error||`Failed to fetch SSO providers: ${w.status}`)}const C=await w.json();return o(C.providers),l(C.total),C}catch(S){const w=S instanceof Error?S:new Error(String(S));throw m(w),w}finally{u(!1)}},[r,h]),g=i.useCallback(async y=>{u(!0),m(null);try{const A=await fetch(`${r}/admin/sso-providers`,{method:"POST",headers:h(),body:JSON.stringify(y)});if(!A.ok){const S=await A.json().catch(()=>({}));throw new Error(S.error||`Failed to create SSO provider: ${A.status}`)}const v=await A.json();return o(S=>[...S,v]),l(S=>S+1),v}catch(A){const v=A instanceof Error?A:new Error(String(A));throw m(v),v}finally{u(!1)}},[r,h]),p=i.useCallback(async(y,A)=>{u(!0),m(null);try{const v=await fetch(`${r}/admin/sso-providers/${y}`,{method:"PUT",headers:h(),body:JSON.stringify(A)});if(!v.ok){const w=await v.json().catch(()=>({}));throw new Error(w.error||`Failed to update SSO provider: ${v.status}`)}const S=await v.json();return o(w=>w.map(C=>C.id===y?S:C)),S}catch(v){const S=v instanceof Error?v:new Error(String(v));throw m(S),S}finally{u(!1)}},[r,h]),x=i.useCallback(async y=>{u(!0),m(null);try{const A=await fetch(`${r}/admin/sso-providers/${y}`,{method:"DELETE",headers:h()});if(!A.ok){const v=await A.json().catch(()=>({}));throw new Error(v.error||`Failed to delete SSO provider: ${A.status}`)}o(v=>v.filter(S=>S.id!==y)),l(v=>v-1)}catch(A){const v=A instanceof Error?A:new Error(String(A));throw m(v),v}finally{u(!1)}},[r,h]),j=i.useCallback(async(y,A)=>p(y,{enabled:A}),[p]);return{providers:n,total:c,isLoading:d,error:f,fetchProviders:b,createProvider:g,updateProvider:p,deleteProvider:x,toggleProvider:j}}class qr{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async listOrgs(){try{return(await this.client.get("/orgs")).orgs.map(r=>({...r,membership:{orgId:r.id,role:r.role}}))}catch(t){throw N.handleApiError(t,"Failed to list organizations")}}async getOrg(t){try{return await this.client.get(`/orgs/${t}`)}catch(r){throw N.handleApiError(r,"Failed to get organization")}}async createOrg(t){try{return await this.client.post("/orgs",t)}catch(r){throw N.handleApiError(r,"Failed to create organization")}}async updateOrg(t,r){try{return await this.client.patch(`/orgs/${t}`,r)}catch(a){throw N.handleApiError(a,"Failed to update organization")}}async deleteOrg(t){try{await this.client.delete(`/orgs/${t}`)}catch(r){throw N.handleApiError(r,"Failed to delete organization")}}async authorize(t){try{return await this.client.post("/authorize",t)}catch(r){throw N.handleApiError(r,"Failed to check authorization")}}async getPermissions(t){try{return await this.client.post("/permissions",{orgId:t})}catch(r){throw N.handleApiError(r,"Failed to get permissions")}}}const ys="cedros_active_org";function _o(s){try{return localStorage.getItem(s)}catch{return null}}function gt(s,t){try{localStorage.setItem(s,t)}catch{}}function is(){const{config:s,user:t,authState:r,_internal:a}=N.useCedrosLogin(),n=typeof window<"u"&&!!window.localStorage,[o,c]=i.useState([]),[l,d]=i.useState(null),[u,f]=i.useState([]),[m,h]=i.useState(null),[b,g]=i.useState(!1),[p,x]=i.useState(null),j=i.useMemo(()=>new qr(s.serverUrl,s.requestTimeout,s.retryAttempts,a?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,a]),y=i.useRef(j);i.useEffect(()=>{y.current=j},[j]);const A=i.useCallback(async E=>{try{const P=await y.current.getPermissions(E);f(P.permissions),h(P.role)}catch{f([]),h(null)}},[]),v=i.useCallback(async()=>{if(r!=="authenticated"||!t){c([]),d(null),f([]),h(null);return}g(!0),x(null);try{const E=await y.current.listOrgs();c(E);const P=n?_o(ys):null;let k=E.find(_=>_.id===P);!k&&E.length>0&&(k=E.find(_=>_.isPersonal)||E[0]),k?(d(k),n&&gt(ys,k.id),await A(k.id)):(d(null),f([]),h(null))}catch(E){x(E)}finally{g(!1)}},[r,t,A,n]),S=i.useCallback(async E=>{const P=o.find(k=>k.id===E);if(!P){x({code:"UNKNOWN_ERROR",message:"Organization not found"});return}d(P),n&&gt(ys,E),await A(E)},[o,A,n]),w=i.useCallback(async E=>{g(!0),x(null);try{const P=await y.current.createOrg(E);return await v(),P}catch(P){throw x(P),P}finally{g(!1)}},[v]),C=i.useCallback(async(E,P)=>{g(!0),x(null);try{const k=await y.current.updateOrg(E,P);return await v(),k}catch(k){throw x(k),k}finally{g(!1)}},[v]),T=i.useCallback(async E=>{g(!0),x(null);try{await y.current.deleteOrg(E),await v()}catch(P){throw x(P),P}finally{g(!1)}},[v]),L=i.useCallback(E=>u.includes(E),[u]);return{orgs:o,activeOrg:l,permissions:u,role:m,isLoading:b,error:p,fetchOrgs:v,switchOrg:S,createOrg:w,updateOrg:C,deleteOrg:T,hasPermission:L}}function Eo({className:s}){const{providers:t,isLoading:r,error:a,fetchProviders:n,createProvider:o,updateProvider:c,deleteProvider:l,toggleProvider:d}=Co(),{activeOrg:u}=is(),[f,m]=i.useState("list"),[h,b]=i.useState(null),[g,p]=i.useState(null);i.useEffect(()=>{n(u?.id)},[n,u?.id]);const x=()=>{b(null),p(null),m("add")},j=w=>{b(w),p(null),m("edit")},y=()=>{m("list"),b(null),p(null)},A=async w=>{if(confirm(`Delete SSO provider "${w.name}"? This cannot be undone.`))try{await l(w.id)}catch{}},v=async w=>{try{await d(w.id,!w.enabled)}catch{}},S=async w=>{p(null);try{f==="add"?await o(w):h&&await c(h.id,w),m("list"),b(null)}catch(C){p(C instanceof Error?C.message:"Failed to save provider")}};return r&&t.length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading SSO providers..."})]}):f==="add"||f==="edit"?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(To,{provider:h,orgId:u?.id,error:g,isLoading:r,onSave:S,onCancel:y})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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:"SSO Providers"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure OIDC identity providers for enterprise single sign-on."})]}),e.jsx("button",{type:"button",className:"cedros-btn cedros-btn-primary",onClick:x,children:"Add Provider"})]}),a&&e.jsx(N.ErrorMessage,{error:a.message}),t.length===0?e.jsxs("div",{className:"cedros-system-settings-empty",children:[e.jsx("p",{children:"No SSO providers configured."}),e.jsx("p",{className:"cedros-text-muted",children:"Add an OIDC provider like Okta, Azure AD, or Auth0 to enable enterprise SSO."})]}):e.jsx("div",{className:"cedros-sso-provider-list",children:t.map(w=>e.jsx(Po,{provider:w,onEdit:()=>j(w),onDelete:()=>A(w),onToggle:()=>v(w)},w.id))})]})}function Po({provider:s,onEdit:t,onDelete:r,onToggle:a}){return e.jsxs("div",{className:`cedros-sso-provider-card ${s.enabled?"":"cedros-sso-provider-card--disabled"}`,children:[e.jsxs("div",{className:"cedros-sso-provider-card-header",children:[e.jsxs("div",{className:"cedros-sso-provider-card-info",children:[e.jsx("h3",{className:"cedros-sso-provider-card-name",children:s.name}),e.jsx("p",{className:"cedros-sso-provider-card-issuer",children:s.issuerUrl})]}),e.jsxs("button",{type:"button",role:"switch","aria-checked":s.enabled,className:`cedros-toggle ${s.enabled?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:a,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:s.enabled?"Enabled":"Disabled"})]})]}),e.jsxs("div",{className:"cedros-sso-provider-card-details",children:[e.jsxs("div",{className:"cedros-sso-provider-card-detail",children:[e.jsx("span",{className:"cedros-sso-provider-card-detail-label",children:"Client ID"}),e.jsx("code",{className:"cedros-sso-provider-card-detail-value",children:s.clientId})]}),s.emailDomain&&e.jsxs("div",{className:"cedros-sso-provider-card-detail",children:[e.jsx("span",{className:"cedros-sso-provider-card-detail-label",children:"Email Domain"}),e.jsxs("span",{className:"cedros-sso-provider-card-detail-value",children:["@",s.emailDomain]})]}),e.jsxs("div",{className:"cedros-sso-provider-card-detail",children:[e.jsx("span",{className:"cedros-sso-provider-card-detail-label",children:"Registration"}),e.jsx("span",{className:"cedros-sso-provider-card-detail-value",children:s.allowRegistration?"Allowed":"Existing users only"})]})]}),e.jsxs("div",{className:"cedros-sso-provider-card-actions",children:[e.jsx("button",{type:"button",className:"cedros-btn cedros-btn-ghost",onClick:t,children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-btn cedros-btn-ghost cedros-btn-danger",onClick:r,children:"Delete"})]})]})}function To({provider:s,orgId:t,error:r,isLoading:a,onSave:n,onCancel:o}){const c=!!s,[l,d]=i.useState(s?.name??""),[u,f]=i.useState(s?.issuerUrl??""),[m,h]=i.useState(s?.clientId??""),[b,g]=i.useState(""),[p,x]=i.useState(s?.emailDomain??""),[j,y]=i.useState(s?.allowRegistration??!0),[A,v]=i.useState(s?.enabled??!0),S=i.useCallback(w=>{if(w.preventDefault(),c){const C={name:l,issuerUrl:u,clientId:m,emailDomain:p||null,allowRegistration:j,enabled:A};b&&(C.clientSecret=b),n(C)}else{if(!t)return;n({orgId:t,name:l,issuerUrl:u,clientId:m,clientSecret:b,emailDomain:p||null,allowRegistration:j,enabled:A})}},[c,t,l,u,m,b,p,j,A,n]);return e.jsxs("form",{className:"cedros-sso-provider-form",onSubmit:S,children:[e.jsx("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:c?"Edit SSO Provider":"Add SSO Provider"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure an OIDC identity provider for enterprise single sign-on."})]})}),r&&e.jsx(N.ErrorMessage,{error:r}),e.jsxs("div",{className:"cedros-form-section",children:[e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{className:"cedros-form-label",htmlFor:"sso-name",children:"Provider Name"}),e.jsx("input",{id:"sso-name",type:"text",className:"cedros-form-input",value:l,onChange:w=>d(w.target.value),placeholder:"e.g., Okta, Azure AD",required:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{className:"cedros-form-label",htmlFor:"sso-issuer",children:"Issuer URL"}),e.jsx("input",{id:"sso-issuer",type:"url",className:"cedros-form-input",value:u,onChange:w=>f(w.target.value),placeholder:"https://your-org.okta.com",required:!0}),e.jsx("p",{className:"cedros-form-hint",children:"The OIDC issuer URL. Must support discovery at /.well-known/openid-configuration"})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{className:"cedros-form-label",htmlFor:"sso-client-id",children:"Client ID"}),e.jsx("input",{id:"sso-client-id",type:"text",className:"cedros-form-input",value:m,onChange:w=>h(w.target.value),placeholder:"OAuth client ID",required:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsxs("label",{className:"cedros-form-label",htmlFor:"sso-client-secret",children:["Client Secret ",c&&e.jsx("span",{className:"cedros-form-hint-inline",children:"(leave blank to keep current)"})]}),e.jsx("input",{id:"sso-client-secret",type:"password",className:"cedros-form-input",value:b,onChange:w=>g(w.target.value),placeholder:c?"••••••••":"OAuth client secret",required:!c})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{className:"cedros-form-label",htmlFor:"sso-email-domain",children:"Email Domain (optional)"}),e.jsx("input",{id:"sso-email-domain",type:"text",className:"cedros-form-input",value:p,onChange:w=>x(w.target.value),placeholder:"company.com"}),e.jsx("p",{className:"cedros-form-hint",children:"Restrict to users with emails from this domain"})]}),e.jsx("div",{className:"cedros-form-group",children:e.jsxs("label",{className:"cedros-form-checkbox",children:[e.jsx("input",{type:"checkbox",checked:j,onChange:w=>y(w.target.checked)}),e.jsx("span",{children:"Allow new user registration via SSO"})]})}),e.jsx("div",{className:"cedros-form-group",children:e.jsxs("label",{className:"cedros-form-checkbox",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:w=>v(w.target.checked)}),e.jsx("span",{children:"Enable this provider"})]})})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-btn cedros-btn-ghost",onClick:o,disabled:a,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-btn cedros-btn-primary",disabled:a,children:a?"Saving...":c?"Save Changes":"Add Provider"})]})]})}const bt=[{id:"email",label:"Email",categories:["auth.email"]},{id:"google",label:"Google",categories:["auth.google"]},{id:"apple",label:"Apple",categories:["auth.apple"]},{id:"solana",label:"Solana",categories:["auth.solana"]},{id:"passkeys",label:"Passkeys",categories:["auth.webauthn"]},{id:"instantlink",label:"Instant Link",categories:["auth.instantlink"]},{id:"sso",label:"SSO Providers",categories:[],isCustom:!0}];function Wr({className:s}){const{settings:t,edits:r,isLoading:a,autosaveStatus:n,autosaveError:o,error:c,fetchSettings:l,handleChange:d}=Ee(),[u,f]=i.useState("email");i.useEffect(()=>{l()},[l]);const m=bt.find(g=>g.id===u),h=i.useMemo(()=>{if(!m)return[];const g=[];for(const p of m.categories){const x=t[p]??[];g.push(...x)}return g},[t,m]),b=i.useMemo(()=>m?.keys?h.filter(g=>m.keys.includes(g.key)).sort((g,p)=>m.keys.indexOf(g.key)-m.keys.indexOf(p.key)):h,[h,m]);return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(N.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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:"Authentication"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure authentication providers and methods for user sign-in."})]}),e.jsx(Pe,{status:n,error:o})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:bt.map(g=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${u===g.id?"cedros-admin-tab-active":""}`,onClick:()=>f(g.id),"aria-selected":u===g.id,role:"tab",children:g.label},g.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:m?.isCustom?e.jsx(Eo,{}):b.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",m?.label??"this provider","."]})}):e.jsx(be,{settings:b,edits:r,onChange:d})})]})}const ws=["wallet_recovery_mode"];function $r({className:s}){const{settings:t,edits:r,isLoading:a,autosaveStatus:n,autosaveError:o,error:c,fetchSettings:l,handleChange:d,getEffectiveValue:u}=Ee();i.useEffect(()=>{l()},[l]);const m=(t.features??[]).filter(g=>ws.includes(g.key)).sort((g,p)=>ws.indexOf(g.key)-ws.indexOf(p.key)),h=u("feature_wallet_signing")==="true",b=()=>{d("feature_wallet_signing",h?"false":"true")};return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(N.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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:"Embedded Wallet"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure the embedded wallet for transaction signing."})]}),e.jsxs("div",{className:"cedros-settings-page-header-actions",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":h,className:`cedros-toggle ${h?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:b,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:h?"Enabled":"Disabled"})]}),e.jsx(Pe,{status:n,error:o})]})]}),e.jsx("div",{className:"cedros-admin-tab-content",children:m.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsx("p",{children:"No additional settings available."})}):e.jsx(be,{settings:m,edits:r,onChange:d})})]})}const Lo=["security","rate_limit"];function Mo({className:s}){return e.jsx(os,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:Lo,className:s})}const Do=["email"];function Ro({className:s}){return e.jsx(os,{title:"Email & SMTP",description:"Configure outbound email delivery for verification, password reset, and notifications.",categories:Do,className:s})}const Io=["webhook"];function Uo({className:s}){return e.jsx(os,{title:"Webhooks",description:"Configure HTTP webhook notifications for authentication events.",categories:Io,className:s})}const yt=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}],Fo={mailgun:"smtp.mailgun.org",sendgrid:"smtp.sendgrid.net",postmark:"smtp.postmarkapp.com",ses:"email-smtp.us-east-1.amazonaws.com",resend:"smtp.resend.com"},Bo=["email_provider","email_smtp_password","email_from_address","email_from_name"],Oo=["email_provider","email_smtp_host","email_smtp_port","email_smtp_user","email_smtp_password","email_smtp_tls","email_from_address","email_from_name"];function qo({className:s}){const{settings:t,edits:r,isLoading:a,autosaveStatus:n,autosaveError:o,error:c,fetchSettings:l,handleChange:d,getEffectiveValue:u}=Ee(),[f,m]=i.useState("email");i.useEffect(()=>{l()},[l]);const h=yt.find(y=>y.id===f),b=h?.category??"",p=(u("email_provider")||"custom")==="custom",x=i.useMemo(()=>{const y=t[b]??[];if(f!=="email")return y;const A=p?Oo:Bo;return y.filter(v=>A.includes(v.key)).sort((v,S)=>A.indexOf(v.key)-A.indexOf(S.key))},[t,b,f,p]),j=(y,A)=>{if(d(y,A),y==="email_provider"&&A!=="custom"){const v=Fo[A];v&&(d("email_smtp_host",v),d("email_smtp_port","587"),d("email_smtp_tls","true"))}};return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(N.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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 and webhook notifications."})]}),e.jsx(Pe,{status:n,error:o})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:yt.map(y=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${f===y.id?"cedros-admin-tab-active":""}`,onClick:()=>m(y.id),"aria-selected":f===y.id,role:"tab",children:y.label},y.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:x.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",h?.label??"this section","."]})}):e.jsx(be,{settings:x,edits:r,onChange:f==="email"?j:d})})]})}const wt=[{id:"deposits",label:"Deposits",categories:["deposit.general"],includeKeys:["deposit_company_token","deposit_max_usd","deposit_min_usd","deposit_micro_enabled","deposit_gasless_swap_enabled","solana_rpc_url","jupiter_api_key"]},{id:"tokens",label:"Component",categories:["deposit"],includeKeys:["deposit_show_explainer","deposit_quick_action_tokens","deposit_custom_tokens","deposit_custom_tokens_json"]},{id:"fees",label:"Fees",categories:["deposit"],includeKeys:["deposit_fee_policy","privacy_fee_fixed_lamports","privacy_fee_percent_bps","swap_fee_fixed_lamports","swap_fee_percent_bps","company_fee_fixed_lamports","company_fee_percent_bps","private_deposit_min_lamports"]},{id:"privacy",label:"Privacy",categories:["deposit.general","privacy","withdrawal"],includeKeys:["deposit_privacy_enabled","privacy_period_secs","withdrawal_percentage","withdrawal_min_lamports","partial_withdrawal_count","partial_withdrawal_min_lamports"],sections:[{title:"Privacy Pool Worker",description:"Background worker for processing withdrawals from the privacy cash pool.",keys:["withdrawal_poll_interval_secs","withdrawal_batch_size"]}]},{id:"treasury",label:"Treasury",categories:["withdrawal","deposit"],includeKeys:["treasury_wallet_address"],sections:[{title:"Micropayment Batch Worker",description:"Background worker for batching small SOL deposits together.",keys:["micro_batch_threshold_usd","micro_batch_poll_secs"]}]}];function zr({className:s}){const{settings:t,edits:r,isLoading:a,autosaveStatus:n,autosaveError:o,error:c,fetchSettings:l,handleChange:d,getEffectiveValue:u}=Ee(),[f,m]=i.useState("deposits");i.useEffect(()=>{l()},[l]);const h=wt.find(v=>v.id===f),b=i.useMemo(()=>{if(!h)return[];const v=[];for(const S of h.categories){const w=t[S]??[];v.push(...w)}return v},[t,h]),g=u("deposit_fee_policy")||"company_pays_all",p=i.useMemo(()=>{if(!h)return[];let v=b;if(h.includeKeys&&h.includeKeys.length>0?(v=v.filter(S=>h.includeKeys.includes(S.key)),v.sort((S,w)=>h.includeKeys.indexOf(S.key)-h.includeKeys.indexOf(w.key))):h.excludeKeys&&h.excludeKeys.length>0&&(v=v.filter(S=>!h.excludeKeys.includes(S.key))),h.id==="deposits"&&(parseFloat(u("deposit_min_usd"))||0)>10&&(v=v.filter(w=>w.key!=="deposit_micro_enabled")),h.id==="fees"){const S=["privacy_fee_fixed_lamports","privacy_fee_percent_bps","private_deposit_min_lamports"],w=["swap_fee_fixed_lamports","swap_fee_percent_bps"],C=["company_fee_fixed_lamports","company_fee_percent_bps"];v=v.filter(T=>T.key==="deposit_fee_policy"?!0:g==="company_pays_all"?!1:S.includes(T.key)?g==="user_pays_privacy"||g==="user_pays_all":w.includes(T.key)?g==="user_pays_swap"||g==="user_pays_all":C.includes(T.key)?g==="user_pays_all":!0)}return v},[b,h,u,g]),x=i.useCallback(v=>b.filter(S=>v.includes(S.key)).sort((S,w)=>v.indexOf(S.key)-v.indexOf(w.key)),[b]),j=i.useMemo(()=>{if(h?.id!=="deposits")return;const v={},S=parseFloat(u("deposit_min_usd"))||0,w=u("deposit_micro_enabled");return(w==="false"||w==="0"||w==="")&&S<10&&(v.deposit_min_usd="SOL micro payments must be enabled for minimum deposits under $10."),Object.keys(v).length>0?v:void 0},[h?.id,u]),y=u("feature_credits")==="true",A=()=>{d("feature_credits",y?"false":"true")};return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(N.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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:"Credit System"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure credit deposits, timed withdrawals, and privacy period settings."})]}),e.jsxs("div",{className:"cedros-settings-page-header-actions",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":y,className:`cedros-toggle ${y?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:A,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:y?"Enabled":"Disabled"})]}),e.jsx(Pe,{status:n,error:o})]})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:wt.map(v=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${f===v.id?"cedros-admin-tab-active":""}`,onClick:()=>m(v.id),"aria-selected":f===v.id,role:"tab",children:v.label},v.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:p.length===0&&!h?.sections?.length?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",h?.label??"this section","."]})}):e.jsxs(e.Fragment,{children:[p.length>0&&e.jsx(be,{settings:p,edits:r,onChange:d,externalWarnings:j}),h?.sections?.map(v=>{const S=x(v.keys);return S.length===0?null:e.jsxs("div",{className:"cedros-settings-subsection",children:[e.jsxs("div",{className:"cedros-settings-subsection-header",children:[e.jsx("h4",{className:"cedros-settings-subsection-title",children:v.title}),v.description&&e.jsx("p",{className:"cedros-settings-subsection-description",children:v.description})]}),e.jsx(be,{settings:S,edits:r,onChange:d})]},v.title)})]})})]})}const xt=[{id:"general",label:"Integrations",keys:["server_cedros_pay_api_key"]},{id:"logging",label:"Logging",keys:["server_log_level"]},{id:"metrics",label:"Metrics",keys:["server_metrics_api_key"]},{id:"security",label:"Security",categories:["security","features"],keys:["feature_mfa","security_cors_origins","security_session_timeout"]}];function Vr({className:s}){const{settings:t,edits:r,isLoading:a,autosaveStatus:n,autosaveError:o,error:c,fetchSettings:l,handleChange:d}=Ee(),[u,f]=i.useState("general");i.useEffect(()=>{l()},[l]);const m=xt.find(b=>b.id===u),h=i.useMemo(()=>{if(!m)return[];const b=m.categories??["server"],g=[];for(const p of b){const x=t[p]??[];g.push(...x)}return g.filter(p=>m.keys.includes(p.key)).sort((p,x)=>m.keys.indexOf(p.key)-m.keys.indexOf(x.key))},[t,m]);return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(N.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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 Server"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Server infrastructure settings. Some may be overridden by environment variables."})]}),e.jsx(Pe,{status:n,error:o})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:xt.map(b=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${u===b.id?"cedros-admin-tab-active":""}`,onClick:()=>f(b.id),"aria-selected":u===b.id,role:"tab",children:b.label},b.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:h.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",m?.label??"this section","."]})}):e.jsx(be,{settings:h,edits:r,onChange:d})})]})}class Wo{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async listMembers(t,r=50,a=0){try{const n=await this.client.get(`/orgs/${t}/members?limit=${r}&offset=${a}`);return{members:n.members.map(o=>({id:o.id,userId:o.userId,orgId:t,role:o.role,joinedAt:o.joinedAt,user:{id:o.userId,email:o.email,name:o.name}})),total:n.total}}catch(n){throw N.handleApiError(n,"Failed to list members")}}async updateMemberRole(t,r,a){try{return await this.client.patch(`/orgs/${t}/members/${r}`,a)}catch(n){throw N.handleApiError(n,"Failed to update member role")}}async removeMember(t,r){try{await this.client.delete(`/orgs/${t}/members/${r}`)}catch(a){throw N.handleApiError(a,"Failed to remove member")}}}function Hr(s){const{config:t,authState:r,_internal:a}=N.useCedrosLogin(),[n,o]=i.useState([]),[c,l]=i.useState(0),[d,u]=i.useState(!1),[f,m]=i.useState(null),h=i.useRef(void 0),b=i.useRef(0),g=i.useMemo(()=>new Wo(t.serverUrl,t.requestTimeout,t.retryAttempts,a?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,a]),p=i.useRef(g);p.current=g;const x=i.useCallback(async A=>{if(!s||r!=="authenticated"){o([]),l(0);return}u(!0),m(null);const v=++b.current;try{const{limit:S=50,offset:w=0}=A??{},C=await p.current.listMembers(s,S,w);if(v!==b.current)return;o(C.members),l(C.total)}catch(S){if(v!==b.current)return;m(S)}finally{v===b.current&&u(!1)}},[s,r]);i.useEffect(()=>{if(r!=="authenticated"){h.current=void 0;return}s!==h.current&&(h.current=s,x())},[s,r,x]);const j=i.useCallback(async(A,v)=>{if(!s)throw new Error("No organization selected");u(!0),m(null);try{await p.current.updateMemberRole(s,A,{role:v}),await x()}catch(S){throw m(S),S}finally{u(!1)}},[s,x]),y=i.useCallback(async A=>{if(!s)throw new Error("No organization selected");u(!0),m(null);try{await p.current.removeMember(s,A),await x()}catch(v){throw m(v),v}finally{u(!1)}},[s,x]);return{members:n,total:c,isLoading:d,error:f,fetchMembers:x,updateMemberRole:j,removeMember:y}}class $o{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async listInvites(t,r=50,a=0){try{const n=await this.client.get(`/orgs/${t}/invites?limit=${r}&offset=${a}`);return{invites:n.invites.map(o=>({id:o.id,orgId:o.orgId,email:o.email,role:o.role,invitedBy:o.invitedBy,createdAt:o.createdAt,expiresAt:o.expiresAt})),total:n.total}}catch(n){throw N.handleApiError(n,"Failed to list invites")}}async createInvite(t,r){try{return await this.client.post(`/orgs/${t}/invites`,r)}catch(a){throw N.handleApiError(a,"Failed to create invite")}}async cancelInvite(t,r){try{await this.client.delete(`/orgs/${t}/invites/${r}`)}catch(a){throw N.handleApiError(a,"Failed to cancel invite")}}async resendInvite(t,r){try{await this.client.post(`/orgs/${t}/invites/${r}/resend`,{})}catch(a){throw N.handleApiError(a,"Failed to resend invite")}}async acceptInvite(t){try{return await this.client.post("/invites/accept",t)}catch(r){throw N.handleApiError(r,"Failed to accept invite")}}}function Qr(s){const{config:t,authState:r,_internal:a}=N.useCedrosLogin(),[n,o]=i.useState([]),[c,l]=i.useState(0),[d,u]=i.useState(!1),[f,m]=i.useState(null),h=i.useRef(void 0),b=i.useRef(0),g=i.useMemo(()=>new $o(t.serverUrl,t.requestTimeout,t.retryAttempts,a?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,a]),p=i.useRef(g);p.current=g;const x=i.useCallback(async S=>{if(!s||r!=="authenticated"){o([]),l(0);return}u(!0),m(null);const w=++b.current;try{const{limit:C=50,offset:T=0}=S??{},L=await p.current.listInvites(s,C,T);if(w!==b.current)return;o(L.invites),l(L.total)}catch(C){if(w!==b.current)return;m(C)}finally{w===b.current&&u(!1)}},[s,r]);i.useEffect(()=>{if(r!=="authenticated"){h.current=void 0;return}s!==h.current&&(h.current=s,x())},[s,r,x]);const j=i.useCallback(async(S,w="member")=>{if(!s)throw new Error("No organization selected");u(!0),m(null);try{await p.current.createInvite(s,{email:S,role:w}),await x()}catch(C){throw m(C),C}finally{u(!1)}},[s,x]),y=i.useCallback(async S=>{if(!s)throw new Error("No organization selected");u(!0),m(null);try{await p.current.cancelInvite(s,S),await x()}catch(w){throw m(w),w}finally{u(!1)}},[s,x]),A=i.useCallback(async S=>{if(!s)throw new Error("No organization selected");u(!0),m(null);try{await p.current.resendInvite(s,S)}catch(w){throw m(w),w}finally{u(!1)}},[s]),v=i.useCallback(async S=>{u(!0),m(null);try{return await p.current.acceptInvite({token:S})}catch(w){throw m(w),w}finally{u(!1)}},[]);return{invites:n,total:c,isLoading:d,error:f,fetchInvites:x,createInvite:j,cancelInvite:y,resendInvite:A,acceptInvite:v}}const zo={organizations:!1,sso:!1,mfa:!1,walletSigning:!1,credits:!1,cedrosPay:!1};function Js(){const{settings:s,isLoading:t,error:r,fetchSettings:a,getValue:n}=Ue(),[o,c]=i.useState(!1);i.useEffect(()=>{o||(a(),c(!0))},[a,o]);const l=i.useCallback(m=>m===void 0?!1:m==="true"||m==="1",[]),d=i.useMemo(()=>Object.keys(s).length===0?zo:{organizations:l(n("feature_organizations")),sso:l(n("feature_sso")),mfa:l(n("feature_mfa")),walletSigning:l(n("feature_wallet_signing")),credits:l(n("feature_credits")),cedrosPay:l(n("feature_cedros_pay"))},[s,n,l]),u=i.useCallback(async()=>{await a()},[a]),f=i.useCallback(m=>d[m],[d]);return{features:d,isLoading:t,error:r,refetch:u,isEnabled:f}}class Vo{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async listUsers(t){try{const r=new URLSearchParams;t?.limit&&r.set("limit",String(t.limit)),t?.offset&&r.set("offset",String(t.offset));const a=r.toString(),n=`/admin/users${a?`?${a}`:""}`;return await this.client.get(n)}catch(r){throw N.handleApiError(r,"Failed to list users")}}async getUser(t){try{return await this.client.get(`/admin/users/${t}`)}catch(r){throw N.handleApiError(r,"Failed to get user")}}async setSystemAdmin(t,r){try{await this.client.patch(`/admin/users/${t}/system-admin`,{isAdmin:r})}catch(a){throw N.handleApiError(a,"Failed to update system admin status")}}async updateUser(t,r){try{return await this.client.patch(`/admin/users/${t}`,r)}catch(a){throw N.handleApiError(a,"Failed to update user")}}async deleteUser(t){try{await this.client.delete(`/admin/users/${t}`)}catch(r){throw N.handleApiError(r,"Failed to delete user")}}async forcePasswordReset(t){try{await this.client.post(`/admin/users/${t}/force-password-reset`,{})}catch(r){throw N.handleApiError(r,"Failed to send password reset email")}}async adjustCredits(t,r){try{await this.client.post(`/admin/users/${t}/credits`,r)}catch(a){throw N.handleApiError(a,"Failed to adjust credits")}}async getUserDeposits(t,r){try{const a=new URLSearchParams;r?.limit&&a.set("limit",String(r.limit)),r?.offset&&a.set("offset",String(r.offset));const n=a.toString(),o=`/admin/users/${t}/deposits${n?`?${n}`:""}`;return await this.client.get(o)}catch(a){throw N.handleApiError(a,"Failed to get user deposits")}}async getUserCredits(t,r){try{const a=new URLSearchParams;r?.limit&&a.set("limit",String(r.limit)),r?.offset&&a.set("offset",String(r.offset));const n=a.toString(),o=`/admin/users/${t}/credits${n?`?${n}`:""}`;return await this.client.get(o)}catch(a){throw N.handleApiError(a,"Failed to get user credits")}}async getUserWithdrawalHistory(t,r){try{const a=new URLSearchParams;r?.limit&&a.set("limit",String(r.limit)),r?.offset&&a.set("offset",String(r.offset));const n=a.toString(),o=`/admin/users/${t}/withdrawal-history${n?`?${n}`:""}`;return await this.client.get(o)}catch(a){throw N.handleApiError(a,"Failed to get user withdrawal history")}}async getUserChats(t,r){try{const a=new URLSearchParams;r?.limit&&a.set("limit",String(r.limit)),r?.offset&&a.set("offset",String(r.offset));const n=a.toString(),o=`/admin/users/${t}/chats${n?`?${n}`:""}`;return await this.client.get(o)}catch(a){throw N.handleApiError(a,"Failed to get user chat history")}}async getStats(){try{return await this.client.get("/admin/users/stats")}catch(t){throw N.handleApiError(t,"Failed to get user stats")}}}function ls(){const{config:s,_internal:t}=N.useCedrosLogin(),[r,a]=i.useState([]),[n,o]=i.useState(0),[c,l]=i.useState(!1),[d,u]=i.useState(null),[f,m]=i.useState({}),h=i.useMemo(()=>new Vo(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),b=i.useCallback(async P=>{l(!0),u(null),m(P||{});try{const k=await h.listUsers(P);return a(k.users),o(k.total),k}catch(k){const _=k instanceof Error?k:new Error("Failed to list users");throw u(_),_}finally{l(!1)}},[h]),g=i.useCallback(async P=>{l(!0),u(null);try{return await h.getUser(P)}catch(k){const _=k instanceof Error?k:new Error("Failed to get user");throw u(_),_}finally{l(!1)}},[h]),p=i.useCallback(async(P,k)=>{l(!0),u(null);try{await h.setSystemAdmin(P,k),a(_=>_.map(M=>M.id===P?{...M,isSystemAdmin:k}:M))}catch(_){const M=_ instanceof Error?_:new Error("Failed to update admin status");throw u(M),M}finally{l(!1)}},[h]),x=i.useCallback(async(P,k)=>{l(!0),u(null);try{const _=await h.updateUser(P,k);return a(M=>M.map(D=>D.id===P?_:D)),_}catch(_){const M=_ instanceof Error?_:new Error("Failed to update user");throw u(M),M}finally{l(!1)}},[h]),j=i.useCallback(async P=>{l(!0),u(null);try{await h.deleteUser(P),a(k=>k.filter(_=>_.id!==P)),o(k=>k-1)}catch(k){const _=k instanceof Error?k:new Error("Failed to delete user");throw u(_),_}finally{l(!1)}},[h]),y=i.useCallback(async P=>{l(!0),u(null);try{await h.forcePasswordReset(P)}catch(k){const _=k instanceof Error?k:new Error("Failed to send password reset");throw u(_),_}finally{l(!1)}},[h]),A=i.useCallback(async(P,k,_)=>{l(!0),u(null);try{await h.adjustCredits(P,{amount:k,reason:_})}catch(M){const D=M instanceof Error?M:new Error("Failed to adjust credits");throw u(D),D}finally{l(!1)}},[h]),v=i.useCallback(async(P,k)=>{l(!0),u(null);try{return await h.getUserDeposits(P,k)}catch(_){const M=_ instanceof Error?_:new Error("Failed to get user deposits");throw u(M),M}finally{l(!1)}},[h]),S=i.useCallback(async(P,k)=>{l(!0),u(null);try{return await h.getUserCredits(P,k)}catch(_){const M=_ instanceof Error?_:new Error("Failed to get user credits");throw u(M),M}finally{l(!1)}},[h]),w=i.useCallback(async(P,k)=>{l(!0),u(null);try{return await h.getUserWithdrawalHistory(P,k)}catch(_){const M=_ instanceof Error?_:new Error("Failed to get user withdrawal history");throw u(M),M}finally{l(!1)}},[h]),C=i.useCallback(async(P,k)=>{l(!0),u(null);try{return await h.getUserChats(P,k)}catch(_){const M=_ instanceof Error?_:new Error("Failed to get user chat history");throw u(M),M}finally{l(!1)}},[h]),T=i.useCallback(async()=>{l(!0),u(null);try{return await h.getStats()}catch(P){const k=P instanceof Error?P:new Error("Failed to get user stats");throw u(k),k}finally{l(!1)}},[h]),L=i.useCallback(async()=>{await b(f)},[b,f]),E=i.useCallback(()=>{u(null)},[]);return{users:r,total:n,isLoading:c,error:d,listUsers:b,getUser:g,setSystemAdmin:p,updateUser:x,deleteUser:j,forcePasswordReset:y,adjustCredits:A,getUserDeposits:v,getUserCredits:S,getUserWithdrawalHistory:w,getUserChats:C,getStats:T,refresh:L,clearError:E}}const Ho=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server"],Qo=["pay-products","pay-subscriptions","pay-transactions","pay-coupons","pay-refunds","pay-storefront","pay-ai","pay-payment","pay-messaging","pay-settings"],Ae={users:"Users",team:"Team",deposits:"Deposits",withdrawals:"Withdrawals","settings-wallet":"Wallet Settings","settings-auth":"Auth Settings","settings-messaging":"Messages Settings","settings-credits":"Credits Settings","settings-server":"Server Settings","pay-products":"Products","pay-subscriptions":"Subscriptions","pay-transactions":"Transactions","pay-coupons":"Coupons","pay-refunds":"Refunds","pay-storefront":"Storefront","pay-ai":"Store AI","pay-payment":"Payment Options","pay-messaging":"Store Messages","pay-settings":"Store Server"},Ve={admin:{users:!0,team:!0,deposits:!0,withdrawals:!0,"settings-wallet":!0,"settings-auth":!0,"settings-messaging":!0,"settings-credits":!0,"settings-server":!0,"pay-products":!0,"pay-subscriptions":!0,"pay-transactions":!0,"pay-coupons":!0,"pay-refunds":!0,"pay-storefront":!0,"pay-ai":!0,"pay-payment":!0,"pay-messaging":!0,"pay-settings":!0},member:{users:!1,team:!0,deposits:!1,withdrawals:!1,"settings-wallet":!1,"settings-auth":!1,"settings-messaging":!1,"settings-credits":!1,"settings-server":!1,"pay-products":!1,"pay-subscriptions":!1,"pay-transactions":!1,"pay-coupons":!1,"pay-refunds":!1,"pay-storefront":!1,"pay-ai":!1,"pay-payment":!1,"pay-messaging":!1,"pay-settings":!1}};function Kr(){const{config:s,authState:t,_internal:r}=N.useCedrosLogin(),{activeOrg:a,role:n}=is(),[o,c]=i.useState(Ve),[l,d]=i.useState(!1),[u,f]=i.useState(!1),[m,h]=i.useState(null),b=i.useRef(0),g=i.useMemo(()=>new N.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:r?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),p=i.useRef(g);p.current=g;const x=i.useCallback(async()=>{if(t!=="authenticated"||!a){c(Ve);return}d(!0),h(null);const A=++b.current;try{const v=await p.current.get("/admin/dashboard-permissions");if(A!==b.current)return;c(v.permissions)}catch(v){if(A!==b.current)return;if(v instanceof Error&&v.message.includes("404"))c(Ve);else{const S=v instanceof Error?v.message:"Failed to fetch permissions";h({code:"NETWORK_ERROR",message:S}),c(Ve)}}finally{A===b.current&&d(!1)}},[t,a]),j=i.useCallback(async A=>{if(t!=="authenticated"||!a)throw new Error("Not authenticated");if(n!=="owner")throw new Error("Only owners can modify dashboard permissions");f(!0),h(null);try{await p.current.request({method:"PUT",path:"/admin/dashboard-permissions",body:A}),c(A)}catch(v){const S=v instanceof Error?v.message:"Failed to update permissions";throw h({code:"NETWORK_ERROR",message:S}),new Error(S)}finally{f(!1)}},[t,a,n]),y=i.useCallback(A=>!a||!n||n==="owner"?!0:o[n]?.[A]??!1,[a,n,o]);return i.useEffect(()=>{a?.id&&x()},[a?.id,x]),{permissions:o,canAccess:y,updatePermissions:j,isLoading:l,isUpdating:u,error:m,fetchPermissions:x}}function ye(){const s=N.useCedrosLoginOptional(),[t,r]=i.useState(!1),[a,n]=i.useState(null),o=i.useMemo(()=>s?new N.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=i.useCallback(()=>{n(null)},[]),l=i.useCallback(async p=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{const x=new URLSearchParams;p?.status&&x.set("status",p.status),p?.limit!==void 0&&x.set("limit",String(p.limit)),p?.offset!==void 0&&x.set("offset",String(p.offset));const j=x.toString(),y=j?`/admin/deposits?${j}`:"/admin/deposits";return await o.get(y)}catch(x){const j=N.handleApiError(x,"Failed to list deposits");throw n(j.message),j}finally{r(!1)}},[o]),d=i.useCallback(async()=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get("/admin/deposits/stats")}catch(p){const x=N.handleApiError(p,"Failed to get deposit stats");throw n(x.message),x}finally{r(!1)}},[o]),u=i.useCallback(async p=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{const x=new URLSearchParams;p?.limit!==void 0&&x.set("limit",String(p.limit)),p?.offset!==void 0&&x.set("offset",String(p.offset));const j=x.toString(),y=j?`/admin/deposits/in-privacy-period?${j}`:"/admin/deposits/in-privacy-period";return await o.get(y)}catch(x){const j=N.handleApiError(x,"Failed to list deposits in privacy period");throw n(j.message),j}finally{r(!1)}},[o]),f=i.useCallback(async p=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{const x=new URLSearchParams;p?.limit!==void 0&&x.set("limit",String(p.limit)),p?.offset!==void 0&&x.set("offset",String(p.offset));const j=x.toString(),y=j?`/admin/withdrawals/pending?${j}`:"/admin/withdrawals/pending";return await o.get(y)}catch(x){const j=N.handleApiError(x,"Failed to list pending withdrawals");throw n(j.message),j}finally{r(!1)}},[o]),m=i.useCallback(async(p,x)=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.post(`/admin/withdrawals/${p}/process`,x??{})}catch(j){const y=N.handleApiError(j,"Failed to process withdrawal");throw n(y.message),y}finally{r(!1)}},[o]),h=i.useCallback(async()=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.post("/admin/withdrawals/process-all",{})}catch(p){const x=N.handleApiError(p,"Failed to process withdrawals");throw n(x.message),x}finally{r(!1)}},[o]),b=i.useCallback(async()=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get("/admin/privacy/status")}catch(p){const x=N.handleApiError(p,"Failed to get privacy status");throw n(x.message),x}finally{r(!1)}},[o]),g=i.useCallback(async()=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get("/admin/credits/stats")}catch(p){const x=N.handleApiError(p,"Failed to get credit stats");throw n(x.message),x}finally{r(!1)}},[o]);return{listDeposits:l,getStats:d,listInPrivacyPeriod:u,listPendingWithdrawals:f,processWithdrawal:m,processAllWithdrawals:h,getPrivacyStatus:b,getCreditStats:g,isLoading:t,error:a,clearError:c}}function Te({feature:s="Privacy Cash",className:t=""}){return e.jsxs("div",{className:`cedros-admin-feature-disabled ${t}`,children:[e.jsx("div",{className:"cedros-admin-feature-disabled-icon",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",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.jsxs("h4",{className:"cedros-admin-feature-disabled-title",children:[s," Not Enabled"]}),e.jsx("p",{className:"cedros-admin-feature-disabled-description",children:"This feature is not enabled on the server. To enable it, update your server configuration:"}),e.jsx("div",{className:"cedros-admin-feature-disabled-code",children:e.jsx("code",{children:"PRIVACY_CASH_ENABLED=true"})}),e.jsx("p",{className:"cedros-admin-feature-disabled-note",children:"After updating the configuration, restart the server for changes to take effect."})]})}function Le(s){if(!s)return!1;const t=s.toLowerCase();return t.includes("not found")||t.includes("not enabled")||t.includes("privacy deposits not enabled")||t.includes("404")}const vt={loading:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"cedros-admin__spinner",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),refresh: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:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),e.jsx("path",{d:"M21 3v5h-5"}),e.jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),e.jsx("path",{d:"M8 16H3v5"})]})};function Ce({stats:s,isLoading:t=!1,onRefresh:r}){return e.jsxs("div",{className:"cedros-admin__stats-bar",children:[e.jsx("div",{className:"cedros-admin__stats-bar-grid",children:s.map((a,n)=>e.jsxs("div",{className:"cedros-admin__stats-bar-item",children:[e.jsx("span",{className:"cedros-admin__stats-bar-label",children:a.label}),e.jsx("span",{className:`cedros-admin__stats-bar-value ${a.variant?`cedros-admin__stats-bar-value--${a.variant}`:""}`,children:t?e.jsx("span",{className:"cedros-admin__skeleton cedros-admin__skeleton--value"}):a.value}),a.description&&e.jsx("span",{className:"cedros-admin__stats-bar-desc",children:a.description})]},n))}),r&&e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:r,disabled:t,title:"Refresh stats",children:t?vt.loading:vt.refresh})]})}function Gr({refreshInterval:s=0,className:t="",onLoad:r}){const{getStats:a,isLoading:n,error:o,clearError:c}=ye(),[l,d]=i.useState(null),[u,f]=i.useState(null),m=i.useCallback(async()=>{try{const b=await a();d(b),r?.(b),f(null)}catch(b){const g=b&&typeof b=="object"&&"message"in b?String(b.message):"Failed to load stats";f(g)}},[a,r]);i.useEffect(()=>{m()},[m]),i.useEffect(()=>{if(s<=0)return;const b=setInterval(m,s);return()=>clearInterval(b)},[s,m]);const h=u||o;return Le(h)?e.jsx(Te,{feature:"Privacy Cash",className:t}):h?e.jsxs("div",{className:`cedros-admin-stats cedros-admin-stats-error ${t}`,children:[e.jsx("p",{className:"cedros-admin-error",children:h}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{c(),f(null),m()},children:"Retry"})]}):n&&!l?e.jsxs("div",{className:`cedros-admin-stats cedros-admin-stats-loading ${t}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading statistics..."})]}):l?e.jsx("div",{className:`cedros-admin-stats ${t}`,children:e.jsx(Ce,{stats:[{label:"Total Deposits",value:l.totalDeposits},{label:"Private Deposits",value:l.inPrivacyPeriodCount??0},{label:"Standard Deposits",value:l.readyForWithdrawalCount??0},{label:"Microdeposits",value:l.nativeSolDepositCount??0}],isLoading:n,onRefresh:m})}):null}function Yr({refreshInterval:s=0,className:t="",onLoad:r}){const{getStats:a,isLoading:n,error:o,clearError:c}=ye(),[l,d]=i.useState(null),[u,f]=i.useState(null),m=i.useCallback(async()=>{try{const b=await a();d(b),r?.(b),f(null)}catch(b){const g=b&&typeof b=="object"&&"message"in b?String(b.message):"Failed to load stats";f(g)}},[a,r]);i.useEffect(()=>{m()},[m]),i.useEffect(()=>{if(s<=0)return;const b=setInterval(m,s);return()=>clearInterval(b)},[s,m]);const h=u||o;return Le(h)?e.jsx(Te,{feature:"Privacy Cash",className:t}):h?e.jsxs("div",{className:`cedros-admin-stats ${t}`,children:[e.jsx("p",{className:"cedros-admin-error",children:h}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{c(),f(null),m()},children:"Retry"})]}):n&&!l?e.jsx("div",{className:`cedros-admin-stats ${t}`,children:e.jsx(Ce,{stats:[{label:"Total Withdrawn",value:0},{label:"Pending Withdraw",value:0},{label:"In Privacy Period",value:0},{label:"Microbatch (SOL)",value:"0.0000"}],isLoading:!0})}):l?e.jsx("div",{className:`cedros-admin-stats ${t}`,children:e.jsx(Ce,{stats:[{label:"Total Withdrawn",value:l.totalWithdrawnCount},{label:"Pending Withdraw",value:l.pendingWithdrawalCount},{label:"In Privacy Period",value:l.inPrivacyPeriodCount??0},{label:"Microbatch (SOL)",value:l.readyForWithdrawalSol?.toFixed(4)??"0.0000"}],isLoading:n,onRefresh:m})}):null}function Ko(s){return{pending:"Pending",detected:"Detected",processing:"Processing",completed:"Completed",withdrawn:"Withdrawn",partially_withdrawn:"Partially Withdrawn",expired:"Expired",failed:"Failed"}[s]||s}function Go(s){return s==="completed"||s==="withdrawn"||s==="partially_withdrawn"?"cedros-admin-deposit-success":s==="failed"||s==="expired"?"cedros-admin-deposit-error":s==="processing"||s==="detected"?"cedros-admin-deposit-processing":"cedros-admin-deposit-pending"}function Yo(s){return s==null?"—":`${(s/1e9).toFixed(4)} SOL`}function Jo(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function jt(s){return s.length<=12?s:`${s.slice(0,6)}...${s.slice(-4)}`}function Jr({statusFilter:s,pageSize:t=20,refreshInterval:r=0,className:a="",onLoad:n,onDepositClick:o}){const{listDeposits:c,isLoading:l,error:d,clearError:u}=ye(),[f,m]=i.useState([]),[h,b]=i.useState(0),[g,p]=i.useState(0),[x,j]=i.useState(null),[y,A]=i.useState("createdAt"),[v,S]=i.useState("desc"),w=_=>{y===_?S(v==="asc"?"desc":"asc"):(A(_),S("desc"))},C=i.useMemo(()=>[...f].sort((_,M)=>{let D,B;switch(y){case"userId":D=_.userId.toLowerCase(),B=M.userId.toLowerCase();break;case"amountLamports":D=_.amountLamports??0,B=M.amountLamports??0;break;case"status":D=_.status,B=M.status;break;case"createdAt":D=new Date(_.createdAt).getTime(),B=new Date(M.createdAt).getTime();break;case"txSignature":D=_.txSignature||"",B=M.txSignature||"";break;default:return 0}return D<B?v==="asc"?-1:1:D>B?v==="asc"?1:-1:0}),[f,y,v]),T=i.useCallback(async()=>{try{const _=await c({status:s,limit:t,offset:g});m(_.deposits),b(_.total),n?.(_),j(null)}catch(_){const M=_&&typeof _=="object"&&"message"in _?String(_.message):"Failed to load deposits";j(M)}},[s,t,g,c,n]);i.useEffect(()=>{p(0)},[s,t]),i.useEffect(()=>{T()},[T]),i.useEffect(()=>{if(r<=0)return;const _=setInterval(T,r);return()=>clearInterval(_)},[r,T]);const L=Math.ceil(h/t),E=Math.floor(g/t)+1,P=_=>{const M=(_-1)*t;p(Math.max(0,Math.min(M,Math.max(0,h-1))))},k=x||d;return Le(k)?e.jsx(Te,{feature:"Privacy Cash",className:a}):k?e.jsxs("div",{className:`cedros-admin-deposit-list cedros-admin-deposit-list-error ${a}`,children:[e.jsx("p",{className:"cedros-admin-error",children:k}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{u(),j(null),T()},children:"Retry"})]}):l&&f.length===0?e.jsxs("div",{className:`cedros-admin-deposit-list cedros-admin-deposit-list-loading ${a}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading deposits..."})]}):e.jsxs("div",{className:`cedros-admin-deposit-list ${a}`,children:[e.jsxs("div",{className:"cedros-admin-deposit-list-header",children:[e.jsx("h4",{className:"cedros-admin-deposit-list-title",children:"All Deposits"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-icon-button",onClick:T,disabled:l,title:"Refresh deposits","aria-label":"Refresh deposits",children:l?"...":"↻"})]}),f.length===0?e.jsx("div",{className:"cedros-admin-empty",children:e.jsx("p",{className:"cedros-admin-empty-message",children:"No deposits found."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-deposit-table",children:[e.jsxs("div",{className:"cedros-admin-deposit-thead",children:[e.jsx("div",{className:"cedros-admin-deposit-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${y==="userId"?"cedros-admin-sort-active":""}`,onClick:()=>w("userId"),"aria-label":"Sort by user",children:["User"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:y==="userId"?v==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-deposit-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${y==="amountLamports"?"cedros-admin-sort-active":""}`,onClick:()=>w("amountLamports"),"aria-label":"Sort by amount",children:["Amount"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:y==="amountLamports"?v==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-deposit-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${y==="status"?"cedros-admin-sort-active":""}`,onClick:()=>w("status"),"aria-label":"Sort by status",children:["Status"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:y==="status"?v==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-deposit-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${y==="createdAt"?"cedros-admin-sort-active":""}`,onClick:()=>w("createdAt"),"aria-label":"Sort by created",children:["Created"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:y==="createdAt"?v==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-deposit-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${y==="txSignature"?"cedros-admin-sort-active":""}`,onClick:()=>w("txSignature"),"aria-label":"Sort by transaction",children:["Tx"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:y==="txSignature"?v==="asc"?"↑":"↓":"↕"})]})})]}),C.map(_=>e.jsxs("div",{className:`cedros-admin-deposit-row ${Go(_.status)}`,onClick:()=>o?.(_),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),o?.(_))},role:o?"button":void 0,tabIndex:o?0:void 0,children:[e.jsx("div",{className:"cedros-admin-deposit-td",title:_.userId,children:jt(_.userId)}),e.jsx("div",{className:"cedros-admin-deposit-td",children:Yo(_.amountLamports)}),e.jsx("div",{className:"cedros-admin-deposit-td",children:e.jsx("span",{className:"cedros-admin-status-badge",children:Ko(_.status)})}),e.jsx("div",{className:"cedros-admin-deposit-td",children:Jo(_.createdAt)}),e.jsx("div",{className:"cedros-admin-deposit-td",title:_.txSignature||void 0,children:_.txSignature?jt(_.txSignature):"—"})]},_.id))]}),L>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>P(E-1),disabled:E<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",E," of ",L," (",h," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>P(E+1),disabled:E>=L,children:"Next"})]})]})]})}function At(s){return s==null?"—":`${(s/1e9).toFixed(4)} SOL`}function kt(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Nt(s){return s.length<=12?s:`${s.slice(0,6)}...${s.slice(-4)}`}function Xo(s){const t=new Date(s),a=new Date().getTime()-t.getTime(),n=Math.floor(a/6e4),o=Math.floor(n/60),c=Math.floor(o/24);return c>0?`${c}d ago`:o>0?`${o}h ago`:n>0?`${n}m ago`:"just now"}function St(s){return s?new Date(s)>new Date:!0}function Xr({pageSize:s=20,refreshInterval:t=0,className:r="",onLoad:a,onItemClick:n,onWithdrawalProcessed:o,onAllProcessed:c}){const{listPendingWithdrawals:l,processWithdrawal:d,processAllWithdrawals:u,isLoading:f,error:m,clearError:h}=ye(),[b,g]=i.useState([]),[p,x]=i.useState(0),[j,y]=i.useState(0),[A,v]=i.useState(null),[S,w]=i.useState("withdrawalAvailableAt"),[C,T]=i.useState("asc"),L=R=>{S===R?T(C==="asc"?"desc":"asc"):(w(R),T(R==="withdrawalAvailableAt"?"asc":"desc"))},E=i.useMemo(()=>[...b].sort((R,F)=>{let U,q;switch(S){case"userId":U=R.userId.toLowerCase(),q=F.userId.toLowerCase();break;case"amountLamports":U=R.amountLamports??0,q=F.amountLamports??0;break;case"withdrawalAvailableAt":U=R.withdrawalAvailableAt?new Date(R.withdrawalAvailableAt).getTime():0,q=F.withdrawalAvailableAt?new Date(F.withdrawalAvailableAt).getTime():0;break;default:return 0}return U<q?C==="asc"?-1:1:U>q?C==="asc"?1:-1:0}),[b,S,C]),[P,k]=i.useState(null),[_,M]=i.useState(!1),[D,B]=i.useState(null),[Y,G]=i.useState(null),O=i.useCallback(async()=>{try{const R=await l({limit:s,offset:j});g(R.deposits),x(R.total),a?.(R),v(null)}catch(R){const F=R&&typeof R=="object"&&"message"in R?String(R.message):"Failed to load pending withdrawals";v(F)}},[s,j,l,a]);i.useEffect(()=>{y(0)},[s]),i.useEffect(()=>{O()},[O]),i.useEffect(()=>{if(t<=0)return;const R=setInterval(O,t);return()=>clearInterval(R)},[t,O]),i.useEffect(()=>{if(!D)return;const R=setTimeout(()=>B(null),5e3);return()=>clearTimeout(R)},[D]);const $=Math.ceil(p/s),I=Math.floor(j/s)+1,H=R=>{const F=(R-1)*s;y(Math.max(0,Math.min(F,Math.max(0,p-1))))},ee=async(R,F=!1)=>{if(!F&&St(R.withdrawalAvailableAt)){G(R);return}k(R.id),B(null);try{const U=await d(R.id,{force:F});U.success?(B({type:"success",message:`Withdrawal processed: ${U.txSignature?.slice(0,12)}...`}),o?.(U),await O()):B({type:"error",message:U.error||"Failed to process withdrawal"})}catch(U){B({type:"error",message:U instanceof Error?U.message:"Failed to process withdrawal"})}finally{k(null),G(null)}},Z=async()=>{if(b.length!==0){M(!0),B(null);try{const R=await u();R.totalSucceeded>0?B({type:"success",message:`Processed ${R.totalSucceeded}/${R.totalProcessed} withdrawals`}):R.totalFailed>0&&B({type:"error",message:`Failed to process ${R.totalFailed} withdrawals`}),c?.(R),await O()}catch(R){B({type:"error",message:R instanceof Error?R.message:"Failed to process withdrawals"})}finally{M(!1)}}},Q=A||m;return Le(Q)?e.jsx(Te,{feature:"Privacy Cash",className:r}):Q?e.jsxs("div",{className:`cedros-admin-withdrawal-queue cedros-admin-withdrawal-queue-error ${r}`,children:[e.jsx("p",{className:"cedros-admin-error",children:Q}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{h(),v(null),O()},children:"Retry"})]}):f&&b.length===0&&!P&&!_?e.jsxs("div",{className:`cedros-admin-withdrawal-queue cedros-admin-withdrawal-queue-loading ${r}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading withdrawal queue..."})]}):e.jsxs("div",{className:`cedros-admin-withdrawal-queue ${r}`,children:[Y&&e.jsx("div",{className:"cedros-admin-modal-overlay",onClick:()=>G(null),onKeyDown:R=>R.key==="Escape"&&G(null),role:"dialog","aria-modal":"true","aria-labelledby":"early-withdrawal-title",children:e.jsxs("div",{className:"cedros-admin-modal cedros-admin-modal-warning",onClick:R=>R.stopPropagation(),onKeyDown:()=>{},role:"document",children:[e.jsx("h3",{id:"early-withdrawal-title",className:"cedros-admin-modal-title",children:"Early Withdrawal Warning"}),e.jsxs("div",{className:"cedros-admin-modal-content",children:[e.jsx("p",{className:"cedros-admin-modal-warning-text",children:e.jsx("strong",{children:"This deposit is still within its privacy period."})}),e.jsx("p",{children:"Processing this withdrawal early may compromise user privacy. The privacy period exists to provide plausible deniability for deposits."}),e.jsxs("p",{className:"cedros-admin-modal-details",children:["User: ",Nt(Y.userId),e.jsx("br",{}),"Amount: ",At(Y.amountLamports),e.jsx("br",{}),"Available at:"," ",Y.withdrawalAvailableAt?kt(Y.withdrawalAvailableAt):"—"]}),e.jsx("p",{children:"Are you sure you want to process this withdrawal early?"})]}),e.jsxs("div",{className:"cedros-admin-modal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>G(null),children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:()=>ee(Y,!0),disabled:P===Y.id,children:P===Y.id?"Processing...":"Process Early"})]})]})}),D&&e.jsx("div",{className:`cedros-admin-result cedros-admin-result-${D.type}`,role:"status","aria-live":"polite",children:D.message}),e.jsxs("div",{className:"cedros-admin-withdrawal-queue-header",children:[e.jsx("h4",{className:"cedros-admin-withdrawal-queue-title",children:"Pending Withdrawals"}),e.jsxs("div",{className:"cedros-admin-withdrawal-queue-actions",children:[e.jsxs("span",{className:"cedros-admin-queue-count",children:[p," pending"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-icon-button",onClick:O,disabled:f||_,title:"Refresh queue","aria-label":"Refresh queue",children:f&&!_?"...":"↻"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:Z,disabled:f||_||b.length===0,title:"Process all ready withdrawals",children:_?"Processing...":"Process All"})]})]}),b.length===0?e.jsx("div",{className:"cedros-admin-empty",children:e.jsx("p",{className:"cedros-admin-empty-message",children:"No pending withdrawals."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-withdrawal-table",children:[e.jsxs("div",{className:"cedros-admin-withdrawal-thead",children:[e.jsx("div",{className:"cedros-admin-withdrawal-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${S==="userId"?"cedros-admin-sort-active":""}`,onClick:()=>L("userId"),"aria-label":"Sort by user",children:["User"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:S==="userId"?C==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-withdrawal-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${S==="amountLamports"?"cedros-admin-sort-active":""}`,onClick:()=>L("amountLamports"),"aria-label":"Sort by amount",children:["Amount"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:S==="amountLamports"?C==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-withdrawal-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${S==="withdrawalAvailableAt"?"cedros-admin-sort-active":""}`,onClick:()=>L("withdrawalAvailableAt"),"aria-label":"Sort by ready since",children:["Ready Since"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:S==="withdrawalAvailableAt"?C==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-withdrawal-th",children:"Waiting"}),e.jsx("div",{className:"cedros-admin-withdrawal-th cedros-admin-withdrawal-th-action",children:"Action"})]}),E.map(R=>{const F=St(R.withdrawalAvailableAt),U=P===R.id;return e.jsxs("div",{className:`cedros-admin-withdrawal-row ${F?"cedros-admin-withdrawal-row-early":""}`,onClick:()=>n?.(R),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),n?.(R))},role:n?"button":void 0,tabIndex:n?0:void 0,children:[e.jsx("div",{className:"cedros-admin-withdrawal-td",title:R.userId,children:Nt(R.userId)}),e.jsx("div",{className:"cedros-admin-withdrawal-td",children:At(R.amountLamports)}),e.jsx("div",{className:"cedros-admin-withdrawal-td",children:R.withdrawalAvailableAt?kt(R.withdrawalAvailableAt):"—"}),e.jsx("div",{className:"cedros-admin-withdrawal-td cedros-admin-withdrawal-waiting",children:R.withdrawalAvailableAt?F?"In privacy period":Xo(R.withdrawalAvailableAt):"—"}),e.jsx("div",{className:"cedros-admin-withdrawal-td cedros-admin-withdrawal-td-action",children:e.jsx("button",{type:"button",className:`cedros-button cedros-button-sm ${F?"cedros-button-warning":"cedros-button-primary"}`,onClick:q=>{q.stopPropagation(),ee(R)},disabled:U||_,title:F?"Early withdrawal (requires confirmation)":"Process this withdrawal",children:U?"...":F?"Early":"Process"})})]},R.id)})]}),$>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>H(I-1),disabled:I<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",I," of ",$," (",p," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>H(I+1),disabled:I>=$,children:"Next"})]})]})]})}function Zo(s){return s==null?"—":`${(s/1e9).toFixed(4)} SOL`}function ei(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function si(s){return s.length<=12?s:`${s.slice(0,6)}...${s.slice(-4)}`}function ti(s){const t=new Date(s),r=new Date,a=t.getTime()-r.getTime();if(a<=0)return"Ready";const n=Math.floor(a/6e4),o=Math.floor(n/60),c=Math.floor(o/24);if(c>0){const l=o%24;return l>0?`${c}d ${l}h`:`${c}d`}if(o>0){const l=n%60;return l>0?`${o}h ${l}m`:`${o}h`}return`${n}m`}function Zr({pageSize:s=20,refreshInterval:t=0,className:r="",onLoad:a,onItemClick:n}){const{listInPrivacyPeriod:o,isLoading:c,error:l,clearError:d}=ye(),[u,f]=i.useState([]),[m,h]=i.useState(0),[b,g]=i.useState(0),[p,x]=i.useState(null),j=i.useCallback(async()=>{try{const w=await o({limit:s,offset:b});f(w.deposits),h(w.total),a?.(w),x(null)}catch(w){const C=w&&typeof w=="object"&&"message"in w?String(w.message):"Failed to load deposits";x(C)}},[s,b,o,a]);i.useEffect(()=>{g(0)},[s]),i.useEffect(()=>{j()},[j]),i.useEffect(()=>{if(t<=0)return;const w=setInterval(j,t);return()=>clearInterval(w)},[t,j]);const y=Math.ceil(m/s),A=Math.floor(b/s)+1,v=w=>{const C=(w-1)*s;g(Math.max(0,Math.min(C,Math.max(0,m-1))))},S=p||l;return Le(S)?e.jsx(Te,{feature:"Privacy Cash",className:r}):S?e.jsxs("div",{className:`cedros-admin-privacy-deposits cedros-admin-privacy-deposits-error ${r}`,children:[e.jsx("p",{className:"cedros-admin-error",children:S}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{d(),x(null),j()},children:"Retry"})]}):c&&u.length===0?e.jsxs("div",{className:`cedros-admin-privacy-deposits cedros-admin-privacy-deposits-loading ${r}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading deposits..."})]}):e.jsxs("div",{className:`cedros-admin-privacy-deposits ${r}`,children:[e.jsxs("div",{className:"cedros-admin-privacy-deposits-header",children:[e.jsx("h4",{className:"cedros-admin-privacy-deposits-title",children:"In Privacy Period"}),e.jsxs("div",{className:"cedros-admin-privacy-deposits-actions",children:[e.jsxs("span",{className:"cedros-admin-queue-count",children:[m," deposit",m!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-icon-button",onClick:j,disabled:c,title:"Refresh list","aria-label":"Refresh list",children:c?"...":"↻"})]})]}),u.length===0?e.jsx("div",{className:"cedros-admin-empty",children:e.jsx("p",{className:"cedros-admin-empty-message",children:"No deposits in privacy period."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-privacy-table",children:[e.jsxs("div",{className:"cedros-admin-privacy-thead",children:[e.jsx("div",{className:"cedros-admin-privacy-th",children:e.jsxs("button",{type:"button",className:"cedros-admin-sort-button","aria-label":"Sort by user",children:["User ",e.jsx("span",{className:"cedros-admin-sort-icon",children:"↕"})]})}),e.jsx("div",{className:"cedros-admin-privacy-th",children:e.jsxs("button",{type:"button",className:"cedros-admin-sort-button","aria-label":"Sort by amount",children:["Amount ",e.jsx("span",{className:"cedros-admin-sort-icon",children:"↕"})]})}),e.jsx("div",{className:"cedros-admin-privacy-th",children:e.jsxs("button",{type:"button",className:"cedros-admin-sort-button","aria-label":"Sort by deposited",children:["Deposited ",e.jsx("span",{className:"cedros-admin-sort-icon",children:"↕"})]})}),e.jsx("div",{className:"cedros-admin-privacy-th",children:e.jsxs("button",{type:"button",className:"cedros-admin-sort-button","aria-label":"Sort by ready in",children:["Ready In ",e.jsx("span",{className:"cedros-admin-sort-icon",children:"↕"})]})})]}),u.map(w=>e.jsxs("div",{className:"cedros-admin-privacy-row",onClick:()=>n?.(w),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),n?.(w))},role:n?"button":void 0,tabIndex:n?0:void 0,children:[e.jsx("div",{className:"cedros-admin-privacy-td",title:w.userId,children:si(w.userId)}),e.jsx("div",{className:"cedros-admin-privacy-td",children:Zo(w.amountLamports)}),e.jsx("div",{className:"cedros-admin-privacy-td",children:w.completedAt?ei(w.completedAt):"—"}),e.jsx("div",{className:"cedros-admin-privacy-td cedros-admin-privacy-remaining",children:w.withdrawalAvailableAt?ti(w.withdrawalAvailableAt):"—"})]},w.id))]}),y>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>v(A-1),disabled:A<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",A," of ",y," (",m," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>v(A+1),disabled:A>=y,children:"Next"})]})]})]})}function ri(s){return s==null?"—":`${(s/1e9).toFixed(4)} SOL`}function ni(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ai(s){return s.length<=16?s:`${s.slice(0,8)}...${s.slice(-6)}`}function oi(s){return s.length<=12?s:`${s.slice(0,6)}...${s.slice(-4)}`}function en({pageSize:s=20,refreshInterval:t=0,className:r="",onLoad:a,onItemClick:n}){const{listDeposits:o,isLoading:c,error:l,clearError:d}=ye(),[u,f]=i.useState([]),[m,h]=i.useState(0),[b,g]=i.useState(0),[p,x]=i.useState(null),[j,y]=i.useState("completedAt"),[A,v]=i.useState("desc"),S=k=>{j===k?v(A==="asc"?"desc":"asc"):(y(k),v("desc"))},w=i.useMemo(()=>[...u].sort((k,_)=>{let M,D;switch(j){case"userId":M=k.userId.toLowerCase(),D=_.userId.toLowerCase();break;case"amountLamports":M=k.amountLamports??0,D=_.amountLamports??0;break;case"completedAt":M=k.completedAt?new Date(k.completedAt).getTime():0,D=_.completedAt?new Date(_.completedAt).getTime():0;break;case"withdrawalTxSignature":M=k.withdrawalTxSignature||"",D=_.withdrawalTxSignature||"";break;default:return 0}return M<D?A==="asc"?-1:1:M>D?A==="asc"?1:-1:0}),[u,j,A]),C=i.useCallback(async()=>{try{const k=await o({status:"withdrawn",limit:s,offset:b});f(k.deposits),h(k.total),a?.(k),x(null)}catch(k){const _=k&&typeof k=="object"&&"message"in k?String(k.message):"Failed to load withdrawal history";x(_)}},[s,b,o,a]);i.useEffect(()=>{g(0)},[s]),i.useEffect(()=>{C()},[C]),i.useEffect(()=>{if(t<=0)return;const k=setInterval(C,t);return()=>clearInterval(k)},[t,C]);const T=Math.ceil(m/s),L=Math.floor(b/s)+1,E=k=>{const _=(k-1)*s;g(Math.max(0,Math.min(_,Math.max(0,m-1))))},P=p||l;return Le(P)?e.jsx(Te,{feature:"Privacy Cash",className:r}):P?e.jsxs("div",{className:`cedros-admin-withdrawal-history cedros-admin-withdrawal-history-error ${r}`,children:[e.jsx("p",{className:"cedros-admin-error",children:P}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{d(),x(null),C()},children:"Retry"})]}):c&&u.length===0?e.jsxs("div",{className:`cedros-admin-withdrawal-history cedros-admin-withdrawal-history-loading ${r}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-admin-withdrawal-history ${r}`,children:[e.jsxs("div",{className:"cedros-admin-withdrawal-history-header",children:[e.jsx("h4",{className:"cedros-admin-withdrawal-history-title",children:"Withdrawal History"}),e.jsxs("div",{className:"cedros-admin-withdrawal-history-actions",children:[e.jsxs("span",{className:"cedros-admin-queue-count",children:[m," withdrawal",m!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-icon-button",onClick:C,disabled:c,title:"Refresh list","aria-label":"Refresh list",children:c?"...":"↻"})]})]}),u.length===0?e.jsx("div",{className:"cedros-admin-empty",children:e.jsx("p",{className:"cedros-admin-empty-message",children:"No withdrawals processed yet."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-history-table",children:[e.jsxs("div",{className:"cedros-admin-history-thead",children:[e.jsx("div",{className:"cedros-admin-history-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${j==="userId"?"cedros-admin-sort-active":""}`,onClick:()=>S("userId"),"aria-label":"Sort by user",children:["User"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:j==="userId"?A==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-history-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${j==="amountLamports"?"cedros-admin-sort-active":""}`,onClick:()=>S("amountLamports"),"aria-label":"Sort by amount",children:["Amount"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:j==="amountLamports"?A==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-history-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${j==="completedAt"?"cedros-admin-sort-active":""}`,onClick:()=>S("completedAt"),"aria-label":"Sort by processed",children:["Processed"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:j==="completedAt"?A==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-history-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${j==="withdrawalTxSignature"?"cedros-admin-sort-active":""}`,onClick:()=>S("withdrawalTxSignature"),"aria-label":"Sort by transaction",children:["Transaction"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:j==="withdrawalTxSignature"?A==="asc"?"↑":"↓":"↕"})]})})]}),w.map(k=>e.jsxs("div",{className:"cedros-admin-history-row",onClick:()=>n?.(k),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),n?.(k))},role:n?"button":void 0,tabIndex:n?0:void 0,children:[e.jsx("div",{className:"cedros-admin-history-td",title:k.userId,children:oi(k.userId)}),e.jsx("div",{className:"cedros-admin-history-td",children:ri(k.amountLamports)}),e.jsx("div",{className:"cedros-admin-history-td",children:k.completedAt?ni(k.completedAt):"—"}),e.jsx("div",{className:"cedros-admin-history-td",children:k.withdrawalTxSignature?e.jsx("a",{href:`https://orbmarkets.io/tx/${k.withdrawalTxSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-admin-tx-link",onClick:_=>_.stopPropagation(),title:k.withdrawalTxSignature,children:ai(k.withdrawalTxSignature)}):"—"})]},k.id))]}),T>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>E(L-1),disabled:L<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",L," of ",T," (",m," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>E(L+1),disabled:L>=T,children:"Next"})]})]})]})}function Ct(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function ii(s){return s.length<=12?s:`${s.slice(0,6)}...${s.slice(-4)}`}function li(s){return s==null?"-":(s/1e9).toFixed(4)}function sn({pageSize:s=20,refreshInterval:t=0,currentUserId:r,className:a="",onLoad:n,onUserClick:o}){const{users:c,total:l,isLoading:d,error:u,listUsers:f,clearError:m}=ls(),[h,b]=i.useState(0),[g,p]=i.useState(null),[x,j]=i.useState("createdAt"),[y,A]=i.useState("desc"),v=E=>{x===E?A(y==="asc"?"desc":"asc"):(j(E),A("desc"))},S=i.useMemo(()=>[...c].sort((E,P)=>{let k,_;switch(x){case"name":k=(E.name||E.email||"").toLowerCase(),_=(P.name||P.email||"").toLowerCase();break;case"createdAt":k=new Date(E.createdAt).getTime(),_=new Date(P.createdAt).getTime();break;case"lastLoginAt":k=E.lastLoginAt?new Date(E.lastLoginAt).getTime():0,_=P.lastLoginAt?new Date(P.lastLoginAt).getTime():0;break;case"balanceLamports":k=E.balanceLamports??0,_=P.balanceLamports??0;break;default:return 0}return k<_?y==="asc"?-1:1:k>_?y==="asc"?1:-1:0}),[c,x,y]),w=i.useCallback(async()=>{try{const E=await f({limit:s,offset:h});n?.(E),p(null)}catch(E){p(E instanceof Error?E.message:"Failed to load users")}},[s,h,f,n]);i.useEffect(()=>{b(0)},[s]),i.useEffect(()=>{w()},[w]),i.useEffect(()=>{if(t<=0)return;const E=setInterval(w,t);return()=>clearInterval(E)},[t,w]);const C=Math.ceil(l/s),T=Math.floor(h/s)+1,L=E=>{const P=(E-1)*s;b(Math.max(0,Math.min(P,Math.max(0,l-1))))};return g||u?e.jsxs("div",{className:`cedros-admin-user-list cedros-admin-user-list-error ${a}`,children:[e.jsx("p",{className:"cedros-admin-error",children:g||u?.message}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{m(),p(null),w()},children:"Retry"})]}):d&&c.length===0?e.jsxs("div",{className:`cedros-admin-user-list cedros-admin-user-list-loading ${a}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading users..."})]}):e.jsxs("div",{className:`cedros-admin-user-list ${a}`,children:[e.jsxs("div",{className:"cedros-admin-user-list-header",children:[e.jsx("h4",{className:"cedros-admin-user-list-title",children:"All Users"}),e.jsxs("div",{className:"cedros-admin-user-list-actions",children:[e.jsxs("span",{className:"cedros-admin-queue-count",children:[l," user",l!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-icon-button",onClick:w,disabled:d,title:"Refresh list","aria-label":"Refresh list",children:d?"...":"↻"})]})]}),c.length===0?e.jsx("div",{className:"cedros-admin-empty",children:e.jsx("p",{className:"cedros-admin-empty-message",children:"No users found."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-user-table",children:[e.jsxs("div",{className:"cedros-admin-user-thead",children:[e.jsx("div",{className:"cedros-admin-user-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${x==="name"?"cedros-admin-sort-active":""}`,onClick:()=>v("name"),"aria-label":"Sort by user",children:["User"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:x==="name"?y==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-user-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${x==="createdAt"?"cedros-admin-sort-active":""}`,onClick:()=>v("createdAt"),"aria-label":"Sort by registered date",children:["Registered"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:x==="createdAt"?y==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-user-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${x==="lastLoginAt"?"cedros-admin-sort-active":""}`,onClick:()=>v("lastLoginAt"),"aria-label":"Sort by last login",children:["Last Login"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:x==="lastLoginAt"?y==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-user-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${x==="balanceLamports"?"cedros-admin-sort-active":""}`,onClick:()=>v("balanceLamports"),"aria-label":"Sort by balance",children:["Balance"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:x==="balanceLamports"?y==="asc"?"↑":"↓":"↕"})]})})]}),S.map(E=>{const P=E.id===r;return e.jsxs("div",{className:`cedros-admin-user-row ${P?"cedros-admin-user-row-current":""}`,onClick:()=>o?.(E),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(E))},role:o?"button":void 0,tabIndex:o?0:void 0,children:[e.jsxs("div",{className:"cedros-admin-user-td cedros-admin-user-info",children:[e.jsx("div",{className:"cedros-admin-user-avatar",children:E.picture?e.jsx("img",{src:E.picture,alt:E.name||E.email||"User",className:"cedros-admin-user-avatar-img",referrerPolicy:"no-referrer"}):e.jsx("span",{className:"cedros-admin-user-avatar-placeholder",children:(E.name?.[0]||E.email?.[0]||"?").toUpperCase()})}),e.jsxs("div",{className:"cedros-admin-user-details",children:[e.jsxs("span",{className:"cedros-admin-user-name",children:[E.name||"Unknown",P&&e.jsx("span",{className:"cedros-admin-user-you",children:"(you)"})]}),e.jsx("span",{className:"cedros-admin-user-email",title:E.email,children:E.email||ii(E.id)})]})]}),e.jsx("div",{className:"cedros-admin-user-td",children:Ct(E.createdAt)}),e.jsx("div",{className:"cedros-admin-user-td",children:E.lastLoginAt?Ct(E.lastLoginAt):"-"}),e.jsx("div",{className:"cedros-admin-user-td",children:li(E.balanceLamports)})]},E.id)})]}),C>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>L(T-1),disabled:T<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",T," of ",C," (",l," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>L(T+1),disabled:T>=C,children:"Next"})]})]})]})}function _t(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Xs(s){return new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ci(s){return s==null?"—":`${(s/1e9).toFixed(4)} SOL`}function Ke(s){return s==null?"—":(s/1e9).toFixed(4)}function di(s){return{DEPOSIT:"Deposit",SPEND:"Spend",ADJUSTMENT:"Adjustment",REFUND:"Refund"}[s.toUpperCase()]||s}function ui(s,t){return t?{deposit:"Credit deposit",purchase:"Purchase",api_call:"API usage",subscription:"Subscription",refund:"Refund",bonus:"Bonus credit",promo:"Promotional credit",correction:"Balance correction"}[t.toLowerCase()]||t:{DEPOSIT:"Credit added",SPEND:"Credit used",ADJUSTMENT:"Manual adjustment",REFUND:"Credit refunded"}[s.toUpperCase()]||"—"}function tn({userId:s,onBack:t,currentUserId:r,onEditUser:a,onAdjustCredits:n,cedrosPayEnabled:o=!1,className:c=""}){const{isLoading:l,getUser:d,getUserDeposits:u,getUserCredits:f,getUserChats:m,deleteUser:h,forcePasswordReset:b,clearError:g}=ls(),[p,x]=i.useState(null),[j,y]=i.useState(null),[A,v]=i.useState(null),[S,w]=i.useState(null),[C,T]=i.useState("deposits"),[L,E]=i.useState(null),[P,k]=i.useState(null),[_,M]=i.useState(null),[D,B]=i.useState(null),[Y,G]=i.useState(!1),[O,$]=i.useState(0),[I,H]=i.useState(0),[ee,Z]=i.useState(0),Q=10,R=i.useCallback(async()=>{try{const z=await d(s);x(z),E(null)}catch(z){E(z instanceof Error?z.message:"Failed to load user")}},[s,d]),F=i.useCallback(async()=>{try{const he=await u(s,{limit:Q,offset:O});v(he),M(null)}catch(z){M(z instanceof Error?z.message:"Failed to load deposits")}},[s,u,O]),U=i.useCallback(async()=>{try{const he=await f(s,{limit:Q,offset:I});y(he),k(null)}catch(z){k(z instanceof Error?z.message:"Failed to load credits")}},[s,f,I]),q=i.useCallback(async()=>{if(o)try{const he=await m(s,{limit:Q,offset:ee});w(he),B(null)}catch(z){B(z instanceof Error?z.message:"Failed to load chat history")}},[s,m,ee,o]);i.useEffect(()=>{R(),F(),U(),o&&q()},[R,F,U,q,o]);const re=async()=>{if(!p)return;if(p.id===r){alert("You cannot delete your own account");return}if(p.isSystemAdmin){alert("Cannot delete a system admin. Remove admin status first.");return}if(window.confirm(`Are you sure you want to delete ${p.name||p.email||"this user"}? This action cannot be undone.`)){G(!0);try{await h(p.id),t()}catch{}finally{G(!1)}}},de=async()=>{if(!p?.email){alert("User has no email address");return}if(window.confirm(`Send a password reset email to ${p.email}?`)){G(!0);try{await b(p.id),alert("Password reset email sent")}catch{}finally{G(!1)}}},Fe=A?Math.ceil(A.total/Q):0,Me=Math.floor(O/Q)+1,fe=j?Math.ceil(j.totalTransactions/Q):0,us=Math.floor(I/Q)+1,De=z=>{$((z-1)*Q)},ve=z=>{H((z-1)*Q)},Be=S?Math.ceil(S.total/Q):0,hs=Math.floor(ee/Q)+1,ms=z=>{Z((z-1)*Q)};if(L)return e.jsxs("div",{className:`cedros-admin-user-detail cedros-admin-user-detail-error ${c}`,children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:"Back"}),e.jsx("p",{className:"cedros-admin-error",children:L}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{g(),E(null),R()},children:"Retry"})]});if(l&&!p)return e.jsxs("div",{className:`cedros-admin-user-detail cedros-admin-user-detail-loading ${c}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading user..."})]});if(!p)return e.jsxs("div",{className:`cedros-admin-user-detail ${c}`,children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:"Back"}),e.jsx("p",{className:"cedros-admin-empty-message",children:"User not found."})]});const ge=p.id===r;return e.jsxs("div",{className:`cedros-admin-user-detail ${c}`,children:[e.jsxs("div",{className:"cedros-admin-user-detail-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-back-btn",onClick:t,children:"Back to Users"}),e.jsxs("div",{className:"cedros-admin-user-detail-actions",children:[a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>a(p),disabled:Y,children:"Edit"}),p.email&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:de,disabled:Y,children:"Reset Password"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>n(p),disabled:Y,children:"Adjust Credits"}),!ge&&!p.isSystemAdmin&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-btn-danger",onClick:re,disabled:Y,children:"Delete"})]})]}),e.jsxs("div",{className:"cedros-admin-user-detail-info",children:[e.jsx("div",{className:"cedros-admin-user-detail-avatar",children:p.picture?e.jsx("img",{src:p.picture,alt:p.name||p.email||"User",className:"cedros-admin-user-detail-avatar-img",referrerPolicy:"no-referrer"}):e.jsx("span",{className:"cedros-admin-user-detail-avatar-placeholder",children:(p.name?.[0]||p.email?.[0]||"?").toUpperCase()})}),e.jsxs("div",{className:"cedros-admin-user-detail-meta",children:[e.jsxs("h2",{className:"cedros-admin-user-detail-name",children:[p.name||"Unknown",ge&&e.jsx("span",{className:"cedros-admin-user-you",children:"(you)"})]}),e.jsxs("p",{className:"cedros-admin-user-detail-email",children:[p.email||"No email",p.emailVerified&&e.jsx("span",{className:"cedros-admin-verified-badge",title:"Email verified",children:"Verified"})]}),p.isSystemAdmin&&e.jsx("div",{className:"cedros-admin-user-detail-badges",children:e.jsx("span",{className:"cedros-admin-admin-badge cedros-admin-admin-badge-yes",children:"System Admin"})}),e.jsxs("div",{className:"cedros-admin-user-detail-methods",children:[e.jsx("span",{className:"cedros-admin-user-detail-methods-label",children:"Auth Methods:"}),p.authMethods.length>0?p.authMethods.map(z=>e.jsx("span",{className:`cedros-admin-auth-badge cedros-admin-auth-badge-${z}`,children:z},z)):e.jsx("span",{className:"cedros-admin-auth-badge cedros-admin-auth-badge-none",children:"none"})]}),e.jsxs("p",{className:"cedros-admin-user-detail-dates",children:["Registered: ",_t(p.createdAt)," | Updated: ",_t(p.updatedAt)]})]})]}),P?e.jsxs("div",{className:"cedros-admin-stats-error",children:[e.jsx("p",{className:"cedros-admin-error-inline",children:P}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{k(null),U()},children:"Retry"})]}):j?e.jsxs("div",{className:"cedros-admin-user-detail-stats",children:[e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Credit Balance"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Ke(j.stats.currentBalanceLamports)})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Total Credited"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Ke(j.stats.totalDepositedLamports)})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Total Spent"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Ke(j.stats.totalSpentLamports)})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Deposits"}),e.jsx("span",{className:"cedros-admin-stat-value",children:j.stats.depositCount})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Transactions"}),e.jsx("span",{className:"cedros-admin-stat-value",children:j.stats.spendCount})]})]}):e.jsxs("div",{className:"cedros-admin-stats-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{children:"Loading credit stats..."})]}),e.jsxs("div",{className:"cedros-admin-user-detail-tabs",children:[e.jsxs("button",{type:"button",className:`cedros-admin-tab ${C==="deposits"?"cedros-admin-tab-active":""}`,onClick:()=>T("deposits"),children:["Deposits (",A?.total??0,")"]}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${C==="transactions"?"cedros-admin-tab-active":""}`,onClick:()=>T("transactions"),children:["Credits (",j?.totalTransactions??0,")"]}),o&&e.jsxs("button",{type:"button",className:`cedros-admin-tab ${C==="chats"?"cedros-admin-tab-active":""}`,onClick:()=>T("chats"),children:["Chats (",S?.total??0,")"]})]}),e.jsxs("div",{className:"cedros-admin-user-detail-content",children:[C==="deposits"&&e.jsx(hi,{deposits:A?.deposits??[],total:A?.total??0,currentPage:Me,totalPages:Fe,onPageChange:De,isLoading:l,error:_,onRetry:()=>{M(null),F()}}),C==="transactions"&&e.jsx(mi,{transactions:j?.transactions??[],total:j?.totalTransactions??0,currentPage:us,totalPages:fe,onPageChange:ve,error:P,onRetry:()=>{k(null),U()},isLoading:l}),C==="chats"&&o&&e.jsx(pi,{sessions:S?.sessions??[],total:S?.total??0,currentPage:hs,totalPages:Be,onPageChange:ms,error:D,onRetry:()=>{B(null),q()},isLoading:l})]})]})}function hi({deposits:s,total:t,currentPage:r,totalPages:a,onPageChange:n,isLoading:o,error:c,onRetry:l}){return c?e.jsxs("div",{className:"cedros-admin-tab-error",children:[e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:l,children:"Retry"})]}):o&&s.length===0?e.jsxs("div",{className:"cedros-admin-tab-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{children:"Loading deposits..."})]}):t===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No deposits found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table",children:[e.jsxs("div",{className:"cedros-admin-list-thead",children:[e.jsx("div",{className:"cedros-admin-list-th",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Status"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Transaction"})]}),s.map(d=>e.jsxs("div",{className:"cedros-admin-list-row",children:[e.jsx("div",{className:"cedros-admin-list-td",children:Xs(d.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",children:ci(d.amountLamports)}),e.jsx("div",{className:"cedros-admin-list-td",children:e.jsx("span",{className:`cedros-admin-status-badge cedros-admin-status-${d.status}`,children:d.status})}),e.jsx("div",{className:"cedros-admin-list-td cedros-admin-list-td-actions",children:d.txSignature?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"cedros-admin-list-td-mono",title:d.txSignature,children:[d.txSignature.slice(0,8),"..."]}),e.jsx("a",{href:`https://orbmarkets.io/tx/${d.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-admin-icon-link",title:"View on Orbmarkets","aria-label":"View transaction on Orbmarkets",children:"↗"})]}):e.jsx("span",{className:"cedros-admin-list-td-muted",children:"—"})})]},d.id))]}),a>1&&e.jsx(Zs,{currentPage:r,totalPages:a,total:t,onPageChange:n})]})}function mi({transactions:s,total:t,currentPage:r,totalPages:a,onPageChange:n,isLoading:o,error:c,onRetry:l}){return c?e.jsxs("div",{className:"cedros-admin-tab-error",children:[e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:l,children:"Retry"})]}):o&&s.length===0?e.jsxs("div",{className:"cedros-admin-tab-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{children:"Loading transactions..."})]}):t===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No credit transactions found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table",children:[e.jsxs("div",{className:"cedros-admin-list-thead",children:[e.jsx("div",{className:"cedros-admin-list-th",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Type"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Description"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Amount"})]}),s.map(d=>e.jsxs("div",{className:"cedros-admin-list-row",children:[e.jsx("div",{className:"cedros-admin-list-td",children:Xs(d.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",children:e.jsx("span",{className:`cedros-admin-tx-type cedros-admin-tx-type-${d.txType.toLowerCase()}`,children:di(d.txType)})}),e.jsx("div",{className:"cedros-admin-list-td",children:ui(d.txType,d.referenceType)}),e.jsxs("div",{className:`cedros-admin-list-td ${d.amountLamports>=0?"cedros-admin-amount-positive":"cedros-admin-amount-negative"}`,children:[d.amountLamports>=0?"+":"",Ke(d.amountLamports)]})]},d.id))]}),a>1&&e.jsx(Zs,{currentPage:r,totalPages:a,total:t,onPageChange:n})]})}function pi({sessions:s,total:t,currentPage:r,totalPages:a,onPageChange:n,isLoading:o,error:c,onRetry:l}){return c?e.jsxs("div",{className:"cedros-admin-tab-error",children:[e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:l,children:"Retry"})]}):o&&s.length===0?e.jsxs("div",{className:"cedros-admin-tab-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{children:"Loading chat history..."})]}):t===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No chat sessions found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table",children:[e.jsxs("div",{className:"cedros-admin-list-thead",children:[e.jsx("div",{className:"cedros-admin-list-th",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Session"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Messages"})]}),s.map(d=>e.jsxs("div",{className:"cedros-admin-list-row",children:[e.jsx("div",{className:"cedros-admin-list-td",children:Xs(d.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",children:d.title||`Chat ${d.id.slice(0,8)}...`}),e.jsx("div",{className:"cedros-admin-list-td",children:d.messageCount})]},d.id))]}),a>1&&e.jsx(Zs,{currentPage:r,totalPages:a,total:t,onPageChange:n})]})}function Zs({currentPage:s,totalPages:t,total:r,onPageChange:a}){return e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>a(s-1),disabled:s<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",s," of ",t," (",r," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>a(s+1),disabled:s>=t,children:"Next"})]})}function He({checked:s,onChange:t,disabled:r,label:a}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":a,disabled:r,className:`cedros-toggle cedros-toggle-sm ${s?"cedros-toggle-on":"cedros-toggle-off"} ${r?"cedros-toggle-disabled":""}`,onClick:()=>!r&&t(!s),children:e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})})})}function rn({userRole:s}){const{permissions:t,updatePermissions:r,isLoading:a,isUpdating:n,error:o}=Kr(),{features:c,isLoading:l}=Js(),d=i.useRef(null),u=i.useRef(null),f=s==="owner",m=c.cedrosPay,h=i.useCallback(g=>{u.current=g,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{u.current&&(r(u.current).catch(()=>{}),u.current=null)},500)},[r]);i.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const b=i.useCallback((g,p,x)=>{const j={...t,[g]:{...t[g],[p]:x}};h(j)},[t,h]);return a||l?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx("div",{className:"cedros-dashboard__loading",children:"Loading permissions..."})}):f?e.jsxs("div",{className:"cedros-dashboard__section cedros-permissions-section",children:[e.jsxs("div",{className:"cedros-permissions-header",children:[e.jsx("p",{className:"cedros-permissions-description",children:"Configure which dashboard sections each role can access. Owners always have full access."}),o&&e.jsx("div",{className:"cedros-permissions-error",children:o.message}),n&&e.jsx("span",{className:"cedros-permissions-saving",children:"Saving..."})]}),e.jsx("div",{className:"cedros-permissions-matrix",children:e.jsx("table",{className:"cedros-permissions-table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{className:"cedros-permissions-group-header",children:[e.jsx("th",{className:"cedros-permissions-section-header",children:"Cedros Login"}),e.jsx("th",{className:"cedros-permissions-role-header",children:"Admin"}),e.jsx("th",{className:"cedros-permissions-role-header",children:"Member"})]}),Ho.map(g=>e.jsxs("tr",{className:"cedros-permissions-row",children:[e.jsx("td",{className:"cedros-permissions-section-label",children:Ae[g]}),e.jsx("td",{className:"cedros-permissions-toggle-cell",children:e.jsx(He,{checked:t.admin[g]??!1,onChange:p=>b("admin",g,p),disabled:n,label:`Admin access to ${Ae[g]}`})}),e.jsx("td",{className:"cedros-permissions-toggle-cell",children:e.jsx(He,{checked:t.member[g]??!1,onChange:p=>b("member",g,p),disabled:n,label:`Member access to ${Ae[g]}`})})]},g)),m&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"cedros-permissions-group-header",children:[e.jsx("th",{className:"cedros-permissions-section-header",children:"Cedros Pay"}),e.jsx("th",{className:"cedros-permissions-role-header",children:"Admin"}),e.jsx("th",{className:"cedros-permissions-role-header",children:"Member"})]}),Qo.map(g=>e.jsxs("tr",{className:"cedros-permissions-row",children:[e.jsx("td",{className:"cedros-permissions-section-label",children:Ae[g]}),e.jsx("td",{className:"cedros-permissions-toggle-cell",children:e.jsx(He,{checked:t.admin[g]??!1,onChange:p=>b("admin",g,p),disabled:n,label:`Admin access to ${Ae[g]}`})}),e.jsx("td",{className:"cedros-permissions-toggle-cell",children:e.jsx(He,{checked:t.member[g]??!1,onChange:p=>b("member",g,p),disabled:n,label:`Member access to ${Ae[g]}`})})]},g))]})]})})})]}):e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx("div",{className:"cedros-dashboard__empty",children:"Only organization owners can configure dashboard permissions."})})}function et({name:s,email:t,picture:r,onSettings:a,onLogout:n,className:o=""}){const[c,l]=i.useState(!1),d=i.useRef(null);i.useEffect(()=>{function b(g){d.current&&!d.current.contains(g.target)&&l(!1)}if(c)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[c]),i.useEffect(()=>{function b(g){g.key==="Escape"&&l(!1)}if(c)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[c]);const u=i.useCallback(()=>{l(!1),a?.()},[a]),f=i.useCallback(()=>{l(!1),n?.()},[n]),m=s||"User",h=(s?.[0]||t?.[0]||"?").toUpperCase();return e.jsxs("div",{className:`cedros-profile-dropdown ${o}`,ref:d,children:[e.jsxs("button",{type:"button",className:"cedros-profile-dropdown__trigger",onClick:()=>l(!c),"aria-expanded":c,"aria-haspopup":"menu",children:[e.jsx("div",{className:"cedros-profile-dropdown__avatar",children:r?e.jsx("img",{src:r,alt:m,className:"cedros-profile-dropdown__avatar-img",referrerPolicy:"no-referrer"}):e.jsx("span",{className:"cedros-profile-dropdown__avatar-placeholder",children:h})}),e.jsxs("div",{className:"cedros-profile-dropdown__info",children:[e.jsx("span",{className:"cedros-profile-dropdown__name",children:m}),t&&e.jsx("span",{className:"cedros-profile-dropdown__email",children:t})]}),e.jsx("svg",{className:`cedros-profile-dropdown__chevron ${c?"cedros-profile-dropdown__chevron--open":""}`,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),c&&e.jsxs("div",{className:"cedros-profile-dropdown__menu",role:"menu",children:[a&&e.jsxs("button",{type:"button",className:"cedros-profile-dropdown__item",onClick:u,role:"menuitem",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:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),"Settings"]}),n&&e.jsxs("button",{type:"button",className:"cedros-profile-dropdown__item cedros-profile-dropdown__item--danger",onClick:f,role:"menuitem",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:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),e.jsx("polyline",{points:"16 17 21 12 16 7"}),e.jsx("line",{x1:"21",x2:"9",y1:"12",y2:"12"})]}),"Log out"]})]})]})}const ie={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"})]})},fi=[{id:"users",label:"Users",icon:ie.users},{id:"team",label:"Team",icon:ie.members},{id:"deposits",label:"Deposits",icon:ie.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:ie.withdrawals,requiredFeature:"credits"},{id:"settings-auth",label:"Authentication",icon:ie.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:ie.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:ie.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:ie.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-server",label:"Auth Server",icon:ie.server,group:"Configuration"}];function gi({title:s="Dashboard",sections:t=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server"],defaultSection:r="users",refreshInterval:a=0,pageSize:n=20,onSectionChange:o,onSettingsClick:c,onLogoutClick:l,className:d=""}){const[u,f]=i.useState(r),[m,h]=i.useState(!0),{user:b,logout:g}=N.useCedrosLogin(),{activeOrg:p,role:x,isLoading:j,fetchOrgs:y,hasPermission:A}=is(),{status:v,isLoading:S,checkStatus:w}=Ys(),{features:C,isLoading:T}=Js(),{canAccess:L}=Kr(),E=i.useCallback(D=>{f(D),o?.(D)},[o]),P=fi.filter(D=>!(!t.includes(D.id)||D.requiredFeature&&!C[D.requiredFeature]||!L(D.id))),k=P.find(D=>D.id===u),_=!k&&!T;return i.useEffect(()=>{y(),w()},[y,w]),i.useEffect(()=>{_&&P.length>0&&f("users")},[_,P.length]),!S&&v?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${d}`,children:e.jsx(Br,{onComplete:()=>w()})}):(j||S||T)&&!p?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${d}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):u==="team"&&!p?e.jsx("div",{className:`cedros-admin cedros-dashboard ${d}`,children:e.jsx(N.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${d}`,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:[ie.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:s})]})}),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"}),P.filter(D=>!D.group).map(D=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===D.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>E(D.id),"aria-current":u===D.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:D.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:D.label})]},D.id))]}),P.some(D=>D.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:()=>h(!m),"aria-expanded":m,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${m?"cedros-dashboard__nav-chevron--expanded":""}`,children:ie.chevronRight})]}),m&&P.filter(D=>D.group==="Configuration").map(D=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===D.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>E(D.id),"aria-current":u===D.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:D.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:D.label})]},D.id))]})]}),b&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(et,{name:b.name,email:b.email,picture:b.picture,onSettings:c,onLogout:l??g})})]}),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:s}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:ie.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:k?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[u==="users"&&e.jsx(bi,{pageSize:n,currentUserId:b?.id}),u==="team"&&p&&e.jsx(yi,{orgId:p.id,currentUserId:b?.id,hasPermission:A,role:x}),u==="deposits"&&e.jsx(wi,{pageSize:n,refreshInterval:a}),u==="withdrawals"&&e.jsx(xi,{pageSize:n,refreshInterval:a}),u==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Wr,{})}),u==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx($r,{})}),u==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(qo,{})}),u==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(zr,{})}),u==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Vr,{})})]})]})]})}function bi({pageSize:s,currentUserId:t}){const[r,a]=i.useState(null),[n,o]=i.useState(null),[c,l]=i.useState(!1),[d,u]=i.useState(null),{getStats:f}=ls(),{fetchSettings:m,getValue:h}=Ue(),[b,g]=i.useState(!1);i.useEffect(()=>{b||(m(),g(!0))},[m,b]);const p=i.useCallback(y=>{const A=h(y);return A===void 0?!1:A==="true"||A==="1"},[h]),x=i.useCallback(async()=>{l(!0),u(null);try{const y=await f();o(y)}catch(y){u(y instanceof Error?y.message:"Failed to load user stats")}finally{l(!1)}},[f]);i.useEffect(()=>{x()},[x]);const j=i.useMemo(()=>{const y=[{label:"Total Users",value:n?.total??"—"}],A=p("auth_email_enabled"),v=p("auth_google_enabled"),S=p("auth_apple_enabled"),w=p("auth_solana_enabled"),C=p("auth_webauthn_enabled"),T=p("feature_sso");return A&&y.push({label:"Email Users",value:n?.authMethodCounts.email??0}),v&&y.push({label:"Google Users",value:n?.authMethodCounts.google??0}),S&&y.push({label:"Apple Users",value:n?.authMethodCounts.apple??0}),w&&y.push({label:"Solana Users",value:n?.authMethodCounts.solana??0}),C&&y.push({label:"Passkey Users",value:n?.authMethodCounts.webauthn??0}),T&&y.push({label:"SSO Provider Users",value:n?.authMethodCounts.sso??0}),y},[n,p]);return r?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(tn,{userId:r.id,currentUserId:t,onBack:()=>a(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(Ce,{stats:j,isLoading:c,onRefresh:x}),d&&e.jsx("p",{className:"cedros-admin-error-inline",children:d}),e.jsx(sn,{pageSize:s,currentUserId:t,onUserClick:y=>a(y)})]})}function yi({orgId:s,currentUserId:t,hasPermission:r,role:a}){const[n,o]=i.useState("members"),{members:c,isLoading:l,error:d,fetchMembers:u,updateMemberRole:f,removeMember:m}=Hr(s),{invites:h,isLoading:b,error:g,fetchInvites:p,createInvite:x,cancelInvite:j,resendInvite:y}=Qr(s);i.useEffect(()=>{u(),p()},[u,p]);const A=r("invite:create"),v=r("invite:cancel"),S=h.length,w=c.reduce((E,P)=>(E[P.role]=(E[P.role]??0)+1,E),{}),C=w.owner??0,T=w.admin??0,L=w.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(Ce,{stats:[{label:"Owners",value:C},{label:"Admins",value:T},{label:"Members",value:L},{label:"Pending Invites",value:S}]}),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:()=>o("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:()=>o("invites"),"aria-selected":n==="invites",role:"tab",children:["Pending Invites",S>0&&` (${S})`]}),a==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>o("permissions"),"aria-selected":n==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[n==="members"&&e.jsx(vr,{members:c,currentUserId:t,isLoading:l,error:d?.message,canManage:r("member:remove"),canChangeRoles:r("member:role_change"),onUpdateRole:f,onRemove:m}),n==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[A&&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(jr,{onSubmit:x,isLoading:b,error:g?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ar,{invites:h,isLoading:b,error:g?.message,canManage:v||A,onCancel:v?j:void 0,onResend:A?y:void 0})})]}),n==="permissions"&&a==="owner"&&e.jsx(rn,{userRole:a})]})]})}function wi({pageSize:s,refreshInterval:t}){const[r,a]=i.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(Gr,{refreshInterval:t}),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=>a(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(Jr,{statusFilter:r||void 0,pageSize:s,refreshInterval:t})]})]})}function xi({pageSize:s,refreshInterval:t}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(Yr,{refreshInterval:t}),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(Zr,{pageSize:s,refreshInterval:t}),e.jsx(Xr,{pageSize:s,refreshInterval:t}),e.jsx(en,{pageSize:s,refreshInterval:t})]})]})}class vi{plugins=new Map;listeners=new Set;register(t){this.plugins.has(t.id)&&console.warn(`Plugin ${t.id} already registered, replacing...`),this.plugins.set(t.id,t),t.onRegister?.(this),this.notify()}unregister(t){const r=this.plugins.get(t);r&&(r.onUnregister?.(),this.plugins.delete(t),this.notify())}get(t){return this.plugins.get(t)}getAll(){return Array.from(this.plugins.values())}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){const t=this.getAll();this.listeners.forEach(r=>r(t))}}const nn=i.createContext(null);function ji(){const s=i.useContext(nn);if(!s)throw new Error("useAdminShell must be used within AdminShell");return s}const Et={Users:0,Store:1,Configuration:2};function Ai({title:s="Admin",plugins:t=[],hostContext:r,defaultSection:a,pageSize:n=20,refreshInterval:o=0,onSectionChange:c,logo:l,sidebarFooter:d,onSettingsClick:u,onLogoutClick:f,className:m=""}){const[h]=i.useState(()=>{const E=new vi;return t.forEach(P=>E.register(P)),E}),[b,g]=i.useState(()=>h.getAll());i.useEffect(()=>h.subscribe(g),[h]);const p=i.useMemo(()=>b.flatMap(E=>E.sections.filter(P=>!(P.requiredPermission&&!E.checkPermission(P.requiredPermission,r)||r.dashboardPermissions&&!r.dashboardPermissions.canAccess(P.id))).map(P=>({...P,qualifiedId:`${E.id}:${P.id}`,pluginId:E.id,cssNamespace:E.cssNamespace}))),[b,r]),[x,j]=i.useState(()=>a??p[0]?.qualifiedId??null),[y,A]=i.useState(new Set),v=i.useCallback(E=>{A(P=>{const k=new Set(P);return k.has(E)?k.delete(E):k.add(E),k})},[]);i.useEffect(()=>{x&&!p.find(E=>E.qualifiedId===x)&&j(p[0]?.qualifiedId??null)},[p,x]);const S=i.useCallback(E=>{j(E),c?.(E)},[c]),w=i.useCallback(E=>{const P=h.get(E);return P?P.createPluginContext(r):null},[h,r]),C=i.useMemo(()=>{const E=new Map;return p.forEach(k=>{const _=k.group??"Menu",M=E.get(_)??[];E.set(_,[...M,k])}),Array.from(E.entries()).sort(([k],[_])=>{const M=Et[k]??99,D=Et[_]??99;return M-D})},[p]),T=i.useMemo(()=>{if(!x)return null;const[E,P]=x.split(":"),k=h.get(E);if(!k)return null;const _=k.components[P];if(!_)return null;const M=k.createPluginContext(r);return{Component:_,pluginContext:M,plugin:k}},[x,h,r]),L=i.useMemo(()=>({registry:h,hostContext:r,activeSection:x,setActiveSection:S,getPluginContext:w}),[h,r,x,S,w]);return e.jsx(nn.Provider,{value:L,children:e.jsxs("div",{className:`cedros-admin cedros-admin-shell ${m}`,children:[e.jsxs("aside",{className:"cedros-admin-shell__sidebar",children:[e.jsx("div",{className:"cedros-admin-shell__sidebar-header",children:l??e.jsx("div",{className:"cedros-admin-shell__logo",children:e.jsx("span",{className:"cedros-admin-shell__logo-text",children:s})})}),e.jsx("nav",{className:"cedros-admin-shell__nav",children:C.map(([E,P])=>{const k=E==="Configuration",_=y.has(E);return e.jsxs("div",{className:"cedros-admin-shell__nav-group",children:[k?e.jsxs("button",{type:"button",className:"cedros-admin-shell__nav-label cedros-admin-shell__nav-label--collapsible",onClick:()=>v(E),"aria-expanded":!_,children:[e.jsx("span",{children:E}),e.jsx("span",{className:`cedros-admin-shell__nav-chevron ${_?"":"cedros-admin-shell__nav-chevron--expanded"}`,children: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"})})})]}):e.jsx("span",{className:"cedros-admin-shell__nav-label",children:E}),(!k||!_)&&P.sort((M,D)=>(M.order??0)-(D.order??0)).map(M=>e.jsxs("button",{type:"button",className:`cedros-admin-shell__nav-item ${x===M.qualifiedId?"cedros-admin-shell__nav-item--active":""}`,onClick:()=>S(M.qualifiedId),"aria-current":x===M.qualifiedId?"page":void 0,children:[e.jsx("span",{className:"cedros-admin-shell__nav-icon",children:M.icon}),e.jsx("span",{className:"cedros-admin-shell__nav-text",children:M.label}),M.badge&&e.jsx("span",{className:"cedros-admin-shell__nav-badge",children:M.badge})]},M.qualifiedId))]},E)})}),(r.cedrosLogin?.user||d)&&e.jsxs("div",{className:"cedros-admin-shell__sidebar-footer",children:[r.cedrosLogin?.user&&e.jsx(et,{name:r.cedrosLogin.user.name,email:r.cedrosLogin.user.email,picture:r.cedrosLogin.user.picture,onSettings:u,onLogout:f}),d]})]}),e.jsx("main",{className:"cedros-admin-shell__main",children:T?e.jsx(i.Suspense,{fallback:e.jsx(ki,{}),children:e.jsx("div",{className:"cedros-admin-shell__section","data-plugin-namespace":T.plugin.cssNamespace,children:e.jsx(T.Component,{pluginContext:T.pluginContext,pageSize:n,refreshInterval:o})})}):e.jsx("div",{className:"cedros-admin-shell__empty",children:p.length===0?"No plugins loaded":"Select a section from the sidebar"})})]})})}function ki(){return e.jsxs("div",{className:"cedros-admin-shell__loading",children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading..."})]})}const te={width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ce={users:e.jsxs("svg",{...te,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",{...te,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"})]}),invites:e.jsxs("svg",{...te,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"})]}),deposits:e.jsxs("svg",{...te,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",{...te,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"})]}),settings:e.jsxs("svg",{...te,children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),wallet:e.jsxs("svg",{...te,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",{...te,children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{...te,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"})}),toggles:e.jsxs("svg",{...te,children:[e.jsx("rect",{width:"20",height:"12",x:"2",y:"6",rx:"6"}),e.jsx("circle",{cx:"8",cy:"12",r:"2"})]}),shield:e.jsx("svg",{...te,children:e.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),mail:e.jsxs("svg",{...te,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"})]}),webhook:e.jsxs("svg",{...te,children:[e.jsx("path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2"}),e.jsx("path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06"}),e.jsx("path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8"})]}),coins:e.jsxs("svg",{...te,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",{...te,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"})]})},Ni=i.lazy(()=>Promise.resolve().then(()=>require("./UsersSection-BiZceDV3.cjs"))),Si=i.lazy(()=>Promise.resolve().then(()=>require("./TeamSection-DQ4nfUHN.cjs"))),Ci=i.lazy(()=>Promise.resolve().then(()=>require("./DepositsSection-Ct1gjgIg.cjs"))),_i=i.lazy(()=>Promise.resolve().then(()=>require("./WithdrawalsSection-Cws8inf6.cjs"))),Ei=i.lazy(()=>Promise.resolve().then(()=>require("./AuthenticationSettings-Cro76kIC.cjs"))),Pi=i.lazy(()=>Promise.resolve().then(()=>require("./EmbeddedWalletSettings-DRWeIJKb.cjs"))),Ti=i.lazy(()=>Promise.resolve().then(()=>require("./EmailSettings-DFZ13JbX.cjs"))),Li=i.lazy(()=>Promise.resolve().then(()=>require("./WebhookSettings-onJWLytD.cjs"))),Mi=i.lazy(()=>Promise.resolve().then(()=>require("./CreditSystemSettings-CGR-uzuh.cjs"))),Di=i.lazy(()=>Promise.resolve().then(()=>require("./ServerSettings-D8w8EpoE.cjs"))),Ri={"login:users:read":["admin","owner"],"login:users:write":["admin","owner"],"login:members:read":["member:read","admin","owner"],"login:members:write":["member:remove","member:role_change"],"login:invites:read":["invite:read","admin","owner"],"login:invites:write":["invite:create","invite:cancel"],"login:deposits:read":["admin","owner"],"login:deposits:write":["admin","owner"],"login:settings:read":["admin","owner"],"login:settings:write":["admin","owner"]},Ii=[{id:"users",label:"Users",icon:ce.users,group:"Users",order:0,requiredPermission:"login:users:read"},{id:"team",label:"Team",icon:ce.members,group:"Users",order:1,requiredPermission:"login:members:read"},{id:"deposits",label:"Deposits",icon:ce.deposits,group:"Users",order:2,requiredPermission:"login:deposits:read"},{id:"withdrawals",label:"Withdrawals",icon:ce.withdrawals,group:"Users",order:3,requiredPermission:"login:deposits:read"},{id:"settings-auth",label:"Authentication",icon:ce.key,group:"Configuration",order:0,requiredPermission:"login:settings:read"},{id:"settings-email",label:"Email & SMTP",icon:ce.mail,group:"Configuration",order:1,requiredPermission:"login:settings:read"},{id:"settings-webhooks",label:"Webhooks",icon:ce.webhook,group:"Configuration",order:2,requiredPermission:"login:settings:read"},{id:"settings-wallet",label:"User Wallets",icon:ce.wallet,group:"Configuration",order:3,requiredPermission:"login:settings:read"},{id:"settings-credits",label:"Credit System",icon:ce.coins,group:"Configuration",order:4,requiredPermission:"login:settings:read"},{id:"settings-server",label:"Auth Server",icon:ce.server,group:"Configuration",order:5,requiredPermission:"login:settings:read"}],Ui={id:"cedros-login",name:"Cedros Login",version:"1.0.0",sections:Ii,groups:[{id:"users",label:"Users",order:0},{id:"configuration",label:"Configuration",order:2}],components:{users:Ni,team:Si,deposits:Ci,withdrawals:_i,"settings-auth":Ei,"settings-wallet":Pi,"settings-email":Ti,"settings-webhooks":Li,"settings-credits":Mi,"settings-server":Di},createPluginContext(s){const t=s.cedrosLogin;if(!t)throw new Error("cedros-login plugin requires cedrosLogin in hostContext");return{serverUrl:t.serverUrl,userId:t.user?.id,getAccessToken:t.getAccessToken,hasPermission:r=>this.checkPermission(r,s),orgId:s.org?.orgId,pluginData:{user:t.user,orgRole:s.org?.role}}},checkPermission(s,t){const r=t.org;if(!r)return!!t.cedrosLogin?.user;const a=Ri[s];return a?a.some(n=>r.permissions.includes(n)||n===r.role||n==="admin"&&["admin","owner"].includes(r.role)||n==="owner"&&r.role==="owner"):!1},cssNamespace:"cedros-dashboard"};var ke={},xs,Pt;function Fi(){return Pt||(Pt=1,xs=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),xs}var vs={},pe={},Tt;function we(){if(Tt)return pe;Tt=1;let s;const t=[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(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17},pe.getSymbolTotalCodewords=function(a){return t[a]},pe.getBCHDigit=function(r){let a=0;for(;r!==0;)a++,r>>>=1;return a},pe.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');s=a},pe.isKanjiModeEnabled=function(){return typeof s<"u"},pe.toSJIS=function(a){return s(a)},pe}var js={},Lt;function st(){return Lt||(Lt=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function t(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+r)}}s.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},s.from=function(a,n){if(s.isValid(a))return a;try{return t(a)}catch{return n}}})(js)),js}var As,Mt;function Bi(){if(Mt)return As;Mt=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(t){const r=Math.floor(t/8);return(this.buffer[r]>>>7-t%8&1)===1},put:function(t,r){for(let a=0;a<r;a++)this.putBit((t>>>r-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}},As=s,As}var ks,Dt;function Oi(){if(Dt)return ks;Dt=1;function s(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return s.prototype.set=function(t,r,a,n){const o=t*this.size+r;this.data[o]=a,n&&(this.reservedBit[o]=!0)},s.prototype.get=function(t,r){return this.data[t*this.size+r]},s.prototype.xor=function(t,r,a){this.data[t*this.size+r]^=a},s.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]},ks=s,ks}var Ns={},Rt;function qi(){return Rt||(Rt=1,(function(s){const t=we().getSymbolSize;s.getRowColCoords=function(a){if(a===1)return[];const n=Math.floor(a/7)+2,o=t(a),c=o===145?26:Math.ceil((o-13)/(2*n-2))*2,l=[o-7];for(let d=1;d<n-1;d++)l[d]=l[d-1]-c;return l.push(6),l.reverse()},s.getPositions=function(a){const n=[],o=s.getRowColCoords(a),c=o.length;for(let l=0;l<c;l++)for(let d=0;d<c;d++)l===0&&d===0||l===0&&d===c-1||l===c-1&&d===0||n.push([o[l],o[d]]);return n}})(Ns)),Ns}var Ss={},It;function Wi(){if(It)return Ss;It=1;const s=we().getSymbolSize,t=7;return Ss.getPositions=function(a){const n=s(a);return[[0,0],[n-t,0],[0,n-t]]},Ss}var Cs={},Ut;function $i(){return Ut||(Ut=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};s.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},s.from=function(n){return s.isValid(n)?parseInt(n,10):void 0},s.getPenaltyN1=function(n){const o=n.size;let c=0,l=0,d=0,u=null,f=null;for(let m=0;m<o;m++){l=d=0,u=f=null;for(let h=0;h<o;h++){let b=n.get(m,h);b===u?l++:(l>=5&&(c+=t.N1+(l-5)),u=b,l=1),b=n.get(h,m),b===f?d++:(d>=5&&(c+=t.N1+(d-5)),f=b,d=1)}l>=5&&(c+=t.N1+(l-5)),d>=5&&(c+=t.N1+(d-5))}return c},s.getPenaltyN2=function(n){const o=n.size;let c=0;for(let l=0;l<o-1;l++)for(let d=0;d<o-1;d++){const u=n.get(l,d)+n.get(l,d+1)+n.get(l+1,d)+n.get(l+1,d+1);(u===4||u===0)&&c++}return c*t.N2},s.getPenaltyN3=function(n){const o=n.size;let c=0,l=0,d=0;for(let u=0;u<o;u++){l=d=0;for(let f=0;f<o;f++)l=l<<1&2047|n.get(u,f),f>=10&&(l===1488||l===93)&&c++,d=d<<1&2047|n.get(f,u),f>=10&&(d===1488||d===93)&&c++}return c*t.N3},s.getPenaltyN4=function(n){let o=0;const c=n.data.length;for(let d=0;d<c;d++)o+=n.data[d];return Math.abs(Math.ceil(o*100/c/5)-10)*t.N4};function r(a,n,o){switch(a){case s.Patterns.PATTERN000:return(n+o)%2===0;case s.Patterns.PATTERN001:return n%2===0;case s.Patterns.PATTERN010:return o%3===0;case s.Patterns.PATTERN011:return(n+o)%3===0;case s.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(o/3))%2===0;case s.Patterns.PATTERN101:return n*o%2+n*o%3===0;case s.Patterns.PATTERN110:return(n*o%2+n*o%3)%2===0;case s.Patterns.PATTERN111:return(n*o%3+(n+o)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}s.applyMask=function(n,o){const c=o.size;for(let l=0;l<c;l++)for(let d=0;d<c;d++)o.isReserved(d,l)||o.xor(d,l,r(n,d,l))},s.getBestMask=function(n,o){const c=Object.keys(s.Patterns).length;let l=0,d=1/0;for(let u=0;u<c;u++){o(u),s.applyMask(u,n);const f=s.getPenaltyN1(n)+s.getPenaltyN2(n)+s.getPenaltyN3(n)+s.getPenaltyN4(n);s.applyMask(u,n),f<d&&(d=f,l=u)}return l}})(Cs)),Cs}var Qe={},Ft;function an(){if(Ft)return Qe;Ft=1;const s=st(),t=[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 Qe.getBlocksCount=function(n,o){switch(o){case s.L:return t[(n-1)*4+0];case s.M:return t[(n-1)*4+1];case s.Q:return t[(n-1)*4+2];case s.H:return t[(n-1)*4+3];default:return}},Qe.getTotalCodewordsCount=function(n,o){switch(o){case s.L:return r[(n-1)*4+0];case s.M:return r[(n-1)*4+1];case s.Q:return r[(n-1)*4+2];case s.H:return r[(n-1)*4+3];default:return}},Qe}var _s={},Ie={},Bt;function zi(){if(Bt)return Ie;Bt=1;const s=new Uint8Array(512),t=new Uint8Array(256);return(function(){let a=1;for(let n=0;n<255;n++)s[n]=a,t[a]=n,a<<=1,a&256&&(a^=285);for(let n=255;n<512;n++)s[n]=s[n-255]})(),Ie.log=function(a){if(a<1)throw new Error("log("+a+")");return t[a]},Ie.exp=function(a){return s[a]},Ie.mul=function(a,n){return a===0||n===0?0:s[t[a]+t[n]]},Ie}var Ot;function Vi(){return Ot||(Ot=1,(function(s){const t=zi();s.mul=function(a,n){const o=new Uint8Array(a.length+n.length-1);for(let c=0;c<a.length;c++)for(let l=0;l<n.length;l++)o[c+l]^=t.mul(a[c],n[l]);return o},s.mod=function(a,n){let o=new Uint8Array(a);for(;o.length-n.length>=0;){const c=o[0];for(let d=0;d<n.length;d++)o[d]^=t.mul(n[d],c);let l=0;for(;l<o.length&&o[l]===0;)l++;o=o.slice(l)}return o},s.generateECPolynomial=function(a){let n=new Uint8Array([1]);for(let o=0;o<a;o++)n=s.mul(n,new Uint8Array([1,t.exp(o)]));return n}})(_s)),_s}var Es,qt;function Hi(){if(qt)return Es;qt=1;const s=Vi();function t(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(a){this.degree=a,this.genPoly=s.generateECPolynomial(this.degree)},t.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(a.length+this.degree);n.set(a);const o=s.mod(n,this.genPoly),c=this.degree-o.length;if(c>0){const l=new Uint8Array(this.degree);return l.set(o,c),l}return o},Es=t,Es}var Ps={},Ts={},Ls={},Wt;function on(){return Wt||(Wt=1,Ls.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Ls}var ue={},$t;function ln(){if($t)return ue;$t=1;const s="[0-9]+",t="[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 a="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
2050
- ]))+`;ue.KANJI=new RegExp(r,"g"),ue.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),ue.BYTE=new RegExp(a,"g"),ue.NUMERIC=new RegExp(s,"g"),ue.ALPHANUMERIC=new RegExp(t,"g");const n=new RegExp("^"+r+"$"),o=new RegExp("^"+s+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return ue.testKanji=function(d){return n.test(d)},ue.testNumeric=function(d){return o.test(d)},ue.testAlphanumeric=function(d){return c.test(d)},ue}var zt;function xe(){return zt||(zt=1,(function(s){const t=on(),r=ln();s.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},s.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},s.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},s.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},s.MIXED={bit:-1},s.getCharCountIndicator=function(o,c){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?o.ccBits[0]:c<27?o.ccBits[1]:o.ccBits[2]},s.getBestModeForData=function(o){return r.testNumeric(o)?s.NUMERIC:r.testAlphanumeric(o)?s.ALPHANUMERIC:r.testKanji(o)?s.KANJI:s.BYTE},s.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},s.isValid=function(o){return o&&o.bit&&o.ccBits};function a(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"numeric":return s.NUMERIC;case"alphanumeric":return s.ALPHANUMERIC;case"kanji":return s.KANJI;case"byte":return s.BYTE;default:throw new Error("Unknown mode: "+n)}}s.from=function(o,c){if(s.isValid(o))return o;try{return a(o)}catch{return c}}})(Ts)),Ts}var Vt;function Qi(){return Vt||(Vt=1,(function(s){const t=we(),r=an(),a=st(),n=xe(),o=on(),c=7973,l=t.getBCHDigit(c);function d(h,b,g){for(let p=1;p<=40;p++)if(b<=s.getCapacity(p,g,h))return p}function u(h,b){return n.getCharCountIndicator(h,b)+4}function f(h,b){let g=0;return h.forEach(function(p){const x=u(p.mode,b);g+=x+p.getBitsLength()}),g}function m(h,b){for(let g=1;g<=40;g++)if(f(h,g)<=s.getCapacity(g,b,n.MIXED))return g}s.from=function(b,g){return o.isValid(b)?parseInt(b,10):g},s.getCapacity=function(b,g,p){if(!o.isValid(b))throw new Error("Invalid QR Code version");typeof p>"u"&&(p=n.BYTE);const x=t.getSymbolTotalCodewords(b),j=r.getTotalCodewordsCount(b,g),y=(x-j)*8;if(p===n.MIXED)return y;const A=y-u(p,b);switch(p){case n.NUMERIC:return Math.floor(A/10*3);case n.ALPHANUMERIC:return Math.floor(A/11*2);case n.KANJI:return Math.floor(A/13);case n.BYTE:default:return Math.floor(A/8)}},s.getBestVersionForData=function(b,g){let p;const x=a.from(g,a.M);if(Array.isArray(b)){if(b.length>1)return m(b,x);if(b.length===0)return 1;p=b[0]}else p=b;return d(p.mode,p.getLength(),x)},s.getEncodedBits=function(b){if(!o.isValid(b)||b<7)throw new Error("Invalid QR Code version");let g=b<<12;for(;t.getBCHDigit(g)-l>=0;)g^=c<<t.getBCHDigit(g)-l;return b<<12|g}})(Ps)),Ps}var Ms={},Ht;function Ki(){if(Ht)return Ms;Ht=1;const s=we(),t=1335,r=21522,a=s.getBCHDigit(t);return Ms.getEncodedBits=function(o,c){const l=o.bit<<3|c;let d=l<<10;for(;s.getBCHDigit(d)-a>=0;)d^=t<<s.getBCHDigit(d)-a;return(l<<10|d)^r},Ms}var Ds={},Rs,Qt;function Gi(){if(Qt)return Rs;Qt=1;const s=xe();function t(r){this.mode=s.NUMERIC,this.data=r.toString()}return t.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(a){let n,o,c;for(n=0;n+3<=this.data.length;n+=3)o=this.data.substr(n,3),c=parseInt(o,10),a.put(c,10);const l=this.data.length-n;l>0&&(o=this.data.substr(n),c=parseInt(o,10),a.put(c,l*3+1))},Rs=t,Rs}var Is,Kt;function Yi(){if(Kt)return Is;Kt=1;const s=xe(),t=["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(a){this.mode=s.ALPHANUMERIC,this.data=a}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 o;for(o=0;o+2<=this.data.length;o+=2){let c=t.indexOf(this.data[o])*45;c+=t.indexOf(this.data[o+1]),n.put(c,11)}this.data.length%2&&n.put(t.indexOf(this.data[o]),6)},Is=r,Is}var Us,Gt;function Ji(){if(Gt)return Us;Gt=1;const s=xe();function t(r){this.mode=s.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}return t.getBitsLength=function(a){return a*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(r){for(let a=0,n=this.data.length;a<n;a++)r.put(this.data[a],8)},Us=t,Us}var Fs,Yt;function Xi(){if(Yt)return Fs;Yt=1;const s=xe(),t=we();function r(a){this.mode=s.KANJI,this.data=a}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(a){let n;for(n=0;n<this.data.length;n++){let o=t.toSJIS(this.data[n]);if(o>=33088&&o<=40956)o-=33088;else if(o>=57408&&o<=60351)o-=49472;else throw new Error("Invalid SJIS character: "+this.data[n]+`
2051
- Make sure your charset is UTF-8`);o=(o>>>8&255)*192+(o&255),a.put(o,13)}},Fs=r,Fs}var Bs={exports:{}},Jt;function Zi(){return Jt||(Jt=1,(function(s){var t={single_source_shortest_paths:function(r,a,n){var o={},c={};c[a]=0;var l=t.PriorityQueue.make();l.push(a,0);for(var d,u,f,m,h,b,g,p,x;!l.empty();){d=l.pop(),u=d.value,m=d.cost,h=r[u]||{};for(f in h)h.hasOwnProperty(f)&&(b=h[f],g=m+b,p=c[f],x=typeof c[f]>"u",(x||p>g)&&(c[f]=g,l.push(f,g),o[f]=u))}if(typeof n<"u"&&typeof c[n]>"u"){var j=["Could not find a path from ",a," to ",n,"."].join("");throw new Error(j)}return o},extract_shortest_path_from_predecessor_list:function(r,a){for(var n=[],o=a;o;)n.push(o),r[o],o=r[o];return n.reverse(),n},find_path:function(r,a,n){var o=t.single_source_shortest_paths(r,a,n);return t.extract_shortest_path_from_predecessor_list(o,n)},PriorityQueue:{make:function(r){var a=t.PriorityQueue,n={},o;r=r||{};for(o in a)a.hasOwnProperty(o)&&(n[o]=a[o]);return n.queue=[],n.sorter=r.sorter||a.default_sorter,n},default_sorter:function(r,a){return r.cost-a.cost},push:function(r,a){var n={value:r,cost:a};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=t})(Bs)),Bs.exports}var Xt;function el(){return Xt||(Xt=1,(function(s){const t=xe(),r=Gi(),a=Yi(),n=Ji(),o=Xi(),c=ln(),l=we(),d=Zi();function u(j){return unescape(encodeURIComponent(j)).length}function f(j,y,A){const v=[];let S;for(;(S=j.exec(A))!==null;)v.push({data:S[0],index:S.index,mode:y,length:S[0].length});return v}function m(j){const y=f(c.NUMERIC,t.NUMERIC,j),A=f(c.ALPHANUMERIC,t.ALPHANUMERIC,j);let v,S;return l.isKanjiModeEnabled()?(v=f(c.BYTE,t.BYTE,j),S=f(c.KANJI,t.KANJI,j)):(v=f(c.BYTE_KANJI,t.BYTE,j),S=[]),y.concat(A,v,S).sort(function(C,T){return C.index-T.index}).map(function(C){return{data:C.data,mode:C.mode,length:C.length}})}function h(j,y){switch(y){case t.NUMERIC:return r.getBitsLength(j);case t.ALPHANUMERIC:return a.getBitsLength(j);case t.KANJI:return o.getBitsLength(j);case t.BYTE:return n.getBitsLength(j)}}function b(j){return j.reduce(function(y,A){const v=y.length-1>=0?y[y.length-1]:null;return v&&v.mode===A.mode?(y[y.length-1].data+=A.data,y):(y.push(A),y)},[])}function g(j){const y=[];for(let A=0;A<j.length;A++){const v=j[A];switch(v.mode){case t.NUMERIC:y.push([v,{data:v.data,mode:t.ALPHANUMERIC,length:v.length},{data:v.data,mode:t.BYTE,length:v.length}]);break;case t.ALPHANUMERIC:y.push([v,{data:v.data,mode:t.BYTE,length:v.length}]);break;case t.KANJI:y.push([v,{data:v.data,mode:t.BYTE,length:u(v.data)}]);break;case t.BYTE:y.push([{data:v.data,mode:t.BYTE,length:u(v.data)}])}}return y}function p(j,y){const A={},v={start:{}};let S=["start"];for(let w=0;w<j.length;w++){const C=j[w],T=[];for(let L=0;L<C.length;L++){const E=C[L],P=""+w+L;T.push(P),A[P]={node:E,lastCount:0},v[P]={};for(let k=0;k<S.length;k++){const _=S[k];A[_]&&A[_].node.mode===E.mode?(v[_][P]=h(A[_].lastCount+E.length,E.mode)-h(A[_].lastCount,E.mode),A[_].lastCount+=E.length):(A[_]&&(A[_].lastCount=E.length),v[_][P]=h(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,y))}}S=T}for(let w=0;w<S.length;w++)v[S[w]].end=0;return{map:v,table:A}}function x(j,y){let A;const v=t.getBestModeForData(j);if(A=t.from(y,v),A!==t.BYTE&&A.bit<v.bit)throw new Error('"'+j+'" cannot be encoded with mode '+t.toString(A)+`.
2052
- Suggested mode is: `+t.toString(v));switch(A===t.KANJI&&!l.isKanjiModeEnabled()&&(A=t.BYTE),A){case t.NUMERIC:return new r(j);case t.ALPHANUMERIC:return new a(j);case t.KANJI:return new o(j);case t.BYTE:return new n(j)}}s.fromArray=function(y){return y.reduce(function(A,v){return typeof v=="string"?A.push(x(v,null)):v.data&&A.push(x(v.data,v.mode)),A},[])},s.fromString=function(y,A){const v=m(y,l.isKanjiModeEnabled()),S=g(v),w=p(S,A),C=d.find_path(w.map,"start","end"),T=[];for(let L=1;L<C.length-1;L++)T.push(w.table[C[L]].node);return s.fromArray(b(T))},s.rawSplit=function(y){return s.fromArray(m(y,l.isKanjiModeEnabled()))}})(Ds)),Ds}var Zt;function sl(){if(Zt)return vs;Zt=1;const s=we(),t=st(),r=Bi(),a=Oi(),n=qi(),o=Wi(),c=$i(),l=an(),d=Hi(),u=Qi(),f=Ki(),m=xe(),h=el();function b(w,C){const T=w.size,L=o.getPositions(C);for(let E=0;E<L.length;E++){const P=L[E][0],k=L[E][1];for(let _=-1;_<=7;_++)if(!(P+_<=-1||T<=P+_))for(let M=-1;M<=7;M++)k+M<=-1||T<=k+M||(_>=0&&_<=6&&(M===0||M===6)||M>=0&&M<=6&&(_===0||_===6)||_>=2&&_<=4&&M>=2&&M<=4?w.set(P+_,k+M,!0,!0):w.set(P+_,k+M,!1,!0))}}function g(w){const C=w.size;for(let T=8;T<C-8;T++){const L=T%2===0;w.set(T,6,L,!0),w.set(6,T,L,!0)}}function p(w,C){const T=n.getPositions(C);for(let L=0;L<T.length;L++){const E=T[L][0],P=T[L][1];for(let k=-2;k<=2;k++)for(let _=-2;_<=2;_++)k===-2||k===2||_===-2||_===2||k===0&&_===0?w.set(E+k,P+_,!0,!0):w.set(E+k,P+_,!1,!0)}}function x(w,C){const T=w.size,L=u.getEncodedBits(C);let E,P,k;for(let _=0;_<18;_++)E=Math.floor(_/3),P=_%3+T-8-3,k=(L>>_&1)===1,w.set(E,P,k,!0),w.set(P,E,k,!0)}function j(w,C,T){const L=w.size,E=f.getEncodedBits(C,T);let P,k;for(P=0;P<15;P++)k=(E>>P&1)===1,P<6?w.set(P,8,k,!0):P<8?w.set(P+1,8,k,!0):w.set(L-15+P,8,k,!0),P<8?w.set(8,L-P-1,k,!0):P<9?w.set(8,15-P-1+1,k,!0):w.set(8,15-P-1,k,!0);w.set(L-8,8,1,!0)}function y(w,C){const T=w.size;let L=-1,E=T-1,P=7,k=0;for(let _=T-1;_>0;_-=2)for(_===6&&_--;;){for(let M=0;M<2;M++)if(!w.isReserved(E,_-M)){let D=!1;k<C.length&&(D=(C[k]>>>P&1)===1),w.set(E,_-M,D),P--,P===-1&&(k++,P=7)}if(E+=L,E<0||T<=E){E-=L,L=-L;break}}}function A(w,C,T){const L=new r;T.forEach(function(M){L.put(M.mode.bit,4),L.put(M.getLength(),m.getCharCountIndicator(M.mode,w)),M.write(L)});const E=s.getSymbolTotalCodewords(w),P=l.getTotalCodewordsCount(w,C),k=(E-P)*8;for(L.getLengthInBits()+4<=k&&L.put(0,4);L.getLengthInBits()%8!==0;)L.putBit(0);const _=(k-L.getLengthInBits())/8;for(let M=0;M<_;M++)L.put(M%2?17:236,8);return v(L,w,C)}function v(w,C,T){const L=s.getSymbolTotalCodewords(C),E=l.getTotalCodewordsCount(C,T),P=L-E,k=l.getBlocksCount(C,T),_=L%k,M=k-_,D=Math.floor(L/k),B=Math.floor(P/k),Y=B+1,G=D-B,O=new d(G);let $=0;const I=new Array(k),H=new Array(k);let ee=0;const Z=new Uint8Array(w.buffer);for(let q=0;q<k;q++){const re=q<M?B:Y;I[q]=Z.slice($,$+re),H[q]=O.encode(I[q]),$+=re,ee=Math.max(ee,re)}const Q=new Uint8Array(L);let R=0,F,U;for(F=0;F<ee;F++)for(U=0;U<k;U++)F<I[U].length&&(Q[R++]=I[U][F]);for(F=0;F<G;F++)for(U=0;U<k;U++)Q[R++]=H[U][F];return Q}function S(w,C,T,L){let E;if(Array.isArray(w))E=h.fromArray(w);else if(typeof w=="string"){let D=C;if(!D){const B=h.rawSplit(w);D=u.getBestVersionForData(B,T)}E=h.fromString(w,D||40)}else throw new Error("Invalid data");const P=u.getBestVersionForData(E,T);if(!P)throw new Error("The amount of data is too big to be stored in a QR Code");if(!C)C=P;else if(C<P)throw new Error(`
2049
+ `),oe=12;function On(s){if(s.length!==16)throw new Error(`Invalid share length: expected 16, got ${s.length}`);const r=dr(s,me).split(" ");if(r.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${r.length}`);return r}function qn(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Ks(t,me))throw new Error("Invalid recovery phrase: checksum mismatch");const r=Qs(t,me);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return N.toShamirShare(r)}function Wn(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const r=dr(s,me).split(" ");if(r.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${r.length}`);return r}function $n(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Ks(t,me))throw new Error("Invalid recovery phrase: checksum mismatch");const r=Qs(t,me);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return N.toSeed(r)}function ur(s){if(s.length!==oe)return!1;const t=s.join(" ").toLowerCase().trim();return Ks(t,me)}function ze(s){return me.includes(s.toLowerCase().trim())}function zn(s,t=5){const r=s.toLowerCase().trim();return r.length===0?[]:me.filter(a=>a.startsWith(r)).slice(0,t)}function Vn(s){const t=[];for(let r=0;r<s.length;r+=4)t.push(s.slice(r,r+4));return t}function Hn(s){return s.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function Qn({className:s="",variant:t="default",size:r="md",children:a,menuItems:n=[],hideSignOut:o=!1}){const{user:c,isAuthenticated:l,isLoading:d,openLoginModal:u,logout:f}=N.useAuth(),[m,h]=i.useState(!1),[b,g]=i.useState(-1),p=i.useRef(null),x=i.useRef(null),j=i.useMemo(()=>[...n,...o?[]:[{label:"Sign out",onClick:f}]],[n,o,f]);i.useEffect(()=>{if(!m)return;const w=T=>{p.current&&!p.current.contains(T.target)&&(h(!1),g(-1))},C=T=>{T.key==="Escape"&&(h(!1),g(-1),x.current?.focus())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",C)}},[m]);const y=i.useCallback(w=>{if(!(!m||j.length===0))switch(w.key){case"ArrowDown":w.preventDefault(),g(C=>(C+1)%j.length);break;case"ArrowUp":w.preventDefault(),g(C=>(C-1+j.length)%j.length);break;case"Home":w.preventDefault(),g(0);break;case"End":w.preventDefault(),g(j.length-1);break;case"Enter":case" ":b>=0&&(w.preventDefault(),j[b].onClick(),h(!1),g(-1));break}},[m,b,j]),A=i.useCallback(()=>{j.length!==0&&(h(w=>!w),g(-1))},[j.length]),v={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},S={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(d)return e.jsx("button",{type:"button",className:`cedros-button ${S[t]} ${v[r]} ${s}`,disabled:!0,children:e.jsx(N.LoadingSpinner,{size:"sm"})});if(l&&c){const w=c.name||c.email||"User",C=X.sanitizeImageUrl(c.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:p,onKeyDown:y,children:[e.jsxs("button",{ref:x,type:"button",className:`cedros-button cedros-user-button ${v[r]} ${s}`,"aria-haspopup":"menu","aria-expanded":m,"aria-label":`User menu for ${w}`,onClick:A,children:[C?e.jsx("img",{src:C,alt:w,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(w[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:w})]}),m&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[n.map((T,L)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${b===L?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===L?0:-1,onClick:()=>{T.onClick(),h(!1)},children:[T.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:T.icon}),T.label]},L)),n.length>0&&!o&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!o&&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(),h(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${S[t]} ${v[r]} ${s}`,onClick:u,children:a||"Sign in"})}function Gs(){const{config:s}=N.useCedrosLogin(),[t,r]=i.useState(!1),[a,n]=i.useState(!1),[o,c]=i.useState(null),l=i.useMemo(()=>new N.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:d,getRemainingAttempts:u}=X.useRateLimiter({maxAttempts:3,windowMs:3e5}),f=i.useCallback(async g=>{if(!ns.validateEmail(g)){const p={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw c(p),p}try{d()}catch(p){const x={code:"RATE_LIMITED",message:p instanceof Error?p.message:"Too many attempts"};throw c(x),x}r(!0),c(null),n(!1);try{await l.post("/forgot-password",{email:g}),n(!0)}catch(p){const x=N.handleApiError(p,"Failed to send reset email");throw c(x),x}finally{r(!1)}},[l,d]),m=i.useCallback(async(g,p)=>{r(!0),c(null),n(!1);try{await l.post("/reset-password",{token:g,newPassword:p}),n(!0)}catch(x){const j=N.handleApiError(x,"Failed to reset password");throw c(j),j}finally{r(!1)}},[l]),h=i.useCallback(()=>c(null),[]),b=i.useCallback(()=>{c(null),n(!1),r(!1)},[]);return{forgotPassword:f,resetPassword:m,isLoading:t,isSuccess:a,error:o,clearError:h,reset:b,remainingAttempts:u()}}function hr({onSuccess:s,onCancel:t,className:r=""}){const[a,n]=i.useState(""),{forgotPassword:o,isLoading:c,isSuccess:l,error:d,clearError:u}=Gs(),f=i.useId(),m=async h=>{h.preventDefault();try{await o(a),s?.()}catch{}};return l?e.jsxs("div",{className:`cedros-forgot-password-success ${r}`,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.jsxs("p",{className:"cedros-success-message",children:["If an account exists for ",e.jsx("strong",{children:a}),", you will receive a password reset link shortly."]}),t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:t,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${r}`,onSubmit:m,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:"Enter your email address and we'll send you a link to reset your password."})]}),e.jsx(N.ErrorMessage,{error:d,onDismiss:u}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:f,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:f,type:"email",className:"cedros-input",value:a,onChange:h=>n(h.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:c})]}),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:c||!a,children:c?e.jsxs(e.Fragment,{children:[e.jsx(N.LoadingSpinner,{size:"sm"}),"Sending..."]}):"Send reset link"}),t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:t,disabled:c,children:"Back to login"})]})]})}const Kn={loading:!1,loaded:!1,error:null,callbacks:[],load(){return this.loaded?Promise.resolve():this.loading?new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t})}):(this.loading=!0,new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t});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 a=document.createElement("script");a.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",a.async=!0,a.defer=!0,a.id="apple-signin-script",a.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]},a.onerror=()=>{this.loading=!1,a.remove();const n=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(o=>o.reject(n)),this.callbacks=[]},document.head.appendChild(a)}))}};function mr(){const{config:s,_internal:t}=N.useCedrosLogin(),[r,a]=i.useState(!1),[n,o]=i.useState(!1),[c,l]=i.useState(null),d=i.useRef(s),u=i.useMemo(()=>new N.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]);i.useEffect(()=>{d.current=s},[s]),i.useEffect(()=>{if(!s.appleClientId)return;let h=!0;const b=()=>{if(h)try{window.AppleID?.auth?.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),h&&o(!0)}catch{h&&l({code:"SERVER_ERROR",message:"Failed to initialize Apple Sign In"})}};return Kn.load().then(()=>{h&&b()}).catch(()=>{h&&l({code:"SERVER_ERROR",message:"Failed to load Apple Sign In"})}),()=>{h=!1}},[s.appleClientId]);const f=i.useCallback(async()=>{if(!s.appleClientId){const h={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw l(h),h}if(!n){const h={code:"VALIDATION_ERROR",message:"Apple Sign In not initialized"};throw l(h),h}a(!0),l(null);try{const h=await window.AppleID.auth.signIn(),b=h.authorization?.id_token;if(!b)throw new Error("No ID token received from Apple");const g=h.user?.name?`${h.user.name.firstName||""} ${h.user.name.lastName||""}`.trim():void 0,p=await u.post("/apple",{idToken:b,name:g||void 0});return d.current.callbacks?.onLoginSuccess?.(p.user,"apple"),t?.handleLoginSuccess(p.user,p.tokens),a(!1),p}catch(h){if(h.error==="popup_closed_by_user"){const p={code:"SERVER_ERROR",message:"Apple Sign In was cancelled"};throw l(p),a(!1),p}const g=N.handleApiError(h,"Apple sign-in failed");throw l(g),a(!1),g}},[s.appleClientId,n,u,t]),m=i.useCallback(()=>l(null),[]);return{signIn:f,isLoading:r,isInitialized:n,error:c,clearError:m}}function pr(){if(typeof window>"u"||typeof navigator>"u")return!1;const s=navigator.userAgent.toLowerCase(),t=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(s)||t.includes("mac")||/macintosh/.test(s)||t==="macintel"&&navigator.maxTouchPoints>1)}function fr({onSuccess:s,onError:t,className:r="",variant:a="default",size:n="md",disabled:o=!1,hideOnNonApple:c=!0}){const{signIn:l,isLoading:d,isInitialized:u}=mr(),[f]=i.useState(()=>pr());if(c&&!f)return null;const m=async()=>{try{await l(),s?.()}catch(g){const p=g instanceof Error?g:new Error(String(g));t?.(p)}},h={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},b={default:"cedros-button-apple",outline:"cedros-button-apple-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${b[a]} ${h[n]} ${r}`,onClick:m,disabled:o||!u||d,"aria-label":"Sign in with Apple",children:[d?e.jsx(N.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 se(s,t){if(!s)throw new Error(t)}function Gn(s){return s.replace(/-/g,"+").replace(/_/g,"/")}function ss(s){se(typeof s=="string"&&s.length>0,"Expected base64url string");const t=Gn(s),r=t+"=".repeat((4-t.length%4)%4),a=atob(r),n=new Uint8Array(a.length);for(let o=0;o<a.length;o++)n[o]=a.charCodeAt(o);return n.buffer}function je(s){const t=new Uint8Array(s);let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function gr(s){se(typeof s=="object"&&s!==null,"Invalid credential descriptor");const t=s;return se(typeof t.type=="string","Invalid credential descriptor type"),se(typeof t.id=="string","Invalid credential descriptor id"),{type:t.type,id:ss(t.id),transports:Array.isArray(t.transports)?t.transports:void 0}}function Yn(s){se(s&&typeof s=="object","Missing creation options");const t=s.publicKey;se(t&&typeof t=="object","Missing creation options.publicKey"),se(typeof t.challenge=="string","Missing creation challenge"),se(typeof t.rp=="object"&&t.rp!==null,"Missing rp"),se(typeof t.user=="object"&&t.user!==null,"Missing user");const r=t.rp,a=t.user;se(typeof r.name=="string","Missing rp.name"),se(typeof a.id=="string","Missing user.id"),se(typeof a.name=="string","Missing user.name"),se(typeof a.displayName=="string","Missing user.displayName");const n=Array.isArray(t.excludeCredentials)?t.excludeCredentials.map(gr):void 0,o=Array.isArray(t.pubKeyCredParams)?t.pubKeyCredParams.map(c=>({type:c.type,alg:c.alg})):[];return{challenge:ss(t.challenge),rp:{name:r.name,id:typeof r.id=="string"?r.id:void 0},user:{id:ss(a.id),name:a.name,displayName:a.displayName},pubKeyCredParams:o,timeout:typeof t.timeout=="number"?t.timeout:void 0,attestation:typeof t.attestation=="string"?t.attestation:void 0,authenticatorSelection:typeof t.authenticatorSelection=="object"&&t.authenticatorSelection!==null?t.authenticatorSelection:void 0,excludeCredentials:n,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0}}function Jn(s){se(s&&typeof s=="object","Missing request options");const t=s.publicKey;se(t&&typeof t=="object","Missing request options.publicKey"),se(typeof t.challenge=="string","Missing request challenge");const r=Array.isArray(t.allowCredentials)?t.allowCredentials.map(gr):void 0;return{challenge:ss(t.challenge),rpId:typeof t.rpId=="string"?t.rpId:void 0,timeout:typeof t.timeout=="number"?t.timeout:void 0,userVerification:typeof t.userVerification=="string"?t.userVerification:void 0,allowCredentials:r,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0}}function ut(s){const t=je(s.rawId),r=s.response,n={...{clientDataJSON:je(r.clientDataJSON)}};if("attestationObject"in r){const o=r;if(n.attestationObject=je(o.attestationObject),typeof o.getTransports=="function")try{n.transports=o.getTransports()}catch{}}if("authenticatorData"in r){const o=r;n.authenticatorData=je(o.authenticatorData),n.signature=je(o.signature),o.userHandle&&(n.userHandle=je(o.userHandle))}return{id:s.id,rawId:t,type:s.type,authenticatorAttachment:s.authenticatorAttachment??void 0,clientExtensionResults:s.getClientExtensionResults?.()??{},response:n}}function Xn(){if(typeof window<"u"){const s=window.location?.hostname,t=s==="localhost"||s==="127.0.0.1"||s?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!t)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function ht(s){if(!(s instanceof Error))return null;const t=s.name;return t==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:t==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:t==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function br(){const{config:s,_internal:t}=N.useCedrosLogin(),[r,a]=i.useState(!1),[n,o]=i.useState(null),c=i.useMemo(()=>new N.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[t?.getAccessToken,s.serverUrl,s.requestTimeout,s.retryAttempts]),l=i.useCallback(()=>o(null),[]),d=Xn(),u=i.useCallback(async m=>{if(!d){const h={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw o(h),h}a(!0),o(null);try{const h=await c.post("/webauthn/auth/options",{email:m?.email}),b=Jn(h.options),g=await navigator.credentials.get({publicKey:b});if(!g)throw new Error("Passkey authentication returned no credential");const p=await c.post("/webauthn/auth/verify",{challengeId:h.challengeId,credential:ut(g)});return s.callbacks?.onLoginSuccess?.(p.user,"webauthn"),t?.handleLoginSuccess(p.user,p.tokens),p}catch(h){const g=ht(h)??N.handleApiError(h,"Passkey sign-in failed");throw o(g),g}finally{a(!1)}},[c,s.callbacks,t,d]),f=i.useCallback(async m=>{if(!d){const h={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw o(h),h}a(!0),o(null);try{const h=await c.post("/webauthn/register/options",{}),b=Yn(h.options),g=await navigator.credentials.create({publicKey:b});if(!g)throw new Error("Passkey registration returned no credential");const p=await c.post("/webauthn/register/verify",{challengeId:h.challengeId,credential:ut(g),label:m?.label});if(!p.success)throw new Error("Passkey registration failed");return{credentialId:p.credentialId,label:p.label}}catch(h){const g=ht(h)??N.handleApiError(h,"Passkey registration failed");throw o(g),g}finally{a(!1)}},[c,d]);return{isSupported:d,isLoading:r,error:n,clearError:l,authenticatePasskey:u,registerPasskey:f}}function yr({onSuccess:s,className:t="",children:r,disabled:a}){const{authenticatePasskey:n,isLoading:o,isSupported:c}=br(),l=a||!c||o;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${t}`,onClick:async()=>{await n(),s?.()},disabled:l,"aria-disabled":l,children:[e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(Zn,{})}),e.jsx("span",{children:r??(o?"Continuing...":"Continue with Passkey")})]})}function Zn(){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 Re=["login","register"];function as({onSuccess:s,className:t="",defaultTab:r="login"}){const{config:a}=N.useCedrosLogin(),[n,o]=i.useState(r),[c,l]=i.useState("form"),[d,u]=i.useState(()=>gs.detectSolanaWallets()),[f]=i.useState(()=>pr());i.useEffect(()=>{const v=()=>u(gs.detectSolanaWallets());return v(),window.addEventListener("load",v),window.addEventListener("focus",v),()=>{window.removeEventListener("load",v),window.removeEventListener("focus",v)}},[]);const m=a.forms?.forgotPassword?.mode??"reset",h=i.useCallback(v=>{const S=Re.indexOf(n);let w=S;switch(v.key){case"ArrowLeft":case"ArrowUp":w=S===0?Re.length-1:S-1;break;case"ArrowRight":case"ArrowDown":w=S===Re.length-1?0:S+1;break;case"Home":w=0;break;case"End":w=Re.length-1;break;default:return}v.preventDefault();const C=Re[w];o(C),document.getElementById(`cedros-tab-${C}`)?.focus()},[n]),b=a.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},g=b.email!==!1,p=b.google!==!1&&a.googleClientId,x=b.apple!==!1&&a.appleClientId&&f,j=b.solana!==!1&&d,y=b.webauthn!==!1,A=g&&(p||x||j||y);return c==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${t}`,children:e.jsx(hr,{onCancel:()=>l("form")})}):e.jsxs("div",{className:`cedros-login-form ${t}`,children:[(y||p||x||j)&&e.jsxs("div",{className:"cedros-social-buttons",children:[y&&e.jsx(yr,{onSuccess:s}),p&&e.jsx(Cn.GoogleLoginButton,{onSuccess:s}),x&&e.jsx(fr,{onSuccess:s}),j&&e.jsx(gs.SolanaLoginButton,{onSuccess:s})]}),A&&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 ${n==="login"?"cedros-tab-active":""}`,onClick:()=>o("login"),onKeyDown:h,"aria-selected":n==="login","aria-controls":"cedros-tabpanel-login",tabIndex:n==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${n==="register"?"cedros-tab-active":""}`,onClick:()=>o("register"),onKeyDown:h,"aria-selected":n==="register","aria-controls":"cedros-tabpanel-register",tabIndex:n==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${n}`,"aria-labelledby":`cedros-tab-${n}`,children:n==="login"?e.jsx(X.EmailLoginForm,{onSuccess:s,onSwitchToRegister:()=>o("register"),onForgotPassword:m==="reset"?()=>l("forgotPassword"):void 0}):e.jsx(X.EmailRegisterForm,{onSuccess:s,onSwitchToLogin:()=>o("login")})})]})]})}class wr extends i.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){this.setState({errorInfo:r}),process.env.NODE_ENV==="development"&&(console.error("[Cedros Login] Error caught by ErrorBoundary:",t),console.error("[Cedros Login] Component stack:",r.componentStack)),this.props.onError?.(t,r)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:t,error:r,errorInfo:a}=this.state,{children:n,fallback:o,showDetails:c=!1}=this.props;return t?o||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."}),c&&r&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[r.toString(),a?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):n}}function ea({className:s="",title:t="Sign in to your account"}){const{isModalOpen:r,closeModal:a}=N.useCedrosLogin(),n=i.useRef(null),o=i.useRef(null),c=i.useRef(a);if(i.useEffect(()=>{c.current=a},[a]),i.useEffect(()=>{if(!r)return;o.current=document.activeElement,n.current?.focus();const d=f=>{if(f.key==="Escape"&&c.current(),f.key==="Tab"&&n.current){const m=n.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),h=m[0],b=m[m.length-1];f.shiftKey&&document.activeElement===h?(f.preventDefault(),b?.focus()):!f.shiftKey&&document.activeElement===b&&(f.preventDefault(),h?.focus())}};document.addEventListener("keydown",d);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",d),document.body.style.overflow=u,o.current instanceof HTMLElement&&o.current.focus()}},[r]),!r)return null;const l=d=>{d.target===d.currentTarget&&a()};return e.jsx("div",{className:`cedros-modal-backdrop ${s}`,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:t}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:a,"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(wr,{children:e.jsx(as,{onSuccess:a})})})]})})}function sa({token:s,onSuccess:t,onLoginClick:r,className:a=""}){const[n,o]=i.useState(""),[c,l]=i.useState(""),[d,u]=i.useState(null),{resetPassword:f,isLoading:m,isSuccess:h,error:b,clearError:g}=Gs(),p=n===c,x=d?.isValid&&p&&n.length>0,j=async y=>{if(y.preventDefault(),!!x)try{await f(s,n),t?.()}catch{}};return h?e.jsxs("div",{className:`cedros-reset-password-success ${a}`,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 ${a}`,onSubmit:j,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(N.ErrorMessage,{error:b,onDismiss:g}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(X.PasswordInput,{label:"New password",value:n,onChange:y=>{o(y.target.value),u(ns.validatePassword(y.target.value))},showStrengthMeter:!0,onValidationChange:u,disabled:m,autoComplete:"new-password",error:d&&!d.isValid?Object.values(d.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(X.PasswordInput,{label:"Confirm password",value:c,onChange:y=>l(y.target.value),disabled:m,autoComplete:"new-password",error:c&&!p?"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:m||!x,children:m?e.jsxs(e.Fragment,{children:[e.jsx(N.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:m,children:"Back to login"})]})]})}function Hs({org:s,size:t="lg",className:r=""}){const a=X.sanitizeImageUrl(s.logoUrl),n=t==="lg"?"cedros-org-avatar-lg":"",o=["cedros-org-avatar",n,r].filter(Boolean).join(" "),c=["cedros-org-avatar-placeholder",n,r].filter(Boolean).join(" ");return a?e.jsx("img",{src:a,alt:s.name,className:o,referrerPolicy:"no-referrer"}):e.jsx("div",{className:c,children:s.name[0]?.toUpperCase()||"?"})}function ta({orgs:s,activeOrg:t,isLoading:r=!1,onSelect:a,onCreateClick:n,className:o="",placeholder:c="Select organization"}){const[l,d]=i.useState(!1),u=i.useRef(null);i.useEffect(()=>{const b=g=>{u.current&&!u.current.contains(g.target)&&d(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]),i.useEffect(()=>{const b=g=>{g.key==="Escape"&&d(!1)};if(l)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[l]);const f=i.useCallback(b=>{a(b),d(!1)},[a]),m=i.useCallback(()=>{d(!1),n?.()},[n]),h=i.useCallback(()=>{d(b=>!b)},[]);return r?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${o}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(N.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:u,className:`cedros-org-selector ${o}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:h,"aria-haspopup":"listbox","aria-expanded":l,children:[t?e.jsxs(e.Fragment,{children:[e.jsx(Hs,{org:t,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:t.name}),e.jsx(mt,{role:t.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:c}),e.jsx(ra,{isOpen:l})]}),l&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[s.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:s.map(b=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${b.id===t?.id?"cedros-org-selector-item-active":""}`,onClick:()=>f(b.id),role:"option","aria-selected":b.id===t?.id,children:[e.jsx(Hs,{org:b,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:b.name}),e.jsx(mt,{role:b.membership.role}),b.id===t?.id&&e.jsx(na,{})]})},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:m,children:[e.jsx(aa,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function mt({role:s}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${s}`,children:s})}function ra({isOpen:s}){return e.jsx("svg",{className:`cedros-org-chevron ${s?"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 na(){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 aa(){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 oa(){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 ia(){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 la(){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 ca({orgs:s,activeOrg:t,isLoading:r,onSelect:a,onCreateClick:n}){return r?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[s.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:s.map(o=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${o.id===t?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>a(o.id),children:[e.jsx(Hs,{org:o}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:o.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",o.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${o.membership.role}`,children:o.membership.role}),o.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),o.id===t?.id&&e.jsx(ia,{})]})},o.id))}),n&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:n,children:[e.jsx(la,{}),e.jsx("span",{children:"Create new organization"})]})]})}function da({isLoading:s,onSubmit:t,onCancel:r}){const[a,n]=i.useState(""),[o,c]=i.useState(""),[l,d]=i.useState(null),u=i.useCallback(m=>{n(m);const h=m.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);c(h)},[]),f=i.useCallback(async m=>{if(m.preventDefault(),d(null),!a.trim()){d("Organization name is required");return}if(!o.trim()){d("Organization slug is required");return}try{await t({name:a.trim(),slug:o.trim()})}catch(h){d(h.message||"Failed to create organization")}},[a,o,t]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:f,children:[l&&e.jsx(N.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:a,onChange:m=>u(m.target.value),placeholder:"My Organization",maxLength:255,disabled:s,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:o,onChange:m=>c(m.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:s})]}),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:s,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:s||!a.trim()||!o.trim(),children:s?e.jsx(N.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function ua({isOpen:s,onClose:t,orgs:r,activeOrg:a,isLoading:n=!1,error:o,onSelect:c,onCreate:l,className:d=""}){return s?e.jsx(ha,{onClose:t,orgs:r,activeOrg:a,isLoading:n,error:o,onSelect:c,onCreate:l,className:d}):null}function ha({onClose:s,orgs:t,activeOrg:r,isLoading:a=!1,error:n,onSelect:o,onCreate:c,className:l}){const[d,u]=i.useState("list"),f=i.useRef(null),m=i.useRef(null);i.useEffect(()=>(m.current=document.activeElement,f.current?.querySelector(".cedros-modal-close")?.focus(),()=>{m.current?.focus()}),[]),i.useEffect(()=>{const p=x=>{if(x.key==="Escape"){s();return}if(x.key==="Tab"&&f.current){const j=f.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),y=j[0],A=j[j.length-1];x.shiftKey?document.activeElement===y&&(x.preventDefault(),A?.focus()):document.activeElement===A&&(x.preventDefault(),y?.focus())}};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[s]);const h=i.useCallback(p=>{p.target===p.currentTarget&&s()},[s]),b=i.useCallback(p=>{o(p),s()},[o,s]),g=i.useCallback(async p=>{await c?.(p),s()},[c,s]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:h,children:e.jsxs("div",{ref:f,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:d==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:s,"aria-label":"Close",children:e.jsx(oa,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[n&&e.jsx(N.ErrorMessage,{error:n}),d==="list"?e.jsx(ca,{orgs:t,activeOrg:r,isLoading:a,onSelect:b,onCreateClick:c?()=>u("create"):void 0}):e.jsx(da,{isLoading:a,onSubmit:g,onCancel:()=>u("list")})]})]})})}const ma=["owner","admin","member"];function xr({members:s,currentUserId:t,isLoading:r=!1,error:a,canManage:n=!1,canChangeRoles:o=!1,onUpdateRole:c,onRemove:l,className:d=""}){const[u,f]=i.useState("name"),[m,h]=i.useState("asc"),b=p=>{u===p?h(m==="asc"?"desc":"asc"):(f(p),h("asc"))},g=i.useMemo(()=>{const p={owner:0,admin:1,member:2};return[...s].sort((x,j)=>{let y,A;switch(u){case"name":y=(x.user.name||x.user.email||"").toLowerCase(),A=(j.user.name||j.user.email||"").toLowerCase();break;case"role":y=p[x.role]??99,A=p[j.role]??99;break;case"joinedAt":y=new Date(x.joinedAt).getTime(),A=new Date(j.joinedAt).getTime();break;default:return 0}return y<A?m==="asc"?-1:1:y>A?m==="asc"?1:-1:0})},[s,u,m]);return r&&s.length===0?e.jsxs("div",{className:`cedros-member-list cedros-member-list-loading ${d}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading members..."})]}):a?e.jsx("div",{className:`cedros-member-list ${d}`,children:e.jsx(N.ErrorMessage,{error:a})}):s.length===0?e.jsx("div",{className:`cedros-member-list cedros-member-list-empty ${d}`,children:e.jsx("p",{children:"No members found."})}):e.jsx("div",{className:`cedros-member-list ${d}`,children:e.jsxs("table",{className:"cedros-member-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${u==="name"?"cedros-admin-sort-active":""}`,onClick:()=>b("name"),children:["Member"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:u==="name"?m==="asc"?"↑":"↓":"↕"})]})}),e.jsx("th",{children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${u==="role"?"cedros-admin-sort-active":""}`,onClick:()=>b("role"),children:["Role"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:u==="role"?m==="asc"?"↑":"↓":"↕"})]})}),e.jsx("th",{children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${u==="joinedAt"?"cedros-admin-sort-active":""}`,onClick:()=>b("joinedAt"),children:["Joined"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:u==="joinedAt"?m==="asc"?"↑":"↓":"↕"})]})}),(n||o)&&e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:g.map(p=>e.jsx(pa,{member:p,isCurrentUser:p.userId===t,canManage:n,canChangeRoles:o,onUpdateRole:c,onRemove:l},p.id))})]})})}function pa({member:s,isCurrentUser:t,canManage:r,canChangeRoles:a,onUpdateRole:n,onRemove:o}){const[c,l]=i.useState(!1),[d,u]=i.useState(s.role),f=i.useCallback(async g=>{if(!(!n||g===s.role)){l(!0);try{await n(s.userId,g),u(g)}catch{u(s.role)}finally{l(!1)}}},[s.userId,s.role,n]),m=i.useCallback(async()=>{if(!(!o||!window.confirm(`Are you sure you want to remove ${s.user.name||s.user.email} from this organization?`))){l(!0);try{await o(s.userId)}finally{l(!1)}}},[s.userId,s.user.name,s.user.email,o]),h=s.role==="owner",b=!t&&!h;return e.jsxs("tr",{className:`cedros-member-row ${t?"cedros-member-row-current":""}`,children:[e.jsxs("td",{className:"cedros-member-info",children:[e.jsx(fa,{user:s.user}),e.jsxs("div",{className:"cedros-member-details",children:[e.jsxs("span",{className:"cedros-member-name",children:[s.user.name||"Unknown",t&&e.jsx("span",{className:"cedros-member-you",children:"(you)"})]}),e.jsx("span",{className:"cedros-member-email",children:s.user.email})]})]}),e.jsx("td",{className:"cedros-member-role",children:a&&b&&n?e.jsx("select",{value:d,onChange:g=>f(g.target.value),disabled:c,className:"cedros-role-select",children:ma.map(g=>e.jsx("option",{value:g,children:g.charAt(0).toUpperCase()+g.slice(1)},g))}):e.jsx("span",{className:`cedros-role-badge cedros-role-badge-${s.role}`,children:s.role.charAt(0).toUpperCase()+s.role.slice(1)})}),e.jsx("td",{className:"cedros-member-joined",children:ga(s.joinedAt)}),(r||a)&&e.jsx("td",{className:"cedros-member-actions",children:r&&b&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:m,disabled:c,"aria-label":`Remove ${s.user.name||s.user.email}`,children:c?e.jsx(N.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function fa({user:s}){const t=X.sanitizeImageUrl(s.picture);if(t)return e.jsx("img",{src:t,alt:s.name||s.email||"Member",className:"cedros-member-avatar",referrerPolicy:"no-referrer"});const r=(s.name?.[0]||s.email?.[0]||"?").toUpperCase();return e.jsx("div",{className:"cedros-member-avatar-placeholder",children:r})}function ga(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const ba=["admin","member"];function vr({onSubmit:s,isLoading:t=!1,error:r,availableRoles:a=ba,defaultRole:n="member",className:o=""}){const[c,l]=i.useState(""),[d,u]=i.useState(n),[f,m]=i.useState(null),[h,b]=i.useState(!1),g=i.useRef(null),p=i.useRef(!0);i.useEffect(()=>(p.current=!0,()=>{p.current=!1,g.current!==null&&(window.clearTimeout(g.current),g.current=null)}),[]);const x=i.useCallback(async j=>{j.preventDefault(),m(null),b(!1);const y=c.trim();if(!y){m("Email is required");return}if(!ns.validateEmail(y)){m("Please enter a valid email address");return}try{await s(y,d),l(""),u(n),b(!0),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{p.current&&b(!1),g.current=null},3e3)}catch{}},[c,d,n,s]);return e.jsxs("form",{className:`cedros-invite-form ${o}`,onSubmit:x,children:[(r||f)&&e.jsx(N.ErrorMessage,{error:f??r??null}),h&&e.jsxs("div",{className:"cedros-invite-success",role:"status",children:[e.jsx(ya,{}),e.jsx("span",{children:"Invitation sent successfully!"})]}),e.jsxs("div",{className:"cedros-invite-form-row",children:[e.jsxs("div",{className:"cedros-form-group cedros-invite-email-group",children:[e.jsx("label",{htmlFor:"invite-email",className:"cedros-form-label",children:"Email Address"}),e.jsx("input",{id:"invite-email",type:"email",className:"cedros-form-input",value:c,onChange:j=>l(j.target.value),placeholder:"colleague@example.com",disabled:t,autoComplete:"email"})]}),e.jsxs("div",{className:"cedros-form-group cedros-invite-role-group",children:[e.jsx("label",{htmlFor:"invite-role",className:"cedros-form-label",children:"Role"}),e.jsx("select",{id:"invite-role",className:"cedros-form-select",value:d,onChange:j=>u(j.target.value),disabled:t,children:a.map(j=>e.jsx("option",{value:j,children:j.charAt(0).toUpperCase()+j.slice(1)},j))})]}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary cedros-invite-submit",disabled:t||!c.trim(),children:t?e.jsx(N.LoadingSpinner,{size:"sm"}):"Send Invite"})]}),e.jsx("p",{className:"cedros-form-hint",children:"The invited user will receive an email with a link to join your organization."})]})}function ya(){return e.jsx("svg",{className:"cedros-invite-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 jr({invites:s,isLoading:t=!1,error:r,canManage:a=!1,onCancel:n,onResend:o,className:c=""}){return t&&s.length===0?e.jsxs("div",{className:`cedros-invite-list cedros-invite-list-loading ${c}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading invites..."})]}):r?e.jsx("div",{className:`cedros-invite-list ${c}`,children:e.jsx(N.ErrorMessage,{error:r})}):s.length===0?e.jsx("div",{className:`cedros-invite-list cedros-invite-list-empty ${c}`,children:e.jsx("p",{children:"No pending invites."})}):e.jsx("div",{className:`cedros-invite-list ${c}`,children:e.jsx("ul",{className:"cedros-invite-items",children:s.map(l=>e.jsx(wa,{invite:l,canManage:a,onCancel:n,onResend:o},l.id))})})}function wa({invite:s,canManage:t,onCancel:r,onResend:a}){const[n,o]=i.useState(!1),[c,l]=i.useState(!1),d=i.useRef(null),u=new Date(s.expiresAt)<new Date,f=i.useCallback(async()=>{if(!(!r||!window.confirm(`Are you sure you want to cancel the invite for ${s.email}?`))){o(!0);try{await r(s.id)}finally{o(!1)}}},[s.id,s.email,r]),m=i.useCallback(async()=>{if(a){o(!0),l(!1);try{await a(s.id),l(!0),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>{l(!1),d.current=null},3e3)}finally{o(!1)}}},[s.id,a]);return i.useEffect(()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},[]),e.jsxs("li",{className:`cedros-invite-item ${u?"cedros-invite-item-expired":""}`,children:[e.jsxs("div",{className:"cedros-invite-item-info",children:[e.jsxs("div",{className:"cedros-invite-item-main",children:[e.jsx("span",{className:"cedros-invite-item-email",children:s.email}),e.jsx("span",{className:`cedros-role-badge cedros-role-badge-${s.role}`,children:s.role.charAt(0).toUpperCase()+s.role.slice(1)}),u&&e.jsx("span",{className:"cedros-invite-expired-badge",children:"Expired"})]}),e.jsxs("div",{className:"cedros-invite-item-meta",children:[e.jsxs("span",{className:"cedros-invite-item-date",children:["Invited ",Ar(s.createdAt)]}),!u&&e.jsxs("span",{className:"cedros-invite-item-expires",children:["Expires ",xa(s.expiresAt)]})]})]}),t&&e.jsxs("div",{className:"cedros-invite-item-actions",children:[c&&e.jsx("span",{className:"cedros-invite-resend-success",children:"Sent!"}),a&&!u&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:m,disabled:n,"aria-label":`Resend invite to ${s.email}`,children:n?e.jsx(N.LoadingSpinner,{size:"sm"}):"Resend"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:f,disabled:n,"aria-label":`Cancel invite for ${s.email}`,children:"Cancel"})]})]})}function Ar(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function xa(s){const t=new Date(s),r=new Date,a=t.getTime()-r.getTime(),n=Math.ceil(a/(1e3*60*60*24));return n<0?"expired":n===0?"today":n===1?"tomorrow":n<7?`in ${n} days`:Ar(s)}function va({sessions:s,isLoading:t=!1,error:r,onRevokeAll:a,className:n=""}){const[o,c]=i.useState(!1),[l,d]=i.useState(!1),u=i.useRef(null),f=i.useMemo(()=>s.filter(h=>!h.isCurrent).length,[s]),m=i.useCallback(async()=>{if(!a)return;const h=s.filter(g=>!g.isCurrent).length;if(!(h===0||!window.confirm(`Are you sure you want to sign out of ${h} other device(s)? This will log you out everywhere except this browser.`))){c(!0),d(!1);try{await a(),d(!0),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{d(!1),u.current=null},3e3)}finally{c(!1)}}},[a,s]);return i.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),t&&s.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${n}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):r?e.jsx("div",{className:`cedros-session-list ${n}`,children:e.jsx(N.ErrorMessage,{error:r})}):s.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(Ca,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:s.map(h=>e.jsx(ja,{session:h},h.id))}),a&&f>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:m,disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(N.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${f} other device${f>1?"s":""}`})})]})}function ja({session:s}){const t=Aa(s.userAgent),r=Na(s.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${s.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(Sa,{userAgent:s.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:[t.browser," on ",t.os]}),s.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[s.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",s.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",ka(s.createdAt)]}),r&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function Aa(s){if(!s)return{browser:"Unknown browser",os:"Unknown device"};let t="Unknown browser";s.includes("Chrome")&&!s.includes("Edg")?t="Chrome":s.includes("Safari")&&!s.includes("Chrome")?t="Safari":s.includes("Firefox")?t="Firefox":s.includes("Edg")&&(t="Edge");let r="Unknown device";return s.includes("Windows")?r="Windows":s.includes("Mac")?r="macOS":s.includes("Linux")?r="Linux":s.includes("iPhone")||s.includes("iPad")?r="iOS":s.includes("Android")&&(r="Android"),{browser:t,os:r}}function ka(s){const t=new Date(s),a=new Date().getTime()-t.getTime(),n=Math.floor(a/(1e3*60)),o=Math.floor(a/(1e3*60*60)),c=Math.floor(a/(1e3*60*60*24));return n<1?"just now":n<60?`${n} minute${n>1?"s":""} ago`:o<24?`${o} hour${o>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Na(s){const t=new Date(s),r=new Date,a=3600*1e3;return t.getTime()-r.getTime()<a}function Sa({userAgent:s}){return s?.includes("iPhone")||s?.includes("iPad")||s?.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 Ca(){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 kr({words:s,onConfirm:t,className:r=""}){const[a,n]=i.useState(!1),[o,c]=i.useState(!1),l=i.useRef(null),d=Vn(s),u=i.useCallback(async()=>{try{await navigator.clipboard.writeText(s.join(" ")),n(!0),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>n(!1),2e3)}catch{}},[s]);i.useEffect(()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},[]);const f=i.useCallback(()=>{o&&t()},[o,t]);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:d.map((m,h)=>e.jsx("div",{className:"cedros-word-group",children:m.map((b,g)=>{const p=h*4+g+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[p,"."]}),e.jsx("span",{className:"cedros-word-text",children:b})]},p)})},h))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:u,children:a?"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:o,onChange:m=>c(m.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:!o,children:"Continue"})]})]})}function Nr({onSubmit:s,onCancel:t,isSubmitting:r=!1,error:a,className:n=""}){const[o,c]=i.useState(Array(oe).fill("")),[l,d]=i.useState(null),[u,f]=i.useState([]),[m,h]=i.useState(null),b=i.useId(),g=i.useRef(null),p=i.useCallback((w,C)=>{const T=[...o];if(T[w]=C.toLowerCase().trim(),c(T),C.length>0){const L=zn(C,5);f(L)}else f([]);h(null)},[o]),x=i.useCallback(w=>{d(w),f([])},[]),j=i.useCallback(w=>{const C=o[w];C&&!ze(C)&&h(`Word ${w+1} is not in the wordlist`),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{l===w&&f([])},200)},[o,l]);i.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]);const y=i.useCallback(w=>{if(l!==null){const C=[...o];C[l]=w,c(C),f([]),document.querySelector(`[data-word-index="${l+1}"]`)?.focus()}},[l,o]),A=i.useCallback(w=>{const C=w.clipboardData.getData("text"),T=Hn(C);T.length===oe&&(w.preventDefault(),c(T),h(null))},[]),v=i.useCallback(w=>{if(w.preventDefault(),o.filter(L=>!L).length>0){h(`Please enter all ${oe} words`);return}const T=o.map((L,E)=>({word:L,index:E+1})).filter(({word:L})=>!ze(L));if(T.length>0){h(`Invalid words: ${T.map(L=>`#${L.index}`).join(", ")}`);return}if(!ur(o)){h("Invalid recovery phrase - please check your words");return}s(o)},[o,s]),S=a||m;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${n}`,onSubmit:v,onPaste:A,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:oe},(w,C)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[C+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${o[C]&&!ze(o[C])?"cedros-word-invalid":o[C]&&ze(o[C])?"cedros-word-valid":""}`,value:o[C],onChange:T=>p(C,T.target.value),onFocus:()=>x(C),onBlur:()=>j(C),"data-word-index":C,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:r,"aria-label":`Word ${C+1}`})]},C))}),l!==null&&u.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${b}-suggestions`,children:u.map(w=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>y(w),role:"option",children:w},w))}),S&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:S}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:t,disabled:r,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:r,children:r?"Recovering...":"Recover Wallet"})]})]})}function _a({capabilities:s,className:t=""}){if(s.allSupported)return null;const r=N.getMissingCapabilitiesMessage(s),a=N.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${t}`,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: ",a.browser," ",a.version,a.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:s.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",s.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:s.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",s.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:s.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",s.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",s.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",s.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:s.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",s.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 Ea=["share_c_only","full_seed","none"];function Pa(s){return s&&Ea.includes(s)?s:"share_c_only"}const Ta={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function Sr(){const s=N.useCedrosLoginOptional(),[t,r]=i.useState(null),[a,n]=i.useState(!!s),[o,c]=i.useState(null),l=i.useMemo(()=>s?new N.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts}):null,[s]),d=i.useCallback(async()=>{if(l){n(!0),c(null);try{const u=await l.get("/discovery");u.wallet?r({enabled:u.wallet.enabled,recoveryMode:Pa(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";c(f),r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{n(!1)}}},[l]);return i.useEffect(()=>{l&&d()},[l,d]),s?{walletEnabled:t?.enabled??!1,recoveryMode:t?.recoveryMode??"share_c_only",unlockTtlSeconds:t?.unlockTtlSeconds??900,isLoading:a,error:o,refetch:d}:Ta}function Cr(){const{user:s}=N.useCedrosLogin(),{enroll:t}=N.useWalletMaterial(),{recoveryMode:r}=Sr(),[a,n]=i.useState({step:"idle"}),[o,c]=i.useState(!1),l=i.useRef([]),d=i.useCallback(()=>{N.wipeAll(...l.current),l.current=[]},[]);i.useEffect(()=>()=>{d()},[d]);const u=i.useCallback(async(g,p,x,j)=>{n({step:"generating_seed"});const y=N.generateSeed();l.current.push(y),n({step:"splitting_shares"});const{shareA:A,shareB:v,shareC:S}=le.splitSecret(y);l.current.push(A,v,S),n({step:"encrypting_shares"});const w=await N.aesGcmEncryptToBase64(A,N.toEncryptionKey(p)),C=le.getPublicKeyFromSeed(y),T=le.publicKeyToBase58(C);n({step:"uploading"});const L={solanaPubkey:T,shareAAuthMethod:g,shareACiphertext:w.ciphertext,shareANonce:w.nonce,shareB:N.uint8ArrayToBase64(v)};if(g==="password"){if(!x)throw new Error("KDF salt required for password method");L.shareAKdfSalt=N.uint8ArrayToBase64(x),L.shareAKdfParams=N.DEFAULT_KDF_PARAMS}if(g==="passkey"&&j&&(L.prfSalt=j),await t(L),r==="none")d(),n({step:"complete",solanaPubkey:T});else{const E=r==="full_seed"?Wn(y):On(N.toShamirShare(S));n({step:"showing_recovery",recoveryPhrase:E,solanaPubkey:T})}},[t,r,d]),f=i.useCallback(async g=>{if(!s){n({step:"error",error:"User not authenticated"});return}c(!0),d();try{const p=N.generateArgon2Salt(),x=await le.argon2DeriveInWorker(g,p,N.DEFAULT_KDF_PARAMS);l.current.push(x),await u("password",x,p)}catch(p){n({step:"error",error:p instanceof Error?p.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),m=i.useCallback(async()=>{if(!s){n({step:"error",error:"User not authenticated"});return}c(!0),d();try{const g=N.generatePrfSalt(),p=N.uint8ArrayToBase64(g);n({step:"registering_passkey"});let x;try{const y=new TextEncoder().encode(s.id),A=s.name??s.email??"User",v=s.email??s.id;x=(await N.registerPasskeyWithPrf(y,v,A,g)).prfOutput}catch(y){if(y?.name!=="InvalidStateError")throw y;x=(await N.authenticateWithDiscoverablePrf(p)).prfOutput}l.current.push(x);const j=await N.deriveKeyFromPrf(x,g);l.current.push(j),await u("passkey",j,void 0,p)}catch(g){n({step:"error",error:g instanceof Error?g.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),h=i.useCallback(()=>{const g=a.solanaPubkey;d(),n({step:"complete",solanaPubkey:g})},[a.solanaPubkey,d]),b=i.useCallback(()=>{d(),n({step:"idle"}),c(!1)},[d]);return{state:a,startEnrollmentWithPassword:f,startEnrollmentWithPasskey:m,confirmRecoveryPhrase:h,cancel:b,isEnrolling:o}}function _r({onComplete:s,onCancel:t,className:r="",forceAuthMethod:a}){const{user:n}=N.useCedrosLogin(),{state:o,startEnrollmentWithPassword:c,startEnrollmentWithPasskey:l,confirmRecoveryPhrase:d,cancel:u,isEnrolling:f}=Cr(),m=()=>a||"password",[h,b]=i.useState(m),[g,p]=i.useState(""),[x,j]=i.useState(""),[y,A]=i.useState(null);i.useEffect(()=>{b(m())},[n?.id,a]);const v=i.useCallback(async T=>{if(T.preventDefault(),g!==x){A("Passwords do not match");return}if(g.length<8){A("Password must be at least 8 characters");return}A(null),await c(g)},[g,x,c]),S=i.useCallback(async()=>{await l()},[l]),w=i.useCallback(()=>{d(),o.solanaPubkey&&s?.(o.solanaPubkey)},[d,o.solanaPubkey,s]),C=i.useCallback(()=>{u(),t?.()},[u,t]);return o.step==="generating_seed"||o.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..."})]})}):o.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..."})]})}):o.step==="registering_passkey"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsx("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:e.jsxs("div",{className:"cedros-passkey-prompt",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("h3",{children:"Authenticate with Passkey"}),e.jsx("p",{children:"Follow your browser's prompt to use your passkey."})]})})}):o.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..."})]})}):o.step==="showing_recovery"&&o.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsx(kr,{words:o.recoveryPhrase,onConfirm:w})}):o.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:"})," ",o.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):o.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:o.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:C,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>u(),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"}),e.jsxs("p",{children:["Secure your wallet with a ",h==="passkey"?"passkey":"password","."]})]}),!a&&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:h==="password",onChange:()=>b("password"),disabled:f}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:h==="passkey",onChange:()=>b("passkey"),disabled:f}),e.jsx("span",{children:"Passkey"})]})]}),h==="password"&&e.jsxs("form",{onSubmit:v,className:"cedros-enrollment-form",children:[e.jsx(X.PasswordInput,{label:"Password",value:g,onChange:T=>p(T.target.value),showStrengthMeter:!0,disabled:f,required:!0,minLength:8,placeholder:"Enter a strong password"}),e.jsx(X.PasswordInput,{label:"Confirm Password",value:x,onChange:T=>j(T.target.value),error:y??void 0,disabled:f,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:C,disabled:f,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:f||!g||!x,children:f?"Creating...":"Continue"})]})]}),h==="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.jsx("p",{children:"You'll use the same passkey to sign transactions."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:C,disabled:f,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,disabled:f,children:f?"Creating...":"Use Passkey"})]})]})]})}function Er(){const{user:s}=N.useCedrosLogin(),{signTransaction:t}=N.useWalletMaterial(),[r,a]=i.useState(!1),[n,o]=i.useState(null),c=i.useCallback(async(d,u)=>{if(!s){const f="User not authenticated";throw o(f),new Error(f)}a(!0),o(null);try{const f={transaction:N.uint8ArrayToBase64(d),...u?{credential:N.toCredentialRequest(u)}:{}},m=await t(f);return N.base64ToUint8Array(m.signature)}catch(f){const m=f instanceof Error?f.message:"Signing failed";throw o(m),f}finally{a(!1)}},[s,t]),l=i.useCallback(()=>o(null),[]);return{signTransaction:c,isSigning:r,error:n,clearError:l}}function Pr(){const{getMaterial:s}=N.useWalletMaterial(),[t,r]=i.useState(!1),[a,n]=i.useState(null),o=i.useCallback(async()=>{r(!0),n(null);try{const l=await s();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 d=await N.authenticateWithDiscoverablePrf(l.prfSalt);return{type:"prfOutput",prfOutput:N.uint8ArrayToBase64(d.prfOutput)}}catch(l){const d=l instanceof Error?l.message:"Passkey authentication failed";return n(d),null}finally{r(!1)}},[s]),c=i.useCallback(()=>n(null),[]);return{getPasskeyCredential:o,isAuthenticating:t,error:a,clearError:c}}function Tr({mode:s,isLoading:t=!1,error:r,onPrompt:a,onRetry:n,onCancel:o,title:c,description:l,className:d=""}){const u=i.useCallback(()=>{t||a?.()},[t,a]),f=i.useCallback(()=>{n?.()},[n]),m=s==="register"?"Set Up Passkey":"Verify with Passkey",h=s==="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 ${d}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:t?e.jsx(Ma,{}):r?e.jsx(Da,{}):e.jsx(La,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:c??m}),e.jsx("p",{className:"cedros-passkey-description",children:l??h}),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"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:o,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:u,disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):s==="register"?"Create Passkey":"Use Passkey"}),o&&!t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:o,children:"Cancel"})]})}),t&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",s==="register"?"create":"verify"," your passkey."]})]})}function La(){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 Ma(){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 Da(){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 Lr({onUnlock:s,onCancel:t,showCancel:r=!0,authMethod:a,className:n=""}){N.useCedrosLogin();const{unlock:o,getMaterial:c,isLoading:l}=N.useWalletMaterial(),{getPasskeyCredential:d,isAuthenticating:u}=Pr(),[f,m]=i.useState("idle"),[h,b]=i.useState(a??null),[g,p]=i.useState(""),[x,j]=i.useState(null);i.useEffect(()=>{a!==void 0&&b(a)},[a]);const y=h==="password",A=h==="passkey",v=i.useCallback(async()=>{if(m("credential"),j(null),!h)try{const P=await c();P?b(P.shareAAuthMethod):(j("No wallet enrolled"),m("error"))}catch(P){j(P instanceof Error?P.message:"Failed to get wallet info"),m("error")}},[h,c]),S=i.useCallback(async P=>{P.preventDefault(),j(null),m("unlocking");try{let k;if(y)k={type:"password",password:g};else throw new Error("Invalid auth method");await o(k),m("unlocked"),s?.()}catch(k){j(k instanceof Error?k.message:"Failed to unlock wallet"),m("error")}},[y,g,o,s]),w=i.useCallback(async()=>{j(null),m("unlocking");try{const P=await d();if(!P){m("credential");return}await o(P),m("unlocked"),s?.()}catch(P){j(P instanceof Error?P.message:"Failed to unlock wallet"),m("error")}},[d,o,s]),C=i.useCallback(()=>{p(""),m("idle"),j(null),t?.()},[t]),T=i.useCallback(()=>{p(""),m("credential"),j(null)},[]),L=l||u,E=()=>{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(Ra,{})}),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:v,children:"Unlock Wallet"})]});case"credential":return y?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:S,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(X.PasswordInput,{label:"Password",value:g,onChange:P=>p(P.target.value),disabled:L,autoComplete:"current-password",error:x??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:L||g.length===0,children:L?"Unlocking...":"Unlock"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:C,disabled:L,children:"Cancel"})]})]}):A?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(Tr,{mode:"authenticate",isLoading:L,error:x??void 0,onPrompt:w,onRetry:w,onCancel:r?C:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(N.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(N.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(Ia,{})}),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(Ua,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:x??"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:T,children:"Try Again"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:C,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${n}`,children:E()})}function Ra(){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 Ia(){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 Ua(){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 Mr(){const{recover:s,getShareBForRecovery:t}=N.useWalletMaterial(),{recoveryMode:r}=Sr(),[a,n]=i.useState({step:"idle"}),[o,c]=i.useState(!1),l=i.useRef([]),d=i.useCallback(()=>{N.wipeAll(...l.current),l.current=[]},[]);i.useEffect(()=>()=>{d()},[d]);const u=i.useCallback(async(m,h,b)=>{c(!0),d();try{if(n({step:"validating"}),!ur(m))throw new Error("Invalid recovery phrase. Please check your words.");let g;if(r==="share_c_only"){const T=qn(m);l.current.push(T);const L=N.uint8ArrayToBase64(T),E=await t({shareC:L}),P=N.base64ToUint8Array(E.shareB);l.current.push(P),g=le.combineShares(N.toShamirShare(P),N.toShamirShare(T)),l.current.push(g)}else g=$n(m),l.current.push(g);const p=le.getPublicKeyFromSeed(g),x=le.publicKeyToBase58(p),{shareA:j,shareB:y}=le.splitSecret(g);l.current.push(j,y),n({step:"encrypting"});let A,v,S;if(h==="passkey"){const T=N.generatePrfSalt();S=N.uint8ArrayToBase64(T);const L=await N.authenticateWithDiscoverablePrf(S);l.current.push(L.prfOutput),A=await N.deriveKeyFromPrf(L.prfOutput,T),l.current.push(A)}else v=N.generateArgon2Salt(),A=await le.argon2DeriveInWorker(b,v,N.DEFAULT_KDF_PARAMS),l.current.push(A);const w=await N.aesGcmEncryptToBase64(j,N.toEncryptionKey(A));n({step:"uploading"});const C={solanaPubkey:x,shareAAuthMethod:h,shareACiphertext:w.ciphertext,shareANonce:w.nonce,shareB:N.uint8ArrayToBase64(y)};h==="password"&&(C.shareAKdfSalt=N.uint8ArrayToBase64(v),C.shareAKdfParams=N.DEFAULT_KDF_PARAMS),h==="passkey"&&(C.prfSalt=S),await s(C),d(),n({step:"complete"})}catch(g){d(),n({step:"error",error:g instanceof Error?g.message:"Recovery failed"})}finally{c(!1)}},[s,t,r,d]),f=i.useCallback(()=>{d(),n({step:"idle"}),c(!1)},[d]);return{state:a,startRecovery:u,cancel:f,isRecovering:o}}function Dr({onComplete:s,onCancel:t,className:r="",defaultAuthMethod:a="password"}){const{state:n,startRecovery:o,cancel:c,isRecovering:l}=Mr(),[d,u]=i.useState([]),[f,m]=i.useState(!1),[h,b]=i.useState(a),[g,p]=i.useState(""),[x,j]=i.useState(""),[y,A]=i.useState(null),v=i.useCallback(L=>{u(L),m(!0)},[]),S=i.useCallback(async L=>{if(L.preventDefault(),A(null),h!=="passkey"){if(g!==x){A("Passwords do not match");return}if(h==="password"&&g.length<8){A("Password must be at least 8 characters");return}}await o(d,h,g)},[d,h,g,x,o]),w=i.useCallback(()=>{c(),u([]),m(!1),p(""),j(""),t?.()},[c,t]),C=i.useCallback(()=>{m(!1),p(""),j("")},[]),T=i.useCallback(()=>{s?.()},[s]);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(Fa,{})}),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(Ba,{})}),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"," ",h==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:T,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(Oa,{})}),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:w,children:"Start Over"})})]})}):f?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:S,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:h==="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:h==="passkey",onChange:()=>b("passkey"),disabled:l}),e.jsx("span",{children:"Passkey"})]})]}),h==="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:g,onChange:L=>p(L.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:x,onChange:L=>j(L.target.value),disabled:l,"aria-invalid":y?"true":void 0,placeholder:"Confirm your password"}),y&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:y})]})]}),h==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(qa,{}),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:C,disabled:l,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:l||h!=="passkey"&&(g.length===0||x.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(Nr,{onSubmit:v,onCancel:w,isSubmitting:!1})]})})}function Fa(){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 Ba(){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 Oa(){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 qa(){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 Rr({address:s,label:t="Wallet Address",showCopy:r=!0,showExplorerLink:a=!0,allowReveal:n=!0,className:o=""}){const c=N.useCedrosLoginOptional(),[l,d]=i.useState(!1),[u,f]=i.useState(null),[m,h]=i.useState(!1),b=i.useRef(null),g=c?.config.solana?.network??"mainnet-beta",p=i.useMemo(()=>{const A=`https://explorer.solana.com/address/${s}`;return g==="mainnet-beta"?A:`${A}?cluster=${encodeURIComponent(g)}`},[s,g]),x=n&&s.length>18,j=i.useMemo(()=>!x||m?s:`${s.slice(0,8)}...${s.slice(-8)}`,[s,x,m]),y=i.useCallback(async()=>{try{f(null),await navigator.clipboard.writeText(s),d(!0),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{d(!1),b.current=null},2e3)}catch(A){d(!1),f(A instanceof Error?A.message:"Copy failed")}},[s]);return i.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${o}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:t}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[x&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>h(A=>!A),"aria-label":m?"Hide full wallet address":"Show full wallet address",children:m?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"})]})}),a&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:p,target:"_blank",rel:"noreferrer",children:"Explorer"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:y,"aria-label":"Copy wallet address",children:l?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:s,children:j}),u&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:u})]})}function Ir({status:s,publicKey:t,onLock:r,onEnroll:a,onUnlock:n,onRecover:o,showActions:c=!0,compact:l=!1,className:d=""}){const u=s!==void 0,f=N.useWallet(),m=u?s:f.status,h=u?t??null:f.solanaPubkey,b=u?null:f.error,g=u?()=>{}:f.refresh,p=u?()=>{}:f.clearError,x=Wa(m,b);return l?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${d}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${x.color}`,title:x.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:x.label}),h&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:h,children:$a(h)})]}):e.jsxs("div",{className:`cedros-wallet-status ${d}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${x.color}`,children:e.jsx(za,{status:m})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:x.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:x.description})]})]}),h&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(Rr,{address:h})}),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:p,children:"Dismiss"})]}),c&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[m==="not_enrolled"&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:a,children:"Create Wallet"}),m==="enrolled_locked"&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:n,children:"Unlock Wallet"}),(m==="not_enrolled"||m==="error")&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:"Recover Wallet"}),m==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:g,children:"Retry"})]})]})}function Wa(s,t){switch(s){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:t??"An error occurred with your wallet.",color:"error"}}}function $a(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function za({status:s}){switch(s){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 Va({className:s="",showActions:t=!0}){const r=N.useWallet(),[a,n]=i.useState("status"),o=i.useMemo(()=>{switch(a){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}},[a]),c=i.useCallback(()=>n("status"),[]),l=i.useCallback(async()=>{n("status"),await r.refresh()},[r]),d=i.useCallback(async()=>{n("status"),await r.refresh()},[r]),u=i.useCallback(async()=>{n("status"),await r.refresh()},[r]);return e.jsxs("div",{className:`cedros-wallet-manager ${s}`,children:[a!=="status"&&o&&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:o.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:o.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:c,children:"Back"})]}),a==="status"&&e.jsx(Ir,{onEnroll:()=>n("enroll"),onUnlock:()=>n("unlock"),onRecover:()=>n("recover_intro"),showActions:t}),a==="enroll"&&e.jsx(_r,{onComplete:()=>{l()},onCancel:c}),a==="unlock"&&e.jsx(Lr,{onUnlock:()=>{d()},onCancel:c}),a==="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:c,children:"Cancel"})]})]})}),a==="recover"&&e.jsx(Dr,{onComplete:()=>{u()},onCancel:c})]})}class Ha{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async getSettings(){try{return await this.client.get("/admin/settings")}catch(t){throw N.handleApiError(t,"Failed to fetch system settings")}}async updateSettings(t){try{return await this.client.patch("/admin/settings",{settings:t})}catch(r){throw N.handleApiError(r,"Failed to update system settings")}}}function Ue(){const{config:s,authState:t,_internal:r}=N.useCedrosLogin(),[a,n]=i.useState({}),[o,c]=i.useState(!1),[l,d]=i.useState(!1),[u,f]=i.useState(null),m=i.useRef(0),h=i.useMemo(()=>new Ha(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),b=i.useRef(h);b.current=h;const g=i.useCallback(async()=>{if(t!=="authenticated"){n({});return}c(!0),f(null);const j=++m.current;try{const y=await b.current.getSettings();if(j!==m.current)return;n(y.settings)}catch(y){if(j!==m.current)return;f(y instanceof Error?y:new Error("Failed to fetch settings"))}finally{j===m.current&&c(!1)}},[t]),p=i.useCallback(async j=>{if(t!=="authenticated")throw new Error("Not authenticated");d(!0),f(null);try{await b.current.updateSettings(j),await g()}catch(y){const A=y instanceof Error?y:new Error("Failed to update settings");throw f(A),A}finally{d(!1)}},[t,g]),x=i.useCallback(j=>{for(const y of Object.values(a)){const A=y.find(v=>v.key===j);if(A)return A.value}},[a]);return{settings:a,isLoading:o,isUpdating:l,error:u,fetchSettings:g,updateSettings:p,getValue:x}}function Qa(s){const t=Math.floor(s/86400),r=Math.floor(s%86400/3600),a=Math.floor(s%3600/60),n=s%60;return{days:t,hours:r,minutes:a,seconds:n}}function Ka(s){const{days:t,hours:r,minutes:a}=Qa(s),n=[];return t>0&&n.push(`${t}d`),r>0&&n.push(`${r}h`),a>0&&n.push(`${a}m`),n.length===0&&n.push(`${s}s`),n.join(" ")}const Ga={auth_email_enabled:{key:"auth_email_enabled",label:"Enable Email Authentication",description:"Allow users to sign up and log in with email/password.",inputType:"boolean"},auth_email_require_verification:{key:"auth_email_require_verification",label:"Require Email Verification",description:"Users must verify their email address before they can log in.",inputType:"boolean"},auth_email_block_disposable:{key:"auth_email_block_disposable",label:"Block Disposable Emails",description:"Reject registrations from known disposable email providers.",inputType:"boolean"},auth_google_enabled:{key:"auth_google_enabled",label:"Enable Google Sign-In",description:"Allow users to authenticate with their Google account.",inputType:"boolean"},auth_google_client_id:{key:"auth_google_client_id",label:"Google Client ID",description:"OAuth 2.0 client ID from Google Cloud Console.",inputType:"text"},auth_google_client_secret:{key:"auth_google_client_secret",label:"Google Client Secret",description:"OAuth 2.0 client secret from Google Cloud Console.",inputType:"secret"},auth_apple_enabled:{key:"auth_apple_enabled",label:"Enable Sign in with Apple",description:"Allow users to authenticate with their Apple ID.",inputType:"boolean"},auth_apple_client_id:{key:"auth_apple_client_id",label:"Apple Services ID",description:"The Services ID configured in your Apple Developer account.",inputType:"text"},auth_apple_team_id:{key:"auth_apple_team_id",label:"Apple Team ID",description:"Your Apple Developer Team ID.",inputType:"text"},auth_apple_key_id:{key:"auth_apple_key_id",label:"Apple Key ID",description:"The Key ID for your Sign in with Apple private key.",inputType:"text"},auth_apple_private_key:{key:"auth_apple_private_key",label:"Apple Private Key",description:"The private key file contents (PEM format) for Sign in with Apple.",inputType:"secret",multiline:!0},auth_solana_enabled:{key:"auth_solana_enabled",label:"Enable Solana Wallet Auth",description:"Allow users to authenticate by signing with their Solana wallet.",inputType:"boolean"},auth_solana_challenge_expiry:{key:"auth_solana_challenge_expiry",label:"Challenge Expiry",description:"How long a wallet signature challenge is valid.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"10 minutes",value:"600"}]},auth_webauthn_enabled:{key:"auth_webauthn_enabled",label:"Enable WebAuthn/Passkeys",description:"Allow passwordless authentication with FIDO2/WebAuthn credentials.",inputType:"boolean"},auth_webauthn_rp_id:{key:"auth_webauthn_rp_id",label:"Relying Party ID",description:"Usually your domain (e.g., example.com). Passkeys are bound to this.",inputType:"text"},auth_webauthn_rp_name:{key:"auth_webauthn_rp_name",label:"Relying Party Name",description:"Display name shown to users during passkey registration.",inputType:"text"},auth_webauthn_rp_origin:{key:"auth_webauthn_rp_origin",label:"Allowed Origins",description:"Comma-separated origins allowed for WebAuthn (e.g., https://example.com).",inputType:"text"},feature_privacy_cash:{key:"feature_privacy_cash",label:"Privacy Cash",description:"Enable Privacy Cash deposits and timed withdrawals.",inputType:"boolean"},feature_wallet_signing:{key:"feature_wallet_signing",label:"Embedded Wallet Signing",description:"Enable the embedded wallet for transaction signing.",inputType:"boolean"},feature_sso:{key:"feature_sso",label:"Enterprise SSO",description:"Enable SAML/OIDC single sign-on for enterprise customers.",inputType:"boolean"},feature_organizations:{key:"feature_organizations",label:"Organizations",description:"Enable multi-user organizations with role-based access.",inputType:"boolean"},feature_mfa:{key:"feature_mfa",label:"Two-Factor Authentication",description:"Allow users to enable TOTP-based two-factor authentication.",inputType:"boolean"},feature_instant_link:{key:"feature_instant_link",label:"Instant Link Login",description:"Allow passwordless login via magic link sent to email.",inputType:"boolean"},security_cors_origins:{key:"security_cors_origins",label:"CORS Origins",description:"Allowed origins for cross-origin requests (comma-separated). Empty = same origin only.",inputType:"text"},security_cookie_domain:{key:"security_cookie_domain",label:"Cookie Domain",description:"Domain for auth cookies. Empty uses the request origin.",inputType:"text"},security_cookie_secure:{key:"security_cookie_secure",label:"Secure Cookies",description:"Require HTTPS for cookies. Disable only for local development.",inputType:"boolean"},security_cookie_same_site:{key:"security_cookie_same_site",label:"Cookie SameSite",description:'SameSite policy for cookies. Use "none" only if needed for cross-site embeds.',inputType:"select",presets:[{label:"Strict",value:"strict"},{label:"Lax (Recommended)",value:"lax"},{label:"None (cross-site)",value:"none"}]},security_session_timeout:{key:"security_session_timeout",label:"Session Timeout",description:"How long sessions remain valid before requiring re-authentication.",inputType:"duration",min:300,presets:[{label:"1 hour",value:"3600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"30 days",value:"2592000"}]},security_jwt_issuer:{key:"security_jwt_issuer",label:"JWT Issuer",description:"Issuer claim for JWTs. Empty uses the server URL.",inputType:"text"},security_jwt_audience:{key:"security_jwt_audience",label:"JWT Audience",description:"Audience claim for JWTs. Empty uses default.",inputType:"text"},email_smtp_host:{key:"email_smtp_host",label:"SMTP Host",description:"SMTP server hostname (e.g., smtp.sendgrid.net).",inputType:"text"},email_smtp_port:{key:"email_smtp_port",label:"SMTP Port",description:"SMTP server port. Common: 587 (TLS), 465 (SSL), 25 (unencrypted).",inputType:"select",presets:[{label:"587 (TLS)",value:"587"},{label:"465 (SSL)",value:"465"},{label:"25 (Plain)",value:"25"}]},email_smtp_user:{key:"email_smtp_user",label:"SMTP Username",description:"Username for SMTP authentication.",inputType:"text"},email_smtp_password:{key:"email_smtp_password",label:"SMTP Password",description:"Password or API key for SMTP authentication.",inputType:"secret"},email_smtp_tls:{key:"email_smtp_tls",label:"Use TLS",description:"Enable TLS encryption for SMTP connections.",inputType:"boolean"},email_from_address:{key:"email_from_address",label:"From Address",description:"Default sender email address (e.g., noreply@example.com).",inputType:"text"},email_from_name:{key:"email_from_name",label:"From Name",description:'Default sender display name (e.g., "My App").',inputType:"text"},webhook_enabled:{key:"webhook_enabled",label:"Enable Webhooks",description:"Send HTTP notifications for auth events (signup, login, etc.).",inputType:"boolean"},webhook_url:{key:"webhook_url",label:"Webhook URL",description:"Endpoint to receive webhook POST requests.",inputType:"text"},webhook_secret:{key:"webhook_secret",label:"Webhook Secret",description:"Secret used to sign webhook payloads (HMAC-SHA256).",inputType:"secret"},webhook_timeout:{key:"webhook_timeout",label:"Timeout",description:"Maximum time to wait for webhook response.",inputType:"duration",min:5,presets:[{label:"10 seconds",value:"10"},{label:"30 seconds",value:"30"},{label:"60 seconds",value:"60"}]},webhook_retries:{key:"webhook_retries",label:"Max Retries",description:"Number of retry attempts for failed webhooks.",inputType:"select",presets:[{label:"0 (No retries)",value:"0"},{label:"3 (Recommended)",value:"3"},{label:"5",value:"5"}]},server_frontend_url:{key:"server_frontend_url",label:"Frontend URL",description:"URL of your frontend app (for redirects and email links).",inputType:"text"},server_base_path:{key:"server_base_path",label:"Base Path",description:"Base path for auth endpoints (e.g., /auth).",inputType:"text"},server_trust_proxy:{key:"server_trust_proxy",label:"Trust Proxy",description:"Trust X-Forwarded-For headers. Enable if behind a reverse proxy.",inputType:"boolean"},privacy_period_secs:{key:"privacy_period_secs",label:"Privacy Period",description:"How long deposits are held before withdrawal to provide timing privacy. Longer periods provide better privacy but delay user access to funds.",inputType:"duration",min:0,presets:[{label:"Disabled",value:"0"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"14 days",value:"1209600"},{label:"30 days",value:"2592000"}],warningThreshold:{below:3600,message:"Very short privacy periods may not provide adequate timing protection."}},withdrawal_poll_interval_secs:{key:"withdrawal_poll_interval_secs",label:"Worker Poll Interval",description:"How often the withdrawal worker checks for deposits ready to process. Lower values process faster but increase server load.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"}],warningThreshold:{below:60,message:"Polling more than once per minute may cause excessive load."}},withdrawal_batch_size:{key:"withdrawal_batch_size",label:"Batch Size",description:"Maximum number of withdrawals to process in a single batch. Higher values improve throughput but may cause timeouts.",inputType:"select",min:1,max:100,presets:[{label:"1 (Sequential)",value:"1"},{label:"5",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100 (Max)",value:"100"}]},withdrawal_timeout_secs:{key:"withdrawal_timeout_secs",label:"Transaction Timeout",description:"How long to wait for a withdrawal transaction to confirm before considering it failed.",inputType:"duration",min:30,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"2 minutes",value:"120"},{label:"5 minutes",value:"300"}],warningThreshold:{below:30,message:"Very short timeouts may cause premature failure on slow networks."}},withdrawal_max_retries:{key:"withdrawal_max_retries",label:"Max Retries",description:"Number of times to retry a failed withdrawal before marking it as permanently failed.",inputType:"select",min:0,max:10,presets:[{label:"0 (No retries)",value:"0"},{label:"1",value:"1"},{label:"3 (Recommended)",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},withdrawal_percentage:{key:"withdrawal_percentage",label:"Withdrawal Percentage",description:"Percentage of ready funds to withdraw each cycle. Lower values spread withdrawals over time for better privacy.",inputType:"percentage",min:1,max:100,step:5,presets:[{label:"25%",value:"25"},{label:"50%",value:"50"},{label:"75%",value:"75"},{label:"100% (All at once)",value:"100"}],warningThreshold:{above:75,message:"High percentages may reduce timing privacy by processing most withdrawals together."}},partial_withdrawal_count:{key:"partial_withdrawal_count",label:"Partial Withdrawals",description:"Maximum partial withdrawals per batch. Partial withdrawals add noise to timing analysis. Set to 0 to disable.",inputType:"select",min:0,presets:[{label:"Disabled",value:"0"},{label:"1",value:"1"},{label:"3",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},partial_withdrawal_min_lamports:{key:"partial_withdrawal_min_lamports",label:"Min Balance for Partial",description:"Minimum account balance (in lamports) required before partial withdrawals are considered. 1 SOL = 1,000,000,000 lamports.",inputType:"select",min:0,presets:[{label:"0.1 SOL",value:"100000000"},{label:"0.5 SOL",value:"500000000"},{label:"1 SOL",value:"1000000000"},{label:"5 SOL",value:"5000000000"},{label:"10 SOL",value:"10000000000"}]},rate_limit_auth:{key:"rate_limit_auth",label:"Auth Request Limit",description:"Maximum authentication attempts (login, register, password reset) per IP per window. Protects against brute force attacks.",inputType:"select",min:1,unit:"requests",presets:[{label:"5 (Strict)",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"20",value:"20"},{label:"50 (Permissive)",value:"50"}],warningThreshold:{above:20,message:"High auth limits may allow brute force attempts."}},rate_limit_general:{key:"rate_limit_general",label:"General Request Limit",description:"Maximum general API requests per IP per window. Affects all non-auth endpoints.",inputType:"select",min:1,unit:"requests",presets:[{label:"30",value:"30"},{label:"60 (Recommended)",value:"60"},{label:"120",value:"120"},{label:"300",value:"300"}]},rate_limit_credit:{key:"rate_limit_credit",label:"Credit Request Limit",description:"Maximum credit/balance check requests per IP per window. Higher for apps that poll balance frequently.",inputType:"select",min:1,unit:"requests",presets:[{label:"10",value:"10"},{label:"30 (Recommended)",value:"30"},{label:"60",value:"60"},{label:"120",value:"120"}]},rate_limit_window:{key:"rate_limit_window",label:"Rate Limit Window",description:'Time window for rate limiting. All limits above are "per window". Shorter windows are stricter.',inputType:"duration",min:1,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"}]},deposit_quick_action_tokens:{key:"deposit_quick_action_tokens",label:"Quick Action Tokens",description:"Comma-separated token symbols shown as quick action buttons. First token is the default.",inputType:"tokenSymbolList"},deposit_custom_tokens:{key:"deposit_custom_tokens",label:"Custom Dropdown Tokens",description:'Comma-separated token symbols shown in the "Custom" dropdown. Leave empty to show all.',inputType:"tokenSymbolList"},deposit_custom_tokens_json:{key:"deposit_custom_tokens_json",label:"Custom Token Definitions",description:"Add tokens beyond the built-in list. Define symbol, mint address, decimals, and logo URL.",inputType:"tokenList"}},Ya={"auth.apple":{label:"Apple Sign-In",description:"Configure Sign in with Apple OAuth integration.",icon:""},"auth.email":{label:"Email Authentication",description:"Configure email/password authentication settings.",icon:""},"auth.google":{label:"Google Sign-In",description:"Configure Google OAuth integration.",icon:""},"auth.solana":{label:"Solana Wallet Auth",description:"Configure Solana wallet signature authentication.",icon:""},"auth.webauthn":{label:"WebAuthn / Passkeys",description:"Configure FIDO2/WebAuthn passwordless authentication.",icon:""},deposit:{label:"Deposit Settings",description:"Configure token lists and deposit flow display options.",icon:""},email:{label:"Email / SMTP",description:"Configure outbound email delivery for verification, password reset, and notifications.",icon:""},features:{label:"Feature Flags",description:"Enable or disable major platform features.",icon:""},privacy:{label:"Privacy Settings",description:"Control the privacy period for deposits. Longer periods provide better timing privacy but delay fund availability.",icon:""},rate_limit:{label:"Rate Limiting",description:"Protect the system from abuse by limiting request rates. Balance security with user experience.",icon:""},security:{label:"Security",description:"Configure CORS, cookies, sessions, and JWT settings.",icon:""},server:{label:"Server",description:"Server infrastructure settings. Some may be overridden by environment variables.",icon:""},webhook:{label:"Webhooks",description:"Configure HTTP webhook notifications for auth events.",icon:""},withdrawal:{label:"Withdrawal Worker",description:"Configure how the automated withdrawal processor handles pending withdrawals. These settings affect throughput and privacy.",icon:""}};function Ja({showDescriptions:s=!0,className:t="",onSave:r}){const{settings:a,isLoading:n,isUpdating:o,error:c,fetchSettings:l,updateSettings:d}=Ue(),[u,f]=i.useState({}),[m,h]=i.useState(null),[b,g]=i.useState(!1);i.useEffect(()=>{l()},[l]),i.useEffect(()=>{if(b){const S=setTimeout(()=>g(!1),3e3);return()=>clearTimeout(S)}},[b]);const p=i.useCallback((S,w)=>{f(C=>({...C,[S]:w})),h(null),g(!1)},[]),x=i.useCallback(async()=>{const S=Object.entries(u).map(([w,C])=>({key:w,value:C}));if(S.length!==0)try{await d(S),f({}),h(null),g(!0),r?.()}catch(w){h(w instanceof Error?w.message:"Failed to save settings")}},[u,d,r]),j=i.useCallback(()=>{f({}),h(null),g(!1)},[]),y=Object.keys(u).length>0,A=Object.keys(u).length;if(n&&Object.keys(a).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(c)return e.jsx("div",{className:`cedros-system-settings ${t}`,children:e.jsx(N.ErrorMessage,{error:c.message})});const v=Object.keys(a).sort();return v.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${t}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${t}`,children:[m&&e.jsx(N.ErrorMessage,{error:m}),b&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),v.map(S=>e.jsx(Xa,{category:S,settings:a[S],edits:u,showDescription:s,onChange:p},S)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[y&&e.jsxs("span",{className:"cedros-settings-change-count",children:[A," unsaved change",A!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:j,disabled:!y||o,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,disabled:!y||o,children:o?e.jsx(N.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}function Xa({category:s,settings:t,edits:r,showDescription:a,onChange:n}){const o=Ya[s]||{label:s,description:"",icon:"⚙️"};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:o.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:o.label}),a&&o.description&&e.jsx("p",{className:"cedros-settings-section-description",children:o.description})]})]}),e.jsx("div",{className:"cedros-settings-grid",children:t.map(c=>e.jsx(Za,{setting:c,editValue:r[c.key],onChange:n},c.key))})]})}function Za({setting:s,editValue:t,onChange:r}){const a=Ga[s.key],n=t??s.value,o=t!==void 0&&t!==s.value,c=i.useMemo(()=>{if(!a?.warningThreshold)return null;const l=parseInt(n,10);if(isNaN(l))return null;const{above:d,below:u,message:f}=a.warningThreshold;return d!==void 0&&l>d||u!==void 0&&l<u?f:null},[n,a?.warningThreshold]);return a?e.jsxs("div",{className:`cedros-setting-row ${o?"cedros-setting-row-changed":""} ${c?"cedros-setting-row-warning":""}`,children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:a.label}),e.jsx("span",{className:"cedros-setting-description",children:a.description})]}),e.jsxs("div",{className:"cedros-setting-control",children:[a.inputType==="duration"&&e.jsx(eo,{value:n,onChange:l=>r(s.key,l),presets:a.presets,min:a.min}),a.inputType==="percentage"&&e.jsx(so,{value:n,onChange:l=>r(s.key,l),min:a.min??1,max:a.max??100,step:a.step??5,presets:a.presets}),a.inputType==="select"&&e.jsx(to,{value:n,onChange:l=>r(s.key,l),presets:a.presets??[],unit:a.unit}),a.inputType==="number"&&e.jsx(ro,{value:n,onChange:l=>r(s.key,l),min:a.min,max:a.max,unit:a.unit}),a.inputType==="tokenList"&&e.jsx(oo,{value:n,onChange:l=>r(s.key,l)}),a.inputType==="text"&&e.jsx("input",{type:"text",value:n,onChange:l=>r(s.key,l.target.value),className:"cedros-setting-input",placeholder:a.label}),a.inputType==="boolean"&&e.jsx(no,{value:n,onChange:l=>r(s.key,l)}),a.inputType==="secret"&&e.jsx(ao,{value:n,onChange:l=>r(s.key,l),multiline:a.multiline}),a.inputType==="tokenSymbolList"&&e.jsx(io,{value:n,onChange:l=>r(s.key,l)}),c&&e.jsx("div",{className:"cedros-setting-warning",children:c})]})]}):e.jsxs("div",{className:`cedros-setting-row ${o?"cedros-setting-row-changed":""}`,children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:s.key}),s.description&&e.jsx("span",{className:"cedros-setting-description",children:s.description})]}),e.jsx("div",{className:"cedros-setting-input-wrapper",children:e.jsx("input",{type:"text",value:n,onChange:l=>r(s.key,l.target.value),className:"cedros-setting-input"})})]})}function eo({value:s,onChange:t,presets:r,min:a=0}){const n=parseInt(s,10)||0,o=Ka(n),c=i.useCallback(d=>{d.target.value&&t(d.target.value)},[t]),l=i.useCallback(d=>{const u=Math.max(a,parseInt(d.target.value,10)||0);t(String(u))},[t,a]);return e.jsxs("div",{className:"cedros-duration-input",children:[r&&r.length>0&&e.jsxs("select",{value:r.find(d=>d.value===s)?.value??"",onChange:c,className:"cedros-setting-select",children:[e.jsx("option",{value:"",children:"Custom..."}),r.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))]}),e.jsxs("div",{className:"cedros-duration-custom",children:[e.jsx("input",{type:"number",value:n,onChange:l,min:a,className:"cedros-setting-input cedros-setting-input-sm"}),e.jsx("span",{className:"cedros-setting-unit",children:"seconds"}),e.jsxs("span",{className:"cedros-duration-display",children:["= ",o]})]})]})}function so({value:s,onChange:t,min:r,max:a,step:n,presets:o}){const c=parseInt(s,10)||r,l=i.useCallback(u=>{t(u.target.value)},[t]),d=i.useCallback(u=>{t(u)},[t]);return e.jsxs("div",{className:"cedros-percentage-input",children:[e.jsxs("div",{className:"cedros-percentage-slider-row",children:[e.jsx("input",{type:"range",value:c,onChange:l,min:r,max:a,step:n,className:"cedros-percentage-slider"}),e.jsxs("span",{className:"cedros-percentage-value",children:[c,"%"]})]}),o&&o.length>0&&e.jsx("div",{className:"cedros-preset-buttons",children:o.map(u=>e.jsx("button",{type:"button",className:`cedros-preset-button ${u.value===s?"cedros-preset-button-active":""}`,onClick:()=>d(u.value),children:u.label},u.value))})]})}function to({value:s,onChange:t,presets:r,unit:a}){const n=!r.some(l=>l.value===s),o=i.useCallback(l=>{l.target.value!=="__custom__"&&t(l.target.value)},[t]),c=i.useCallback(l=>{t(l.target.value)},[t]);return e.jsxs("div",{className:"cedros-select-input",children:[e.jsxs("select",{value:n?"__custom__":s,onChange:o,className:"cedros-setting-select",children:[r.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value)),e.jsx("option",{value:"__custom__",children:"Custom..."})]}),n&&e.jsxs("div",{className:"cedros-select-custom",children:[e.jsx("input",{type:"number",value:s,onChange:c,className:"cedros-setting-input cedros-setting-input-sm"}),a&&e.jsx("span",{className:"cedros-setting-unit",children:a})]})]})}function ro({value:s,onChange:t,min:r,max:a,unit:n}){const o=i.useCallback(c=>{t(c.target.value)},[t]);return e.jsxs("div",{className:"cedros-number-input",children:[e.jsx("input",{type:"number",value:s,onChange:o,min:r,max:a,className:"cedros-setting-input"}),n&&e.jsx("span",{className:"cedros-setting-unit",children:n})]})}function no({value:s,onChange:t}){const r=s==="true",a=i.useCallback(()=>{t(r?"false":"true")},[r,t]);return e.jsxs("button",{type:"button",role:"switch","aria-checked":r,className:`cedros-toggle ${r?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:a,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:r?"Enabled":"Disabled"})]})}function ao({value:s,onChange:t,multiline:r}){const[a,n]=i.useState(!1),[o,c]=i.useState(!1),l=s&&s.length>0,d=i.useCallback(()=>{n(!0),c(!0)},[]),u=i.useCallback(()=>{n(!1),c(!1)},[]),f=i.useCallback(m=>{t(m.target.value)},[t]);return!a&&l?e.jsxs("div",{className:"cedros-secret-input cedros-secret-input-masked",children:[e.jsx("span",{className:"cedros-secret-masked",children:"•".repeat(Math.min(s.length,20))}),e.jsx("button",{type:"button",className:"cedros-secret-edit-btn",onClick:d,children:"Edit"})]}):e.jsxs("div",{className:"cedros-secret-input",children:[r?e.jsx("textarea",{value:s,onChange:f,className:"cedros-setting-input cedros-setting-textarea",placeholder:"Enter secret value...",rows:4}):e.jsx("input",{type:o?"text":"password",value:s,onChange:f,className:"cedros-setting-input",placeholder:"Enter secret value..."}),e.jsxs("div",{className:"cedros-secret-actions",children:[!r&&e.jsx("button",{type:"button",className:"cedros-secret-toggle-btn",onClick:()=>c(!o),children:o?"Hide":"Show"}),a&&e.jsx("button",{type:"button",className:"cedros-secret-done-btn",onClick:u,children:"Done"})]})]})}const Ur=["SOL","USDC","USDT","EURC","USD1","PYUSD","USDH","CASH","BONK","ORE"];function oo({value:s,onChange:t}){const r=i.useMemo(()=>{try{return JSON.parse(s||"[]")}catch{return[]}},[s]),a=i.useCallback(l=>{t(JSON.stringify(l))},[t]),n=i.useCallback(()=>{a([...r,{symbol:"",mint:"",decimals:6}])},[r,a]),o=i.useCallback((l,d,u)=>{const f=[...r];f[l]={...f[l],[d]:u},a(f)},[r,a]),c=i.useCallback(l=>{a(r.filter((d,u)=>u!==l))},[r,a]);return e.jsxs("div",{className:"cedros-token-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Built-in tokens:"}),e.jsx("div",{className:"cedros-token-presets-list",children:Ur.map(l=>e.jsx("span",{className:"cedros-token-preset-chip",children:l},l))})]}),r.length===0&&e.jsx("p",{className:"cedros-token-list-empty",children:"No custom tokens added. Use the built-in tokens above or add your own."}),r.map((l,d)=>e.jsxs("div",{className:"cedros-token-row",children:[e.jsxs("div",{className:"cedros-token-row-fields",children:[e.jsx("input",{type:"text",placeholder:"Symbol",value:l.symbol,onChange:u=>o(d,"symbol",u.target.value.toUpperCase()),className:"cedros-setting-input cedros-token-input-symbol",maxLength:10}),e.jsx("input",{type:"text",placeholder:"Mint address",value:l.mint,onChange:u=>o(d,"mint",u.target.value),className:"cedros-setting-input cedros-token-input-mint"}),e.jsx("input",{type:"number",placeholder:"Decimals",value:l.decimals,onChange:u=>o(d,"decimals",parseInt(u.target.value,10)||0),className:"cedros-setting-input cedros-token-input-decimals",min:0,max:18}),e.jsx("input",{type:"text",placeholder:"Logo URL (optional)",value:l.logoUrl||"",onChange:u=>o(d,"logoUrl",u.target.value||void 0),className:"cedros-setting-input cedros-token-input-logo"})]}),e.jsx("button",{type:"button",className:"cedros-token-remove-btn",onClick:()=>c(d),title:"Remove token",children:"×"})]},d)),e.jsx("button",{type:"button",className:"cedros-token-add-btn",onClick:n,children:"+ Add Token"})]})}function io({value:s,onChange:t}){const r=i.useMemo(()=>s.split(",").map(o=>o.trim()).filter(Boolean),[s]),a=i.useCallback(o=>{if(!o||r.includes(o))return;const c=[...r,o].join(", ");t(c)},[r,t]),n=i.useCallback(o=>{const c=r.filter(l=>l!==o).join(", ");t(c)},[r,t]);return e.jsxs("div",{className:"cedros-token-symbol-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Click to add:"}),e.jsx("div",{className:"cedros-token-presets-list",children:Ur.map(o=>{const c=r.includes(o);return e.jsxs("button",{type:"button",className:`cedros-token-preset-chip ${c?"cedros-token-preset-chip-selected":""}`,onClick:()=>c?n(o):a(o),title:c?`Remove ${o}`:`Add ${o}`,children:[o,c&&e.jsx("span",{className:"cedros-token-chip-check",children:"✓"})]},o)})})]}),e.jsx("input",{type:"text",value:s,onChange:o=>t(o.target.value),className:"cedros-setting-input",placeholder:"USDC, SOL, BONK..."})]})}class lo{client;constructor(t,r,a){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a})}async getStatus(){try{return await this.client.get("/setup/status")}catch(t){throw N.handleApiError(t,"Failed to check setup status")}}async createFirstAdmin(t){try{return await this.client.post("/setup/admin",t)}catch(r){throw N.handleApiError(r,"Failed to create admin account")}}}function Ys(){const{config:s}=N.useCedrosLogin(),[t,r]=i.useState(null),[a,n]=i.useState(!1),[o,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useRef(0),f=i.useMemo(()=>new lo(s.serverUrl,s.requestTimeout,s.retryAttempts),[s.serverUrl,s.requestTimeout,s.retryAttempts]),m=i.useRef(f);m.current=f;const h=i.useCallback(async()=>{n(!0),d(null);const g=++u.current;try{const p=await m.current.getStatus();if(g!==u.current)return;r(p)}catch(p){if(g!==u.current)return;d(p instanceof Error?p:new Error("Failed to check setup status"))}finally{g===u.current&&n(!1)}},[]),b=i.useCallback(async g=>{c(!0),d(null);try{const p=await m.current.createFirstAdmin(g);return await h(),p}catch(p){const x=p instanceof Error?p:new Error("Failed to create admin");throw d(x),x}finally{c(!1)}},[h]);return{status:t,isLoading:a,isCreating:o,error:l,checkStatus:h,createAdmin:b}}const co=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,pt=8;function uo(s){const t={};return s.email?co.test(s.email)||(t.email="Invalid email format"):t.email="Email is required",s.password?s.password.length<pt&&(t.password=`Password must be at least ${pt} characters`):t.password="Password is required",s.confirmPassword?s.password!==s.confirmPassword&&(t.confirmPassword="Passwords do not match"):t.confirmPassword="Please confirm your password",t}function Fr({onComplete:s,className:t=""}){const{status:r,isLoading:a,isCreating:n,error:o,checkStatus:c,createAdmin:l}=Ys(),[d,u]=i.useState({email:"",password:"",confirmPassword:"",name:""}),[f,m]=i.useState({}),[h,b]=i.useState(!1);i.useEffect(()=>{c()},[c]);const g=i.useCallback(x=>j=>{u(y=>({...y,[x]:j.target.value})),m(y=>({...y,[x]:void 0}))},[]),p=i.useCallback(async x=>{x.preventDefault();const j=uo(d);if(Object.keys(j).length>0){m(j);return}try{await l({email:d.email,password:d.password,name:d.name||void 0}),b(!0),s?.()}catch{}},[d,l,s]);return a?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):r&&!r.needsSetup?e.jsx("div",{className:`cedros-setup ${t}`,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."})]})}):h?e.jsx("div",{className:`cedros-setup ${t}`,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 ${t}`,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:p,children:[o&&e.jsx(N.ErrorMessage,{error:o.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:d.email,onChange:g("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:d.name,onChange:g("name"),placeholder:"Admin",autoComplete:"name",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:d.password,onChange:g("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:d.confirmPassword,onChange:g("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(N.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 ho=800,mo=2e3;function Ee(){const{settings:s,isLoading:t,error:r,fetchSettings:a,updateSettings:n}=Ue(),[o,c]=i.useState({}),[l,d]=i.useState("idle"),[u,f]=i.useState(null),m=i.useRef(null),h=i.useRef(null),b=i.useRef({});i.useEffect(()=>()=>{m.current&&clearTimeout(m.current),h.current&&clearTimeout(h.current)},[]);const g=i.useCallback(async()=>{const j={...b.current};if(Object.keys(j).length===0){d("idle");return}d("saving"),f(null);const y=Object.entries(j).map(([A,v])=>({key:A,value:v}));try{await n(y),c(A=>{const v={...A};for(const S of Object.keys(j))delete v[S];return v});for(const A of Object.keys(j))delete b.current[A];d("saved"),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{d("idle")},mo)}catch(A){d("error"),f(A instanceof Error?A.message:"Failed to save")}},[n]),p=i.useCallback((j,y)=>{c(A=>({...A,[j]:y})),b.current[j]=y,f(null),d("pending"),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{g()},ho)},[g]),x=i.useCallback(j=>{if(o[j]!==void 0)return o[j];for(const y of Object.values(s)){const A=y.find(v=>v.key===j);if(A)return A.value}return""},[o,s]);return{settings:s,edits:o,isLoading:t,autosaveStatus:l,autosaveError:u,error:r,fetchSettings:a,handleChange:p,getEffectiveValue:x}}function po(s){const t=Math.floor(s/86400),r=Math.floor(s%86400/3600),a=Math.floor(s%3600/60),n=s%60;return{days:t,hours:r,minutes:a,seconds:n}}function fo(s){const{days:t,hours:r,minutes:a}=po(s),n=[];return t>0&&n.push(`${t}d`),r>0&&n.push(`${r}h`),a>0&&n.push(`${a}m`),n.length===0&&n.push(`${s}s`),n.join(" ")}const go={auth_email_enabled:{key:"auth_email_enabled",label:"Enable Email Authentication",description:"Allow users to sign up and log in with email/password.",inputType:"boolean"},auth_email_require_verification:{key:"auth_email_require_verification",label:"Require Email Verification",description:"Users must verify their email address before they can log in.",inputType:"boolean"},auth_email_block_disposable:{key:"auth_email_block_disposable",label:"Block Disposable Emails",description:"Reject registrations from known disposable email providers.",inputType:"boolean"},auth_google_enabled:{key:"auth_google_enabled",label:"Enable Google Sign-In",description:"Allow users to authenticate with their Google account.",inputType:"boolean"},auth_google_client_id:{key:"auth_google_client_id",label:"Google Client ID",description:"OAuth 2.0 client ID from Google Cloud Console.",inputType:"text"},auth_google_client_secret:{key:"auth_google_client_secret",label:"Google Client Secret",description:"OAuth 2.0 client secret from Google Cloud Console.",inputType:"secret"},auth_apple_enabled:{key:"auth_apple_enabled",label:"Enable Sign in with Apple",description:"Allow users to authenticate with their Apple ID.",inputType:"boolean"},auth_apple_client_id:{key:"auth_apple_client_id",label:"Apple Services ID",description:"The Services ID configured in your Apple Developer account.",inputType:"text"},auth_apple_team_id:{key:"auth_apple_team_id",label:"Apple Team ID",description:"Your Apple Developer Team ID.",inputType:"text"},auth_apple_key_id:{key:"auth_apple_key_id",label:"Apple Key ID",description:"The Key ID for your Sign in with Apple private key.",inputType:"text"},auth_apple_private_key:{key:"auth_apple_private_key",label:"Apple Private Key",description:"The private key file contents (PEM format) for Sign in with Apple.",inputType:"secret",multiline:!0},auth_solana_enabled:{key:"auth_solana_enabled",label:"Enable Solana Wallet Auth",description:"Allow users to authenticate by signing with their Solana wallet.",inputType:"boolean"},auth_solana_challenge_expiry:{key:"auth_solana_challenge_expiry",label:"Challenge Expiry",description:"How long a wallet signature challenge is valid.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"10 minutes",value:"600"}]},auth_webauthn_enabled:{key:"auth_webauthn_enabled",label:"Enable WebAuthn/Passkeys",description:"Allow passwordless authentication with FIDO2/WebAuthn credentials.",inputType:"boolean"},auth_webauthn_rp_id:{key:"auth_webauthn_rp_id",label:"Relying Party ID",description:"Usually your domain (e.g., example.com). Passkeys are bound to this.",inputType:"text"},auth_webauthn_rp_name:{key:"auth_webauthn_rp_name",label:"Relying Party Name",description:"Display name shown to users during passkey registration.",inputType:"text"},auth_webauthn_rp_origin:{key:"auth_webauthn_rp_origin",label:"Allowed Origins",description:"Comma-separated origins allowed for WebAuthn (e.g., https://example.com).",inputType:"text"},auth_instantlink_enabled:{key:"auth_instantlink_enabled",label:"Enable Instant Link",description:"Allow passwordless login via magic link sent to email.",inputType:"boolean"},auth_instantlink_expiry:{key:"auth_instantlink_expiry",label:"Link Expiry",description:"How long the magic link remains valid.",inputType:"duration",min:60,presets:[{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"},{label:"30 minutes",value:"1800"},{label:"1 hour",value:"3600"}]},auth_instantlink_rate_limit:{key:"auth_instantlink_rate_limit",label:"Rate Limit",description:"Maximum instant link requests per email per hour.",inputType:"select",presets:[{label:"3 per hour",value:"3"},{label:"5 per hour",value:"5"},{label:"10 per hour",value:"10"}]},feature_organizations:{key:"feature_organizations",label:"Organizations",description:"Enable multi-user organizations with role-based access.",inputType:"boolean"},feature_sso:{key:"feature_sso",label:"Enterprise SSO",description:"Enable SAML/OIDC single sign-on for enterprise customers.",inputType:"boolean"},feature_mfa:{key:"feature_mfa",label:"Two-Factor Authentication",description:"Allow users to enable TOTP-based two-factor authentication.",inputType:"boolean"},feature_wallet_signing:{key:"feature_wallet_signing",label:"Enable Embedded Wallet",description:"Enable the embedded wallet for transaction signing.",inputType:"boolean"},wallet_recovery_mode:{key:"wallet_recovery_mode",label:"Recovery Mode",description:"How users can recover their wallet if they lose access.",inputType:"select",presets:[{label:"Share C Only (Recommended)",value:"share_c_only"},{label:"Full Seed Phrase",value:"full_seed"},{label:"No Recovery",value:"none"}]},feature_credits:{key:"feature_credits",label:"Credit System",description:"Enable the deposits and credits system. Users can deposit tokens to receive platform credits.",inputType:"boolean"},security_cors_origins:{key:"security_cors_origins",label:"CORS Origins",description:"Allowed origins for cross-origin requests (comma-separated). Empty = same origin only.",inputType:"text"},security_cookie_domain:{key:"security_cookie_domain",label:"Cookie Domain",description:"Domain for auth cookies. Empty uses the request origin.",inputType:"text"},security_cookie_secure:{key:"security_cookie_secure",label:"Secure Cookies",description:"Require HTTPS for cookies. Disable only for local development.",inputType:"boolean"},security_cookie_same_site:{key:"security_cookie_same_site",label:"Cookie SameSite",description:'SameSite policy for cookies. Use "none" only if needed for cross-site embeds.',inputType:"select",presets:[{label:"Strict",value:"strict"},{label:"Lax (Recommended)",value:"lax"},{label:"None (cross-site)",value:"none"}]},security_session_timeout:{key:"security_session_timeout",label:"Session Timeout",description:"How long sessions remain valid before requiring re-authentication.",inputType:"duration",min:300,presets:[{label:"1 hour",value:"3600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"30 days",value:"2592000"}]},security_jwt_issuer:{key:"security_jwt_issuer",label:"JWT Issuer",description:"Issuer claim for JWTs. Empty uses the server URL.",inputType:"text"},security_jwt_audience:{key:"security_jwt_audience",label:"JWT Audience",description:"Audience claim for JWTs. Empty uses default.",inputType:"text"},email_provider:{key:"email_provider",label:"Email Provider",description:"Select your email service provider for automatic configuration.",inputType:"select",presets:[{label:"Mailgun",value:"mailgun"},{label:"SendGrid",value:"sendgrid"},{label:"Postmark",value:"postmark"},{label:"AWS SES",value:"ses"},{label:"Resend",value:"resend"},{label:"Custom SMTP",value:"custom"}]},email_smtp_host:{key:"email_smtp_host",label:"SMTP Host",description:"SMTP server hostname (e.g., smtp.sendgrid.net).",inputType:"text"},email_smtp_port:{key:"email_smtp_port",label:"SMTP Port",description:"SMTP server port. Common: 587 (TLS), 465 (SSL), 25 (unencrypted).",inputType:"select",presets:[{label:"587 (TLS)",value:"587"},{label:"465 (SSL)",value:"465"},{label:"25 (Plain)",value:"25"}]},email_smtp_user:{key:"email_smtp_user",label:"SMTP Username",description:"Username for SMTP authentication.",inputType:"text"},email_smtp_password:{key:"email_smtp_password",label:"API Key",description:"API key or password for your email provider.",inputType:"secret"},email_smtp_tls:{key:"email_smtp_tls",label:"Use TLS",description:"Enable TLS encryption for SMTP connections.",inputType:"boolean"},email_from_address:{key:"email_from_address",label:"From Address",description:"Default sender email address (e.g., noreply@example.com).",inputType:"text"},email_from_name:{key:"email_from_name",label:"From Name",description:'Default sender display name (e.g., "My App").',inputType:"text"},webhook_enabled:{key:"webhook_enabled",label:"Enable Webhooks",description:"Send notifications to a Discord or Slack webhook URL.",inputType:"boolean"},webhook_url:{key:"webhook_url",label:"Webhook URL",description:"Discord or Slack webhook URL to receive notifications.",inputType:"text",placeholder:"https://discord.com/api/webhooks/..."},webhook_notify_registrations:{key:"webhook_notify_registrations",label:"New Registrations",description:"Notify when a new user registers.",inputType:"boolean"},webhook_notify_signins:{key:"webhook_notify_signins",label:"Sign-Ins",description:"Notify when a user signs in.",inputType:"boolean"},webhook_notify_deposits:{key:"webhook_notify_deposits",label:"Deposits",description:"Notify when a user makes a deposit.",inputType:"boolean"},server_frontend_url:{key:"server_frontend_url",label:"Frontend URL",description:"URL of your frontend app (for redirects and email links).",inputType:"text"},server_base_path:{key:"server_base_path",label:"Base Path",description:"Base path for auth endpoints (e.g., /auth).",inputType:"text"},server_trust_proxy:{key:"server_trust_proxy",label:"Trust Proxy",description:"Trust X-Forwarded-For headers. Enable if behind a reverse proxy.",inputType:"boolean"},server_cedros_pay_api_key:{key:"server_cedros_pay_api_key",label:"Cedros Pay API Key",description:"API key for Cedros Pay to authenticate with this server. Copy this into your Cedros Pay settings.",inputType:"secret"},jupiter_api_key:{key:"jupiter_api_key",label:"Jupiter API Key",description:'API key for Jupiter Ultra API (gasless swaps). Get a free key at <a href="https://portal.jup.ag" target="_blank" rel="noopener">portal.jup.ag</a>.',inputType:"secret"},server_metrics_api_key:{key:"server_metrics_api_key",label:"Metrics API Key",description:"API key for Prometheus/Grafana to scrape the /metrics endpoint. Use with Authorization: Bearer header.",inputType:"secret"},server_log_level:{key:"server_log_level",label:"Log Level",description:"Minimum severity level for log output. Lower levels are more verbose.",inputType:"select",presets:[{label:"Trace (most verbose)",value:"trace"},{label:"Debug",value:"debug"},{label:"Info",value:"info"},{label:"Warn",value:"warn"},{label:"Error (least verbose)",value:"error"}]},server_log_format:{key:"server_log_format",label:"Log Format",description:"Output format for log messages.",inputType:"select",presets:[{label:"JSON (structured)",value:"json"},{label:"Pretty (human-readable)",value:"pretty"}]},server_environment:{key:"server_environment",label:"Environment",description:"Deployment environment. Affects default behaviors and log verbosity.",inputType:"select",presets:[{label:"Development",value:"development"},{label:"Staging",value:"staging"},{label:"Production",value:"production"}]},privacy_period_secs:{key:"privacy_period_secs",label:"Privacy Period",description:"How long deposits are held before withdrawal to provide timing privacy. Longer periods provide better privacy but delay user access to funds.",inputType:"duration",min:0,presets:[{label:"Disabled",value:"0"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"14 days",value:"1209600"},{label:"30 days",value:"2592000"}],warningThreshold:{below:3600,message:"Very short privacy periods may not provide adequate timing protection."}},treasury_wallet_address:{key:"treasury_wallet_address",label:"Treasury Wallet Address",description:"Solana wallet address where funds are sent. Used for privacy cash withdrawals, micro payment batches, and direct payments.",inputType:"text",placeholder:"e.g., 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU"},withdrawal_poll_interval_secs:{key:"withdrawal_poll_interval_secs",label:"Worker Poll Interval",description:"How often the withdrawal worker checks for deposits ready to process. Lower values process faster but increase server load.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"}],warningThreshold:{below:60,message:"Polling more than once per minute may cause excessive load."}},withdrawal_batch_size:{key:"withdrawal_batch_size",label:"Batch Size",description:"Maximum number of withdrawals to process in a single batch. Higher values improve throughput but may cause timeouts.",inputType:"select",min:1,max:100,presets:[{label:"1 (Sequential)",value:"1"},{label:"5",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100 (Max)",value:"100"}]},withdrawal_timeout_secs:{key:"withdrawal_timeout_secs",label:"Transaction Timeout",description:"How long to wait for a withdrawal transaction to confirm before considering it failed.",inputType:"duration",min:30,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"2 minutes",value:"120"},{label:"5 minutes",value:"300"}],warningThreshold:{below:30,message:"Very short timeouts may cause premature failure on slow networks."}},withdrawal_max_retries:{key:"withdrawal_max_retries",label:"Max Retries",description:"Number of times to retry a failed withdrawal before marking it as permanently failed.",inputType:"select",min:0,max:10,presets:[{label:"0 (No retries)",value:"0"},{label:"1",value:"1"},{label:"3 (Recommended)",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},withdrawal_percentage:{key:"withdrawal_percentage",label:"Withdrawal Percentage",description:"Percentage of ready funds to withdraw each cycle. Lower values spread withdrawals over time for better privacy.",inputType:"percentage",min:1,max:100,step:5,presets:[{label:"25%",value:"25"},{label:"50%",value:"50"},{label:"75%",value:"75"},{label:"100% (All at once)",value:"100"}],warningThreshold:{above:75,message:"High percentages may reduce timing privacy by processing most withdrawals together."}},partial_withdrawal_count:{key:"partial_withdrawal_count",label:"Partial Withdrawals",description:"Maximum partial withdrawals per batch. Partial withdrawals add noise to timing analysis. Set to 0 to disable.",inputType:"select",min:0,presets:[{label:"Disabled",value:"0"},{label:"1",value:"1"},{label:"3",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},partial_withdrawal_min_lamports:{key:"partial_withdrawal_min_lamports",label:"Min Balance for Partial",description:"Minimum account balance (in lamports) required before partial withdrawals are considered. 1 SOL = 1,000,000,000 lamports.",inputType:"select",min:0,presets:[{label:"0.1 SOL",value:"100000000"},{label:"0.5 SOL",value:"500000000"},{label:"1 SOL",value:"1000000000"},{label:"5 SOL",value:"5000000000"},{label:"10 SOL",value:"10000000000"}]},rate_limit_auth:{key:"rate_limit_auth",label:"Auth Request Limit",description:"Maximum authentication attempts (login, register, password reset) per IP per window. Protects against brute force attacks.",inputType:"select",min:1,unit:"requests",presets:[{label:"5 (Strict)",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"20",value:"20"},{label:"50 (Permissive)",value:"50"}],warningThreshold:{above:20,message:"High auth limits may allow brute force attempts."}},rate_limit_general:{key:"rate_limit_general",label:"General Request Limit",description:"Maximum general API requests per IP per window. Affects all non-auth endpoints.",inputType:"select",min:1,unit:"requests",presets:[{label:"30",value:"30"},{label:"60 (Recommended)",value:"60"},{label:"120",value:"120"},{label:"300",value:"300"}]},rate_limit_credit:{key:"rate_limit_credit",label:"Credit Request Limit",description:"Maximum credit/balance check requests per IP per window. Higher for apps that poll balance frequently.",inputType:"select",min:1,unit:"requests",presets:[{label:"10",value:"10"},{label:"30 (Recommended)",value:"30"},{label:"60",value:"60"},{label:"120",value:"120"}]},rate_limit_window:{key:"rate_limit_window",label:"Rate Limit Window",description:'Time window for rate limiting. All limits above are "per window". Shorter windows are stricter.',inputType:"duration",min:1,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"}]},solana_rpc_url:{key:"solana_rpc_url",label:"Solana RPC URL",description:'Get a fast RPC endpoint from <a href="https://helius.dev" target="_blank" rel="noopener">Helius</a> or <a href="https://quicknode.com" target="_blank" rel="noopener">QuickNode</a>.',inputType:"text",placeholder:"https://api.mainnet-beta.solana.com"},solana_network:{key:"solana_network",label:"Solana Network",description:"The Solana network to use for deposits and withdrawals.",inputType:"select",presets:[{label:"Mainnet",value:"mainnet-beta"},{label:"Devnet",value:"devnet"}]},deposit_privacy_enabled:{key:"deposit_privacy_enabled",label:"Enable Private Deposits",description:"When enabled, deposits are held for a privacy period before withdrawal. Provides timing privacy but delays fund availability.",inputType:"boolean"},deposit_company_token:{key:"deposit_company_token",label:"Platform Token",description:"The token that represents platform credits. Deposits are converted to this token. Common choices: USDC, SOL.",inputType:"select",presets:[{label:"USDC",value:"USDC"},{label:"USDT",value:"USDT"},{label:"SOL",value:"SOL"},{label:"EURC",value:"EURC"}]},deposit_micro_enabled:{key:"deposit_micro_enabled",label:"SOL Micro Payments",description:"Allow small SOL deposits (under $10) that are batched together for efficiency.",inputType:"boolean"},deposit_gasless_swap_enabled:{key:"deposit_gasless_swap_enabled",label:"Gasless Swap Payments",description:"Allow deposits via Jupiter swaps.",inputType:"boolean"},deposit_min_usd:{key:"deposit_min_usd",label:"Minimum Deposit",description:"Minimum deposit amount in USD equivalent.",inputType:"select",unit:"USD",presets:[{label:"$1",value:"1"},{label:"$5",value:"5"},{label:"$10",value:"10"},{label:"$25",value:"25"}]},deposit_max_usd:{key:"deposit_max_usd",label:"Maximum Deposit",description:"Maximum deposit amount per transaction in USD equivalent. Set to 0 for unlimited.",inputType:"select",unit:"USD",presets:[{label:"Unlimited",value:"0"},{label:"$1,000",value:"1000"},{label:"$10,000",value:"10000"},{label:"$100,000",value:"100000"}]},deposit_show_explainer:{key:"deposit_show_explainer",label:"Show Explainer Screen",description:"Show the introductory explainer screen at the start of the deposit flow.",inputType:"boolean"},deposit_quick_action_tokens:{key:"deposit_quick_action_tokens",label:"Quick Action Tokens",description:"Comma-separated token symbols shown as quick action buttons. First token is the default.",inputType:"tokenSymbolList"},deposit_custom_tokens:{key:"deposit_custom_tokens",label:"Custom Dropdown Tokens",description:'Comma-separated token symbols shown in the "Custom" dropdown. Leave empty to show all.',inputType:"tokenSymbolList"},deposit_custom_tokens_json:{key:"deposit_custom_tokens_json",label:"Custom Token Definitions",description:"Add tokens beyond the built-in list. Define symbol, mint address, decimals, and logo URL.",inputType:"tokenList"},deposit_fee_policy:{key:"deposit_fee_policy",label:"Fee Policy",description:"Who pays deposit fees: company absorbs all, or user pays swap/privacy/all fees.",inputType:"select",presets:[{label:"Company Pays All",value:"company_pays_all"},{label:"User Pays Swap Fees",value:"user_pays_swap"},{label:"User Pays Privacy Fees",value:"user_pays_privacy"},{label:"User Pays All Fees",value:"user_pays_all"}]},privacy_fee_fixed_lamports:{key:"privacy_fee_fixed_lamports",label:"Privacy Fixed Fee",description:"Fixed fee for Privacy Cash deposits in lamports. 1 SOL = 1,000,000,000 lamports.",inputType:"select",unit:"lamports",presets:[{label:"0 SOL",value:"0"},{label:"0.001 SOL",value:"1000000"},{label:"0.005 SOL",value:"5000000"},{label:"0.006 SOL (Default)",value:"6000000"},{label:"0.01 SOL",value:"10000000"}]},privacy_fee_percent_bps:{key:"privacy_fee_percent_bps",label:"Privacy Percentage Fee",description:"Percentage fee for Privacy Cash deposits in basis points. 100 bps = 1%.",inputType:"select",unit:"bps",presets:[{label:"0%",value:"0"},{label:"0.25%",value:"25"},{label:"0.35% (Default)",value:"35"},{label:"0.5%",value:"50"},{label:"1%",value:"100"}]},swap_fee_fixed_lamports:{key:"swap_fee_fixed_lamports",label:"Swap Fixed Fee",description:"Fixed fee for Jupiter swaps in lamports. Covers transaction costs.",inputType:"select",unit:"lamports",presets:[{label:"0 SOL",value:"0"},{label:"0.001 SOL (Default)",value:"1000000"},{label:"0.002 SOL",value:"2000000"},{label:"0.005 SOL",value:"5000000"}]},swap_fee_percent_bps:{key:"swap_fee_percent_bps",label:"Swap Percentage Fee",description:"Percentage fee for Jupiter swaps in basis points. 100 bps = 1%.",inputType:"select",unit:"bps",presets:[{label:"0%",value:"0"},{label:"0.1% (Default)",value:"10"},{label:"0.25%",value:"25"},{label:"0.5%",value:"50"}]},company_fee_fixed_lamports:{key:"company_fee_fixed_lamports",label:"Company Fixed Fee",description:"Additional fixed processing fee in lamports. Set to 0 to disable.",inputType:"select",unit:"lamports",presets:[{label:"Disabled",value:"0"},{label:"0.001 SOL",value:"1000000"},{label:"0.005 SOL",value:"5000000"},{label:"0.01 SOL",value:"10000000"}]},company_fee_percent_bps:{key:"company_fee_percent_bps",label:"Company Percentage Fee",description:"Additional percentage processing fee in basis points. 100 bps = 1%.",inputType:"select",unit:"bps",presets:[{label:"Disabled",value:"0"},{label:"0.1%",value:"10"},{label:"0.25%",value:"25"},{label:"0.5%",value:"50"},{label:"1%",value:"100"}]},micro_batch_threshold_usd:{key:"micro_batch_threshold_usd",label:"Batch Threshold",description:"Minimum accumulated USD value before triggering a batch swap. Jupiter requires ~$10 minimum.",inputType:"select",unit:"USD",presets:[{label:"$10 (Minimum)",value:"10"},{label:"$25",value:"25"},{label:"$50",value:"50"},{label:"$100",value:"100"}]},micro_batch_poll_secs:{key:"micro_batch_poll_secs",label:"Batch Poll Interval",description:"How often to check for batchable micro deposits. Lower values process faster but increase load.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes (Default)",value:"300"},{label:"15 minutes",value:"900"},{label:"1 hour",value:"3600"}]},private_deposit_min_lamports:{key:"private_deposit_min_lamports",label:"Min Private Deposit",description:"Minimum amount for Privacy Cash deposits in lamports. Smaller deposits use micro batching.",inputType:"select",unit:"lamports",presets:[{label:"0.1 SOL",value:"100000000"},{label:"0.25 SOL (Default)",value:"250000000"},{label:"0.5 SOL",value:"500000000"},{label:"1 SOL",value:"1000000000"}]},withdrawal_min_lamports:{key:"withdrawal_min_lamports",label:"Min Withdrawal Amount",description:"Minimum amount to withdraw in lamports. Deposits below this remain pending. Fees are ~0.006 SOL + 0.35% + Jupiter.",inputType:"select",unit:"lamports",presets:[{label:"0.5 SOL",value:"500000000"},{label:"1 SOL (Default)",value:"1000000000"},{label:"2 SOL",value:"2000000000"},{label:"5 SOL",value:"5000000000"}],warningThreshold:{below:5e8,message:"Very small withdrawals may lose significant value to fees."}}},Br=["SOL","USDC","USDT","EURC","USD1","PYUSD","USDH","CASH","BONK","ORE"];function be({settings:s,edits:t,onChange:r,externalWarnings:a}){return e.jsx("div",{className:"cedros-settings-grid",children:s.map(n=>e.jsx(bo,{setting:n,editValue:t[n.key],onChange:r,externalWarning:a?.[n.key]},n.key))})}function bo({setting:s,editValue:t,onChange:r,externalWarning:a}){const n=go[s.key],o=t??s.value,c=t!==void 0&&t!==s.value,l=n?.inputType==="boolean",d=i.useMemo(()=>{if(a)return a;if(!n?.warningThreshold)return null;const u=parseInt(o,10);if(isNaN(u))return null;const{above:f,below:m,message:h}=n.warningThreshold;return f!==void 0&&u>f||m!==void 0&&u<m?h:null},[o,n?.warningThreshold,a]);return n?e.jsx("div",{className:`cedros-setting-row ${c?"cedros-setting-row-changed":""} ${d?"cedros-setting-row-warning":""} ${l?"cedros-setting-row-toggle":""}`,children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-setting-control cedros-setting-control-toggle",children:[e.jsx(ft,{meta:n,value:o,onChange:u=>r(s.key,u)}),d&&e.jsx("div",{className:"cedros-setting-warning",children:d})]}),e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:n.label}),e.jsx("span",{className:"cedros-setting-description",dangerouslySetInnerHTML:{__html:n.description}})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:n.label}),e.jsx("span",{className:"cedros-setting-description",dangerouslySetInnerHTML:{__html:n.description}})]}),e.jsxs("div",{className:"cedros-setting-control",children:[e.jsx(ft,{meta:n,value:o,onChange:u=>r(s.key,u)}),d&&e.jsx("div",{className:"cedros-setting-warning",children:d})]})]})}):e.jsxs("div",{className:`cedros-setting-row ${c?"cedros-setting-row-changed":""}`,children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:s.key}),s.description&&e.jsx("span",{className:"cedros-setting-description",children:s.description})]}),e.jsx("div",{className:"cedros-setting-input-wrapper",children:e.jsx("input",{type:"text",value:o,onChange:u=>r(s.key,u.target.value),className:"cedros-setting-input"})})]})}function ft({meta:s,value:t,onChange:r}){switch(s.inputType){case"duration":return e.jsx(yo,{value:t,onChange:r,presets:s.presets,min:s.min});case"percentage":return e.jsx(wo,{value:t,onChange:r,min:s.min??1,max:s.max??100,step:s.step??5,presets:s.presets});case"select":return e.jsx(xo,{value:t,onChange:r,presets:s.presets??[],unit:s.unit});case"number":return e.jsx(vo,{value:t,onChange:r,min:s.min,max:s.max,unit:s.unit});case"tokenList":return e.jsx(ko,{value:t,onChange:r});case"text":return e.jsx("input",{type:"text",value:t,onChange:a=>r(a.target.value),className:"cedros-setting-input",placeholder:s.label});case"boolean":return e.jsx(jo,{value:t,onChange:r});case"secret":return e.jsx(Ao,{value:t,onChange:r,multiline:s.multiline});case"tokenSymbolList":return e.jsx(No,{value:t,onChange:r});default:return e.jsx("input",{type:"text",value:t,onChange:a=>r(a.target.value),className:"cedros-setting-input"})}}function yo({value:s,onChange:t,presets:r,min:a=0}){const n=parseInt(s,10)||0,o=fo(n),c=i.useCallback(d=>{d.target.value&&t(d.target.value)},[t]),l=i.useCallback(d=>{const u=Math.max(a,parseInt(d.target.value,10)||0);t(String(u))},[t,a]);return e.jsxs("div",{className:"cedros-duration-input",children:[r&&r.length>0&&e.jsxs("select",{value:r.find(d=>d.value===s)?.value??"",onChange:c,className:"cedros-setting-select",children:[e.jsx("option",{value:"",children:"Custom..."}),r.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))]}),e.jsxs("div",{className:"cedros-duration-custom",children:[e.jsx("input",{type:"number",value:n,onChange:l,min:a,className:"cedros-setting-input cedros-setting-input-sm"}),e.jsx("span",{className:"cedros-setting-unit",children:"seconds"}),e.jsxs("span",{className:"cedros-duration-display",children:["= ",o]})]})]})}function wo({value:s,onChange:t,min:r,max:a,step:n,presets:o}){const c=parseInt(s,10)||r,l=i.useCallback(u=>{t(u.target.value)},[t]),d=i.useCallback(u=>{t(u)},[t]);return e.jsxs("div",{className:"cedros-percentage-input",children:[e.jsxs("div",{className:"cedros-percentage-slider-row",children:[e.jsx("input",{type:"range",value:c,onChange:l,min:r,max:a,step:n,className:"cedros-percentage-slider"}),e.jsxs("span",{className:"cedros-percentage-value",children:[c,"%"]})]}),o&&o.length>0&&e.jsx("div",{className:"cedros-preset-buttons",children:o.map(u=>e.jsx("button",{type:"button",className:`cedros-preset-button ${u.value===s?"cedros-preset-button-active":""}`,onClick:()=>d(u.value),children:u.label},u.value))})]})}function xo({value:s,onChange:t,presets:r,unit:a}){const n=!r.some(l=>l.value===s),o=i.useCallback(l=>{l.target.value!=="__custom__"&&t(l.target.value)},[t]),c=i.useCallback(l=>{t(l.target.value)},[t]);return e.jsxs("div",{className:"cedros-select-input",children:[e.jsxs("select",{value:n?"__custom__":s,onChange:o,className:"cedros-setting-select",children:[r.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value)),e.jsx("option",{value:"__custom__",children:"Custom..."})]}),n&&e.jsxs("div",{className:"cedros-select-custom",children:[e.jsx("input",{type:"number",value:s,onChange:c,className:"cedros-setting-input cedros-setting-input-sm"}),a&&e.jsx("span",{className:"cedros-setting-unit",children:a})]})]})}function vo({value:s,onChange:t,min:r,max:a,unit:n}){const o=i.useCallback(c=>{t(c.target.value)},[t]);return e.jsxs("div",{className:"cedros-number-input",children:[e.jsx("input",{type:"number",value:s,onChange:o,min:r,max:a,className:"cedros-setting-input"}),n&&e.jsx("span",{className:"cedros-setting-unit",children:n})]})}function jo({value:s,onChange:t}){const r=s==="true",a=i.useCallback(()=>{t(r?"false":"true")},[r,t]);return e.jsxs("button",{type:"button",role:"switch","aria-checked":r,className:`cedros-toggle ${r?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:a,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:r?"Enabled":"Disabled"})]})}function Ao({value:s,onChange:t,multiline:r}){const[a,n]=i.useState(!1),[o,c]=i.useState(!1),l=s&&s.length>0,d=i.useCallback(()=>{n(!0),c(!0)},[]),u=i.useCallback(()=>{n(!1),c(!1)},[]),f=i.useCallback(m=>{t(m.target.value)},[t]);return!a&&l?e.jsxs("div",{className:"cedros-secret-input cedros-secret-input-masked",children:[e.jsx("span",{className:"cedros-secret-masked",children:"•".repeat(Math.min(s.length,20))}),e.jsx("button",{type:"button",className:"cedros-secret-edit-btn",onClick:d,children:"Edit"})]}):e.jsxs("div",{className:"cedros-secret-input",children:[r?e.jsx("textarea",{value:s,onChange:f,className:"cedros-setting-input cedros-setting-textarea",placeholder:"Enter secret value...",rows:4}):e.jsx("input",{type:o?"text":"password",value:s,onChange:f,className:"cedros-setting-input",placeholder:"Enter secret value..."}),e.jsxs("div",{className:"cedros-secret-actions",children:[!r&&e.jsx("button",{type:"button",className:"cedros-secret-toggle-btn",onClick:()=>c(!o),children:o?"Hide":"Show"}),a&&e.jsx("button",{type:"button",className:"cedros-secret-done-btn",onClick:u,children:"Done"})]})]})}function ko({value:s,onChange:t}){const r=i.useMemo(()=>{try{return JSON.parse(s||"[]")}catch{return[]}},[s]),a=i.useCallback(l=>{t(JSON.stringify(l))},[t]),n=i.useCallback(()=>{a([...r,{symbol:"",mint:"",decimals:6}])},[r,a]),o=i.useCallback((l,d,u)=>{const f=[...r];f[l]={...f[l],[d]:u},a(f)},[r,a]),c=i.useCallback(l=>{a(r.filter((d,u)=>u!==l))},[r,a]);return e.jsxs("div",{className:"cedros-token-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Built-in tokens:"}),e.jsx("div",{className:"cedros-token-presets-list",children:Br.map(l=>e.jsx("span",{className:"cedros-token-preset-chip",children:l},l))})]}),r.length===0&&e.jsx("p",{className:"cedros-token-list-empty",children:"No custom tokens added. Use the built-in tokens above or add your own."}),r.map((l,d)=>e.jsxs("div",{className:"cedros-token-row",children:[e.jsxs("div",{className:"cedros-token-row-fields",children:[e.jsx("input",{type:"text",placeholder:"Symbol",value:l.symbol,onChange:u=>o(d,"symbol",u.target.value.toUpperCase()),className:"cedros-setting-input cedros-token-input-symbol",maxLength:10}),e.jsx("input",{type:"text",placeholder:"Mint address",value:l.mint,onChange:u=>o(d,"mint",u.target.value),className:"cedros-setting-input cedros-token-input-mint"}),e.jsx("input",{type:"number",placeholder:"Decimals",value:l.decimals,onChange:u=>o(d,"decimals",parseInt(u.target.value,10)||0),className:"cedros-setting-input cedros-token-input-decimals",min:0,max:18}),e.jsx("input",{type:"text",placeholder:"Logo URL (optional)",value:l.logoUrl||"",onChange:u=>o(d,"logoUrl",u.target.value||void 0),className:"cedros-setting-input cedros-token-input-logo"})]}),e.jsx("button",{type:"button",className:"cedros-token-remove-btn",onClick:()=>c(d),title:"Remove token",children:"×"})]},d)),e.jsx("button",{type:"button",className:"cedros-token-add-btn",onClick:n,children:"+ Add Token"})]})}function No({value:s,onChange:t}){const r=i.useMemo(()=>s.split(",").map(o=>o.trim()).filter(Boolean),[s]),a=i.useCallback(o=>{if(!o||r.includes(o))return;const c=[...r,o].join(", ");t(c)},[r,t]),n=i.useCallback(o=>{const c=r.filter(l=>l!==o).join(", ");t(c)},[r,t]);return e.jsxs("div",{className:"cedros-token-symbol-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Click to add:"}),e.jsx("div",{className:"cedros-token-presets-list",children:Br.map(o=>{const c=r.includes(o);return e.jsxs("button",{type:"button",className:`cedros-token-preset-chip ${c?"cedros-token-preset-chip-selected":""}`,onClick:()=>c?n(o):a(o),title:c?`Remove ${o}`:`Add ${o}`,children:[o,c&&e.jsx("span",{className:"cedros-token-chip-check",children:"✓"})]},o)})})]}),e.jsx("input",{type:"text",value:s,onChange:o=>t(o.target.value),className:"cedros-setting-input",placeholder:"USDC, SOL, BONK..."})]})}function Pe({status:s,error:t}){return s==="idle"?null:e.jsxs("div",{className:`cedros-autosave-status cedros-autosave-status--${s}`,children:[s==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-autosave-dot"}),e.jsx("span",{children:"Unsaved changes"})]}),s==="saving"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-autosave-spinner"}),e.jsx("span",{children:"Saving..."})]}),s==="saved"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-autosave-check",children:"✓"}),e.jsx("span",{children:"Saved"})]}),s==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-autosave-error-icon",children:"!"}),e.jsx("span",{children:t||"Save failed"})]})]})}function os({title:s,description:t,categories:r,className:a=""}){const{settings:n,edits:o,isLoading:c,autosaveStatus:l,autosaveError:d,error:u,fetchSettings:f,handleChange:m}=Ee();i.useEffect(()=>{f()},[f]);const h=r.filter(b=>n[b]?.length>0);return c&&Object.keys(n).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${a}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):u?e.jsx("div",{className:`cedros-system-settings ${a}`,children:e.jsx(N.ErrorMessage,{error:u.message})}):e.jsxs("div",{className:`cedros-system-settings ${a}`,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:s}),e.jsx("p",{className:"cedros-settings-page-description",children:t})]}),e.jsx(Pe,{status:l,error:d})]}),h.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsx("p",{children:"No settings found for this section."})}):h.map(b=>e.jsx(be,{settings:n[b],edits:o,onChange:m},b))]})}function So(){const{config:s,_internal:t}=N.useCedrosLogin(),r=s.serverUrl,a=i.useRef(t?.getAccessToken??(()=>null));a.current=t?.getAccessToken??(()=>null);const[n,o]=i.useState([]),[c,l]=i.useState(0),[d,u]=i.useState(!1),[f,m]=i.useState(null),h=i.useCallback(()=>{const y=a.current();return{"Content-Type":"application/json",...y?{Authorization:`Bearer ${y}`}:{}}},[]),b=i.useCallback(async(y,A=50,v=0)=>{u(!0),m(null);try{const S=new URLSearchParams;y&&S.set("org_id",y),S.set("limit",String(A)),S.set("offset",String(v));const w=await fetch(`${r}/admin/sso-providers?${S}`,{headers:h()});if(!w.ok){const T=await w.json().catch(()=>({}));throw new Error(T.error||`Failed to fetch SSO providers: ${w.status}`)}const C=await w.json();return o(C.providers),l(C.total),C}catch(S){const w=S instanceof Error?S:new Error(String(S));throw m(w),w}finally{u(!1)}},[r,h]),g=i.useCallback(async y=>{u(!0),m(null);try{const A=await fetch(`${r}/admin/sso-providers`,{method:"POST",headers:h(),body:JSON.stringify(y)});if(!A.ok){const S=await A.json().catch(()=>({}));throw new Error(S.error||`Failed to create SSO provider: ${A.status}`)}const v=await A.json();return o(S=>[...S,v]),l(S=>S+1),v}catch(A){const v=A instanceof Error?A:new Error(String(A));throw m(v),v}finally{u(!1)}},[r,h]),p=i.useCallback(async(y,A)=>{u(!0),m(null);try{const v=await fetch(`${r}/admin/sso-providers/${y}`,{method:"PUT",headers:h(),body:JSON.stringify(A)});if(!v.ok){const w=await v.json().catch(()=>({}));throw new Error(w.error||`Failed to update SSO provider: ${v.status}`)}const S=await v.json();return o(w=>w.map(C=>C.id===y?S:C)),S}catch(v){const S=v instanceof Error?v:new Error(String(v));throw m(S),S}finally{u(!1)}},[r,h]),x=i.useCallback(async y=>{u(!0),m(null);try{const A=await fetch(`${r}/admin/sso-providers/${y}`,{method:"DELETE",headers:h()});if(!A.ok){const v=await A.json().catch(()=>({}));throw new Error(v.error||`Failed to delete SSO provider: ${A.status}`)}o(v=>v.filter(S=>S.id!==y)),l(v=>v-1)}catch(A){const v=A instanceof Error?A:new Error(String(A));throw m(v),v}finally{u(!1)}},[r,h]),j=i.useCallback(async(y,A)=>p(y,{enabled:A}),[p]);return{providers:n,total:c,isLoading:d,error:f,fetchProviders:b,createProvider:g,updateProvider:p,deleteProvider:x,toggleProvider:j}}class Or{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async listOrgs(){try{return(await this.client.get("/orgs")).orgs.map(r=>({...r,membership:{orgId:r.id,role:r.role}}))}catch(t){throw N.handleApiError(t,"Failed to list organizations")}}async getOrg(t){try{return await this.client.get(`/orgs/${t}`)}catch(r){throw N.handleApiError(r,"Failed to get organization")}}async createOrg(t){try{return await this.client.post("/orgs",t)}catch(r){throw N.handleApiError(r,"Failed to create organization")}}async updateOrg(t,r){try{return await this.client.patch(`/orgs/${t}`,r)}catch(a){throw N.handleApiError(a,"Failed to update organization")}}async deleteOrg(t){try{await this.client.delete(`/orgs/${t}`)}catch(r){throw N.handleApiError(r,"Failed to delete organization")}}async authorize(t){try{return await this.client.post("/authorize",t)}catch(r){throw N.handleApiError(r,"Failed to check authorization")}}async getPermissions(t){try{return await this.client.post("/permissions",{orgId:t})}catch(r){throw N.handleApiError(r,"Failed to get permissions")}}}const ys="cedros_active_org";function Co(s){try{return localStorage.getItem(s)}catch{return null}}function gt(s,t){try{localStorage.setItem(s,t)}catch{}}function is(){const{config:s,user:t,authState:r,_internal:a}=N.useCedrosLogin(),n=typeof window<"u"&&!!window.localStorage,[o,c]=i.useState([]),[l,d]=i.useState(null),[u,f]=i.useState([]),[m,h]=i.useState(null),[b,g]=i.useState(!1),[p,x]=i.useState(null),j=i.useMemo(()=>new Or(s.serverUrl,s.requestTimeout,s.retryAttempts,a?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,a]),y=i.useRef(j);i.useEffect(()=>{y.current=j},[j]);const A=i.useCallback(async E=>{try{const P=await y.current.getPermissions(E);f(P.permissions),h(P.role)}catch{f([]),h(null)}},[]),v=i.useCallback(async()=>{if(r!=="authenticated"||!t){c([]),d(null),f([]),h(null);return}g(!0),x(null);try{const E=await y.current.listOrgs();c(E);const P=n?Co(ys):null;let k=E.find(_=>_.id===P);!k&&E.length>0&&(k=E.find(_=>_.isPersonal)||E[0]),k?(d(k),n&&gt(ys,k.id),await A(k.id)):(d(null),f([]),h(null))}catch(E){x(E)}finally{g(!1)}},[r,t,A,n]),S=i.useCallback(async E=>{const P=o.find(k=>k.id===E);if(!P){x({code:"UNKNOWN_ERROR",message:"Organization not found"});return}d(P),n&&gt(ys,E),await A(E)},[o,A,n]),w=i.useCallback(async E=>{g(!0),x(null);try{const P=await y.current.createOrg(E);return await v(),P}catch(P){throw x(P),P}finally{g(!1)}},[v]),C=i.useCallback(async(E,P)=>{g(!0),x(null);try{const k=await y.current.updateOrg(E,P);return await v(),k}catch(k){throw x(k),k}finally{g(!1)}},[v]),T=i.useCallback(async E=>{g(!0),x(null);try{await y.current.deleteOrg(E),await v()}catch(P){throw x(P),P}finally{g(!1)}},[v]),L=i.useCallback(E=>u.includes(E),[u]);return{orgs:o,activeOrg:l,permissions:u,role:m,isLoading:b,error:p,fetchOrgs:v,switchOrg:S,createOrg:w,updateOrg:C,deleteOrg:T,hasPermission:L}}function _o({className:s}){const{providers:t,isLoading:r,error:a,fetchProviders:n,createProvider:o,updateProvider:c,deleteProvider:l,toggleProvider:d}=So(),{activeOrg:u}=is(),[f,m]=i.useState("list"),[h,b]=i.useState(null),[g,p]=i.useState(null);i.useEffect(()=>{n(u?.id)},[n,u?.id]);const x=()=>{b(null),p(null),m("add")},j=w=>{b(w),p(null),m("edit")},y=()=>{m("list"),b(null),p(null)},A=async w=>{if(confirm(`Delete SSO provider "${w.name}"? This cannot be undone.`))try{await l(w.id)}catch{}},v=async w=>{try{await d(w.id,!w.enabled)}catch{}},S=async w=>{p(null);try{f==="add"?await o(w):h&&await c(h.id,w),m("list"),b(null)}catch(C){p(C instanceof Error?C.message:"Failed to save provider")}};return r&&t.length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading SSO providers..."})]}):f==="add"||f==="edit"?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(Po,{provider:h,orgId:u?.id,error:g,isLoading:r,onSave:S,onCancel:y})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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:"SSO Providers"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure OIDC identity providers for enterprise single sign-on."})]}),e.jsx("button",{type:"button",className:"cedros-btn cedros-btn-primary",onClick:x,children:"Add Provider"})]}),a&&e.jsx(N.ErrorMessage,{error:a.message}),t.length===0?e.jsxs("div",{className:"cedros-system-settings-empty",children:[e.jsx("p",{children:"No SSO providers configured."}),e.jsx("p",{className:"cedros-text-muted",children:"Add an OIDC provider like Okta, Azure AD, or Auth0 to enable enterprise SSO."})]}):e.jsx("div",{className:"cedros-sso-provider-list",children:t.map(w=>e.jsx(Eo,{provider:w,onEdit:()=>j(w),onDelete:()=>A(w),onToggle:()=>v(w)},w.id))})]})}function Eo({provider:s,onEdit:t,onDelete:r,onToggle:a}){return e.jsxs("div",{className:`cedros-sso-provider-card ${s.enabled?"":"cedros-sso-provider-card--disabled"}`,children:[e.jsxs("div",{className:"cedros-sso-provider-card-header",children:[e.jsxs("div",{className:"cedros-sso-provider-card-info",children:[e.jsx("h3",{className:"cedros-sso-provider-card-name",children:s.name}),e.jsx("p",{className:"cedros-sso-provider-card-issuer",children:s.issuerUrl})]}),e.jsxs("button",{type:"button",role:"switch","aria-checked":s.enabled,className:`cedros-toggle ${s.enabled?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:a,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:s.enabled?"Enabled":"Disabled"})]})]}),e.jsxs("div",{className:"cedros-sso-provider-card-details",children:[e.jsxs("div",{className:"cedros-sso-provider-card-detail",children:[e.jsx("span",{className:"cedros-sso-provider-card-detail-label",children:"Client ID"}),e.jsx("code",{className:"cedros-sso-provider-card-detail-value",children:s.clientId})]}),s.emailDomain&&e.jsxs("div",{className:"cedros-sso-provider-card-detail",children:[e.jsx("span",{className:"cedros-sso-provider-card-detail-label",children:"Email Domain"}),e.jsxs("span",{className:"cedros-sso-provider-card-detail-value",children:["@",s.emailDomain]})]}),e.jsxs("div",{className:"cedros-sso-provider-card-detail",children:[e.jsx("span",{className:"cedros-sso-provider-card-detail-label",children:"Registration"}),e.jsx("span",{className:"cedros-sso-provider-card-detail-value",children:s.allowRegistration?"Allowed":"Existing users only"})]})]}),e.jsxs("div",{className:"cedros-sso-provider-card-actions",children:[e.jsx("button",{type:"button",className:"cedros-btn cedros-btn-ghost",onClick:t,children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-btn cedros-btn-ghost cedros-btn-danger",onClick:r,children:"Delete"})]})]})}function Po({provider:s,orgId:t,error:r,isLoading:a,onSave:n,onCancel:o}){const c=!!s,[l,d]=i.useState(s?.name??""),[u,f]=i.useState(s?.issuerUrl??""),[m,h]=i.useState(s?.clientId??""),[b,g]=i.useState(""),[p,x]=i.useState(s?.emailDomain??""),[j,y]=i.useState(s?.allowRegistration??!0),[A,v]=i.useState(s?.enabled??!0),S=i.useCallback(w=>{if(w.preventDefault(),c){const C={name:l,issuerUrl:u,clientId:m,emailDomain:p||null,allowRegistration:j,enabled:A};b&&(C.clientSecret=b),n(C)}else{if(!t)return;n({orgId:t,name:l,issuerUrl:u,clientId:m,clientSecret:b,emailDomain:p||null,allowRegistration:j,enabled:A})}},[c,t,l,u,m,b,p,j,A,n]);return e.jsxs("form",{className:"cedros-sso-provider-form",onSubmit:S,children:[e.jsx("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:c?"Edit SSO Provider":"Add SSO Provider"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure an OIDC identity provider for enterprise single sign-on."})]})}),r&&e.jsx(N.ErrorMessage,{error:r}),e.jsxs("div",{className:"cedros-form-section",children:[e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{className:"cedros-form-label",htmlFor:"sso-name",children:"Provider Name"}),e.jsx("input",{id:"sso-name",type:"text",className:"cedros-form-input",value:l,onChange:w=>d(w.target.value),placeholder:"e.g., Okta, Azure AD",required:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{className:"cedros-form-label",htmlFor:"sso-issuer",children:"Issuer URL"}),e.jsx("input",{id:"sso-issuer",type:"url",className:"cedros-form-input",value:u,onChange:w=>f(w.target.value),placeholder:"https://your-org.okta.com",required:!0}),e.jsx("p",{className:"cedros-form-hint",children:"The OIDC issuer URL. Must support discovery at /.well-known/openid-configuration"})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{className:"cedros-form-label",htmlFor:"sso-client-id",children:"Client ID"}),e.jsx("input",{id:"sso-client-id",type:"text",className:"cedros-form-input",value:m,onChange:w=>h(w.target.value),placeholder:"OAuth client ID",required:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsxs("label",{className:"cedros-form-label",htmlFor:"sso-client-secret",children:["Client Secret ",c&&e.jsx("span",{className:"cedros-form-hint-inline",children:"(leave blank to keep current)"})]}),e.jsx("input",{id:"sso-client-secret",type:"password",className:"cedros-form-input",value:b,onChange:w=>g(w.target.value),placeholder:c?"••••••••":"OAuth client secret",required:!c})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{className:"cedros-form-label",htmlFor:"sso-email-domain",children:"Email Domain (optional)"}),e.jsx("input",{id:"sso-email-domain",type:"text",className:"cedros-form-input",value:p,onChange:w=>x(w.target.value),placeholder:"company.com"}),e.jsx("p",{className:"cedros-form-hint",children:"Restrict to users with emails from this domain"})]}),e.jsx("div",{className:"cedros-form-group",children:e.jsxs("label",{className:"cedros-form-checkbox",children:[e.jsx("input",{type:"checkbox",checked:j,onChange:w=>y(w.target.checked)}),e.jsx("span",{children:"Allow new user registration via SSO"})]})}),e.jsx("div",{className:"cedros-form-group",children:e.jsxs("label",{className:"cedros-form-checkbox",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:w=>v(w.target.checked)}),e.jsx("span",{children:"Enable this provider"})]})})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-btn cedros-btn-ghost",onClick:o,disabled:a,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-btn cedros-btn-primary",disabled:a,children:a?"Saving...":c?"Save Changes":"Add Provider"})]})]})}const bt=[{id:"email",label:"Email",categories:["auth.email"]},{id:"google",label:"Google",categories:["auth.google"]},{id:"apple",label:"Apple",categories:["auth.apple"]},{id:"solana",label:"Solana",categories:["auth.solana"]},{id:"passkeys",label:"Passkeys",categories:["auth.webauthn"]},{id:"instantlink",label:"Instant Link",categories:["auth.instantlink"]},{id:"sso",label:"SSO Providers",categories:[],isCustom:!0}];function qr({className:s}){const{settings:t,edits:r,isLoading:a,autosaveStatus:n,autosaveError:o,error:c,fetchSettings:l,handleChange:d}=Ee(),[u,f]=i.useState("email");i.useEffect(()=>{l()},[l]);const m=bt.find(g=>g.id===u),h=i.useMemo(()=>{if(!m)return[];const g=[];for(const p of m.categories){const x=t[p]??[];g.push(...x)}return g},[t,m]),b=i.useMemo(()=>m?.keys?h.filter(g=>m.keys.includes(g.key)).sort((g,p)=>m.keys.indexOf(g.key)-m.keys.indexOf(p.key)):h,[h,m]);return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(N.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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:"Authentication"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure authentication providers and methods for user sign-in."})]}),e.jsx(Pe,{status:n,error:o})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:bt.map(g=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${u===g.id?"cedros-admin-tab-active":""}`,onClick:()=>f(g.id),"aria-selected":u===g.id,role:"tab",children:g.label},g.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:m?.isCustom?e.jsx(_o,{}):b.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",m?.label??"this provider","."]})}):e.jsx(be,{settings:b,edits:r,onChange:d})})]})}const ws=["wallet_recovery_mode"];function Wr({className:s}){const{settings:t,edits:r,isLoading:a,autosaveStatus:n,autosaveError:o,error:c,fetchSettings:l,handleChange:d,getEffectiveValue:u}=Ee();i.useEffect(()=>{l()},[l]);const m=(t.features??[]).filter(g=>ws.includes(g.key)).sort((g,p)=>ws.indexOf(g.key)-ws.indexOf(p.key)),h=u("feature_wallet_signing")==="true",b=()=>{d("feature_wallet_signing",h?"false":"true")};return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(N.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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:"Embedded Wallet"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure the embedded wallet for transaction signing."})]}),e.jsxs("div",{className:"cedros-settings-page-header-actions",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":h,className:`cedros-toggle ${h?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:b,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:h?"Enabled":"Disabled"})]}),e.jsx(Pe,{status:n,error:o})]})]}),e.jsx("div",{className:"cedros-admin-tab-content",children:m.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsx("p",{children:"No additional settings available."})}):e.jsx(be,{settings:m,edits:r,onChange:d})})]})}const To=["security","rate_limit"];function Lo({className:s}){return e.jsx(os,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:To,className:s})}const Mo=["email"];function Do({className:s}){return e.jsx(os,{title:"Email & SMTP",description:"Configure outbound email delivery for verification, password reset, and notifications.",categories:Mo,className:s})}const Ro=["webhook"];function Io({className:s}){return e.jsx(os,{title:"Webhooks",description:"Configure HTTP webhook notifications for authentication events.",categories:Ro,className:s})}const yt=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}],Uo={mailgun:"smtp.mailgun.org",sendgrid:"smtp.sendgrid.net",postmark:"smtp.postmarkapp.com",ses:"email-smtp.us-east-1.amazonaws.com",resend:"smtp.resend.com"},Fo=["email_provider","email_smtp_password","email_from_address","email_from_name"],Bo=["email_provider","email_smtp_host","email_smtp_port","email_smtp_user","email_smtp_password","email_smtp_tls","email_from_address","email_from_name"];function Oo({className:s}){const{settings:t,edits:r,isLoading:a,autosaveStatus:n,autosaveError:o,error:c,fetchSettings:l,handleChange:d,getEffectiveValue:u}=Ee(),[f,m]=i.useState("email");i.useEffect(()=>{l()},[l]);const h=yt.find(y=>y.id===f),b=h?.category??"",p=(u("email_provider")||"custom")==="custom",x=i.useMemo(()=>{const y=t[b]??[];if(f!=="email")return y;const A=p?Bo:Fo;return y.filter(v=>A.includes(v.key)).sort((v,S)=>A.indexOf(v.key)-A.indexOf(S.key))},[t,b,f,p]),j=(y,A)=>{if(d(y,A),y==="email_provider"&&A!=="custom"){const v=Uo[A];v&&(d("email_smtp_host",v),d("email_smtp_port","587"),d("email_smtp_tls","true"))}};return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(N.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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 and webhook notifications."})]}),e.jsx(Pe,{status:n,error:o})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:yt.map(y=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${f===y.id?"cedros-admin-tab-active":""}`,onClick:()=>m(y.id),"aria-selected":f===y.id,role:"tab",children:y.label},y.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:x.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",h?.label??"this section","."]})}):e.jsx(be,{settings:x,edits:r,onChange:f==="email"?j:d})})]})}const wt=[{id:"deposits",label:"Deposits",categories:["deposit.general"],includeKeys:["deposit_company_token","deposit_max_usd","deposit_min_usd","deposit_micro_enabled","deposit_gasless_swap_enabled","solana_rpc_url","jupiter_api_key"]},{id:"tokens",label:"Component",categories:["deposit"],includeKeys:["deposit_show_explainer","deposit_quick_action_tokens","deposit_custom_tokens","deposit_custom_tokens_json"]},{id:"fees",label:"Fees",categories:["deposit"],includeKeys:["deposit_fee_policy","privacy_fee_fixed_lamports","privacy_fee_percent_bps","swap_fee_fixed_lamports","swap_fee_percent_bps","company_fee_fixed_lamports","company_fee_percent_bps","private_deposit_min_lamports"]},{id:"privacy",label:"Privacy",categories:["deposit.general","privacy","withdrawal"],includeKeys:["deposit_privacy_enabled","privacy_period_secs","withdrawal_percentage","withdrawal_min_lamports","partial_withdrawal_count","partial_withdrawal_min_lamports"],sections:[{title:"Privacy Pool Worker",description:"Background worker for processing withdrawals from the privacy cash pool.",keys:["withdrawal_poll_interval_secs","withdrawal_batch_size"]}]},{id:"treasury",label:"Treasury",categories:["withdrawal","deposit"],includeKeys:["treasury_wallet_address"],sections:[{title:"Micropayment Batch Worker",description:"Background worker for batching small SOL deposits together.",keys:["micro_batch_threshold_usd","micro_batch_poll_secs"]}]}];function $r({className:s}){const{settings:t,edits:r,isLoading:a,autosaveStatus:n,autosaveError:o,error:c,fetchSettings:l,handleChange:d,getEffectiveValue:u}=Ee(),[f,m]=i.useState("deposits");i.useEffect(()=>{l()},[l]);const h=wt.find(v=>v.id===f),b=i.useMemo(()=>{if(!h)return[];const v=[];for(const S of h.categories){const w=t[S]??[];v.push(...w)}return v},[t,h]),g=u("deposit_fee_policy")||"company_pays_all",p=i.useMemo(()=>{if(!h)return[];let v=b;if(h.includeKeys&&h.includeKeys.length>0?(v=v.filter(S=>h.includeKeys.includes(S.key)),v.sort((S,w)=>h.includeKeys.indexOf(S.key)-h.includeKeys.indexOf(w.key))):h.excludeKeys&&h.excludeKeys.length>0&&(v=v.filter(S=>!h.excludeKeys.includes(S.key))),h.id==="deposits"&&(parseFloat(u("deposit_min_usd"))||0)>10&&(v=v.filter(w=>w.key!=="deposit_micro_enabled")),h.id==="fees"){const S=["privacy_fee_fixed_lamports","privacy_fee_percent_bps","private_deposit_min_lamports"],w=["swap_fee_fixed_lamports","swap_fee_percent_bps"],C=["company_fee_fixed_lamports","company_fee_percent_bps"];v=v.filter(T=>T.key==="deposit_fee_policy"?!0:g==="company_pays_all"?!1:S.includes(T.key)?g==="user_pays_privacy"||g==="user_pays_all":w.includes(T.key)?g==="user_pays_swap"||g==="user_pays_all":C.includes(T.key)?g==="user_pays_all":!0)}return v},[b,h,u,g]),x=i.useCallback(v=>b.filter(S=>v.includes(S.key)).sort((S,w)=>v.indexOf(S.key)-v.indexOf(w.key)),[b]),j=i.useMemo(()=>{if(h?.id!=="deposits")return;const v={},S=parseFloat(u("deposit_min_usd"))||0,w=u("deposit_micro_enabled");return(w==="false"||w==="0"||w==="")&&S<10&&(v.deposit_min_usd="SOL micro payments must be enabled for minimum deposits under $10."),Object.keys(v).length>0?v:void 0},[h?.id,u]),y=u("feature_credits")==="true",A=()=>{d("feature_credits",y?"false":"true")};return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(N.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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:"Credit System"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure credit deposits, timed withdrawals, and privacy period settings."})]}),e.jsxs("div",{className:"cedros-settings-page-header-actions",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":y,className:`cedros-toggle ${y?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:A,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:y?"Enabled":"Disabled"})]}),e.jsx(Pe,{status:n,error:o})]})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:wt.map(v=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${f===v.id?"cedros-admin-tab-active":""}`,onClick:()=>m(v.id),"aria-selected":f===v.id,role:"tab",children:v.label},v.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:p.length===0&&!h?.sections?.length?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",h?.label??"this section","."]})}):e.jsxs(e.Fragment,{children:[p.length>0&&e.jsx(be,{settings:p,edits:r,onChange:d,externalWarnings:j}),h?.sections?.map(v=>{const S=x(v.keys);return S.length===0?null:e.jsxs("div",{className:"cedros-settings-subsection",children:[e.jsxs("div",{className:"cedros-settings-subsection-header",children:[e.jsx("h4",{className:"cedros-settings-subsection-title",children:v.title}),v.description&&e.jsx("p",{className:"cedros-settings-subsection-description",children:v.description})]}),e.jsx(be,{settings:S,edits:r,onChange:d})]},v.title)})]})})]})}const xt=[{id:"general",label:"Integrations",keys:["server_cedros_pay_api_key"]},{id:"logging",label:"Logging",keys:["server_log_level"]},{id:"metrics",label:"Metrics",keys:["server_metrics_api_key"]},{id:"security",label:"Security",categories:["security","features"],keys:["feature_mfa","security_cors_origins","security_session_timeout"]}];function zr({className:s}){const{settings:t,edits:r,isLoading:a,autosaveStatus:n,autosaveError:o,error:c,fetchSettings:l,handleChange:d}=Ee(),[u,f]=i.useState("general");i.useEffect(()=>{l()},[l]);const m=xt.find(b=>b.id===u),h=i.useMemo(()=>{if(!m)return[];const b=m.categories??["server"],g=[];for(const p of b){const x=t[p]??[];g.push(...x)}return g.filter(p=>m.keys.includes(p.key)).sort((p,x)=>m.keys.indexOf(p.key)-m.keys.indexOf(x.key))},[t,m]);return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(N.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,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 Server"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Server infrastructure settings. Some may be overridden by environment variables."})]}),e.jsx(Pe,{status:n,error:o})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:xt.map(b=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${u===b.id?"cedros-admin-tab-active":""}`,onClick:()=>f(b.id),"aria-selected":u===b.id,role:"tab",children:b.label},b.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:h.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",m?.label??"this section","."]})}):e.jsx(be,{settings:h,edits:r,onChange:d})})]})}class qo{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async listMembers(t,r=50,a=0){try{const n=await this.client.get(`/orgs/${t}/members?limit=${r}&offset=${a}`);return{members:n.members.map(o=>({id:o.id,userId:o.userId,orgId:t,role:o.role,joinedAt:o.joinedAt,user:{id:o.userId,email:o.email,name:o.name}})),total:n.total}}catch(n){throw N.handleApiError(n,"Failed to list members")}}async updateMemberRole(t,r,a){try{return await this.client.patch(`/orgs/${t}/members/${r}`,a)}catch(n){throw N.handleApiError(n,"Failed to update member role")}}async removeMember(t,r){try{await this.client.delete(`/orgs/${t}/members/${r}`)}catch(a){throw N.handleApiError(a,"Failed to remove member")}}}function Vr(s){const{config:t,authState:r,_internal:a}=N.useCedrosLogin(),[n,o]=i.useState([]),[c,l]=i.useState(0),[d,u]=i.useState(!1),[f,m]=i.useState(null),h=i.useRef(void 0),b=i.useRef(0),g=i.useMemo(()=>new qo(t.serverUrl,t.requestTimeout,t.retryAttempts,a?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,a]),p=i.useRef(g);p.current=g;const x=i.useCallback(async A=>{if(!s||r!=="authenticated"){o([]),l(0);return}u(!0),m(null);const v=++b.current;try{const{limit:S=50,offset:w=0}=A??{},C=await p.current.listMembers(s,S,w);if(v!==b.current)return;o(C.members),l(C.total)}catch(S){if(v!==b.current)return;m(S)}finally{v===b.current&&u(!1)}},[s,r]);i.useEffect(()=>{if(r!=="authenticated"){h.current=void 0;return}s!==h.current&&(h.current=s,x())},[s,r,x]);const j=i.useCallback(async(A,v)=>{if(!s)throw new Error("No organization selected");u(!0),m(null);try{await p.current.updateMemberRole(s,A,{role:v}),await x()}catch(S){throw m(S),S}finally{u(!1)}},[s,x]),y=i.useCallback(async A=>{if(!s)throw new Error("No organization selected");u(!0),m(null);try{await p.current.removeMember(s,A),await x()}catch(v){throw m(v),v}finally{u(!1)}},[s,x]);return{members:n,total:c,isLoading:d,error:f,fetchMembers:x,updateMemberRole:j,removeMember:y}}class Wo{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async listInvites(t,r=50,a=0){try{const n=await this.client.get(`/orgs/${t}/invites?limit=${r}&offset=${a}`);return{invites:n.invites.map(o=>({id:o.id,orgId:o.orgId,email:o.email,role:o.role,invitedBy:o.invitedBy,createdAt:o.createdAt,expiresAt:o.expiresAt})),total:n.total}}catch(n){throw N.handleApiError(n,"Failed to list invites")}}async createInvite(t,r){try{return await this.client.post(`/orgs/${t}/invites`,r)}catch(a){throw N.handleApiError(a,"Failed to create invite")}}async cancelInvite(t,r){try{await this.client.delete(`/orgs/${t}/invites/${r}`)}catch(a){throw N.handleApiError(a,"Failed to cancel invite")}}async resendInvite(t,r){try{await this.client.post(`/orgs/${t}/invites/${r}/resend`,{})}catch(a){throw N.handleApiError(a,"Failed to resend invite")}}async acceptInvite(t){try{return await this.client.post("/invites/accept",t)}catch(r){throw N.handleApiError(r,"Failed to accept invite")}}}function Hr(s){const{config:t,authState:r,_internal:a}=N.useCedrosLogin(),[n,o]=i.useState([]),[c,l]=i.useState(0),[d,u]=i.useState(!1),[f,m]=i.useState(null),h=i.useRef(void 0),b=i.useRef(0),g=i.useMemo(()=>new Wo(t.serverUrl,t.requestTimeout,t.retryAttempts,a?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,a]),p=i.useRef(g);p.current=g;const x=i.useCallback(async S=>{if(!s||r!=="authenticated"){o([]),l(0);return}u(!0),m(null);const w=++b.current;try{const{limit:C=50,offset:T=0}=S??{},L=await p.current.listInvites(s,C,T);if(w!==b.current)return;o(L.invites),l(L.total)}catch(C){if(w!==b.current)return;m(C)}finally{w===b.current&&u(!1)}},[s,r]);i.useEffect(()=>{if(r!=="authenticated"){h.current=void 0;return}s!==h.current&&(h.current=s,x())},[s,r,x]);const j=i.useCallback(async(S,w="member")=>{if(!s)throw new Error("No organization selected");u(!0),m(null);try{await p.current.createInvite(s,{email:S,role:w}),await x()}catch(C){throw m(C),C}finally{u(!1)}},[s,x]),y=i.useCallback(async S=>{if(!s)throw new Error("No organization selected");u(!0),m(null);try{await p.current.cancelInvite(s,S),await x()}catch(w){throw m(w),w}finally{u(!1)}},[s,x]),A=i.useCallback(async S=>{if(!s)throw new Error("No organization selected");u(!0),m(null);try{await p.current.resendInvite(s,S)}catch(w){throw m(w),w}finally{u(!1)}},[s]),v=i.useCallback(async S=>{u(!0),m(null);try{return await p.current.acceptInvite({token:S})}catch(w){throw m(w),w}finally{u(!1)}},[]);return{invites:n,total:c,isLoading:d,error:f,fetchInvites:x,createInvite:j,cancelInvite:y,resendInvite:A,acceptInvite:v}}const $o={organizations:!1,sso:!1,mfa:!1,walletSigning:!1,credits:!1,cedrosPay:!1};function Js(){const{settings:s,isLoading:t,error:r,fetchSettings:a,getValue:n}=Ue(),[o,c]=i.useState(!1);i.useEffect(()=>{o||(a(),c(!0))},[a,o]);const l=i.useCallback(m=>m===void 0?!1:m==="true"||m==="1",[]),d=i.useMemo(()=>Object.keys(s).length===0?$o:{organizations:l(n("feature_organizations")),sso:l(n("feature_sso")),mfa:l(n("feature_mfa")),walletSigning:l(n("feature_wallet_signing")),credits:l(n("feature_credits")),cedrosPay:l(n("feature_cedros_pay"))},[s,n,l]),u=i.useCallback(async()=>{await a()},[a]),f=i.useCallback(m=>d[m],[d]);return{features:d,isLoading:t,error:r,refetch:u,isEnabled:f}}class zo{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async listUsers(t){try{const r=new URLSearchParams;t?.limit&&r.set("limit",String(t.limit)),t?.offset&&r.set("offset",String(t.offset));const a=r.toString(),n=`/admin/users${a?`?${a}`:""}`;return await this.client.get(n)}catch(r){throw N.handleApiError(r,"Failed to list users")}}async getUser(t){try{return await this.client.get(`/admin/users/${t}`)}catch(r){throw N.handleApiError(r,"Failed to get user")}}async setSystemAdmin(t,r){try{await this.client.patch(`/admin/users/${t}/system-admin`,{isAdmin:r})}catch(a){throw N.handleApiError(a,"Failed to update system admin status")}}async updateUser(t,r){try{return await this.client.patch(`/admin/users/${t}`,r)}catch(a){throw N.handleApiError(a,"Failed to update user")}}async deleteUser(t){try{await this.client.delete(`/admin/users/${t}`)}catch(r){throw N.handleApiError(r,"Failed to delete user")}}async forcePasswordReset(t){try{await this.client.post(`/admin/users/${t}/force-password-reset`,{})}catch(r){throw N.handleApiError(r,"Failed to send password reset email")}}async adjustCredits(t,r){try{await this.client.post(`/admin/users/${t}/credits`,r)}catch(a){throw N.handleApiError(a,"Failed to adjust credits")}}async getUserDeposits(t,r){try{const a=new URLSearchParams;r?.limit&&a.set("limit",String(r.limit)),r?.offset&&a.set("offset",String(r.offset));const n=a.toString(),o=`/admin/users/${t}/deposits${n?`?${n}`:""}`;return await this.client.get(o)}catch(a){throw N.handleApiError(a,"Failed to get user deposits")}}async getUserCredits(t,r){try{const a=new URLSearchParams;r?.limit&&a.set("limit",String(r.limit)),r?.offset&&a.set("offset",String(r.offset));const n=a.toString(),o=`/admin/users/${t}/credits${n?`?${n}`:""}`;return await this.client.get(o)}catch(a){throw N.handleApiError(a,"Failed to get user credits")}}async getUserWithdrawalHistory(t,r){try{const a=new URLSearchParams;r?.limit&&a.set("limit",String(r.limit)),r?.offset&&a.set("offset",String(r.offset));const n=a.toString(),o=`/admin/users/${t}/withdrawal-history${n?`?${n}`:""}`;return await this.client.get(o)}catch(a){throw N.handleApiError(a,"Failed to get user withdrawal history")}}async getUserChats(t,r){try{const a=new URLSearchParams;r?.limit&&a.set("limit",String(r.limit)),r?.offset&&a.set("offset",String(r.offset));const n=a.toString(),o=`/admin/users/${t}/chats${n?`?${n}`:""}`;return await this.client.get(o)}catch(a){throw N.handleApiError(a,"Failed to get user chat history")}}async getStats(){try{return await this.client.get("/admin/users/stats")}catch(t){throw N.handleApiError(t,"Failed to get user stats")}}}function ls(){const{config:s,_internal:t}=N.useCedrosLogin(),[r,a]=i.useState([]),[n,o]=i.useState(0),[c,l]=i.useState(!1),[d,u]=i.useState(null),[f,m]=i.useState({}),h=i.useMemo(()=>new zo(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),b=i.useCallback(async P=>{l(!0),u(null),m(P||{});try{const k=await h.listUsers(P);return a(k.users),o(k.total),k}catch(k){const _=k instanceof Error?k:new Error("Failed to list users");throw u(_),_}finally{l(!1)}},[h]),g=i.useCallback(async P=>{l(!0),u(null);try{return await h.getUser(P)}catch(k){const _=k instanceof Error?k:new Error("Failed to get user");throw u(_),_}finally{l(!1)}},[h]),p=i.useCallback(async(P,k)=>{l(!0),u(null);try{await h.setSystemAdmin(P,k),a(_=>_.map(M=>M.id===P?{...M,isSystemAdmin:k}:M))}catch(_){const M=_ instanceof Error?_:new Error("Failed to update admin status");throw u(M),M}finally{l(!1)}},[h]),x=i.useCallback(async(P,k)=>{l(!0),u(null);try{const _=await h.updateUser(P,k);return a(M=>M.map(D=>D.id===P?_:D)),_}catch(_){const M=_ instanceof Error?_:new Error("Failed to update user");throw u(M),M}finally{l(!1)}},[h]),j=i.useCallback(async P=>{l(!0),u(null);try{await h.deleteUser(P),a(k=>k.filter(_=>_.id!==P)),o(k=>k-1)}catch(k){const _=k instanceof Error?k:new Error("Failed to delete user");throw u(_),_}finally{l(!1)}},[h]),y=i.useCallback(async P=>{l(!0),u(null);try{await h.forcePasswordReset(P)}catch(k){const _=k instanceof Error?k:new Error("Failed to send password reset");throw u(_),_}finally{l(!1)}},[h]),A=i.useCallback(async(P,k,_)=>{l(!0),u(null);try{await h.adjustCredits(P,{amount:k,reason:_})}catch(M){const D=M instanceof Error?M:new Error("Failed to adjust credits");throw u(D),D}finally{l(!1)}},[h]),v=i.useCallback(async(P,k)=>{l(!0),u(null);try{return await h.getUserDeposits(P,k)}catch(_){const M=_ instanceof Error?_:new Error("Failed to get user deposits");throw u(M),M}finally{l(!1)}},[h]),S=i.useCallback(async(P,k)=>{l(!0),u(null);try{return await h.getUserCredits(P,k)}catch(_){const M=_ instanceof Error?_:new Error("Failed to get user credits");throw u(M),M}finally{l(!1)}},[h]),w=i.useCallback(async(P,k)=>{l(!0),u(null);try{return await h.getUserWithdrawalHistory(P,k)}catch(_){const M=_ instanceof Error?_:new Error("Failed to get user withdrawal history");throw u(M),M}finally{l(!1)}},[h]),C=i.useCallback(async(P,k)=>{l(!0),u(null);try{return await h.getUserChats(P,k)}catch(_){const M=_ instanceof Error?_:new Error("Failed to get user chat history");throw u(M),M}finally{l(!1)}},[h]),T=i.useCallback(async()=>{l(!0),u(null);try{return await h.getStats()}catch(P){const k=P instanceof Error?P:new Error("Failed to get user stats");throw u(k),k}finally{l(!1)}},[h]),L=i.useCallback(async()=>{await b(f)},[b,f]),E=i.useCallback(()=>{u(null)},[]);return{users:r,total:n,isLoading:c,error:d,listUsers:b,getUser:g,setSystemAdmin:p,updateUser:x,deleteUser:j,forcePasswordReset:y,adjustCredits:A,getUserDeposits:v,getUserCredits:S,getUserWithdrawalHistory:w,getUserChats:C,getStats:T,refresh:L,clearError:E}}const Vo=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server"],Ho=["pay-products","pay-subscriptions","pay-transactions","pay-coupons","pay-refunds","pay-storefront","pay-ai","pay-payment","pay-messaging","pay-settings"],Ae={users:"Users",team:"Team",deposits:"Deposits",withdrawals:"Withdrawals","settings-wallet":"Wallet Settings","settings-auth":"Auth Settings","settings-messaging":"Messages Settings","settings-credits":"Credits Settings","settings-server":"Server Settings","pay-products":"Products","pay-subscriptions":"Subscriptions","pay-transactions":"Transactions","pay-coupons":"Coupons","pay-refunds":"Refunds","pay-storefront":"Storefront","pay-ai":"Store AI","pay-payment":"Payment Options","pay-messaging":"Store Messages","pay-settings":"Store Server"},Ve={admin:{users:!0,team:!0,deposits:!0,withdrawals:!0,"settings-wallet":!0,"settings-auth":!0,"settings-messaging":!0,"settings-credits":!0,"settings-server":!0,"pay-products":!0,"pay-subscriptions":!0,"pay-transactions":!0,"pay-coupons":!0,"pay-refunds":!0,"pay-storefront":!0,"pay-ai":!0,"pay-payment":!0,"pay-messaging":!0,"pay-settings":!0},member:{users:!1,team:!0,deposits:!1,withdrawals:!1,"settings-wallet":!1,"settings-auth":!1,"settings-messaging":!1,"settings-credits":!1,"settings-server":!1,"pay-products":!1,"pay-subscriptions":!1,"pay-transactions":!1,"pay-coupons":!1,"pay-refunds":!1,"pay-storefront":!1,"pay-ai":!1,"pay-payment":!1,"pay-messaging":!1,"pay-settings":!1}};function Qr(){const{config:s,authState:t,_internal:r}=N.useCedrosLogin(),{activeOrg:a,role:n}=is(),[o,c]=i.useState(Ve),[l,d]=i.useState(!1),[u,f]=i.useState(!1),[m,h]=i.useState(null),b=i.useRef(0),g=i.useMemo(()=>new N.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:r?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),p=i.useRef(g);p.current=g;const x=i.useCallback(async()=>{if(t!=="authenticated"||!a){c(Ve);return}d(!0),h(null);const A=++b.current;try{const v=await p.current.get("/admin/dashboard-permissions");if(A!==b.current)return;c(v.permissions)}catch(v){if(A!==b.current)return;if(v instanceof Error&&v.message.includes("404"))c(Ve);else{const S=v instanceof Error?v.message:"Failed to fetch permissions";h({code:"NETWORK_ERROR",message:S}),c(Ve)}}finally{A===b.current&&d(!1)}},[t,a]),j=i.useCallback(async A=>{if(t!=="authenticated"||!a)throw new Error("Not authenticated");if(n!=="owner")throw new Error("Only owners can modify dashboard permissions");f(!0),h(null);try{await p.current.request({method:"PUT",path:"/admin/dashboard-permissions",body:A}),c(A)}catch(v){const S=v instanceof Error?v.message:"Failed to update permissions";throw h({code:"NETWORK_ERROR",message:S}),new Error(S)}finally{f(!1)}},[t,a,n]),y=i.useCallback(A=>!a||!n||n==="owner"?!0:o[n]?.[A]??!1,[a,n,o]);return i.useEffect(()=>{a?.id&&x()},[a?.id,x]),{permissions:o,canAccess:y,updatePermissions:j,isLoading:l,isUpdating:u,error:m,fetchPermissions:x}}function ye(){const s=N.useCedrosLoginOptional(),[t,r]=i.useState(!1),[a,n]=i.useState(null),o=i.useMemo(()=>s?new N.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=i.useCallback(()=>{n(null)},[]),l=i.useCallback(async p=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{const x=new URLSearchParams;p?.status&&x.set("status",p.status),p?.limit!==void 0&&x.set("limit",String(p.limit)),p?.offset!==void 0&&x.set("offset",String(p.offset));const j=x.toString(),y=j?`/admin/deposits?${j}`:"/admin/deposits";return await o.get(y)}catch(x){const j=N.handleApiError(x,"Failed to list deposits");throw n(j.message),j}finally{r(!1)}},[o]),d=i.useCallback(async()=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get("/admin/deposits/stats")}catch(p){const x=N.handleApiError(p,"Failed to get deposit stats");throw n(x.message),x}finally{r(!1)}},[o]),u=i.useCallback(async p=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{const x=new URLSearchParams;p?.limit!==void 0&&x.set("limit",String(p.limit)),p?.offset!==void 0&&x.set("offset",String(p.offset));const j=x.toString(),y=j?`/admin/deposits/in-privacy-period?${j}`:"/admin/deposits/in-privacy-period";return await o.get(y)}catch(x){const j=N.handleApiError(x,"Failed to list deposits in privacy period");throw n(j.message),j}finally{r(!1)}},[o]),f=i.useCallback(async p=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{const x=new URLSearchParams;p?.limit!==void 0&&x.set("limit",String(p.limit)),p?.offset!==void 0&&x.set("offset",String(p.offset));const j=x.toString(),y=j?`/admin/withdrawals/pending?${j}`:"/admin/withdrawals/pending";return await o.get(y)}catch(x){const j=N.handleApiError(x,"Failed to list pending withdrawals");throw n(j.message),j}finally{r(!1)}},[o]),m=i.useCallback(async(p,x)=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.post(`/admin/withdrawals/${p}/process`,x??{})}catch(j){const y=N.handleApiError(j,"Failed to process withdrawal");throw n(y.message),y}finally{r(!1)}},[o]),h=i.useCallback(async()=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.post("/admin/withdrawals/process-all",{})}catch(p){const x=N.handleApiError(p,"Failed to process withdrawals");throw n(x.message),x}finally{r(!1)}},[o]),b=i.useCallback(async()=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get("/admin/privacy/status")}catch(p){const x=N.handleApiError(p,"Failed to get privacy status");throw n(x.message),x}finally{r(!1)}},[o]),g=i.useCallback(async()=>{if(!o)throw new Error("useAdminDeposits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get("/admin/credits/stats")}catch(p){const x=N.handleApiError(p,"Failed to get credit stats");throw n(x.message),x}finally{r(!1)}},[o]);return{listDeposits:l,getStats:d,listInPrivacyPeriod:u,listPendingWithdrawals:f,processWithdrawal:m,processAllWithdrawals:h,getPrivacyStatus:b,getCreditStats:g,isLoading:t,error:a,clearError:c}}function Te({feature:s="Privacy Cash",className:t=""}){return e.jsxs("div",{className:`cedros-admin-feature-disabled ${t}`,children:[e.jsx("div",{className:"cedros-admin-feature-disabled-icon",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",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.jsxs("h4",{className:"cedros-admin-feature-disabled-title",children:[s," Not Enabled"]}),e.jsx("p",{className:"cedros-admin-feature-disabled-description",children:"This feature is not enabled on the server. To enable it, update your server configuration:"}),e.jsx("div",{className:"cedros-admin-feature-disabled-code",children:e.jsx("code",{children:"PRIVACY_CASH_ENABLED=true"})}),e.jsx("p",{className:"cedros-admin-feature-disabled-note",children:"After updating the configuration, restart the server for changes to take effect."})]})}function Le(s){if(!s)return!1;const t=s.toLowerCase();return t.includes("not found")||t.includes("not enabled")||t.includes("privacy deposits not enabled")||t.includes("404")}const vt={loading:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"cedros-admin__spinner",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),refresh: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:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),e.jsx("path",{d:"M21 3v5h-5"}),e.jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),e.jsx("path",{d:"M8 16H3v5"})]})};function Ce({stats:s,isLoading:t=!1,onRefresh:r}){return e.jsxs("div",{className:"cedros-admin__stats-bar",children:[e.jsx("div",{className:"cedros-admin__stats-bar-grid",children:s.map((a,n)=>e.jsxs("div",{className:"cedros-admin__stats-bar-item",children:[e.jsx("span",{className:"cedros-admin__stats-bar-label",children:a.label}),e.jsx("span",{className:`cedros-admin__stats-bar-value ${a.variant?`cedros-admin__stats-bar-value--${a.variant}`:""}`,children:t?e.jsx("span",{className:"cedros-admin__skeleton cedros-admin__skeleton--value"}):a.value}),a.description&&e.jsx("span",{className:"cedros-admin__stats-bar-desc",children:a.description})]},n))}),r&&e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:r,disabled:t,title:"Refresh stats",children:t?vt.loading:vt.refresh})]})}function Kr({refreshInterval:s=0,className:t="",onLoad:r}){const{getStats:a,isLoading:n,error:o,clearError:c}=ye(),[l,d]=i.useState(null),[u,f]=i.useState(null),m=i.useCallback(async()=>{try{const b=await a();d(b),r?.(b),f(null)}catch(b){const g=b&&typeof b=="object"&&"message"in b?String(b.message):"Failed to load stats";f(g)}},[a,r]);i.useEffect(()=>{m()},[m]),i.useEffect(()=>{if(s<=0)return;const b=setInterval(m,s);return()=>clearInterval(b)},[s,m]);const h=u||o;return Le(h)?e.jsx(Te,{feature:"Privacy Cash",className:t}):h?e.jsxs("div",{className:`cedros-admin-stats cedros-admin-stats-error ${t}`,children:[e.jsx("p",{className:"cedros-admin-error",children:h}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{c(),f(null),m()},children:"Retry"})]}):n&&!l?e.jsxs("div",{className:`cedros-admin-stats cedros-admin-stats-loading ${t}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading statistics..."})]}):l?e.jsx("div",{className:`cedros-admin-stats ${t}`,children:e.jsx(Ce,{stats:[{label:"Total Deposits",value:l.totalDeposits},{label:"Private Deposits",value:l.inPrivacyPeriodCount??0},{label:"Standard Deposits",value:l.readyForWithdrawalCount??0},{label:"Microdeposits",value:l.nativeSolDepositCount??0}],isLoading:n,onRefresh:m})}):null}function Gr({refreshInterval:s=0,className:t="",onLoad:r}){const{getStats:a,isLoading:n,error:o,clearError:c}=ye(),[l,d]=i.useState(null),[u,f]=i.useState(null),m=i.useCallback(async()=>{try{const b=await a();d(b),r?.(b),f(null)}catch(b){const g=b&&typeof b=="object"&&"message"in b?String(b.message):"Failed to load stats";f(g)}},[a,r]);i.useEffect(()=>{m()},[m]),i.useEffect(()=>{if(s<=0)return;const b=setInterval(m,s);return()=>clearInterval(b)},[s,m]);const h=u||o;return Le(h)?e.jsx(Te,{feature:"Privacy Cash",className:t}):h?e.jsxs("div",{className:`cedros-admin-stats ${t}`,children:[e.jsx("p",{className:"cedros-admin-error",children:h}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{c(),f(null),m()},children:"Retry"})]}):n&&!l?e.jsx("div",{className:`cedros-admin-stats ${t}`,children:e.jsx(Ce,{stats:[{label:"Total Withdrawn",value:0},{label:"Pending Withdraw",value:0},{label:"In Privacy Period",value:0},{label:"Microbatch (SOL)",value:"0.0000"}],isLoading:!0})}):l?e.jsx("div",{className:`cedros-admin-stats ${t}`,children:e.jsx(Ce,{stats:[{label:"Total Withdrawn",value:l.totalWithdrawnCount},{label:"Pending Withdraw",value:l.pendingWithdrawalCount},{label:"In Privacy Period",value:l.inPrivacyPeriodCount??0},{label:"Microbatch (SOL)",value:l.readyForWithdrawalSol?.toFixed(4)??"0.0000"}],isLoading:n,onRefresh:m})}):null}function Qo(s){return{pending:"Pending",detected:"Detected",processing:"Processing",completed:"Completed",withdrawn:"Withdrawn",partially_withdrawn:"Partially Withdrawn",expired:"Expired",failed:"Failed"}[s]||s}function Ko(s){return s==="completed"||s==="withdrawn"||s==="partially_withdrawn"?"cedros-admin-deposit-success":s==="failed"||s==="expired"?"cedros-admin-deposit-error":s==="processing"||s==="detected"?"cedros-admin-deposit-processing":"cedros-admin-deposit-pending"}function Go(s){return s==null?"—":`${(s/1e9).toFixed(4)} SOL`}function Yo(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function jt(s){return s.length<=12?s:`${s.slice(0,6)}...${s.slice(-4)}`}function Yr({statusFilter:s,pageSize:t=20,refreshInterval:r=0,className:a="",onLoad:n,onDepositClick:o}){const{listDeposits:c,isLoading:l,error:d,clearError:u}=ye(),[f,m]=i.useState([]),[h,b]=i.useState(0),[g,p]=i.useState(0),[x,j]=i.useState(null),[y,A]=i.useState("createdAt"),[v,S]=i.useState("desc"),w=_=>{y===_?S(v==="asc"?"desc":"asc"):(A(_),S("desc"))},C=i.useMemo(()=>[...f].sort((_,M)=>{let D,B;switch(y){case"userId":D=_.userId.toLowerCase(),B=M.userId.toLowerCase();break;case"amountLamports":D=_.amountLamports??0,B=M.amountLamports??0;break;case"status":D=_.status,B=M.status;break;case"createdAt":D=new Date(_.createdAt).getTime(),B=new Date(M.createdAt).getTime();break;case"txSignature":D=_.txSignature||"",B=M.txSignature||"";break;default:return 0}return D<B?v==="asc"?-1:1:D>B?v==="asc"?1:-1:0}),[f,y,v]),T=i.useCallback(async()=>{try{const _=await c({status:s,limit:t,offset:g});m(_.deposits),b(_.total),n?.(_),j(null)}catch(_){const M=_&&typeof _=="object"&&"message"in _?String(_.message):"Failed to load deposits";j(M)}},[s,t,g,c,n]);i.useEffect(()=>{p(0)},[s,t]),i.useEffect(()=>{T()},[T]),i.useEffect(()=>{if(r<=0)return;const _=setInterval(T,r);return()=>clearInterval(_)},[r,T]);const L=Math.ceil(h/t),E=Math.floor(g/t)+1,P=_=>{const M=(_-1)*t;p(Math.max(0,Math.min(M,Math.max(0,h-1))))},k=x||d;return Le(k)?e.jsx(Te,{feature:"Privacy Cash",className:a}):k?e.jsxs("div",{className:`cedros-admin-deposit-list cedros-admin-deposit-list-error ${a}`,children:[e.jsx("p",{className:"cedros-admin-error",children:k}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{u(),j(null),T()},children:"Retry"})]}):l&&f.length===0?e.jsxs("div",{className:`cedros-admin-deposit-list cedros-admin-deposit-list-loading ${a}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading deposits..."})]}):e.jsxs("div",{className:`cedros-admin-deposit-list ${a}`,children:[e.jsxs("div",{className:"cedros-admin-deposit-list-header",children:[e.jsx("h4",{className:"cedros-admin-deposit-list-title",children:"All Deposits"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-icon-button",onClick:T,disabled:l,title:"Refresh deposits","aria-label":"Refresh deposits",children:l?"...":"↻"})]}),f.length===0?e.jsx("div",{className:"cedros-admin-empty",children:e.jsx("p",{className:"cedros-admin-empty-message",children:"No deposits found."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-deposit-table",children:[e.jsxs("div",{className:"cedros-admin-deposit-thead",children:[e.jsx("div",{className:"cedros-admin-deposit-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${y==="userId"?"cedros-admin-sort-active":""}`,onClick:()=>w("userId"),"aria-label":"Sort by user",children:["User"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:y==="userId"?v==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-deposit-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${y==="amountLamports"?"cedros-admin-sort-active":""}`,onClick:()=>w("amountLamports"),"aria-label":"Sort by amount",children:["Amount"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:y==="amountLamports"?v==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-deposit-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${y==="status"?"cedros-admin-sort-active":""}`,onClick:()=>w("status"),"aria-label":"Sort by status",children:["Status"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:y==="status"?v==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-deposit-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${y==="createdAt"?"cedros-admin-sort-active":""}`,onClick:()=>w("createdAt"),"aria-label":"Sort by created",children:["Created"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:y==="createdAt"?v==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-deposit-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${y==="txSignature"?"cedros-admin-sort-active":""}`,onClick:()=>w("txSignature"),"aria-label":"Sort by transaction",children:["Tx"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:y==="txSignature"?v==="asc"?"↑":"↓":"↕"})]})})]}),C.map(_=>e.jsxs("div",{className:`cedros-admin-deposit-row ${Ko(_.status)}`,onClick:()=>o?.(_),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),o?.(_))},role:o?"button":void 0,tabIndex:o?0:void 0,children:[e.jsx("div",{className:"cedros-admin-deposit-td",title:_.userId,children:jt(_.userId)}),e.jsx("div",{className:"cedros-admin-deposit-td",children:Go(_.amountLamports)}),e.jsx("div",{className:"cedros-admin-deposit-td",children:e.jsx("span",{className:"cedros-admin-status-badge",children:Qo(_.status)})}),e.jsx("div",{className:"cedros-admin-deposit-td",children:Yo(_.createdAt)}),e.jsx("div",{className:"cedros-admin-deposit-td",title:_.txSignature||void 0,children:_.txSignature?jt(_.txSignature):"—"})]},_.id))]}),L>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>P(E-1),disabled:E<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",E," of ",L," (",h," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>P(E+1),disabled:E>=L,children:"Next"})]})]})]})}function At(s){return s==null?"—":`${(s/1e9).toFixed(4)} SOL`}function kt(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Nt(s){return s.length<=12?s:`${s.slice(0,6)}...${s.slice(-4)}`}function Jo(s){const t=new Date(s),a=new Date().getTime()-t.getTime(),n=Math.floor(a/6e4),o=Math.floor(n/60),c=Math.floor(o/24);return c>0?`${c}d ago`:o>0?`${o}h ago`:n>0?`${n}m ago`:"just now"}function St(s){return s?new Date(s)>new Date:!0}function Jr({pageSize:s=20,refreshInterval:t=0,className:r="",onLoad:a,onItemClick:n,onWithdrawalProcessed:o,onAllProcessed:c}){const{listPendingWithdrawals:l,processWithdrawal:d,processAllWithdrawals:u,isLoading:f,error:m,clearError:h}=ye(),[b,g]=i.useState([]),[p,x]=i.useState(0),[j,y]=i.useState(0),[A,v]=i.useState(null),[S,w]=i.useState("withdrawalAvailableAt"),[C,T]=i.useState("asc"),L=R=>{S===R?T(C==="asc"?"desc":"asc"):(w(R),T(R==="withdrawalAvailableAt"?"asc":"desc"))},E=i.useMemo(()=>[...b].sort((R,F)=>{let U,q;switch(S){case"userId":U=R.userId.toLowerCase(),q=F.userId.toLowerCase();break;case"amountLamports":U=R.amountLamports??0,q=F.amountLamports??0;break;case"withdrawalAvailableAt":U=R.withdrawalAvailableAt?new Date(R.withdrawalAvailableAt).getTime():0,q=F.withdrawalAvailableAt?new Date(F.withdrawalAvailableAt).getTime():0;break;default:return 0}return U<q?C==="asc"?-1:1:U>q?C==="asc"?1:-1:0}),[b,S,C]),[P,k]=i.useState(null),[_,M]=i.useState(!1),[D,B]=i.useState(null),[Y,G]=i.useState(null),O=i.useCallback(async()=>{try{const R=await l({limit:s,offset:j});g(R.deposits),x(R.total),a?.(R),v(null)}catch(R){const F=R&&typeof R=="object"&&"message"in R?String(R.message):"Failed to load pending withdrawals";v(F)}},[s,j,l,a]);i.useEffect(()=>{y(0)},[s]),i.useEffect(()=>{O()},[O]),i.useEffect(()=>{if(t<=0)return;const R=setInterval(O,t);return()=>clearInterval(R)},[t,O]),i.useEffect(()=>{if(!D)return;const R=setTimeout(()=>B(null),5e3);return()=>clearTimeout(R)},[D]);const $=Math.ceil(p/s),I=Math.floor(j/s)+1,H=R=>{const F=(R-1)*s;y(Math.max(0,Math.min(F,Math.max(0,p-1))))},ee=async(R,F=!1)=>{if(!F&&St(R.withdrawalAvailableAt)){G(R);return}k(R.id),B(null);try{const U=await d(R.id,{force:F});U.success?(B({type:"success",message:`Withdrawal processed: ${U.txSignature?.slice(0,12)}...`}),o?.(U),await O()):B({type:"error",message:U.error||"Failed to process withdrawal"})}catch(U){B({type:"error",message:U instanceof Error?U.message:"Failed to process withdrawal"})}finally{k(null),G(null)}},Z=async()=>{if(b.length!==0){M(!0),B(null);try{const R=await u();R.totalSucceeded>0?B({type:"success",message:`Processed ${R.totalSucceeded}/${R.totalProcessed} withdrawals`}):R.totalFailed>0&&B({type:"error",message:`Failed to process ${R.totalFailed} withdrawals`}),c?.(R),await O()}catch(R){B({type:"error",message:R instanceof Error?R.message:"Failed to process withdrawals"})}finally{M(!1)}}},Q=A||m;return Le(Q)?e.jsx(Te,{feature:"Privacy Cash",className:r}):Q?e.jsxs("div",{className:`cedros-admin-withdrawal-queue cedros-admin-withdrawal-queue-error ${r}`,children:[e.jsx("p",{className:"cedros-admin-error",children:Q}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{h(),v(null),O()},children:"Retry"})]}):f&&b.length===0&&!P&&!_?e.jsxs("div",{className:`cedros-admin-withdrawal-queue cedros-admin-withdrawal-queue-loading ${r}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading withdrawal queue..."})]}):e.jsxs("div",{className:`cedros-admin-withdrawal-queue ${r}`,children:[Y&&e.jsx("div",{className:"cedros-admin-modal-overlay",onClick:()=>G(null),onKeyDown:R=>R.key==="Escape"&&G(null),role:"dialog","aria-modal":"true","aria-labelledby":"early-withdrawal-title",children:e.jsxs("div",{className:"cedros-admin-modal cedros-admin-modal-warning",onClick:R=>R.stopPropagation(),onKeyDown:()=>{},role:"document",children:[e.jsx("h3",{id:"early-withdrawal-title",className:"cedros-admin-modal-title",children:"Early Withdrawal Warning"}),e.jsxs("div",{className:"cedros-admin-modal-content",children:[e.jsx("p",{className:"cedros-admin-modal-warning-text",children:e.jsx("strong",{children:"This deposit is still within its privacy period."})}),e.jsx("p",{children:"Processing this withdrawal early may compromise user privacy. The privacy period exists to provide plausible deniability for deposits."}),e.jsxs("p",{className:"cedros-admin-modal-details",children:["User: ",Nt(Y.userId),e.jsx("br",{}),"Amount: ",At(Y.amountLamports),e.jsx("br",{}),"Available at:"," ",Y.withdrawalAvailableAt?kt(Y.withdrawalAvailableAt):"—"]}),e.jsx("p",{children:"Are you sure you want to process this withdrawal early?"})]}),e.jsxs("div",{className:"cedros-admin-modal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>G(null),children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:()=>ee(Y,!0),disabled:P===Y.id,children:P===Y.id?"Processing...":"Process Early"})]})]})}),D&&e.jsx("div",{className:`cedros-admin-result cedros-admin-result-${D.type}`,role:"status","aria-live":"polite",children:D.message}),e.jsxs("div",{className:"cedros-admin-withdrawal-queue-header",children:[e.jsx("h4",{className:"cedros-admin-withdrawal-queue-title",children:"Pending Withdrawals"}),e.jsxs("div",{className:"cedros-admin-withdrawal-queue-actions",children:[e.jsxs("span",{className:"cedros-admin-queue-count",children:[p," pending"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-icon-button",onClick:O,disabled:f||_,title:"Refresh queue","aria-label":"Refresh queue",children:f&&!_?"...":"↻"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:Z,disabled:f||_||b.length===0,title:"Process all ready withdrawals",children:_?"Processing...":"Process All"})]})]}),b.length===0?e.jsx("div",{className:"cedros-admin-empty",children:e.jsx("p",{className:"cedros-admin-empty-message",children:"No pending withdrawals."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-withdrawal-table",children:[e.jsxs("div",{className:"cedros-admin-withdrawal-thead",children:[e.jsx("div",{className:"cedros-admin-withdrawal-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${S==="userId"?"cedros-admin-sort-active":""}`,onClick:()=>L("userId"),"aria-label":"Sort by user",children:["User"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:S==="userId"?C==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-withdrawal-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${S==="amountLamports"?"cedros-admin-sort-active":""}`,onClick:()=>L("amountLamports"),"aria-label":"Sort by amount",children:["Amount"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:S==="amountLamports"?C==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-withdrawal-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${S==="withdrawalAvailableAt"?"cedros-admin-sort-active":""}`,onClick:()=>L("withdrawalAvailableAt"),"aria-label":"Sort by ready since",children:["Ready Since"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:S==="withdrawalAvailableAt"?C==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-withdrawal-th",children:"Waiting"}),e.jsx("div",{className:"cedros-admin-withdrawal-th cedros-admin-withdrawal-th-action",children:"Action"})]}),E.map(R=>{const F=St(R.withdrawalAvailableAt),U=P===R.id;return e.jsxs("div",{className:`cedros-admin-withdrawal-row ${F?"cedros-admin-withdrawal-row-early":""}`,onClick:()=>n?.(R),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),n?.(R))},role:n?"button":void 0,tabIndex:n?0:void 0,children:[e.jsx("div",{className:"cedros-admin-withdrawal-td",title:R.userId,children:Nt(R.userId)}),e.jsx("div",{className:"cedros-admin-withdrawal-td",children:At(R.amountLamports)}),e.jsx("div",{className:"cedros-admin-withdrawal-td",children:R.withdrawalAvailableAt?kt(R.withdrawalAvailableAt):"—"}),e.jsx("div",{className:"cedros-admin-withdrawal-td cedros-admin-withdrawal-waiting",children:R.withdrawalAvailableAt?F?"In privacy period":Jo(R.withdrawalAvailableAt):"—"}),e.jsx("div",{className:"cedros-admin-withdrawal-td cedros-admin-withdrawal-td-action",children:e.jsx("button",{type:"button",className:`cedros-button cedros-button-sm ${F?"cedros-button-warning":"cedros-button-primary"}`,onClick:q=>{q.stopPropagation(),ee(R)},disabled:U||_,title:F?"Early withdrawal (requires confirmation)":"Process this withdrawal",children:U?"...":F?"Early":"Process"})})]},R.id)})]}),$>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>H(I-1),disabled:I<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",I," of ",$," (",p," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>H(I+1),disabled:I>=$,children:"Next"})]})]})]})}function Xo(s){return s==null?"—":`${(s/1e9).toFixed(4)} SOL`}function Zo(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ei(s){return s.length<=12?s:`${s.slice(0,6)}...${s.slice(-4)}`}function si(s){const t=new Date(s),r=new Date,a=t.getTime()-r.getTime();if(a<=0)return"Ready";const n=Math.floor(a/6e4),o=Math.floor(n/60),c=Math.floor(o/24);if(c>0){const l=o%24;return l>0?`${c}d ${l}h`:`${c}d`}if(o>0){const l=n%60;return l>0?`${o}h ${l}m`:`${o}h`}return`${n}m`}function Xr({pageSize:s=20,refreshInterval:t=0,className:r="",onLoad:a,onItemClick:n}){const{listInPrivacyPeriod:o,isLoading:c,error:l,clearError:d}=ye(),[u,f]=i.useState([]),[m,h]=i.useState(0),[b,g]=i.useState(0),[p,x]=i.useState(null),j=i.useCallback(async()=>{try{const w=await o({limit:s,offset:b});f(w.deposits),h(w.total),a?.(w),x(null)}catch(w){const C=w&&typeof w=="object"&&"message"in w?String(w.message):"Failed to load deposits";x(C)}},[s,b,o,a]);i.useEffect(()=>{g(0)},[s]),i.useEffect(()=>{j()},[j]),i.useEffect(()=>{if(t<=0)return;const w=setInterval(j,t);return()=>clearInterval(w)},[t,j]);const y=Math.ceil(m/s),A=Math.floor(b/s)+1,v=w=>{const C=(w-1)*s;g(Math.max(0,Math.min(C,Math.max(0,m-1))))},S=p||l;return Le(S)?e.jsx(Te,{feature:"Privacy Cash",className:r}):S?e.jsxs("div",{className:`cedros-admin-privacy-deposits cedros-admin-privacy-deposits-error ${r}`,children:[e.jsx("p",{className:"cedros-admin-error",children:S}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{d(),x(null),j()},children:"Retry"})]}):c&&u.length===0?e.jsxs("div",{className:`cedros-admin-privacy-deposits cedros-admin-privacy-deposits-loading ${r}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading deposits..."})]}):e.jsxs("div",{className:`cedros-admin-privacy-deposits ${r}`,children:[e.jsxs("div",{className:"cedros-admin-privacy-deposits-header",children:[e.jsx("h4",{className:"cedros-admin-privacy-deposits-title",children:"In Privacy Period"}),e.jsxs("div",{className:"cedros-admin-privacy-deposits-actions",children:[e.jsxs("span",{className:"cedros-admin-queue-count",children:[m," deposit",m!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-icon-button",onClick:j,disabled:c,title:"Refresh list","aria-label":"Refresh list",children:c?"...":"↻"})]})]}),u.length===0?e.jsx("div",{className:"cedros-admin-empty",children:e.jsx("p",{className:"cedros-admin-empty-message",children:"No deposits in privacy period."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-privacy-table",children:[e.jsxs("div",{className:"cedros-admin-privacy-thead",children:[e.jsx("div",{className:"cedros-admin-privacy-th",children:e.jsxs("button",{type:"button",className:"cedros-admin-sort-button","aria-label":"Sort by user",children:["User ",e.jsx("span",{className:"cedros-admin-sort-icon",children:"↕"})]})}),e.jsx("div",{className:"cedros-admin-privacy-th",children:e.jsxs("button",{type:"button",className:"cedros-admin-sort-button","aria-label":"Sort by amount",children:["Amount ",e.jsx("span",{className:"cedros-admin-sort-icon",children:"↕"})]})}),e.jsx("div",{className:"cedros-admin-privacy-th",children:e.jsxs("button",{type:"button",className:"cedros-admin-sort-button","aria-label":"Sort by deposited",children:["Deposited ",e.jsx("span",{className:"cedros-admin-sort-icon",children:"↕"})]})}),e.jsx("div",{className:"cedros-admin-privacy-th",children:e.jsxs("button",{type:"button",className:"cedros-admin-sort-button","aria-label":"Sort by ready in",children:["Ready In ",e.jsx("span",{className:"cedros-admin-sort-icon",children:"↕"})]})})]}),u.map(w=>e.jsxs("div",{className:"cedros-admin-privacy-row",onClick:()=>n?.(w),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),n?.(w))},role:n?"button":void 0,tabIndex:n?0:void 0,children:[e.jsx("div",{className:"cedros-admin-privacy-td",title:w.userId,children:ei(w.userId)}),e.jsx("div",{className:"cedros-admin-privacy-td",children:Xo(w.amountLamports)}),e.jsx("div",{className:"cedros-admin-privacy-td",children:w.completedAt?Zo(w.completedAt):"—"}),e.jsx("div",{className:"cedros-admin-privacy-td cedros-admin-privacy-remaining",children:w.withdrawalAvailableAt?si(w.withdrawalAvailableAt):"—"})]},w.id))]}),y>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>v(A-1),disabled:A<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",A," of ",y," (",m," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>v(A+1),disabled:A>=y,children:"Next"})]})]})]})}function ti(s){return s==null?"—":`${(s/1e9).toFixed(4)} SOL`}function ri(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ni(s){return s.length<=16?s:`${s.slice(0,8)}...${s.slice(-6)}`}function ai(s){return s.length<=12?s:`${s.slice(0,6)}...${s.slice(-4)}`}function Zr({pageSize:s=20,refreshInterval:t=0,className:r="",onLoad:a,onItemClick:n}){const{listDeposits:o,isLoading:c,error:l,clearError:d}=ye(),[u,f]=i.useState([]),[m,h]=i.useState(0),[b,g]=i.useState(0),[p,x]=i.useState(null),[j,y]=i.useState("completedAt"),[A,v]=i.useState("desc"),S=k=>{j===k?v(A==="asc"?"desc":"asc"):(y(k),v("desc"))},w=i.useMemo(()=>[...u].sort((k,_)=>{let M,D;switch(j){case"userId":M=k.userId.toLowerCase(),D=_.userId.toLowerCase();break;case"amountLamports":M=k.amountLamports??0,D=_.amountLamports??0;break;case"completedAt":M=k.completedAt?new Date(k.completedAt).getTime():0,D=_.completedAt?new Date(_.completedAt).getTime():0;break;case"withdrawalTxSignature":M=k.withdrawalTxSignature||"",D=_.withdrawalTxSignature||"";break;default:return 0}return M<D?A==="asc"?-1:1:M>D?A==="asc"?1:-1:0}),[u,j,A]),C=i.useCallback(async()=>{try{const k=await o({status:"withdrawn",limit:s,offset:b});f(k.deposits),h(k.total),a?.(k),x(null)}catch(k){const _=k&&typeof k=="object"&&"message"in k?String(k.message):"Failed to load withdrawal history";x(_)}},[s,b,o,a]);i.useEffect(()=>{g(0)},[s]),i.useEffect(()=>{C()},[C]),i.useEffect(()=>{if(t<=0)return;const k=setInterval(C,t);return()=>clearInterval(k)},[t,C]);const T=Math.ceil(m/s),L=Math.floor(b/s)+1,E=k=>{const _=(k-1)*s;g(Math.max(0,Math.min(_,Math.max(0,m-1))))},P=p||l;return Le(P)?e.jsx(Te,{feature:"Privacy Cash",className:r}):P?e.jsxs("div",{className:`cedros-admin-withdrawal-history cedros-admin-withdrawal-history-error ${r}`,children:[e.jsx("p",{className:"cedros-admin-error",children:P}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{d(),x(null),C()},children:"Retry"})]}):c&&u.length===0?e.jsxs("div",{className:`cedros-admin-withdrawal-history cedros-admin-withdrawal-history-loading ${r}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-admin-withdrawal-history ${r}`,children:[e.jsxs("div",{className:"cedros-admin-withdrawal-history-header",children:[e.jsx("h4",{className:"cedros-admin-withdrawal-history-title",children:"Withdrawal History"}),e.jsxs("div",{className:"cedros-admin-withdrawal-history-actions",children:[e.jsxs("span",{className:"cedros-admin-queue-count",children:[m," withdrawal",m!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-icon-button",onClick:C,disabled:c,title:"Refresh list","aria-label":"Refresh list",children:c?"...":"↻"})]})]}),u.length===0?e.jsx("div",{className:"cedros-admin-empty",children:e.jsx("p",{className:"cedros-admin-empty-message",children:"No withdrawals processed yet."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-history-table",children:[e.jsxs("div",{className:"cedros-admin-history-thead",children:[e.jsx("div",{className:"cedros-admin-history-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${j==="userId"?"cedros-admin-sort-active":""}`,onClick:()=>S("userId"),"aria-label":"Sort by user",children:["User"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:j==="userId"?A==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-history-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${j==="amountLamports"?"cedros-admin-sort-active":""}`,onClick:()=>S("amountLamports"),"aria-label":"Sort by amount",children:["Amount"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:j==="amountLamports"?A==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-history-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${j==="completedAt"?"cedros-admin-sort-active":""}`,onClick:()=>S("completedAt"),"aria-label":"Sort by processed",children:["Processed"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:j==="completedAt"?A==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-history-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${j==="withdrawalTxSignature"?"cedros-admin-sort-active":""}`,onClick:()=>S("withdrawalTxSignature"),"aria-label":"Sort by transaction",children:["Transaction"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:j==="withdrawalTxSignature"?A==="asc"?"↑":"↓":"↕"})]})})]}),w.map(k=>e.jsxs("div",{className:"cedros-admin-history-row",onClick:()=>n?.(k),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),n?.(k))},role:n?"button":void 0,tabIndex:n?0:void 0,children:[e.jsx("div",{className:"cedros-admin-history-td",title:k.userId,children:ai(k.userId)}),e.jsx("div",{className:"cedros-admin-history-td",children:ti(k.amountLamports)}),e.jsx("div",{className:"cedros-admin-history-td",children:k.completedAt?ri(k.completedAt):"—"}),e.jsx("div",{className:"cedros-admin-history-td",children:k.withdrawalTxSignature?e.jsx("a",{href:`https://orbmarkets.io/tx/${k.withdrawalTxSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-admin-tx-link",onClick:_=>_.stopPropagation(),title:k.withdrawalTxSignature,children:ni(k.withdrawalTxSignature)}):"—"})]},k.id))]}),T>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>E(L-1),disabled:L<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",L," of ",T," (",m," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>E(L+1),disabled:L>=T,children:"Next"})]})]})]})}function Ct(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function oi(s){return s.length<=12?s:`${s.slice(0,6)}...${s.slice(-4)}`}function ii(s){return s==null?"-":(s/1e9).toFixed(4)}function en({pageSize:s=20,refreshInterval:t=0,currentUserId:r,className:a="",onLoad:n,onUserClick:o}){const{users:c,total:l,isLoading:d,error:u,listUsers:f,clearError:m}=ls(),[h,b]=i.useState(0),[g,p]=i.useState(null),[x,j]=i.useState("createdAt"),[y,A]=i.useState("desc"),v=E=>{x===E?A(y==="asc"?"desc":"asc"):(j(E),A("desc"))},S=i.useMemo(()=>[...c].sort((E,P)=>{let k,_;switch(x){case"name":k=(E.name||E.email||"").toLowerCase(),_=(P.name||P.email||"").toLowerCase();break;case"createdAt":k=new Date(E.createdAt).getTime(),_=new Date(P.createdAt).getTime();break;case"lastLoginAt":k=E.lastLoginAt?new Date(E.lastLoginAt).getTime():0,_=P.lastLoginAt?new Date(P.lastLoginAt).getTime():0;break;case"balanceLamports":k=E.balanceLamports??0,_=P.balanceLamports??0;break;default:return 0}return k<_?y==="asc"?-1:1:k>_?y==="asc"?1:-1:0}),[c,x,y]),w=i.useCallback(async()=>{try{const E=await f({limit:s,offset:h});n?.(E),p(null)}catch(E){p(E instanceof Error?E.message:"Failed to load users")}},[s,h,f,n]);i.useEffect(()=>{b(0)},[s]),i.useEffect(()=>{w()},[w]),i.useEffect(()=>{if(t<=0)return;const E=setInterval(w,t);return()=>clearInterval(E)},[t,w]);const C=Math.ceil(l/s),T=Math.floor(h/s)+1,L=E=>{const P=(E-1)*s;b(Math.max(0,Math.min(P,Math.max(0,l-1))))};return g||u?e.jsxs("div",{className:`cedros-admin-user-list cedros-admin-user-list-error ${a}`,children:[e.jsx("p",{className:"cedros-admin-error",children:g||u?.message}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{m(),p(null),w()},children:"Retry"})]}):d&&c.length===0?e.jsxs("div",{className:`cedros-admin-user-list cedros-admin-user-list-loading ${a}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading users..."})]}):e.jsxs("div",{className:`cedros-admin-user-list ${a}`,children:[e.jsxs("div",{className:"cedros-admin-user-list-header",children:[e.jsx("h4",{className:"cedros-admin-user-list-title",children:"All Users"}),e.jsxs("div",{className:"cedros-admin-user-list-actions",children:[e.jsxs("span",{className:"cedros-admin-queue-count",children:[l," user",l!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-icon-button",onClick:w,disabled:d,title:"Refresh list","aria-label":"Refresh list",children:d?"...":"↻"})]})]}),c.length===0?e.jsx("div",{className:"cedros-admin-empty",children:e.jsx("p",{className:"cedros-admin-empty-message",children:"No users found."})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-user-table",children:[e.jsxs("div",{className:"cedros-admin-user-thead",children:[e.jsx("div",{className:"cedros-admin-user-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${x==="name"?"cedros-admin-sort-active":""}`,onClick:()=>v("name"),"aria-label":"Sort by user",children:["User"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:x==="name"?y==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-user-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${x==="createdAt"?"cedros-admin-sort-active":""}`,onClick:()=>v("createdAt"),"aria-label":"Sort by registered date",children:["Registered"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:x==="createdAt"?y==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-user-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${x==="lastLoginAt"?"cedros-admin-sort-active":""}`,onClick:()=>v("lastLoginAt"),"aria-label":"Sort by last login",children:["Last Login"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:x==="lastLoginAt"?y==="asc"?"↑":"↓":"↕"})]})}),e.jsx("div",{className:"cedros-admin-user-th",children:e.jsxs("button",{type:"button",className:`cedros-admin-sort-button ${x==="balanceLamports"?"cedros-admin-sort-active":""}`,onClick:()=>v("balanceLamports"),"aria-label":"Sort by balance",children:["Balance"," ",e.jsx("span",{className:"cedros-admin-sort-icon",children:x==="balanceLamports"?y==="asc"?"↑":"↓":"↕"})]})})]}),S.map(E=>{const P=E.id===r;return e.jsxs("div",{className:`cedros-admin-user-row ${P?"cedros-admin-user-row-current":""}`,onClick:()=>o?.(E),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(E))},role:o?"button":void 0,tabIndex:o?0:void 0,children:[e.jsxs("div",{className:"cedros-admin-user-td cedros-admin-user-info",children:[e.jsx("div",{className:"cedros-admin-user-avatar",children:E.picture?e.jsx("img",{src:E.picture,alt:E.name||E.email||"User",className:"cedros-admin-user-avatar-img",referrerPolicy:"no-referrer"}):e.jsx("span",{className:"cedros-admin-user-avatar-placeholder",children:(E.name?.[0]||E.email?.[0]||"?").toUpperCase()})}),e.jsxs("div",{className:"cedros-admin-user-details",children:[e.jsxs("span",{className:"cedros-admin-user-name",children:[E.name||"Unknown",P&&e.jsx("span",{className:"cedros-admin-user-you",children:"(you)"})]}),e.jsx("span",{className:"cedros-admin-user-email",title:E.email,children:E.email||oi(E.id)})]})]}),e.jsx("div",{className:"cedros-admin-user-td",children:Ct(E.createdAt)}),e.jsx("div",{className:"cedros-admin-user-td",children:E.lastLoginAt?Ct(E.lastLoginAt):"-"}),e.jsx("div",{className:"cedros-admin-user-td",children:ii(E.balanceLamports)})]},E.id)})]}),C>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>L(T-1),disabled:T<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",T," of ",C," (",l," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>L(T+1),disabled:T>=C,children:"Next"})]})]})]})}function _t(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Xs(s){return new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function li(s){return s==null?"—":`${(s/1e9).toFixed(4)} SOL`}function Ke(s){return s==null?"—":(s/1e9).toFixed(4)}function ci(s){return{DEPOSIT:"Deposit",SPEND:"Spend",ADJUSTMENT:"Adjustment",REFUND:"Refund"}[s.toUpperCase()]||s}function di(s,t){return t?{deposit:"Credit deposit",purchase:"Purchase",api_call:"API usage",subscription:"Subscription",refund:"Refund",bonus:"Bonus credit",promo:"Promotional credit",correction:"Balance correction"}[t.toLowerCase()]||t:{DEPOSIT:"Credit added",SPEND:"Credit used",ADJUSTMENT:"Manual adjustment",REFUND:"Credit refunded"}[s.toUpperCase()]||"—"}function sn({userId:s,onBack:t,currentUserId:r,onEditUser:a,onAdjustCredits:n,cedrosPayEnabled:o=!1,className:c=""}){const{isLoading:l,getUser:d,getUserDeposits:u,getUserCredits:f,getUserChats:m,deleteUser:h,forcePasswordReset:b,clearError:g}=ls(),[p,x]=i.useState(null),[j,y]=i.useState(null),[A,v]=i.useState(null),[S,w]=i.useState(null),[C,T]=i.useState("deposits"),[L,E]=i.useState(null),[P,k]=i.useState(null),[_,M]=i.useState(null),[D,B]=i.useState(null),[Y,G]=i.useState(!1),[O,$]=i.useState(0),[I,H]=i.useState(0),[ee,Z]=i.useState(0),Q=10,R=i.useCallback(async()=>{try{const z=await d(s);x(z),E(null)}catch(z){E(z instanceof Error?z.message:"Failed to load user")}},[s,d]),F=i.useCallback(async()=>{try{const he=await u(s,{limit:Q,offset:O});v(he),M(null)}catch(z){M(z instanceof Error?z.message:"Failed to load deposits")}},[s,u,O]),U=i.useCallback(async()=>{try{const he=await f(s,{limit:Q,offset:I});y(he),k(null)}catch(z){k(z instanceof Error?z.message:"Failed to load credits")}},[s,f,I]),q=i.useCallback(async()=>{if(o)try{const he=await m(s,{limit:Q,offset:ee});w(he),B(null)}catch(z){B(z instanceof Error?z.message:"Failed to load chat history")}},[s,m,ee,o]);i.useEffect(()=>{R(),F(),U(),o&&q()},[R,F,U,q,o]);const re=async()=>{if(!p)return;if(p.id===r){alert("You cannot delete your own account");return}if(p.isSystemAdmin){alert("Cannot delete a system admin. Remove admin status first.");return}if(window.confirm(`Are you sure you want to delete ${p.name||p.email||"this user"}? This action cannot be undone.`)){G(!0);try{await h(p.id),t()}catch{}finally{G(!1)}}},de=async()=>{if(!p?.email){alert("User has no email address");return}if(window.confirm(`Send a password reset email to ${p.email}?`)){G(!0);try{await b(p.id),alert("Password reset email sent")}catch{}finally{G(!1)}}},Fe=A?Math.ceil(A.total/Q):0,Me=Math.floor(O/Q)+1,fe=j?Math.ceil(j.totalTransactions/Q):0,us=Math.floor(I/Q)+1,De=z=>{$((z-1)*Q)},ve=z=>{H((z-1)*Q)},Be=S?Math.ceil(S.total/Q):0,hs=Math.floor(ee/Q)+1,ms=z=>{Z((z-1)*Q)};if(L)return e.jsxs("div",{className:`cedros-admin-user-detail cedros-admin-user-detail-error ${c}`,children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:"Back"}),e.jsx("p",{className:"cedros-admin-error",children:L}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:()=>{g(),E(null),R()},children:"Retry"})]});if(l&&!p)return e.jsxs("div",{className:`cedros-admin-user-detail cedros-admin-user-detail-loading ${c}`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading user..."})]});if(!p)return e.jsxs("div",{className:`cedros-admin-user-detail ${c}`,children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:"Back"}),e.jsx("p",{className:"cedros-admin-empty-message",children:"User not found."})]});const ge=p.id===r;return e.jsxs("div",{className:`cedros-admin-user-detail ${c}`,children:[e.jsxs("div",{className:"cedros-admin-user-detail-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-back-btn",onClick:t,children:"Back to Users"}),e.jsxs("div",{className:"cedros-admin-user-detail-actions",children:[a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>a(p),disabled:Y,children:"Edit"}),p.email&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:de,disabled:Y,children:"Reset Password"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>n(p),disabled:Y,children:"Adjust Credits"}),!ge&&!p.isSystemAdmin&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-admin-btn-danger",onClick:re,disabled:Y,children:"Delete"})]})]}),e.jsxs("div",{className:"cedros-admin-user-detail-info",children:[e.jsx("div",{className:"cedros-admin-user-detail-avatar",children:p.picture?e.jsx("img",{src:p.picture,alt:p.name||p.email||"User",className:"cedros-admin-user-detail-avatar-img",referrerPolicy:"no-referrer"}):e.jsx("span",{className:"cedros-admin-user-detail-avatar-placeholder",children:(p.name?.[0]||p.email?.[0]||"?").toUpperCase()})}),e.jsxs("div",{className:"cedros-admin-user-detail-meta",children:[e.jsxs("h2",{className:"cedros-admin-user-detail-name",children:[p.name||"Unknown",ge&&e.jsx("span",{className:"cedros-admin-user-you",children:"(you)"})]}),e.jsxs("p",{className:"cedros-admin-user-detail-email",children:[p.email||"No email",p.emailVerified&&e.jsx("span",{className:"cedros-admin-verified-badge",title:"Email verified",children:"Verified"})]}),p.isSystemAdmin&&e.jsx("div",{className:"cedros-admin-user-detail-badges",children:e.jsx("span",{className:"cedros-admin-admin-badge cedros-admin-admin-badge-yes",children:"System Admin"})}),e.jsxs("div",{className:"cedros-admin-user-detail-methods",children:[e.jsx("span",{className:"cedros-admin-user-detail-methods-label",children:"Auth Methods:"}),p.authMethods.length>0?p.authMethods.map(z=>e.jsx("span",{className:`cedros-admin-auth-badge cedros-admin-auth-badge-${z}`,children:z},z)):e.jsx("span",{className:"cedros-admin-auth-badge cedros-admin-auth-badge-none",children:"none"})]}),e.jsxs("p",{className:"cedros-admin-user-detail-dates",children:["Registered: ",_t(p.createdAt)," | Updated: ",_t(p.updatedAt)]})]})]}),P?e.jsxs("div",{className:"cedros-admin-stats-error",children:[e.jsx("p",{className:"cedros-admin-error-inline",children:P}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{k(null),U()},children:"Retry"})]}):j?e.jsxs("div",{className:"cedros-admin-user-detail-stats",children:[e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Credit Balance"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Ke(j.stats.currentBalanceLamports)})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Total Credited"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Ke(j.stats.totalDepositedLamports)})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Total Spent"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Ke(j.stats.totalSpentLamports)})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Deposits"}),e.jsx("span",{className:"cedros-admin-stat-value",children:j.stats.depositCount})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Transactions"}),e.jsx("span",{className:"cedros-admin-stat-value",children:j.stats.spendCount})]})]}):e.jsxs("div",{className:"cedros-admin-stats-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{children:"Loading credit stats..."})]}),e.jsxs("div",{className:"cedros-admin-user-detail-tabs",children:[e.jsxs("button",{type:"button",className:`cedros-admin-tab ${C==="deposits"?"cedros-admin-tab-active":""}`,onClick:()=>T("deposits"),children:["Deposits (",A?.total??0,")"]}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${C==="transactions"?"cedros-admin-tab-active":""}`,onClick:()=>T("transactions"),children:["Credits (",j?.totalTransactions??0,")"]}),o&&e.jsxs("button",{type:"button",className:`cedros-admin-tab ${C==="chats"?"cedros-admin-tab-active":""}`,onClick:()=>T("chats"),children:["Chats (",S?.total??0,")"]})]}),e.jsxs("div",{className:"cedros-admin-user-detail-content",children:[C==="deposits"&&e.jsx(ui,{deposits:A?.deposits??[],total:A?.total??0,currentPage:Me,totalPages:Fe,onPageChange:De,isLoading:l,error:_,onRetry:()=>{M(null),F()}}),C==="transactions"&&e.jsx(hi,{transactions:j?.transactions??[],total:j?.totalTransactions??0,currentPage:us,totalPages:fe,onPageChange:ve,error:P,onRetry:()=>{k(null),U()},isLoading:l}),C==="chats"&&o&&e.jsx(mi,{sessions:S?.sessions??[],total:S?.total??0,currentPage:hs,totalPages:Be,onPageChange:ms,error:D,onRetry:()=>{B(null),q()},isLoading:l})]})]})}function ui({deposits:s,total:t,currentPage:r,totalPages:a,onPageChange:n,isLoading:o,error:c,onRetry:l}){return c?e.jsxs("div",{className:"cedros-admin-tab-error",children:[e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:l,children:"Retry"})]}):o&&s.length===0?e.jsxs("div",{className:"cedros-admin-tab-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{children:"Loading deposits..."})]}):t===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No deposits found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table",children:[e.jsxs("div",{className:"cedros-admin-list-thead",children:[e.jsx("div",{className:"cedros-admin-list-th",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Status"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Transaction"})]}),s.map(d=>e.jsxs("div",{className:"cedros-admin-list-row",children:[e.jsx("div",{className:"cedros-admin-list-td",children:Xs(d.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",children:li(d.amountLamports)}),e.jsx("div",{className:"cedros-admin-list-td",children:e.jsx("span",{className:`cedros-admin-status-badge cedros-admin-status-${d.status}`,children:d.status})}),e.jsx("div",{className:"cedros-admin-list-td cedros-admin-list-td-actions",children:d.txSignature?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"cedros-admin-list-td-mono",title:d.txSignature,children:[d.txSignature.slice(0,8),"..."]}),e.jsx("a",{href:`https://orbmarkets.io/tx/${d.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-admin-icon-link",title:"View on Orbmarkets","aria-label":"View transaction on Orbmarkets",children:"↗"})]}):e.jsx("span",{className:"cedros-admin-list-td-muted",children:"—"})})]},d.id))]}),a>1&&e.jsx(Zs,{currentPage:r,totalPages:a,total:t,onPageChange:n})]})}function hi({transactions:s,total:t,currentPage:r,totalPages:a,onPageChange:n,isLoading:o,error:c,onRetry:l}){return c?e.jsxs("div",{className:"cedros-admin-tab-error",children:[e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:l,children:"Retry"})]}):o&&s.length===0?e.jsxs("div",{className:"cedros-admin-tab-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{children:"Loading transactions..."})]}):t===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No credit transactions found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table",children:[e.jsxs("div",{className:"cedros-admin-list-thead",children:[e.jsx("div",{className:"cedros-admin-list-th",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Type"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Description"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Amount"})]}),s.map(d=>e.jsxs("div",{className:"cedros-admin-list-row",children:[e.jsx("div",{className:"cedros-admin-list-td",children:Xs(d.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",children:e.jsx("span",{className:`cedros-admin-tx-type cedros-admin-tx-type-${d.txType.toLowerCase()}`,children:ci(d.txType)})}),e.jsx("div",{className:"cedros-admin-list-td",children:di(d.txType,d.referenceType)}),e.jsxs("div",{className:`cedros-admin-list-td ${d.amountLamports>=0?"cedros-admin-amount-positive":"cedros-admin-amount-negative"}`,children:[d.amountLamports>=0?"+":"",Ke(d.amountLamports)]})]},d.id))]}),a>1&&e.jsx(Zs,{currentPage:r,totalPages:a,total:t,onPageChange:n})]})}function mi({sessions:s,total:t,currentPage:r,totalPages:a,onPageChange:n,isLoading:o,error:c,onRetry:l}){return c?e.jsxs("div",{className:"cedros-admin-tab-error",children:[e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:l,children:"Retry"})]}):o&&s.length===0?e.jsxs("div",{className:"cedros-admin-tab-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{children:"Loading chat history..."})]}):t===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No chat sessions found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table",children:[e.jsxs("div",{className:"cedros-admin-list-thead",children:[e.jsx("div",{className:"cedros-admin-list-th",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Session"}),e.jsx("div",{className:"cedros-admin-list-th",children:"Messages"})]}),s.map(d=>e.jsxs("div",{className:"cedros-admin-list-row",children:[e.jsx("div",{className:"cedros-admin-list-td",children:Xs(d.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",children:d.title||`Chat ${d.id.slice(0,8)}...`}),e.jsx("div",{className:"cedros-admin-list-td",children:d.messageCount})]},d.id))]}),a>1&&e.jsx(Zs,{currentPage:r,totalPages:a,total:t,onPageChange:n})]})}function Zs({currentPage:s,totalPages:t,total:r,onPageChange:a}){return e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>a(s-1),disabled:s<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",s," of ",t," (",r," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>a(s+1),disabled:s>=t,children:"Next"})]})}function He({checked:s,onChange:t,disabled:r,label:a}){return e.jsx("button",{type:"button",role:"switch","aria-checked":s,"aria-label":a,disabled:r,className:`cedros-toggle cedros-toggle-sm ${s?"cedros-toggle-on":"cedros-toggle-off"} ${r?"cedros-toggle-disabled":""}`,onClick:()=>!r&&t(!s),children:e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})})})}function tn({userRole:s}){const{permissions:t,updatePermissions:r,isLoading:a,isUpdating:n,error:o}=Qr(),{features:c,isLoading:l}=Js(),d=i.useRef(null),u=i.useRef(null),f=s==="owner",m=c.cedrosPay,h=i.useCallback(g=>{u.current=g,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{u.current&&(r(u.current).catch(()=>{}),u.current=null)},500)},[r]);i.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const b=i.useCallback((g,p,x)=>{const j={...t,[g]:{...t[g],[p]:x}};h(j)},[t,h]);return a||l?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx("div",{className:"cedros-dashboard__loading",children:"Loading permissions..."})}):f?e.jsxs("div",{className:"cedros-dashboard__section cedros-permissions-section",children:[e.jsxs("div",{className:"cedros-permissions-header",children:[e.jsx("p",{className:"cedros-permissions-description",children:"Configure which dashboard sections each role can access. Owners always have full access."}),o&&e.jsx("div",{className:"cedros-permissions-error",children:o.message}),n&&e.jsx("span",{className:"cedros-permissions-saving",children:"Saving..."})]}),e.jsx("div",{className:"cedros-permissions-matrix",children:e.jsx("table",{className:"cedros-permissions-table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{className:"cedros-permissions-group-header",children:[e.jsx("th",{className:"cedros-permissions-section-header",children:"Cedros Login"}),e.jsx("th",{className:"cedros-permissions-role-header",children:"Admin"}),e.jsx("th",{className:"cedros-permissions-role-header",children:"Member"})]}),Vo.map(g=>e.jsxs("tr",{className:"cedros-permissions-row",children:[e.jsx("td",{className:"cedros-permissions-section-label",children:Ae[g]}),e.jsx("td",{className:"cedros-permissions-toggle-cell",children:e.jsx(He,{checked:t.admin[g]??!1,onChange:p=>b("admin",g,p),disabled:n,label:`Admin access to ${Ae[g]}`})}),e.jsx("td",{className:"cedros-permissions-toggle-cell",children:e.jsx(He,{checked:t.member[g]??!1,onChange:p=>b("member",g,p),disabled:n,label:`Member access to ${Ae[g]}`})})]},g)),m&&e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"cedros-permissions-group-header",children:[e.jsx("th",{className:"cedros-permissions-section-header",children:"Cedros Pay"}),e.jsx("th",{className:"cedros-permissions-role-header",children:"Admin"}),e.jsx("th",{className:"cedros-permissions-role-header",children:"Member"})]}),Ho.map(g=>e.jsxs("tr",{className:"cedros-permissions-row",children:[e.jsx("td",{className:"cedros-permissions-section-label",children:Ae[g]}),e.jsx("td",{className:"cedros-permissions-toggle-cell",children:e.jsx(He,{checked:t.admin[g]??!1,onChange:p=>b("admin",g,p),disabled:n,label:`Admin access to ${Ae[g]}`})}),e.jsx("td",{className:"cedros-permissions-toggle-cell",children:e.jsx(He,{checked:t.member[g]??!1,onChange:p=>b("member",g,p),disabled:n,label:`Member access to ${Ae[g]}`})})]},g))]})]})})})]}):e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx("div",{className:"cedros-dashboard__empty",children:"Only organization owners can configure dashboard permissions."})})}function et({name:s,email:t,picture:r,onSettings:a,onLogout:n,className:o=""}){const[c,l]=i.useState(!1),d=i.useRef(null);i.useEffect(()=>{function b(g){d.current&&!d.current.contains(g.target)&&l(!1)}if(c)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[c]),i.useEffect(()=>{function b(g){g.key==="Escape"&&l(!1)}if(c)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[c]);const u=i.useCallback(()=>{l(!1),a?.()},[a]),f=i.useCallback(()=>{l(!1),n?.()},[n]),m=s||"User",h=(s?.[0]||t?.[0]||"?").toUpperCase();return e.jsxs("div",{className:`cedros-profile-dropdown ${o}`,ref:d,children:[e.jsxs("button",{type:"button",className:"cedros-profile-dropdown__trigger",onClick:()=>l(!c),"aria-expanded":c,"aria-haspopup":"menu",children:[e.jsx("div",{className:"cedros-profile-dropdown__avatar",children:r?e.jsx("img",{src:r,alt:m,className:"cedros-profile-dropdown__avatar-img",referrerPolicy:"no-referrer"}):e.jsx("span",{className:"cedros-profile-dropdown__avatar-placeholder",children:h})}),e.jsxs("div",{className:"cedros-profile-dropdown__info",children:[e.jsx("span",{className:"cedros-profile-dropdown__name",children:m}),t&&e.jsx("span",{className:"cedros-profile-dropdown__email",children:t})]}),e.jsx("svg",{className:`cedros-profile-dropdown__chevron ${c?"cedros-profile-dropdown__chevron--open":""}`,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})]}),c&&e.jsxs("div",{className:"cedros-profile-dropdown__menu",role:"menu",children:[a&&e.jsxs("button",{type:"button",className:"cedros-profile-dropdown__item",onClick:u,role:"menuitem",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:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),"Settings"]}),n&&e.jsxs("button",{type:"button",className:"cedros-profile-dropdown__item cedros-profile-dropdown__item--danger",onClick:f,role:"menuitem",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:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),e.jsx("polyline",{points:"16 17 21 12 16 7"}),e.jsx("line",{x1:"21",x2:"9",y1:"12",y2:"12"})]}),"Log out"]})]})]})}const ie={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"})]})},pi=[{id:"users",label:"Users",icon:ie.users},{id:"team",label:"Team",icon:ie.members},{id:"deposits",label:"Deposits",icon:ie.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:ie.withdrawals,requiredFeature:"credits"},{id:"settings-auth",label:"Authentication",icon:ie.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:ie.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:ie.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:ie.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-server",label:"Auth Server",icon:ie.server,group:"Configuration"}];function fi({title:s="Dashboard",sections:t=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server"],defaultSection:r="users",refreshInterval:a=0,pageSize:n=20,onSectionChange:o,onSettingsClick:c,onLogoutClick:l,className:d=""}){const[u,f]=i.useState(r),[m,h]=i.useState(!0),{user:b,logout:g}=N.useCedrosLogin(),{activeOrg:p,role:x,isLoading:j,fetchOrgs:y,hasPermission:A}=is(),{status:v,isLoading:S,checkStatus:w}=Ys(),{features:C,isLoading:T}=Js(),{canAccess:L}=Qr(),E=i.useCallback(D=>{f(D),o?.(D)},[o]),P=pi.filter(D=>!(!t.includes(D.id)||D.requiredFeature&&!C[D.requiredFeature]||!L(D.id))),k=P.find(D=>D.id===u),_=!k&&!T;return i.useEffect(()=>{y(),w()},[y,w]),i.useEffect(()=>{_&&P.length>0&&f("users")},[_,P.length]),!S&&v?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${d}`,children:e.jsx(Fr,{onComplete:()=>w()})}):(j||S||T)&&!p?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${d}`,children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):u==="team"&&!p?e.jsx("div",{className:`cedros-admin cedros-dashboard ${d}`,children:e.jsx(N.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${d}`,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:[ie.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:s})]})}),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"}),P.filter(D=>!D.group).map(D=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===D.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>E(D.id),"aria-current":u===D.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:D.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:D.label})]},D.id))]}),P.some(D=>D.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:()=>h(!m),"aria-expanded":m,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${m?"cedros-dashboard__nav-chevron--expanded":""}`,children:ie.chevronRight})]}),m&&P.filter(D=>D.group==="Configuration").map(D=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===D.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>E(D.id),"aria-current":u===D.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:D.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:D.label})]},D.id))]})]}),b&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(et,{name:b.name,email:b.email,picture:b.picture,onSettings:c,onLogout:l??g})})]}),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:s}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:ie.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:k?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[u==="users"&&e.jsx(gi,{pageSize:n,currentUserId:b?.id}),u==="team"&&p&&e.jsx(bi,{orgId:p.id,currentUserId:b?.id,hasPermission:A,role:x}),u==="deposits"&&e.jsx(yi,{pageSize:n,refreshInterval:a}),u==="withdrawals"&&e.jsx(wi,{pageSize:n,refreshInterval:a}),u==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(qr,{})}),u==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Wr,{})}),u==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Oo,{})}),u==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx($r,{})}),u==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(zr,{})})]})]})]})}function gi({pageSize:s,currentUserId:t}){const[r,a]=i.useState(null),[n,o]=i.useState(null),[c,l]=i.useState(!1),[d,u]=i.useState(null),{getStats:f}=ls(),{fetchSettings:m,getValue:h}=Ue(),[b,g]=i.useState(!1);i.useEffect(()=>{b||(m(),g(!0))},[m,b]);const p=i.useCallback(y=>{const A=h(y);return A===void 0?!1:A==="true"||A==="1"},[h]),x=i.useCallback(async()=>{l(!0),u(null);try{const y=await f();o(y)}catch(y){u(y instanceof Error?y.message:"Failed to load user stats")}finally{l(!1)}},[f]);i.useEffect(()=>{x()},[x]);const j=i.useMemo(()=>{const y=[{label:"Total Users",value:n?.total??"—"}],A=p("auth_email_enabled"),v=p("auth_google_enabled"),S=p("auth_apple_enabled"),w=p("auth_solana_enabled"),C=p("auth_webauthn_enabled"),T=p("feature_sso");return A&&y.push({label:"Email Users",value:n?.authMethodCounts.email??0}),v&&y.push({label:"Google Users",value:n?.authMethodCounts.google??0}),S&&y.push({label:"Apple Users",value:n?.authMethodCounts.apple??0}),w&&y.push({label:"Solana Users",value:n?.authMethodCounts.solana??0}),C&&y.push({label:"Passkey Users",value:n?.authMethodCounts.webauthn??0}),T&&y.push({label:"SSO Provider Users",value:n?.authMethodCounts.sso??0}),y},[n,p]);return r?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(sn,{userId:r.id,currentUserId:t,onBack:()=>a(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(Ce,{stats:j,isLoading:c,onRefresh:x}),d&&e.jsx("p",{className:"cedros-admin-error-inline",children:d}),e.jsx(en,{pageSize:s,currentUserId:t,onUserClick:y=>a(y)})]})}function bi({orgId:s,currentUserId:t,hasPermission:r,role:a}){const[n,o]=i.useState("members"),{members:c,isLoading:l,error:d,fetchMembers:u,updateMemberRole:f,removeMember:m}=Vr(s),{invites:h,isLoading:b,error:g,fetchInvites:p,createInvite:x,cancelInvite:j,resendInvite:y}=Hr(s);i.useEffect(()=>{u(),p()},[u,p]);const A=r("invite:create"),v=r("invite:cancel"),S=h.length,w=c.reduce((E,P)=>(E[P.role]=(E[P.role]??0)+1,E),{}),C=w.owner??0,T=w.admin??0,L=w.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(Ce,{stats:[{label:"Owners",value:C},{label:"Admins",value:T},{label:"Members",value:L},{label:"Pending Invites",value:S}]}),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:()=>o("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:()=>o("invites"),"aria-selected":n==="invites",role:"tab",children:["Pending Invites",S>0&&` (${S})`]}),a==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>o("permissions"),"aria-selected":n==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[n==="members"&&e.jsx(xr,{members:c,currentUserId:t,isLoading:l,error:d?.message,canManage:r("member:remove"),canChangeRoles:r("member:role_change"),onUpdateRole:f,onRemove:m}),n==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[A&&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(vr,{onSubmit:x,isLoading:b,error:g?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(jr,{invites:h,isLoading:b,error:g?.message,canManage:v||A,onCancel:v?j:void 0,onResend:A?y:void 0})})]}),n==="permissions"&&a==="owner"&&e.jsx(tn,{userRole:a})]})]})}function yi({pageSize:s,refreshInterval:t}){const[r,a]=i.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(Kr,{refreshInterval:t}),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=>a(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(Yr,{statusFilter:r||void 0,pageSize:s,refreshInterval:t})]})]})}function wi({pageSize:s,refreshInterval:t}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(Gr,{refreshInterval:t}),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(Xr,{pageSize:s,refreshInterval:t}),e.jsx(Jr,{pageSize:s,refreshInterval:t}),e.jsx(Zr,{pageSize:s,refreshInterval:t})]})]})}class xi{plugins=new Map;listeners=new Set;register(t){this.plugins.has(t.id)&&console.warn(`Plugin ${t.id} already registered, replacing...`),this.plugins.set(t.id,t),t.onRegister?.(this),this.notify()}unregister(t){const r=this.plugins.get(t);r&&(r.onUnregister?.(),this.plugins.delete(t),this.notify())}get(t){return this.plugins.get(t)}getAll(){return Array.from(this.plugins.values())}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notify(){const t=this.getAll();this.listeners.forEach(r=>r(t))}}const rn=i.createContext(null);function vi(){const s=i.useContext(rn);if(!s)throw new Error("useAdminShell must be used within AdminShell");return s}function ji(s){const t=new Map;for(const r of s)for(const a of r.groups??[])t.has(a.label)||t.set(a.label,a.order);return t}function Ai({title:s="Admin",plugins:t=[],hostContext:r,defaultSection:a,pageSize:n=20,refreshInterval:o=0,onSectionChange:c,logo:l,sidebarFooter:d,onSettingsClick:u,onLogoutClick:f,className:m=""}){const[h]=i.useState(()=>{const E=new xi;return t.forEach(P=>E.register(P)),E}),[b,g]=i.useState(()=>h.getAll());i.useEffect(()=>h.subscribe(g),[h]);const p=i.useMemo(()=>b.flatMap(E=>E.sections.filter(P=>!(P.requiredPermission&&!E.checkPermission(P.requiredPermission,r)||r.dashboardPermissions&&!r.dashboardPermissions.canAccess(P.id))).map(P=>({...P,qualifiedId:`${E.id}:${P.id}`,pluginId:E.id,cssNamespace:E.cssNamespace}))),[b,r]),[x,j]=i.useState(()=>a??p[0]?.qualifiedId??null),[y,A]=i.useState(new Set),v=i.useCallback(E=>{A(P=>{const k=new Set(P);return k.has(E)?k.delete(E):k.add(E),k})},[]);i.useEffect(()=>{x&&!p.find(E=>E.qualifiedId===x)&&j(p[0]?.qualifiedId??null)},[p,x]);const S=i.useCallback(E=>{j(E),c?.(E)},[c]),w=i.useCallback(E=>{const P=h.get(E);return P?P.createPluginContext(r):null},[h,r]),C=i.useMemo(()=>{const E=ji(b),P=new Map;return p.forEach(_=>{const M=_.group??"Menu",D=P.get(M)??[];P.set(M,[...D,_])}),Array.from(P.entries()).sort(([_],[M])=>{const D=E.get(_)??99,B=E.get(M)??99;return D-B})},[p,b]),T=i.useMemo(()=>{if(!x)return null;const[E,P]=x.split(":"),k=h.get(E);if(!k)return null;const _=k.components[P];if(!_)return null;const M=k.createPluginContext(r);return{Component:_,pluginContext:M,plugin:k}},[x,h,r]),L=i.useMemo(()=>({registry:h,hostContext:r,activeSection:x,setActiveSection:S,getPluginContext:w}),[h,r,x,S,w]);return e.jsx(rn.Provider,{value:L,children:e.jsxs("div",{className:`cedros-admin cedros-admin-shell ${m||""}`,children:[e.jsxs("aside",{className:"cedros-admin-shell__sidebar",children:[e.jsx("div",{className:"cedros-admin-shell__sidebar-header",children:l??e.jsx("div",{className:"cedros-admin-shell__logo",children:e.jsx("span",{className:"cedros-admin-shell__logo-text",children:s})})}),e.jsx("nav",{className:"cedros-admin-shell__nav",children:C.map(([E,P])=>{const k=E==="Configuration",_=y.has(E);return e.jsxs("div",{className:"cedros-admin-shell__nav-group",children:[k?e.jsxs("button",{type:"button",className:"cedros-admin-shell__nav-label cedros-admin-shell__nav-label--collapsible",onClick:()=>v(E),"aria-expanded":!_,children:[e.jsx("span",{children:E}),e.jsx("span",{className:`cedros-admin-shell__nav-chevron ${_?"":"cedros-admin-shell__nav-chevron--expanded"}`,children: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"})})})]}):e.jsx("span",{className:"cedros-admin-shell__nav-label",children:E}),(!k||!_)&&P.sort((M,D)=>(M.order??0)-(D.order??0)).map(M=>e.jsxs("button",{type:"button",className:`cedros-admin-shell__nav-item ${x===M.qualifiedId?"cedros-admin-shell__nav-item--active":""}`,onClick:()=>S(M.qualifiedId),"aria-current":x===M.qualifiedId?"page":void 0,children:[e.jsx("span",{className:"cedros-admin-shell__nav-icon",children:M.icon}),e.jsx("span",{className:"cedros-admin-shell__nav-text",children:M.label}),M.badge&&e.jsx("span",{className:"cedros-admin-shell__nav-badge",children:M.badge})]},M.qualifiedId))]},E)})}),(r.cedrosLogin?.user||d)&&e.jsxs("div",{className:"cedros-admin-shell__sidebar-footer",children:[r.cedrosLogin?.user&&e.jsx(et,{name:r.cedrosLogin.user.name,email:r.cedrosLogin.user.email,picture:r.cedrosLogin.user.picture,onSettings:u,onLogout:f}),d]})]}),e.jsx("main",{className:"cedros-admin-shell__main",children:T?e.jsx(i.Suspense,{fallback:e.jsx(ki,{}),children:e.jsx("div",{className:"cedros-admin-shell__section","data-plugin-namespace":T.plugin.cssNamespace,children:e.jsx(T.Component,{pluginContext:T.pluginContext,pageSize:n,refreshInterval:o})})}):e.jsx("div",{className:"cedros-admin-shell__empty",children:p.length===0?"No plugins loaded":"Select a section from the sidebar"})})]})})}function ki(){return e.jsxs("div",{className:"cedros-admin-shell__loading",children:[e.jsx(N.LoadingSpinner,{}),e.jsx("span",{children:"Loading..."})]})}const te={width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},ce={users:e.jsxs("svg",{...te,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",{...te,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"})]}),invites:e.jsxs("svg",{...te,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"})]}),deposits:e.jsxs("svg",{...te,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",{...te,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"})]}),settings:e.jsxs("svg",{...te,children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),wallet:e.jsxs("svg",{...te,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",{...te,children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{...te,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"})}),toggles:e.jsxs("svg",{...te,children:[e.jsx("rect",{width:"20",height:"12",x:"2",y:"6",rx:"6"}),e.jsx("circle",{cx:"8",cy:"12",r:"2"})]}),shield:e.jsx("svg",{...te,children:e.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),mail:e.jsxs("svg",{...te,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"})]}),webhook:e.jsxs("svg",{...te,children:[e.jsx("path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2"}),e.jsx("path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06"}),e.jsx("path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8"})]}),coins:e.jsxs("svg",{...te,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",{...te,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"})]})},Ni=i.lazy(()=>Promise.resolve().then(()=>require("./UsersSection-BImSsHRA.cjs"))),Si=i.lazy(()=>Promise.resolve().then(()=>require("./TeamSection-BgFEYBD7.cjs"))),Ci=i.lazy(()=>Promise.resolve().then(()=>require("./DepositsSection-BzlzofEm.cjs"))),_i=i.lazy(()=>Promise.resolve().then(()=>require("./WithdrawalsSection-_7gHudQ8.cjs"))),Ei=i.lazy(()=>Promise.resolve().then(()=>require("./AuthenticationSettings-CEVF1qTV.cjs"))),Pi=i.lazy(()=>Promise.resolve().then(()=>require("./EmbeddedWalletSettings-D8oqefzm.cjs"))),Ti=i.lazy(()=>Promise.resolve().then(()=>require("./EmailSettings-D2Y_T3ea.cjs"))),Li=i.lazy(()=>Promise.resolve().then(()=>require("./WebhookSettings-fOHCAQqx.cjs"))),Mi=i.lazy(()=>Promise.resolve().then(()=>require("./CreditSystemSettings-CVxamkZ8.cjs"))),Di=i.lazy(()=>Promise.resolve().then(()=>require("./ServerSettings-Yrumq_CL.cjs"))),Ri={"login:users:read":["admin","owner"],"login:users:write":["admin","owner"],"login:members:read":["member:read","admin","owner"],"login:members:write":["member:remove","member:role_change"],"login:invites:read":["invite:read","admin","owner"],"login:invites:write":["invite:create","invite:cancel"],"login:deposits:read":["admin","owner"],"login:deposits:write":["admin","owner"],"login:settings:read":["admin","owner"],"login:settings:write":["admin","owner"]},Ii=[{id:"users",label:"Users",icon:ce.users,group:"Users",order:0,requiredPermission:"login:users:read"},{id:"team",label:"Team",icon:ce.members,group:"Users",order:1,requiredPermission:"login:members:read"},{id:"deposits",label:"Deposits",icon:ce.deposits,group:"Users",order:2,requiredPermission:"login:deposits:read"},{id:"withdrawals",label:"Withdrawals",icon:ce.withdrawals,group:"Users",order:3,requiredPermission:"login:deposits:read"},{id:"settings-auth",label:"Authentication",icon:ce.key,group:"Configuration",order:0,requiredPermission:"login:settings:read"},{id:"settings-email",label:"Email & SMTP",icon:ce.mail,group:"Configuration",order:1,requiredPermission:"login:settings:read"},{id:"settings-webhooks",label:"Webhooks",icon:ce.webhook,group:"Configuration",order:2,requiredPermission:"login:settings:read"},{id:"settings-wallet",label:"User Wallets",icon:ce.wallet,group:"Configuration",order:3,requiredPermission:"login:settings:read"},{id:"settings-credits",label:"Credit System",icon:ce.coins,group:"Configuration",order:4,requiredPermission:"login:settings:read"},{id:"settings-server",label:"Auth Server",icon:ce.server,group:"Configuration",order:5,requiredPermission:"login:settings:read"}],Ui={id:"cedros-login",name:"Cedros Login",version:"1.0.0",sections:Ii,groups:[{id:"users",label:"Users",order:0},{id:"configuration",label:"Configuration",order:2}],components:{users:Ni,team:Si,deposits:Ci,withdrawals:_i,"settings-auth":Ei,"settings-wallet":Pi,"settings-email":Ti,"settings-webhooks":Li,"settings-credits":Mi,"settings-server":Di},createPluginContext(s){const t=s.cedrosLogin;if(!t)throw new Error("cedros-login plugin requires cedrosLogin in hostContext");return{serverUrl:t.serverUrl,userId:t.user?.id,getAccessToken:t.getAccessToken,hasPermission:r=>this.checkPermission(r,s),orgId:s.org?.orgId,pluginData:{user:t.user,orgRole:s.org?.role}}},checkPermission(s,t){const r=t.org;if(!r)return!!t.cedrosLogin?.user;const a=Ri[s];return a?a.some(n=>r.permissions.includes(n)||n===r.role||n==="admin"&&["admin","owner"].includes(r.role)||n==="owner"&&r.role==="owner"):!1},cssNamespace:"cedros-dashboard"};var ke={},xs,Et;function Fi(){return Et||(Et=1,xs=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),xs}var vs={},pe={},Pt;function we(){if(Pt)return pe;Pt=1;let s;const t=[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(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17},pe.getSymbolTotalCodewords=function(a){return t[a]},pe.getBCHDigit=function(r){let a=0;for(;r!==0;)a++,r>>>=1;return a},pe.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');s=a},pe.isKanjiModeEnabled=function(){return typeof s<"u"},pe.toSJIS=function(a){return s(a)},pe}var js={},Tt;function st(){return Tt||(Tt=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function t(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+r)}}s.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},s.from=function(a,n){if(s.isValid(a))return a;try{return t(a)}catch{return n}}})(js)),js}var As,Lt;function Bi(){if(Lt)return As;Lt=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(t){const r=Math.floor(t/8);return(this.buffer[r]>>>7-t%8&1)===1},put:function(t,r){for(let a=0;a<r;a++)this.putBit((t>>>r-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}},As=s,As}var ks,Mt;function Oi(){if(Mt)return ks;Mt=1;function s(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return s.prototype.set=function(t,r,a,n){const o=t*this.size+r;this.data[o]=a,n&&(this.reservedBit[o]=!0)},s.prototype.get=function(t,r){return this.data[t*this.size+r]},s.prototype.xor=function(t,r,a){this.data[t*this.size+r]^=a},s.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]},ks=s,ks}var Ns={},Dt;function qi(){return Dt||(Dt=1,(function(s){const t=we().getSymbolSize;s.getRowColCoords=function(a){if(a===1)return[];const n=Math.floor(a/7)+2,o=t(a),c=o===145?26:Math.ceil((o-13)/(2*n-2))*2,l=[o-7];for(let d=1;d<n-1;d++)l[d]=l[d-1]-c;return l.push(6),l.reverse()},s.getPositions=function(a){const n=[],o=s.getRowColCoords(a),c=o.length;for(let l=0;l<c;l++)for(let d=0;d<c;d++)l===0&&d===0||l===0&&d===c-1||l===c-1&&d===0||n.push([o[l],o[d]]);return n}})(Ns)),Ns}var Ss={},Rt;function Wi(){if(Rt)return Ss;Rt=1;const s=we().getSymbolSize,t=7;return Ss.getPositions=function(a){const n=s(a);return[[0,0],[n-t,0],[0,n-t]]},Ss}var Cs={},It;function $i(){return It||(It=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};s.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},s.from=function(n){return s.isValid(n)?parseInt(n,10):void 0},s.getPenaltyN1=function(n){const o=n.size;let c=0,l=0,d=0,u=null,f=null;for(let m=0;m<o;m++){l=d=0,u=f=null;for(let h=0;h<o;h++){let b=n.get(m,h);b===u?l++:(l>=5&&(c+=t.N1+(l-5)),u=b,l=1),b=n.get(h,m),b===f?d++:(d>=5&&(c+=t.N1+(d-5)),f=b,d=1)}l>=5&&(c+=t.N1+(l-5)),d>=5&&(c+=t.N1+(d-5))}return c},s.getPenaltyN2=function(n){const o=n.size;let c=0;for(let l=0;l<o-1;l++)for(let d=0;d<o-1;d++){const u=n.get(l,d)+n.get(l,d+1)+n.get(l+1,d)+n.get(l+1,d+1);(u===4||u===0)&&c++}return c*t.N2},s.getPenaltyN3=function(n){const o=n.size;let c=0,l=0,d=0;for(let u=0;u<o;u++){l=d=0;for(let f=0;f<o;f++)l=l<<1&2047|n.get(u,f),f>=10&&(l===1488||l===93)&&c++,d=d<<1&2047|n.get(f,u),f>=10&&(d===1488||d===93)&&c++}return c*t.N3},s.getPenaltyN4=function(n){let o=0;const c=n.data.length;for(let d=0;d<c;d++)o+=n.data[d];return Math.abs(Math.ceil(o*100/c/5)-10)*t.N4};function r(a,n,o){switch(a){case s.Patterns.PATTERN000:return(n+o)%2===0;case s.Patterns.PATTERN001:return n%2===0;case s.Patterns.PATTERN010:return o%3===0;case s.Patterns.PATTERN011:return(n+o)%3===0;case s.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(o/3))%2===0;case s.Patterns.PATTERN101:return n*o%2+n*o%3===0;case s.Patterns.PATTERN110:return(n*o%2+n*o%3)%2===0;case s.Patterns.PATTERN111:return(n*o%3+(n+o)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}s.applyMask=function(n,o){const c=o.size;for(let l=0;l<c;l++)for(let d=0;d<c;d++)o.isReserved(d,l)||o.xor(d,l,r(n,d,l))},s.getBestMask=function(n,o){const c=Object.keys(s.Patterns).length;let l=0,d=1/0;for(let u=0;u<c;u++){o(u),s.applyMask(u,n);const f=s.getPenaltyN1(n)+s.getPenaltyN2(n)+s.getPenaltyN3(n)+s.getPenaltyN4(n);s.applyMask(u,n),f<d&&(d=f,l=u)}return l}})(Cs)),Cs}var Qe={},Ut;function nn(){if(Ut)return Qe;Ut=1;const s=st(),t=[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 Qe.getBlocksCount=function(n,o){switch(o){case s.L:return t[(n-1)*4+0];case s.M:return t[(n-1)*4+1];case s.Q:return t[(n-1)*4+2];case s.H:return t[(n-1)*4+3];default:return}},Qe.getTotalCodewordsCount=function(n,o){switch(o){case s.L:return r[(n-1)*4+0];case s.M:return r[(n-1)*4+1];case s.Q:return r[(n-1)*4+2];case s.H:return r[(n-1)*4+3];default:return}},Qe}var _s={},Ie={},Ft;function zi(){if(Ft)return Ie;Ft=1;const s=new Uint8Array(512),t=new Uint8Array(256);return(function(){let a=1;for(let n=0;n<255;n++)s[n]=a,t[a]=n,a<<=1,a&256&&(a^=285);for(let n=255;n<512;n++)s[n]=s[n-255]})(),Ie.log=function(a){if(a<1)throw new Error("log("+a+")");return t[a]},Ie.exp=function(a){return s[a]},Ie.mul=function(a,n){return a===0||n===0?0:s[t[a]+t[n]]},Ie}var Bt;function Vi(){return Bt||(Bt=1,(function(s){const t=zi();s.mul=function(a,n){const o=new Uint8Array(a.length+n.length-1);for(let c=0;c<a.length;c++)for(let l=0;l<n.length;l++)o[c+l]^=t.mul(a[c],n[l]);return o},s.mod=function(a,n){let o=new Uint8Array(a);for(;o.length-n.length>=0;){const c=o[0];for(let d=0;d<n.length;d++)o[d]^=t.mul(n[d],c);let l=0;for(;l<o.length&&o[l]===0;)l++;o=o.slice(l)}return o},s.generateECPolynomial=function(a){let n=new Uint8Array([1]);for(let o=0;o<a;o++)n=s.mul(n,new Uint8Array([1,t.exp(o)]));return n}})(_s)),_s}var Es,Ot;function Hi(){if(Ot)return Es;Ot=1;const s=Vi();function t(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(a){this.degree=a,this.genPoly=s.generateECPolynomial(this.degree)},t.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(a.length+this.degree);n.set(a);const o=s.mod(n,this.genPoly),c=this.degree-o.length;if(c>0){const l=new Uint8Array(this.degree);return l.set(o,c),l}return o},Es=t,Es}var Ps={},Ts={},Ls={},qt;function an(){return qt||(qt=1,Ls.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Ls}var ue={},Wt;function on(){if(Wt)return ue;Wt=1;const s="[0-9]+",t="[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 a="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
2050
+ ]))+`;ue.KANJI=new RegExp(r,"g"),ue.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),ue.BYTE=new RegExp(a,"g"),ue.NUMERIC=new RegExp(s,"g"),ue.ALPHANUMERIC=new RegExp(t,"g");const n=new RegExp("^"+r+"$"),o=new RegExp("^"+s+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return ue.testKanji=function(d){return n.test(d)},ue.testNumeric=function(d){return o.test(d)},ue.testAlphanumeric=function(d){return c.test(d)},ue}var $t;function xe(){return $t||($t=1,(function(s){const t=an(),r=on();s.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},s.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},s.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},s.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},s.MIXED={bit:-1},s.getCharCountIndicator=function(o,c){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?o.ccBits[0]:c<27?o.ccBits[1]:o.ccBits[2]},s.getBestModeForData=function(o){return r.testNumeric(o)?s.NUMERIC:r.testAlphanumeric(o)?s.ALPHANUMERIC:r.testKanji(o)?s.KANJI:s.BYTE},s.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},s.isValid=function(o){return o&&o.bit&&o.ccBits};function a(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"numeric":return s.NUMERIC;case"alphanumeric":return s.ALPHANUMERIC;case"kanji":return s.KANJI;case"byte":return s.BYTE;default:throw new Error("Unknown mode: "+n)}}s.from=function(o,c){if(s.isValid(o))return o;try{return a(o)}catch{return c}}})(Ts)),Ts}var zt;function Qi(){return zt||(zt=1,(function(s){const t=we(),r=nn(),a=st(),n=xe(),o=an(),c=7973,l=t.getBCHDigit(c);function d(h,b,g){for(let p=1;p<=40;p++)if(b<=s.getCapacity(p,g,h))return p}function u(h,b){return n.getCharCountIndicator(h,b)+4}function f(h,b){let g=0;return h.forEach(function(p){const x=u(p.mode,b);g+=x+p.getBitsLength()}),g}function m(h,b){for(let g=1;g<=40;g++)if(f(h,g)<=s.getCapacity(g,b,n.MIXED))return g}s.from=function(b,g){return o.isValid(b)?parseInt(b,10):g},s.getCapacity=function(b,g,p){if(!o.isValid(b))throw new Error("Invalid QR Code version");typeof p>"u"&&(p=n.BYTE);const x=t.getSymbolTotalCodewords(b),j=r.getTotalCodewordsCount(b,g),y=(x-j)*8;if(p===n.MIXED)return y;const A=y-u(p,b);switch(p){case n.NUMERIC:return Math.floor(A/10*3);case n.ALPHANUMERIC:return Math.floor(A/11*2);case n.KANJI:return Math.floor(A/13);case n.BYTE:default:return Math.floor(A/8)}},s.getBestVersionForData=function(b,g){let p;const x=a.from(g,a.M);if(Array.isArray(b)){if(b.length>1)return m(b,x);if(b.length===0)return 1;p=b[0]}else p=b;return d(p.mode,p.getLength(),x)},s.getEncodedBits=function(b){if(!o.isValid(b)||b<7)throw new Error("Invalid QR Code version");let g=b<<12;for(;t.getBCHDigit(g)-l>=0;)g^=c<<t.getBCHDigit(g)-l;return b<<12|g}})(Ps)),Ps}var Ms={},Vt;function Ki(){if(Vt)return Ms;Vt=1;const s=we(),t=1335,r=21522,a=s.getBCHDigit(t);return Ms.getEncodedBits=function(o,c){const l=o.bit<<3|c;let d=l<<10;for(;s.getBCHDigit(d)-a>=0;)d^=t<<s.getBCHDigit(d)-a;return(l<<10|d)^r},Ms}var Ds={},Rs,Ht;function Gi(){if(Ht)return Rs;Ht=1;const s=xe();function t(r){this.mode=s.NUMERIC,this.data=r.toString()}return t.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(a){let n,o,c;for(n=0;n+3<=this.data.length;n+=3)o=this.data.substr(n,3),c=parseInt(o,10),a.put(c,10);const l=this.data.length-n;l>0&&(o=this.data.substr(n),c=parseInt(o,10),a.put(c,l*3+1))},Rs=t,Rs}var Is,Qt;function Yi(){if(Qt)return Is;Qt=1;const s=xe(),t=["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(a){this.mode=s.ALPHANUMERIC,this.data=a}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 o;for(o=0;o+2<=this.data.length;o+=2){let c=t.indexOf(this.data[o])*45;c+=t.indexOf(this.data[o+1]),n.put(c,11)}this.data.length%2&&n.put(t.indexOf(this.data[o]),6)},Is=r,Is}var Us,Kt;function Ji(){if(Kt)return Us;Kt=1;const s=xe();function t(r){this.mode=s.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}return t.getBitsLength=function(a){return a*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(r){for(let a=0,n=this.data.length;a<n;a++)r.put(this.data[a],8)},Us=t,Us}var Fs,Gt;function Xi(){if(Gt)return Fs;Gt=1;const s=xe(),t=we();function r(a){this.mode=s.KANJI,this.data=a}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(a){let n;for(n=0;n<this.data.length;n++){let o=t.toSJIS(this.data[n]);if(o>=33088&&o<=40956)o-=33088;else if(o>=57408&&o<=60351)o-=49472;else throw new Error("Invalid SJIS character: "+this.data[n]+`
2051
+ Make sure your charset is UTF-8`);o=(o>>>8&255)*192+(o&255),a.put(o,13)}},Fs=r,Fs}var Bs={exports:{}},Yt;function Zi(){return Yt||(Yt=1,(function(s){var t={single_source_shortest_paths:function(r,a,n){var o={},c={};c[a]=0;var l=t.PriorityQueue.make();l.push(a,0);for(var d,u,f,m,h,b,g,p,x;!l.empty();){d=l.pop(),u=d.value,m=d.cost,h=r[u]||{};for(f in h)h.hasOwnProperty(f)&&(b=h[f],g=m+b,p=c[f],x=typeof c[f]>"u",(x||p>g)&&(c[f]=g,l.push(f,g),o[f]=u))}if(typeof n<"u"&&typeof c[n]>"u"){var j=["Could not find a path from ",a," to ",n,"."].join("");throw new Error(j)}return o},extract_shortest_path_from_predecessor_list:function(r,a){for(var n=[],o=a;o;)n.push(o),r[o],o=r[o];return n.reverse(),n},find_path:function(r,a,n){var o=t.single_source_shortest_paths(r,a,n);return t.extract_shortest_path_from_predecessor_list(o,n)},PriorityQueue:{make:function(r){var a=t.PriorityQueue,n={},o;r=r||{};for(o in a)a.hasOwnProperty(o)&&(n[o]=a[o]);return n.queue=[],n.sorter=r.sorter||a.default_sorter,n},default_sorter:function(r,a){return r.cost-a.cost},push:function(r,a){var n={value:r,cost:a};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=t})(Bs)),Bs.exports}var Jt;function el(){return Jt||(Jt=1,(function(s){const t=xe(),r=Gi(),a=Yi(),n=Ji(),o=Xi(),c=on(),l=we(),d=Zi();function u(j){return unescape(encodeURIComponent(j)).length}function f(j,y,A){const v=[];let S;for(;(S=j.exec(A))!==null;)v.push({data:S[0],index:S.index,mode:y,length:S[0].length});return v}function m(j){const y=f(c.NUMERIC,t.NUMERIC,j),A=f(c.ALPHANUMERIC,t.ALPHANUMERIC,j);let v,S;return l.isKanjiModeEnabled()?(v=f(c.BYTE,t.BYTE,j),S=f(c.KANJI,t.KANJI,j)):(v=f(c.BYTE_KANJI,t.BYTE,j),S=[]),y.concat(A,v,S).sort(function(C,T){return C.index-T.index}).map(function(C){return{data:C.data,mode:C.mode,length:C.length}})}function h(j,y){switch(y){case t.NUMERIC:return r.getBitsLength(j);case t.ALPHANUMERIC:return a.getBitsLength(j);case t.KANJI:return o.getBitsLength(j);case t.BYTE:return n.getBitsLength(j)}}function b(j){return j.reduce(function(y,A){const v=y.length-1>=0?y[y.length-1]:null;return v&&v.mode===A.mode?(y[y.length-1].data+=A.data,y):(y.push(A),y)},[])}function g(j){const y=[];for(let A=0;A<j.length;A++){const v=j[A];switch(v.mode){case t.NUMERIC:y.push([v,{data:v.data,mode:t.ALPHANUMERIC,length:v.length},{data:v.data,mode:t.BYTE,length:v.length}]);break;case t.ALPHANUMERIC:y.push([v,{data:v.data,mode:t.BYTE,length:v.length}]);break;case t.KANJI:y.push([v,{data:v.data,mode:t.BYTE,length:u(v.data)}]);break;case t.BYTE:y.push([{data:v.data,mode:t.BYTE,length:u(v.data)}])}}return y}function p(j,y){const A={},v={start:{}};let S=["start"];for(let w=0;w<j.length;w++){const C=j[w],T=[];for(let L=0;L<C.length;L++){const E=C[L],P=""+w+L;T.push(P),A[P]={node:E,lastCount:0},v[P]={};for(let k=0;k<S.length;k++){const _=S[k];A[_]&&A[_].node.mode===E.mode?(v[_][P]=h(A[_].lastCount+E.length,E.mode)-h(A[_].lastCount,E.mode),A[_].lastCount+=E.length):(A[_]&&(A[_].lastCount=E.length),v[_][P]=h(E.length,E.mode)+4+t.getCharCountIndicator(E.mode,y))}}S=T}for(let w=0;w<S.length;w++)v[S[w]].end=0;return{map:v,table:A}}function x(j,y){let A;const v=t.getBestModeForData(j);if(A=t.from(y,v),A!==t.BYTE&&A.bit<v.bit)throw new Error('"'+j+'" cannot be encoded with mode '+t.toString(A)+`.
2052
+ Suggested mode is: `+t.toString(v));switch(A===t.KANJI&&!l.isKanjiModeEnabled()&&(A=t.BYTE),A){case t.NUMERIC:return new r(j);case t.ALPHANUMERIC:return new a(j);case t.KANJI:return new o(j);case t.BYTE:return new n(j)}}s.fromArray=function(y){return y.reduce(function(A,v){return typeof v=="string"?A.push(x(v,null)):v.data&&A.push(x(v.data,v.mode)),A},[])},s.fromString=function(y,A){const v=m(y,l.isKanjiModeEnabled()),S=g(v),w=p(S,A),C=d.find_path(w.map,"start","end"),T=[];for(let L=1;L<C.length-1;L++)T.push(w.table[C[L]].node);return s.fromArray(b(T))},s.rawSplit=function(y){return s.fromArray(m(y,l.isKanjiModeEnabled()))}})(Ds)),Ds}var Xt;function sl(){if(Xt)return vs;Xt=1;const s=we(),t=st(),r=Bi(),a=Oi(),n=qi(),o=Wi(),c=$i(),l=nn(),d=Hi(),u=Qi(),f=Ki(),m=xe(),h=el();function b(w,C){const T=w.size,L=o.getPositions(C);for(let E=0;E<L.length;E++){const P=L[E][0],k=L[E][1];for(let _=-1;_<=7;_++)if(!(P+_<=-1||T<=P+_))for(let M=-1;M<=7;M++)k+M<=-1||T<=k+M||(_>=0&&_<=6&&(M===0||M===6)||M>=0&&M<=6&&(_===0||_===6)||_>=2&&_<=4&&M>=2&&M<=4?w.set(P+_,k+M,!0,!0):w.set(P+_,k+M,!1,!0))}}function g(w){const C=w.size;for(let T=8;T<C-8;T++){const L=T%2===0;w.set(T,6,L,!0),w.set(6,T,L,!0)}}function p(w,C){const T=n.getPositions(C);for(let L=0;L<T.length;L++){const E=T[L][0],P=T[L][1];for(let k=-2;k<=2;k++)for(let _=-2;_<=2;_++)k===-2||k===2||_===-2||_===2||k===0&&_===0?w.set(E+k,P+_,!0,!0):w.set(E+k,P+_,!1,!0)}}function x(w,C){const T=w.size,L=u.getEncodedBits(C);let E,P,k;for(let _=0;_<18;_++)E=Math.floor(_/3),P=_%3+T-8-3,k=(L>>_&1)===1,w.set(E,P,k,!0),w.set(P,E,k,!0)}function j(w,C,T){const L=w.size,E=f.getEncodedBits(C,T);let P,k;for(P=0;P<15;P++)k=(E>>P&1)===1,P<6?w.set(P,8,k,!0):P<8?w.set(P+1,8,k,!0):w.set(L-15+P,8,k,!0),P<8?w.set(8,L-P-1,k,!0):P<9?w.set(8,15-P-1+1,k,!0):w.set(8,15-P-1,k,!0);w.set(L-8,8,1,!0)}function y(w,C){const T=w.size;let L=-1,E=T-1,P=7,k=0;for(let _=T-1;_>0;_-=2)for(_===6&&_--;;){for(let M=0;M<2;M++)if(!w.isReserved(E,_-M)){let D=!1;k<C.length&&(D=(C[k]>>>P&1)===1),w.set(E,_-M,D),P--,P===-1&&(k++,P=7)}if(E+=L,E<0||T<=E){E-=L,L=-L;break}}}function A(w,C,T){const L=new r;T.forEach(function(M){L.put(M.mode.bit,4),L.put(M.getLength(),m.getCharCountIndicator(M.mode,w)),M.write(L)});const E=s.getSymbolTotalCodewords(w),P=l.getTotalCodewordsCount(w,C),k=(E-P)*8;for(L.getLengthInBits()+4<=k&&L.put(0,4);L.getLengthInBits()%8!==0;)L.putBit(0);const _=(k-L.getLengthInBits())/8;for(let M=0;M<_;M++)L.put(M%2?17:236,8);return v(L,w,C)}function v(w,C,T){const L=s.getSymbolTotalCodewords(C),E=l.getTotalCodewordsCount(C,T),P=L-E,k=l.getBlocksCount(C,T),_=L%k,M=k-_,D=Math.floor(L/k),B=Math.floor(P/k),Y=B+1,G=D-B,O=new d(G);let $=0;const I=new Array(k),H=new Array(k);let ee=0;const Z=new Uint8Array(w.buffer);for(let q=0;q<k;q++){const re=q<M?B:Y;I[q]=Z.slice($,$+re),H[q]=O.encode(I[q]),$+=re,ee=Math.max(ee,re)}const Q=new Uint8Array(L);let R=0,F,U;for(F=0;F<ee;F++)for(U=0;U<k;U++)F<I[U].length&&(Q[R++]=I[U][F]);for(F=0;F<G;F++)for(U=0;U<k;U++)Q[R++]=H[U][F];return Q}function S(w,C,T,L){let E;if(Array.isArray(w))E=h.fromArray(w);else if(typeof w=="string"){let D=C;if(!D){const B=h.rawSplit(w);D=u.getBestVersionForData(B,T)}E=h.fromString(w,D||40)}else throw new Error("Invalid data");const P=u.getBestVersionForData(E,T);if(!P)throw new Error("The amount of data is too big to be stored in a QR Code");if(!C)C=P;else if(C<P)throw new Error(`
2053
2053
  The chosen QR Code version cannot contain this amount of data.
2054
2054
  Minimum version required to store current data is: `+P+`.
2055
- `);const k=A(C,T,E),_=s.getSymbolSize(C),M=new a(_);return b(M,C),g(M),p(M,C),j(M,T,0),C>=7&&x(M,C),y(M,k),isNaN(L)&&(L=c.getBestMask(M,j.bind(null,M,T))),c.applyMask(L,M),j(M,T,L),{modules:M,version:C,errorCorrectionLevel:T,maskPattern:L,segments:E}}return vs.create=function(C,T){if(typeof C>"u"||C==="")throw new Error("No input text");let L=t.M,E,P;return typeof T<"u"&&(L=t.from(T.errorCorrectionLevel,t.M),E=u.from(T.version),P=c.from(T.maskPattern),T.toSJISFunc&&s.setToSJISFunction(T.toSJISFunc)),S(C,E,L,P)},vs}var Os={},qs={},er;function cn(){return er||(er=1,(function(s){function t(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let a=r.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+r);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(o){return[o,o]}))),a.length===6&&a.push("F","F");const n=parseInt(a.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+a.slice(0,6).join("")}}s.getOptions=function(a){a||(a={}),a.color||(a.color={});const n=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,o=a.width&&a.width>=21?a.width:void 0,c=a.scale||4;return{width:o,scale:o?4:c,margin:n,color:{dark:t(a.color.dark||"#000000ff"),light:t(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}},s.getScale=function(a,n){return n.width&&n.width>=a+n.margin*2?n.width/(a+n.margin*2):n.scale},s.getImageWidth=function(a,n){const o=s.getScale(a,n);return Math.floor((a+n.margin*2)*o)},s.qrToImageData=function(a,n,o){const c=n.modules.size,l=n.modules.data,d=s.getScale(c,o),u=Math.floor((c+o.margin*2)*d),f=o.margin*d,m=[o.color.light,o.color.dark];for(let h=0;h<u;h++)for(let b=0;b<u;b++){let g=(h*u+b)*4,p=o.color.light;if(h>=f&&b>=f&&h<u-f&&b<u-f){const x=Math.floor((h-f)/d),j=Math.floor((b-f)/d);p=m[l[x*c+j]?1:0]}a[g++]=p.r,a[g++]=p.g,a[g++]=p.b,a[g]=p.a}}})(qs)),qs}var sr;function tl(){return sr||(sr=1,(function(s){const t=cn();function r(n,o,c){n.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=c,o.width=c,o.style.height=c+"px",o.style.width=c+"px"}function a(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}s.render=function(o,c,l){let d=l,u=c;typeof d>"u"&&(!c||!c.getContext)&&(d=c,c=void 0),c||(u=a()),d=t.getOptions(d);const f=t.getImageWidth(o.modules.size,d),m=u.getContext("2d"),h=m.createImageData(f,f);return t.qrToImageData(h.data,o,d),r(m,u,f),m.putImageData(h,0,0),u},s.renderToDataURL=function(o,c,l){let d=l;typeof d>"u"&&(!c||!c.getContext)&&(d=c,c=void 0),d||(d={});const u=s.render(o,c,d),f=d.type||"image/png",m=d.rendererOpts||{};return u.toDataURL(f,m.quality)}})(Os)),Os}var Ws={},tr;function rl(){if(tr)return Ws;tr=1;const s=cn();function t(n,o){const c=n.a/255,l=o+'="'+n.hex+'"';return c<1?l+" "+o+'-opacity="'+c.toFixed(2).slice(1)+'"':l}function r(n,o,c){let l=n+o;return typeof c<"u"&&(l+=" "+c),l}function a(n,o,c){let l="",d=0,u=!1,f=0;for(let m=0;m<n.length;m++){const h=Math.floor(m%o),b=Math.floor(m/o);!h&&!u&&(u=!0),n[m]?(f++,m>0&&h>0&&n[m-1]||(l+=u?r("M",h+c,.5+b+c):r("m",d,0),d=0,u=!1),h+1<o&&n[m+1]||(l+=r("h",f),f=0)):d++}return l}return Ws.render=function(o,c,l){const d=s.getOptions(c),u=o.modules.size,f=o.modules.data,m=u+d.margin*2,h=d.color.light.a?"<path "+t(d.color.light,"fill")+' d="M0 0h'+m+"v"+m+'H0z"/>':"",b="<path "+t(d.color.dark,"stroke")+' d="'+a(f,u,d.margin)+'"/>',g='viewBox="0 0 '+m+" "+m+'"',x='<svg xmlns="http://www.w3.org/2000/svg" '+(d.width?'width="'+d.width+'" height="'+d.width+'" ':"")+g+' shape-rendering="crispEdges">'+h+b+`</svg>
2056
- `;return typeof l=="function"&&l(null,x),x},Ws}var rr;function nl(){if(rr)return ke;rr=1;const s=Fi(),t=sl(),r=tl(),a=rl();function n(o,c,l,d,u){const f=[].slice.call(arguments,1),m=f.length,h=typeof f[m-1]=="function";if(!h&&!s())throw new Error("Callback required as last argument");if(h){if(m<2)throw new Error("Too few arguments provided");m===2?(u=l,l=c,c=d=void 0):m===3&&(c.getContext&&typeof u>"u"?(u=d,d=void 0):(u=d,d=l,l=c,c=void 0))}else{if(m<1)throw new Error("Too few arguments provided");return m===1?(l=c,c=d=void 0):m===2&&!c.getContext&&(d=l,l=c,c=void 0),new Promise(function(b,g){try{const p=t.create(l,d);b(o(p,c,d))}catch(p){g(p)}})}try{const b=t.create(l,d);u(null,o(b,c,d))}catch(b){u(b)}}return ke.create=t.create,ke.toCanvas=n.bind(null,r.render),ke.toDataURL=n.bind(null,r.renderToDataURL),ke.toString=n.bind(null,function(o,c,l){return a.render(o,l)}),ke}var al=nl();const ol=le.getDefaultExportFromCjs(al);function il({value:s,size:t=200,alt:r="QR code",className:a=""}){const n=i.useRef(null),[o,c]=i.useState(null);return i.useEffect(()=>{!n.current||!s||ol.toCanvas(n.current,s,{width:t,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{c(null)}).catch(l=>{c(l instanceof Error?l.message:"Failed to generate QR code")})},[s,t]),o?e.jsx("div",{className:`cedros-qr-error ${a}`,style:{width:t,height:t},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 ${a}`,role:"img","aria-label":r,style:{borderRadius:"0.5rem"}})}function tt(){const{config:s,_internal:t}=N.useCedrosLogin(),[r,a]=i.useState(null),[n,o]=i.useState("idle"),[c,l]=i.useState(null),[d,u]=i.useState(!1),[f,m]=i.useState(null),h=i.useMemo(()=>new N.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),b=i.useCallback(async()=>{u(!0),m(null);try{const v=await h.get("/mfa/status");return a(v),v}catch(v){const S=N.handleApiError(v,"Failed to get TOTP status");throw m(S),S}finally{u(!1)}},[h]),g=i.useCallback(async()=>{u(!0),m(null),o("loading");try{const v=await h.post("/mfa/setup",{});return l(v),o("setup"),v}catch(v){const S=N.handleApiError(v,"Failed to start TOTP setup");throw m(S),o("error"),S}finally{u(!1)}},[h]),p=i.useCallback(async v=>{if(!/^\d{6}$/.test(v)){const S={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw m(S),S}u(!0),m(null),o("verifying");try{await h.post("/mfa/enable",{code:v}),o("success"),a({enabled:!0,recoveryCodesRemaining:c?.recoveryCodes.length??0})}catch(S){const w=N.handleApiError(S,"Invalid verification code");throw m(w),o("error"),w}finally{u(!1)}},[h,c]),x=i.useCallback(async v=>{if(!v){const S={code:"VALIDATION_ERROR",message:"Please enter your password"};throw m(S),S}u(!0),m(null);try{await h.post("/mfa/disable",{password:v}),a({enabled:!1,recoveryCodesRemaining:0}),l(null),o("idle")}catch(S){const w=N.handleApiError(S,"Failed to disable TOTP");throw m(w),w}finally{u(!1)}},[h]),j=i.useCallback(async v=>{if(!/^\d{6}$/.test(v)){const S={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw m(S),S}u(!0),m(null);try{return await h.post("/mfa/recovery-codes/regenerate",{code:v})}catch(S){const w=N.handleApiError(S,"Failed to regenerate recovery codes");throw m(w),w}finally{u(!1)}},[h]),y=i.useCallback(()=>m(null),[]),A=i.useCallback(()=>{m(null),l(null),o("idle"),u(!1)},[]);return{status:r,setupState:n,setupData:c,isLoading:d,error:f,getStatus:b,beginSetup:g,enableTotp:p,disableTotp:x,regenerateBackupCodes:j,clearError:y,reset:A}}function dn({onSuccess:s,onCancel:t,className:r=""}){const{setupState:a,setupData:n,isLoading:o,error:c,beginSetup:l,enableTotp:d,clearError:u,reset:f}=tt(),[m,h]=i.useState("qr"),[b,g]=i.useState(""),[p,x]=i.useState(!1),[j,y]=i.useState(!1),A=i.useRef(null);i.useEffect(()=>{a==="idle"&&l().catch(()=>{})},[a,l]),i.useEffect(()=>{a==="success"&&s?.()},[a,s]);const v=async()=>{n?.secret&&(await navigator.clipboard.writeText(n.secret),x(!0),A.current!==null&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>x(!1),2e3))},S=async()=>{if(n?.recoveryCodes){const T=n.recoveryCodes.join(`
2055
+ `);const k=A(C,T,E),_=s.getSymbolSize(C),M=new a(_);return b(M,C),g(M),p(M,C),j(M,T,0),C>=7&&x(M,C),y(M,k),isNaN(L)&&(L=c.getBestMask(M,j.bind(null,M,T))),c.applyMask(L,M),j(M,T,L),{modules:M,version:C,errorCorrectionLevel:T,maskPattern:L,segments:E}}return vs.create=function(C,T){if(typeof C>"u"||C==="")throw new Error("No input text");let L=t.M,E,P;return typeof T<"u"&&(L=t.from(T.errorCorrectionLevel,t.M),E=u.from(T.version),P=c.from(T.maskPattern),T.toSJISFunc&&s.setToSJISFunction(T.toSJISFunc)),S(C,E,L,P)},vs}var Os={},qs={},Zt;function ln(){return Zt||(Zt=1,(function(s){function t(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let a=r.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+r);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(o){return[o,o]}))),a.length===6&&a.push("F","F");const n=parseInt(a.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+a.slice(0,6).join("")}}s.getOptions=function(a){a||(a={}),a.color||(a.color={});const n=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,o=a.width&&a.width>=21?a.width:void 0,c=a.scale||4;return{width:o,scale:o?4:c,margin:n,color:{dark:t(a.color.dark||"#000000ff"),light:t(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}},s.getScale=function(a,n){return n.width&&n.width>=a+n.margin*2?n.width/(a+n.margin*2):n.scale},s.getImageWidth=function(a,n){const o=s.getScale(a,n);return Math.floor((a+n.margin*2)*o)},s.qrToImageData=function(a,n,o){const c=n.modules.size,l=n.modules.data,d=s.getScale(c,o),u=Math.floor((c+o.margin*2)*d),f=o.margin*d,m=[o.color.light,o.color.dark];for(let h=0;h<u;h++)for(let b=0;b<u;b++){let g=(h*u+b)*4,p=o.color.light;if(h>=f&&b>=f&&h<u-f&&b<u-f){const x=Math.floor((h-f)/d),j=Math.floor((b-f)/d);p=m[l[x*c+j]?1:0]}a[g++]=p.r,a[g++]=p.g,a[g++]=p.b,a[g]=p.a}}})(qs)),qs}var er;function tl(){return er||(er=1,(function(s){const t=ln();function r(n,o,c){n.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=c,o.width=c,o.style.height=c+"px",o.style.width=c+"px"}function a(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}s.render=function(o,c,l){let d=l,u=c;typeof d>"u"&&(!c||!c.getContext)&&(d=c,c=void 0),c||(u=a()),d=t.getOptions(d);const f=t.getImageWidth(o.modules.size,d),m=u.getContext("2d"),h=m.createImageData(f,f);return t.qrToImageData(h.data,o,d),r(m,u,f),m.putImageData(h,0,0),u},s.renderToDataURL=function(o,c,l){let d=l;typeof d>"u"&&(!c||!c.getContext)&&(d=c,c=void 0),d||(d={});const u=s.render(o,c,d),f=d.type||"image/png",m=d.rendererOpts||{};return u.toDataURL(f,m.quality)}})(Os)),Os}var Ws={},sr;function rl(){if(sr)return Ws;sr=1;const s=ln();function t(n,o){const c=n.a/255,l=o+'="'+n.hex+'"';return c<1?l+" "+o+'-opacity="'+c.toFixed(2).slice(1)+'"':l}function r(n,o,c){let l=n+o;return typeof c<"u"&&(l+=" "+c),l}function a(n,o,c){let l="",d=0,u=!1,f=0;for(let m=0;m<n.length;m++){const h=Math.floor(m%o),b=Math.floor(m/o);!h&&!u&&(u=!0),n[m]?(f++,m>0&&h>0&&n[m-1]||(l+=u?r("M",h+c,.5+b+c):r("m",d,0),d=0,u=!1),h+1<o&&n[m+1]||(l+=r("h",f),f=0)):d++}return l}return Ws.render=function(o,c,l){const d=s.getOptions(c),u=o.modules.size,f=o.modules.data,m=u+d.margin*2,h=d.color.light.a?"<path "+t(d.color.light,"fill")+' d="M0 0h'+m+"v"+m+'H0z"/>':"",b="<path "+t(d.color.dark,"stroke")+' d="'+a(f,u,d.margin)+'"/>',g='viewBox="0 0 '+m+" "+m+'"',x='<svg xmlns="http://www.w3.org/2000/svg" '+(d.width?'width="'+d.width+'" height="'+d.width+'" ':"")+g+' shape-rendering="crispEdges">'+h+b+`</svg>
2056
+ `;return typeof l=="function"&&l(null,x),x},Ws}var tr;function nl(){if(tr)return ke;tr=1;const s=Fi(),t=sl(),r=tl(),a=rl();function n(o,c,l,d,u){const f=[].slice.call(arguments,1),m=f.length,h=typeof f[m-1]=="function";if(!h&&!s())throw new Error("Callback required as last argument");if(h){if(m<2)throw new Error("Too few arguments provided");m===2?(u=l,l=c,c=d=void 0):m===3&&(c.getContext&&typeof u>"u"?(u=d,d=void 0):(u=d,d=l,l=c,c=void 0))}else{if(m<1)throw new Error("Too few arguments provided");return m===1?(l=c,c=d=void 0):m===2&&!c.getContext&&(d=l,l=c,c=void 0),new Promise(function(b,g){try{const p=t.create(l,d);b(o(p,c,d))}catch(p){g(p)}})}try{const b=t.create(l,d);u(null,o(b,c,d))}catch(b){u(b)}}return ke.create=t.create,ke.toCanvas=n.bind(null,r.render),ke.toDataURL=n.bind(null,r.renderToDataURL),ke.toString=n.bind(null,function(o,c,l){return a.render(o,l)}),ke}var al=nl();const ol=le.getDefaultExportFromCjs(al);function il({value:s,size:t=200,alt:r="QR code",className:a=""}){const n=i.useRef(null),[o,c]=i.useState(null);return i.useEffect(()=>{!n.current||!s||ol.toCanvas(n.current,s,{width:t,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{c(null)}).catch(l=>{c(l instanceof Error?l.message:"Failed to generate QR code")})},[s,t]),o?e.jsx("div",{className:`cedros-qr-error ${a}`,style:{width:t,height:t},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 ${a}`,role:"img","aria-label":r,style:{borderRadius:"0.5rem"}})}function tt(){const{config:s,_internal:t}=N.useCedrosLogin(),[r,a]=i.useState(null),[n,o]=i.useState("idle"),[c,l]=i.useState(null),[d,u]=i.useState(!1),[f,m]=i.useState(null),h=i.useMemo(()=>new N.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),b=i.useCallback(async()=>{u(!0),m(null);try{const v=await h.get("/mfa/status");return a(v),v}catch(v){const S=N.handleApiError(v,"Failed to get TOTP status");throw m(S),S}finally{u(!1)}},[h]),g=i.useCallback(async()=>{u(!0),m(null),o("loading");try{const v=await h.post("/mfa/setup",{});return l(v),o("setup"),v}catch(v){const S=N.handleApiError(v,"Failed to start TOTP setup");throw m(S),o("error"),S}finally{u(!1)}},[h]),p=i.useCallback(async v=>{if(!/^\d{6}$/.test(v)){const S={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw m(S),S}u(!0),m(null),o("verifying");try{await h.post("/mfa/enable",{code:v}),o("success"),a({enabled:!0,recoveryCodesRemaining:c?.recoveryCodes.length??0})}catch(S){const w=N.handleApiError(S,"Invalid verification code");throw m(w),o("error"),w}finally{u(!1)}},[h,c]),x=i.useCallback(async v=>{if(!v){const S={code:"VALIDATION_ERROR",message:"Please enter your password"};throw m(S),S}u(!0),m(null);try{await h.post("/mfa/disable",{password:v}),a({enabled:!1,recoveryCodesRemaining:0}),l(null),o("idle")}catch(S){const w=N.handleApiError(S,"Failed to disable TOTP");throw m(w),w}finally{u(!1)}},[h]),j=i.useCallback(async v=>{if(!/^\d{6}$/.test(v)){const S={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw m(S),S}u(!0),m(null);try{return await h.post("/mfa/recovery-codes/regenerate",{code:v})}catch(S){const w=N.handleApiError(S,"Failed to regenerate recovery codes");throw m(w),w}finally{u(!1)}},[h]),y=i.useCallback(()=>m(null),[]),A=i.useCallback(()=>{m(null),l(null),o("idle"),u(!1)},[]);return{status:r,setupState:n,setupData:c,isLoading:d,error:f,getStatus:b,beginSetup:g,enableTotp:p,disableTotp:x,regenerateBackupCodes:j,clearError:y,reset:A}}function cn({onSuccess:s,onCancel:t,className:r=""}){const{setupState:a,setupData:n,isLoading:o,error:c,beginSetup:l,enableTotp:d,clearError:u,reset:f}=tt(),[m,h]=i.useState("qr"),[b,g]=i.useState(""),[p,x]=i.useState(!1),[j,y]=i.useState(!1),A=i.useRef(null);i.useEffect(()=>{a==="idle"&&l().catch(()=>{})},[a,l]),i.useEffect(()=>{a==="success"&&s?.()},[a,s]);const v=async()=>{n?.secret&&(await navigator.clipboard.writeText(n.secret),x(!0),A.current!==null&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>x(!1),2e3))},S=async()=>{if(n?.recoveryCodes){const T=n.recoveryCodes.join(`
2057
2057
  `);await navigator.clipboard.writeText(T)}},w=async()=>{try{await d(b)}catch{g("")}},C=()=>{f(),t?.()};return i.useEffect(()=>()=>{A.current!==null&&(window.clearTimeout(A.current),A.current=null)},[]),a==="loading"||a==="idle"&&o?e.jsx("div",{className:`cedros-totp-setup ${r}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(N.LoadingSpinner,{size:"lg",label:"Setting up two-factor authentication"})})}):a==="error"&&!n?e.jsxs("div",{className:`cedros-totp-setup ${r}`,children:[e.jsx(N.ErrorMessage,{error:c,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:C,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>l(),children:"Try again"})]})]}):a==="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:[m==="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(il,{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:v,"aria-label":"Copy secret",children:p?"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:C,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>h("backup"),children:"Continue"})]})]}),m==="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((T,L)=>e.jsx("code",{className:"cedros-totp-backup-code",children:T},L))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:S,children:"Copy all codes"}),e.jsxs("label",{className:"cedros-checkbox-label cedros-totp-confirm",children:[e.jsx("input",{type:"checkbox",className:"cedros-checkbox",checked:j,onChange:T=>y(T.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:()=>h("qr"),children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>h("verify"),disabled:!j,children:"Continue"})]})]}),m==="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(X.OtpInput,{value:b,onChange:g,onComplete:w,disabled:o,error:c?.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:()=>h("backup"),disabled:o,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:w,disabled:o||b.length!==6,children:o?e.jsxs(e.Fragment,{children:[e.jsx(N.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Verifying..."})]}):"Enable 2FA"})]})]})]}):null}function ll({onStatusChange:s,className:t=""}){const{status:r,isLoading:a,error:n,getStatus:o,disableTotp:c,regenerateBackupCodes:l,clearError:d}=tt(),[u,f]=i.useState("status"),[m,h]=i.useState(""),[b,g]=i.useState(""),[p,x]=i.useState(null),[j,y]=i.useState(!1),[A,v]=i.useState(null);i.useEffect(()=>{o().catch(()=>{})},[o]);const S=i.useCallback(()=>{f("status"),s?.(!0)},[s]),w=async()=>{y(!0),v(null);try{await c(m),f("status"),h(""),s?.(!1)}catch(L){v(L instanceof Error?L.message:"Failed to disable 2FA"),h("")}finally{y(!1)}},C=async()=>{y(!0),v(null);try{const L=await l(b);x(L.recoveryCodes),g("")}catch(L){v(L instanceof Error?L.message:"Failed to regenerate codes"),g("")}finally{y(!1)}},T=async()=>{p&&await navigator.clipboard.writeText(p.join(`
2058
- `))};return a&&!r?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(N.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):n&&!r?e.jsxs("div",{className:`cedros-totp-settings ${t}`,children:[e.jsx(N.ErrorMessage,{error:n,onDismiss:d}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>o(),children:"Retry"})]}):u==="setup"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx(dn,{onSuccess:S,onCancel:()=>f("status")})}):u==="disable"?e.jsx("div",{className:`cedros-totp-settings ${t}`,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."}),A&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(N.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:A},onDismiss:()=>v(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(X.PasswordInput,{label:"Password",placeholder:"Enter your password",value:m,onChange:L=>h(L.target.value),disabled:j,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"),h(""),v(null)},disabled:j,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:w,disabled:j||m.length===0,children:j?e.jsxs(e.Fragment,{children:[e.jsx(N.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):u==="regenerate"?p?e.jsx("div",{className:`cedros-totp-settings ${t}`,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:p.map((L,E)=>e.jsx("code",{className:"cedros-totp-backup-code",children:L},E))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:T,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"),x(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,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."}),A&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(N.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:A},onDismiss:()=>v(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(X.OtpInput,{value:b,onChange:g,onComplete:C,disabled:j,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"),g(""),v(null)},disabled:j,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:C,disabled:j||b.length!==6,children:j?e.jsxs(e.Fragment,{children:[e.jsx(N.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,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."})]}),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 cl{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async changePassword(t){try{return await this.client.post("/auth/change-password",t)}catch(r){throw N.handleApiError(r,"Failed to change password")}}async updateProfile(t){try{return await this.client.patch("/auth/me",t)}catch(r){throw N.handleApiError(r,"Failed to update profile")}}}function un(){const{config:s,authState:t,_internal:r}=N.useCedrosLogin(),[a,n]=i.useState(!1),[o,c]=i.useState(null),l=i.useMemo(()=>new cl(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),d=i.useCallback(()=>{c(null)},[]),u=i.useCallback(async m=>{if(t!=="authenticated")throw new Error("Must be authenticated to update profile");n(!0),c(null);try{return await l.updateProfile(m)}catch(h){const b=h instanceof Error?h:new Error("Failed to update profile");throw c(b),b}finally{n(!1)}},[t,l]),f=i.useCallback(async m=>{if(t!=="authenticated")throw new Error("Must be authenticated to change password");n(!0),c(null);try{await l.changePassword(m)}catch(h){const b=h instanceof Error?h:new Error("Failed to change password");throw c(b),b}finally{n(!1)}},[t,l]);return{isLoading:a,error:o,updateProfile:u,changePassword:f,clearError:d}}function dl({onPasswordChange:s,onClose:t,className:r=""}){const{user:a}=N.useAuth(),{isLoading:n,error:o,changePassword:c,clearError:l}=un(),[d,u]=i.useState("main"),[f,m]=i.useState(""),[h,b]=i.useState(""),[g,p]=i.useState(""),[x,j]=i.useState(null),[y,A]=i.useState(null),v=ns.validatePassword(h),S=h===g,w=f.length>0&&h.length>0&&g.length>0&&v.isValid&&S,C=i.useCallback(async()=>{if(w){j(null),A(null);try{await c({currentPassword:f,newPassword:h}),m(""),b(""),p(""),A("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>{u("main"),A(null)},2e3)}catch(E){j(E instanceof Error?E.message:"Failed to change password")}}},[w,f,h,c,s]),T=i.useCallback(()=>{u("main"),m(""),b(""),p(""),j(null),l()},[l]),L=()=>a?.name?a.name.split(" ").map(E=>E[0]).join("").toUpperCase().slice(0,2):a?.email?a.email[0].toUpperCase():"?";return d==="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."}),(x||o)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(N.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:x||o?.message||""},onDismiss:()=>{j(null),l()}})}),y&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),y]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:f,onChange:E=>m(E.target.value),disabled:n,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"New password",placeholder:"Enter new password",value:h,onChange:E=>b(E.target.value),disabled:n,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:g,onChange:E=>p(E.target.value),disabled:n,error:g.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:T,disabled:n,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:C,disabled:n||!w,children:n?e.jsxs(e.Fragment,{children:[e.jsx(N.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.jsx("div",{className:"cedros-profile-avatar-container",children:a?.picture?e.jsx("img",{src:a.picture,alt:a.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:L()})}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:a?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:a?.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:a?.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:()=>u("change-password"),children:"Change"})]})]}),t&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})})}function hn(){const s=N.useCedrosLoginOptional(),[t,r]=i.useState(!1),[a,n]=i.useState(null),o=i.useMemo(()=>s?new N.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=i.useCallback(()=>{n(null)},[]),l=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.post("/deposit",{amount_lamports:g})}catch(p){const x=N.handleApiError(p,"Failed to execute deposit");throw n(x.message),x}finally{r(!1)}},[o]),d=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get(`/deposit/status/${g}`)}catch(p){const x=N.handleApiError(p,"Failed to get deposit status");throw n(x.message),x}finally{r(!1)}},[o]),u=i.useCallback(async()=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get("/deposit/config")}catch(g){const p=N.handleApiError(g,"Failed to get deposit config");throw n(p.message),p}finally{r(!1)}},[o]),f=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const p=new URLSearchParams;g?.limit!==void 0&&p.set("limit",String(g.limit)),g?.offset!==void 0&&p.set("offset",String(g.offset));const x=p.toString(),j=x?`/deposits?${x}`:"/deposits";return await o.get(j)}catch(p){const x=N.handleApiError(p,"Failed to list deposits");throw n(x.message),x}finally{r(!1)}},[o]),m=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const p=new URLSearchParams({input_mint:g.inputMint,amount:String(g.amount),taker:g.taker});return await o.get(`/deposit/quote?${p}`)}catch(p){const x=N.handleApiError(p,"Failed to get deposit quote");throw n(x.message),x}finally{r(!1)}},[o]),h=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.post("/deposit/public",g)}catch(p){const x=N.handleApiError(p,"Failed to execute public deposit");throw n(x.message),x}finally{r(!1)}},[o]),b=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.post("/deposit/micro",g)}catch(p){const x=N.handleApiError(p,"Failed to execute micro deposit");throw n(x.message),x}finally{r(!1)}},[o]);return{deposit:l,getQuote:m,publicDeposit:h,microDeposit:b,getStatus:d,getConfig:u,listDeposits:f,isLoading:t,error:a,clearError:c}}function rt({tokens:s,selectedToken:t,onSelect:r,openSignal:a,placeholder:n="Select token",disabled:o=!1,className:c="",searchable:l=!0}){const[d,u]=i.useState(!1),[f,m]=i.useState(""),h=i.useRef(null),b=i.useRef(null),g=i.useMemo(()=>{if(!f.trim())return s;const y=f.toLowerCase();return s.filter(A=>A.symbol.toLowerCase().includes(y)||A.name.toLowerCase().includes(y)||A.mint.toLowerCase().includes(y))},[s,f]);i.useEffect(()=>{const y=A=>{h.current&&!h.current.contains(A.target)&&(u(!1),m(""))};if(d)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[d]),i.useEffect(()=>{d&&l&&b.current&&b.current.focus()},[d,l]),i.useEffect(()=>{a===void 0||o||(u(!0),m(""))},[a,o]);const p=i.useCallback(()=>{o||(u(y=>!y),d&&m(""))},[o,d]),x=i.useCallback(y=>{r(y),u(!1),m("")},[r]),j=i.useCallback(y=>{y.key==="Escape"?(u(!1),m("")):y.key==="Enter"&&g.length===1&&x(g[0])},[g,x]);return e.jsxs("div",{ref:h,className:`cedros-token-selector ${d?"cedros-token-selector-open":""} ${o?"cedros-token-selector-disabled":""} ${c}`,onKeyDown:j,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:p,disabled:o,"aria-haspopup":"listbox","aria-expanded":d,children:[t?e.jsxs("span",{className:"cedros-token-selector-selected",children:[t.logoUrl&&e.jsx("img",{src:t.logoUrl,alt:t.symbol,className:"cedros-token-icon",onError:y=>{y.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:t.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:n}),e.jsx("span",{className:"cedros-token-selector-arrow",children:d?"▲":"▼"})]}),d&&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:f,onChange:y=>m(y.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:g.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:g.map(y=>e.jsxs("button",{type:"button",className:`cedros-token-option ${t?.mint===y.mint?"cedros-token-option-selected":""}`,onClick:()=>x(y),role:"option","aria-selected":t?.mint===y.mint,children:[y.logoUrl&&e.jsx("img",{src:y.logoUrl,alt:y.symbol,className:"cedros-token-icon",onError:A=>{A.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:y.symbol}),e.jsx("span",{className:"cedros-token-name",children:y.name})]}),t?.mint===y.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},y.mint))})})]})]})}function cs(s,t){return t.privateDepositsEnabled&&s>=t.privateMinUsd?"private":s>=t.publicMinUsd?"public":"sol_micro"}const nt="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=",ul=1e4,ts=1e3,mn=3;function hl(s){return Number.isFinite(s)?`$${Math.round(s)}`:"$0"}function ml(s,t){switch(s){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 ${hl(t.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function at(s,t,r){return Math.min(Math.max(s,t),r)}function pl(s,t){if(t<=0)return 0;const r=at(s/t,0,1);return Math.round(Math.pow(r,1/mn)*ts)}function fl(s,t){const r=at(s/ts,0,1);return t*Math.pow(r,mn)}function pn(s){return s<10?.01:s<100?1:s<500?5:s<1e3?10:s<5e3?25:50}function gl(s){return s<1?2:0}function nr(s){const t=pn(s),r=Math.round(s/t)*t,a=gl(t);return Number(r.toFixed(a))}function ot({config:s,valueUsd:t,onChange:r,maxUsd:a=ul,disabled:n=!1,className:o=""}){const c=at(Number.isFinite(t)?t:0,0,a),l=i.useMemo(()=>cs(c,s),[c,s]),d=ml(l,s),u=pl(c,a),f=u/ts*100;return e.jsxs("div",{className:`cedros-tiered-slider ${o}`,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:c||"",onChange:m=>r(nr(parseFloat(m.target.value)||0)),placeholder:"Enter amount",disabled:n,min:0,step:pn(c),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:nt,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),d.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:d.detail})]})]}),e.jsx("input",{type:"range",min:0,max:ts,step:1,value:u,onChange:m=>r(nr(fl(parseFloat(m.target.value),a))),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"}),d.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:d.note})]})}function bl(s){return s.companyFeePercent>0||s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap"||s.feePolicy==="user_pays_privacy"}function yl(s,t,r){const{feePolicy:a,privacyFeePercent:n,swapFeePercent:o,companyFeePercent:c}=s;let l=c;return r||(a==="user_pays_all"?(l+=o,t&&(l+=n)):a==="user_pays_privacy"&&t?l+=n:a==="user_pays_swap"&&(l+=o)),l}const Ge=1e9,Ne={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:nt},Se={mint:"other",symbol:"OTHER",name:"Other",decimals:6},fn=1e4;function wl(s,t){const r=t<s.publicMinUsd,a=t>=s.privateMinUsd,n=[],o=!r&&a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(s.privacyFeeFixedLamports>0||s.privacyFeePercent>0),c=!r&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(s.swapFeeFixedLamports>0||s.swapFeePercent>0),l=s.companyFeeFixedLamports>0||s.companyFeePercent>0;if(o){const d=s.privacyFeeFixedLamports/Ge,u=s.privacyFeePercent,f=d*s.solPriceUsd,m=t*(u/100);n.push({label:"Privacy",solAmount:d,percent:u,usdAmount:f+m})}if(c){const d=s.swapFeeFixedLamports/Ge,u=s.swapFeePercent,f=d*s.solPriceUsd,m=t*(u/100);n.push({label:"Swap",solAmount:d,percent:u,usdAmount:f+m})}if(l){const d=s.companyFeeFixedLamports/Ge,u=s.companyFeePercent,f=d*s.solPriceUsd,m=t*(u/100);n.push({label:"Service",solAmount:d,percent:u,usdAmount:f+m})}return n}function gn(s,t,r){const a=wl(s,t),n=r<.01?.01:r;if(a.length===0)return`Total: $${n.toFixed(2)}`;const o=a.reduce((g,p)=>g+p.solAmount,0),c=a.reduce((g,p)=>g+p.percent,0),l={fee:7,sol:8,rate:7,usd:8},d=g=>{const p=g.label.padEnd(l.fee),x=g.solAmount.toFixed(4).padStart(6).padEnd(l.sol),j=(g.percent.toFixed(2)+"%").padStart(5).padEnd(l.rate),y=("$"+Math.max(g.usdAmount,.01).toFixed(2)).padEnd(l.usd);return`${p} │ ${x} │ ${j} │ ${y}`},u=`${"Fee".padEnd(l.fee)} │ ${"SOL".padEnd(l.sol)} │ ${"+ Rate".padEnd(l.rate)} │ ${"= Total".padEnd(l.usd)}`,f=`${"─".repeat(l.fee)}─┼─${"─".repeat(l.sol)}─┼─${"─".repeat(l.rate)}─┼─${"─".repeat(l.usd)}`,m=("$"+n.toFixed(2)).padEnd(l.usd),h=`${"TOTAL".padEnd(l.fee)} │ ${o.toFixed(4).padStart(6).padEnd(l.sol)} │ ${(c.toFixed(2)+"%").padStart(5).padEnd(l.rate)} │ ${m}`;return[u,f,...a.map(d),f,h].join(`
2059
- `)}function xl(s){const t=[],r=s.privacyFeeFixedLamports>0||s.privacyFeePercent>0,a=s.swapFeeFixedLamports>0||s.swapFeePercent>0,n=s.companyFeeFixedLamports>0||s.companyFeePercent>0;return r&&t.push("Privacy Cash fee"),a&&t.push("swap fee"),n&&t.push("company service fee"),t.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function ds(s,t){if(t<=0)return 0;const r=t<s.publicMinUsd,a=t>=s.privateMinUsd,n=yl(s,a,r);let o=s.companyFeeFixedLamports;r||(a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(o+=s.privacyFeeFixedLamports),(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(o+=s.swapFeeFixedLamports));const c=o/Ge*s.solPriceUsd,l=t*(n/100);return c+l}function bn(s,t,r){return s==="sol"?"SOL":s==="single-token"?t.symbol:r.some(n=>n.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function ar(s){return s.map(t=>t.trim()).filter(Boolean)}const yn=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function wn(s,t,r){if(yn.has(s.symbol))return 1;const a=t.tokenPrices?.[s.symbol];if(a&&a>0)return a;if(s.symbol==="SOL")return t.solPriceUsd||null;const n=r?.[s.symbol];return n&&n>0?n:null}function xn(s,t){const r=yn.has(t)?2:4;return s.toFixed(r)}function vl({config:s,currencyMode:t,depositMethod:r,tokens:a=[],defaultToken:n,minAmount:o,maxAmount:c=1e4,onSuccess:l,onError:d,onCancel:u,onUnlockRequired:f,onAuthorize:m,className:h="",showStepIndicator:b=!0,pollInterval:g=5e3,demoMode:p=!1,demoAutoConfirmMs:x,tokenPriceUsd:j,showExplainer:y=!1,siteName:A,explainerConfig:v}){const{deposit:S,getStatus:w,error:C,clearError:T}=hn(),L=N.useWallet(),E=ar(s.quickActionTokens),P=ar(s.customTokenSymbols),k=i.useMemo(()=>{const W=s.customTokens??[];if(W.length===0)return a;const V=new Set(a.map(J=>J.symbol)),K=[...a];for(const J of W)V.has(J.symbol)||(K.push({mint:J.mint,symbol:J.symbol,name:J.symbol,decimals:J.decimals,logoUrl:J.logoUrl}),V.add(J.symbol));return K},[a,s.customTokens]),_=i.useMemo(()=>{if(P.length===0)return k;const W=k.filter(V=>P.includes(V.symbol));return W.length>0?W:k},[k,P]),M=s.privateDepositsEnabled,D=r?r==="sign"&&!M?"receive":r:M&&L.hasExternalWallet?"sign":"receive",B=E[0]?k.find(W=>W.symbol===E[0]):void 0,Y=t==="sol"?Ne:t==="single-token"?B??k.find(W=>W.symbol==="USDC")??k[0]??Ne:n??B??k.find(W=>W.symbol==="USDC")??k.find(W=>W.symbol!=="SOL")??k[0]??Ne,G=i.useCallback(()=>y?"explainer":"unlock",[y]),[O,$]=i.useState(G),[I,H]=i.useState(Y),[ee,Z]=i.useState(""),[Q,R]=i.useState(null),[F,U]=i.useState(null),[q,re]=i.useState(null),[de,Fe]=i.useState(null),[Me,fe]=i.useState(!1),[us,De]=i.useState(!1),[ve,Be]=i.useState(null);i.useEffect(()=>{$(G()),H(Y),Z(""),R(null),U(null),re(null),Fe(null),fe(!1),De(!1),Be(null),T()},[t,D,Y,T,G]);const hs=o??s.privateMinSol,ms=c,ge=parseFloat(ee),z=L.status==="enrolled_locked"||L.status==="enrolled_unlocked"||L.status==="unlocked",he=z&&L.isUnlocked,ps=z&&!L.isUnlocked,ct=i.useCallback(()=>{let K=D==="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 y&&(K=[{key:"explainer",label:"Info"},...K]),K},[D,y])(),An=ct.findIndex(W=>W.key===O),dt=i.useCallback(W=>{H(W)},[]),kn=i.useCallback(async W=>{if(!m){$(D==="sign"?"confirm":"show-address");return}De(!0),U(null);try{const K=await m(W,D==="sign"?ge:null,I);re(K.sessionId),Fe(K.depositAddress),$(D==="sign"?"confirm":"show-address")}catch(V){const K=V instanceof Error?V:new Error("Authorization failed");U(K.message)}finally{De(!1)}},[m,D,ge,I]),Nn=i.useCallback(async(W,V)=>{T(),U(null),$("signing");const K=W??ge,J=V??I;if(!p){if(ps&&f){f(),$("confirm");return}if(!he){U("Wallet not ready"),$("error");return}}try{const ae=Math.floor(K*Math.pow(10,J.decimals));if(p){await new Promise(We=>setTimeout(We,1500));const qe={token:t==="sol"?null:J,amount:K,amountSmallestUnit:ae,txSignature:`demo-tx-${Date.now()}`,sessionId:q||`demo-session-${Date.now()}`,response:{sessionId:q||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:ae,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};R(qe),$("success"),l?.(qe);return}const ne=await S(ae),Oe={token:t==="sol"?null:J,amount:K,amountSmallestUnit:ae,txSignature:ne.txSignature,sessionId:ne.sessionId,response:ne,method:"sign"};R(Oe),$("success"),l?.(Oe)}catch(ae){const ne=ae instanceof Error?ae:new Error("Deposit failed");U(ne.message),$("error"),d?.(ne)}},[S,ge,I,t,p,q,he,ps,f,l,d,T]),Sn=i.useCallback(()=>{$("waiting")},[]),fs=i.useCallback(async()=>{const W=de||L.solanaPubkey;if(W)try{await navigator.clipboard.writeText(W),fe(!0),setTimeout(()=>fe(!1),2e3)}catch{const V=document.createElement("textarea");V.value=W,document.body.appendChild(V),V.select(),document.execCommand("copy"),document.body.removeChild(V),fe(!0),setTimeout(()=>fe(!1),2e3)}},[de,L.solanaPubkey]);i.useEffect(()=>{if(!(O==="confirm"||O==="show-address"||O==="waiting")||!q||p)return;let V=!1,K=0;const J=360,ae=async()=>{if(!(V||K>=J)){K++;try{const ne=await w(q);if(ne.status==="completed"||ne.status==="detected"){const Oe=ne.amountLamports?ne.amountLamports/Math.pow(10,I.decimals):0,qe=ne.amountLamports||0,We={token:t==="sol"?null:I,amount:Oe,amountSmallestUnit:qe,txSignature:ne.txSignature||"",sessionId:q,response:ne,method:"receive",depositAddress:L.solanaPubkey??void 0};R(We),$("success"),l?.(We);return}}catch{}V||setTimeout(ae,g)}};return ae(),()=>{V=!0}},[O,q,p,w,I,t,L.solanaPubkey,l,g]),i.useEffect(()=>{if(!p||!x||O!=="waiting"||D!=="receive"||!de)return;const W=window.setTimeout(()=>{const V=ve??s.privateMinUsd,K=I.symbol==="SOL"&&s.solPriceUsd>0?V/s.solPriceUsd:V,J=Math.floor(K*Math.pow(10,I.decimals)),ae={token:t==="sol"?null:I,amount:K,amountSmallestUnit:J,txSignature:`demo-tx-${Date.now()}`,sessionId:q||`demo-session-${Date.now()}`,response:{sessionId:q||`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:de??void 0};R(ae),$("success"),l?.(ae)},x);return()=>window.clearTimeout(W)},[p,x,O,D,de,ve,s,I,t,q,l]);const Cn=i.useCallback(()=>{$(G()),Z(""),R(null),U(null),T()},[G,T]);return s.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${h}`,children:[b&&O!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:ct.map((W,V)=>{const K=An>=V,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:V+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(jl,{siteName:A,config:v,depositConfig:s,currencyMode:t,token:I,tokens:_,onContinue:()=>$("unlock"),onCancel:u}),O==="unlock"&&e.jsx(Al,{token:I,tokens:_,currencyMode:t,depositMethod:D,isAuthorizing:us,error:F,onAuthorize:kn,onBack:y?()=>$("explainer"):void 0,onCancel:u}),O==="confirm"&&D==="sign"&&e.jsx(kl,{token:I,tokens:k,quickActionSymbols:E,customTokenSymbols:P,currencyMode:t,minAmount:hs,maxAmount:ms,depositAddress:de||L.solanaPubkey,walletReady:he||p,needsUnlock:ps&&!p,copied:Me,isListening:!!q&&!p,config:s,onCopy:fs,onTokenSelect:dt,onUnlockRequired:f,onConfirm:(W,V)=>Nn(W,V),onBack:()=>$("unlock"),onCancel:u}),O==="signing"&&e.jsx(Nl,{depositAddress:L.solanaPubkey}),O==="show-address"&&e.jsx(Sl,{token:I,tokens:k,quickActionSymbols:E,customTokenSymbols:P,tokenPriceUsd:j,currencyMode:t,depositAddress:de||L.solanaPubkey,copied:Me,isListening:!!q&&!p,config:s,onCopy:fs,onTokenSelect:dt,onAmountChange:Be,onSent:Sn,onBack:()=>$("unlock"),onCancel:u}),O==="waiting"&&e.jsx(Cl,{token:I,depositAddress:de||L.solanaPubkey,copied:Me,feeLine:ve?`Fees: $${Math.max(ds(s,ve),.01).toFixed(2)} total`:"Fees: calculated after deposit",onCopy:fs}),O==="success"&&Q&&e.jsx(_l,{result:Q,config:s,onNewDeposit:Cn}),O==="error"&&e.jsx(El,{error:F||C||"An error occurred",onRetry:()=>$("confirm"),onCancel:u})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${h}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function jl({siteName:s,config:t,depositConfig:r,currencyMode:a,token:n,tokens:o,onContinue:c,onCancel:l}){const d=t?.title??"How Deposits Work",u=t?.exchangeName??"Coinbase",f=X.sanitizeExternalUrl(t?.exchangeUrl)??"https://www.coinbase.com",m=t?.showExchangeSuggestion!==!1,h=bn(a,n,o),b=s?`${s} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",g=t?.body??b,p=bl(r),x=xl(r);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:d}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:g}),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:p?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:x})]})]})]}),m&&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 ",h," 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:[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:c,children:"Continue"})]})]})}function Al({token:s,tokens:t,currencyMode:r,depositMethod:a,isAuthorizing:n,error:o,onAuthorize:c,onBack:l}){const[d,u]=i.useState(""),f=bn(r,s,t),m=h=>{h.preventDefault(),d.trim()&&c(d)};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:a==="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:m,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:d,onChange:h=>u(h.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:n,autoComplete:"current-password"})]}),o&&e.jsx("p",{className:"cedros-deposit-flow-error",children:o}),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:!d.trim()||n,children:n?"Authorizing...":"Continue"})]})]})]})}function kl({token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:a,currencyMode:n,minAmount:o,maxAmount:c,depositAddress:l,walletReady:d,needsUnlock:u,copied:f,isListening:m,config:h,onCopy:b,onTokenSelect:g,onUnlockRequired:p,onConfirm:x,onBack:j}){const[y,A]=i.useState(h.privateMinUsd),[v,S]=i.useState(!1),[w,C]=i.useState(!1),[T,L]=i.useState(0),[E,P]=i.useState(null),_=cs(y,h)==="sol_micro",M=s.symbol===Se.symbol,D=i.useMemo(()=>{const F=a.length===0?t:t.filter(re=>a.includes(re.symbol)),U=F.length>0?F:t;return U.some(re=>re.symbol===Se.symbol)?U:[...U,Se]},[t,a]),B=ds(h,y),Y=B<.01?.01:B,G=M?"Fees: calculated after deposit":`Fees: $${Y.toFixed(2)} total`,O=M?"":gn(h,y,B),$=wn(_?Ne:s,h),I=$?y/$:s.symbol==="SOL"&&h.solPriceUsd>0?y/h.solPriceUsd:y,H=I?xn(I,_?"SOL":s.symbol):null,Z=y-B<=0&&y>0,Q=!M&&y>0&&!Z&&I>=o&&I<=c;i.useEffect(()=>{if(n==="multi-token")if(_&&s.symbol!=="SOL"){P(s);const F=t.find(U=>U.symbol==="SOL");F&&g(F)}else!_&&E&&s.symbol==="SOL"&&(g(E),P(null))},[_,s.symbol,n,t,g,E,s]);const R=()=>{Q&&x(I,s)};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.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(F=>{const U=t.find(re=>re.symbol===F),q=s.symbol===F;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${q?"is-active":""}`,onClick:()=>{U&&(S(!1),g(U))},disabled:!U,children:[U?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:U.logoUrl,alt:`${F} logo`}),F]},F)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${v?"is-active":""}`,onClick:()=>{S(!0),L(F=>F+1)},children:"Custom"})]}),v&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(rt,{tokens:D,selectedToken:s,onSelect:g,openSignal:T})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(ot,{config:h,valueUsd:y,onChange:A,maxUsd:fn})}),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??"--"} ${_?"SOL":s.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:f?"✓":"⧉"}),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:"↗"})]})]}),f&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),Z&&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:[G,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${w?"is-open":""}`,"data-tooltip":O,"aria-label":`Fee breakdown: ${O.replaceAll(`
2060
- `,", ")}`,"aria-expanded":w,onClick:F=>{F.stopPropagation(),C(U=>!U)},onBlur:()=>C(!1),onKeyDown:F=>{F.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 network confirmation."})]})]}),m&&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."}),p&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:p,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:j,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:R,disabled:!Q||!d||!l,children:"Deposit"})]})]})}function Nl({depositAddress:s}){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..."}),s&&e.jsxs("p",{className:"cedros-deposit-flow-signing-dest",children:["Sending to:"," ",e.jsxs("code",{children:[s.slice(0,6),"...",s.slice(-4)]})]})]})}function Sl({token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:a,tokenPriceUsd:n,currencyMode:o,depositAddress:c,copied:l,isListening:d,config:u,onCopy:f,onTokenSelect:m,onAmountChange:h,onSent:b,onBack:g}){const[p,x]=i.useState(u.privateMinUsd),[j,y]=i.useState(!1),[A,v]=i.useState(!1),[S,w]=i.useState(0),[C,T]=i.useState(null),E=cs(p,u)==="sol_micro",P=s.symbol===Se.symbol,k=i.useMemo(()=>{const I=a.length===0?t:t.filter(Z=>a.includes(Z.symbol)),H=I.length>0?I:t;return H.some(Z=>Z.symbol===Se.symbol)?H:[...H,Se]},[t,a]),_=ds(u,p),M=_<.01?.01:_,D=P?"Fees: calculated after deposit":`Fees: $${M.toFixed(2)} total`,B=P?"":gn(u,p,_),Y=P||p>0,G=wn(E?Ne:s,u,n),O=G?p/G:null,$=O?xn(O,s.symbol):null;return i.useEffect(()=>{if(o==="multi-token")if(E&&s.symbol!=="SOL"){T(s);const I=t.find(H=>H.symbol==="SOL");I&&m(I)}else!E&&C&&s.symbol==="SOL"&&(m(C),T(null))},[E,s.symbol,o,t,m,C,s]),i.useEffect(()=>{h(p)},[p,h]),c?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."}),o==="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(I=>{const H=t.find(Z=>Z.symbol===I),ee=s.symbol===I;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${ee?"is-active":""}`,onClick:()=>{H&&(y(!1),m(H))},disabled:!H,children:[H?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:H.logoUrl,alt:`${I} logo`}),I]},I)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${j?"is-active":""}`,onClick:()=>{y(!0),w(I=>I+1)},children:"Custom"})]}),j&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(rt,{tokens:k,selectedToken:s,onSelect:m,openSignal:S})})]}),!P&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit Amount"}),e.jsx(ot,{config:u,valueUsd:p,onChange:x,maxUsd:fn})]}),P&&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:P?"Send any token to this address":`Send ${$??"--"} ${E?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:c}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:f,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:[D,!P&&e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${A?"is-open":""}`,"data-tooltip":B,"aria-label":`Fee breakdown: ${B.replaceAll(`
2061
- `,", ")}`,"aria-expanded":A,onClick:I=>{I.stopPropagation(),v(H=>!H)},onBlur:()=>v(!1),onKeyDown:I=>{I.key==="Escape"&&v(!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)."})]})]}),d&&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:g,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:b,disabled:!Y,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 Cl({token:s,depositAddress:t,copied:r,feeLine:a,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:s.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."}),t&&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:[t.slice(0,6),"...",t.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/${t}`,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:a})]})]})]})]})}function _l({result:s,config:t,onNewDeposit:r}){const a=s.token??Ne,n=a.symbol==="SOL"&&t.solPriceUsd>0?s.amount*t.solPriceUsd:s.amount,o=ds(t,n),c=Math.max(n-o,0),l=o<.01?.01:o;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 ",s.amount.toLocaleString()," ",a.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[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/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[s.txSignature.slice(0,8),"...",s.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${s.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:["$",n.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:["-$",l.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:["+$",c.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 El({error:s,onRetry:t,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:s}),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:t,children:"Try Again"})]})]})}const Pl="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=",Tl="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==",Ll="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",Ml="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==",Dl="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==",Rl="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==",Il="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",Ul="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",Fl="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",Bl=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:nt},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:Rl},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:Fl},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:Ll},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:Ul},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Dl},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:Il},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Tl},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Pl},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:Ml}];function it(){const s=N.useCedrosLoginOptional(),[t,r]=i.useState(!1),[a,n]=i.useState(null),o=i.useMemo(()=>s?new N.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=i.useCallback(()=>{n(null)},[]),l=i.useCallback(async()=>{if(!o)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get("/credits/balance/sol")}catch(f){const m=N.handleApiError(f,"Failed to fetch credit balance");throw n(m.message),m}finally{r(!1)}},[o]),d=i.useCallback(async()=>{if(!o)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return(await o.get("/credits/balance")).balances}catch(f){const m=N.handleApiError(f,"Failed to fetch credit balances");throw n(m.message),m}finally{r(!1)}},[o]),u=i.useCallback(async f=>{if(!o)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{const m=new URLSearchParams;f?.currency&&m.set("currency",f.currency),f?.limit&&m.set("limit",f.limit.toString()),f?.offset&&m.set("offset",f.offset.toString());const h=m.toString(),b=h?`/credits/history?${h}`:"/credits/history";return await o.get(b)}catch(m){const h=N.handleApiError(m,"Failed to fetch transaction history");throw n(h.message),h}finally{r(!1)}},[o]);return{getBalance:l,getAllBalances:d,getHistory:u,isLoading:t,error:a,clearError:c}}function Ol({showAllCurrencies:s=!1,refreshInterval:t=0,compact:r=!1,className:a="",onLoad:n}){const{getBalance:o,getAllBalances:c,isLoading:l,error:d,clearError:u}=it(),[f,m]=i.useState([]),[h,b]=i.useState(null),g=i.useCallback(async()=>{try{if(s){const p=await c();m(p),n?.(p)}else{const p=await o();m([p]),n?.([p])}b(null)}catch(p){b(p instanceof Error?p.message:"Failed to load balance")}},[s,o,c,n]);if(i.useEffect(()=>{g()},[g]),i.useEffect(()=>{if(t<=0)return;const p=setInterval(g,t);return()=>clearInterval(p)},[t,g]),h||d)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${a}`,children:[e.jsx("p",{className:"cedros-credit-error",children:h||d}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{u(),b(null),g()},children:"Retry"})]});if(l&&f.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${a}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(r){const p=f[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${a}`,children:[p?e.jsx("span",{className:"cedros-credit-value",title:`${p.balanceLamports} lamports`,children:p.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 ${a}`,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:g,disabled:l,title:"Refresh balance",children:l?"...":"↻"})]}),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(p=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:p.currency}),e.jsx("span",{className:"cedros-credit-amount",children:p.display})]},p.currency))})]})}const $s=[{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 ql(s,t){const r=s<0,a=Math.abs(s),n=t.toUpperCase()==="SOL",c=a/Math.pow(10,n?9:6),l=r?"-":"+";return n?`${l}${c.toFixed(4)} SOL`:`${l}$${c.toFixed(2)}`}function Wl(s){const t=new Date(s),r=new Date,a=r.getTime()-t.getTime(),n=Math.floor(a/(1e3*60*60*24));if(n===0){const o=Math.floor(a/36e5);if(o===0){const c=Math.floor(a/6e4);return c<1?"Just now":`${c}m ago`}return`${o}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==r.getFullYear()?"numeric":void 0})}function $l(s){return s?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[s.toLowerCase()]||s:"Transaction"}function zl(s,t){const r=(s||"").toLowerCase();return r==="deposit"?"↓":r==="spend"||r==="usage"||r==="charge"?"↑":r==="refund"?"←":r==="bonus"||r==="credit"?"★":t?"+":"−"}function Vl({defaultTab:s="all",pageSize:t=10,refreshInterval:r=0,className:a="",onLoad:n,onTransactionClick:o}){const{getHistory:c,isLoading:l,error:d,clearError:u}=it(),[f,m]=i.useState(s),[h,b]=i.useState([]),[g,p]=i.useState(0),[x,j]=i.useState(0),[y,A]=i.useState(null),v=$s.find(k=>k.key===f)||$s[0],S=i.useMemo(()=>v.txTypes===null?h:h.filter(k=>{const _=k.txType||"";return v.txTypes.some(M=>_.toLowerCase().includes(M.toLowerCase()))}),[h,v.txTypes]),w=i.useCallback(async()=>{try{const k=await c({limit:t*3,offset:x});b(k.transactions),p(k.total),n?.(k),A(null)}catch(k){A(k instanceof Error?k.message:"Failed to load history")}},[t,x,c,n]);i.useEffect(()=>{j(0)},[f]),i.useEffect(()=>{w()},[w]),i.useEffect(()=>{if(r<=0)return;const k=setInterval(w,r);return()=>clearInterval(k)},[r,w]);const C=Math.ceil(g/t),T=Math.floor(x/t)+1,L=k=>{const _=(k-1)*t;j(Math.max(0,Math.min(_,Math.max(0,g-1))))},E=k=>{m(k)};if(y||d)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${a}`,children:[e.jsx("p",{className:"cedros-tx-error",children:y||d}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{u(),A(null),w()},children:"Retry"})]});if(l&&h.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${a}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const P=k=>k.txTypes===null?h.length:h.filter(_=>{const M=_.txType||"";return k.txTypes.some(D=>M.toLowerCase().includes(D.toLowerCase()))}).length;return e.jsxs("div",{className:`cedros-tx-history ${a}`,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:w,disabled:l,title:"Refresh",children:l?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:$s.map(k=>{const _=P(k),M=f===k.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${M?"cedros-tx-tab-active":""}`,onClick:()=>E(k.key),children:[k.label,_>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:_})]},k.key)})}),S.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 ${v.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:S.slice(0,t).map(k=>{const _=k.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${_?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>o?.(k),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),o?.(k))},role:o?"button":void 0,tabIndex:o?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${_?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:zl(k.txType,_)}),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:$l(k.txType)}),e.jsx("span",{className:`cedros-tx-amount ${_?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:ql(k.amountLamports,k.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:k.description}),e.jsx("span",{className:"cedros-tx-date",children:Wl(k.createdAt)})]})]})]},k.id)})}),C>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>L(T-1),disabled:T<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",T," of ",C]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>L(T+1),disabled:T>=C,children:"Next"})]})]})]})}function Hl({brandLogo:s,brandName:t,title:r="Welcome back",subtitle:a="Login with your Apple or Google account",termsText:n,onSuccess:o,defaultTab:c="login",children:l,className:d=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${d}`,children:[(s||t)&&e.jsxs("div",{className:"cedros-brand-header",children:[s,t&&e.jsx("span",{className:"cedros-brand-name",children:t})]}),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}),a&&e.jsx("p",{className:"cedros-full-page-subtitle",children:a})]}),l??e.jsx(as,{defaultTab:c,onSuccess:o})]}),n&&e.jsx("p",{className:"cedros-terms-footer",children:n})]})}function Ql({brandName:s="Your Brand",brandLogo:t,tagline:r="Your tagline goes here. Make it compelling.",title:a="Sign in",subtitle:n="Enter your credentials to access your account",onSuccess:o,defaultTab:c="login",children:l,className:d=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${d}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[t??e.jsx("div",{className:"cedros-split-page-logo",children:s.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:s}),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:a}),n&&e.jsx("p",{className:"cedros-split-page-subtitle",children:n}),l??e.jsx(as,{defaultTab:c,onSuccess:o})]})})]})}class Kl{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(t){throw N.handleApiError(t,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(t){throw N.handleApiError(t,"Failed to revoke sessions")}}}function Gl(){const{config:s,authState:t,_internal:r}=N.useCedrosLogin(),[a,n]=i.useState([]),[o,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useMemo(()=>new Kl(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),f=i.useCallback(async()=>{if(t!=="authenticated"){n([]);return}c(!0),d(null);try{const b=await u.listSessions();n(b)}catch(b){d(b)}finally{c(!1)}},[t,u]);i.useEffect(()=>{t==="authenticated"?f():n([])},[t,f]);const m=i.useCallback(async()=>{c(!0),d(null);try{const b=await u.revokeAllSessions();return await f(),b}catch(b){throw d(b),b}finally{c(!1)}},[u,f]),h=i.useMemo(()=>a.filter(b=>!b.isCurrent).length,[a]);return{sessions:a,isLoading:o,error:l,fetchSessions:f,revokeAllSessions:m,otherSessionCount:h}}function Yl(){const{config:s,_internal:t}=N.useCedrosLogin(),[r,a]=i.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),n=i.useMemo(()=>new qr(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),o=i.useCallback(async d=>{a(u=>({...u,isLoading:!0,error:null}));try{const u=await n.authorize(d),f={allowed:u.allowed,reason:u.reason,isLoading:!1,error:null};return a(f),f}catch(u){const f={allowed:!1,reason:void 0,isLoading:!1,error:u};return a(f),f}},[n]),c=i.useCallback(async d=>(await o(d)).allowed,[o]),l=i.useCallback(()=>{a({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:c,lastCheck:r,clearCheck:l,checkAuthorization:o}}function Jl(){const s=N.useCedrosLoginOptional(),[t,r]=i.useState(!1),[a,n]=i.useState(null),[o,c]=i.useState(null),l=i.useMemo(()=>s?new N.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),d=i.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const m=await l.get("/wallet/pending-recovery");c(m)}catch(m){const h=N.handleApiError(m,"Failed to fetch pending recovery");throw n(h.message),h}finally{r(!1)}},[l]),u=i.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const m={confirmed:!0};await l.post("/wallet/acknowledge-recovery",m),c(null)}catch(m){const h=N.handleApiError(m,"Failed to acknowledge recovery");throw n(h.message),h}finally{r(!1)}},[l]),f=i.useCallback(()=>n(null),[]);return i.useEffect(()=>{l&&s?.authState==="authenticated"&&d().catch(()=>{})},[l,s?.authState,d]),{hasPendingRecovery:o?.hasPendingRecovery??!1,recoveryType:o?.recoveryType??null,recoveryPhrase:o?.recoveryPhrase??null,expiresAt:o?.expiresAt?new Date(o.expiresAt):null,fetchPendingRecovery:d,acknowledgeRecovery:u,isLoading:t,error:a,clearError:f}}function Xl(s={}){const{onExternalSign:t}=s,{solanaPubkey:r,hasExternalWallet:a,status:n,isUnlocked:o}=N.useWallet(),{signTransaction:c,isSigning:l,error:d,clearError:u}=Pr(),f=i.useMemo(()=>a&&t?"external":n==="enrolled_locked"||n==="enrolled_unlocked"?"sss":"none",[a,t,n]),m=f!=="none",h=n==="enrolled_locked"||n==="enrolled_unlocked";return{signTransaction:i.useCallback(async(g,p)=>{if(f==="external"){if(!t)throw new Error("External wallet signing callback not provided");return t(g)}if(f==="sss"){if(!p&&!o)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return p?c(g,p):c(g)}throw new Error("No signing method available. Enroll a wallet first.")},[f,t,o,c]),signingMethod:f,canSign:m,isSigning:l,publicKey:r,hasExternalWallet:a,hasSssWallet:h,isSssUnlocked:o,error:d,clearError:u}}const lt=i.createContext(null),rs={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 vn(s,t){return jn(s,t)}function jn(s,t){const r={...s};for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const n=s[a],o=t[a];typeof n=="object"&&n!==null&&typeof o=="object"&&o!==null?r[a]=jn(n,o):o!==void 0&&(r[a]=o)}return r}function Zl({children:s,locale:t="en",translations:r}){const a=i.useMemo(()=>({t:r?vn(rs,r):rs,locale:t}),[r,t]);return e.jsx(lt.Provider,{value:a,children:s})}function ec(){return i.useContext(lt)?.t??rs}function sc(){return i.useContext(lt)?.locale??"en"}exports.AdminDepositList=Jr;exports.AdminDepositStats=Gr;exports.AdminPrivacyPeriodDeposits=Zr;exports.AdminShell=Ai;exports.AdminUserDetail=tn;exports.AdminUserList=sn;exports.AdminWithdrawalHistory=en;exports.AdminWithdrawalQueue=Xr;exports.AdminWithdrawalStats=Yr;exports.AppleLoginButton=gr;exports.AuthenticationSettings=Wr;exports.CapabilityWarning=Ea;exports.CedrosAdminDashboard=gi;exports.CreditBalance=Ol;exports.CreditSystemSettings=zr;exports.DepositFlow=vl;exports.EmailSettings=Ro;exports.EmbeddedWalletSettings=$r;exports.ErrorBoundary=xr;exports.ForgotPasswordForm=mr;exports.FullPageLayout=Hl;exports.History=Vl;exports.I18nProvider=Zl;exports.Icons=ce;exports.InviteForm=jr;exports.InviteList=Ar;exports.LoginButton=Kn;exports.LoginForm=as;exports.LoginModal=sa;exports.MemberList=vr;exports.OrgSelector=ra;exports.OrgSwitcher=ha;exports.PasskeyLoginButton=wr;exports.PasskeyPrompt=Lr;exports.PermissionsSection=rn;exports.ProfileDropdown=et;exports.RecoveryPhraseDisplay=Nr;exports.RecoveryPhraseInput=Sr;exports.ResetPasswordForm=ta;exports.SUPPORTED_TOKENS=Bl;exports.SecuritySettings=Mo;exports.ServerSettings=Vr;exports.SessionList=ja;exports.SettingsPageLayout=os;exports.SetupWizard=Br;exports.SplitPageLayout=Ql;exports.StatsBar=Ce;exports.SystemSettings=Xa;exports.TieredAmountSlider=ot;exports.TokenSelector=rt;exports.TotpSettings=ll;exports.TotpSetup=dn;exports.UserProfileSettings=dl;exports.WalletAddressRow=Ir;exports.WalletEnrollment=Er;exports.WalletManager=Ha;exports.WalletRecovery=Rr;exports.WalletStatus=Ur;exports.WalletUnlock=Mr;exports.WebhookSettings=Uo;exports.cedrosLoginPlugin=Ui;exports.defaultTranslations=rs;exports.getTierForAmount=cs;exports.mergeTranslations=vn;exports.useAdminDeposits=ye;exports.useAdminShell=ji;exports.useAdminUsers=ls;exports.useAppleAuth=pr;exports.useAuthorize=Yl;exports.useCredits=it;exports.useDeposit=hn;exports.useInvites=Qr;exports.useLocale=sc;exports.useMembers=Hr;exports.useOrgs=is;exports.usePasskeySigning=Tr;exports.usePasswordReset=Gs;exports.usePendingRecovery=Jl;exports.useProfile=un;exports.useServerFeatures=Js;exports.useSessions=Gl;exports.useSetup=Ys;exports.useSystemSettings=Ue;exports.useTotp=tt;exports.useTransactionSigning=Xl;exports.useTranslations=ec;exports.useWalletEnrollment=_r;exports.useWalletRecovery=Dr;exports.useWalletSigning=Pr;exports.useWebAuthn=yr;
2058
+ `))};return a&&!r?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(N.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):n&&!r?e.jsxs("div",{className:`cedros-totp-settings ${t}`,children:[e.jsx(N.ErrorMessage,{error:n,onDismiss:d}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>o(),children:"Retry"})]}):u==="setup"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx(cn,{onSuccess:S,onCancel:()=>f("status")})}):u==="disable"?e.jsx("div",{className:`cedros-totp-settings ${t}`,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."}),A&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(N.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:A},onDismiss:()=>v(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(X.PasswordInput,{label:"Password",placeholder:"Enter your password",value:m,onChange:L=>h(L.target.value),disabled:j,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"),h(""),v(null)},disabled:j,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:w,disabled:j||m.length===0,children:j?e.jsxs(e.Fragment,{children:[e.jsx(N.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):u==="regenerate"?p?e.jsx("div",{className:`cedros-totp-settings ${t}`,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:p.map((L,E)=>e.jsx("code",{className:"cedros-totp-backup-code",children:L},E))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:T,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"),x(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,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."}),A&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(N.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:A},onDismiss:()=>v(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(X.OtpInput,{value:b,onChange:g,onComplete:C,disabled:j,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"),g(""),v(null)},disabled:j,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:C,disabled:j||b.length!==6,children:j?e.jsxs(e.Fragment,{children:[e.jsx(N.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,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."})]}),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 cl{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async changePassword(t){try{return await this.client.post("/auth/change-password",t)}catch(r){throw N.handleApiError(r,"Failed to change password")}}async updateProfile(t){try{return await this.client.patch("/auth/me",t)}catch(r){throw N.handleApiError(r,"Failed to update profile")}}}function dn(){const{config:s,authState:t,_internal:r}=N.useCedrosLogin(),[a,n]=i.useState(!1),[o,c]=i.useState(null),l=i.useMemo(()=>new cl(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),d=i.useCallback(()=>{c(null)},[]),u=i.useCallback(async m=>{if(t!=="authenticated")throw new Error("Must be authenticated to update profile");n(!0),c(null);try{return await l.updateProfile(m)}catch(h){const b=h instanceof Error?h:new Error("Failed to update profile");throw c(b),b}finally{n(!1)}},[t,l]),f=i.useCallback(async m=>{if(t!=="authenticated")throw new Error("Must be authenticated to change password");n(!0),c(null);try{await l.changePassword(m)}catch(h){const b=h instanceof Error?h:new Error("Failed to change password");throw c(b),b}finally{n(!1)}},[t,l]);return{isLoading:a,error:o,updateProfile:u,changePassword:f,clearError:d}}function dl({onPasswordChange:s,onClose:t,className:r=""}){const{user:a}=N.useAuth(),{isLoading:n,error:o,changePassword:c,clearError:l}=dn(),[d,u]=i.useState("main"),[f,m]=i.useState(""),[h,b]=i.useState(""),[g,p]=i.useState(""),[x,j]=i.useState(null),[y,A]=i.useState(null),v=ns.validatePassword(h),S=h===g,w=f.length>0&&h.length>0&&g.length>0&&v.isValid&&S,C=i.useCallback(async()=>{if(w){j(null),A(null);try{await c({currentPassword:f,newPassword:h}),m(""),b(""),p(""),A("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>{u("main"),A(null)},2e3)}catch(E){j(E instanceof Error?E.message:"Failed to change password")}}},[w,f,h,c,s]),T=i.useCallback(()=>{u("main"),m(""),b(""),p(""),j(null),l()},[l]),L=()=>a?.name?a.name.split(" ").map(E=>E[0]).join("").toUpperCase().slice(0,2):a?.email?a.email[0].toUpperCase():"?";return d==="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."}),(x||o)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(N.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:x||o?.message||""},onDismiss:()=>{j(null),l()}})}),y&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),y]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:f,onChange:E=>m(E.target.value),disabled:n,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"New password",placeholder:"Enter new password",value:h,onChange:E=>b(E.target.value),disabled:n,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:g,onChange:E=>p(E.target.value),disabled:n,error:g.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:T,disabled:n,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:C,disabled:n||!w,children:n?e.jsxs(e.Fragment,{children:[e.jsx(N.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.jsx("div",{className:"cedros-profile-avatar-container",children:a?.picture?e.jsx("img",{src:a.picture,alt:a.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:L()})}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:a?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:a?.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:a?.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:()=>u("change-password"),children:"Change"})]})]}),t&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})})}function un(){const s=N.useCedrosLoginOptional(),[t,r]=i.useState(!1),[a,n]=i.useState(null),o=i.useMemo(()=>s?new N.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=i.useCallback(()=>{n(null)},[]),l=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.post("/deposit",{amount_lamports:g})}catch(p){const x=N.handleApiError(p,"Failed to execute deposit");throw n(x.message),x}finally{r(!1)}},[o]),d=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get(`/deposit/status/${g}`)}catch(p){const x=N.handleApiError(p,"Failed to get deposit status");throw n(x.message),x}finally{r(!1)}},[o]),u=i.useCallback(async()=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get("/deposit/config")}catch(g){const p=N.handleApiError(g,"Failed to get deposit config");throw n(p.message),p}finally{r(!1)}},[o]),f=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const p=new URLSearchParams;g?.limit!==void 0&&p.set("limit",String(g.limit)),g?.offset!==void 0&&p.set("offset",String(g.offset));const x=p.toString(),j=x?`/deposits?${x}`:"/deposits";return await o.get(j)}catch(p){const x=N.handleApiError(p,"Failed to list deposits");throw n(x.message),x}finally{r(!1)}},[o]),m=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const p=new URLSearchParams({input_mint:g.inputMint,amount:String(g.amount),taker:g.taker});return await o.get(`/deposit/quote?${p}`)}catch(p){const x=N.handleApiError(p,"Failed to get deposit quote");throw n(x.message),x}finally{r(!1)}},[o]),h=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.post("/deposit/public",g)}catch(p){const x=N.handleApiError(p,"Failed to execute public deposit");throw n(x.message),x}finally{r(!1)}},[o]),b=i.useCallback(async g=>{if(!o)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.post("/deposit/micro",g)}catch(p){const x=N.handleApiError(p,"Failed to execute micro deposit");throw n(x.message),x}finally{r(!1)}},[o]);return{deposit:l,getQuote:m,publicDeposit:h,microDeposit:b,getStatus:d,getConfig:u,listDeposits:f,isLoading:t,error:a,clearError:c}}function rt({tokens:s,selectedToken:t,onSelect:r,openSignal:a,placeholder:n="Select token",disabled:o=!1,className:c="",searchable:l=!0}){const[d,u]=i.useState(!1),[f,m]=i.useState(""),h=i.useRef(null),b=i.useRef(null),g=i.useMemo(()=>{if(!f.trim())return s;const y=f.toLowerCase();return s.filter(A=>A.symbol.toLowerCase().includes(y)||A.name.toLowerCase().includes(y)||A.mint.toLowerCase().includes(y))},[s,f]);i.useEffect(()=>{const y=A=>{h.current&&!h.current.contains(A.target)&&(u(!1),m(""))};if(d)return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[d]),i.useEffect(()=>{d&&l&&b.current&&b.current.focus()},[d,l]),i.useEffect(()=>{a===void 0||o||(u(!0),m(""))},[a,o]);const p=i.useCallback(()=>{o||(u(y=>!y),d&&m(""))},[o,d]),x=i.useCallback(y=>{r(y),u(!1),m("")},[r]),j=i.useCallback(y=>{y.key==="Escape"?(u(!1),m("")):y.key==="Enter"&&g.length===1&&x(g[0])},[g,x]);return e.jsxs("div",{ref:h,className:`cedros-token-selector ${d?"cedros-token-selector-open":""} ${o?"cedros-token-selector-disabled":""} ${c}`,onKeyDown:j,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:p,disabled:o,"aria-haspopup":"listbox","aria-expanded":d,children:[t?e.jsxs("span",{className:"cedros-token-selector-selected",children:[t.logoUrl&&e.jsx("img",{src:t.logoUrl,alt:t.symbol,className:"cedros-token-icon",onError:y=>{y.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:t.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:n}),e.jsx("span",{className:"cedros-token-selector-arrow",children:d?"▲":"▼"})]}),d&&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:f,onChange:y=>m(y.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:g.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:g.map(y=>e.jsxs("button",{type:"button",className:`cedros-token-option ${t?.mint===y.mint?"cedros-token-option-selected":""}`,onClick:()=>x(y),role:"option","aria-selected":t?.mint===y.mint,children:[y.logoUrl&&e.jsx("img",{src:y.logoUrl,alt:y.symbol,className:"cedros-token-icon",onError:A=>{A.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:y.symbol}),e.jsx("span",{className:"cedros-token-name",children:y.name})]}),t?.mint===y.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},y.mint))})})]})]})}function cs(s,t){return t.privateDepositsEnabled&&s>=t.privateMinUsd?"private":s>=t.publicMinUsd?"public":"sol_micro"}const nt="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=",ul=1e4,ts=1e3,hn=3;function hl(s){return Number.isFinite(s)?`$${Math.round(s)}`:"$0"}function ml(s,t){switch(s){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 ${hl(t.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function at(s,t,r){return Math.min(Math.max(s,t),r)}function pl(s,t){if(t<=0)return 0;const r=at(s/t,0,1);return Math.round(Math.pow(r,1/hn)*ts)}function fl(s,t){const r=at(s/ts,0,1);return t*Math.pow(r,hn)}function mn(s){return s<10?.01:s<100?1:s<500?5:s<1e3?10:s<5e3?25:50}function gl(s){return s<1?2:0}function rr(s){const t=mn(s),r=Math.round(s/t)*t,a=gl(t);return Number(r.toFixed(a))}function ot({config:s,valueUsd:t,onChange:r,maxUsd:a=ul,disabled:n=!1,className:o=""}){const c=at(Number.isFinite(t)?t:0,0,a),l=i.useMemo(()=>cs(c,s),[c,s]),d=ml(l,s),u=pl(c,a),f=u/ts*100;return e.jsxs("div",{className:`cedros-tiered-slider ${o}`,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:c||"",onChange:m=>r(rr(parseFloat(m.target.value)||0)),placeholder:"Enter amount",disabled:n,min:0,step:mn(c),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:nt,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),d.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:d.detail})]})]}),e.jsx("input",{type:"range",min:0,max:ts,step:1,value:u,onChange:m=>r(rr(fl(parseFloat(m.target.value),a))),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"}),d.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:d.note})]})}function bl(s){return s.companyFeePercent>0||s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap"||s.feePolicy==="user_pays_privacy"}function yl(s,t,r){const{feePolicy:a,privacyFeePercent:n,swapFeePercent:o,companyFeePercent:c}=s;let l=c;return r||(a==="user_pays_all"?(l+=o,t&&(l+=n)):a==="user_pays_privacy"&&t?l+=n:a==="user_pays_swap"&&(l+=o)),l}const Ge=1e9,Ne={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:nt},Se={mint:"other",symbol:"OTHER",name:"Other",decimals:6},pn=1e4;function wl(s,t){const r=t<s.publicMinUsd,a=t>=s.privateMinUsd,n=[],o=!r&&a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(s.privacyFeeFixedLamports>0||s.privacyFeePercent>0),c=!r&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(s.swapFeeFixedLamports>0||s.swapFeePercent>0),l=s.companyFeeFixedLamports>0||s.companyFeePercent>0;if(o){const d=s.privacyFeeFixedLamports/Ge,u=s.privacyFeePercent,f=d*s.solPriceUsd,m=t*(u/100);n.push({label:"Privacy",solAmount:d,percent:u,usdAmount:f+m})}if(c){const d=s.swapFeeFixedLamports/Ge,u=s.swapFeePercent,f=d*s.solPriceUsd,m=t*(u/100);n.push({label:"Swap",solAmount:d,percent:u,usdAmount:f+m})}if(l){const d=s.companyFeeFixedLamports/Ge,u=s.companyFeePercent,f=d*s.solPriceUsd,m=t*(u/100);n.push({label:"Service",solAmount:d,percent:u,usdAmount:f+m})}return n}function fn(s,t,r){const a=wl(s,t),n=r<.01?.01:r;if(a.length===0)return`Total: $${n.toFixed(2)}`;const o=a.reduce((g,p)=>g+p.solAmount,0),c=a.reduce((g,p)=>g+p.percent,0),l={fee:7,sol:8,rate:7,usd:8},d=g=>{const p=g.label.padEnd(l.fee),x=g.solAmount.toFixed(4).padStart(6).padEnd(l.sol),j=(g.percent.toFixed(2)+"%").padStart(5).padEnd(l.rate),y=("$"+Math.max(g.usdAmount,.01).toFixed(2)).padEnd(l.usd);return`${p} │ ${x} │ ${j} │ ${y}`},u=`${"Fee".padEnd(l.fee)} │ ${"SOL".padEnd(l.sol)} │ ${"+ Rate".padEnd(l.rate)} │ ${"= Total".padEnd(l.usd)}`,f=`${"─".repeat(l.fee)}─┼─${"─".repeat(l.sol)}─┼─${"─".repeat(l.rate)}─┼─${"─".repeat(l.usd)}`,m=("$"+n.toFixed(2)).padEnd(l.usd),h=`${"TOTAL".padEnd(l.fee)} │ ${o.toFixed(4).padStart(6).padEnd(l.sol)} │ ${(c.toFixed(2)+"%").padStart(5).padEnd(l.rate)} │ ${m}`;return[u,f,...a.map(d),f,h].join(`
2059
+ `)}function xl(s){const t=[],r=s.privacyFeeFixedLamports>0||s.privacyFeePercent>0,a=s.swapFeeFixedLamports>0||s.swapFeePercent>0,n=s.companyFeeFixedLamports>0||s.companyFeePercent>0;return r&&t.push("Privacy Cash fee"),a&&t.push("swap fee"),n&&t.push("company service fee"),t.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function ds(s,t){if(t<=0)return 0;const r=t<s.publicMinUsd,a=t>=s.privateMinUsd,n=yl(s,a,r);let o=s.companyFeeFixedLamports;r||(a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(o+=s.privacyFeeFixedLamports),(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(o+=s.swapFeeFixedLamports));const c=o/Ge*s.solPriceUsd,l=t*(n/100);return c+l}function gn(s,t,r){return s==="sol"?"SOL":s==="single-token"?t.symbol:r.some(n=>n.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function nr(s){return s.map(t=>t.trim()).filter(Boolean)}const bn=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function yn(s,t,r){if(bn.has(s.symbol))return 1;const a=t.tokenPrices?.[s.symbol];if(a&&a>0)return a;if(s.symbol==="SOL")return t.solPriceUsd||null;const n=r?.[s.symbol];return n&&n>0?n:null}function wn(s,t){const r=bn.has(t)?2:4;return s.toFixed(r)}function vl({config:s,currencyMode:t,depositMethod:r,tokens:a=[],defaultToken:n,minAmount:o,maxAmount:c=1e4,onSuccess:l,onError:d,onCancel:u,onUnlockRequired:f,onAuthorize:m,className:h="",showStepIndicator:b=!0,pollInterval:g=5e3,demoMode:p=!1,demoAutoConfirmMs:x,tokenPriceUsd:j,showExplainer:y=!1,siteName:A,explainerConfig:v}){const{deposit:S,getStatus:w,error:C,clearError:T}=un(),L=N.useWallet(),E=nr(s.quickActionTokens),P=nr(s.customTokenSymbols),k=i.useMemo(()=>{const W=s.customTokens??[];if(W.length===0)return a;const V=new Set(a.map(J=>J.symbol)),K=[...a];for(const J of W)V.has(J.symbol)||(K.push({mint:J.mint,symbol:J.symbol,name:J.symbol,decimals:J.decimals,logoUrl:J.logoUrl}),V.add(J.symbol));return K},[a,s.customTokens]),_=i.useMemo(()=>{if(P.length===0)return k;const W=k.filter(V=>P.includes(V.symbol));return W.length>0?W:k},[k,P]),M=s.privateDepositsEnabled,D=r?r==="sign"&&!M?"receive":r:M&&L.hasExternalWallet?"sign":"receive",B=E[0]?k.find(W=>W.symbol===E[0]):void 0,Y=t==="sol"?Ne:t==="single-token"?B??k.find(W=>W.symbol==="USDC")??k[0]??Ne:n??B??k.find(W=>W.symbol==="USDC")??k.find(W=>W.symbol!=="SOL")??k[0]??Ne,G=i.useCallback(()=>y?"explainer":"unlock",[y]),[O,$]=i.useState(G),[I,H]=i.useState(Y),[ee,Z]=i.useState(""),[Q,R]=i.useState(null),[F,U]=i.useState(null),[q,re]=i.useState(null),[de,Fe]=i.useState(null),[Me,fe]=i.useState(!1),[us,De]=i.useState(!1),[ve,Be]=i.useState(null);i.useEffect(()=>{$(G()),H(Y),Z(""),R(null),U(null),re(null),Fe(null),fe(!1),De(!1),Be(null),T()},[t,D,Y,T,G]);const hs=o??s.privateMinSol,ms=c,ge=parseFloat(ee),z=L.status==="enrolled_locked"||L.status==="enrolled_unlocked"||L.status==="unlocked",he=z&&L.isUnlocked,ps=z&&!L.isUnlocked,ct=i.useCallback(()=>{let K=D==="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 y&&(K=[{key:"explainer",label:"Info"},...K]),K},[D,y])(),jn=ct.findIndex(W=>W.key===O),dt=i.useCallback(W=>{H(W)},[]),An=i.useCallback(async W=>{if(!m){$(D==="sign"?"confirm":"show-address");return}De(!0),U(null);try{const K=await m(W,D==="sign"?ge:null,I);re(K.sessionId),Fe(K.depositAddress),$(D==="sign"?"confirm":"show-address")}catch(V){const K=V instanceof Error?V:new Error("Authorization failed");U(K.message)}finally{De(!1)}},[m,D,ge,I]),kn=i.useCallback(async(W,V)=>{T(),U(null),$("signing");const K=W??ge,J=V??I;if(!p){if(ps&&f){f(),$("confirm");return}if(!he){U("Wallet not ready"),$("error");return}}try{const ae=Math.floor(K*Math.pow(10,J.decimals));if(p){await new Promise(We=>setTimeout(We,1500));const qe={token:t==="sol"?null:J,amount:K,amountSmallestUnit:ae,txSignature:`demo-tx-${Date.now()}`,sessionId:q||`demo-session-${Date.now()}`,response:{sessionId:q||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:ae,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};R(qe),$("success"),l?.(qe);return}const ne=await S(ae),Oe={token:t==="sol"?null:J,amount:K,amountSmallestUnit:ae,txSignature:ne.txSignature,sessionId:ne.sessionId,response:ne,method:"sign"};R(Oe),$("success"),l?.(Oe)}catch(ae){const ne=ae instanceof Error?ae:new Error("Deposit failed");U(ne.message),$("error"),d?.(ne)}},[S,ge,I,t,p,q,he,ps,f,l,d,T]),Nn=i.useCallback(()=>{$("waiting")},[]),fs=i.useCallback(async()=>{const W=de||L.solanaPubkey;if(W)try{await navigator.clipboard.writeText(W),fe(!0),setTimeout(()=>fe(!1),2e3)}catch{const V=document.createElement("textarea");V.value=W,document.body.appendChild(V),V.select(),document.execCommand("copy"),document.body.removeChild(V),fe(!0),setTimeout(()=>fe(!1),2e3)}},[de,L.solanaPubkey]);i.useEffect(()=>{if(!(O==="confirm"||O==="show-address"||O==="waiting")||!q||p)return;let V=!1,K=0;const J=360,ae=async()=>{if(!(V||K>=J)){K++;try{const ne=await w(q);if(ne.status==="completed"||ne.status==="detected"){const Oe=ne.amountLamports?ne.amountLamports/Math.pow(10,I.decimals):0,qe=ne.amountLamports||0,We={token:t==="sol"?null:I,amount:Oe,amountSmallestUnit:qe,txSignature:ne.txSignature||"",sessionId:q,response:ne,method:"receive",depositAddress:L.solanaPubkey??void 0};R(We),$("success"),l?.(We);return}}catch{}V||setTimeout(ae,g)}};return ae(),()=>{V=!0}},[O,q,p,w,I,t,L.solanaPubkey,l,g]),i.useEffect(()=>{if(!p||!x||O!=="waiting"||D!=="receive"||!de)return;const W=window.setTimeout(()=>{const V=ve??s.privateMinUsd,K=I.symbol==="SOL"&&s.solPriceUsd>0?V/s.solPriceUsd:V,J=Math.floor(K*Math.pow(10,I.decimals)),ae={token:t==="sol"?null:I,amount:K,amountSmallestUnit:J,txSignature:`demo-tx-${Date.now()}`,sessionId:q||`demo-session-${Date.now()}`,response:{sessionId:q||`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:de??void 0};R(ae),$("success"),l?.(ae)},x);return()=>window.clearTimeout(W)},[p,x,O,D,de,ve,s,I,t,q,l]);const Sn=i.useCallback(()=>{$(G()),Z(""),R(null),U(null),T()},[G,T]);return s.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${h}`,children:[b&&O!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:ct.map((W,V)=>{const K=jn>=V,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:V+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(jl,{siteName:A,config:v,depositConfig:s,currencyMode:t,token:I,tokens:_,onContinue:()=>$("unlock"),onCancel:u}),O==="unlock"&&e.jsx(Al,{token:I,tokens:_,currencyMode:t,depositMethod:D,isAuthorizing:us,error:F,onAuthorize:An,onBack:y?()=>$("explainer"):void 0,onCancel:u}),O==="confirm"&&D==="sign"&&e.jsx(kl,{token:I,tokens:k,quickActionSymbols:E,customTokenSymbols:P,currencyMode:t,minAmount:hs,maxAmount:ms,depositAddress:de||L.solanaPubkey,walletReady:he||p,needsUnlock:ps&&!p,copied:Me,isListening:!!q&&!p,config:s,onCopy:fs,onTokenSelect:dt,onUnlockRequired:f,onConfirm:(W,V)=>kn(W,V),onBack:()=>$("unlock"),onCancel:u}),O==="signing"&&e.jsx(Nl,{depositAddress:L.solanaPubkey}),O==="show-address"&&e.jsx(Sl,{token:I,tokens:k,quickActionSymbols:E,customTokenSymbols:P,tokenPriceUsd:j,currencyMode:t,depositAddress:de||L.solanaPubkey,copied:Me,isListening:!!q&&!p,config:s,onCopy:fs,onTokenSelect:dt,onAmountChange:Be,onSent:Nn,onBack:()=>$("unlock"),onCancel:u}),O==="waiting"&&e.jsx(Cl,{token:I,depositAddress:de||L.solanaPubkey,copied:Me,feeLine:ve?`Fees: $${Math.max(ds(s,ve),.01).toFixed(2)} total`:"Fees: calculated after deposit",onCopy:fs}),O==="success"&&Q&&e.jsx(_l,{result:Q,config:s,onNewDeposit:Sn}),O==="error"&&e.jsx(El,{error:F||C||"An error occurred",onRetry:()=>$("confirm"),onCancel:u})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${h}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function jl({siteName:s,config:t,depositConfig:r,currencyMode:a,token:n,tokens:o,onContinue:c,onCancel:l}){const d=t?.title??"How Deposits Work",u=t?.exchangeName??"Coinbase",f=X.sanitizeExternalUrl(t?.exchangeUrl)??"https://www.coinbase.com",m=t?.showExchangeSuggestion!==!1,h=gn(a,n,o),b=s?`${s} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",g=t?.body??b,p=bl(r),x=xl(r);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:d}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:g}),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:p?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:x})]})]})]}),m&&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 ",h," 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:[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:c,children:"Continue"})]})]})}function Al({token:s,tokens:t,currencyMode:r,depositMethod:a,isAuthorizing:n,error:o,onAuthorize:c,onBack:l}){const[d,u]=i.useState(""),f=gn(r,s,t),m=h=>{h.preventDefault(),d.trim()&&c(d)};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:a==="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:m,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:d,onChange:h=>u(h.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:n,autoComplete:"current-password"})]}),o&&e.jsx("p",{className:"cedros-deposit-flow-error",children:o}),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:!d.trim()||n,children:n?"Authorizing...":"Continue"})]})]})]})}function kl({token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:a,currencyMode:n,minAmount:o,maxAmount:c,depositAddress:l,walletReady:d,needsUnlock:u,copied:f,isListening:m,config:h,onCopy:b,onTokenSelect:g,onUnlockRequired:p,onConfirm:x,onBack:j}){const[y,A]=i.useState(h.privateMinUsd),[v,S]=i.useState(!1),[w,C]=i.useState(!1),[T,L]=i.useState(0),[E,P]=i.useState(null),_=cs(y,h)==="sol_micro",M=s.symbol===Se.symbol,D=i.useMemo(()=>{const F=a.length===0?t:t.filter(re=>a.includes(re.symbol)),U=F.length>0?F:t;return U.some(re=>re.symbol===Se.symbol)?U:[...U,Se]},[t,a]),B=ds(h,y),Y=B<.01?.01:B,G=M?"Fees: calculated after deposit":`Fees: $${Y.toFixed(2)} total`,O=M?"":fn(h,y,B),$=yn(_?Ne:s,h),I=$?y/$:s.symbol==="SOL"&&h.solPriceUsd>0?y/h.solPriceUsd:y,H=I?wn(I,_?"SOL":s.symbol):null,Z=y-B<=0&&y>0,Q=!M&&y>0&&!Z&&I>=o&&I<=c;i.useEffect(()=>{if(n==="multi-token")if(_&&s.symbol!=="SOL"){P(s);const F=t.find(U=>U.symbol==="SOL");F&&g(F)}else!_&&E&&s.symbol==="SOL"&&(g(E),P(null))},[_,s.symbol,n,t,g,E,s]);const R=()=>{Q&&x(I,s)};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.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(F=>{const U=t.find(re=>re.symbol===F),q=s.symbol===F;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${q?"is-active":""}`,onClick:()=>{U&&(S(!1),g(U))},disabled:!U,children:[U?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:U.logoUrl,alt:`${F} logo`}),F]},F)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${v?"is-active":""}`,onClick:()=>{S(!0),L(F=>F+1)},children:"Custom"})]}),v&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(rt,{tokens:D,selectedToken:s,onSelect:g,openSignal:T})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(ot,{config:h,valueUsd:y,onChange:A,maxUsd:pn})}),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??"--"} ${_?"SOL":s.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:f?"✓":"⧉"}),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:"↗"})]})]}),f&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),Z&&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:[G,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${w?"is-open":""}`,"data-tooltip":O,"aria-label":`Fee breakdown: ${O.replaceAll(`
2060
+ `,", ")}`,"aria-expanded":w,onClick:F=>{F.stopPropagation(),C(U=>!U)},onBlur:()=>C(!1),onKeyDown:F=>{F.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 network confirmation."})]})]}),m&&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."}),p&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:p,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:j,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:R,disabled:!Q||!d||!l,children:"Deposit"})]})]})}function Nl({depositAddress:s}){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..."}),s&&e.jsxs("p",{className:"cedros-deposit-flow-signing-dest",children:["Sending to:"," ",e.jsxs("code",{children:[s.slice(0,6),"...",s.slice(-4)]})]})]})}function Sl({token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:a,tokenPriceUsd:n,currencyMode:o,depositAddress:c,copied:l,isListening:d,config:u,onCopy:f,onTokenSelect:m,onAmountChange:h,onSent:b,onBack:g}){const[p,x]=i.useState(u.privateMinUsd),[j,y]=i.useState(!1),[A,v]=i.useState(!1),[S,w]=i.useState(0),[C,T]=i.useState(null),E=cs(p,u)==="sol_micro",P=s.symbol===Se.symbol,k=i.useMemo(()=>{const I=a.length===0?t:t.filter(Z=>a.includes(Z.symbol)),H=I.length>0?I:t;return H.some(Z=>Z.symbol===Se.symbol)?H:[...H,Se]},[t,a]),_=ds(u,p),M=_<.01?.01:_,D=P?"Fees: calculated after deposit":`Fees: $${M.toFixed(2)} total`,B=P?"":fn(u,p,_),Y=P||p>0,G=yn(E?Ne:s,u,n),O=G?p/G:null,$=O?wn(O,s.symbol):null;return i.useEffect(()=>{if(o==="multi-token")if(E&&s.symbol!=="SOL"){T(s);const I=t.find(H=>H.symbol==="SOL");I&&m(I)}else!E&&C&&s.symbol==="SOL"&&(m(C),T(null))},[E,s.symbol,o,t,m,C,s]),i.useEffect(()=>{h(p)},[p,h]),c?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."}),o==="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(I=>{const H=t.find(Z=>Z.symbol===I),ee=s.symbol===I;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${ee?"is-active":""}`,onClick:()=>{H&&(y(!1),m(H))},disabled:!H,children:[H?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:H.logoUrl,alt:`${I} logo`}),I]},I)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${j?"is-active":""}`,onClick:()=>{y(!0),w(I=>I+1)},children:"Custom"})]}),j&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(rt,{tokens:k,selectedToken:s,onSelect:m,openSignal:S})})]}),!P&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit Amount"}),e.jsx(ot,{config:u,valueUsd:p,onChange:x,maxUsd:pn})]}),P&&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:P?"Send any token to this address":`Send ${$??"--"} ${E?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:c}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:f,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:[D,!P&&e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${A?"is-open":""}`,"data-tooltip":B,"aria-label":`Fee breakdown: ${B.replaceAll(`
2061
+ `,", ")}`,"aria-expanded":A,onClick:I=>{I.stopPropagation(),v(H=>!H)},onBlur:()=>v(!1),onKeyDown:I=>{I.key==="Escape"&&v(!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)."})]})]}),d&&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:g,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:b,disabled:!Y,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 Cl({token:s,depositAddress:t,copied:r,feeLine:a,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:s.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."}),t&&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:[t.slice(0,6),"...",t.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/${t}`,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:a})]})]})]})]})}function _l({result:s,config:t,onNewDeposit:r}){const a=s.token??Ne,n=a.symbol==="SOL"&&t.solPriceUsd>0?s.amount*t.solPriceUsd:s.amount,o=ds(t,n),c=Math.max(n-o,0),l=o<.01?.01:o;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 ",s.amount.toLocaleString()," ",a.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[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/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[s.txSignature.slice(0,8),"...",s.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${s.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:["$",n.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:["-$",l.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:["+$",c.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 El({error:s,onRetry:t,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:s}),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:t,children:"Try Again"})]})]})}const Pl="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=",Tl="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==",Ll="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",Ml="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==",Dl="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==",Rl="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==",Il="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",Ul="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",Fl="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",Bl=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:nt},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:Rl},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:Fl},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:Ll},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:Ul},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Dl},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:Il},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Tl},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Pl},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:Ml}];function it(){const s=N.useCedrosLoginOptional(),[t,r]=i.useState(!1),[a,n]=i.useState(null),o=i.useMemo(()=>s?new N.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=i.useCallback(()=>{n(null)},[]),l=i.useCallback(async()=>{if(!o)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await o.get("/credits/balance/sol")}catch(f){const m=N.handleApiError(f,"Failed to fetch credit balance");throw n(m.message),m}finally{r(!1)}},[o]),d=i.useCallback(async()=>{if(!o)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return(await o.get("/credits/balance")).balances}catch(f){const m=N.handleApiError(f,"Failed to fetch credit balances");throw n(m.message),m}finally{r(!1)}},[o]),u=i.useCallback(async f=>{if(!o)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{const m=new URLSearchParams;f?.currency&&m.set("currency",f.currency),f?.limit&&m.set("limit",f.limit.toString()),f?.offset&&m.set("offset",f.offset.toString());const h=m.toString(),b=h?`/credits/history?${h}`:"/credits/history";return await o.get(b)}catch(m){const h=N.handleApiError(m,"Failed to fetch transaction history");throw n(h.message),h}finally{r(!1)}},[o]);return{getBalance:l,getAllBalances:d,getHistory:u,isLoading:t,error:a,clearError:c}}function Ol({showAllCurrencies:s=!1,refreshInterval:t=0,compact:r=!1,className:a="",onLoad:n}){const{getBalance:o,getAllBalances:c,isLoading:l,error:d,clearError:u}=it(),[f,m]=i.useState([]),[h,b]=i.useState(null),g=i.useCallback(async()=>{try{if(s){const p=await c();m(p),n?.(p)}else{const p=await o();m([p]),n?.([p])}b(null)}catch(p){b(p instanceof Error?p.message:"Failed to load balance")}},[s,o,c,n]);if(i.useEffect(()=>{g()},[g]),i.useEffect(()=>{if(t<=0)return;const p=setInterval(g,t);return()=>clearInterval(p)},[t,g]),h||d)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${a}`,children:[e.jsx("p",{className:"cedros-credit-error",children:h||d}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{u(),b(null),g()},children:"Retry"})]});if(l&&f.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${a}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(r){const p=f[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${a}`,children:[p?e.jsx("span",{className:"cedros-credit-value",title:`${p.balanceLamports} lamports`,children:p.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 ${a}`,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:g,disabled:l,title:"Refresh balance",children:l?"...":"↻"})]}),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(p=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:p.currency}),e.jsx("span",{className:"cedros-credit-amount",children:p.display})]},p.currency))})]})}const $s=[{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 ql(s,t){const r=s<0,a=Math.abs(s),n=t.toUpperCase()==="SOL",c=a/Math.pow(10,n?9:6),l=r?"-":"+";return n?`${l}${c.toFixed(4)} SOL`:`${l}$${c.toFixed(2)}`}function Wl(s){const t=new Date(s),r=new Date,a=r.getTime()-t.getTime(),n=Math.floor(a/(1e3*60*60*24));if(n===0){const o=Math.floor(a/36e5);if(o===0){const c=Math.floor(a/6e4);return c<1?"Just now":`${c}m ago`}return`${o}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==r.getFullYear()?"numeric":void 0})}function $l(s){return s?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[s.toLowerCase()]||s:"Transaction"}function zl(s,t){const r=(s||"").toLowerCase();return r==="deposit"?"↓":r==="spend"||r==="usage"||r==="charge"?"↑":r==="refund"?"←":r==="bonus"||r==="credit"?"★":t?"+":"−"}function Vl({defaultTab:s="all",pageSize:t=10,refreshInterval:r=0,className:a="",onLoad:n,onTransactionClick:o}){const{getHistory:c,isLoading:l,error:d,clearError:u}=it(),[f,m]=i.useState(s),[h,b]=i.useState([]),[g,p]=i.useState(0),[x,j]=i.useState(0),[y,A]=i.useState(null),v=$s.find(k=>k.key===f)||$s[0],S=i.useMemo(()=>v.txTypes===null?h:h.filter(k=>{const _=k.txType||"";return v.txTypes.some(M=>_.toLowerCase().includes(M.toLowerCase()))}),[h,v.txTypes]),w=i.useCallback(async()=>{try{const k=await c({limit:t*3,offset:x});b(k.transactions),p(k.total),n?.(k),A(null)}catch(k){A(k instanceof Error?k.message:"Failed to load history")}},[t,x,c,n]);i.useEffect(()=>{j(0)},[f]),i.useEffect(()=>{w()},[w]),i.useEffect(()=>{if(r<=0)return;const k=setInterval(w,r);return()=>clearInterval(k)},[r,w]);const C=Math.ceil(g/t),T=Math.floor(x/t)+1,L=k=>{const _=(k-1)*t;j(Math.max(0,Math.min(_,Math.max(0,g-1))))},E=k=>{m(k)};if(y||d)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${a}`,children:[e.jsx("p",{className:"cedros-tx-error",children:y||d}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{u(),A(null),w()},children:"Retry"})]});if(l&&h.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${a}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const P=k=>k.txTypes===null?h.length:h.filter(_=>{const M=_.txType||"";return k.txTypes.some(D=>M.toLowerCase().includes(D.toLowerCase()))}).length;return e.jsxs("div",{className:`cedros-tx-history ${a}`,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:w,disabled:l,title:"Refresh",children:l?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:$s.map(k=>{const _=P(k),M=f===k.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${M?"cedros-tx-tab-active":""}`,onClick:()=>E(k.key),children:[k.label,_>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:_})]},k.key)})}),S.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 ${v.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:S.slice(0,t).map(k=>{const _=k.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${_?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>o?.(k),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),o?.(k))},role:o?"button":void 0,tabIndex:o?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${_?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:zl(k.txType,_)}),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:$l(k.txType)}),e.jsx("span",{className:`cedros-tx-amount ${_?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:ql(k.amountLamports,k.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:k.description}),e.jsx("span",{className:"cedros-tx-date",children:Wl(k.createdAt)})]})]})]},k.id)})}),C>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>L(T-1),disabled:T<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",T," of ",C]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>L(T+1),disabled:T>=C,children:"Next"})]})]})]})}function Hl({brandLogo:s,brandName:t,title:r="Welcome back",subtitle:a="Login with your Apple or Google account",termsText:n,onSuccess:o,defaultTab:c="login",children:l,className:d=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${d}`,children:[(s||t)&&e.jsxs("div",{className:"cedros-brand-header",children:[s,t&&e.jsx("span",{className:"cedros-brand-name",children:t})]}),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}),a&&e.jsx("p",{className:"cedros-full-page-subtitle",children:a})]}),l??e.jsx(as,{defaultTab:c,onSuccess:o})]}),n&&e.jsx("p",{className:"cedros-terms-footer",children:n})]})}function Ql({brandName:s="Your Brand",brandLogo:t,tagline:r="Your tagline goes here. Make it compelling.",title:a="Sign in",subtitle:n="Enter your credentials to access your account",onSuccess:o,defaultTab:c="login",children:l,className:d=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${d}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[t??e.jsx("div",{className:"cedros-split-page-logo",children:s.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:s}),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:a}),n&&e.jsx("p",{className:"cedros-split-page-subtitle",children:n}),l??e.jsx(as,{defaultTab:c,onSuccess:o})]})})]})}class Kl{client;constructor(t,r,a,n){this.client=new N.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:a,getAccessToken:n})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(t){throw N.handleApiError(t,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(t){throw N.handleApiError(t,"Failed to revoke sessions")}}}function Gl(){const{config:s,authState:t,_internal:r}=N.useCedrosLogin(),[a,n]=i.useState([]),[o,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useMemo(()=>new Kl(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),f=i.useCallback(async()=>{if(t!=="authenticated"){n([]);return}c(!0),d(null);try{const b=await u.listSessions();n(b)}catch(b){d(b)}finally{c(!1)}},[t,u]);i.useEffect(()=>{t==="authenticated"?f():n([])},[t,f]);const m=i.useCallback(async()=>{c(!0),d(null);try{const b=await u.revokeAllSessions();return await f(),b}catch(b){throw d(b),b}finally{c(!1)}},[u,f]),h=i.useMemo(()=>a.filter(b=>!b.isCurrent).length,[a]);return{sessions:a,isLoading:o,error:l,fetchSessions:f,revokeAllSessions:m,otherSessionCount:h}}function Yl(){const{config:s,_internal:t}=N.useCedrosLogin(),[r,a]=i.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),n=i.useMemo(()=>new Or(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),o=i.useCallback(async d=>{a(u=>({...u,isLoading:!0,error:null}));try{const u=await n.authorize(d),f={allowed:u.allowed,reason:u.reason,isLoading:!1,error:null};return a(f),f}catch(u){const f={allowed:!1,reason:void 0,isLoading:!1,error:u};return a(f),f}},[n]),c=i.useCallback(async d=>(await o(d)).allowed,[o]),l=i.useCallback(()=>{a({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:c,lastCheck:r,clearCheck:l,checkAuthorization:o}}function Jl(){const s=N.useCedrosLoginOptional(),[t,r]=i.useState(!1),[a,n]=i.useState(null),[o,c]=i.useState(null),l=i.useMemo(()=>s?new N.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),d=i.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const m=await l.get("/wallet/pending-recovery");c(m)}catch(m){const h=N.handleApiError(m,"Failed to fetch pending recovery");throw n(h.message),h}finally{r(!1)}},[l]),u=i.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const m={confirmed:!0};await l.post("/wallet/acknowledge-recovery",m),c(null)}catch(m){const h=N.handleApiError(m,"Failed to acknowledge recovery");throw n(h.message),h}finally{r(!1)}},[l]),f=i.useCallback(()=>n(null),[]);return i.useEffect(()=>{l&&s?.authState==="authenticated"&&d().catch(()=>{})},[l,s?.authState,d]),{hasPendingRecovery:o?.hasPendingRecovery??!1,recoveryType:o?.recoveryType??null,recoveryPhrase:o?.recoveryPhrase??null,expiresAt:o?.expiresAt?new Date(o.expiresAt):null,fetchPendingRecovery:d,acknowledgeRecovery:u,isLoading:t,error:a,clearError:f}}function Xl(s={}){const{onExternalSign:t}=s,{solanaPubkey:r,hasExternalWallet:a,status:n,isUnlocked:o}=N.useWallet(),{signTransaction:c,isSigning:l,error:d,clearError:u}=Er(),f=i.useMemo(()=>a&&t?"external":n==="enrolled_locked"||n==="enrolled_unlocked"?"sss":"none",[a,t,n]),m=f!=="none",h=n==="enrolled_locked"||n==="enrolled_unlocked";return{signTransaction:i.useCallback(async(g,p)=>{if(f==="external"){if(!t)throw new Error("External wallet signing callback not provided");return t(g)}if(f==="sss"){if(!p&&!o)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return p?c(g,p):c(g)}throw new Error("No signing method available. Enroll a wallet first.")},[f,t,o,c]),signingMethod:f,canSign:m,isSigning:l,publicKey:r,hasExternalWallet:a,hasSssWallet:h,isSssUnlocked:o,error:d,clearError:u}}const lt=i.createContext(null),rs={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 xn(s,t){return vn(s,t)}function vn(s,t){const r={...s};for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const n=s[a],o=t[a];typeof n=="object"&&n!==null&&typeof o=="object"&&o!==null?r[a]=vn(n,o):o!==void 0&&(r[a]=o)}return r}function Zl({children:s,locale:t="en",translations:r}){const a=i.useMemo(()=>({t:r?xn(rs,r):rs,locale:t}),[r,t]);return e.jsx(lt.Provider,{value:a,children:s})}function ec(){return i.useContext(lt)?.t??rs}function sc(){return i.useContext(lt)?.locale??"en"}exports.AdminDepositList=Yr;exports.AdminDepositStats=Kr;exports.AdminPrivacyPeriodDeposits=Xr;exports.AdminShell=Ai;exports.AdminUserDetail=sn;exports.AdminUserList=en;exports.AdminWithdrawalHistory=Zr;exports.AdminWithdrawalQueue=Jr;exports.AdminWithdrawalStats=Gr;exports.AppleLoginButton=fr;exports.AuthenticationSettings=qr;exports.CapabilityWarning=_a;exports.CedrosAdminDashboard=fi;exports.CreditBalance=Ol;exports.CreditSystemSettings=$r;exports.DepositFlow=vl;exports.EmailSettings=Do;exports.EmbeddedWalletSettings=Wr;exports.ErrorBoundary=wr;exports.ForgotPasswordForm=hr;exports.FullPageLayout=Hl;exports.History=Vl;exports.I18nProvider=Zl;exports.Icons=ce;exports.InviteForm=vr;exports.InviteList=jr;exports.LoginButton=Qn;exports.LoginForm=as;exports.LoginModal=ea;exports.MemberList=xr;exports.OrgSelector=ta;exports.OrgSwitcher=ua;exports.PasskeyLoginButton=yr;exports.PasskeyPrompt=Tr;exports.PermissionsSection=tn;exports.ProfileDropdown=et;exports.RecoveryPhraseDisplay=kr;exports.RecoveryPhraseInput=Nr;exports.ResetPasswordForm=sa;exports.SUPPORTED_TOKENS=Bl;exports.SecuritySettings=Lo;exports.ServerSettings=zr;exports.SessionList=va;exports.SettingsPageLayout=os;exports.SetupWizard=Fr;exports.SplitPageLayout=Ql;exports.StatsBar=Ce;exports.SystemSettings=Ja;exports.TieredAmountSlider=ot;exports.TokenSelector=rt;exports.TotpSettings=ll;exports.TotpSetup=cn;exports.UserProfileSettings=dl;exports.WalletAddressRow=Rr;exports.WalletEnrollment=_r;exports.WalletManager=Va;exports.WalletRecovery=Dr;exports.WalletStatus=Ir;exports.WalletUnlock=Lr;exports.WebhookSettings=Io;exports.cedrosLoginPlugin=Ui;exports.defaultTranslations=rs;exports.getTierForAmount=cs;exports.mergeTranslations=xn;exports.useAdminDeposits=ye;exports.useAdminShell=vi;exports.useAdminUsers=ls;exports.useAppleAuth=mr;exports.useAuthorize=Yl;exports.useCredits=it;exports.useDeposit=un;exports.useInvites=Hr;exports.useLocale=sc;exports.useMembers=Vr;exports.useOrgs=is;exports.usePasskeySigning=Pr;exports.usePasswordReset=Gs;exports.usePendingRecovery=Jl;exports.useProfile=dn;exports.useServerFeatures=Js;exports.useSessions=Gl;exports.useSetup=Ys;exports.useSystemSettings=Ue;exports.useTotp=tt;exports.useTransactionSigning=Xl;exports.useTranslations=ec;exports.useWalletEnrollment=Cr;exports.useWalletRecovery=Mr;exports.useWalletSigning=Er;exports.useWebAuthn=br;