auramaxx 0.0.8 → 0.0.9

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 (60) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +37 -37
  3. package/.next/app-path-routes-manifest.json +7 -7
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/prerender-manifest.json +30 -30
  6. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  7. package/.next/server/app/_not-found.html +1 -1
  8. package/.next/server/app/_not-found.rsc +1 -1
  9. package/.next/server/app/api/[...doc]/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/api/agent-requests/route_client-reference-manifest.js +1 -1
  11. package/.next/server/app/api/apps/install/route_client-reference-manifest.js +1 -1
  12. package/.next/server/app/api/apps/manifests/route_client-reference-manifest.js +1 -1
  13. package/.next/server/app/api/apps/static/[...path]/route_client-reference-manifest.js +1 -1
  14. package/.next/server/app/api/docs/plain/route_client-reference-manifest.js +1 -1
  15. package/.next/server/app/api/events/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/page_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
  18. package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/version/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/workspace/[id]/apps/[wid]/route_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/workspace/[id]/apps/route_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/workspace/[id]/export/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/workspace/[id]/route_client-reference-manifest.js +1 -1
  24. package/.next/server/app/api/workspace/config/route_client-reference-manifest.js +1 -1
  25. package/.next/server/app/api/workspace/import/route_client-reference-manifest.js +1 -1
  26. package/.next/server/app/api/workspace/route_client-reference-manifest.js +1 -1
  27. package/.next/server/app/app-legacy-do-not-use/page_client-reference-manifest.js +1 -1
  28. package/.next/server/app/app-legacy-do-not-use.html +1 -1
  29. package/.next/server/app/app-legacy-do-not-use.rsc +1 -1
  30. package/.next/server/app/approve/[actionId]/page_client-reference-manifest.js +1 -1
  31. package/.next/server/app/docs/[...doc]/page_client-reference-manifest.js +1 -1
  32. package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  33. package/.next/server/app/health/page_client-reference-manifest.js +1 -1
  34. package/.next/server/app/health.html +1 -1
  35. package/.next/server/app/health.rsc +1 -1
  36. package/.next/server/app/hello/page_client-reference-manifest.js +1 -1
  37. package/.next/server/app/hello.html +1 -1
  38. package/.next/server/app/hello.rsc +1 -1
  39. package/.next/server/app/index.html +1 -1
  40. package/.next/server/app/index.rsc +2 -2
  41. package/.next/server/app/page.js +1 -1
  42. package/.next/server/app/page_client-reference-manifest.js +1 -1
  43. package/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  44. package/.next/server/app/privacy.html +1 -1
  45. package/.next/server/app/privacy.rsc +1 -1
  46. package/.next/server/app/share/[token]/page_client-reference-manifest.js +1 -1
  47. package/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  48. package/.next/server/app/terms.html +1 -1
  49. package/.next/server/app/terms.rsc +1 -1
  50. package/.next/server/app-paths-manifest.json +7 -7
  51. package/.next/server/pages/404.html +1 -1
  52. package/.next/server/pages/500.html +1 -1
  53. package/.next/server/server-reference-manifest.json +1 -1
  54. package/.next/static/chunks/app/{page-52f5307c8de15a0f.js → page-202668d41c2b1c70.js} +1 -1
  55. package/.next/trace +4 -4
  56. package/package.json +1 -1
  57. package/src/components/vault/CredentialVault.tsx +4 -3
  58. package/src/server/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
  59. /package/.next/static/{ZzQRBK0AIpWkCI8_z1OA2 → D6gXZ612zYsWYHv6fu0JE}/_buildManifest.js +0 -0
  60. /package/.next/static/{ZzQRBK0AIpWkCI8_z1OA2 → D6gXZ612zYsWYHv6fu0JE}/_ssgManifest.js +0 -0
@@ -56,7 +56,7 @@ ${this.parser.parse(a)}</blockquote>
56
56
  ${a}</tr>
57
57
  `}tablecell(a){let b=this.parser.parseInline(a.tokens),c=a.header?"th":"td";return(a.align?`<${c} align="${a.align}">`:`<${c}>`)+b+`</${c}>
58
58
  `}strong({tokens:a}){return`<strong>${this.parser.parseInline(a)}</strong>`}em({tokens:a}){return`<em>${this.parser.parseInline(a)}</em>`}codespan({text:a}){return`<code>${bd(a,!0)}</code>`}br(a){return"<br>"}del({tokens:a}){return`<del>${this.parser.parseInline(a)}</del>`}link({href:a,title:b,tokens:c}){let d=this.parser.parseInline(c),e=be(a);if(null===e)return d;let f='<a href="'+(a=e)+'"';return b&&(f+=' title="'+bd(b)+'"'),f+=">"+d+"</a>"}image({href:a,title:b,text:c,tokens:d}){d&&(c=this.parser.parseInline(d,this.parser.textRenderer));let e=be(a);if(null===e)return bd(c);a=e;let f=`<img src="${a}" alt="${c}"`;return b&&(f+=` title="${bd(b)}"`),f+=">"}text(a){return"tokens"in a&&a.tokens?this.parser.parseInline(a.tokens):"escaped"in a&&a.escaped?a.text:bd(a.text)}},bl=class{strong({text:a}){return a}em({text:a}){return a}codespan({text:a}){return a}del({text:a}){return a}html({text:a}){return a}text({text:a}){return a}link({text:a}){return""+a}image({text:a}){return""+a}br(){return""}checkbox({raw:a}){return a}},bm=class a{options;renderer;textRenderer;constructor(a){this.options=a||ak,this.options.renderer=this.options.renderer||new bk,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new bl}static parse(b,c){return new a(c).parse(b)}static parseInline(b,c){return new a(c).parseInline(b)}parse(a){let b="";for(let c=0;c<a.length;c++){let d=a[c];if(this.options.extensions?.renderers?.[d.type]){let a=this.options.extensions.renderers[d.type].call({parser:this},d);if(!1!==a||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(d.type)){b+=a||"";continue}}switch(d.type){case"space":b+=this.renderer.space(d);break;case"hr":b+=this.renderer.hr(d);break;case"heading":b+=this.renderer.heading(d);break;case"code":b+=this.renderer.code(d);break;case"table":b+=this.renderer.table(d);break;case"blockquote":b+=this.renderer.blockquote(d);break;case"list":b+=this.renderer.list(d);break;case"checkbox":b+=this.renderer.checkbox(d);break;case"html":b+=this.renderer.html(d);break;case"def":b+=this.renderer.def(d);break;case"paragraph":b+=this.renderer.paragraph(d);break;case"text":b+=this.renderer.text(d);break;default:{let a='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw Error(a)}}}return b}parseInline(a,b=this.renderer){let c="";for(let d=0;d<a.length;d++){let e=a[d];if(this.options.extensions?.renderers?.[e.type]){let a=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==a||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(e.type)){c+=a||"";continue}}switch(e.type){case"escape":case"text":c+=b.text(e);break;case"html":c+=b.html(e);break;case"link":c+=b.link(e);break;case"image":c+=b.image(e);break;case"checkbox":c+=b.checkbox(e);break;case"strong":c+=b.strong(e);break;case"em":c+=b.em(e);break;case"codespan":c+=b.codespan(e);break;case"br":c+=b.br(e);break;case"del":c+=b.del(e);break;default:{let a='Token with "'+e.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw Error(a)}}}return c}},bn=class{options;block;constructor(a){this.options=a||ak}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(a){return a}postprocess(a){return a}processAllTokens(a){return a}emStrongMask(a){return a}provideLexer(){return this.block?bj.lex:bj.lexInline}provideParser(){return this.block?bm.parse:bm.parseInline}},bo=new class{defaults=aj();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=bm;Renderer=bk;TextRenderer=bl;Lexer=bj;Tokenizer=bi;Hooks=bn;constructor(...a){this.use(...a)}walkTokens(a,b){let c=[];for(let d of a)switch(c=c.concat(b.call(this,d)),d.type){case"table":for(let a of d.header)c=c.concat(this.walkTokens(a.tokens,b));for(let a of d.rows)for(let d of a)c=c.concat(this.walkTokens(d.tokens,b));break;case"list":c=c.concat(this.walkTokens(d.items,b));break;default:{let a=d;this.defaults.extensions?.childTokens?.[a.type]?this.defaults.extensions.childTokens[a.type].forEach(d=>{let e=a[d].flat(1/0);c=c.concat(this.walkTokens(e,b))}):a.tokens&&(c=c.concat(this.walkTokens(a.tokens,b)))}}return c}use(...a){let b=this.defaults.extensions||{renderers:{},childTokens:{}};return a.forEach(a=>{let c={...a};if(c.async=this.defaults.async||c.async||!1,a.extensions&&(a.extensions.forEach(a=>{if(!a.name)throw Error("extension name required");if("renderer"in a){let c=b.renderers[a.name];c?b.renderers[a.name]=function(...b){let d=a.renderer.apply(this,b);return!1===d&&(d=c.apply(this,b)),d}:b.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||"block"!==a.level&&"inline"!==a.level)throw Error("extension level must be 'block' or 'inline'");let c=b[a.level];c?c.unshift(a.tokenizer):b[a.level]=[a.tokenizer],a.start&&("block"===a.level?b.startBlock?b.startBlock.push(a.start):b.startBlock=[a.start]:"inline"===a.level&&(b.startInline?b.startInline.push(a.start):b.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(b.childTokens[a.name]=a.childTokens)}),c.extensions=b),a.renderer){let b=this.defaults.renderer||new bk(this.defaults);for(let c in a.renderer){if(!(c in b))throw Error(`renderer '${c}' does not exist`);if(["options","parser"].includes(c))continue;let d=a.renderer[c],e=b[c];b[c]=(...a)=>{let c=d.apply(b,a);return!1===c&&(c=e.apply(b,a)),c||""}}c.renderer=b}if(a.tokenizer){let b=this.defaults.tokenizer||new bi(this.defaults);for(let c in a.tokenizer){if(!(c in b))throw Error(`tokenizer '${c}' does not exist`);if(["options","rules","lexer"].includes(c))continue;let d=a.tokenizer[c],e=b[c];b[c]=(...a)=>{let c=d.apply(b,a);return!1===c&&(c=e.apply(b,a)),c}}c.tokenizer=b}if(a.hooks){let b=this.defaults.hooks||new bn;for(let c in a.hooks){if(!(c in b))throw Error(`hook '${c}' does not exist`);if(["options","block"].includes(c))continue;let d=a.hooks[c],e=b[c];bn.passThroughHooks.has(c)?b[c]=a=>{if(this.defaults.async&&bn.passThroughHooksRespectAsync.has(c))return(async()=>{let c=await d.call(b,a);return e.call(b,c)})();let f=d.call(b,a);return e.call(b,f)}:b[c]=(...a)=>{if(this.defaults.async)return(async()=>{let c=await d.apply(b,a);return!1===c&&(c=await e.apply(b,a)),c})();let c=d.apply(b,a);return!1===c&&(c=e.apply(b,a)),c}}c.hooks=b}if(a.walkTokens){let b=this.defaults.walkTokens,d=a.walkTokens;c.walkTokens=function(a){let c=[];return c.push(d.call(this,a)),b&&(c=c.concat(b.call(this,a))),c}}this.defaults={...this.defaults,...c}}),this}setOptions(a){return this.defaults={...this.defaults,...a},this}lexer(a,b){return bj.lex(a,b??this.defaults)}parser(a,b){return bm.parse(a,b??this.defaults)}parseMarkdown(a){return(b,c)=>{let d={...c},e={...this.defaults,...d},f=this.onError(!!e.silent,!!e.async);if(!0===this.defaults.async&&!1===d.async)return f(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof b>"u"||null===b)return f(Error("marked(): input parameter is undefined or null"));if("string"!=typeof b)return f(Error("marked(): input parameter is of type "+Object.prototype.toString.call(b)+", string expected"));if(e.hooks&&(e.hooks.options=e,e.hooks.block=a),e.async)return(async()=>{let c=e.hooks?await e.hooks.preprocess(b):b,d=await (e.hooks?await e.hooks.provideLexer():a?bj.lex:bj.lexInline)(c,e),f=e.hooks?await e.hooks.processAllTokens(d):d;e.walkTokens&&await Promise.all(this.walkTokens(f,e.walkTokens));let g=await (e.hooks?await e.hooks.provideParser():a?bm.parse:bm.parseInline)(f,e);return e.hooks?await e.hooks.postprocess(g):g})().catch(f);try{e.hooks&&(b=e.hooks.preprocess(b));let c=(e.hooks?e.hooks.provideLexer():a?bj.lex:bj.lexInline)(b,e);e.hooks&&(c=e.hooks.processAllTokens(c)),e.walkTokens&&this.walkTokens(c,e.walkTokens);let d=(e.hooks?e.hooks.provideParser():a?bm.parse:bm.parseInline)(c,e);return e.hooks&&(d=e.hooks.postprocess(d)),d}catch(a){return f(a)}}}onError(a,b){return c=>{if(c.message+=`
59
- Please report this to https://github.com/markedjs/marked.`,a){let a="<p>An error occurred:</p><pre>"+bd(c.message+"",!0)+"</pre>";return b?Promise.resolve(a):a}if(b)return Promise.reject(c);throw c}}};function bp(a,b){return bo.parse(a,b)}bp.options=bp.setOptions=function(a){return bo.setOptions(a),bp.defaults=bo.defaults,ak=bp.defaults,bp},bp.getDefaults=aj,bp.defaults=ak,bp.use=function(...a){return bo.use(...a),bp.defaults=bo.defaults,ak=bp.defaults,bp},bp.walkTokens=function(a,b){return bo.walkTokens(a,b)},bp.parseInline=bo.parseInline,bp.Parser=bm,bp.parser=bm.parse,bp.Renderer=bk,bp.TextRenderer=bl,bp.Lexer=bj,bp.lexer=bj.lex,bp.Tokenizer=bi,bp.Hooks=bn,bp.parse=bp,bp.options,bp.setOptions,bp.use,bp.walkTokens,bp.parseInline,bm.parse,bj.lex;let bq=({label:a,value:b,copyValue:c,trailingValue:f,credentialId:g,fieldKey:h,isSensitive:i,onShowLargeType:j,sensitiveInteractionMode:k="default",actionsPosition:l="left",showActionsInHoverCopyMode:m=!1,sensitiveClickBehavior:o="reveal",disableLargeType:p=!1,renderMarkdown:q=!1})=>{let[r,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(!1),[x,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)(null),[F,G]=(0,e.useState)(!1),H=(0,e.useRef)(null),I=(0,e.useRef)(null),J=(0,e.useRef)(null),K="hover-copy"===k||"markdown-hover-copy"===k,L="markdown-hover-copy"===k,M="hover-copy"===k,N=!K&&"copy"===o,O=!K||m,P=(0,e.useMemo)(()=>{if(!L||null==x)return"";let a=x.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return bp.parse(a,{async:!1,breaks:!0})},[L,x]),Q=(0,e.useMemo)(()=>{if(!q||!b)return"";let a=b.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return bp.parse(a,{async:!1,breaks:!0})},[q,b]);(0,e.useEffect)(()=>()=>{I.current&&clearTimeout(I.current),J.current&&clearTimeout(J.current)},[]),(0,e.useEffect)(()=>{u(!1),w(!1),A(null),E(null),G(!1),I.current&&clearTimeout(I.current)},[g,h]);let R=(0,e.useCallback)(()=>{u(!0),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>u(!1),2e3)},[]),S=(0,e.useCallback)(a=>{A(a),w(!0),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{w(!1),A(null)},3e4)},[]),T=(0,e.useCallback)(async()=>{if(null!=x)return x;try{let a=await s.FH.post(s.jI.Wallet,`/credentials/${g}/read`),b=await (0,t.DC)(a.encrypted),c=JSON.parse(b),d="string"==typeof c.type?c.type:"",e=(0,y.Dw)(d,h),f=c.fields?.find(a=>(0,y.Dw)(d,a.key)===e||h===y.l3&&"value"===a.key);if(!f)return null;return f.value}catch{return null}},[g,h,x]),U=(0,e.useCallback)(async()=>{if(null!=x)return x;C(!0),E(null);try{let a=await T();return null==a&&E("Field not found"),a}catch{return E("Decryption failed -- try re-unlocking"),null}finally{C(!1)}},[T,x]),V=(0,e.useCallback)(async()=>{if(B)return;G(!1);let a=await T();null!=a&&(navigator.clipboard.writeText(a),R())},[T,B,R]),W=(0,e.useCallback)(async()=>{if(B||v&&null!=x)return;G(!1);let a=await U();null!=a&&S(a)},[U,B,S,v,x]),X=(0,e.useCallback)(()=>{w(!1),A(null),I.current&&clearTimeout(I.current)},[]),Y=(0,e.useCallback)(async()=>{G(!1);let a=await T();null!=a&&j(a)},[T,j]),Z=(0,e.useCallback)(()=>{let a=c??b;a&&(navigator.clipboard.writeText(a),R())},[c,b,R]),$=(0,e.useCallback)(()=>{b&&(G(!1),j(b))},[j,b]),_=(0,e.useCallback)(async()=>{if(!K||B)return;let a=x;null==a&&null!=(a=await U())&&A(a),null!=a&&(M&&S(a),navigator.clipboard.writeText(a),R())},[U,B,K,M,R,S,x]),aa=(0,e.useCallback)(a=>{if(!M&&!N){if(a.stopPropagation(),K)return void _();W()}},[_,W,K,M,N]);if(!i){let c=(0,d.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,d.jsxs)("button",{type:"button",onClick:a=>{a.stopPropagation(),Z()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,d.jsx)(ae.A,{size:10}),r?"Copied":"Copy"]}),(0,d.jsx)("button",{ref:H,onClick:a=>{a.stopPropagation(),G(!F)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":`Field actions for ${a}`,children:(0,d.jsx)(af.A,{size:12})}),(0,d.jsx)(z.AM,{isOpen:F,onClose:()=>G(!1),anchorEl:H.current,anchor:"right",children:(0,d.jsxs)("div",{className:"flex flex-col gap-1 min-w-[160px]",children:[(0,d.jsxs)("button",{onClick:Z,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ae.A,{size:10}),"Copy"]}),(0,d.jsxs)("button",{onClick:$,disabled:!b||p,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors disabled:opacity-40",children:[(0,d.jsx)(ag,{size:10}),"Show in large type"]})]})})]});return q&&b?(0,d.jsxs)("div",{className:"flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors group items-start",onClick:Z,children:["left"===l&&c,(0,d.jsx)("div",{className:"w-24 shrink-0",children:(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:r?"Copied":a})}),(0,d.jsx)("div",{className:"basis-full lg:basis-auto lg:flex-1 min-w-0 prose-mono max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",dangerouslySetInnerHTML:{__html:Q}}),"right"===l&&c]}):(0,d.jsxs)("div",{className:"flex flex-wrap lg:flex-nowrap items-center gap-x-3 gap-y-1 py-2 px-2 cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors group",onClick:Z,children:["left"===l&&c,(0,d.jsx)("div",{className:"w-24 shrink-0",children:(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:a})}),(0,d.jsxs)("div",{className:"basis-full lg:basis-auto lg:flex-1 min-w-0 min-h-[24px] flex items-center",children:[(0,d.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:r?"Copied":b||"--"}),f]}),"right"===l&&c]})}let ab=O?(0,d.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,d.jsxs)("button",{type:"button",onClick:a=>{a.stopPropagation(),V()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,d.jsx)(ae.A,{size:10}),r?"Copied":"Copy"]}),(0,d.jsx)("button",{ref:H,onClick:a=>{a.stopPropagation(),G(!F)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":`Field actions for ${a}`,children:(0,d.jsx)(af.A,{size:12})}),(0,d.jsx)(z.AM,{isOpen:F,onClose:()=>G(!1),anchorEl:H.current,anchor:"right",children:(0,d.jsxs)("div",{className:"flex flex-col gap-1 min-w-[170px]",children:[(0,d.jsxs)("button",{onClick:V,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ae.A,{size:10}),"Copy"]}),!K&&!v&&(0,d.jsxs)("button",{onClick:W,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ah.A,{size:10}),"Reveal"]}),!K&&v&&(0,d.jsxs)("button",{onClick:X,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ai.A,{size:10}),"Hide"]}),!p&&(0,d.jsxs)("button",{onClick:Y,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ag,{size:10}),"Show in large type"]})]})})]}):null;if(L){let b=(0,d.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,d.jsxs)("button",{type:"button",onClick:a=>{a.stopPropagation(),V()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,d.jsx)(ae.A,{size:10}),r?"Copied":"Copy"]}),(0,d.jsx)("button",{ref:H,onClick:a=>{a.stopPropagation(),G(!F)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":`Field actions for ${a}`,children:(0,d.jsx)(af.A,{size:12})}),(0,d.jsx)(z.AM,{isOpen:F,onClose:()=>G(!1),anchorEl:H.current,anchor:"right",children:(0,d.jsxs)("div",{className:"flex flex-col gap-1 min-w-[170px]",children:[(0,d.jsxs)("button",{onClick:V,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ae.A,{size:10}),"Copy"]}),v?(0,d.jsxs)("button",{onClick:X,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ai.A,{size:10}),"Hide"]}):(0,d.jsxs)("button",{onClick:W,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ah.A,{size:10}),"Reveal"]})]})})]});return(0,d.jsxs)("div",{"data-testid":`credential-field-row-${h}`,className:"flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 group transition-colors cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] items-start",onClick:()=>{v&&null!=x?V():W()},children:["left"===l&&b,(0,d.jsx)("div",{className:"w-24 shrink-0",children:(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:r?"Copied":a})}),(0,d.jsx)("div",{"data-testid":`credential-field-value-${h}`,className:"basis-full lg:basis-auto lg:flex-1 min-w-0",children:D?(0,d.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-danger,#ef4444)]",children:D}):B?(0,d.jsx)(n.A,{size:12,className:"animate-spin text-[var(--color-text-muted,#6b7280)]"}):v&&null!=x?(0,d.jsx)("div",{className:"prose-mono max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",dangerouslySetInnerHTML:{__html:P}}):(0,d.jsx)("span",{className:"font-mono text-[11px] text-[var(--color-text-muted,#6b7280)] tracking-wider",children:"••••••••"})}),"right"===l&&b]})}return(0,d.jsxs)("div",{"data-testid":`credential-field-row-${h}`,className:`flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 group transition-colors rounded-sm items-center ${M||N?"cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)]":""}`,onClick:()=>{if(M)return void _();N&&V()},children:["left"===l&&ab,(0,d.jsx)("div",{className:"w-24 shrink-0",children:(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:a})}),(0,d.jsx)("div",{"data-testid":`credential-field-value-${h}`,className:`basis-full lg:basis-auto lg:flex-1 min-w-0 transition-colors rounded-sm ${K?"":"cursor-pointer"} ${M||N?"min-h-[24px] flex items-center":"hover:bg-[var(--color-background-alt,#f4f4f5)] min-h-[24px] flex items-center"} px-1 py-0.5`,onClick:aa,children:D?(0,d.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-danger,#ef4444)]",children:D}):B?(0,d.jsx)(n.A,{size:12,className:"animate-spin text-[var(--color-text-muted,#6b7280)]"}):M?v&&null!=x?(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:x}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),X()},className:"shrink-0 text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:(0,d.jsx)(ai.A,{size:12})})]}):(0,d.jsxs)("div",{className:"w-full",children:[(0,d.jsx)("div",{"data-testid":`credential-field-barcode-${h}`,className:"h-4 w-full bg-[repeating-linear-gradient(90deg,var(--color-text,#000),var(--color-text,#000)_1px,transparent_1px,transparent_3px)] opacity-30"}),(0,d.jsx)("div",{className:"mt-1 h-1.5 w-full",style:{backgroundImage:"repeating-linear-gradient(45deg, var(--color-text, #000), var(--color-text, #000) 5px, transparent 5px, transparent 10px)",opacity:.1}}),(0,d.jsx)("div",{className:"mt-1 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] tracking-wider uppercase",children:r?"Copied":"Click to reveal and copy"})]}):K?(0,d.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-wider uppercase",children:r?"Copied":null!=x?"Hover then click to copy":"Decrypting"}):v&&null!=x?(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:x}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),X()},className:"shrink-0 text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:(0,d.jsx)(ai.A,{size:12})})]}):(0,d.jsx)("span",{className:"font-mono text-[11px] text-[var(--color-text-muted,#6b7280)] tracking-wider",children:r?"Copied":"••••••••"})}),"right"===l&&ab]})},br=({credentialId:a})=>{let[b,c]=(0,e.useState)(null),[f,g]=(0,e.useState)(30),[h,i]=(0,e.useState)(null),j=(0,e.useCallback)(async()=>{try{let b=await s.FH.post(s.jI.Wallet,`/credentials/${a}/totp`);b.success&&b.code?(c(b.code),g(b.remaining),i(!0)):i(!1)}catch{i(!1)}},[a]);if((0,e.useEffect)(()=>{j()},[j]),(0,e.useEffect)(()=>{if(!0!==h)return;let a=setInterval(()=>{g(a=>a<=1?(j(),30):a-1)},1e3);return()=>clearInterval(a)},[h,j]),null===h||!1===h)return null;let k=f<=5,l=b?`${b.slice(0,3)} ${b.slice(3)}`:"--- ---",m=f/30;return(0,d.jsx)("div",{className:"space-y-0.5","data-testid":"totp-display",children:(0,d.jsx)(bq,{label:"2FA Code",value:l,copyValue:b??void 0,credentialId:a,fieldKey:"totp_code",isSensitive:!1,trailingValue:(0,d.jsxs)("div",{className:"ml-2 flex items-center gap-1.5",children:[(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 18 18",className:"shrink-0",style:{transform:"rotate(-90deg)"},children:[(0,d.jsx)("circle",{cx:"9",cy:"9",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-[var(--color-border,#d4d4d8)]",opacity:"0.3"}),(0,d.jsx)("circle",{cx:"9",cy:"9",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeDasharray:`${43.98*m} 43.98`,strokeLinecap:"round",className:k?"text-[var(--color-danger,#ef4444)]":"text-[var(--color-accent,#ccff00)]"})]}),(0,d.jsxs)("span",{className:`font-mono text-[9px] ${k?"text-[var(--color-danger,#ef4444)]":"text-[var(--color-text-faint,#9ca3af)]"}`,children:[f,"s"]})]}),disableLargeType:!0,onShowLargeType:()=>{}})})},bs=({isOpen:a,onClose:b,value:c})=>{let[f,g]=(0,e.useState)(!1),h=(0,e.useRef)(null),i=Array.from(c??""),j=(0,e.useCallback)(async()=>{try{await navigator.clipboard.writeText(c),g(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>g(!1),2e3)}catch{}},[c]);return(0,e.useEffect)(()=>(a||g(!1),()=>{h.current&&clearTimeout(h.current)}),[a]),(0,d.jsx)(z.aF,{isOpen:a,onClose:b,title:"Expanded Value",size:"lg",contentClassName:"!p-0",footer:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:b,children:"Cancel"}),(0,d.jsx)(z.$n,{variant:"primary",size:"sm",onClick:()=>{j()},children:f?"COPIED":"COPY"})]}),children:(0,d.jsxs)("div",{className:"w-full min-h-[360px] px-6 py-8 flex flex-col items-center justify-center text-center",children:[(0,d.jsx)("div",{className:"w-full max-w-[900px] max-h-[70vh] overflow-auto px-1",children:(0,d.jsx)("div",{className:"grid gap-2 [grid-template-columns:repeat(auto-fit,minmax(56px,1fr))]",children:i.map((a,b)=>(0,d.jsxs)("div",{"data-testid":`large-type-char-${b+1}`,className:"rounded-sm border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#ffffff)] px-1 py-2",children:[(0,d.jsx)("div",{className:"font-mono text-3xl font-bold leading-none text-[var(--color-text,#0a0a0a)] select-all",children:(a=>" "===a?"␠":"\n"===a?"↵":" "===a?"⇥":a)(a)}),(0,d.jsx)("div",{"data-testid":`large-type-index-${b+1}`,className:"mt-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:b+1})]},`${b}-${a}`))})}),(0,d.jsx)("div",{className:"mt-8 font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-faint,#9ca3af)]",children:"Use copy to move this value to clipboard"})]})})};var bt=c(38442),bu=c(71613);let bv=[{value:"15m",label:"15 Minutes"},{value:"1h",label:"1 Hour"},{value:"24h",label:"24 Hours"},{value:"7d",label:"7 Days"},{value:"30d",label:"30 Days"}],bw=[{value:"anyone",label:"Anyone with link"},{value:"password",label:"Set password"}],bx=({isOpen:a,onClose:b,credentialId:c,credentialName:f})=>{let[g,h]=(0,e.useState)("24h"),[i,j]=(0,e.useState)("anyone"),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)(!1),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(null);(0,e.useEffect)(()=>{a&&(u(null),p(!1),w(""),D(null),y(!1))},[a]);let E=()=>"password"!==i||k.trim()?null:"Password is required when access mode is Set password",F=async()=>{u(null);let a=E();if(a)return void u(a);try{r(!0),p(!1);let a=await s.FH.post(s.jI.Wallet,"/credential-shares/gist",{credentialId:c,expiresAfter:g,accessMode:i,oneTimeOnly:m,shareBaseUrl:window.location.origin,..."password"===i?{password:k}:{}});w(a.gist.url),await navigator.clipboard.writeText(a.gist.url),p(!0),setTimeout(()=>p(!1),2e3)}catch{u('Failed to create secret gist. Check "gh auth status" in terminal. If needed, run "gh auth login".')}finally{r(!1)}},G=async()=>{D(null);let a=E();if(a)return void D(a);try{let a;B(!0);let b=(a=(await s.FH.post(s.jI.Wallet,"/credential-shares",{credentialId:c,expiresAfter:g,accessMode:i,oneTimeOnly:m,..."password"===i?{password:k}:{}})).share.token,`${window.location.origin}/share/${a}`);await navigator.clipboard.writeText(b),y(!0),setTimeout(()=>y(!1),2e3)}catch(a){D(a instanceof Error?a.message:"Failed to generate share link")}finally{B(!1)}},H=()=>{u(null),p(!1),r(!1),w(""),D(null),y(!1),B(!1),b()};return(0,d.jsx)(z.aF,{isOpen:a,onClose:H,title:`Sharing ${f}`,icon:(0,d.jsx)(bt.A,{size:16,className:"text-[var(--color-text,#0a0a0a)]"}),size:"md",footer:(0,d.jsx)("div",{className:"flex items-center justify-end gap-2",children:(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:H,children:"CLOSE"})}),children:(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"GitHub Gist (Recommended)"}),(0,d.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:["Check ",(0,d.jsx)("span",{className:"text-[var(--color-text,#0a0a0a)]",children:"`gh auth status`"})," first; run ",(0,d.jsx)("span",{className:"text-[var(--color-text,#0a0a0a)]",children:"`gh auth login`"})," only if needed."]}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[v?(0,d.jsx)("a",{href:v,target:"_blank",rel:"noreferrer",className:"flex-1 min-w-0 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] truncate hover:underline",title:v,children:v}):(0,d.jsx)("div",{className:"flex-1 min-w-0 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] truncate",children:"Click SHARE GIST to generate a link."}),(0,d.jsxs)(z.$n,{variant:"primary",size:"sm",onClick:F,loading:q,className:"shrink-0 whitespace-nowrap",children:[o?(0,d.jsx)(bu.A,{size:10}):(0,d.jsx)(ae.A,{size:10}),o?"COPIED":"SHARE GIST"]})]}),t&&(0,d.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-danger,#ef4444)]",children:t})]}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"Share Link (Local)"}),(0,d.jsx)(z.UM,{label:"Link Expires After",options:bv,value:g,onChange:a=>h(a),compact:!0}),(0,d.jsx)(z.UM,{label:"Available To",options:bw,value:i,onChange:a=>j(a),compact:!0}),"password"===i&&(0,d.jsx)(z.ks,{label:"Share Password",type:"password",value:k,onChange:a=>l(a.target.value),placeholder:"Enter password",compact:!0}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsxs)("label",{className:"flex flex-1 min-w-0 items-center gap-2 cursor-pointer",children:[(0,d.jsx)("input",{type:"checkbox",checked:m,onChange:a=>n(a.target.checked),className:"accent-[var(--color-accent,#ccff00)]"}),(0,d.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text,#0a0a0a)] truncate",children:"Can only be viewed one time"})]}),(0,d.jsxs)(z.$n,{variant:"primary",size:"sm",onClick:G,loading:A,className:"shrink-0 whitespace-nowrap",children:[x?(0,d.jsx)(bu.A,{size:10}):(0,d.jsx)(ae.A,{size:10}),x?"COPIED":"COPY LINK"]})]}),C&&(0,d.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-danger,#ef4444)]",children:C})]})]})})};var by=c(78583);let bz=({walletLink:a})=>{let[b,c]=(0,e.useState)(null),[f,g]=(0,e.useState)(!0),[h,i]=(0,e.useState)(!1),j=a.chain.toLowerCase();(0,e.useEffect)(()=>{let b=!0;return(async()=>{try{let d=((await s.FH.get(s.jI.Wallet,"/wallets")).wallets||[]).find(b=>b.address.toLowerCase()===a.walletAddress.toLowerCase()&&b.chain.toLowerCase()===j)||null;b&&c(d)}catch{b&&c(null)}finally{b&&g(!1)}})(),()=>{b=!1}},[a.walletAddress,j,a.chain]);let k=(0,e.useMemo)(()=>b?.name||b?.label||a.label||"Linked Wallet",[b,a.label]);return(0,d.jsxs)("div",{className:"mt-2 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background-alt,#f4f4f5)] p-3",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsxs)("div",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] inline-flex items-center gap-1",children:[(0,d.jsx)(E.A,{size:11})," Linked Wallet"]}),(0,d.jsxs)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:[a.tier," \xb7 ",a.chain]})]}),(0,d.jsx)("div",{className:"font-mono text-[11px] text-[var(--color-text,#0a0a0a)] mb-1",children:k}),(0,d.jsx)("div",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] mb-2 break-all",children:a.walletAddress}),f?(0,d.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:"Loading wallet state…"}):b?(0,d.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-success,#22c55e)] mb-2",children:["Wallet resolved",b.balance?` \xb7 Balance: ${b.balance}`:""]}):(0,d.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-warning,#f59e0b)] mb-2",children:"Stale link: wallet not found in current wallet list"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("button",{type:"button",className:"px-2 py-1 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px]",onClick:async()=>{await navigator.clipboard.writeText(a.walletAddress),i(!0),setTimeout(()=>i(!1),1200)},children:(0,d.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,d.jsx)(ae.A,{size:10})," ",h?"COPIED":(a=>`${a.slice(0,6)}...${a.slice(-4)}`)(a.walletAddress)]})}),(0,d.jsxs)("a",{href:function(a,b){return"solana"===a||"solana-devnet"===a?`https://solscan.io/account/${b}`:"polygon"===a?`https://polygonscan.com/address/${b}`:"ethereum"===a?`https://etherscan.io/address/${b}`:`https://basescan.org/address/${b}`}(j,a.walletAddress),target:"_blank",rel:"noreferrer",className:"px-2 py-1 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px] inline-flex items-center gap-1",children:[(0,d.jsx)(by.A,{size:10})," Explorer"]})]})]})};function bA(a){return new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}let bB=({credential:a,vaultName:b,lifecycle:c,onEdit:f,onDelete:g,onRestore:h,onDuplicate:i})=>{let[j,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(null),[r,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(null),[A,B]=(0,e.useState)(""),C=a=>{k(a)};(0,e.useEffect)(()=>{q(null),t(!1),v(null),x(null),B("")},[a.id]);let D=(0,e.useCallback)(async()=>{t(!0),q(null);try{let b=await s.FH.post(s.jI.Wallet,`/credentials/${a.id}/reauth`);v(b.authorization_url||null),x(b.state||null),q(b.message||"Authorization URL generated. Complete provider consent, then paste code.")}catch(a){q(a instanceof Error?a.message:"Failed to start re-auth")}finally{t(!1)}},[a.id]),E=(0,e.useCallback)(async()=>{if(!A.trim()||!w)return void q("Enter authorization code after consent to complete re-auth.");t(!0);try{let b=await s.FH.post(s.jI.Wallet,`/credentials/${a.id}/reauth`,{code:A.trim(),state:w});q(b.message||"Re-auth complete. Refresh credential details."),B("")}catch(a){q(a instanceof Error?a.message:"Failed to complete re-auth")}finally{t(!1)}},[a.id,A,w]),F={login:"Login",card:"Card",note:"Note",plain_note:"Plain Note",hot_wallet:"Hot Wallet",apikey:"API Key",custom:"Key / Value",oauth2:"OAuth2",ssh:"SSH Key",gpg:"GPG Key"}[a.type]||a.type.charAt(0).toUpperCase()+a.type.slice(1),G=a.meta.sensitive_field_keys??[],H=a.meta.walletLink,I="active"===c,J=I?"ARCHIVE":"archive"===c?"DELETE":"PURGE",K=I?"Archive Credential":"archive"===c?"Delete Credential":"Purge Credential",L=I?"This credential will be moved to Archive.":"archive"===c?"This credential will be moved to Recently Deleted.":"This credential will be permanently deleted now.",M={sensitiveClickBehavior:"copy"};return(0,d.jsxs)("div",{className:"p-6 flex flex-col relative",children:[(0,d.jsx)("div",{className:"absolute top-6 -left-1 text-vertical label-specimen-sm text-[var(--color-text-faint,#9ca3af)] select-none opacity-40 hidden lg:block",children:"CLASSIFIED"}),(0,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("h2",{className:"font-mono font-bold text-lg text-[var(--color-text,#0a0a0a)]",children:a.name}),(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,d.jsx)("span",{className:"shard-start inline-block bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-[8px] font-bold uppercase tracking-widest px-2 py-0.5",children:F}),(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:b})]})]}),(0,d.jsxs)("div",{className:"flex-1 space-y-0.5",children:["login"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"URL",value:a.meta.url,credentialId:a.id,fieldKey:y.u.login.url,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Username",value:a.meta.username,credentialId:a.id,fieldKey:y.u.login.username,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Password",credentialId:a.id,fieldKey:y.u.login.password,isSensitive:!0,onShowLargeType:C,...M}),I&&(0,d.jsx)(br,{credentialId:a.id}),G.includes(y.u.login.notes)&&(0,d.jsx)(bq,{label:"Notes",credentialId:a.id,fieldKey:y.u.login.notes,isSensitive:!0,onShowLargeType:C,...M})]}),"card"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Cardholder",value:a.meta.cardholder,credentialId:a.id,fieldKey:y.u.card.cardholder,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Brand",value:a.meta.brand,credentialId:a.id,fieldKey:y.u.card.brand,isSensitive:!1,onShowLargeType:C}),a.meta.last4&&(0,d.jsx)(bq,{label:"Card",value:`•••• ${a.meta.last4}`,credentialId:a.id,fieldKey:y.u.card.last4,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Number",credentialId:a.id,fieldKey:y.u.card.number,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Expiry",credentialId:a.id,fieldKey:y.u.card.expiry,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"CVV",credentialId:a.id,fieldKey:y.u.card.cvv,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Billing ZIP",value:a.meta.billing_zip,credentialId:a.id,fieldKey:y.u.card.billingZip,isSensitive:!1,onShowLargeType:C}),G.includes(y.u.card.notes)&&(0,d.jsx)(bq,{label:"Notes",credentialId:a.id,fieldKey:y.u.card.notes,isSensitive:!0,onShowLargeType:C,...M})]}),"note"===a.type&&(0,d.jsx)(bq,{label:"Content",credentialId:a.id,fieldKey:y.l3,isSensitive:!0,onShowLargeType:C,sensitiveInteractionMode:"markdown-hover-copy",disableLargeType:!0}),"plain_note"===a.type&&(0,d.jsx)(bq,{label:"Content",value:a.meta[y.l3]||a.meta.value,credentialId:a.id,fieldKey:y.l3,isSensitive:!1,onShowLargeType:C,renderMarkdown:!0,disableLargeType:!0}),"apikey"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Key",value:a.meta.key,credentialId:a.id,fieldKey:y.u.apikey.key,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Value",credentialId:a.id,fieldKey:y.u.apikey.value,isSensitive:!0,onShowLargeType:C,sensitiveClickBehavior:"copy"})]}),"hot_wallet"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Address",value:a.meta.address||H?.walletAddress,credentialId:a.id,fieldKey:y.u.hot_wallet.address,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Chain",value:a.meta.chain||H?.chain,credentialId:a.id,fieldKey:y.u.hot_wallet.chain,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Private Key",credentialId:a.id,fieldKey:y.u.hot_wallet.privateKey,isSensitive:!0,onShowLargeType:C,...M})]}),"custom"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Key",value:a.meta.primaryKey||"value",credentialId:a.id,fieldKey:"primaryKey",isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Value",credentialId:a.id,fieldKey:a.meta.primaryKey||y.u.custom.value,isSensitive:!0,onShowLargeType:C,...M})]}),"ssh"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Fingerprint",value:a.meta.fingerprint,credentialId:a.id,fieldKey:y.u.ssh.fingerprint,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Key Type",value:a.meta.key_type,credentialId:a.id,fieldKey:y.u.ssh.keyType,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Hosts",value:Array.isArray(a.meta.hosts)?a.meta.hosts.join(", "):void 0,credentialId:a.id,fieldKey:y.u.ssh.hosts,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Public Key",value:a.meta.public_key,credentialId:a.id,fieldKey:y.u.ssh.publicKey,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Private Key",credentialId:a.id,fieldKey:y.u.ssh.privateKey,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Passphrase",credentialId:a.id,fieldKey:y.u.ssh.passphrase,isSensitive:!0,onShowLargeType:C,...M})]}),"gpg"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Fingerprint",value:a.meta.fingerprint,credentialId:a.id,fieldKey:y.u.gpg.fingerprint,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Key ID",value:a.meta.key_id,credentialId:a.id,fieldKey:y.u.gpg.keyId,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"UID Email",value:a.meta.uid_email,credentialId:a.id,fieldKey:y.u.gpg.uidEmail,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Expires At",value:a.meta.expires_at,credentialId:a.id,fieldKey:y.u.gpg.expiresAt,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Public Key",value:a.meta.public_key,credentialId:a.id,fieldKey:y.u.gpg.publicKey,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Private Key",credentialId:a.id,fieldKey:y.u.gpg.privateKey,isSensitive:!0,onShowLargeType:C,...M})]}),"oauth2"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Token Endpoint",value:a.meta.token_endpoint,credentialId:a.id,fieldKey:y.u.oauth2.tokenEndpoint,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Scopes",value:a.meta.scopes,credentialId:a.id,fieldKey:y.u.oauth2.scopes,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Auth Method",value:a.meta.auth_method,credentialId:a.id,fieldKey:y.u.oauth2.authMethod,isSensitive:!1,onShowLargeType:C}),(a.meta.needs_reauth||u)&&(0,d.jsxs)("div",{className:"px-2 py-2 my-1 border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 text-[var(--color-danger,#ef4444)] font-mono text-[10px]",children:["⚠️ Re-authentication required",!!a.meta.reauth_reason&&(0,d.jsx)("span",{className:"block text-[9px] text-[var(--color-danger,#ef4444)]/70 mt-0.5",children:String(a.meta.reauth_reason)}),(0,d.jsx)("button",{className:"mt-1 px-2 py-0.5 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider disabled:opacity-50",onClick:D,disabled:r,children:r?"Loading…":"Start Re-auth"}),u&&(0,d.jsx)("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"mt-1 ml-2 inline-block px-2 py-0.5 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider",children:"Open Consent"}),w&&(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,d.jsx)("input",{value:A,onChange:a=>B(a.target.value),placeholder:"Paste authorization code",className:"flex-1 px-2 py-1 border border-[var(--color-danger,#ef4444)]/30 bg-transparent text-[9px]"}),(0,d.jsx)("button",{className:"px-2 py-1 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider disabled:opacity-50",onClick:E,disabled:r||!A.trim(),children:"Complete Re-auth"})]}),p&&(0,d.jsx)("div",{className:"mt-1 text-[9px] text-[var(--color-danger,#ef4444)]/90 break-words",children:p})]}),a.meta.last_refreshed&&(0,d.jsxs)("div",{className:"px-1 py-1",children:[(0,d.jsxs)("span",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["Last Refreshed:"," "]}),(0,d.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:new Date(String(a.meta.last_refreshed)).toLocaleString()})]}),(()=>{let b=a.meta.expires_at,c=Math.floor(Date.now()/1e3),e=!b||c>=b,f=b?e?"Expired — will auto-refresh on next read":`Valid for ${Math.floor((b-c)/60)}m`:"No token yet";return(0,d.jsxs)("div",{className:"px-1 py-2",children:[(0,d.jsxs)("span",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["Token Status:"," "]}),(0,d.jsx)("span",{className:"font-mono text-[10px] font-bold",style:{color:e?"var(--color-danger,#ef4444)":"var(--color-success,#00c853)"},children:f})]})})(),(0,d.jsx)(bq,{label:"Access Token",credentialId:a.id,fieldKey:y.u.oauth2.accessToken,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Refresh Token",credentialId:a.id,fieldKey:y.u.oauth2.refreshToken,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Client ID",credentialId:a.id,fieldKey:y.u.oauth2.clientId,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Client Secret",credentialId:a.id,fieldKey:y.u.oauth2.clientSecret,isSensitive:!0,onShowLargeType:C,...M})]})]}),H&&(0,d.jsx)(bz,{walletLink:H}),a.meta.tags&&a.meta.tags.length>0&&(0,d.jsx)("div",{className:"mt-4 flex flex-wrap gap-1.5",children:a.meta.tags.map(a=>(0,d.jsx)("span",{className:"inline-block font-mono text-[9px] px-2 py-0.5 bg-[var(--color-accent,#ccff00)]/10 text-[var(--color-text-muted,#6b7280)]",children:a},a))}),(0,d.jsx)("div",{className:"mt-4 pt-3 border-t border-[var(--color-border,#d4d4d8)]",children:(0,d.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-faint,#9ca3af)] space-y-0.5",children:[(0,d.jsxs)("div",{children:["Created ",bA(a.createdAt)]}),(0,d.jsxs)("div",{children:["Updated ",bA(a.updatedAt)]}),a.archivedAt&&(0,d.jsxs)("div",{children:["Archived ",bA(a.archivedAt)]}),a.deletedAt&&(0,d.jsxs)("div",{children:["Deleted ",bA(a.deletedAt)]}),(0,d.jsxs)("div",{children:["Vault: ",b]})]})}),(0,d.jsxs)("div",{className:"mt-4 flex gap-2",children:[I&&(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:"SHARE"}),I&&(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:f,children:"EDIT"}),I&&i&&(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:i,children:"DUPLICATE"}),!I&&(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:h,children:"archive"===c?"RESTORE":"RESTORE TO ARCHIVE"}),(0,d.jsx)(z.$n,{variant:"danger",size:"sm",onClick:()=>m(!0),children:J})]}),(0,d.jsx)(z.Rw,{isOpen:l,onClose:()=>m(!1),onConfirm:()=>{m(!1),g()},title:K,message:L,confirmText:"recently_deleted"===c?"PURGE":"CONFIRM",variant:"recently_deleted"===c?"danger":"warning"}),(0,d.jsx)(bs,{isOpen:null!=j,onClose:()=>k(null),value:j??""}),(0,d.jsx)(bx,{isOpen:n,onClose:()=>o(!1),credentialId:a.id,credentialName:a.name})]})},bC=({variant:a,onAdd:b})=>"no-selection"===a?(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)(H.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,d.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Select a credential from the list"})]})}):"empty-lifecycle"===a?(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)(H.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,d.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1",children:"No credentials in this section"})]})}):(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)(H.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,d.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1",children:"Your vault is empty"}),(0,d.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-faint,#9ca3af)] mb-4",children:"Create your first credential"}),(0,d.jsx)(z.$n,{size:"sm",onClick:b,icon:(0,d.jsx)(m.A,{size:10}),children:"ADD"})]})});var bD=c(73778),bE=c(18310),bF=c(75219);let bG=[{label:"1Password",format:"1password-csv",supported:!0},{label:"Bitwarden",format:"bitwarden-csv",supported:!0},{label:"Chrome",format:"chrome-csv",supported:!0},{label:"Firefox",format:"firefox-csv",supported:!0},{label:"iCloud Keychain",format:"icloud-csv",supported:!0},{label:"LastPass",format:"lastpass-csv",supported:!0}],bH={skip:"Skip",rename:"Rename",overwrite:"Create Anyway"},bI=({isOpen:a,onClose:b,onComplete:c,vaults:f,selectedVaultId:g,onSelectedVaultIdChange:h,onAddVault:i,walletBaseUrl:j})=>{let[k,l]=(0,e.useState)("select"),[m,n]=(0,e.useState)("1password-csv"),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)("skip"),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(!1),[y,A]=(0,e.useState)(null),B=(0,e.useRef)(null),C=(0,e.useMemo)(()=>f.map(a=>({value:a.id,label:a.name||(a.isPrimary?"Primary":`Vault ${a.id.slice(0,6)}`)})),[f]),E=(0,e.useMemo)(()=>f.find(a=>a.id===g)||null,[f,g]),F=(0,e.useCallback)(()=>{l("select"),n("1password-csv"),p(null),r("skip"),t(null),v(null),x(!1),A(null),B.current&&(B.current.value="")},[]),G=(0,e.useCallback)(()=>{F(),b()},[F,b]),H=(0,e.useCallback)(a=>{let b=a.target.files?.[0]??null;if(b&&b.size>0xa00000){A(`File too large (${(b.size/1024/1024).toFixed(1)}MB). Maximum is 10MB.`),p(null),B.current&&(B.current.value="");return}p(b),A(null)},[]),I=(0,e.useCallback)(a=>{if(!o)return null;let b=new FormData;return b.append("file",o),b.append("format",m),b.append("vaultId",g||"primary"),a&&b.append("dryRun","true"),b.append("duplicateStrategy",q),b},[o,m,g,q]),J=(0,e.useCallback)(async()=>{if(o){x(!0),A(null);try{let a=I(!0);if(!a)return;let b=await fetch(`${j}/credentials/import`,{method:"POST",headers:{},body:a});if(!(b.headers.get("content-type")||"").includes("application/json"))return void A(`Server error: ${b.status} ${b.statusText}`);let c=await b.json();if(!b.ok||!c.success)return void A(c.error||`Request failed: ${b.status}`);t(c),l("preview")}catch(a){A(a instanceof Error?a.message:"Preview failed")}finally{x(!1)}}},[o,I,j]),K=(0,e.useCallback)(async()=>{x(!0),A(null);try{let a=I(!1);if(!a)return;let b=await fetch(`${j}/credentials/import`,{method:"POST",headers:{},body:a});if(!(b.headers.get("content-type")||"").includes("application/json"))return void A(`Server error: ${b.status} ${b.statusText}`);let c=await b.json();if(!b.ok)return void A(c.error||`Request failed: ${b.status}`);v(c),l("result")}catch(a){A(a instanceof Error?a.message:"Import failed")}finally{x(!1)}},[I,j]),L=(0,e.useCallback)(()=>{c(),G()},[c,G]),M=bG.find(a=>a.format===m);return(0,d.jsxs)(z.aF,{isOpen:a,onClose:G,title:"Import Credentials",size:"md",footer:(()=>{if("select"===k)return(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:G,children:"CANCEL"}),(0,d.jsx)(z.$n,{size:"sm",onClick:J,loading:w,disabled:!o||!M?.supported,children:"PREVIEW"})]});if("preview"===k&&s){let a="skip"===q?s.total-s.duplicates:s.total;return(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>{l("select"),A(null),B.current&&(B.current.value="")},children:"BACK"}),(0,d.jsxs)(z.$n,{size:"sm",onClick:K,loading:w,disabled:0===s.credentials.length,children:["IMPORT ",a," CREDENTIAL",1!==a?"S":""]})]})}return"result"===k?(0,d.jsx)("div",{className:"flex justify-end",children:(0,d.jsx)(z.$n,{size:"sm",onClick:L,children:"DONE"})}):null})(),children:["select"===k&&(0,d.jsxs)("div",{className:"space-y-5",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-2",children:"Source"}),(0,d.jsx)(z.O6,{ariaLabel:"Import source",value:m,onChange:a=>{let b=bG.find(b=>b.format===a);b?.supported&&n(b.format)},options:bG.map(a=>({value:a.format,label:a.label,description:a.supported?void 0:"Coming soon",icon:(0,d.jsx)(D.A,{size:12})}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-2",children:"File"}),(0,d.jsx)("input",{ref:B,type:"file",accept:".csv",onChange:H,className:"hidden"}),(0,d.jsxs)("button",{onClick:()=>B.current?.click(),className:"w-full flex items-center justify-center gap-2 px-4 py-4 border-2 border-dashed border-[var(--color-border,#d4d4d8)] hover:border-[var(--color-text-muted,#6b7280)] transition-colors",children:[(0,d.jsx)(Y.A,{size:14,className:"text-[var(--color-text-muted,#6b7280)]"}),(0,d.jsx)("span",{className:"text-[10px] font-mono tracking-wider text-[var(--color-text-muted,#6b7280)]",children:o?o.name:"Choose CSV file"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-end gap-2",children:[(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)(z.UM,{label:"Target Vault",ariaLabel:"TARGET VAULT",options:C,value:g,onChange:h,compact:!0,searchable:!0,menuPosition:"top",searchPlaceholder:"Search vault...",emptyMessage:"No vault matches"})}),(0,d.jsx)(z.$n,{type:"button",variant:"secondary",size:"sm",onClick:i,className:"!h-[var(--control-height-sm)] !px-3",children:"ADD"})]}),E&&!E.isUnlocked&&(0,d.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-warning,#ff4d00)] border border-[var(--color-warning,#ff4d00)]/30 bg-[var(--color-warning,#ff4d00)]/10 px-3 py-2",children:"Selected vault is locked. Unlock it before preview/import."})]}),y&&(0,d.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 bg-red-50 border border-red-200",children:[(0,d.jsx)(bE.A,{size:12,className:"text-red-500 flex-shrink-0 mt-0.5"}),(0,d.jsx)("span",{className:"text-[10px] font-mono text-red-700",children:y})]})]}),"preview"===k&&(s?(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{className:"flex gap-4",children:[(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"text-[18px] font-bold font-mono text-[var(--color-text,#0a0a0a)]",children:s.total}),(0,d.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Total"})]}),s.duplicates>0&&(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"text-[18px] font-bold font-mono text-amber-600",children:s.duplicates}),(0,d.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Duplicates"})]})]}),(0,d.jsxs)("div",{className:"max-h-[240px] overflow-y-auto border border-[var(--color-border,#d4d4d8)]",children:[0===s.credentials.length?(0,d.jsx)("div",{className:"px-4 py-8 text-center text-[10px] font-mono text-[var(--color-text-muted,#6b7280)]",children:"No credentials found in file"}):s.credentials.map((a,b)=>(0,d.jsxs)("div",{className:`flex items-center gap-2 px-3 py-1.5 border-b border-[var(--color-border,#d4d4d8)] last:border-b-0 ${a.isDuplicate?"bg-amber-50/50":""}`,children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-[10px] font-mono text-[var(--color-text,#0a0a0a)] truncate",children:a.name}),a.url&&(0,d.jsx)("div",{className:"text-[8px] font-mono text-[var(--color-text-faint,#9ca3af)] truncate",children:a.url})]}),(0,d.jsx)("span",{className:"text-[8px] font-mono tracking-wider uppercase text-[var(--color-text-faint,#9ca3af)] flex-shrink-0",children:a.type}),a.isDuplicate&&(0,d.jsx)("span",{className:"text-[8px] font-mono tracking-wider uppercase text-amber-600 flex-shrink-0",children:"DUP"})]},b)),s.total>s.credentials.length&&(0,d.jsxs)("div",{className:"px-3 py-1.5 text-[9px] font-mono text-[var(--color-text-faint,#9ca3af)] text-center",children:["+ ",s.total-s.credentials.length," more"]})]}),s.duplicates>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1.5",children:"Duplicate handling"}),(0,d.jsx)("div",{className:"flex gap-1.5",children:["skip","rename","overwrite"].map(a=>(0,d.jsx)("button",{onClick:()=>r(a),className:`px-3 py-1.5 text-[9px] font-mono tracking-wider uppercase border transition-colors ${q===a?"border-[var(--color-accent,#ccff00)] bg-[var(--color-accent,#ccff00)]/10 text-[var(--color-text,#0a0a0a)]":"border-[var(--color-border,#d4d4d8)] text-[var(--color-text-muted,#6b7280)] hover:bg-[var(--color-background-alt,#f4f4f5)]"}`,children:bH[a]},a))})]}),y&&(0,d.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 bg-red-50 border border-red-200",children:[(0,d.jsx)(bE.A,{size:12,className:"text-red-500 flex-shrink-0 mt-0.5"}),(0,d.jsx)("span",{className:"text-[10px] font-mono text-red-700",children:y})]})]}):null),"result"===k&&(()=>{if(!u)return null;let a=u.errors.length>0;return(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[u.success?(0,d.jsx)(bF.A,{size:20,className:"text-green-600"}):(0,d.jsx)(bE.A,{size:20,className:"text-red-500"}),(0,d.jsx)("div",{children:(0,d.jsx)("div",{className:"text-[11px] font-mono font-bold text-[var(--color-text,#0a0a0a)]",children:u.success?"Import Complete":"Import Failed"})})]}),(0,d.jsxs)("div",{className:"flex gap-6",children:[(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"text-[18px] font-bold font-mono text-green-600",children:u.imported}),(0,d.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Imported"})]}),u.skipped>0&&(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"text-[18px] font-bold font-mono text-[var(--color-text-muted,#6b7280)]",children:u.skipped}),(0,d.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Skipped"})]}),a&&(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"text-[18px] font-bold font-mono text-red-500",children:u.errors.length}),(0,d.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Errors"})]})]}),a&&(0,d.jsx)("div",{className:"max-h-[120px] overflow-y-auto border border-red-200 bg-red-50",children:u.errors.map((a,b)=>(0,d.jsxs)("div",{className:"px-3 py-1 text-[9px] font-mono text-red-700 border-b border-red-100 last:border-b-0",children:["Row ",a.row,": ",a.reason]},b))})]})})()]})};var bJ=c(75046),bK=c(16945),bL=c(77886),bM=c(2761);let bN={CREDENTIAL_SCOPE_DENIED:"SCOPE_DENY",TOKEN_PERMISSION_DENIED:"SCOPE_DENY",TOKEN_REVOKED:"TOKEN_REVOKED",TOKEN_EXPIRED:"TOKEN_EXPIRED",RATE_LIMIT:"RATE_LIMITED",RATE_LIMITED:"RATE_LIMITED",CREDENTIAL_NOT_FOUND:"NOT_FOUND",CREDENTIAL_TOTP_NOT_CONFIGURED:"NOT_FOUND",TOKEN_AGENT_PUBKEY_MISSING:"MISSING_KEY",INTERNAL_ERROR:"INTERNAL_ERROR",ALLOW:"UNKNOWN"};function bO(a,b,c){let d="string"==typeof a?a.trim().toUpperCase():"";return"ALLOW"===d?"ALLOW":"DENY"===d?"DENY":"RATE_LIMIT"===d?"RATE_LIMIT":"ERROR"===d?"ERROR":!0===b?"ALLOW":!1===b&&(c??0)===429?"RATE_LIMIT":!1===b?"DENY":(c??0)>=500?"ERROR":"UNKNOWN"}function bP(a){return bN["string"==typeof a?a.trim().toUpperCase():""]??"UNKNOWN"}function bQ(a){return a.tokenHash?"HIGH":a.agentId?"MEDIUM":"LOW"}function bR(a){let b="string"==typeof a.decision?a.decision:void 0,c="string"==typeof a.reasonCode?a.reasonCode:void 0,d="string"==typeof a.tokenHash?a.tokenHash:void 0,e="string"==typeof a.agentId?a.agentId:void 0,f=a.timestamp,g=new Date("string"==typeof f||"number"==typeof f?f:Date.now()).getTime();return{id:String(a.id??`${g}-${d??e??"unknown"}`),timestamp:g,tokenKey:d??e??"unknown",tokenHash:d,agentId:e,endpoint:"string"==typeof a.action?a.action:void 0,credentialKey:"string"==typeof a.credentialId?a.credentialId:void 0,sourceVersion:"task40-audit-v1",decision:bO(b,a.allowed,a.httpStatus),reasonCode:bP(c),rawDecision:b,rawReasonCode:c,confidence:bQ({tokenHash:d,agentId:e})}}function bS(a){let b="object"==typeof a.data&&null!==a.data?a.data:{},c="object"==typeof b.metadata&&null!==b.metadata?b.metadata:{},d="string"==typeof b.result?b.result:"string"==typeof b.decision?b.decision:void 0,e="string"==typeof b.reasonCode?b.reasonCode:"string"==typeof b.reason?b.reason:void 0,f="string"==typeof b.tokenHash?b.tokenHash:void 0,g="string"==typeof b.agentId?b.agentId:void 0,h=a.timestamp,i=new Date("string"==typeof h||"number"==typeof h?h:Date.now()).getTime();return{id:String(a.id??`${i}-${f??g??"unknown"}`),timestamp:i,tokenKey:f??g??"unknown",tokenHash:f,agentId:g,endpoint:"string"==typeof c.route?c.route:"string"==typeof b.action?b.action:void 0,credentialKey:"string"==typeof b.credentialId?b.credentialId:void 0,sourceVersion:"legacy-logs-v1",decision:bO(d,b.allowed,b.httpStatus),reasonCode:bP(e),rawDecision:d,rawReasonCode:e,confidence:bQ({tokenHash:f,agentId:g})}}function bT(a){return"HIGH"===a?3:"MEDIUM"===a?2:1}let bU=[{value:"active",label:"ACTIVE"},{value:"revoked",label:"REVOKED"},{value:"expired",label:"EXPIRED"},{value:"all",label:"ALL"}],bV=[{value:"1h",label:"1 HOUR"},{value:"24h",label:"24 HOURS"},{value:"7d",label:"7 DAYS"}],bW=[{value:"all",label:"ALL"},{value:"ALLOW",label:"ALLOW"},{value:"DENY",label:"DENY"},{value:"RATE_LIMIT",label:"RATE_LIMIT"},{value:"ERROR",label:"ERROR"},{value:"UNKNOWN",label:"UNKNOWN"}];function bX(a){if(null==a)return null;if("number"==typeof a)return a<1e12?1e3*a:a;let b=Date.parse(a);return Number.isFinite(b)?b:null}function bY(a){return a?a.length<=14?a:`${a.slice(0,8)}...${a.slice(-6)}`:"—"}function bZ(a){let b=bX(a);return null===b?"—":new Date(b).toLocaleString()}function b$(){let{subscribe:a}=(0,bL.h)(),[b,c]=(0,e.useState)([]),[f,g]=(0,e.useState)([]),[h,i]=(0,e.useState)("active"),[j,k]=(0,e.useState)("24h"),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)("all"),[p,q]=(0,e.useState)("all"),[r,t]=(0,e.useState)(0),[u,v]=(0,e.useState)(!0),[w,x]=(0,e.useState)(null),[y,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),[G,H]=(0,e.useState)(null),I=(0,e.useRef)(null),J=(0,e.useRef)(null),K=(0,e.useCallback)(async()=>{v(!0),x(null);try{let[a,b,d]=await Promise.all([s.FH.get(s.jI.Wallet,"/dashboard"),s.FH.get(s.jI.Wallet,"/security/credential-access/recent",{limit:500}),s.FH.get(s.jI.Wallet,"/logs",{category:"agent",limit:200})]),e=a.success?[...a.tokens.active??[],...a.tokens.inactive??[]]:[],f=b.success?b.rows.map(bR):[],h=d.success?d.logs.filter(a=>{let b=a.data??{};return"credential_access_decision"===b.action}).map(bS):[],i=Date.now(),j=(function(a){let b=new Map;for(let c of a){let a=c.id||`${c.timestamp}|${c.endpoint??""}|${c.tokenKey}|${c.credentialKey??""}|${c.decision}|${c.reasonCode}`,d=b.get(a);if(!d||bT(c.confidence)>bT(d.confidence)){b.set(a,c);continue}"task40-audit-v1"===c.sourceVersion&&"legacy-logs-v1"===d.sourceVersion&&b.set(a,c)}return Array.from(b.values()).sort((a,b)=>b.timestamp-a.timestamp)})([...f,...h]).filter(a=>a.timestamp<=i);c(e),g(j.slice(0,500)),t(0)}catch(a){x(a instanceof Error?a.message:"Failed to load audit console")}finally{v(!1)}},[]);(0,e.useCallback)(()=>{J.current||(J.current=setTimeout(()=>{J.current=null,K()},120))},[K]);let L=(0,e.useMemo)(()=>Date.now()-("1h"===j?36e5:"7d"===j?6048e5:864e5),[j]),M=l.trim().toLowerCase(),N=(0,e.useMemo)(()=>b.map((a,b)=>({key:a.tokenHash||a.agentId||`unknown-${b}`,token:a,status:function(a){if(a.isRevoked)return"revoked";let b=bX(a.expiresAt);return a.isExpired||null!==b&&b<=Date.now()?"expired":a.isActive?"active":"inactive"}(a)})),[b]),O=(0,e.useMemo)(()=>new Map(N.map(a=>[a.key,a])),[N]),P="all"===n?null:O.get(n)??null,Q=(0,e.useMemo)(()=>f.filter(a=>a.timestamp>=L),[f,L]),R=(0,e.useMemo)(()=>{let a=N.filter(a=>"active"===a.status).length,b=Q.filter(a=>"DENY"===a.decision).length;return{activeCount:a,denied:b,rateLimited:Q.filter(a=>"RATE_LIMIT"===a.decision).length,unknown:Q.filter(a=>"UNKNOWN"===a.decision||"UNKNOWN"===a.reasonCode).length}},[N,Q]),S=(0,e.useMemo)(()=>N.filter(a=>("all"===h||a.status===h)&&(!M||`${a.key} ${a.token.tokenHash} ${a.token.agentId}`.toLowerCase().includes(M))),[N,h,M]),T=(0,e.useMemo)(()=>{let a=[{value:"all",label:"ALL TOKENS"}],b=new Set(["all"]);if(S.forEach(c=>{b.has(c.key)||(b.add(c.key),a.push({value:c.key,label:`${c.token.agentId??"unknown"} \xb7 ${bY(c.token.tokenHash??c.key)}`}))}),"all"!==n&&!b.has(n)){let b=O.get(n);b&&a.push({value:b.key,label:`${b.token.agentId??"unknown"} \xb7 ${bY(b.token.tokenHash??b.key)}`})}return a},[S,n,O]),U=(0,e.useMemo)(()=>{let a=new Map;return Q.forEach(b=>{[b.tokenHash,b.tokenKey,b.agentId?`agent:${b.agentId}`:void 0,b.agentId].filter(a=>!!a).forEach(c=>{a.set(c,Math.max(a.get(c)??0,b.timestamp))})}),a},[Q]),V=(0,e.useCallback)(a=>{let b=a.token.tokenHash;return b&&U.has(b)?U.get(b)??null:U.has(a.key)?U.get(a.key)??null:a.token.agentId&&U.has(`agent:${a.token.agentId}`)?U.get(`agent:${a.token.agentId}`)??null:a.token.agentId&&U.has(a.token.agentId)?U.get(a.token.agentId)??null:null},[U]),W=(0,e.useMemo)(()=>Q.filter(a=>{if("all"!==n){let b=P?.token.agentId,c=a.tokenKey===n||a.tokenHash===n,d=!!b&&a.agentId===b;if(!c&&!d)return!1}return("all"===p||a.decision===p)&&(!M||!!`${a.tokenHash??""} ${a.tokenKey} ${a.agentId??""}`.toLowerCase().includes(M))&&!0}),[p,Q,n,P,M]),X=(0,e.useMemo)(()=>{let a=50*r;return W.slice(a,a+50)},[W,r]),Y=(0,e.useCallback)(a=>{o(a),t(0),I.current&&"function"==typeof I.current.scrollIntoView&&I.current.scrollIntoView({behavior:"smooth",block:"start"})},[]),Z=(0,e.useCallback)(async(a,b)=>{if(!b||!navigator.clipboard)return void A("Clipboard unavailable for this key.");try{let c=bY(b);await navigator.clipboard.writeText(c),E(a),A(`Copied ${c}`),setTimeout(()=>E(b=>b===a?null:b),1500)}catch{A("Clipboard write failed.")}},[]),$=(0,e.useCallback)((a,b)=>{if(!b)return void A("Token hash unavailable; cannot revoke.");H({tokenKey:a,tokenHash:b})},[]),_=(0,e.useCallback)(async()=>{if(!G)return;let{tokenKey:a,tokenHash:b}=G;H(null),C(a),A(null);try{let a=await s.FH.post(s.jI.Wallet,"/actions/tokens/revoke",{tokenHash:b});if(!a.success)return void A(a.error||"Failed to revoke token.");A(`Revoked ${bY(b)}`),await K()}catch(a){A(a instanceof Error?a.message:"Failed to revoke token.")}finally{C(null)}},[G,K]);return u?(0,d.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"LOADING_AUDIT_CONSOLE…"}):w?(0,d.jsx)("div",{className:"p-4 border border-[var(--color-warning,#ff4d00)] bg-[color-mix(in_srgb,var(--color-warning,#ff4d00)_10%,transparent)]",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 font-mono text-[10px] text-[var(--color-warning,#ff4d00)]",children:[(0,d.jsx)(bK.A,{size:12})," ",w]})}):(0,d.jsxs)("div",{className:"h-full flex flex-col p-3 gap-3 overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between border border-[var(--color-border,#d4d4d8)] p-2 bg-[var(--color-surface,#fff)]",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-mono text-[11px] font-bold",children:"AUDIT"}),(0,d.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:[bV.find(a=>a.value===j)?.label.toLowerCase()," \xb7 ",Math.min(f.length,500)," rows",f.length>=500?" (capped)":""]})]}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>void K(),icon:(0,d.jsx)(F.A,{size:10}),children:"REFRESH"})]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 xl:grid-cols-4 gap-2",children:[(0,d.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,d.jsx)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:"ACTIVE KEYS"}),(0,d.jsx)("div",{className:"font-mono text-[12px] font-bold",children:R.activeCount})]}),(0,d.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,d.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["DENIES (",j,")"]}),(0,d.jsx)("div",{className:"font-mono text-[12px] font-bold",children:R.denied})]}),(0,d.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,d.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["RATE LIMITED (",j,")"]}),(0,d.jsx)("div",{className:"font-mono text-[12px] font-bold",children:R.rateLimited})]}),(0,d.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,d.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["UNKNOWN MAPS (",j,")"]}),(0,d.jsx)("div",{className:"font-mono text-[12px] font-bold",children:R.unknown})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-5 gap-2",children:[(0,d.jsx)(z.UM,{label:"Status",options:bU,value:h,onChange:a=>i(a),compact:!0}),(0,d.jsx)(z.UM,{label:"Window",options:bV,value:j,onChange:a=>k(a),compact:!0}),(0,d.jsx)(z.UM,{label:"Token",options:T,value:n,onChange:o,compact:!0}),(0,d.jsx)(z.UM,{label:"Decision",options:bW,value:p,onChange:a=>q(a),compact:!0}),(0,d.jsxs)("label",{className:"font-mono text-[9px] flex flex-col gap-1",children:["SEARCH KEY / AGENT",(0,d.jsx)("input",{value:l,onChange:a=>m(a.target.value),placeholder:"hash or agent id",className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] px-2 py-1.5 text-[10px]"})]})]}),y&&(0,d.jsx)("div",{className:"font-mono text-[9px] border border-[var(--color-info,#0047ff)] p-2 text-[var(--color-info,#0047ff)] bg-[color-mix(in_srgb,var(--color-info,#0047ff)_8%,transparent)]",children:y}),(0,d.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-2 py-1.5 border-b border-[var(--color-border,#d4d4d8)] font-mono text-[9px]",children:["KEY INVENTORY \xb7 ",S.length," ROWS"]}),(0,d.jsx)("div",{className:"max-h-[220px] overflow-auto",children:0===S.length?(0,d.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"NO TOKENS MATCH FILTERS"}):(0,d.jsxs)("table",{className:"w-full text-left",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-[var(--color-surface-alt,#fafafa)] border-b",children:(0,d.jsxs)("tr",{className:"font-mono text-[9px]",children:[(0,d.jsx)("th",{className:"p-2",children:"KEY"}),(0,d.jsx)("th",{className:"p-2",children:"AGENT"}),(0,d.jsx)("th",{className:"p-2",children:"PERMISSIONS"}),(0,d.jsx)("th",{className:"p-2",children:"ISSUED"}),(0,d.jsx)("th",{className:"p-2",children:"EXPIRES"}),(0,d.jsx)("th",{className:"p-2",children:"LAST USED"}),(0,d.jsx)("th",{className:"p-2",children:"ACTIONS"})]})}),(0,d.jsx)("tbody",{children:S.map(a=>{var b,c;let e=V(a),f=B===a.key,g="active"===a.status&&!!a.token.tokenHash;return(0,d.jsxs)("tr",{className:"border-b font-mono text-[9px]",children:[(0,d.jsxs)("td",{className:"p-2",children:[(0,d.jsx)("div",{children:bY(a.token.tokenHash??a.key)}),(0,d.jsx)("div",{className:`text-[8px] uppercase ${"active"===(b=a.status)?"text-[var(--color-success,#16a34a)]":"revoked"===b?"text-[var(--color-warning,#ff4d00)]":"expired"===b?"text-[var(--color-text-faint,#9ca3af)]":"text-[var(--color-text-muted,#6b7280)]"}`,children:a.status})]}),(0,d.jsx)("td",{className:"p-2",children:a.token.agentId??"unknown"}),(0,d.jsx)("td",{className:"p-2",children:(c=a.token.permissions??[])&&0!==c.length?c.length<=2?c.join(", "):`${c.slice(0,2).join(", ")} +${c.length-2}`:"—"}),(0,d.jsx)("td",{className:"p-2",children:bZ(a.token.createdAt)}),(0,d.jsxs)("td",{className:"p-2",children:[bZ(a.token.expiresAt),(0,d.jsx)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:function(a){let b=bX(a);if(null===b)return"—";let c=b-Date.now();if(c<=0)return"expired";let d=Math.floor(c/6e4);if(d<60)return`${d}m`;let e=Math.floor(d/60);return e<24?`${e}h`:`${Math.floor(e/24)}d`}(a.token.expiresAt)})]}),(0,d.jsx)("td",{className:"p-2",children:e?new Date(e).toLocaleString():"—"}),(0,d.jsx)("td",{className:"p-2",children:(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("button",{onClick:()=>void Z(a.key,a.token.tokenHash),className:"border px-1.5 py-0.5 text-[8px] disabled:opacity-40",title:"Copy short hash",disabled:!a.token.tokenHash,children:(0,d.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,d.jsx)(ae.A,{size:8}),D===a.key?"COPIED":"COPY"]})}),(0,d.jsx)("button",{onClick:()=>Y(a.key),className:"border px-1.5 py-0.5 text-[8px]",title:"Open activity",children:"VIEW"}),(0,d.jsx)("button",{onClick:()=>$(a.key,a.token.tokenHash),disabled:!g||f,className:"border px-1.5 py-0.5 text-[8px] disabled:opacity-40 text-[var(--color-warning,#ff4d00)]",title:g?"Revoke token":"Token cannot be revoked",children:f?"REVOKING":"REVOKE"})]})})]},a.key)})})]})})]}),(0,d.jsxs)("div",{ref:I,className:"flex-1 overflow-auto border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)]",children:[(0,d.jsxs)("div",{className:"sticky top-0 z-10 px-2 py-1.5 border-b bg-[var(--color-surface-alt,#fafafa)] font-mono text-[9px] flex items-center justify-between",children:[(0,d.jsxs)("span",{children:["TOKEN ACTIVITY \xb7 ",W.length," ROWS"]}),(0,d.jsxs)("span",{className:"text-[var(--color-text-muted,#6b7280)]",children:["PAGE ",r+1," / ",Math.max(1,Math.ceil(W.length/50))]})]}),f.length>=500&&(0,d.jsx)("div",{className:"font-mono text-[9px] border-b border-[var(--color-warning,#ff4d00)] p-2 text-[var(--color-warning,#ff4d00)]",children:"RESULTS TRUNCATED AT 500 ROWS — NARROW FILTERS TO REDUCE VOLUME."}),0===X.length?(0,d.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"NO AUDIT EVENTS IN WINDOW"}):(0,d.jsxs)("table",{className:"w-full text-left",children:[(0,d.jsx)("thead",{className:"sticky top-[31px] bg-[var(--color-surface-alt,#fafafa)] border-b",children:(0,d.jsxs)("tr",{className:"font-mono text-[9px]",children:[(0,d.jsx)("th",{className:"p-2",children:"TIME"}),(0,d.jsx)("th",{className:"p-2",children:"TOKEN / AGENT"}),(0,d.jsx)("th",{className:"p-2",children:"DECISION"}),(0,d.jsx)("th",{className:"p-2",children:"REASON"}),(0,d.jsx)("th",{className:"p-2",children:"CONFIDENCE"}),(0,d.jsx)("th",{className:"p-2",children:"ENDPOINT"})]})}),(0,d.jsx)("tbody",{children:X.map(a=>(0,d.jsxs)("tr",{className:"border-b font-mono text-[9px]",children:[(0,d.jsx)("td",{className:"p-2",children:new Date(a.timestamp).toLocaleString()}),(0,d.jsxs)("td",{className:"p-2",children:[a.agentId??"unknown"," \xb7 ",a.tokenKey.slice(0,10)]}),(0,d.jsx)("td",{className:"p-2",children:a.decision}),(0,d.jsxs)("td",{className:"p-2",children:[a.reasonCode,a.rawReasonCode&&"UNKNOWN"===a.reasonCode?` (${a.rawReasonCode})`:""]}),(0,d.jsx)("td",{className:"p-2",title:"HIGH"===a.confidence?"Direct token hash match":"MEDIUM"===a.confidence?"Agent correlation":"Partial/ambiguous join",children:a.confidence}),(0,d.jsx)("td",{className:"p-2",children:a.endpoint??"—"})]},a.id))})]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>t(a=>Math.max(0,a-1)),disabled:0===r,className:"font-mono text-[9px] border px-2 py-1 disabled:opacity-40",children:"PREV"}),(0,d.jsx)("button",{onClick:()=>t(a=>(a+1)*50<W.length?a+1:a),disabled:(r+1)*50>=W.length,className:"font-mono text-[9px] border px-2 py-1 disabled:opacity-40",children:"NEXT"})]}),(0,d.jsx)(z.Rw,{isOpen:null!==G,onClose:()=>H(null),onConfirm:()=>void _(),title:"Revoke Token",message:G?`Revoke token ${bY(G.tokenHash)}? The agent will lose access immediately.`:"",confirmText:"REVOKE",variant:"danger"})]})}let b_=(0,p.A)("ShieldAlert",[["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",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),b0=[{id:"strict",label:"Strict",description:"Agent vault only, read-only, strong field redaction. 15 min TTL."},{id:"dev",label:"Dev (recommended)",description:"All vaults, read/write, moderate redaction. 1 hour TTL."},{id:"admin",label:"Admin (dangerous)",description:"Full access, no redaction. Use with caution."}],b1=[{value:"wallet:list",label:"wallet:list"},{value:"wallet:create:hot",label:"wallet:create:hot"},{value:"wallet:create:temp",label:"wallet:create:temp"},{value:"wallet:rename",label:"wallet:rename"},{value:"wallet:export",label:"wallet:export"},{value:"wallet:tx:add",label:"wallet:tx:add"},{value:"wallet:asset:add",label:"wallet:asset:add"},{value:"wallet:asset:remove",label:"wallet:asset:remove"},{value:"send:hot",label:"send:hot"},{value:"send:temp",label:"send:temp"},{value:"swap",label:"swap"},{value:"fund",label:"fund"},{value:"launch",label:"launch"},{value:"apikey:get",label:"apikey:get"},{value:"apikey:set",label:"apikey:set"},{value:"workspace:modify",label:"workspace:modify"},{value:"strategy:read",label:"strategy:read"},{value:"strategy:manage",label:"strategy:manage"},{value:"app:storage",label:"app:storage"},{value:"app:storage:all",label:"app:storage:all"},{value:"app:accesskey",label:"app:accesskey"},{value:"action:create",label:"action:create"},{value:"action:read",label:"action:read"},{value:"action:resolve",label:"action:resolve"},{value:"adapter:manage",label:"adapter:manage"},{value:"addressbook:write",label:"addressbook:write"},{value:"bookmark:write",label:"bookmark:write"},{value:"secret:read",label:"secret:read"},{value:"secret:write",label:"secret:write"},{value:"totp:read",label:"totp:read"},{value:"trade:all",label:"trade:all"},{value:"wallet:write",label:"wallet:write"},{value:"extension:*",label:"extension:*"},{value:"admin:*",label:"admin:* (dangerous)"}],b2={strict:"Read-only, agent vault only. Hidden: password, cvv, privateKey, seedPhrase, refresh_token. 15 min TTL, 50 reads max.",dev:"Read/write, all vaults. Hidden: cvv, seedPhrase, privateKey, refresh_token. 1 hour TTL, 500 reads max.",admin:"Full access, no field redaction. 1 hour TTL, unlimited reads."},b3=[{value:"profile",label:"Profile"},{value:"permissions",label:"Permissions"}],b4="aura:api-keys:profiles:v1",b5={strict:{ttlSeconds:900,maxReads:50,scope:["secret:read"],excludeFields:["password","cvv","privateKey","seedPhrase","refresh_token"]},dev:{ttlSeconds:3600,maxReads:500,scope:["wallet:list","secret:read","secret:write","action:create","action:read","action:resolve"],excludeFields:["cvv","seedPhrase","privateKey","refresh_token"]},admin:{ttlSeconds:3600,scope:["admin:*"],excludeFields:[]}};function b6(a){return a.length<=14?a:`${a.slice(0,8)}...${a.slice(-4)}`}function b7(){let a=Math.random().toString(36).slice(2,8);return`agent:local:${a}`}function b8(a){return Array.from(new Set(a.map(a=>a.trim().normalize("NFKC").toLowerCase()).filter(Boolean)))}let b9=({requests:a,activeTokens:b,inactiveTokens:c,actionLoading:f,onResolveAction:g,onRevokeToken:h,vaults:i=[]})=>{let[j,l]=(0,e.useState)([]),[m,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(""),[r,u]=(0,e.useState)("dev"),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)(""),[A,B]=(0,e.useState)([]),[C,D]=(0,e.useState)("secret:read"),[E,G]=(0,e.useState)(""),[I,K]=(0,e.useState)([]),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(null),[P,Q]=(0,e.useState)(()=>b7()),[R,S]=(0,e.useState)("profile"),[T,U]=(0,e.useState)("builtin:dev"),[V,W]=(0,e.useState)("secret:read"),[X,Y]=(0,e.useState)(["secret:read","secret:write"]),[Z,$]=(0,e.useState)([]),[_,aa]=(0,e.useState)(!1),[ab,ac]=(0,e.useState)(null),[ad,af]=(0,e.useState)(null),[ag,ah]=(0,e.useState)(null),[ai,aj]=(0,e.useState)(!1),[ak,al]=(0,e.useState)(!1),[am,an]=(0,e.useState)(null),[ao,ap]=(0,e.useState)(null),[aq,ar]=(0,e.useState)(null);(0,e.useEffect)(()=>{try{let a=localStorage.getItem(b4);if(!a)return;let b=JSON.parse(a);if(!Array.isArray(b))return;let c=b.filter(a=>a&&"string"==typeof a.id&&"string"==typeof a.name&&"string"==typeof a.profile&&"v1"===a.profileVersion&&"number"==typeof a.updatedAt).map(a=>{let b=b8([...a.overrides?.scope||[],...a.overrides?.readScopes||[],...a.overrides?.writeScopes||[]]),c=a.overrides?{...a.overrides,...b.length>0?{scope:b}:{},readScopes:void 0,writeScopes:void 0}:null;return{...a,overrides:c}});l(c)}catch{l([])}},[]),(0,e.useEffect)(()=>{localStorage.setItem(b4,JSON.stringify(j))},[j]);let as=(0,e.useCallback)(()=>{o(null),q(""),u("dev"),w(""),y(""),B([]),D("secret:read"),G(""),K([]),M(null),O(null)},[]),at=(0,e.useCallback)(a=>{let b=b5[a];b&&(w(String(b.ttlSeconds)),y("number"==typeof b.maxReads?String(b.maxReads):""),B(b.scope),D(b.scope[0]||"secret:read"),G(b.excludeFields.join(", ")))},[]),au=(0,e.useMemo)(()=>{let a=[{value:"vault:*",label:"All Vaults (vault:*)"}];for(let b of i){let c=b.name||b.id;a.push({value:`vault:${b.id}`,label:`vault:${c}`})}return a},[i]),av=(0,e.useMemo)(()=>a.filter(a=>"pending"===a.status&&("auth"===a.type||"permission_update"===a.type)),[a]),aw=(0,e.useMemo)(()=>[...b0.map(a=>({value:`builtin:${a.id}`,label:`${a.label} — ${a.description}`})),...j.map(a=>({value:`draft:${a.id}`,label:`Custom \xb7 ${a.name}`}))],[j]);(0,e.useEffect)(()=>{aw.some(a=>a.value===T)||U("builtin:dev")},[T,aw]);let ax=(0,e.useCallback)(()=>{if(T.startsWith("draft:")){let a=T.slice(6),b=j.find(b=>b.id===a);if(b){let a=b8([...b.overrides?.scope||[],...b.overrides?.readScopes||[],...b.overrides?.writeScopes||[]]),c=b.overrides?{...b.overrides,...a.length>0?{scope:a}:{}}:void 0;return{profile:b.profile,profileVersion:b.profileVersion,...c?{profileOverrides:c}:{}}}}return{profile:T.startsWith("builtin:")?T.slice(8):"dev",profileVersion:"v1"}},[T,j]),ay=(0,e.useCallback)(a=>{let b=b8([a])[0];b&&Y(a=>a.includes(b)?a:[...a,b])},[]),az=(0,e.useCallback)(a=>{Y(b=>b.filter(b=>b!==a))},[]),aA=(0,e.useCallback)(()=>{M(null),O(null);let a=p.trim();if(!a)return void M("Profile name is required.");let{overrides:b,error:c}=function(a){let b={};if(a.ttlSeconds.trim().length>0){let c=Number(a.ttlSeconds.trim());if(!Number.isFinite(c)||c<=0)return{overrides:null,error:"TTL override must be a positive number."};b.ttlSeconds=c}if(a.maxReads.trim().length>0){let c=Number(a.maxReads.trim());if(!Number.isFinite(c)||c<=0)return{overrides:null,error:"Max reads override must be a positive number."};b.maxReads=c}let c=b8(a.scope),d=function(a){let b=a.split(",").map(a=>a.trim()).filter(Boolean);return b.length>0?b:void 0}(a.excludeFields);return c.length>0&&(b.scope=c),d&&(b.excludeFields=d),{overrides:Object.keys(b).length>0?b:null,error:null}}({ttlSeconds:v,maxReads:x,scope:A,excludeFields:E});if(c)return void M(c);let d=I.length>0?{...b||{},readScopes:I,writeScopes:I}:b;if(j.some(b=>b.name.toLowerCase()===a.toLowerCase()&&b.id!==m))return void M("A profile with this name already exists.");let e={id:m||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,name:a,profile:r,profileVersion:"v1",overrides:d,updatedAt:Date.now()};l(a=>m?a.map(a=>a.id===m?e:a):[e,...a]),O(m?"Profile updated.":"Profile created."),m||U(`draft:${e.id}`),o(e.id)},[m,r,E,x,p,A,v,I,j]),aB=(0,e.useCallback)(a=>{o(a.id),q(a.name),u(a.profile),w(a.overrides?.ttlSeconds?String(a.overrides.ttlSeconds):""),y(a.overrides?.maxReads?String(a.overrides.maxReads):"");let b=b8([...a.overrides?.scope||[],...a.overrides?.readScopes||[],...a.overrides?.writeScopes||[]]);B(b),D(b[0]||"secret:read"),G((a.overrides?.excludeFields||[]).join(", ")),K(a.overrides?.readScopes||a.overrides?.vaultReadScopes||[]),M(null),O(null)},[]),aC=(0,e.useCallback)(a=>{let b=b8([a])[0];b&&B(a=>a.includes(b)?a:[...a,b])},[]),aD=(0,e.useCallback)(a=>{B(b=>b.filter(b=>b!==a))},[]),aE=(0,e.useCallback)(a=>{l(b=>b.filter(b=>b.id!==a)),m===a&&as(),T===`draft:${a}`&&U("builtin:dev")},[m,T,as]),aF=(0,e.useCallback)(async()=>{if(an(null),ap(null),"permissions"===R)return void an("Policy preview is currently available for profile-based issuance only.");al(!0);try{let a=ax(),b=await s.FH.post(s.jI.Wallet,"/actions/token/preview",a);ap(function(a){let b=a&&"object"==typeof a?a:{},c=b.effectivePolicy&&"object"==typeof b.effectivePolicy?b.effectivePolicy:{},d=c.credentialAccess&&"object"==typeof c.credentialAccess?c.credentialAccess:{},e=c.rateBudget&&"object"==typeof c.rateBudget?c.rateBudget:{};return{version:"v1",profile:b.profile&&"object"==typeof b.profile?b.profile:void 0,effectivePolicy:{permissions:Array.isArray(c.permissions)?c.permissions.filter(a=>"string"==typeof a):[],credentialAccess:{read:Array.isArray(d.read)?d.read.filter(a=>"string"==typeof a):[],write:Array.isArray(d.write)?d.write.filter(a=>"string"==typeof a):[],excludeFields:Array.isArray(d.excludeFields)?d.excludeFields.filter(a=>"string"==typeof a):[],maxReads:"number"==typeof d.maxReads?d.maxReads:null},ttlSeconds:"number"==typeof c.ttlSeconds?c.ttlSeconds:0,maxReads:"number"==typeof c.maxReads?c.maxReads:null,rateBudget:{state:"inherited"===e.state||"explicit"===e.state?e.state:"none",requests:"number"==typeof e.requests?e.requests:null,windowSeconds:"number"==typeof e.windowSeconds?e.windowSeconds:null,source:"profile"===e.source||"override"===e.source?e.source:"none"}},warnings:Array.isArray(b.warnings)?b.warnings.filter(a=>"string"==typeof a):[],overrideDelta:Array.isArray(b.overrideDelta)?b.overrideDelta.filter(a=>"string"==typeof a):[],denyExamples:Array.isArray(b.denyExamples)?b.denyExamples.filter(a=>!!a&&"object"==typeof a).map(a=>({code:String(a.code||"UNKNOWN"),message:String(a.message||"")})):[],effectivePolicyHash:"string"==typeof b.effectivePolicyHash?b.effectivePolicyHash:"n/a"}}(b))}catch(a){an(a instanceof Error?a.message:"Failed to preview profile policy.")}finally{al(!1)}},[R,ax]),aG=(0,e.useCallback)(async()=>{if(ac(null),af(null),ah(null),!P.trim())return void ac("Agent ID is required.");if("permissions"===R&&0===X.length)return void ac("Select at least one permission for manual issuance.");let a=(0,t.OQ)();if(!a)return void ac("Vault keypair is unavailable. Re-unlock and retry.");aa(!0);try{let b;if("permissions"===R){let c=Z.length>0?{read:Z,write:Z}:void 0;b=await s.FH.post(s.jI.Wallet,"/actions/token",{agentId:P.trim(),pubkey:a,permissions:X,...c?{credentialAccess:c}:{}})}else{let c=ax();Z.length>0&&(c.profileOverrides={...c.profileOverrides||{},readScopes:Z,writeScopes:Z}),b=await s.FH.post(s.jI.Wallet,"/actions/token",{agentId:P.trim(),pubkey:a,...c})}if(!b.success||!b.encryptedToken)throw Error("Token issuance failed.");let c=await (0,t.DC)(b.encryptedToken);if(af(c),"permissions"===R)ah(`${P.trim()} \xb7 permissions:${X.join(",")}${b.warnings?.length?" \xb7 warnings present":""}`);else{let a=ax();ah(`${P.trim()} \xb7 ${a.profile}@${a.profileVersion}${b.warnings?.length?" \xb7 warnings present":""}`)}}catch(a){ac(a instanceof Error?a.message:"Token issuance failed.")}finally{aa(!1)}},[P,R,X,Z,ax]),aH=(0,e.useCallback)(async()=>{ad&&navigator.clipboard&&(await navigator.clipboard.writeText(ad),aj(!0),setTimeout(()=>aj(!1),1500))},[ad]),aI=(0,e.useCallback)(async(a,b)=>{let c=await g(a,b);if(c.success)return void ar(b?`Approved request ${a.slice(0,8)}.`:`Rejected request ${a.slice(0,8)}.`);ar(c.message||"Failed to resolve request.")},[g]),aJ=(0,e.useMemo)(()=>b.filter(a=>!a.isAdmin),[b]);return(0,d.jsxs)("div",{className:"h-full overflow-y-auto px-5 py-4 font-mono",children:[(0,d.jsxs)("div",{className:"mb-4 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,d.jsx)("div",{className:"text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"API KEYS"}),(0,d.jsx)("div",{className:"mt-1 text-[9px] text-[var(--color-text-muted,#6b7280)] leading-relaxed",children:"Auth management surface for profile templates + permissions-based issuance + pending auth approvals."})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[(0,d.jsxs)("section",{className:"order-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,d.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"ISSUE API KEY"}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,d.jsx)(z.ks,{label:"Agent ID",value:P,onChange:a=>Q(a.target.value),placeholder:"agent:local:dev",compact:!0}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>Q(b7()),icon:(0,d.jsx)(F.A,{size:10}),title:"Regenerate Agent ID",className:"mb-[1px]",children:"NEW ID"})]}),(0,d.jsx)(z.UM,{label:"Issuance Mode",options:b3,value:R,onChange:a=>S(a),compact:!0})]}),"profile"===R?(0,d.jsxs)("div",{className:"mt-2",children:[(0,d.jsx)(z.UM,{label:"Profile Source",options:aw,value:T,onChange:U,compact:!0}),(()=>{let a=T.startsWith("builtin:")?T.slice(8):null,b=a?b2[a]:null;return b?(0,d.jsx)("div",{className:"mt-1 px-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:b}):(0,d.jsx)("div",{className:"mt-1 px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Profile mode resolves permissions/scopes/ttl from the selected profile."})})()]}):(0,d.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,d.jsx)(z.UM,{label:"Permissions",options:b1.map(a=>({value:a.value,label:a.label})),value:V,onChange:W,compact:!0}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>ay(V),children:"ADD"})]}),0===X.length?(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-danger,#ef4444)]",children:"No permissions selected."}):(0,d.jsx)("div",{className:"flex flex-wrap gap-1",children:X.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[a,(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>az(a),className:"h-4 px-1 text-[8px]",children:"X"})]},`perm-${a}`))}),(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Permissions mode issues exactly the selected permissions."})]}),au.length>1&&(0,d.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,d.jsx)(z.UM,{label:"Vault Scope",options:au,value:au[0]?.value||"vault:*",onChange:a=>{Z.includes(a)||$(b=>[...b,a])},compact:!0}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>$([]),children:"CLEAR"})]}),0===Z.length?(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"No vault restriction — uses profile/system defaults."}):(0,d.jsx)("div",{className:"flex flex-wrap gap-1",children:Z.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[a,(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>$(b=>b.filter(b=>b!==a)),className:"h-4 px-1 text-[8px]",children:"X"})]},`vs-${a}`))})]}),(0,d.jsx)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-2 py-2 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:"Generate a key in one click. Preview is optional and only shows what permissions/scopes will be issued."}),ab&&(0,d.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:ab}),(0,d.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,d.jsx)(z.$n,{size:"sm",onClick:()=>{aG()},loading:_,icon:_?void 0:(0,d.jsx)(k.A,{size:11}),children:"ISSUE API KEY"}),(0,d.jsx)(z.$n,{size:"sm",variant:"secondary",onClick:()=>{aF()},loading:ak,disabled:"permissions"===R,icon:ak?void 0:(0,d.jsx)(F.A,{size:11}),children:"PREVIEW POLICY"})]}),am&&(0,d.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:am}),ao&&(0,d.jsxs)("div",{className:"mt-3 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,d.jsxs)("div",{className:"text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["HASH ",b6(ao.effectivePolicyHash)]}),ao.profile&&(0,d.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["profile: ",ao.profile.id,"@",ao.profile.version]}),(0,d.jsxs)("div",{className:"mt-1 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:["permissions: ",ao.effectivePolicy.permissions.length," \xb7 ttl: ",ao.effectivePolicy.ttlSeconds,"s \xb7 max reads: ",ao.effectivePolicy.maxReads??"unlimited"]}),(0,d.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,d.jsxs)("div",{children:["perms: ",ao.effectivePolicy.permissions.join(", ")||"(none)"]}),(0,d.jsxs)("div",{children:["read scope: ",ao.effectivePolicy.credentialAccess.read.join(", ")||"(none)"]}),(0,d.jsxs)("div",{children:["write scope: ",ao.effectivePolicy.credentialAccess.write.join(", ")||"(none)"]}),(0,d.jsxs)("div",{children:["excluded fields: ",ao.effectivePolicy.credentialAccess.excludeFields.join(", ")||"(none)"]}),(0,d.jsxs)("div",{children:["rate budget: ",ao.effectivePolicy.rateBudget.state," (",ao.effectivePolicy.rateBudget.requests??"n/a"," / ",ao.effectivePolicy.rateBudget.windowSeconds??"n/a","s, source=",ao.effectivePolicy.rateBudget.source,")"]})]}),ao.overrideDelta.length>0&&(0,d.jsxs)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-1.5 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,d.jsx)("div",{className:"mb-1 tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"OVERRIDE DELTA"}),ao.overrideDelta.join(" \xb7 ")]}),ao.denyExamples&&ao.denyExamples.length>0&&(0,d.jsxs)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-1.5 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,d.jsx)("div",{className:"mb-1 tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"EXPECTED DENY EXAMPLES"}),(0,d.jsx)("ul",{className:"space-y-0.5",children:ao.denyExamples.map(a=>(0,d.jsxs)("li",{children:["• ",a.code,": ",a.message]},`${a.code}-${a.message.slice(0,12)}`))})]}),ao.warnings.length>0&&(0,d.jsxs)("div",{className:"mt-2 flex items-start gap-1.5 text-[8px] text-[var(--color-warning,#ff4d00)]",children:[(0,d.jsx)(b_,{size:10,className:"mt-[1px]"}),(0,d.jsx)("span",{children:ao.warnings.join(" | ")})]})]}),ad&&(0,d.jsxs)("div",{className:"mt-3 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,d.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,d.jsx)("div",{className:"text-[8px] tracking-widest text-[var(--color-success,#16a34a)]",children:"API KEY ISSUED"}),(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>{aH()},icon:(0,d.jsx)(ae.A,{size:10}),children:ai?"COPIED":"COPY"})]}),ag&&(0,d.jsx)("div",{className:"mb-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:ag}),(0,d.jsx)("code",{className:"block max-h-20 overflow-y-auto break-all bg-[var(--color-background,#f4f4f5)] px-2 py-1 text-[9px] text-[var(--color-text,#0a0a0a)]",children:ad})]})]}),(0,d.jsxs)("section",{className:"order-2 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,d.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,d.jsx)("div",{className:"text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"PROFILE BUILDER"}),m&&(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:as,children:"NEW"})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,d.jsx)(z.ks,{label:"Profile Name",value:p,onChange:a=>q(a.target.value),placeholder:"e.g. CI deploy scoped",compact:!0}),(0,d.jsx)(z.UM,{label:"Load from template",options:b0.map(a=>({value:a.id,label:`${a.label} — ${a.description}`})),value:r,onChange:a=>{u(a),at(a)},compact:!0}),r&&b2[r]&&(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:b2[r]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,d.jsx)(z.ks,{label:"TTL Override",value:v,onChange:a=>w(a.target.value),placeholder:"seconds",compact:!0}),(0,d.jsx)(z.ks,{label:"Max Reads",value:x,onChange:a=>y(a.target.value),placeholder:"count",compact:!0})]}),(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,d.jsx)(z.UM,{label:"Scope",options:b1.map(a=>({value:a.value,label:a.label})),value:C,onChange:D,compact:!0}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>aC(C),children:"ADD"})]}),0===A.length?(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Using base profile scope defaults."}):(0,d.jsx)("div",{className:"flex flex-wrap gap-1",children:A.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[a,(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>aD(a),className:"h-4 px-1 text-[8px]",children:"X"})]},`scope-${a}`))})]}),(0,d.jsxs)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["Scope uses the same permission vocabulary as Issue API Key (for example: ",(0,d.jsx)("code",{children:"secret:read"}),", ",(0,d.jsx)("code",{children:"secret:write"}),", ",(0,d.jsx)("code",{children:"wallet:create:hot"}),", ",(0,d.jsx)("code",{children:"send:hot"}),")."]}),(0,d.jsx)(z.ks,{label:"Exclude Fields (CSV)",value:E,onChange:a=>G(a.target.value),placeholder:"password, seedPhrase",compact:!0}),au.length>1&&(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,d.jsx)(z.UM,{label:"Vault Read/Write Scope",options:au,value:au[0]?.value||"vault:*",onChange:a=>{I.includes(a)||K(b=>[...b,a])},compact:!0}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>K([]),children:"CLEAR"})]}),0===I.length?(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Using base profile vault defaults."}):(0,d.jsx)("div",{className:"flex flex-wrap gap-1",children:I.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[a,(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>K(b=>b.filter(b=>b!==a)),className:"h-4 px-1 text-[8px]",children:"X"})]},`pvs-${a}`))}),(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Restricts which vaults this profile can read/write credentials from. Select specific vaults or leave empty for profile defaults."})]})]}),L&&(0,d.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:L}),N&&(0,d.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-success,#16a34a)]",children:N}),(0,d.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,d.jsx)(z.$n,{size:"sm",onClick:aA,icon:(0,d.jsx)(H.A,{size:11}),children:m?"UPDATE PROFILE":"CREATE PROFILE"}),m&&(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:as,children:"CANCEL"})]}),(0,d.jsxs)("div",{className:"mt-4 border-t border-[var(--color-border,#d4d4d8)] pt-3",children:[(0,d.jsxs)("div",{className:"mb-2 text-[9px] font-bold tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["SAVED PROFILES (",j.length,")"]}),0===j.length?(0,d.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No custom profiles saved yet."}):(0,d.jsx)("div",{className:"space-y-2",children:j.map(a=>(0,d.jsxs)("div",{className:"flex items-center justify-between border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-2 py-1.5",children:[(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>aB(a),className:"h-auto min-h-0 w-full justify-start px-0 py-0 text-left hover:bg-transparent",children:(0,d.jsxs)("span",{className:"block",children:[(0,d.jsx)("span",{className:"block text-[10px] text-[var(--color-text,#0a0a0a)]",children:a.name}),(0,d.jsxs)("span",{className:"block text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:[a.profile,"@",a.profileVersion]})]})}),(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>aE(a.id),icon:(0,d.jsx)(J.A,{size:10}),children:""})]},a.id))})]})]})]}),(0,d.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2",children:[(0,d.jsxs)("section",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,d.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"PENDING AUTH REQUESTS"}),aq&&(0,d.jsx)("div",{className:"mb-2 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:aq}),0===av.length?(0,d.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No pending auth requests."}):(0,d.jsx)("div",{className:"space-y-2",children:av.map(a=>{let b=function(a){if(!a)return{};try{let b=JSON.parse(a);if(b&&"object"==typeof b)return b;return{}}catch{return{}}}(a.metadata),c="string"==typeof b.agentId?b.agentId:"unknown-agent",e="object"==typeof b.profile&&b.profile&&"id"in b.profile?b.profile:null,g=e?`${String(e.id)}@${String(e.version||"v1")}`:"n/a",h=e?function(a){return b2[a]||`Custom profile: ${a}`}(String(e.id)):null,i=Array.isArray(b.permissions)?b.permissions:[],j=f===`resolve-${a.id}`;return(0,d.jsxs)("div",{className:"rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,d.jsxs)("div",{className:"text-[9px] text-[var(--color-text,#0a0a0a)]",children:[c," \xb7 ",a.type]}),(0,d.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:[g," \xb7 ",new Date(a.createdAt).toLocaleString()]}),h&&(0,d.jsx)("div",{className:"mt-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:h}),i.length>0&&(0,d.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1",children:[i.slice(0,6).map(a=>(0,d.jsx)("span",{className:"border border-[var(--color-border,#d4d4d8)] px-1 py-0.5 text-[7px] text-[var(--color-text-muted,#6b7280)]",children:String(a)},a)),i.length>6&&(0,d.jsxs)("span",{className:"px-1 py-0.5 text-[7px] text-[var(--color-text-faint,#9ca3af)]",children:["+",i.length-6," more"]})]}),(0,d.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,d.jsx)(z.$n,{size:"sm",onClick:()=>{aI(a.id,!0)},loading:j,icon:j?void 0:(0,d.jsx)(bu.A,{size:10}),children:"APPROVE"}),(0,d.jsx)(z.$n,{size:"sm",variant:"secondary",onClick:()=>{aI(a.id,!1)},disabled:j,icon:(0,d.jsx)(bK.A,{size:10}),children:"REJECT"})]})]},a.id)})})]}),(0,d.jsxs)("section",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,d.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"ISSUED API KEYS"}),(0,d.jsxs)("div",{className:"mb-2 text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["ACTIVE (",aJ.length,")"]}),0===aJ.length?(0,d.jsx)("div",{className:"mb-3 text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No active non-admin tokens."}):(0,d.jsx)("div",{className:"mb-3 space-y-2",children:aJ.map(a=>{let b=f===`revoke-${a.tokenHash}`;return(0,d.jsxs)("div",{className:"rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("div",{className:"text-[9px] text-[var(--color-text,#0a0a0a)]",children:a.agentId}),(0,d.jsx)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:b6(a.tokenHash)})]}),(0,d.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["perms: ",a.permissions.length," \xb7 expires: ",new Date(a.expiresAt).toLocaleString()]}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(z.$n,{size:"sm",variant:"secondary",onClick:()=>{h(a.tokenHash)},disabled:b,icon:b?(0,d.jsx)(n.A,{size:10,className:"animate-spin"}):(0,d.jsx)(J.A,{size:10}),children:"REVOKE"})})]},a.tokenHash)})}),(0,d.jsxs)("div",{className:"mb-2 text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["INACTIVE (",c.length,")"]}),0===c.length?(0,d.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No inactive tokens."}):(0,d.jsxs)("div",{className:"space-y-1.5",children:[c.slice(0,8).map(a=>(0,d.jsxs)("div",{className:"flex items-center justify-between rounded border border-[var(--color-border,#d4d4d8)] px-2 py-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,d.jsx)("span",{children:a.agentId}),(0,d.jsx)("span",{children:b6(a.tokenHash)})]},`${a.agentId}-${a.tokenHash}`)),c.length>8&&(0,d.jsxs)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["+",c.length-8," more inactive tokens"]})]})]})]})]})};var ca=c(38998),cb=c(64354);let cc={vaultId:null,category:"all",tag:null,search:"",favoritesOnly:!1,lifecycle:"active"},cd=[{value:"linked",label:"Child (inherits parent unlock)"},{value:"independent",label:"Independent (separate password)"}],ce=["username","url","content","key","value","cardholder","brand","last4","token_endpoint","scopes","fingerprint"],cf={active:"active",archive:"archive",archived:"archive",deleted:"recently_deleted",recently_deleted:"recently_deleted",recentlydeleted:"recently_deleted"},cg=(()=>{let a=new Map;for(let b of Object.values(y.Rn))for(let c of b)for(let b of(a.set(c.key.toLowerCase(),c.key),c.aliases||[]))a.set(b.toLowerCase(),c.key);return a})(),ch=(()=>{let a=[...ce,...Array.from(cg.values())],b=new Set,c=[];for(let d of a){let a=d.toLowerCase();b.has(a)||(b.add(a),c.push(d))}return c.slice(0,8)})();function ci(a){return a.location?a.location:a.deletedAt?"recently_deleted":a.archivedAt?"archive":"active"}function cj(a){let b=a.createdAt?Date.parse(a.createdAt):NaN;return Number.isFinite(b)?b:0}function ck(a,b){let c=b[a.id];return"number"==typeof c&&Number.isFinite(c)&&c>0?c:cj(a)}function cl(a,b){let c={};for(let d of a){let a=b[d.id];if("number"==typeof a&&Number.isFinite(a)&&a>0){c[d.id]=a;continue}c[d.id]=cj(d)}return c}function cm(a){return a.trim().toLowerCase()}function cn(a){return null==a?"":"string"==typeof a||"number"==typeof a||"boolean"==typeof a?String(a).toLowerCase():Array.isArray(a)?a.map(cn).join(" "):"object"==typeof a?Object.values(a).map(cn).join(" "):""}function co(a){let b=a.trim().toLowerCase().replace(/\s+/g,"_");return cg.get(b)||b}let cp=({onLock:a,onSettings:b})=>{let{subscribe:c}=(0,bL.h)(),[f,g]=(0,e.useState)([]),[h,i]=(0,e.useState)([]),[j,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(cc),[n,o]=(0,e.useState)(!0),[p,q]=(0,e.useState)("credentials"),[t,y]=(0,e.useState)({}),[A,B]=(0,e.useState)({}),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(()=>"desktop"),{clearToken:I,setToken:J}=(0,r.A)(),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(!1),[O,P]=(0,e.useState)(!1),[Q,R]=(0,e.useState)("api-key-form"),[S,T]=(0,e.useState)(null),[U,V]=(0,e.useState)(null),[W,Y]=(0,e.useState)(!1),[Z,$]=(0,e.useState)(""),[_,aa]=(0,e.useState)("independent"),[ab,ae]=(0,e.useState)(""),[af,ag]=(0,e.useState)(""),[ah,ai]=(0,e.useState)(!1),[aj,ak]=(0,e.useState)(!1),[al,am]=(0,e.useState)(""),[an,ao]=(0,e.useState)(!1),[ap,aq]=(0,e.useState)(!1),[ar,as]=(0,e.useState)(null),[at,au]=(0,e.useState)(""),[av,aw]=(0,e.useState)(!1),[ax,ay]=(0,e.useState)(null),[az,aA]=(0,e.useState)(null),[aB,aC]=(0,e.useState)(!1),[aD,aE]=(0,e.useState)(null),{requests:aF,notifications:aG,dismissNotification:aH,resolveAction:aI,revokeToken:aJ=async()=>!1,activeTokens:aK=[],inactiveTokens:aL=[],actionLoading:aM}=(0,cb.S)({autoFetch:!0}),aN=(0,e.useRef)(null),aO=(0,e.useRef)(null),aP=(0,e.useRef)(null),aQ=(0,e.useRef)(null),aR="mobile"===G,aS="tablet"===G,aT=(0,e.useCallback)(async()=>{try{let[a,b,c,d]=await Promise.all([s.FH.get(s.jI.Wallet,"/credentials",{location:"active"}),s.FH.get(s.jI.Wallet,"/credentials",{location:"archive"}),s.FH.get(s.jI.Wallet,"/credentials",{location:"recently_deleted"}),s.FH.get(s.jI.Wallet,"/vaults/credential")]),e=(a,b)=>a.success?(a.credentials||[]).map(a=>({...a,location:b})):[],f=[...e(a,"active"),...e(b,"archive"),...e(c,"recently_deleted")];g(f),y(a=>cl(f,a)),B(a=>cl(f,a)),d.success&&i(d.vaults)}catch(a){console.error("[CredentialVault] fetch error:",a)}finally{o(!1)}},[]);(0,e.useEffect)(()=>{aT()},[aT]),(0,e.useEffect)(()=>{},[]),(0,e.useEffect)(()=>{},[t]);let aU=(0,e.useCallback)((a,b=Date.now())=>{y(c=>{let d=Number.isFinite(b)&&b>0?b:Date.now();return c[a]===d?c:{...c,[a]:d}})},[]),aV=(0,e.useCallback)(()=>{aP.current||(aP.current=setTimeout(()=>{aP.current=null,aT()},120))},[aT]);(0,e.useEffect)(()=>{let a=c(bM.Cw.CREDENTIAL_CHANGED,a=>{let b=a.data;b?.credentialId&&aV()}),b=c(bM.Cw.CREDENTIAL_ACCESSED,a=>{let b=a.data;b?.credentialId&&!0===b.allowed&&aU(b.credentialId)});return()=>{a(),b(),aP.current&&(clearTimeout(aP.current),aP.current=null),aQ.current&&(clearTimeout(aQ.current),aQ.current=null)}},[aV,c,aU]),(0,e.useEffect)(()=>{j&&!f.some(a=>a.id===j)&&(k(null),N(!1))},[f,j]),(0,e.useEffect)(()=>{let a=()=>{var a;return H((a=window.innerWidth)<768?"mobile":a<1280?"tablet":"desktop")};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),(0,e.useEffect)(()=>{aR||(L(!1),N(!1))},[aR]),(0,e.useEffect)(()=>{if(!C)return;let a=a=>{let b=a.target;b&&(aO.current?.contains(b)||(aQ.current&&(clearTimeout(aQ.current),aQ.current=null),F(!1),D(!1)))};return document.addEventListener("mousedown",a),document.addEventListener("touchstart",a),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("touchstart",a)}},[C]);let aW=(0,e.useMemo)(()=>h.find(a=>a.isPrimary)?.id||"",[h]),aX=(0,e.useMemo)(()=>h.map(a=>({value:a.id,label:a.name||(a.isPrimary?"Primary":`Vault ${a.id.slice(0,6)}`)})),[h]);(0,e.useEffect)(()=>{W&&ae(a=>a&&aX.some(b=>b.value===a)?a:l.vaultId||aW||aX[0]?.value||"")},[l.vaultId,aX,aW,W]),(0,e.useEffect)(()=>{if(0===h.length)return void am("primary");let a=aW||h[0].id||"primary";am(b=>b&&h.some(a=>a.id===b)?b:a)},[aW,h]);let aY=(0,e.useMemo)(()=>{if(!l.vaultId)return null;let a=h.find(a=>a.id===l.vaultId);return new Set(a?function(a,b){let c=new Map;for(let a of b){let b=a.parentVaultId||a.linkedTo;if(!b)continue;let d=c.get(b)||[];d.push(a),c.set(b,d)}let d=[],e=[a],f=new Set;for(;e.length>0;){let a=e.shift();if(!f.has(a))for(let b of(f.add(a),d.push(a),c.get(a)||[]))e.push(b.id)}return d}(a.id,h):[l.vaultId])},[l.vaultId,h]),aZ=(0,e.useCallback)(a=>aY?a.filter(a=>aY.has(a.vaultId)):a,[aY]),a$=(0,e.useMemo)(()=>{let a=new Map;for(let b of h)a.set(b.id,(b.name||(b.isPrimary?"Primary":`Vault ${b.id.slice(0,6)}`)).toLowerCase());return a},[h]),a_=(0,e.useMemo)(()=>{let a=function(a){let b={terms:[],tagFilters:[],typeFilters:[],vaultFilters:[],fieldFilters:[],lifecycleFilters:new Set,favoriteOnly:!1};for(let c of a.trim().split(/\s+/).map(a=>a.trim()).filter(Boolean)){let a=cm(c);if("favorite"===a||"favourite"===a||"fav"===a){b.favoriteOnly=!0;continue}let d=cf[a];if(d){b.lifecycleFilters.add(d);continue}let e=c.indexOf(":");if(e<=0){b.terms.push(a);continue}let f=cm(c.slice(0,e)),g=cm(c.slice(e+1).trim());if(g){if("tag"===f){b.tagFilters.push(g);continue}if("type"===f){b.typeFilters.push(g);continue}if("vault"===f){b.vaultFilters.push(g);continue}if("lifecycle"===f||"location"===f){let a=cf[g];a&&b.lifecycleFilters.add(a);continue}if("favorite"===f||"fav"===f){b.favoriteOnly=!["false","0","no"].includes(g);continue}b.fieldFilters.push({key:co(f),value:g})}}return b}(l.search),b=a.lifecycleFilters.size>0,c=a.terms,d=aZ(f);if(d=b?d.filter(b=>a.lifecycleFilters.has(ci(b))):d.filter(a=>ci(a)===l.lifecycle),"all"!==l.category&&(d=d.filter(a=>a.type===l.category)),(l.favoritesOnly||a.favoriteOnly)&&(d=d.filter(a=>!!a.meta.favorite)),l.tag){let a=cm(l.tag);d=d.filter(b=>(b.meta.tags||[]).some(b=>cm(b).includes(a)))}a.tagFilters.length>0&&(d=d.filter(b=>{let c=(b.meta.tags||[]).map(a=>cm(a));return a.tagFilters.every(a=>c.some(b=>b.includes(a)))})),a.typeFilters.length>0&&(d=d.filter(b=>a.typeFilters.some(a=>cm(b.type).includes(a)))),a.vaultFilters.length>0&&(d=d.filter(b=>{let c=a$.get(b.vaultId)||cm(b.vaultId);return a.vaultFilters.every(a=>c.includes(a)||cm(b.vaultId).includes(a))}));let e=d,g=d;return a.fieldFilters.length>0&&(g=g.filter(b=>a.fieldFilters.every(a=>(function(a,b,c){let d=co(b);for(let[b,e]of Object.entries(a.meta||{}))if(co(b)===d&&cn(e).includes(c))return!0;return!1})(b,a.key,a.value)))),c.length>0&&(g=g.filter(a=>{let b=ci(a),d=(a.meta.tags||[]).map(a=>cm(a)).join(" "),e=a$.get(a.vaultId)||cm(a.vaultId),f=cn(a.meta),g=[cm(a.name),cm(a.id),cm(a.type),d,e,f].join(" ");return c.every(c=>{if("favorite"===c||"favourite"===c||"fav"===c)return!!a.meta.favorite;let d=cf[c];return d?b===d:g.includes(c)})})),{parsed:a,preTextFiltered:e,results:g}},[f,l,aZ,a$]),a0=a_.results,a1=(0,e.useMemo)(()=>ac(a0,A,l.search),[a0,A,l.search]),a2=(0,e.useMemo)(()=>{let a=l.search.trim();if(!a||a.includes(":")||a0.length>0)return[];let b=cm(a);return a_.preTextFiltered.some(a=>cm(a.name).includes(b))?[]:ch.map(b=>`${b}:${a}`)},[l.search,a0.length,a_.preTextFiltered]),a3=(0,e.useMemo)(()=>{let a=aZ(f).filter(a=>ci(a)===l.lifecycle);if(l.tag){let b=l.tag;a=a.filter(a=>a.meta.tags?.includes(b))}return l.favoritesOnly&&(a=a.filter(a=>a.meta.favorite)),{all:a.length,login:a.filter(a=>"login"===a.type).length,card:a.filter(a=>"card"===a.type).length,note:a.filter(a=>"note"===a.type).length,plain_note:a.filter(a=>"plain_note"===a.type).length,hot_wallet:a.filter(a=>"hot_wallet"===a.type).length,api:a.filter(a=>"api"===a.type).length,apikey:a.filter(a=>"apikey"===a.type).length,custom:a.filter(a=>"custom"===a.type).length,passkey:a.filter(a=>"passkey"===a.type).length,oauth2:a.filter(a=>"oauth2"===a.type).length,ssh:a.filter(a=>"ssh"===a.type).length,gpg:a.filter(a=>"gpg"===a.type).length}},[f,l.lifecycle,l.tag,l.favoritesOnly,aZ]),a4=(0,e.useMemo)(()=>{let a=new Set;return aZ(f).filter(a=>ci(a)===l.lifecycle).forEach(b=>b.meta.tags?.forEach(b=>a.add(b))),Array.from(a).sort()},[f,l.lifecycle,aZ]),a5=(0,e.useMemo)(()=>aZ(f).filter(a=>ci(a)===l.lifecycle).filter(a=>a.meta.favorite).length,[f,l.lifecycle,aZ]),a6=(0,e.useMemo)(()=>f.find(a=>a.id===j)||null,[f,j]),a7=(0,e.useMemo)(()=>{if(!a6)return"";let a=h.find(a=>a.id===a6.vaultId);return a?a.name||(a.isPrimary?"Primary":a.id.slice(0,8)):"primary"===a6.vaultId?"Primary":a6.vaultId.slice(0,8)},[a6,h]),a8=(0,e.useMemo)(()=>a6?ci(a6):l.lifecycle,[a6,l.lifecycle]),a9=(0,e.useMemo)(()=>[...f].sort((a,b)=>ck(b,t)-ck(a,t)).slice(0,8),[f,t]),ba=(0,e.useCallback)((a=120)=>{aQ.current&&clearTimeout(aQ.current),aQ.current=setTimeout(()=>{E||D(!1),aQ.current=null},a)},[E]),bb=(0,e.useMemo)(()=>ar?ar.name||(ar.isPrimary?"Primary":`Vault ${ar.id.slice(0,6)}`):"Vault",[ar]),bc=(0,e.useMemo)(()=>az?az.name||(az.isPrimary?"Primary":`Vault ${az.id.slice(0,6)}`):"Vault",[az]),bd=(0,e.useMemo)(()=>null!==l.vaultId||"all"!==l.category||null!==l.tag||""!==l.search.trim()||l.favoritesOnly,[l]),be=(0,e.useCallback)(a=>{m(b=>({...b,...a}))},[]),bf=(0,e.useCallback)(()=>{m(cc)},[]),bg=(0,e.useCallback)(async()=>{try{await s.FH.post(s.jI.Wallet,"/lock",{})}catch(a){console.error("[CredentialVault] lock error:",a)}I(),a()},[a,I]);(0,e.useCallback)(a=>{as(a),au(""),ay(null)},[]);let bh=(0,e.useCallback)(()=>{as(null),au(""),ay(null)},[]),bi=(0,e.useCallback)(async()=>{if(ar&&at){aw(!0),ay(null);try{let a=await (0,s.WE)(at,ar.id);a.token&&J(a.token),await aT(),m(a=>({...a,vaultId:ar.id,lifecycle:"active",tag:null})),bh()}catch(a){ay(a.message||"Failed to unlock vault")}finally{aw(!1)}}},[at,ar,J,aT,bh]),bj=(0,e.useCallback)(async a=>{try{await s.FH.post(s.jI.Wallet,`/vaults/credential/${encodeURIComponent(a)}/lock`,{}),await aT()}catch(a){console.error("[CredentialVault] lock vault error:",a)}},[aT]),bk=(0,e.useCallback)(a=>{aA(a),aE(null)},[]),bl=(0,e.useCallback)(()=>{aB||(aA(null),aE(null))},[aB]),bm=(0,e.useCallback)(async()=>{if(az){aC(!0),aE(null);try{await s.FH.delete(s.jI.Wallet,`/vaults/credential/${encodeURIComponent(az.id)}`),m(a=>a.vaultId===az.id?{...a,vaultId:null,lifecycle:"active",tag:null}:a),a6?.vaultId===az.id&&(k(null),N(!1)),await aT(),aA(null)}catch(a){aE(a.message||"Failed to delete vault")}finally{aC(!1)}}},[az,aT,a6]),bn=(0,e.useCallback)(async()=>{if(j)try{let a=encodeURIComponent(a8);await s.FH.delete(s.jI.Wallet,`/credentials/${j}?location=${a}`),k(null),N(!1),aT()}catch(a){console.error("[CredentialVault] delete error:",a)}},[j,a8,aT]),bo=(0,e.useCallback)(async()=>{if(j&&"active"!==a8)try{await s.FH.post(s.jI.Wallet,`/credentials/${j}/restore`,{from:a8}),k(null),N(!1),aT()}catch(a){console.error("[CredentialVault] restore error:",a)}},[j,a8,aT]),bp=(0,e.useCallback)(async()=>{if(j)try{let a=await s.FH.post(s.jI.Wallet,`/credentials/${j}/duplicate`);await aT(),a.credential&&k(a.credential.id)}catch(a){console.error("[CredentialVault] duplicate error:",a)}},[j,aT]),bq=(0,e.useCallback)(()=>{$(""),aa("independent"),ae(""),ag("")},[]),br=(0,e.useCallback)(()=>{Y(!1),ao(!1),bq()},[bq]),bs=(0,e.useCallback)(async()=>{if(Z.trim()&&("independent"!==_||!(af.length<8))&&("linked"!==_||ab)){ai(!0);try{let a={name:Z.trim(),mode:_};if("linked"===_)a.parentVaultId=ab;else{let b=await s.FH.get(s.jI.Wallet,"/auth/connect");a.encrypted=await (0,x.X)(af,b.publicKey)}let b=await s.FH.post(s.jI.Wallet,"/vaults/credential",a),c=b?.vault?.id;an&&c&&am(c),Y(!1),ao(!1),bq(),await aT()}catch(a){console.error("[CredentialVault] create vault error:",a)}finally{ai(!1)}}},[Z,_,ab,af,an,aT,bq]),bt=(0,e.useCallback)(a=>{a?(aa("linked"),ae(a)):(aa("independent"),ae(""),ag("")),Y(!0)},[]),bu=(0,e.useCallback)(()=>{am(aW||h[0]?.id||"primary"),ak(!0)},[aW,h]),bv=(0,e.useCallback)(()=>{ao(!0),bt()},[bt]),bw=(0,e.useCallback)((a="api-key-form",b)=>{let c={};l.vaultId&&(c.vaultId=l.vaultId),b?.applyFilters?(l.tag&&(c.tags=[l.tag]),b.prefillType?c.type=b.prefillType:l.category&&"all"!==l.category&&(c.type=l.category)):b?.prefillType&&(c.type=b.prefillType),V(null),R(a),T(Object.keys(c).length>0?c:null),P(!0)},[l]),bx=(0,e.useCallback)(async a=>{P(!1),V(null),T(null),await aT(),a&&(k(a),aU(a),aR&&N(!0))},[aT,aR,aU]),by=(0,e.useCallback)(a=>{k(a),aU(a),aR&&N(!0)},[aR,aU]),bz=(0,e.useCallback)(a=>{be({search:a}),D(!1),requestAnimationFrame(()=>aN.current?.focus())},[be]),bA=(0,e.useCallback)(a=>{be({search:a.name}),by(a.id),D(!1)},[be,by]),bE=(0,e.useMemo)(()=>l.search.trim()?[]:["tag:work","type:login","vault:primary","favorite","archived","recently_deleted"],[l.search]),bF=(C||E)&&""===l.search.trim();return(!function({filteredCredentials:a,selectedId:b,isMobile:c,searchRef:d,onCreateCredential:e,setSelectedId:f,setMobileDetailOpen:g}){}({filteredCredentials:a1,selectedId:j,isMobile:aR,searchRef:aN,onCreateCredential:()=>bw("api-key-form"),setSelectedId:k,setMobileDetailOpen:N}),n)?(0,d.jsxs)("div",{className:"h-screen w-screen flex items-center justify-center bg-[var(--color-background,#f4f4f5)] relative isolate vault-surface",children:[(0,d.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,d.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"})]}),(0,d.jsxs)("div",{className:"flex flex-col items-center relative z-10",children:[(0,d.jsx)("div",{className:"w-6 h-6 border-2 border-[var(--color-border,#d4d4d8)] border-t-[var(--color-text,#0a0a0a)] animate-spin"}),(0,d.jsx)("div",{className:"mt-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest",children:"LOADING VAULT"})]})]}):(0,d.jsxs)("div",{className:"relative isolate h-screen w-screen overflow-hidden flex flex-col bg-[var(--color-background,#f4f4f5)] vault-surface",children:[(0,d.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,d.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"}),(0,d.jsx)("div",{className:"absolute bottom-[5%] right-[5%] opacity-[0.03] select-none",children:(0,d.jsx)("div",{className:"text-[12vw] font-black leading-none text-[var(--color-text,#0a0a0a)] font-mono tracking-tighter text-right",children:"AURAMAXX"})}),(0,d.jsx)("div",{className:"absolute top-10 left-[200px] w-24 h-24 border-l-4 border-t-4 border-[var(--color-text,#0a0a0a)] opacity-10",children:(0,d.jsx)("div",{className:"absolute top-2 left-2 w-3 h-3 bg-[var(--color-text,#0a0a0a)]"})}),(0,d.jsx)("div",{className:"absolute bottom-10 right-10 w-24 h-24 border-r-4 border-b-4 border-[var(--color-text,#0a0a0a)] opacity-10 flex items-end justify-end",children:(0,d.jsx)("div",{className:"absolute bottom-2 right-2 w-3 h-3 bg-[var(--color-text,#0a0a0a)]"})})]}),(0,d.jsxs)("div",{className:"relative z-10 flex-1 flex overflow-hidden",children:[!aR&&!aS&&(0,d.jsx)(X,{vaults:h,filters:l,categoryCounts:a3,tags:a4,favoritesCount:a5,onFilterChange:be,onLock:bg,onLockVault:bj,onCreateCredential:(a,b)=>bw("type-picker"===a?"type-picker":"api-key-form",b?{prefillType:b}:void 0),onCreateVault:bt,mode:"desktop",notifications:aG,onDismissNotification:aH,pendingActionCount:aG.filter(a=>"pending"===a.status&&"notify"!==a.type).length,surface:p,onSurfaceChange:q,onSettings:b,onDeleteVault:bk}),aS&&(0,d.jsxs)("div",{className:"h-full w-12 shrink-0 border-r border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#f4f4f2)] flex flex-col items-center pt-3 gap-3 relative z-10",children:[(0,d.jsx)("img",{src:"/logo.webp",alt:"Aura",className:"w-6 h-6 object-contain"}),(0,d.jsx)("button",{type:"button",onClick:()=>L(!0),className:"flex items-center justify-center w-7 h-7 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors rounded","aria-label":"Open sidebar",title:"Open sidebar",children:(0,d.jsx)(u,{size:14})})]}),"audit"===p?(0,d.jsx)("div",{className:"flex-1 h-full overflow-hidden",children:(0,d.jsx)(b$,{})}):"apiKeys"===p?(0,d.jsx)("div",{className:"flex-1 h-full overflow-hidden",children:(0,d.jsx)(b9,{requests:aF,activeTokens:aK,inactiveTokens:aL,actionLoading:aM,onResolveAction:aI,onRevokeToken:aJ,vaults:h})}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ad,{credentials:a0,latestAccessById:A,selectedId:j,searchQuery:l.search,onSearchChange:a=>be({search:a}),onSelect:by,onAdd:()=>bw("api-key-form"),onCreateWithFilter:bd?()=>bw("api-key-form",{applyFilters:!0}):void 0,canAdd:"active"===l.lifecycle,onImport:bu,canImport:"active"===l.lifecycle,onOpenGenerator:()=>aq(!0),onClearFilters:bf,hasActiveFilters:bd,fieldSearchSuggestions:a2,onApplySearchSuggestion:bz,searchInputRef:aN,showSearch:!1,className:aR?"flex-1 h-full flex flex-col pb-14 min-w-0":"w-[300px] h-full flex flex-col pb-14 border-r border-[var(--color-border,#d4d4d8)]",leadingAction:aR?(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",icon:(0,d.jsx)(u,{size:12}),onClick:()=>L(!0),className:"!px-1.5 !h-8 !w-8","aria-label":"Open sidebar",title:"Open sidebar"}):void 0}),!aR&&(0,d.jsx)("div",{className:"flex-1 h-full overflow-y-auto pb-14",children:a6?(0,d.jsx)(bB,{credential:a6,vaultName:a7,lifecycle:a8,onEdit:()=>V(a6.id),onDelete:bn,onRestore:bo,onDuplicate:bp}):(0,d.jsx)(bC,{variant:"active"!==l.lifecycle?"empty-lifecycle":0===f.filter(a=>"active"===ci(a)).length?"empty-vault":"no-selection",onAdd:"active"===l.lifecycle?()=>bw("api-key-form"):void 0})})]}),"credentials"===p&&(0,d.jsx)("div",{className:`absolute bottom-0 z-30 border-t border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#ffffff)]/95 backdrop-blur-sm ${aR?"left-0 right-0 w-full":`${aS?"left-12":"left-[200px]"} right-0`}`,children:(0,d.jsx)("div",{className:"w-full px-3 py-2.5",children:(0,d.jsxs)("div",{ref:aO,className:"relative w-full",children:[bF&&(0,d.jsxs)("div",{"data-testid":"search-dock-panel",className:"absolute bottom-full left-0 w-full mb-1 bg-[var(--color-surface,#ffffff)] border border-[var(--color-border-focus,#0a0a0a)] shadow-mech max-h-56 overflow-y-auto z-20",children:[a9.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-3 py-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] border-b border-[var(--color-border-muted,#e5e7eb)] flex items-center gap-1.5",children:[(0,d.jsx)(v,{size:11}),"Recently Accessed"]}),a9.map(a=>(0,d.jsxs)("button",{type:"button",className:"w-full text-left px-4 py-2.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] font-mono text-xs border-b border-[var(--color-border-muted,#e5e5e5)] last:border-0",onMouseDown:b=>{b.preventDefault(),bA(a)},children:[(0,d.jsx)("div",{className:"text-[var(--color-text,#0a0a0a)] truncate",children:a.name}),(0,d.jsxs)("div",{className:"text-[9px] uppercase tracking-wider truncate",children:[a$.get(a.vaultId)||a.vaultId," \xb7 ",ci(a)]})]},a.id))]}),0===a9.length&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] border-b border-[var(--color-border-muted,#e5e7eb)]",children:"Try Structured Search"}),bE.map(a=>(0,d.jsxs)("button",{type:"button",className:"w-full text-left px-4 py-2.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] font-mono text-xs border-b border-[var(--color-border-muted,#e5e5e5)] last:border-0 flex items-center gap-2 group/item",onMouseDown:b=>{b.preventDefault(),bz(a)},children:[(0,d.jsx)("div",{className:"w-1.5 h-1.5 flex-shrink-0 bg-[var(--color-border,#d4d4d8)] group-hover/item:bg-[var(--color-text,#0a0a0a)]"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:a})]},a))]})]}),(0,d.jsx)(z.ks,{compact:!0,leftElement:(0,d.jsx)(w.A,{size:12}),placeholder:"Search...",value:l.search,onChange:a=>be({search:a.target.value}),inputRef:aN,onFocus:()=>{F(!0)},onClick:()=>{aQ.current&&(clearTimeout(aQ.current),aQ.current=null),D(!0)},onBlur:()=>{F(!1),ba()}})]})})})]}),(0,d.jsx)(ca.Z,{requests:aF,resolveAction:aI,actionLoading:aM}),aR&&(0,d.jsx)(z._s,{isOpen:M&&null!=a6,onClose:()=>N(!1),title:a6?.name||"Credential",subtitle:a7||"Credential_Detail",width:"full",children:a6?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>N(!1),className:"mb-3",children:"BACK"}),(0,d.jsx)(bB,{credential:a6,vaultName:a7,lifecycle:a8,onEdit:()=>V(a6.id),onDelete:bn,onRestore:bo,onDuplicate:bp})]}):(0,d.jsx)(bC,{variant:"active"!==l.lifecycle?"empty-lifecycle":0===f.length?"empty-vault":"no-selection",onAdd:"active"===l.lifecycle?()=>bw("api-key-form"):void 0})}),(aR||aS)&&K&&(0,d.jsxs)("div",{className:"absolute inset-0 z-40",children:[(0,d.jsx)("button",{type:"button","aria-label":"Close sidebar",onClick:()=>L(!1),className:"absolute inset-0 bg-[var(--color-text,#0a0a0a)]/20"}),(0,d.jsx)("div",{className:"absolute left-0 top-0 h-full",children:(0,d.jsx)(X,{vaults:h,filters:l,categoryCounts:a3,tags:a4,favoritesCount:a5,onFilterChange:be,onLock:bg,onLockVault:bj,onCreateCredential:(a,b)=>bw("type-picker"===a?"type-picker":"api-key-form",b?{prefillType:b}:void 0),onCreateVault:bt,mode:"mobile",onNavigate:()=>L(!1),notifications:aG,onDismissNotification:aH,pendingActionCount:aG.filter(a=>"pending"===a.status&&"notify"!==a.type).length,surface:p,onSurfaceChange:q,onSettings:b,onDeleteVault:bk})})]}),(0,d.jsx)(z.aF,{isOpen:null!=az,onClose:bl,title:`Delete ${bc}?`,size:"sm",footer:(0,d.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:bl,disabled:aB,children:"CANCEL"}),(0,d.jsx)(z.$n,{variant:"danger",size:"sm",onClick:bm,loading:aB,children:"DELETE"})]}),children:(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"This will permanently delete the vault and its credentials."}),aD&&(0,d.jsx)("div",{className:"text-[10px] text-[var(--color-danger,#ef4444)] border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 px-3 py-2",children:aD})]})}),(0,d.jsx)(z.aF,{isOpen:null!=ar,onClose:bh,title:`Unlock ${bb}`,size:"sm",footer:(0,d.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:bh,children:"CANCEL"}),(0,d.jsx)(z.$n,{size:"sm",onClick:bi,loading:av,disabled:!at,children:"UNLOCK"})]}),children:(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)(z.ks,{label:"Vault Password",type:"password",placeholder:"Enter vault password",value:at,onChange:a=>au(a.target.value),autoFocus:!0}),ax&&(0,d.jsx)("div",{className:"text-[10px] text-[var(--color-danger,#ef4444)] border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 px-3 py-2",children:ax})]})}),(0,d.jsx)(bD.i,{isOpen:O||!!U,onClose:()=>{P(!1),V(null),T(null)},onSaved:bx,editCredentialId:U??void 0,vaults:h,createStartStep:"type-picker"===Q?"type":"form",createStartType:"type-picker"===Q?void 0:"apikey",createPrefill:S??void 0}),(0,d.jsx)(bI,{isOpen:aj,onClose:()=>ak(!1),onComplete:aT,vaults:h,selectedVaultId:al,onSelectedVaultIdChange:am,onAddVault:bv,walletBaseUrl:(0,s.au)()}),(0,d.jsx)(bJ.p,{isOpen:ap,onClose:()=>aq(!1),onUse:a=>{aq(!1),navigator.clipboard.writeText(a).catch(()=>{})}}),(0,d.jsx)(z.aF,{isOpen:W,onClose:br,title:"New Vault",size:"md",footer:(0,d.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:br,children:"CANCEL"}),(0,d.jsx)(z.$n,{size:"sm",onClick:bs,loading:ah,disabled:!Z.trim()||"linked"===_&&!ab||"independent"===_&&af.length<8,children:"CREATE"})]}),children:(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)(z.ks,{label:"Vault Name",placeholder:"e.g. Work, Personal",value:Z,onChange:a=>$(a.target.value),autoFocus:!0}),(0,d.jsx)(z.UM,{label:"Vault Type",options:cd,value:_,onChange:a=>{aa(a),"independent"!==a&&ag("")},compact:!0}),"linked"===_&&(0,d.jsx)(z.UM,{label:"Parent Vault",options:aX,value:ab,onChange:ae,disabled:0===aX.length,compact:!0}),"independent"===_&&(0,d.jsx)(z.ks,{label:"Vault Password",type:"password",placeholder:"At least 8 characters",value:af,onChange:a=>ag(a.target.value)})]})})]})};var cq=c(93535),cr=c(60125),cs=c(71287),ct=c(24328);function cu(){let{updateAvailable:a,current:b,latest:c,updating:e,updateError:f,updateOutput:g,runUpdate:h,apiServerDown:i,restartingServer:j,restartError:k,runRestart:l}=(0,ct.e)();return i||k||a||g||f?i||k?(0,d.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[9999] px-4 py-2.5 font-mono text-[11px] flex items-center justify-between gap-3",style:{background:"var(--color-warning, #ff4d00)",color:"#fff"},children:[(0,d.jsx)("span",{children:"API SERVER OFFLINE. RUN: auramaxx restart"}),(0,d.jsx)(z.$n,{type:"button",onClick:()=>{l()},loading:j,variant:"primary",size:"sm",children:"RESTART NOW"}),k&&(0,d.jsx)("span",{className:"text-[10px]",style:{color:"#fff",opacity:.9},children:k})]}):g&&!a?(0,d.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[100] px-3 py-2 border text-[9px] font-mono tracking-widest flex items-center justify-center gap-3",style:{color:"var(--color-accent-foreground, #0a0a0a)",borderColor:"var(--color-accent, #ccff00)",background:"var(--color-accent, #ccff00)"},children:[(0,d.jsxs)("span",{children:["UPDATE COMPLETE — AURAMAXX ",c," READY"]}),(0,d.jsx)(z.$n,{type:"button",size:"sm",variant:"primary",onClick:()=>{window.location.reload()},children:"RESTART"})]}):(0,d.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[9999] px-4 py-2.5 font-mono text-[11px] flex items-center justify-between gap-3",style:{background:"var(--color-warning, #ff4d00)",color:"#fff"},children:[(0,d.jsxs)("span",{children:["UPDATE AVAILABLE: ",b," → ",c]}),(0,d.jsx)(z.$n,{type:"button",onClick:()=>{h()},loading:e,variant:"primary",size:"sm",children:"UPDATE NOW"}),f&&(0,d.jsx)("span",{className:"text-[10px]",style:{color:"#fff",opacity:.9},children:f})]}):null}var cv=c(68225);let cw=["strict","dev","admin"],cx=["auto","strict","off"],cy=[{value:"strict",label:"strict",description:"Minimal local token scope with explicit allowlists."},{value:"dev",label:"dev",description:"Balanced local automation with scoped defaults."},{value:"admin",label:"admin (dangerous)",description:"Broad token scope. Use only in tightly controlled local environments."}],cz=[{value:"auto",label:"auto (recommended)",description:"Uses `.aura` when present and safely falls back to token scope when missing."},{value:"strict",label:"strict (require .aura)",description:"Requires explicit `.aura` mappings for secret access."},{value:"off",label:"off (disable project allowlist)",description:"Disables project allowlist checks for local token access."}],cA=[{value:"dev",label:"mid (dev)",description:"Access to most things. Human approval for stuff like CVV."},{value:"strict",label:"sus (local)",description:"Most locked down. Every request needs manual approval."},{value:"admin",label:"maxx (admin)",description:"Full access. Use only when you fully trust the agent."}],cB=[{value:"light",label:"Light"},{value:"dark",label:"Dark"}],cC=[{value:"normal",label:"Normal"},{value:"big",label:"Big"}],cD="auramaxx_admin_token",cE=new Set(f.Yu.english.map(a=>a.toLowerCase())),cF=a=>a.trim().toLowerCase().split(/\s+/).filter(Boolean);function cG(){let{token:a,setToken:b,clearToken:c}=(0,r.A)(),{colorMode:g,uiScale:p,setColorMode:u,setUiScale:v}=(0,cv.D)(),[w,x]=(0,e.useState)("loading"),[y,A]=(0,e.useState)(""),[B,C]=(0,e.useState)(!0),[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(null),[H,I]=(0,e.useState)(null),[J,K]=(0,e.useState)(!1),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(null),[P,Q]=(0,e.useState)(!1),[R,S]=(0,e.useState)("dev"),[T,U]=(0,e.useState)("seed"),[V,W]=(0,e.useState)(null),[X,Y]=(0,e.useState)(!1),[Z,$]=(0,e.useState)(!1),{notifications:_,dismissNotification:aa}=(0,cb.S)({autoFetch:!!a}),[ab,ac]=(0,e.useState)(!1),[ad,ae]=(0,e.useState)(!1),[af,ag]=(0,e.useState)(null),[ah,ai]=(0,e.useState)(null),[aj,ak]=(0,e.useState)({profile:"dev",profileVersion:"v1",autoApprove:!0,projectScopeMode:"auto"}),[al,am]=(0,e.useState)(null),[an,ao]=(0,e.useState)(null),[ap,aq]=(0,e.useState)({}),[ar,as]=(0,e.useState)(null),[at,au]=(0,e.useState)(!1),[av,aw]=(0,e.useState)(!1),[ax,ay]=(0,e.useState)(!1),[az,aA]=(0,e.useState)(!1),[aB,aC]=(0,e.useState)(!0),[aD,aE]=(0,e.useState)(!1),[aF,aG]=(0,e.useState)(!1),[aH,aI]=(0,e.useState)(!1),[aJ,aK]=(0,e.useState)(!1),[aL,aM]=(0,e.useState)([]),[aN,aO]=(0,e.useState)(!1),[aP,aQ]=(0,e.useState)(!1),[aR,aS]=(0,e.useState)(null),[aT,aU]=(0,e.useState)(!1),[aV,aW]=(0,e.useState)(null),[aX,aY]=(0,e.useState)(null),[aZ,a$]=(0,e.useState)(!1),[a_,a0]=(0,e.useState)(""),[a1,a2]=(0,e.useState)(""),[a3,a4]=(0,e.useState)(""),[a5,a6]=(0,e.useState)(null),[a7,a8]=(0,e.useState)(null),[a9,ba]=(0,e.useState)(!1),[bb,bc]=(0,e.useState)(!1),[bd,be]=(0,e.useState)(12),[bf,bg]=(0,e.useState)(Array(12).fill("")),[bh,bi]=(0,e.useState)(!1),[bj,bk]=(0,e.useState)(!1),[bl]=(0,e.useState)(()=>"ready to auramaxx and mog prompt peasants?"),[bm,bn]=(0,e.useState)(""),[bo,bp]=(0,e.useState)(null),[bq,br]=(0,e.useState)(!1),bs=(0,e.useRef)("loading"),bt=(0,e.useRef)(null),bu=(0,e.useRef)(null),bv=(0,e.useRef)(!0),bw=(0,e.useRef)(0),bx=(0,e.useRef)(null),by=(0,e.useMemo)(()=>!!H,[H]),bz=(0,e.useMemo)(()=>bf.filter(a=>a.length>0).length,[bf]),bA=(0,e.useMemo)(()=>bf.map(a=>a.trim().toLowerCase()).join(" ").trim(),[bf]),bB=(0,e.useMemo)(()=>{let a=new Set;return bf.forEach((b,c)=>{b&&(cE.has(b.trim().toLowerCase())||a.add(c))}),a},[bf]),bC=(0,e.useMemo)(()=>bz===bd&&!(bB.size>0)&&f.JB(bA),[bB.size,bA,bd,bz]),bD=(0,e.useCallback)(a=>"admin"===a.profile,[]),bE=(0,e.useMemo)(()=>!!ah&&JSON.stringify(ah)!==JSON.stringify(aj),[aj,ah]),bF=(0,e.useCallback)(a=>{let b=bs.current;if("loading"===b||"transition"===b){if(bu.current===a)return;bu.current=a,Q(!0),bt.current&&clearTimeout(bt.current),bt.current=setTimeout(()=>{Q(!1),bu.current=null,x(a)},220);return}bt.current&&(clearTimeout(bt.current),bt.current=null),bu.current=null,Q(!1),x(a)},[]),bG=(0,e.useCallback)(()=>{bt.current&&(clearTimeout(bt.current),bt.current=null),bu.current=null,Q(!1),x("transition")},[]),bH=(0,e.useCallback)(async()=>{let d=++bw.current,e=()=>bv.current&&d===bw.current,f=a;if(f&&!(0,t.Xo)())try{bx.current||(bx.current=(async()=>{let{publicKeyBase64:a}=await (0,t.T5)();return(0,s.fP)(a)})().finally(()=>{bx.current=null}));let a=await bx.current;if(!e())return;a.token&&(b(a.token),f=a.token)}catch{if(!e())return;c(),f=null}try{let[a,c]=await Promise.all([s.FH.get(s.jI.Wallet,"/setup"),s.FH.get(s.jI.Wallet,"/setup/vaults")]);if(!e())return;if(!(a.hasWallet||c.vaults&&c.vaults.some(a=>a.isPrimary))||by)return void bF("setup");let d="loading"===bs.current||"transition"===bs.current;if(a.unlocked&&!f&&d)try{if(await new Promise(a=>setTimeout(a,120)),!e())return;let a=window.localStorage.getItem(cD),c=window.sessionStorage.getItem(cD),d=a||c;if(d)return void b(d,{persist:a?"local":"session"})}catch{if(!e())return}if(!a.unlocked&&f&&d)try{if(await new Promise(a=>setTimeout(a,450)),!e())return;let a=await s.FH.get(s.jI.Wallet,"/setup");if(!e())return;if(a.unlocked)return void bF("unlocked")}catch{if(!e())return}if(!a.unlocked||!f)return void bF("locked");bF("unlocked")}catch{if(!e())return;bF("setup")}},[a,c,by,bF,b]),bI=(0,e.useCallback)(async()=>{if(!a)return void am("Unlock vault first to manage local socket policy.");au(!0),am(null),ao(null),as(null);try{let b={Authorization:`Bearer ${a}`},c=s.FH.getBaseUrl(s.jI.Wallet),d=await fetch(`${c}/defaults`,{headers:b});if(!d.ok)throw Error("Failed to load canonical trust policy defaults.");let e=await d.json();if(!1===e.success)throw Error("Failed to load canonical trust policy defaults.");let f=Object.values(e.defaults||{}).flat(),g=a=>f.find(b=>b.key===a)?.value,h=String(g("trust.localProfile")??"").trim();if(!cw.includes(h))throw Error(`Unknown persisted local profile: ${h||"(empty)"}`);let i=String(g("trust.localProfileVersion")??"v1").trim();if("v1"!==i)throw Error("Unknown local profile version; refusing to edit settings.");let j=String(g("trust.projectScopeMode")??"auto").trim();if(!cx.includes(j))throw Error(`Unknown persisted project scope mode: ${j||"(empty)"}`);let k={profile:h,profileVersion:"v1",autoApprove:!!g("trust.localAutoApprove"),projectScopeMode:j};ai(k),ak(k)}catch(a){am(a.message||"Failed to load policy settings"),ai(null)}finally{au(!1)}},[a]),bJ=(0,e.useCallback)(async()=>{if(!a)throw Error("Missing auth token for save.");if(!cw.includes(aj.profile))throw Error("Unknown profile selected; refusing to persist.");if(!cx.includes(aj.projectScopeMode))throw Error("Unknown project scope mode selected; refusing to persist.");let b=s.FH.getBaseUrl(s.jI.Wallet),c={"Content-Type":"application/json",Authorization:`Bearer ${a}`},d=[["trust.localProfile",aj.profile],["trust.localProfileVersion","v1"],["trust.localAutoApprove",aj.autoApprove],["trust.projectScopeMode",aj.projectScopeMode]];if(!(await Promise.all(d.map(async([a,d])=>(await fetch(`${b}/defaults/${a}`,{method:"PATCH",headers:c,body:JSON.stringify({value:d})})).ok))).every(Boolean))throw Error("Failed to save canonical trust policy defaults.");return{...aj,profileVersion:"v1"}},[aj,a]),bK=(0,e.useCallback)(async()=>{if(ah&&!at&&!av){if(!bD(ah)&&bD(aj)&&!ax)return void ay(!0);aw(!0),ao(null),as(null);try{let a=await bJ();ai(a),ak(a),ay(!1),as("Local trust policy saved. Changes apply to newly issued local tokens only.")}catch(b){let a=b.message||"Failed to save policy settings";ay(!1),a.includes("Unknown profile selected")||a.includes("Unknown project scope mode selected")?ao(a):(await bI(),ao(`${a} Server values were reloaded.`))}finally{aw(!1)}}},[ax,bD,bI,bJ,aj,at,av,ah]),bL=(0,e.useCallback)(()=>{a$(!1),a0(""),a2(""),a4(""),a6(null),ba(!1)},[]),bM=(0,e.useCallback)(async a=>{if(a.preventDefault(),a6(null),a8(null),a1.length<8)return void a6("New password must be at least 8 characters.");if(a1!==a3)return void a6("New password and confirmation do not match.");ba(!0);try{await (0,s.g4)(a_,a1),a8("Primary vault password updated."),bL()}catch(a){a6(a.message||"Failed to change primary password.")}finally{ba(!1)}},[bL,a3,a_,a1]),bN=(0,e.useCallback)((a,b)=>{let c=b.trim().toLowerCase();if(c.includes(" ")){let b=cF(c);if(b.length>1){let c=[...bf];b.forEach((b,d)=>{let e=a+d;e<c.length&&(c[e]=b)}),bg(c),bp(null);return}}let d=[...bf];d[a]=c,bg(d),bp(null)},[bf]),bO=(0,e.useCallback)((a,b)=>{let c=cF(b);if(c.length<=1)return!1;let d=c.length>12?24:bd;if(d!==bd){be(d);let a=Array(d).fill("");return c.slice(0,d).forEach((b,c)=>{a[c]=b}),bg(a),bp(null),!0}let e=[...bf];return c.forEach((b,c)=>{let d=a+c;d<e.length&&(e[d]=b)}),bg(e),bp(null),!0},[bd,bf]),bP=(0,e.useCallback)(async a=>{if(a.preventDefault(),bp(null),bm.length<8)return void bp("New password must be at least 8 characters.");if(!bC)return void bp("Enter a valid 12 or 24-word BIP-39 seed phrase.");br(!0);try{let{publicKeyBase64:a}=await (0,t.T5)(),c=await (0,s.OW)(bA,bm,a);c.token&&b(c.token,{persist:B?"local":"session"}),A(""),bn(""),bg(Array(bd).fill("")),bG(),bV()}catch(a){bp(a.message||"Recovery failed.")}finally{br(!1)}},[bG,bC,bA,bm,bd,b,B]),bQ=async a=>{if(a.preventDefault(),y){E(!0),G(null);try{let{publicKeyBase64:a}=await (0,t.T5)(),c=await (0,s.WE)(y,void 0,a);c.token&&b(c.token,{persist:B?"local":"session"}),A(""),bG(),bV()}catch(a){G(a.message||"Unlock failed")}finally{E(!1)}}},bR=async a=>{if(a.preventDefault(),!(y.length<8)){E(!0),G(null);try{let{publicKeyBase64:a}=await (0,t.T5)(),c=await (0,s.ne)(y,a);c.token&&(b(c.token,{persist:B?"local":"session"}),W(c.token)),c.mnemonic&&(I(c.mnemonic),K(!1),U("seed"),M(null),O(null)),A(""),c.mnemonic||bH()}catch(a){G(a.message||"Setup failed")}finally{E(!1)}}},bS=(0,e.useCallback)(async()=>{if(!H)return;let a=!1;if("undefined"!=typeof navigator&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(H),a=!0}catch{a=!1}if(a)return void O("copied");let b=document.createElement("textarea");b.value=H,b.setAttribute("readonly","true"),b.style.position="fixed",b.style.left="-9999px",document.body.appendChild(b),b.focus(),b.select();let c=!1;try{c=document.execCommand("copy")}catch{c=!1}finally{b.remove()}O(c?"copied":"copy-failed")},[H]),bT=(0,e.useCallback)(()=>{if(!H)return;let a=new Date().toISOString().slice(0,10),b=H.split(" ").map((a,b)=>`${b+1}. ${a}`).join("\n"),c=`# Aura Vault Seed Phrase Backup
59
+ Please report this to https://github.com/markedjs/marked.`,a){let a="<p>An error occurred:</p><pre>"+bd(c.message+"",!0)+"</pre>";return b?Promise.resolve(a):a}if(b)return Promise.reject(c);throw c}}};function bp(a,b){return bo.parse(a,b)}bp.options=bp.setOptions=function(a){return bo.setOptions(a),bp.defaults=bo.defaults,ak=bp.defaults,bp},bp.getDefaults=aj,bp.defaults=ak,bp.use=function(...a){return bo.use(...a),bp.defaults=bo.defaults,ak=bp.defaults,bp},bp.walkTokens=function(a,b){return bo.walkTokens(a,b)},bp.parseInline=bo.parseInline,bp.Parser=bm,bp.parser=bm.parse,bp.Renderer=bk,bp.TextRenderer=bl,bp.Lexer=bj,bp.lexer=bj.lex,bp.Tokenizer=bi,bp.Hooks=bn,bp.parse=bp,bp.options,bp.setOptions,bp.use,bp.walkTokens,bp.parseInline,bm.parse,bj.lex;let bq=({label:a,value:b,copyValue:c,trailingValue:f,credentialId:g,fieldKey:h,isSensitive:i,onShowLargeType:j,sensitiveInteractionMode:k="default",actionsPosition:l="left",showActionsInHoverCopyMode:m=!1,sensitiveClickBehavior:o="reveal",disableLargeType:p=!1,renderMarkdown:q=!1})=>{let[r,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(!1),[x,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(!1),[D,E]=(0,e.useState)(null),[F,G]=(0,e.useState)(!1),H=(0,e.useRef)(null),I=(0,e.useRef)(null),J=(0,e.useRef)(null),K="hover-copy"===k||"markdown-hover-copy"===k,L="markdown-hover-copy"===k,M="hover-copy"===k,N=!K&&"copy"===o,O=!K||m,P=(0,e.useMemo)(()=>{if(!L||null==x)return"";let a=x.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return bp.parse(a,{async:!1,breaks:!0})},[L,x]),Q=(0,e.useMemo)(()=>{if(!q||!b)return"";let a=b.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return bp.parse(a,{async:!1,breaks:!0})},[q,b]);(0,e.useEffect)(()=>()=>{I.current&&clearTimeout(I.current),J.current&&clearTimeout(J.current)},[]),(0,e.useEffect)(()=>{u(!1),w(!1),A(null),E(null),G(!1),I.current&&clearTimeout(I.current)},[g,h]);let R=(0,e.useCallback)(()=>{u(!0),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>u(!1),2e3)},[]),S=(0,e.useCallback)(a=>{A(a),w(!0),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{w(!1),A(null)},3e4)},[]),T=(0,e.useCallback)(async()=>{if(null!=x)return x;try{let a=await s.FH.post(s.jI.Wallet,`/credentials/${g}/read`),b=await (0,t.DC)(a.encrypted),c=JSON.parse(b),d="string"==typeof c.type?c.type:"",e=(0,y.Dw)(d,h),f=c.fields?.find(a=>(0,y.Dw)(d,a.key)===e||h===y.l3&&"value"===a.key);if(!f)return null;return f.value}catch{return null}},[g,h,x]),U=(0,e.useCallback)(async()=>{if(null!=x)return x;C(!0),E(null);try{let a=await T();return null==a&&E("Field not found"),a}catch{return E("Decryption failed -- try re-unlocking"),null}finally{C(!1)}},[T,x]),V=(0,e.useCallback)(async()=>{if(B)return;G(!1);let a=await T();null!=a&&(navigator.clipboard.writeText(a),R())},[T,B,R]),W=(0,e.useCallback)(async()=>{if(B||v&&null!=x)return;G(!1);let a=await U();null!=a&&S(a)},[U,B,S,v,x]),X=(0,e.useCallback)(()=>{w(!1),A(null),I.current&&clearTimeout(I.current)},[]),Y=(0,e.useCallback)(async()=>{G(!1);let a=await T();null!=a&&j(a)},[T,j]),Z=(0,e.useCallback)(()=>{let a=c??b;a&&(navigator.clipboard.writeText(a),R())},[c,b,R]),$=(0,e.useCallback)(()=>{b&&(G(!1),j(b))},[j,b]),_=(0,e.useCallback)(async()=>{if(!K||B)return;let a=x;null==a&&null!=(a=await U())&&A(a),null!=a&&(M&&S(a),navigator.clipboard.writeText(a),R())},[U,B,K,M,R,S,x]),aa=(0,e.useCallback)(a=>{if(!M&&!N){if(a.stopPropagation(),K)return void _();W()}},[_,W,K,M,N]);if(!i){let c=(0,d.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,d.jsxs)("button",{type:"button",onClick:a=>{a.stopPropagation(),Z()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,d.jsx)(ae.A,{size:10}),r?"Copied":"Copy"]}),(0,d.jsx)("button",{ref:H,onClick:a=>{a.stopPropagation(),G(!F)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":`Field actions for ${a}`,children:(0,d.jsx)(af.A,{size:12})}),(0,d.jsx)(z.AM,{isOpen:F,onClose:()=>G(!1),anchorEl:H.current,anchor:"right",children:(0,d.jsxs)("div",{className:"flex flex-col gap-1 min-w-[160px]",children:[(0,d.jsxs)("button",{onClick:Z,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ae.A,{size:10}),"Copy"]}),(0,d.jsxs)("button",{onClick:$,disabled:!b||p,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors disabled:opacity-40",children:[(0,d.jsx)(ag,{size:10}),"Show in large type"]})]})})]});return q&&b?(0,d.jsxs)("div",{className:"flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors group items-start",onClick:Z,children:["left"===l&&c,(0,d.jsx)("div",{className:"w-24 shrink-0",children:(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:r?"Copied":a})}),(0,d.jsx)("div",{className:"basis-full lg:basis-auto lg:flex-1 min-w-0 prose-mono max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",dangerouslySetInnerHTML:{__html:Q}}),"right"===l&&c]}):(0,d.jsxs)("div",{className:"flex flex-wrap lg:flex-nowrap items-center gap-x-3 gap-y-1 py-2 px-2 cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors group",onClick:Z,children:["left"===l&&c,(0,d.jsx)("div",{className:"w-24 shrink-0",children:(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:a})}),(0,d.jsxs)("div",{className:"basis-full lg:basis-auto lg:flex-1 min-w-0 min-h-[24px] flex items-center",children:[(0,d.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:r?"Copied":b||"--"}),f]}),"right"===l&&c]})}let ab=O?(0,d.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,d.jsxs)("button",{type:"button",onClick:a=>{a.stopPropagation(),V()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,d.jsx)(ae.A,{size:10}),r?"Copied":"Copy"]}),(0,d.jsx)("button",{ref:H,onClick:a=>{a.stopPropagation(),G(!F)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":`Field actions for ${a}`,children:(0,d.jsx)(af.A,{size:12})}),(0,d.jsx)(z.AM,{isOpen:F,onClose:()=>G(!1),anchorEl:H.current,anchor:"right",children:(0,d.jsxs)("div",{className:"flex flex-col gap-1 min-w-[170px]",children:[(0,d.jsxs)("button",{onClick:V,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ae.A,{size:10}),"Copy"]}),!K&&!v&&(0,d.jsxs)("button",{onClick:W,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ah.A,{size:10}),"Reveal"]}),!K&&v&&(0,d.jsxs)("button",{onClick:X,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ai.A,{size:10}),"Hide"]}),!p&&(0,d.jsxs)("button",{onClick:Y,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ag,{size:10}),"Show in large type"]})]})})]}):null;if(L){let b=(0,d.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,d.jsxs)("button",{type:"button",onClick:a=>{a.stopPropagation(),V()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,d.jsx)(ae.A,{size:10}),r?"Copied":"Copy"]}),(0,d.jsx)("button",{ref:H,onClick:a=>{a.stopPropagation(),G(!F)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":`Field actions for ${a}`,children:(0,d.jsx)(af.A,{size:12})}),(0,d.jsx)(z.AM,{isOpen:F,onClose:()=>G(!1),anchorEl:H.current,anchor:"right",children:(0,d.jsxs)("div",{className:"flex flex-col gap-1 min-w-[170px]",children:[(0,d.jsxs)("button",{onClick:V,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ae.A,{size:10}),"Copy"]}),v?(0,d.jsxs)("button",{onClick:X,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ai.A,{size:10}),"Hide"]}):(0,d.jsxs)("button",{onClick:W,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,d.jsx)(ah.A,{size:10}),"Reveal"]})]})})]});return(0,d.jsxs)("div",{"data-testid":`credential-field-row-${h}`,className:"flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 group transition-colors cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] items-start",onClick:()=>{v&&null!=x?V():W()},children:["left"===l&&b,(0,d.jsx)("div",{className:"w-24 shrink-0",children:(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:r?"Copied":a})}),(0,d.jsx)("div",{"data-testid":`credential-field-value-${h}`,className:"basis-full lg:basis-auto lg:flex-1 min-w-0",children:D?(0,d.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-danger,#ef4444)]",children:D}):B?(0,d.jsx)(n.A,{size:12,className:"animate-spin text-[var(--color-text-muted,#6b7280)]"}):v&&null!=x?(0,d.jsx)("div",{className:"prose-mono max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",dangerouslySetInnerHTML:{__html:P}}):(0,d.jsx)("span",{className:"font-mono text-[11px] text-[var(--color-text-muted,#6b7280)] tracking-wider",children:"••••••••"})}),"right"===l&&b]})}return(0,d.jsxs)("div",{"data-testid":`credential-field-row-${h}`,className:`flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 group transition-colors rounded-sm items-center ${M||N?"cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)]":""}`,onClick:()=>{if(M)return void _();N&&V()},children:["left"===l&&ab,(0,d.jsx)("div",{className:"w-24 shrink-0",children:(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:a})}),(0,d.jsx)("div",{"data-testid":`credential-field-value-${h}`,className:`basis-full lg:basis-auto lg:flex-1 min-w-0 transition-colors rounded-sm ${K?"":"cursor-pointer"} ${M||N?"min-h-[24px] flex items-center":"hover:bg-[var(--color-background-alt,#f4f4f5)] min-h-[24px] flex items-center"} px-1 py-0.5`,onClick:aa,children:D?(0,d.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-danger,#ef4444)]",children:D}):B?(0,d.jsx)(n.A,{size:12,className:"animate-spin text-[var(--color-text-muted,#6b7280)]"}):M?v&&null!=x?(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:x}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),X()},className:"shrink-0 text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:(0,d.jsx)(ai.A,{size:12})})]}):(0,d.jsxs)("div",{className:"w-full",children:[(0,d.jsx)("div",{"data-testid":`credential-field-barcode-${h}`,className:"h-4 w-full bg-[repeating-linear-gradient(90deg,var(--color-text,#000),var(--color-text,#000)_1px,transparent_1px,transparent_3px)] opacity-30"}),(0,d.jsx)("div",{className:"mt-1 h-1.5 w-full",style:{backgroundImage:"repeating-linear-gradient(45deg, var(--color-text, #000), var(--color-text, #000) 5px, transparent 5px, transparent 10px)",opacity:.1}}),(0,d.jsx)("div",{className:"mt-1 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] tracking-wider uppercase",children:r?"Copied":"Click to reveal and copy"})]}):K?(0,d.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-wider uppercase",children:r?"Copied":null!=x?"Hover then click to copy":"Decrypting"}):v&&null!=x?(0,d.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,d.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:x}),(0,d.jsx)("button",{onClick:a=>{a.stopPropagation(),X()},className:"shrink-0 text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:(0,d.jsx)(ai.A,{size:12})})]}):(0,d.jsx)("span",{className:"font-mono text-[11px] text-[var(--color-text-muted,#6b7280)] tracking-wider",children:r?"Copied":"••••••••"})}),"right"===l&&ab]})},br=({credentialId:a})=>{let[b,c]=(0,e.useState)(null),[f,g]=(0,e.useState)(30),[h,i]=(0,e.useState)(null),j=(0,e.useCallback)(async()=>{try{let b=await s.FH.post(s.jI.Wallet,`/credentials/${a}/totp`);b.success&&b.code?(c(b.code),g(b.remaining),i(!0)):i(!1)}catch{i(!1)}},[a]);if((0,e.useEffect)(()=>{j()},[j]),(0,e.useEffect)(()=>{if(!0!==h)return;let a=setInterval(()=>{g(a=>a<=1?(j(),30):a-1)},1e3);return()=>clearInterval(a)},[h,j]),null===h||!1===h)return null;let k=f<=5,l=b?`${b.slice(0,3)} ${b.slice(3)}`:"--- ---",m=f/30;return(0,d.jsx)("div",{className:"space-y-0.5","data-testid":"totp-display",children:(0,d.jsx)(bq,{label:"2FA Code",value:l,copyValue:b??void 0,credentialId:a,fieldKey:"totp_code",isSensitive:!1,trailingValue:(0,d.jsxs)("div",{className:"ml-2 flex items-center gap-1.5",children:[(0,d.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 18 18",className:"shrink-0",style:{transform:"rotate(-90deg)"},children:[(0,d.jsx)("circle",{cx:"9",cy:"9",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-[var(--color-border,#d4d4d8)]",opacity:"0.3"}),(0,d.jsx)("circle",{cx:"9",cy:"9",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeDasharray:`${43.98*m} 43.98`,strokeLinecap:"round",className:k?"text-[var(--color-danger,#ef4444)]":"text-[var(--color-accent,#ccff00)]"})]}),(0,d.jsxs)("span",{className:`font-mono text-[9px] ${k?"text-[var(--color-danger,#ef4444)]":"text-[var(--color-text-faint,#9ca3af)]"}`,children:[f,"s"]})]}),disableLargeType:!0,onShowLargeType:()=>{}})})},bs=({isOpen:a,onClose:b,value:c})=>{let[f,g]=(0,e.useState)(!1),h=(0,e.useRef)(null),i=Array.from(c??""),j=(0,e.useCallback)(async()=>{try{await navigator.clipboard.writeText(c),g(!0),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>g(!1),2e3)}catch{}},[c]);return(0,e.useEffect)(()=>(a||g(!1),()=>{h.current&&clearTimeout(h.current)}),[a]),(0,d.jsx)(z.aF,{isOpen:a,onClose:b,title:"Expanded Value",size:"lg",contentClassName:"!p-0",footer:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:b,children:"Cancel"}),(0,d.jsx)(z.$n,{variant:"primary",size:"sm",onClick:()=>{j()},children:f?"COPIED":"COPY"})]}),children:(0,d.jsxs)("div",{className:"w-full min-h-[360px] px-6 py-8 flex flex-col items-center justify-center text-center",children:[(0,d.jsx)("div",{className:"w-full max-w-[900px] max-h-[70vh] overflow-auto px-1",children:(0,d.jsx)("div",{className:"grid gap-2 [grid-template-columns:repeat(auto-fit,minmax(56px,1fr))]",children:i.map((a,b)=>(0,d.jsxs)("div",{"data-testid":`large-type-char-${b+1}`,className:"rounded-sm border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#ffffff)] px-1 py-2",children:[(0,d.jsx)("div",{className:"font-mono text-3xl font-bold leading-none text-[var(--color-text,#0a0a0a)] select-all",children:(a=>" "===a?"␠":"\n"===a?"↵":" "===a?"⇥":a)(a)}),(0,d.jsx)("div",{"data-testid":`large-type-index-${b+1}`,className:"mt-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:b+1})]},`${b}-${a}`))})}),(0,d.jsx)("div",{className:"mt-8 font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-faint,#9ca3af)]",children:"Use copy to move this value to clipboard"})]})})};var bt=c(38442),bu=c(71613);let bv=[{value:"15m",label:"15 Minutes"},{value:"1h",label:"1 Hour"},{value:"24h",label:"24 Hours"},{value:"7d",label:"7 Days"},{value:"30d",label:"30 Days"}],bw=[{value:"anyone",label:"Anyone with link"},{value:"password",label:"Set password"}],bx=({isOpen:a,onClose:b,credentialId:c,credentialName:f})=>{let[g,h]=(0,e.useState)("24h"),[i,j]=(0,e.useState)("anyone"),[k,l]=(0,e.useState)(""),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1),[t,u]=(0,e.useState)(null),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)(!1),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(null);(0,e.useEffect)(()=>{a&&(u(null),p(!1),w(""),D(null),y(!1))},[a]);let E=()=>"password"!==i||k.trim()?null:"Password is required when access mode is Set password",F=async()=>{u(null);let a=E();if(a)return void u(a);try{r(!0),p(!1);let a=await s.FH.post(s.jI.Wallet,"/credential-shares/gist",{credentialId:c,expiresAfter:g,accessMode:i,oneTimeOnly:m,shareBaseUrl:window.location.origin,..."password"===i?{password:k}:{}});w(a.gist.url),await navigator.clipboard.writeText(a.gist.url),p(!0),setTimeout(()=>p(!1),2e3)}catch{u('Failed to create secret gist. Check "gh auth status" in terminal. If needed, run "gh auth login".')}finally{r(!1)}},G=async()=>{D(null);let a=E();if(a)return void D(a);try{let a;B(!0);let b=(a=(await s.FH.post(s.jI.Wallet,"/credential-shares",{credentialId:c,expiresAfter:g,accessMode:i,oneTimeOnly:m,..."password"===i?{password:k}:{}})).share.token,`${window.location.origin}/share/${a}`);await navigator.clipboard.writeText(b),y(!0),setTimeout(()=>y(!1),2e3)}catch(a){D(a instanceof Error?a.message:"Failed to generate share link")}finally{B(!1)}},H=()=>{u(null),p(!1),r(!1),w(""),D(null),y(!1),B(!1),b()};return(0,d.jsx)(z.aF,{isOpen:a,onClose:H,title:`Sharing ${f}`,icon:(0,d.jsx)(bt.A,{size:16,className:"text-[var(--color-text,#0a0a0a)]"}),size:"md",footer:(0,d.jsx)("div",{className:"flex items-center justify-end gap-2",children:(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:H,children:"CLOSE"})}),children:(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"GitHub Gist (Recommended)"}),(0,d.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:["Check ",(0,d.jsx)("span",{className:"text-[var(--color-text,#0a0a0a)]",children:"`gh auth status`"})," first; run ",(0,d.jsx)("span",{className:"text-[var(--color-text,#0a0a0a)]",children:"`gh auth login`"})," only if needed."]}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[v?(0,d.jsx)("a",{href:v,target:"_blank",rel:"noreferrer",className:"flex-1 min-w-0 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] truncate hover:underline",title:v,children:v}):(0,d.jsx)("div",{className:"flex-1 min-w-0 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] truncate",children:"Click SHARE GIST to generate a link."}),(0,d.jsxs)(z.$n,{variant:"primary",size:"sm",onClick:F,loading:q,className:"shrink-0 whitespace-nowrap",children:[o?(0,d.jsx)(bu.A,{size:10}):(0,d.jsx)(ae.A,{size:10}),o?"COPIED":"SHARE GIST"]})]}),t&&(0,d.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-danger,#ef4444)]",children:t})]}),(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"Share Link (Local)"}),(0,d.jsx)(z.UM,{label:"Link Expires After",options:bv,value:g,onChange:a=>h(a),compact:!0}),(0,d.jsx)(z.UM,{label:"Available To",options:bw,value:i,onChange:a=>j(a),compact:!0}),"password"===i&&(0,d.jsx)(z.ks,{label:"Share Password",type:"password",value:k,onChange:a=>l(a.target.value),placeholder:"Enter password",compact:!0}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsxs)("label",{className:"flex flex-1 min-w-0 items-center gap-2 cursor-pointer",children:[(0,d.jsx)("input",{type:"checkbox",checked:m,onChange:a=>n(a.target.checked),className:"accent-[var(--color-accent,#ccff00)]"}),(0,d.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text,#0a0a0a)] truncate",children:"Can only be viewed one time"})]}),(0,d.jsxs)(z.$n,{variant:"primary",size:"sm",onClick:G,loading:A,className:"shrink-0 whitespace-nowrap",children:[x?(0,d.jsx)(bu.A,{size:10}):(0,d.jsx)(ae.A,{size:10}),x?"COPIED":"COPY LINK"]})]}),C&&(0,d.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-danger,#ef4444)]",children:C})]})]})})};var by=c(78583);let bz=({walletLink:a})=>{let[b,c]=(0,e.useState)(null),[f,g]=(0,e.useState)(!0),[h,i]=(0,e.useState)(!1),j=a.chain.toLowerCase();(0,e.useEffect)(()=>{let b=!0;return(async()=>{try{let d=((await s.FH.get(s.jI.Wallet,"/wallets")).wallets||[]).find(b=>b.address.toLowerCase()===a.walletAddress.toLowerCase()&&b.chain.toLowerCase()===j)||null;b&&c(d)}catch{b&&c(null)}finally{b&&g(!1)}})(),()=>{b=!1}},[a.walletAddress,j,a.chain]);let k=(0,e.useMemo)(()=>b?.name||b?.label||a.label||"Linked Wallet",[b,a.label]);return(0,d.jsxs)("div",{className:"mt-2 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background-alt,#f4f4f5)] p-3",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,d.jsxs)("div",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] inline-flex items-center gap-1",children:[(0,d.jsx)(E.A,{size:11})," Linked Wallet"]}),(0,d.jsxs)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:[a.tier," \xb7 ",a.chain]})]}),(0,d.jsx)("div",{className:"font-mono text-[11px] text-[var(--color-text,#0a0a0a)] mb-1",children:k}),(0,d.jsx)("div",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] mb-2 break-all",children:a.walletAddress}),f?(0,d.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:"Loading wallet state…"}):b?(0,d.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-success,#22c55e)] mb-2",children:["Wallet resolved",b.balance?` \xb7 Balance: ${b.balance}`:""]}):(0,d.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-warning,#f59e0b)] mb-2",children:"Stale link: wallet not found in current wallet list"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("button",{type:"button",className:"px-2 py-1 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px]",onClick:async()=>{await navigator.clipboard.writeText(a.walletAddress),i(!0),setTimeout(()=>i(!1),1200)},children:(0,d.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,d.jsx)(ae.A,{size:10})," ",h?"COPIED":(a=>`${a.slice(0,6)}...${a.slice(-4)}`)(a.walletAddress)]})}),(0,d.jsxs)("a",{href:function(a,b){return"solana"===a||"solana-devnet"===a?`https://solscan.io/account/${b}`:"polygon"===a?`https://polygonscan.com/address/${b}`:"ethereum"===a?`https://etherscan.io/address/${b}`:`https://basescan.org/address/${b}`}(j,a.walletAddress),target:"_blank",rel:"noreferrer",className:"px-2 py-1 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px] inline-flex items-center gap-1",children:[(0,d.jsx)(by.A,{size:10})," Explorer"]})]})]})};function bA(a){return new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}let bB=({credential:a,vaultName:b,lifecycle:c,onEdit:f,onDelete:g,onRestore:h,onDuplicate:i})=>{let[j,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(null),[r,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(null),[A,B]=(0,e.useState)(""),C=a=>{k(a)};(0,e.useEffect)(()=>{q(null),t(!1),v(null),x(null),B("")},[a.id]);let D=(0,e.useCallback)(async()=>{t(!0),q(null);try{let b=await s.FH.post(s.jI.Wallet,`/credentials/${a.id}/reauth`);v(b.authorization_url||null),x(b.state||null),q(b.message||"Authorization URL generated. Complete provider consent, then paste code.")}catch(a){q(a instanceof Error?a.message:"Failed to start re-auth")}finally{t(!1)}},[a.id]),E=(0,e.useCallback)(async()=>{if(!A.trim()||!w)return void q("Enter authorization code after consent to complete re-auth.");t(!0);try{let b=await s.FH.post(s.jI.Wallet,`/credentials/${a.id}/reauth`,{code:A.trim(),state:w});q(b.message||"Re-auth complete. Refresh credential details."),B("")}catch(a){q(a instanceof Error?a.message:"Failed to complete re-auth")}finally{t(!1)}},[a.id,A,w]),F={login:"Login",card:"Card",note:"Note",plain_note:"Plain Note",hot_wallet:"Hot Wallet",apikey:"API Key",custom:"Key / Value",oauth2:"OAuth2",ssh:"SSH Key",gpg:"GPG Key"}[a.type]||a.type.charAt(0).toUpperCase()+a.type.slice(1),G=a.meta.sensitive_field_keys??[],H=a.meta.walletLink,I="active"===c,J=I?"ARCHIVE":"archive"===c?"DELETE":"PURGE",K=I?"Archive Credential":"archive"===c?"Delete Credential":"Purge Credential",L=I?"This credential will be moved to Archive.":"archive"===c?"This credential will be moved to Recently Deleted.":"This credential will be permanently deleted now.",M={sensitiveClickBehavior:"copy"};return(0,d.jsxs)("div",{className:"p-6 flex flex-col relative",children:[(0,d.jsx)("div",{className:"absolute top-6 -left-1 text-vertical label-specimen-sm text-[var(--color-text-faint,#9ca3af)] select-none opacity-40 hidden lg:block",children:"CLASSIFIED"}),(0,d.jsxs)("div",{className:"mb-6",children:[(0,d.jsx)("h2",{className:"font-mono font-bold text-lg text-[var(--color-text,#0a0a0a)]",children:a.name}),(0,d.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,d.jsx)("span",{className:"shard-start inline-block bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-[8px] font-bold uppercase tracking-widest px-2 py-0.5",children:F}),(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:b})]})]}),(0,d.jsxs)("div",{className:"flex-1 space-y-0.5",children:["login"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"URL",value:a.meta.url,credentialId:a.id,fieldKey:y.u.login.url,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Username",value:a.meta.username,credentialId:a.id,fieldKey:y.u.login.username,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Password",credentialId:a.id,fieldKey:y.u.login.password,isSensitive:!0,onShowLargeType:C,...M}),I&&(0,d.jsx)(br,{credentialId:a.id}),G.includes(y.u.login.notes)&&(0,d.jsx)(bq,{label:"Notes",credentialId:a.id,fieldKey:y.u.login.notes,isSensitive:!0,onShowLargeType:C,...M})]}),"card"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Cardholder",value:a.meta.cardholder,credentialId:a.id,fieldKey:y.u.card.cardholder,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Brand",value:a.meta.brand,credentialId:a.id,fieldKey:y.u.card.brand,isSensitive:!1,onShowLargeType:C}),a.meta.last4&&(0,d.jsx)(bq,{label:"Card",value:`•••• ${a.meta.last4}`,credentialId:a.id,fieldKey:y.u.card.last4,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Number",credentialId:a.id,fieldKey:y.u.card.number,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Expiry",credentialId:a.id,fieldKey:y.u.card.expiry,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"CVV",credentialId:a.id,fieldKey:y.u.card.cvv,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Billing ZIP",value:a.meta.billing_zip,credentialId:a.id,fieldKey:y.u.card.billingZip,isSensitive:!1,onShowLargeType:C}),G.includes(y.u.card.notes)&&(0,d.jsx)(bq,{label:"Notes",credentialId:a.id,fieldKey:y.u.card.notes,isSensitive:!0,onShowLargeType:C,...M})]}),"note"===a.type&&(0,d.jsx)(bq,{label:"Content",credentialId:a.id,fieldKey:y.l3,isSensitive:!0,onShowLargeType:C,sensitiveInteractionMode:"markdown-hover-copy",disableLargeType:!0}),"plain_note"===a.type&&(0,d.jsx)(bq,{label:"Content",value:a.meta[y.l3]||a.meta.value,credentialId:a.id,fieldKey:y.l3,isSensitive:!1,onShowLargeType:C,renderMarkdown:!0,disableLargeType:!0}),"apikey"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Key",value:a.meta.key,credentialId:a.id,fieldKey:y.u.apikey.key,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Value",credentialId:a.id,fieldKey:y.u.apikey.value,isSensitive:!0,onShowLargeType:C,sensitiveClickBehavior:"copy"})]}),"hot_wallet"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Address",value:a.meta.address||H?.walletAddress,credentialId:a.id,fieldKey:y.u.hot_wallet.address,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Chain",value:a.meta.chain||H?.chain,credentialId:a.id,fieldKey:y.u.hot_wallet.chain,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Private Key",credentialId:a.id,fieldKey:y.u.hot_wallet.privateKey,isSensitive:!0,onShowLargeType:C,...M})]}),"custom"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Key",value:a.meta.primaryKey||"value",credentialId:a.id,fieldKey:"primaryKey",isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Value",credentialId:a.id,fieldKey:a.meta.primaryKey||y.u.custom.value,isSensitive:!0,onShowLargeType:C,...M})]}),"ssh"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Fingerprint",value:a.meta.fingerprint,credentialId:a.id,fieldKey:y.u.ssh.fingerprint,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Key Type",value:a.meta.key_type,credentialId:a.id,fieldKey:y.u.ssh.keyType,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Hosts",value:Array.isArray(a.meta.hosts)?a.meta.hosts.join(", "):void 0,credentialId:a.id,fieldKey:y.u.ssh.hosts,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Public Key",value:a.meta.public_key,credentialId:a.id,fieldKey:y.u.ssh.publicKey,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Private Key",credentialId:a.id,fieldKey:y.u.ssh.privateKey,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Passphrase",credentialId:a.id,fieldKey:y.u.ssh.passphrase,isSensitive:!0,onShowLargeType:C,...M})]}),"gpg"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Fingerprint",value:a.meta.fingerprint,credentialId:a.id,fieldKey:y.u.gpg.fingerprint,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Key ID",value:a.meta.key_id,credentialId:a.id,fieldKey:y.u.gpg.keyId,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"UID Email",value:a.meta.uid_email,credentialId:a.id,fieldKey:y.u.gpg.uidEmail,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Expires At",value:a.meta.expires_at,credentialId:a.id,fieldKey:y.u.gpg.expiresAt,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Public Key",value:a.meta.public_key,credentialId:a.id,fieldKey:y.u.gpg.publicKey,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Private Key",credentialId:a.id,fieldKey:y.u.gpg.privateKey,isSensitive:!0,onShowLargeType:C,...M})]}),"oauth2"===a.type&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bq,{label:"Token Endpoint",value:a.meta.token_endpoint,credentialId:a.id,fieldKey:y.u.oauth2.tokenEndpoint,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Scopes",value:a.meta.scopes,credentialId:a.id,fieldKey:y.u.oauth2.scopes,isSensitive:!1,onShowLargeType:C}),(0,d.jsx)(bq,{label:"Auth Method",value:a.meta.auth_method,credentialId:a.id,fieldKey:y.u.oauth2.authMethod,isSensitive:!1,onShowLargeType:C}),(a.meta.needs_reauth||u)&&(0,d.jsxs)("div",{className:"px-2 py-2 my-1 border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 text-[var(--color-danger,#ef4444)] font-mono text-[10px]",children:["⚠️ Re-authentication required",!!a.meta.reauth_reason&&(0,d.jsx)("span",{className:"block text-[9px] text-[var(--color-danger,#ef4444)]/70 mt-0.5",children:String(a.meta.reauth_reason)}),(0,d.jsx)("button",{className:"mt-1 px-2 py-0.5 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider disabled:opacity-50",onClick:D,disabled:r,children:r?"Loading…":"Start Re-auth"}),u&&(0,d.jsx)("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"mt-1 ml-2 inline-block px-2 py-0.5 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider",children:"Open Consent"}),w&&(0,d.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,d.jsx)("input",{value:A,onChange:a=>B(a.target.value),placeholder:"Paste authorization code",className:"flex-1 px-2 py-1 border border-[var(--color-danger,#ef4444)]/30 bg-transparent text-[9px]"}),(0,d.jsx)("button",{className:"px-2 py-1 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider disabled:opacity-50",onClick:E,disabled:r||!A.trim(),children:"Complete Re-auth"})]}),p&&(0,d.jsx)("div",{className:"mt-1 text-[9px] text-[var(--color-danger,#ef4444)]/90 break-words",children:p})]}),a.meta.last_refreshed&&(0,d.jsxs)("div",{className:"px-1 py-1",children:[(0,d.jsxs)("span",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["Last Refreshed:"," "]}),(0,d.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:new Date(String(a.meta.last_refreshed)).toLocaleString()})]}),(()=>{let b=a.meta.expires_at,c=Math.floor(Date.now()/1e3),e=!b||c>=b,f=b?e?"Expired — will auto-refresh on next read":`Valid for ${Math.floor((b-c)/60)}m`:"No token yet";return(0,d.jsxs)("div",{className:"px-1 py-2",children:[(0,d.jsxs)("span",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["Token Status:"," "]}),(0,d.jsx)("span",{className:"font-mono text-[10px] font-bold",style:{color:e?"var(--color-danger,#ef4444)":"var(--color-success,#00c853)"},children:f})]})})(),(0,d.jsx)(bq,{label:"Access Token",credentialId:a.id,fieldKey:y.u.oauth2.accessToken,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Refresh Token",credentialId:a.id,fieldKey:y.u.oauth2.refreshToken,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Client ID",credentialId:a.id,fieldKey:y.u.oauth2.clientId,isSensitive:!0,onShowLargeType:C,...M}),(0,d.jsx)(bq,{label:"Client Secret",credentialId:a.id,fieldKey:y.u.oauth2.clientSecret,isSensitive:!0,onShowLargeType:C,...M})]})]}),H&&(0,d.jsx)(bz,{walletLink:H}),a.meta.tags&&a.meta.tags.length>0&&(0,d.jsx)("div",{className:"mt-4 flex flex-wrap gap-1.5",children:a.meta.tags.map(a=>(0,d.jsx)("span",{className:"inline-block font-mono text-[9px] px-2 py-0.5 bg-[var(--color-accent,#ccff00)]/10 text-[var(--color-text-muted,#6b7280)]",children:a},a))}),(0,d.jsx)("div",{className:"mt-4 pt-3 border-t border-[var(--color-border,#d4d4d8)]",children:(0,d.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-faint,#9ca3af)] space-y-0.5",children:[(0,d.jsxs)("div",{children:["Created ",bA(a.createdAt)]}),(0,d.jsxs)("div",{children:["Updated ",bA(a.updatedAt)]}),a.archivedAt&&(0,d.jsxs)("div",{children:["Archived ",bA(a.archivedAt)]}),a.deletedAt&&(0,d.jsxs)("div",{children:["Deleted ",bA(a.deletedAt)]}),(0,d.jsxs)("div",{children:["Vault: ",b]})]})}),(0,d.jsxs)("div",{className:"mt-4 flex gap-2",children:[I&&(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>o(!0),children:"SHARE"}),I&&(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:f,children:"EDIT"}),I&&i&&(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:i,children:"DUPLICATE"}),!I&&(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:h,children:"archive"===c?"RESTORE":"RESTORE TO ARCHIVE"}),(0,d.jsx)(z.$n,{variant:"danger",size:"sm",onClick:()=>m(!0),children:J})]}),(0,d.jsx)(z.Rw,{isOpen:l,onClose:()=>m(!1),onConfirm:()=>{m(!1),g()},title:K,message:L,confirmText:"recently_deleted"===c?"PURGE":"CONFIRM",variant:"recently_deleted"===c?"danger":"warning"}),(0,d.jsx)(bs,{isOpen:null!=j,onClose:()=>k(null),value:j??""}),(0,d.jsx)(bx,{isOpen:n,onClose:()=>o(!1),credentialId:a.id,credentialName:a.name})]})},bC=({variant:a,onAdd:b})=>"no-selection"===a?(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)(H.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,d.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Select a credential from the list"})]})}):"empty-lifecycle"===a?(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)(H.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,d.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1",children:"No credentials in this section"})]})}):(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)(H.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,d.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1",children:"Your vault is empty"}),(0,d.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-faint,#9ca3af)] mb-4",children:"Create your first credential"}),(0,d.jsx)(z.$n,{size:"sm",onClick:b,icon:(0,d.jsx)(m.A,{size:10}),children:"ADD"})]})});var bD=c(73778),bE=c(18310),bF=c(75219);let bG=[{label:"1Password",format:"1password-csv",supported:!0},{label:"Bitwarden",format:"bitwarden-csv",supported:!0},{label:"Chrome",format:"chrome-csv",supported:!0},{label:"Firefox",format:"firefox-csv",supported:!0},{label:"iCloud Keychain",format:"icloud-csv",supported:!0},{label:"LastPass",format:"lastpass-csv",supported:!0}],bH={skip:"Skip",rename:"Rename",overwrite:"Create Anyway"},bI=({isOpen:a,onClose:b,onComplete:c,vaults:f,selectedVaultId:g,onSelectedVaultIdChange:h,onAddVault:i,walletBaseUrl:j})=>{let[k,l]=(0,e.useState)("select"),[m,n]=(0,e.useState)("1password-csv"),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)("skip"),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(!1),[y,A]=(0,e.useState)(null),B=(0,e.useRef)(null),C=(0,e.useMemo)(()=>f.map(a=>({value:a.id,label:a.name||(a.isPrimary?"Primary":`Vault ${a.id.slice(0,6)}`)})),[f]),E=(0,e.useMemo)(()=>f.find(a=>a.id===g)||null,[f,g]),F=(0,e.useCallback)(()=>{l("select"),n("1password-csv"),p(null),r("skip"),t(null),v(null),x(!1),A(null),B.current&&(B.current.value="")},[]),G=(0,e.useCallback)(()=>{F(),b()},[F,b]),H=(0,e.useCallback)(a=>{let b=a.target.files?.[0]??null;if(b&&b.size>0xa00000){A(`File too large (${(b.size/1024/1024).toFixed(1)}MB). Maximum is 10MB.`),p(null),B.current&&(B.current.value="");return}p(b),A(null)},[]),I=(0,e.useCallback)(a=>{if(!o)return null;let b=new FormData;return b.append("file",o),b.append("format",m),b.append("vaultId",g||"primary"),a&&b.append("dryRun","true"),b.append("duplicateStrategy",q),b},[o,m,g,q]),J=(0,e.useCallback)(async()=>{if(o){x(!0),A(null);try{let a=I(!0);if(!a)return;let b=await fetch(`${j}/credentials/import`,{method:"POST",headers:{},body:a});if(!(b.headers.get("content-type")||"").includes("application/json"))return void A(`Server error: ${b.status} ${b.statusText}`);let c=await b.json();if(!b.ok||!c.success)return void A(c.error||`Request failed: ${b.status}`);t(c),l("preview")}catch(a){A(a instanceof Error?a.message:"Preview failed")}finally{x(!1)}}},[o,I,j]),K=(0,e.useCallback)(async()=>{x(!0),A(null);try{let a=I(!1);if(!a)return;let b=await fetch(`${j}/credentials/import`,{method:"POST",headers:{},body:a});if(!(b.headers.get("content-type")||"").includes("application/json"))return void A(`Server error: ${b.status} ${b.statusText}`);let c=await b.json();if(!b.ok)return void A(c.error||`Request failed: ${b.status}`);v(c),l("result")}catch(a){A(a instanceof Error?a.message:"Import failed")}finally{x(!1)}},[I,j]),L=(0,e.useCallback)(()=>{c(),G()},[c,G]),M=bG.find(a=>a.format===m);return(0,d.jsxs)(z.aF,{isOpen:a,onClose:G,title:"Import Credentials",size:"md",footer:(()=>{if("select"===k)return(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:G,children:"CANCEL"}),(0,d.jsx)(z.$n,{size:"sm",onClick:J,loading:w,disabled:!o||!M?.supported,children:"PREVIEW"})]});if("preview"===k&&s){let a="skip"===q?s.total-s.duplicates:s.total;return(0,d.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>{l("select"),A(null),B.current&&(B.current.value="")},children:"BACK"}),(0,d.jsxs)(z.$n,{size:"sm",onClick:K,loading:w,disabled:0===s.credentials.length,children:["IMPORT ",a," CREDENTIAL",1!==a?"S":""]})]})}return"result"===k?(0,d.jsx)("div",{className:"flex justify-end",children:(0,d.jsx)(z.$n,{size:"sm",onClick:L,children:"DONE"})}):null})(),children:["select"===k&&(0,d.jsxs)("div",{className:"space-y-5",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-2",children:"Source"}),(0,d.jsx)(z.O6,{ariaLabel:"Import source",value:m,onChange:a=>{let b=bG.find(b=>b.format===a);b?.supported&&n(b.format)},options:bG.map(a=>({value:a.format,label:a.label,description:a.supported?void 0:"Coming soon",icon:(0,d.jsx)(D.A,{size:12})}))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-2",children:"File"}),(0,d.jsx)("input",{ref:B,type:"file",accept:".csv",onChange:H,className:"hidden"}),(0,d.jsxs)("button",{onClick:()=>B.current?.click(),className:"w-full flex items-center justify-center gap-2 px-4 py-4 border-2 border-dashed border-[var(--color-border,#d4d4d8)] hover:border-[var(--color-text-muted,#6b7280)] transition-colors",children:[(0,d.jsx)(Y.A,{size:14,className:"text-[var(--color-text-muted,#6b7280)]"}),(0,d.jsx)("span",{className:"text-[10px] font-mono tracking-wider text-[var(--color-text-muted,#6b7280)]",children:o?o.name:"Choose CSV file"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-end gap-2",children:[(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)(z.UM,{label:"Target Vault",ariaLabel:"TARGET VAULT",options:C,value:g,onChange:h,compact:!0,searchable:!0,menuPosition:"top",searchPlaceholder:"Search vault...",emptyMessage:"No vault matches"})}),(0,d.jsx)(z.$n,{type:"button",variant:"secondary",size:"sm",onClick:i,className:"!h-[var(--control-height-sm)] !px-3",children:"ADD"})]}),E&&!E.isUnlocked&&(0,d.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-warning,#ff4d00)] border border-[var(--color-warning,#ff4d00)]/30 bg-[var(--color-warning,#ff4d00)]/10 px-3 py-2",children:"Selected vault is locked. Unlock it before preview/import."})]}),y&&(0,d.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 bg-red-50 border border-red-200",children:[(0,d.jsx)(bE.A,{size:12,className:"text-red-500 flex-shrink-0 mt-0.5"}),(0,d.jsx)("span",{className:"text-[10px] font-mono text-red-700",children:y})]})]}),"preview"===k&&(s?(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{className:"flex gap-4",children:[(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"text-[18px] font-bold font-mono text-[var(--color-text,#0a0a0a)]",children:s.total}),(0,d.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Total"})]}),s.duplicates>0&&(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"text-[18px] font-bold font-mono text-amber-600",children:s.duplicates}),(0,d.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Duplicates"})]})]}),(0,d.jsxs)("div",{className:"max-h-[240px] overflow-y-auto border border-[var(--color-border,#d4d4d8)]",children:[0===s.credentials.length?(0,d.jsx)("div",{className:"px-4 py-8 text-center text-[10px] font-mono text-[var(--color-text-muted,#6b7280)]",children:"No credentials found in file"}):s.credentials.map((a,b)=>(0,d.jsxs)("div",{className:`flex items-center gap-2 px-3 py-1.5 border-b border-[var(--color-border,#d4d4d8)] last:border-b-0 ${a.isDuplicate?"bg-amber-50/50":""}`,children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsx)("div",{className:"text-[10px] font-mono text-[var(--color-text,#0a0a0a)] truncate",children:a.name}),a.url&&(0,d.jsx)("div",{className:"text-[8px] font-mono text-[var(--color-text-faint,#9ca3af)] truncate",children:a.url})]}),(0,d.jsx)("span",{className:"text-[8px] font-mono tracking-wider uppercase text-[var(--color-text-faint,#9ca3af)] flex-shrink-0",children:a.type}),a.isDuplicate&&(0,d.jsx)("span",{className:"text-[8px] font-mono tracking-wider uppercase text-amber-600 flex-shrink-0",children:"DUP"})]},b)),s.total>s.credentials.length&&(0,d.jsxs)("div",{className:"px-3 py-1.5 text-[9px] font-mono text-[var(--color-text-faint,#9ca3af)] text-center",children:["+ ",s.total-s.credentials.length," more"]})]}),s.duplicates>0&&(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1.5",children:"Duplicate handling"}),(0,d.jsx)("div",{className:"flex gap-1.5",children:["skip","rename","overwrite"].map(a=>(0,d.jsx)("button",{onClick:()=>r(a),className:`px-3 py-1.5 text-[9px] font-mono tracking-wider uppercase border transition-colors ${q===a?"border-[var(--color-accent,#ccff00)] bg-[var(--color-accent,#ccff00)]/10 text-[var(--color-text,#0a0a0a)]":"border-[var(--color-border,#d4d4d8)] text-[var(--color-text-muted,#6b7280)] hover:bg-[var(--color-background-alt,#f4f4f5)]"}`,children:bH[a]},a))})]}),y&&(0,d.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 bg-red-50 border border-red-200",children:[(0,d.jsx)(bE.A,{size:12,className:"text-red-500 flex-shrink-0 mt-0.5"}),(0,d.jsx)("span",{className:"text-[10px] font-mono text-red-700",children:y})]})]}):null),"result"===k&&(()=>{if(!u)return null;let a=u.errors.length>0;return(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[u.success?(0,d.jsx)(bF.A,{size:20,className:"text-green-600"}):(0,d.jsx)(bE.A,{size:20,className:"text-red-500"}),(0,d.jsx)("div",{children:(0,d.jsx)("div",{className:"text-[11px] font-mono font-bold text-[var(--color-text,#0a0a0a)]",children:u.success?"Import Complete":"Import Failed"})})]}),(0,d.jsxs)("div",{className:"flex gap-6",children:[(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"text-[18px] font-bold font-mono text-green-600",children:u.imported}),(0,d.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Imported"})]}),u.skipped>0&&(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"text-[18px] font-bold font-mono text-[var(--color-text-muted,#6b7280)]",children:u.skipped}),(0,d.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Skipped"})]}),a&&(0,d.jsxs)("div",{className:"text-center",children:[(0,d.jsx)("div",{className:"text-[18px] font-bold font-mono text-red-500",children:u.errors.length}),(0,d.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Errors"})]})]}),a&&(0,d.jsx)("div",{className:"max-h-[120px] overflow-y-auto border border-red-200 bg-red-50",children:u.errors.map((a,b)=>(0,d.jsxs)("div",{className:"px-3 py-1 text-[9px] font-mono text-red-700 border-b border-red-100 last:border-b-0",children:["Row ",a.row,": ",a.reason]},b))})]})})()]})};var bJ=c(75046),bK=c(16945),bL=c(77886),bM=c(2761);let bN={CREDENTIAL_SCOPE_DENIED:"SCOPE_DENY",TOKEN_PERMISSION_DENIED:"SCOPE_DENY",TOKEN_REVOKED:"TOKEN_REVOKED",TOKEN_EXPIRED:"TOKEN_EXPIRED",RATE_LIMIT:"RATE_LIMITED",RATE_LIMITED:"RATE_LIMITED",CREDENTIAL_NOT_FOUND:"NOT_FOUND",CREDENTIAL_TOTP_NOT_CONFIGURED:"NOT_FOUND",TOKEN_AGENT_PUBKEY_MISSING:"MISSING_KEY",INTERNAL_ERROR:"INTERNAL_ERROR",ALLOW:"UNKNOWN"};function bO(a,b,c){let d="string"==typeof a?a.trim().toUpperCase():"";return"ALLOW"===d?"ALLOW":"DENY"===d?"DENY":"RATE_LIMIT"===d?"RATE_LIMIT":"ERROR"===d?"ERROR":!0===b?"ALLOW":!1===b&&(c??0)===429?"RATE_LIMIT":!1===b?"DENY":(c??0)>=500?"ERROR":"UNKNOWN"}function bP(a){return bN["string"==typeof a?a.trim().toUpperCase():""]??"UNKNOWN"}function bQ(a){return a.tokenHash?"HIGH":a.agentId?"MEDIUM":"LOW"}function bR(a){let b="string"==typeof a.decision?a.decision:void 0,c="string"==typeof a.reasonCode?a.reasonCode:void 0,d="string"==typeof a.tokenHash?a.tokenHash:void 0,e="string"==typeof a.agentId?a.agentId:void 0,f=a.timestamp,g=new Date("string"==typeof f||"number"==typeof f?f:Date.now()).getTime();return{id:String(a.id??`${g}-${d??e??"unknown"}`),timestamp:g,tokenKey:d??e??"unknown",tokenHash:d,agentId:e,endpoint:"string"==typeof a.action?a.action:void 0,credentialKey:"string"==typeof a.credentialId?a.credentialId:void 0,sourceVersion:"task40-audit-v1",decision:bO(b,a.allowed,a.httpStatus),reasonCode:bP(c),rawDecision:b,rawReasonCode:c,confidence:bQ({tokenHash:d,agentId:e})}}function bS(a){let b="object"==typeof a.data&&null!==a.data?a.data:{},c="object"==typeof b.metadata&&null!==b.metadata?b.metadata:{},d="string"==typeof b.result?b.result:"string"==typeof b.decision?b.decision:void 0,e="string"==typeof b.reasonCode?b.reasonCode:"string"==typeof b.reason?b.reason:void 0,f="string"==typeof b.tokenHash?b.tokenHash:void 0,g="string"==typeof b.agentId?b.agentId:void 0,h=a.timestamp,i=new Date("string"==typeof h||"number"==typeof h?h:Date.now()).getTime();return{id:String(a.id??`${i}-${f??g??"unknown"}`),timestamp:i,tokenKey:f??g??"unknown",tokenHash:f,agentId:g,endpoint:"string"==typeof c.route?c.route:"string"==typeof b.action?b.action:void 0,credentialKey:"string"==typeof b.credentialId?b.credentialId:void 0,sourceVersion:"legacy-logs-v1",decision:bO(d,b.allowed,b.httpStatus),reasonCode:bP(e),rawDecision:d,rawReasonCode:e,confidence:bQ({tokenHash:f,agentId:g})}}function bT(a){return"HIGH"===a?3:"MEDIUM"===a?2:1}let bU=[{value:"active",label:"ACTIVE"},{value:"revoked",label:"REVOKED"},{value:"expired",label:"EXPIRED"},{value:"all",label:"ALL"}],bV=[{value:"1h",label:"1 HOUR"},{value:"24h",label:"24 HOURS"},{value:"7d",label:"7 DAYS"}],bW=[{value:"all",label:"ALL"},{value:"ALLOW",label:"ALLOW"},{value:"DENY",label:"DENY"},{value:"RATE_LIMIT",label:"RATE_LIMIT"},{value:"ERROR",label:"ERROR"},{value:"UNKNOWN",label:"UNKNOWN"}];function bX(a){if(null==a)return null;if("number"==typeof a)return a<1e12?1e3*a:a;let b=Date.parse(a);return Number.isFinite(b)?b:null}function bY(a){return a?a.length<=14?a:`${a.slice(0,8)}...${a.slice(-6)}`:"—"}function bZ(a){let b=bX(a);return null===b?"—":new Date(b).toLocaleString()}function b$(){let{subscribe:a}=(0,bL.h)(),[b,c]=(0,e.useState)([]),[f,g]=(0,e.useState)([]),[h,i]=(0,e.useState)("active"),[j,k]=(0,e.useState)("24h"),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)("all"),[p,q]=(0,e.useState)("all"),[r,t]=(0,e.useState)(0),[u,v]=(0,e.useState)(!0),[w,x]=(0,e.useState)(null),[y,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),[G,H]=(0,e.useState)(null),I=(0,e.useRef)(null),J=(0,e.useRef)(null),K=(0,e.useCallback)(async()=>{v(!0),x(null);try{let[a,b,d]=await Promise.all([s.FH.get(s.jI.Wallet,"/dashboard"),s.FH.get(s.jI.Wallet,"/security/credential-access/recent",{limit:500}),s.FH.get(s.jI.Wallet,"/logs",{category:"agent",limit:200})]),e=a.success?[...a.tokens.active??[],...a.tokens.inactive??[]]:[],f=b.success?b.rows.map(bR):[],h=d.success?d.logs.filter(a=>{let b=a.data??{};return"credential_access_decision"===b.action}).map(bS):[],i=Date.now(),j=(function(a){let b=new Map;for(let c of a){let a=c.id||`${c.timestamp}|${c.endpoint??""}|${c.tokenKey}|${c.credentialKey??""}|${c.decision}|${c.reasonCode}`,d=b.get(a);if(!d||bT(c.confidence)>bT(d.confidence)){b.set(a,c);continue}"task40-audit-v1"===c.sourceVersion&&"legacy-logs-v1"===d.sourceVersion&&b.set(a,c)}return Array.from(b.values()).sort((a,b)=>b.timestamp-a.timestamp)})([...f,...h]).filter(a=>a.timestamp<=i);c(e),g(j.slice(0,500)),t(0)}catch(a){x(a instanceof Error?a.message:"Failed to load audit console")}finally{v(!1)}},[]);(0,e.useCallback)(()=>{J.current||(J.current=setTimeout(()=>{J.current=null,K()},120))},[K]);let L=(0,e.useMemo)(()=>Date.now()-("1h"===j?36e5:"7d"===j?6048e5:864e5),[j]),M=l.trim().toLowerCase(),N=(0,e.useMemo)(()=>b.map((a,b)=>({key:a.tokenHash||a.agentId||`unknown-${b}`,token:a,status:function(a){if(a.isRevoked)return"revoked";let b=bX(a.expiresAt);return a.isExpired||null!==b&&b<=Date.now()?"expired":a.isActive?"active":"inactive"}(a)})),[b]),O=(0,e.useMemo)(()=>new Map(N.map(a=>[a.key,a])),[N]),P="all"===n?null:O.get(n)??null,Q=(0,e.useMemo)(()=>f.filter(a=>a.timestamp>=L),[f,L]),R=(0,e.useMemo)(()=>{let a=N.filter(a=>"active"===a.status).length,b=Q.filter(a=>"DENY"===a.decision).length;return{activeCount:a,denied:b,rateLimited:Q.filter(a=>"RATE_LIMIT"===a.decision).length,unknown:Q.filter(a=>"UNKNOWN"===a.decision||"UNKNOWN"===a.reasonCode).length}},[N,Q]),S=(0,e.useMemo)(()=>N.filter(a=>("all"===h||a.status===h)&&(!M||`${a.key} ${a.token.tokenHash} ${a.token.agentId}`.toLowerCase().includes(M))),[N,h,M]),T=(0,e.useMemo)(()=>{let a=[{value:"all",label:"ALL TOKENS"}],b=new Set(["all"]);if(S.forEach(c=>{b.has(c.key)||(b.add(c.key),a.push({value:c.key,label:`${c.token.agentId??"unknown"} \xb7 ${bY(c.token.tokenHash??c.key)}`}))}),"all"!==n&&!b.has(n)){let b=O.get(n);b&&a.push({value:b.key,label:`${b.token.agentId??"unknown"} \xb7 ${bY(b.token.tokenHash??b.key)}`})}return a},[S,n,O]),U=(0,e.useMemo)(()=>{let a=new Map;return Q.forEach(b=>{[b.tokenHash,b.tokenKey,b.agentId?`agent:${b.agentId}`:void 0,b.agentId].filter(a=>!!a).forEach(c=>{a.set(c,Math.max(a.get(c)??0,b.timestamp))})}),a},[Q]),V=(0,e.useCallback)(a=>{let b=a.token.tokenHash;return b&&U.has(b)?U.get(b)??null:U.has(a.key)?U.get(a.key)??null:a.token.agentId&&U.has(`agent:${a.token.agentId}`)?U.get(`agent:${a.token.agentId}`)??null:a.token.agentId&&U.has(a.token.agentId)?U.get(a.token.agentId)??null:null},[U]),W=(0,e.useMemo)(()=>Q.filter(a=>{if("all"!==n){let b=P?.token.agentId,c=a.tokenKey===n||a.tokenHash===n,d=!!b&&a.agentId===b;if(!c&&!d)return!1}return("all"===p||a.decision===p)&&(!M||!!`${a.tokenHash??""} ${a.tokenKey} ${a.agentId??""}`.toLowerCase().includes(M))&&!0}),[p,Q,n,P,M]),X=(0,e.useMemo)(()=>{let a=50*r;return W.slice(a,a+50)},[W,r]),Y=(0,e.useCallback)(a=>{o(a),t(0),I.current&&"function"==typeof I.current.scrollIntoView&&I.current.scrollIntoView({behavior:"smooth",block:"start"})},[]),Z=(0,e.useCallback)(async(a,b)=>{if(!b||!navigator.clipboard)return void A("Clipboard unavailable for this key.");try{let c=bY(b);await navigator.clipboard.writeText(c),E(a),A(`Copied ${c}`),setTimeout(()=>E(b=>b===a?null:b),1500)}catch{A("Clipboard write failed.")}},[]),$=(0,e.useCallback)((a,b)=>{if(!b)return void A("Token hash unavailable; cannot revoke.");H({tokenKey:a,tokenHash:b})},[]),_=(0,e.useCallback)(async()=>{if(!G)return;let{tokenKey:a,tokenHash:b}=G;H(null),C(a),A(null);try{let a=await s.FH.post(s.jI.Wallet,"/actions/tokens/revoke",{tokenHash:b});if(!a.success)return void A(a.error||"Failed to revoke token.");A(`Revoked ${bY(b)}`),await K()}catch(a){A(a instanceof Error?a.message:"Failed to revoke token.")}finally{C(null)}},[G,K]);return u?(0,d.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"LOADING_AUDIT_CONSOLE…"}):w?(0,d.jsx)("div",{className:"p-4 border border-[var(--color-warning,#ff4d00)] bg-[color-mix(in_srgb,var(--color-warning,#ff4d00)_10%,transparent)]",children:(0,d.jsxs)("div",{className:"flex items-center gap-2 font-mono text-[10px] text-[var(--color-warning,#ff4d00)]",children:[(0,d.jsx)(bK.A,{size:12})," ",w]})}):(0,d.jsxs)("div",{className:"h-full flex flex-col p-3 gap-3 overflow-hidden",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between border border-[var(--color-border,#d4d4d8)] p-2 bg-[var(--color-surface,#fff)]",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"font-mono text-[11px] font-bold",children:"AUDIT"}),(0,d.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:[bV.find(a=>a.value===j)?.label.toLowerCase()," \xb7 ",Math.min(f.length,500)," rows",f.length>=500?" (capped)":""]})]}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>void K(),icon:(0,d.jsx)(F.A,{size:10}),children:"REFRESH"})]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 xl:grid-cols-4 gap-2",children:[(0,d.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,d.jsx)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:"ACTIVE KEYS"}),(0,d.jsx)("div",{className:"font-mono text-[12px] font-bold",children:R.activeCount})]}),(0,d.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,d.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["DENIES (",j,")"]}),(0,d.jsx)("div",{className:"font-mono text-[12px] font-bold",children:R.denied})]}),(0,d.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,d.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["RATE LIMITED (",j,")"]}),(0,d.jsx)("div",{className:"font-mono text-[12px] font-bold",children:R.rateLimited})]}),(0,d.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,d.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["UNKNOWN MAPS (",j,")"]}),(0,d.jsx)("div",{className:"font-mono text-[12px] font-bold",children:R.unknown})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-5 gap-2",children:[(0,d.jsx)(z.UM,{label:"Status",options:bU,value:h,onChange:a=>i(a),compact:!0}),(0,d.jsx)(z.UM,{label:"Window",options:bV,value:j,onChange:a=>k(a),compact:!0}),(0,d.jsx)(z.UM,{label:"Token",options:T,value:n,onChange:o,compact:!0}),(0,d.jsx)(z.UM,{label:"Decision",options:bW,value:p,onChange:a=>q(a),compact:!0}),(0,d.jsxs)("label",{className:"font-mono text-[9px] flex flex-col gap-1",children:["SEARCH KEY / AGENT",(0,d.jsx)("input",{value:l,onChange:a=>m(a.target.value),placeholder:"hash or agent id",className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] px-2 py-1.5 text-[10px]"})]})]}),y&&(0,d.jsx)("div",{className:"font-mono text-[9px] border border-[var(--color-info,#0047ff)] p-2 text-[var(--color-info,#0047ff)] bg-[color-mix(in_srgb,var(--color-info,#0047ff)_8%,transparent)]",children:y}),(0,d.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] overflow-hidden",children:[(0,d.jsxs)("div",{className:"px-2 py-1.5 border-b border-[var(--color-border,#d4d4d8)] font-mono text-[9px]",children:["KEY INVENTORY \xb7 ",S.length," ROWS"]}),(0,d.jsx)("div",{className:"max-h-[220px] overflow-auto",children:0===S.length?(0,d.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"NO TOKENS MATCH FILTERS"}):(0,d.jsxs)("table",{className:"w-full text-left",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-[var(--color-surface-alt,#fafafa)] border-b",children:(0,d.jsxs)("tr",{className:"font-mono text-[9px]",children:[(0,d.jsx)("th",{className:"p-2",children:"KEY"}),(0,d.jsx)("th",{className:"p-2",children:"AGENT"}),(0,d.jsx)("th",{className:"p-2",children:"PERMISSIONS"}),(0,d.jsx)("th",{className:"p-2",children:"ISSUED"}),(0,d.jsx)("th",{className:"p-2",children:"EXPIRES"}),(0,d.jsx)("th",{className:"p-2",children:"LAST USED"}),(0,d.jsx)("th",{className:"p-2",children:"ACTIONS"})]})}),(0,d.jsx)("tbody",{children:S.map(a=>{var b,c;let e=V(a),f=B===a.key,g="active"===a.status&&!!a.token.tokenHash;return(0,d.jsxs)("tr",{className:"border-b font-mono text-[9px]",children:[(0,d.jsxs)("td",{className:"p-2",children:[(0,d.jsx)("div",{children:bY(a.token.tokenHash??a.key)}),(0,d.jsx)("div",{className:`text-[8px] uppercase ${"active"===(b=a.status)?"text-[var(--color-success,#16a34a)]":"revoked"===b?"text-[var(--color-warning,#ff4d00)]":"expired"===b?"text-[var(--color-text-faint,#9ca3af)]":"text-[var(--color-text-muted,#6b7280)]"}`,children:a.status})]}),(0,d.jsx)("td",{className:"p-2",children:a.token.agentId??"unknown"}),(0,d.jsx)("td",{className:"p-2",children:(c=a.token.permissions??[])&&0!==c.length?c.length<=2?c.join(", "):`${c.slice(0,2).join(", ")} +${c.length-2}`:"—"}),(0,d.jsx)("td",{className:"p-2",children:bZ(a.token.createdAt)}),(0,d.jsxs)("td",{className:"p-2",children:[bZ(a.token.expiresAt),(0,d.jsx)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:function(a){let b=bX(a);if(null===b)return"—";let c=b-Date.now();if(c<=0)return"expired";let d=Math.floor(c/6e4);if(d<60)return`${d}m`;let e=Math.floor(d/60);return e<24?`${e}h`:`${Math.floor(e/24)}d`}(a.token.expiresAt)})]}),(0,d.jsx)("td",{className:"p-2",children:e?new Date(e).toLocaleString():"—"}),(0,d.jsx)("td",{className:"p-2",children:(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("button",{onClick:()=>void Z(a.key,a.token.tokenHash),className:"border px-1.5 py-0.5 text-[8px] disabled:opacity-40",title:"Copy short hash",disabled:!a.token.tokenHash,children:(0,d.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,d.jsx)(ae.A,{size:8}),D===a.key?"COPIED":"COPY"]})}),(0,d.jsx)("button",{onClick:()=>Y(a.key),className:"border px-1.5 py-0.5 text-[8px]",title:"Open activity",children:"VIEW"}),(0,d.jsx)("button",{onClick:()=>$(a.key,a.token.tokenHash),disabled:!g||f,className:"border px-1.5 py-0.5 text-[8px] disabled:opacity-40 text-[var(--color-warning,#ff4d00)]",title:g?"Revoke token":"Token cannot be revoked",children:f?"REVOKING":"REVOKE"})]})})]},a.key)})})]})})]}),(0,d.jsxs)("div",{ref:I,className:"flex-1 overflow-auto border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)]",children:[(0,d.jsxs)("div",{className:"sticky top-0 z-10 px-2 py-1.5 border-b bg-[var(--color-surface-alt,#fafafa)] font-mono text-[9px] flex items-center justify-between",children:[(0,d.jsxs)("span",{children:["TOKEN ACTIVITY \xb7 ",W.length," ROWS"]}),(0,d.jsxs)("span",{className:"text-[var(--color-text-muted,#6b7280)]",children:["PAGE ",r+1," / ",Math.max(1,Math.ceil(W.length/50))]})]}),f.length>=500&&(0,d.jsx)("div",{className:"font-mono text-[9px] border-b border-[var(--color-warning,#ff4d00)] p-2 text-[var(--color-warning,#ff4d00)]",children:"RESULTS TRUNCATED AT 500 ROWS — NARROW FILTERS TO REDUCE VOLUME."}),0===X.length?(0,d.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"NO AUDIT EVENTS IN WINDOW"}):(0,d.jsxs)("table",{className:"w-full text-left",children:[(0,d.jsx)("thead",{className:"sticky top-[31px] bg-[var(--color-surface-alt,#fafafa)] border-b",children:(0,d.jsxs)("tr",{className:"font-mono text-[9px]",children:[(0,d.jsx)("th",{className:"p-2",children:"TIME"}),(0,d.jsx)("th",{className:"p-2",children:"TOKEN / AGENT"}),(0,d.jsx)("th",{className:"p-2",children:"DECISION"}),(0,d.jsx)("th",{className:"p-2",children:"REASON"}),(0,d.jsx)("th",{className:"p-2",children:"CONFIDENCE"}),(0,d.jsx)("th",{className:"p-2",children:"ENDPOINT"})]})}),(0,d.jsx)("tbody",{children:X.map(a=>(0,d.jsxs)("tr",{className:"border-b font-mono text-[9px]",children:[(0,d.jsx)("td",{className:"p-2",children:new Date(a.timestamp).toLocaleString()}),(0,d.jsxs)("td",{className:"p-2",children:[a.agentId??"unknown"," \xb7 ",a.tokenKey.slice(0,10)]}),(0,d.jsx)("td",{className:"p-2",children:a.decision}),(0,d.jsxs)("td",{className:"p-2",children:[a.reasonCode,a.rawReasonCode&&"UNKNOWN"===a.reasonCode?` (${a.rawReasonCode})`:""]}),(0,d.jsx)("td",{className:"p-2",title:"HIGH"===a.confidence?"Direct token hash match":"MEDIUM"===a.confidence?"Agent correlation":"Partial/ambiguous join",children:a.confidence}),(0,d.jsx)("td",{className:"p-2",children:a.endpoint??"—"})]},a.id))})]})]}),(0,d.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,d.jsx)("button",{onClick:()=>t(a=>Math.max(0,a-1)),disabled:0===r,className:"font-mono text-[9px] border px-2 py-1 disabled:opacity-40",children:"PREV"}),(0,d.jsx)("button",{onClick:()=>t(a=>(a+1)*50<W.length?a+1:a),disabled:(r+1)*50>=W.length,className:"font-mono text-[9px] border px-2 py-1 disabled:opacity-40",children:"NEXT"})]}),(0,d.jsx)(z.Rw,{isOpen:null!==G,onClose:()=>H(null),onConfirm:()=>void _(),title:"Revoke Token",message:G?`Revoke token ${bY(G.tokenHash)}? The agent will lose access immediately.`:"",confirmText:"REVOKE",variant:"danger"})]})}let b_=(0,p.A)("ShieldAlert",[["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",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),b0=[{id:"strict",label:"Strict",description:"Agent vault only, read-only, strong field redaction. 15 min TTL."},{id:"dev",label:"Dev (recommended)",description:"All vaults, read/write, moderate redaction. 1 hour TTL."},{id:"admin",label:"Admin (dangerous)",description:"Full access, no redaction. Use with caution."}],b1=[{value:"wallet:list",label:"wallet:list"},{value:"wallet:create:hot",label:"wallet:create:hot"},{value:"wallet:create:temp",label:"wallet:create:temp"},{value:"wallet:rename",label:"wallet:rename"},{value:"wallet:export",label:"wallet:export"},{value:"wallet:tx:add",label:"wallet:tx:add"},{value:"wallet:asset:add",label:"wallet:asset:add"},{value:"wallet:asset:remove",label:"wallet:asset:remove"},{value:"send:hot",label:"send:hot"},{value:"send:temp",label:"send:temp"},{value:"swap",label:"swap"},{value:"fund",label:"fund"},{value:"launch",label:"launch"},{value:"apikey:get",label:"apikey:get"},{value:"apikey:set",label:"apikey:set"},{value:"workspace:modify",label:"workspace:modify"},{value:"strategy:read",label:"strategy:read"},{value:"strategy:manage",label:"strategy:manage"},{value:"app:storage",label:"app:storage"},{value:"app:storage:all",label:"app:storage:all"},{value:"app:accesskey",label:"app:accesskey"},{value:"action:create",label:"action:create"},{value:"action:read",label:"action:read"},{value:"action:resolve",label:"action:resolve"},{value:"adapter:manage",label:"adapter:manage"},{value:"addressbook:write",label:"addressbook:write"},{value:"bookmark:write",label:"bookmark:write"},{value:"secret:read",label:"secret:read"},{value:"secret:write",label:"secret:write"},{value:"totp:read",label:"totp:read"},{value:"trade:all",label:"trade:all"},{value:"wallet:write",label:"wallet:write"},{value:"extension:*",label:"extension:*"},{value:"admin:*",label:"admin:* (dangerous)"}],b2={strict:"Read-only, agent vault only. Hidden: password, cvv, privateKey, seedPhrase, refresh_token. 15 min TTL, 50 reads max.",dev:"Read/write, all vaults. Hidden: cvv, seedPhrase, privateKey, refresh_token. 1 hour TTL, 500 reads max.",admin:"Full access, no field redaction. 1 hour TTL, unlimited reads."},b3=[{value:"profile",label:"Profile"},{value:"permissions",label:"Permissions"}],b4="aura:api-keys:profiles:v1",b5={strict:{ttlSeconds:900,maxReads:50,scope:["secret:read"],excludeFields:["password","cvv","privateKey","seedPhrase","refresh_token"]},dev:{ttlSeconds:3600,maxReads:500,scope:["wallet:list","secret:read","secret:write","action:create","action:read","action:resolve"],excludeFields:["cvv","seedPhrase","privateKey","refresh_token"]},admin:{ttlSeconds:3600,scope:["admin:*"],excludeFields:[]}};function b6(a){return a.length<=14?a:`${a.slice(0,8)}...${a.slice(-4)}`}function b7(){let a=Math.random().toString(36).slice(2,8);return`agent:local:${a}`}function b8(a){return Array.from(new Set(a.map(a=>a.trim().normalize("NFKC").toLowerCase()).filter(Boolean)))}let b9=({requests:a,activeTokens:b,inactiveTokens:c,actionLoading:f,onResolveAction:g,onRevokeToken:h,vaults:i=[]})=>{let[j,l]=(0,e.useState)([]),[m,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(""),[r,u]=(0,e.useState)("dev"),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)(""),[A,B]=(0,e.useState)([]),[C,D]=(0,e.useState)("secret:read"),[E,G]=(0,e.useState)(""),[I,K]=(0,e.useState)([]),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(null),[P,Q]=(0,e.useState)(()=>b7()),[R,S]=(0,e.useState)("profile"),[T,U]=(0,e.useState)("builtin:dev"),[V,W]=(0,e.useState)("secret:read"),[X,Y]=(0,e.useState)(["secret:read","secret:write"]),[Z,$]=(0,e.useState)([]),[_,aa]=(0,e.useState)(!1),[ab,ac]=(0,e.useState)(null),[ad,af]=(0,e.useState)(null),[ag,ah]=(0,e.useState)(null),[ai,aj]=(0,e.useState)(!1),[ak,al]=(0,e.useState)(!1),[am,an]=(0,e.useState)(null),[ao,ap]=(0,e.useState)(null),[aq,ar]=(0,e.useState)(null);(0,e.useEffect)(()=>{try{let a=localStorage.getItem(b4);if(!a)return;let b=JSON.parse(a);if(!Array.isArray(b))return;let c=b.filter(a=>a&&"string"==typeof a.id&&"string"==typeof a.name&&"string"==typeof a.profile&&"v1"===a.profileVersion&&"number"==typeof a.updatedAt).map(a=>{let b=b8([...a.overrides?.scope||[],...a.overrides?.readScopes||[],...a.overrides?.writeScopes||[]]),c=a.overrides?{...a.overrides,...b.length>0?{scope:b}:{},readScopes:void 0,writeScopes:void 0}:null;return{...a,overrides:c}});l(c)}catch{l([])}},[]),(0,e.useEffect)(()=>{localStorage.setItem(b4,JSON.stringify(j))},[j]);let as=(0,e.useCallback)(()=>{o(null),q(""),u("dev"),w(""),y(""),B([]),D("secret:read"),G(""),K([]),M(null),O(null)},[]),at=(0,e.useCallback)(a=>{let b=b5[a];b&&(w(String(b.ttlSeconds)),y("number"==typeof b.maxReads?String(b.maxReads):""),B(b.scope),D(b.scope[0]||"secret:read"),G(b.excludeFields.join(", ")))},[]),au=(0,e.useMemo)(()=>{let a=[{value:"vault:*",label:"All Vaults (vault:*)"}];for(let b of i){let c=b.name||b.id;a.push({value:`vault:${b.id}`,label:`vault:${c}`})}return a},[i]),av=(0,e.useMemo)(()=>a.filter(a=>"pending"===a.status&&("auth"===a.type||"permission_update"===a.type)),[a]),aw=(0,e.useMemo)(()=>[...b0.map(a=>({value:`builtin:${a.id}`,label:`${a.label} — ${a.description}`})),...j.map(a=>({value:`draft:${a.id}`,label:`Custom \xb7 ${a.name}`}))],[j]);(0,e.useEffect)(()=>{aw.some(a=>a.value===T)||U("builtin:dev")},[T,aw]);let ax=(0,e.useCallback)(()=>{if(T.startsWith("draft:")){let a=T.slice(6),b=j.find(b=>b.id===a);if(b){let a=b8([...b.overrides?.scope||[],...b.overrides?.readScopes||[],...b.overrides?.writeScopes||[]]),c=b.overrides?{...b.overrides,...a.length>0?{scope:a}:{}}:void 0;return{profile:b.profile,profileVersion:b.profileVersion,...c?{profileOverrides:c}:{}}}}return{profile:T.startsWith("builtin:")?T.slice(8):"dev",profileVersion:"v1"}},[T,j]),ay=(0,e.useCallback)(a=>{let b=b8([a])[0];b&&Y(a=>a.includes(b)?a:[...a,b])},[]),az=(0,e.useCallback)(a=>{Y(b=>b.filter(b=>b!==a))},[]),aA=(0,e.useCallback)(()=>{M(null),O(null);let a=p.trim();if(!a)return void M("Profile name is required.");let{overrides:b,error:c}=function(a){let b={};if(a.ttlSeconds.trim().length>0){let c=Number(a.ttlSeconds.trim());if(!Number.isFinite(c)||c<=0)return{overrides:null,error:"TTL override must be a positive number."};b.ttlSeconds=c}if(a.maxReads.trim().length>0){let c=Number(a.maxReads.trim());if(!Number.isFinite(c)||c<=0)return{overrides:null,error:"Max reads override must be a positive number."};b.maxReads=c}let c=b8(a.scope),d=function(a){let b=a.split(",").map(a=>a.trim()).filter(Boolean);return b.length>0?b:void 0}(a.excludeFields);return c.length>0&&(b.scope=c),d&&(b.excludeFields=d),{overrides:Object.keys(b).length>0?b:null,error:null}}({ttlSeconds:v,maxReads:x,scope:A,excludeFields:E});if(c)return void M(c);let d=I.length>0?{...b||{},readScopes:I,writeScopes:I}:b;if(j.some(b=>b.name.toLowerCase()===a.toLowerCase()&&b.id!==m))return void M("A profile with this name already exists.");let e={id:m||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,name:a,profile:r,profileVersion:"v1",overrides:d,updatedAt:Date.now()};l(a=>m?a.map(a=>a.id===m?e:a):[e,...a]),O(m?"Profile updated.":"Profile created."),m||U(`draft:${e.id}`),o(e.id)},[m,r,E,x,p,A,v,I,j]),aB=(0,e.useCallback)(a=>{o(a.id),q(a.name),u(a.profile),w(a.overrides?.ttlSeconds?String(a.overrides.ttlSeconds):""),y(a.overrides?.maxReads?String(a.overrides.maxReads):"");let b=b8([...a.overrides?.scope||[],...a.overrides?.readScopes||[],...a.overrides?.writeScopes||[]]);B(b),D(b[0]||"secret:read"),G((a.overrides?.excludeFields||[]).join(", ")),K(a.overrides?.readScopes||a.overrides?.vaultReadScopes||[]),M(null),O(null)},[]),aC=(0,e.useCallback)(a=>{let b=b8([a])[0];b&&B(a=>a.includes(b)?a:[...a,b])},[]),aD=(0,e.useCallback)(a=>{B(b=>b.filter(b=>b!==a))},[]),aE=(0,e.useCallback)(a=>{l(b=>b.filter(b=>b.id!==a)),m===a&&as(),T===`draft:${a}`&&U("builtin:dev")},[m,T,as]),aF=(0,e.useCallback)(async()=>{if(an(null),ap(null),"permissions"===R)return void an("Policy preview is currently available for profile-based issuance only.");al(!0);try{let a=ax(),b=await s.FH.post(s.jI.Wallet,"/actions/token/preview",a);ap(function(a){let b=a&&"object"==typeof a?a:{},c=b.effectivePolicy&&"object"==typeof b.effectivePolicy?b.effectivePolicy:{},d=c.credentialAccess&&"object"==typeof c.credentialAccess?c.credentialAccess:{},e=c.rateBudget&&"object"==typeof c.rateBudget?c.rateBudget:{};return{version:"v1",profile:b.profile&&"object"==typeof b.profile?b.profile:void 0,effectivePolicy:{permissions:Array.isArray(c.permissions)?c.permissions.filter(a=>"string"==typeof a):[],credentialAccess:{read:Array.isArray(d.read)?d.read.filter(a=>"string"==typeof a):[],write:Array.isArray(d.write)?d.write.filter(a=>"string"==typeof a):[],excludeFields:Array.isArray(d.excludeFields)?d.excludeFields.filter(a=>"string"==typeof a):[],maxReads:"number"==typeof d.maxReads?d.maxReads:null},ttlSeconds:"number"==typeof c.ttlSeconds?c.ttlSeconds:0,maxReads:"number"==typeof c.maxReads?c.maxReads:null,rateBudget:{state:"inherited"===e.state||"explicit"===e.state?e.state:"none",requests:"number"==typeof e.requests?e.requests:null,windowSeconds:"number"==typeof e.windowSeconds?e.windowSeconds:null,source:"profile"===e.source||"override"===e.source?e.source:"none"}},warnings:Array.isArray(b.warnings)?b.warnings.filter(a=>"string"==typeof a):[],overrideDelta:Array.isArray(b.overrideDelta)?b.overrideDelta.filter(a=>"string"==typeof a):[],denyExamples:Array.isArray(b.denyExamples)?b.denyExamples.filter(a=>!!a&&"object"==typeof a).map(a=>({code:String(a.code||"UNKNOWN"),message:String(a.message||"")})):[],effectivePolicyHash:"string"==typeof b.effectivePolicyHash?b.effectivePolicyHash:"n/a"}}(b))}catch(a){an(a instanceof Error?a.message:"Failed to preview profile policy.")}finally{al(!1)}},[R,ax]),aG=(0,e.useCallback)(async()=>{if(ac(null),af(null),ah(null),!P.trim())return void ac("Agent ID is required.");if("permissions"===R&&0===X.length)return void ac("Select at least one permission for manual issuance.");let a=(0,t.OQ)();if(!a)return void ac("Vault keypair is unavailable. Re-unlock and retry.");aa(!0);try{let b;if("permissions"===R){let c=Z.length>0?{read:Z,write:Z}:void 0;b=await s.FH.post(s.jI.Wallet,"/actions/token",{agentId:P.trim(),pubkey:a,permissions:X,...c?{credentialAccess:c}:{}})}else{let c=ax();Z.length>0&&(c.profileOverrides={...c.profileOverrides||{},readScopes:Z,writeScopes:Z}),b=await s.FH.post(s.jI.Wallet,"/actions/token",{agentId:P.trim(),pubkey:a,...c})}if(!b.success||!b.encryptedToken)throw Error("Token issuance failed.");let c=await (0,t.DC)(b.encryptedToken);if(af(c),"permissions"===R)ah(`${P.trim()} \xb7 permissions:${X.join(",")}${b.warnings?.length?" \xb7 warnings present":""}`);else{let a=ax();ah(`${P.trim()} \xb7 ${a.profile}@${a.profileVersion}${b.warnings?.length?" \xb7 warnings present":""}`)}}catch(a){ac(a instanceof Error?a.message:"Token issuance failed.")}finally{aa(!1)}},[P,R,X,Z,ax]),aH=(0,e.useCallback)(async()=>{ad&&navigator.clipboard&&(await navigator.clipboard.writeText(ad),aj(!0),setTimeout(()=>aj(!1),1500))},[ad]),aI=(0,e.useCallback)(async(a,b)=>{let c=await g(a,b);if(c.success)return void ar(b?`Approved request ${a.slice(0,8)}.`:`Rejected request ${a.slice(0,8)}.`);ar(c.message||"Failed to resolve request.")},[g]),aJ=(0,e.useMemo)(()=>b.filter(a=>!a.isAdmin),[b]);return(0,d.jsxs)("div",{className:"h-full overflow-y-auto px-5 py-4 font-mono",children:[(0,d.jsxs)("div",{className:"mb-4 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,d.jsx)("div",{className:"text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"API KEYS"}),(0,d.jsx)("div",{className:"mt-1 text-[9px] text-[var(--color-text-muted,#6b7280)] leading-relaxed",children:"Auth management surface for profile templates + permissions-based issuance + pending auth approvals."})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[(0,d.jsxs)("section",{className:"order-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,d.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"ISSUE API KEY"}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,d.jsx)(z.ks,{label:"Agent ID",value:P,onChange:a=>Q(a.target.value),placeholder:"agent:local:dev",compact:!0}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>Q(b7()),icon:(0,d.jsx)(F.A,{size:10}),title:"Regenerate Agent ID",className:"mb-[1px]",children:"NEW ID"})]}),(0,d.jsx)(z.UM,{label:"Issuance Mode",options:b3,value:R,onChange:a=>S(a),compact:!0})]}),"profile"===R?(0,d.jsxs)("div",{className:"mt-2",children:[(0,d.jsx)(z.UM,{label:"Profile Source",options:aw,value:T,onChange:U,compact:!0}),(()=>{let a=T.startsWith("builtin:")?T.slice(8):null,b=a?b2[a]:null;return b?(0,d.jsx)("div",{className:"mt-1 px-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:b}):(0,d.jsx)("div",{className:"mt-1 px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Profile mode resolves permissions/scopes/ttl from the selected profile."})})()]}):(0,d.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,d.jsx)(z.UM,{label:"Permissions",options:b1.map(a=>({value:a.value,label:a.label})),value:V,onChange:W,compact:!0}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>ay(V),children:"ADD"})]}),0===X.length?(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-danger,#ef4444)]",children:"No permissions selected."}):(0,d.jsx)("div",{className:"flex flex-wrap gap-1",children:X.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[a,(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>az(a),className:"h-4 px-1 text-[8px]",children:"X"})]},`perm-${a}`))}),(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Permissions mode issues exactly the selected permissions."})]}),au.length>1&&(0,d.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,d.jsx)(z.UM,{label:"Vault Scope",options:au,value:au[0]?.value||"vault:*",onChange:a=>{Z.includes(a)||$(b=>[...b,a])},compact:!0}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>$([]),children:"CLEAR"})]}),0===Z.length?(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"No vault restriction — uses profile/system defaults."}):(0,d.jsx)("div",{className:"flex flex-wrap gap-1",children:Z.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[a,(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>$(b=>b.filter(b=>b!==a)),className:"h-4 px-1 text-[8px]",children:"X"})]},`vs-${a}`))})]}),(0,d.jsx)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-2 py-2 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:"Generate a key in one click. Preview is optional and only shows what permissions/scopes will be issued."}),ab&&(0,d.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:ab}),(0,d.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,d.jsx)(z.$n,{size:"sm",onClick:()=>{aG()},loading:_,icon:_?void 0:(0,d.jsx)(k.A,{size:11}),children:"ISSUE API KEY"}),(0,d.jsx)(z.$n,{size:"sm",variant:"secondary",onClick:()=>{aF()},loading:ak,disabled:"permissions"===R,icon:ak?void 0:(0,d.jsx)(F.A,{size:11}),children:"PREVIEW POLICY"})]}),am&&(0,d.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:am}),ao&&(0,d.jsxs)("div",{className:"mt-3 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,d.jsxs)("div",{className:"text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["HASH ",b6(ao.effectivePolicyHash)]}),ao.profile&&(0,d.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["profile: ",ao.profile.id,"@",ao.profile.version]}),(0,d.jsxs)("div",{className:"mt-1 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:["permissions: ",ao.effectivePolicy.permissions.length," \xb7 ttl: ",ao.effectivePolicy.ttlSeconds,"s \xb7 max reads: ",ao.effectivePolicy.maxReads??"unlimited"]}),(0,d.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,d.jsxs)("div",{children:["perms: ",ao.effectivePolicy.permissions.join(", ")||"(none)"]}),(0,d.jsxs)("div",{children:["read scope: ",ao.effectivePolicy.credentialAccess.read.join(", ")||"(none)"]}),(0,d.jsxs)("div",{children:["write scope: ",ao.effectivePolicy.credentialAccess.write.join(", ")||"(none)"]}),(0,d.jsxs)("div",{children:["excluded fields: ",ao.effectivePolicy.credentialAccess.excludeFields.join(", ")||"(none)"]}),(0,d.jsxs)("div",{children:["rate budget: ",ao.effectivePolicy.rateBudget.state," (",ao.effectivePolicy.rateBudget.requests??"n/a"," / ",ao.effectivePolicy.rateBudget.windowSeconds??"n/a","s, source=",ao.effectivePolicy.rateBudget.source,")"]})]}),ao.overrideDelta.length>0&&(0,d.jsxs)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-1.5 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,d.jsx)("div",{className:"mb-1 tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"OVERRIDE DELTA"}),ao.overrideDelta.join(" \xb7 ")]}),ao.denyExamples&&ao.denyExamples.length>0&&(0,d.jsxs)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-1.5 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,d.jsx)("div",{className:"mb-1 tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"EXPECTED DENY EXAMPLES"}),(0,d.jsx)("ul",{className:"space-y-0.5",children:ao.denyExamples.map(a=>(0,d.jsxs)("li",{children:["• ",a.code,": ",a.message]},`${a.code}-${a.message.slice(0,12)}`))})]}),ao.warnings.length>0&&(0,d.jsxs)("div",{className:"mt-2 flex items-start gap-1.5 text-[8px] text-[var(--color-warning,#ff4d00)]",children:[(0,d.jsx)(b_,{size:10,className:"mt-[1px]"}),(0,d.jsx)("span",{children:ao.warnings.join(" | ")})]})]}),ad&&(0,d.jsxs)("div",{className:"mt-3 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,d.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,d.jsx)("div",{className:"text-[8px] tracking-widest text-[var(--color-success,#16a34a)]",children:"API KEY ISSUED"}),(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>{aH()},icon:(0,d.jsx)(ae.A,{size:10}),children:ai?"COPIED":"COPY"})]}),ag&&(0,d.jsx)("div",{className:"mb-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:ag}),(0,d.jsx)("code",{className:"block max-h-20 overflow-y-auto break-all bg-[var(--color-background,#f4f4f5)] px-2 py-1 text-[9px] text-[var(--color-text,#0a0a0a)]",children:ad})]})]}),(0,d.jsxs)("section",{className:"order-2 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,d.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,d.jsx)("div",{className:"text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"PROFILE BUILDER"}),m&&(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:as,children:"NEW"})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,d.jsx)(z.ks,{label:"Profile Name",value:p,onChange:a=>q(a.target.value),placeholder:"e.g. CI deploy scoped",compact:!0}),(0,d.jsx)(z.UM,{label:"Load from template",options:b0.map(a=>({value:a.id,label:`${a.label} — ${a.description}`})),value:r,onChange:a=>{u(a),at(a)},compact:!0}),r&&b2[r]&&(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:b2[r]}),(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,d.jsx)(z.ks,{label:"TTL Override",value:v,onChange:a=>w(a.target.value),placeholder:"seconds",compact:!0}),(0,d.jsx)(z.ks,{label:"Max Reads",value:x,onChange:a=>y(a.target.value),placeholder:"count",compact:!0})]}),(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,d.jsx)(z.UM,{label:"Scope",options:b1.map(a=>({value:a.value,label:a.label})),value:C,onChange:D,compact:!0}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>aC(C),children:"ADD"})]}),0===A.length?(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Using base profile scope defaults."}):(0,d.jsx)("div",{className:"flex flex-wrap gap-1",children:A.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[a,(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>aD(a),className:"h-4 px-1 text-[8px]",children:"X"})]},`scope-${a}`))})]}),(0,d.jsxs)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["Scope uses the same permission vocabulary as Issue API Key (for example: ",(0,d.jsx)("code",{children:"secret:read"}),", ",(0,d.jsx)("code",{children:"secret:write"}),", ",(0,d.jsx)("code",{children:"wallet:create:hot"}),", ",(0,d.jsx)("code",{children:"send:hot"}),")."]}),(0,d.jsx)(z.ks,{label:"Exclude Fields (CSV)",value:E,onChange:a=>G(a.target.value),placeholder:"password, seedPhrase",compact:!0}),au.length>1&&(0,d.jsxs)("div",{className:"space-y-1",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,d.jsx)(z.UM,{label:"Vault Read/Write Scope",options:au,value:au[0]?.value||"vault:*",onChange:a=>{I.includes(a)||K(b=>[...b,a])},compact:!0}),(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:()=>K([]),children:"CLEAR"})]}),0===I.length?(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Using base profile vault defaults."}):(0,d.jsx)("div",{className:"flex flex-wrap gap-1",children:I.map(a=>(0,d.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[a,(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>K(b=>b.filter(b=>b!==a)),className:"h-4 px-1 text-[8px]",children:"X"})]},`pvs-${a}`))}),(0,d.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Restricts which vaults this profile can read/write credentials from. Select specific vaults or leave empty for profile defaults."})]})]}),L&&(0,d.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:L}),N&&(0,d.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-success,#16a34a)]",children:N}),(0,d.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,d.jsx)(z.$n,{size:"sm",onClick:aA,icon:(0,d.jsx)(H.A,{size:11}),children:m?"UPDATE PROFILE":"CREATE PROFILE"}),m&&(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:as,children:"CANCEL"})]}),(0,d.jsxs)("div",{className:"mt-4 border-t border-[var(--color-border,#d4d4d8)] pt-3",children:[(0,d.jsxs)("div",{className:"mb-2 text-[9px] font-bold tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["SAVED PROFILES (",j.length,")"]}),0===j.length?(0,d.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No custom profiles saved yet."}):(0,d.jsx)("div",{className:"space-y-2",children:j.map(a=>(0,d.jsxs)("div",{className:"flex items-center justify-between border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-2 py-1.5",children:[(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>aB(a),className:"h-auto min-h-0 w-full justify-start px-0 py-0 text-left hover:bg-transparent",children:(0,d.jsxs)("span",{className:"block",children:[(0,d.jsx)("span",{className:"block text-[10px] text-[var(--color-text,#0a0a0a)]",children:a.name}),(0,d.jsxs)("span",{className:"block text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:[a.profile,"@",a.profileVersion]})]})}),(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>aE(a.id),icon:(0,d.jsx)(J.A,{size:10}),children:""})]},a.id))})]})]})]}),(0,d.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2",children:[(0,d.jsxs)("section",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,d.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"PENDING AUTH REQUESTS"}),aq&&(0,d.jsx)("div",{className:"mb-2 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:aq}),0===av.length?(0,d.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No pending auth requests."}):(0,d.jsx)("div",{className:"space-y-2",children:av.map(a=>{let b=function(a){if(!a)return{};try{let b=JSON.parse(a);if(b&&"object"==typeof b)return b;return{}}catch{return{}}}(a.metadata),c="string"==typeof b.agentId?b.agentId:"unknown-agent",e="object"==typeof b.profile&&b.profile&&"id"in b.profile?b.profile:null,g=e?`${String(e.id)}@${String(e.version||"v1")}`:"n/a",h=e?function(a){return b2[a]||`Custom profile: ${a}`}(String(e.id)):null,i=Array.isArray(b.permissions)?b.permissions:[],j=f===`resolve-${a.id}`;return(0,d.jsxs)("div",{className:"rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,d.jsxs)("div",{className:"text-[9px] text-[var(--color-text,#0a0a0a)]",children:[c," \xb7 ",a.type]}),(0,d.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:[g," \xb7 ",new Date(a.createdAt).toLocaleString()]}),h&&(0,d.jsx)("div",{className:"mt-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:h}),i.length>0&&(0,d.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1",children:[i.slice(0,6).map(a=>(0,d.jsx)("span",{className:"border border-[var(--color-border,#d4d4d8)] px-1 py-0.5 text-[7px] text-[var(--color-text-muted,#6b7280)]",children:String(a)},a)),i.length>6&&(0,d.jsxs)("span",{className:"px-1 py-0.5 text-[7px] text-[var(--color-text-faint,#9ca3af)]",children:["+",i.length-6," more"]})]}),(0,d.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,d.jsx)(z.$n,{size:"sm",onClick:()=>{aI(a.id,!0)},loading:j,icon:j?void 0:(0,d.jsx)(bu.A,{size:10}),children:"APPROVE"}),(0,d.jsx)(z.$n,{size:"sm",variant:"secondary",onClick:()=>{aI(a.id,!1)},disabled:j,icon:(0,d.jsx)(bK.A,{size:10}),children:"REJECT"})]})]},a.id)})})]}),(0,d.jsxs)("section",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,d.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"ISSUED API KEYS"}),(0,d.jsxs)("div",{className:"mb-2 text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["ACTIVE (",aJ.length,")"]}),0===aJ.length?(0,d.jsx)("div",{className:"mb-3 text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No active non-admin tokens."}):(0,d.jsx)("div",{className:"mb-3 space-y-2",children:aJ.map(a=>{let b=f===`revoke-${a.tokenHash}`;return(0,d.jsxs)("div",{className:"rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("div",{className:"text-[9px] text-[var(--color-text,#0a0a0a)]",children:a.agentId}),(0,d.jsx)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:b6(a.tokenHash)})]}),(0,d.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["perms: ",a.permissions.length," \xb7 expires: ",new Date(a.expiresAt).toLocaleString()]}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(z.$n,{size:"sm",variant:"secondary",onClick:()=>{h(a.tokenHash)},disabled:b,icon:b?(0,d.jsx)(n.A,{size:10,className:"animate-spin"}):(0,d.jsx)(J.A,{size:10}),children:"REVOKE"})})]},a.tokenHash)})}),(0,d.jsxs)("div",{className:"mb-2 text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["INACTIVE (",c.length,")"]}),0===c.length?(0,d.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No inactive tokens."}):(0,d.jsxs)("div",{className:"space-y-1.5",children:[c.slice(0,8).map(a=>(0,d.jsxs)("div",{className:"flex items-center justify-between rounded border border-[var(--color-border,#d4d4d8)] px-2 py-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,d.jsx)("span",{children:a.agentId}),(0,d.jsx)("span",{children:b6(a.tokenHash)})]},`${a.agentId}-${a.tokenHash}`)),c.length>8&&(0,d.jsxs)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["+",c.length-8," more inactive tokens"]})]})]})]})]})};var ca=c(38998),cb=c(64354);let cc={vaultId:null,category:"all",tag:null,search:"",favoritesOnly:!1,lifecycle:"active"},cd=[{value:"linked",label:"Child (inherits parent unlock)"},{value:"independent",label:"Independent (separate password)"}],ce=["username","url","content","key","value","cardholder","brand","last4","token_endpoint","scopes","fingerprint"],cf={active:"active",archive:"archive",archived:"archive",deleted:"recently_deleted",recently_deleted:"recently_deleted",recentlydeleted:"recently_deleted"},cg=(()=>{let a=new Map;for(let b of Object.values(y.Rn))for(let c of b)for(let b of(a.set(c.key.toLowerCase(),c.key),c.aliases||[]))a.set(b.toLowerCase(),c.key);return a})(),ch=(()=>{let a=[...ce,...Array.from(cg.values())],b=new Set,c=[];for(let d of a){let a=d.toLowerCase();b.has(a)||(b.add(a),c.push(d))}return c.slice(0,8)})();function ci(a){return a.location?a.location:a.deletedAt?"recently_deleted":a.archivedAt?"archive":"active"}function cj(a){let b=a.createdAt?Date.parse(a.createdAt):NaN;return Number.isFinite(b)?b:0}function ck(a,b){let c=b[a.id];return"number"==typeof c&&Number.isFinite(c)&&c>0?c:cj(a)}function cl(a,b){let c={};for(let d of a){let a=b[d.id];if("number"==typeof a&&Number.isFinite(a)&&a>0){c[d.id]=a;continue}c[d.id]=cj(d)}return c}function cm(a){return a.trim().toLowerCase()}function cn(a){return null==a?"":"string"==typeof a||"number"==typeof a||"boolean"==typeof a?String(a).toLowerCase():Array.isArray(a)?a.map(cn).join(" "):"object"==typeof a?Object.values(a).map(cn).join(" "):""}function co(a){let b=a.trim().toLowerCase().replace(/\s+/g,"_");return cg.get(b)||b}let cp=({onLock:a,onSettings:b})=>{let{subscribe:c}=(0,bL.h)(),[f,g]=(0,e.useState)([]),[h,i]=(0,e.useState)([]),[j,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(cc),[n,o]=(0,e.useState)(!0),[p,q]=(0,e.useState)("credentials"),[t,y]=(0,e.useState)({}),[A,B]=(0,e.useState)({}),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(()=>"desktop"),{clearToken:I,setToken:J}=(0,r.A)(),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(!1),[O,P]=(0,e.useState)(!1),[Q,R]=(0,e.useState)("api-key-form"),[S,T]=(0,e.useState)(null),[U,V]=(0,e.useState)(null),[W,Y]=(0,e.useState)(!1),[Z,$]=(0,e.useState)(""),[_,aa]=(0,e.useState)("independent"),[ab,ae]=(0,e.useState)(""),[af,ag]=(0,e.useState)(""),[ah,ai]=(0,e.useState)(!1),[aj,ak]=(0,e.useState)(!1),[al,am]=(0,e.useState)(""),[an,ao]=(0,e.useState)(!1),[ap,aq]=(0,e.useState)(!1),[ar,as]=(0,e.useState)(null),[at,au]=(0,e.useState)(""),[av,aw]=(0,e.useState)(!1),[ax,ay]=(0,e.useState)(null),[az,aA]=(0,e.useState)(null),[aB,aC]=(0,e.useState)(!1),[aD,aE]=(0,e.useState)(null),{requests:aF,notifications:aG,dismissNotification:aH,resolveAction:aI,revokeToken:aJ=async()=>!1,activeTokens:aK=[],inactiveTokens:aL=[],actionLoading:aM}=(0,cb.S)({autoFetch:!0}),aN=(0,e.useRef)(null),aO=(0,e.useRef)(null),aP=(0,e.useRef)(null),aQ=(0,e.useRef)(null),aR="mobile"===G,aS="tablet"===G,aT=(0,e.useCallback)(async()=>{try{let[a,b,c,d]=await Promise.all([s.FH.get(s.jI.Wallet,"/credentials",{location:"active"}),s.FH.get(s.jI.Wallet,"/credentials",{location:"archive"}),s.FH.get(s.jI.Wallet,"/credentials",{location:"recently_deleted"}),s.FH.get(s.jI.Wallet,"/vaults/credential")]),e=(a,b)=>a.success?(a.credentials||[]).map(a=>({...a,location:b})):[],f=[...e(a,"active"),...e(b,"archive"),...e(c,"recently_deleted")];g(f),y(a=>cl(f,a)),B(a=>cl(f,a)),d.success&&i(d.vaults)}catch(a){console.error("[CredentialVault] fetch error:",a)}finally{o(!1)}},[]);(0,e.useEffect)(()=>{aT()},[aT]),(0,e.useEffect)(()=>{},[]),(0,e.useEffect)(()=>{},[t]);let aU=(0,e.useCallback)((a,b=Date.now())=>{y(c=>{let d=Number.isFinite(b)&&b>0?b:Date.now();return c[a]===d?c:{...c,[a]:d}})},[]),aV=(0,e.useCallback)(()=>{aP.current||(aP.current=setTimeout(()=>{aP.current=null,aT()},120))},[aT]);(0,e.useEffect)(()=>{let a=c(bM.Cw.CREDENTIAL_CHANGED,a=>{let b=a.data;b?.credentialId&&aV()}),b=c(bM.Cw.CREDENTIAL_ACCESSED,a=>{let b=a.data;b?.credentialId&&!0===b.allowed&&aU(b.credentialId)});return()=>{a(),b(),aP.current&&(clearTimeout(aP.current),aP.current=null),aQ.current&&(clearTimeout(aQ.current),aQ.current=null)}},[aV,c,aU]),(0,e.useEffect)(()=>{j&&!f.some(a=>a.id===j)&&(k(null),N(!1))},[f,j]),(0,e.useEffect)(()=>{let a=()=>{var a;return H((a=window.innerWidth)<768?"mobile":a<1280?"tablet":"desktop")};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),(0,e.useEffect)(()=>{aR||(L(!1),N(!1))},[aR]),(0,e.useEffect)(()=>{if(!C)return;let a=a=>{let b=a.target;b&&(aO.current?.contains(b)||(aQ.current&&(clearTimeout(aQ.current),aQ.current=null),F(!1),D(!1)))};return document.addEventListener("mousedown",a),document.addEventListener("touchstart",a),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("touchstart",a)}},[C]);let aW=(0,e.useMemo)(()=>h.find(a=>a.isPrimary)?.id||"",[h]),aX=(0,e.useMemo)(()=>h.map(a=>({value:a.id,label:a.name||(a.isPrimary?"Primary":`Vault ${a.id.slice(0,6)}`)})),[h]);(0,e.useEffect)(()=>{W&&ae(a=>a&&aX.some(b=>b.value===a)?a:l.vaultId||aW||aX[0]?.value||"")},[l.vaultId,aX,aW,W]),(0,e.useEffect)(()=>{if(0===h.length)return void am("primary");let a=aW||h[0].id||"primary";am(b=>b&&h.some(a=>a.id===b)?b:a)},[aW,h]);let aY=(0,e.useMemo)(()=>{if(!l.vaultId)return null;let a=h.find(a=>a.id===l.vaultId);return new Set(a?function(a,b){let c=new Map;for(let a of b){let b=a.parentVaultId||a.linkedTo;if(!b)continue;let d=c.get(b)||[];d.push(a),c.set(b,d)}let d=[],e=[a],f=new Set;for(;e.length>0;){let a=e.shift();if(!f.has(a))for(let b of(f.add(a),d.push(a),c.get(a)||[]))e.push(b.id)}return d}(a.id,h):[l.vaultId])},[l.vaultId,h]),aZ=(0,e.useCallback)(a=>aY?a.filter(a=>aY.has(a.vaultId)):a,[aY]),a$=(0,e.useMemo)(()=>{let a=new Map;for(let b of h)a.set(b.id,(b.name||(b.isPrimary?"Primary":`Vault ${b.id.slice(0,6)}`)).toLowerCase());return a},[h]),a_=(0,e.useMemo)(()=>{let a=function(a){let b={terms:[],tagFilters:[],typeFilters:[],vaultFilters:[],fieldFilters:[],lifecycleFilters:new Set,favoriteOnly:!1};for(let c of a.trim().split(/\s+/).map(a=>a.trim()).filter(Boolean)){let a=cm(c);if("favorite"===a||"favourite"===a||"fav"===a){b.favoriteOnly=!0;continue}let d=cf[a];if(d){b.lifecycleFilters.add(d);continue}let e=c.indexOf(":");if(e<=0){b.terms.push(a);continue}let f=cm(c.slice(0,e)),g=cm(c.slice(e+1).trim());if(g){if("tag"===f){b.tagFilters.push(g);continue}if("type"===f){b.typeFilters.push(g);continue}if("vault"===f){b.vaultFilters.push(g);continue}if("lifecycle"===f||"location"===f){let a=cf[g];a&&b.lifecycleFilters.add(a);continue}if("favorite"===f||"fav"===f){b.favoriteOnly=!["false","0","no"].includes(g);continue}b.fieldFilters.push({key:co(f),value:g})}}return b}(l.search),b=a.lifecycleFilters.size>0,c=a.terms,d=aZ(f);if(d=b?d.filter(b=>a.lifecycleFilters.has(ci(b))):d.filter(a=>ci(a)===l.lifecycle),"all"!==l.category&&(d=d.filter(a=>a.type===l.category)),(l.favoritesOnly||a.favoriteOnly)&&(d=d.filter(a=>!!a.meta.favorite)),l.tag){let a=cm(l.tag);d=d.filter(b=>(b.meta.tags||[]).some(b=>cm(b).includes(a)))}a.tagFilters.length>0&&(d=d.filter(b=>{let c=(b.meta.tags||[]).map(a=>cm(a));return a.tagFilters.every(a=>c.some(b=>b.includes(a)))})),a.typeFilters.length>0&&(d=d.filter(b=>a.typeFilters.some(a=>cm(b.type).includes(a)))),a.vaultFilters.length>0&&(d=d.filter(b=>{let c=a$.get(b.vaultId)||cm(b.vaultId);return a.vaultFilters.every(a=>c.includes(a)||cm(b.vaultId).includes(a))}));let e=d,g=d;return a.fieldFilters.length>0&&(g=g.filter(b=>a.fieldFilters.every(a=>(function(a,b,c){let d=co(b);for(let[b,e]of Object.entries(a.meta||{}))if(co(b)===d&&cn(e).includes(c))return!0;return!1})(b,a.key,a.value)))),c.length>0&&(g=g.filter(a=>{let b=ci(a),d=(a.meta.tags||[]).map(a=>cm(a)).join(" "),e=a$.get(a.vaultId)||cm(a.vaultId),f=cn(a.meta),g=[cm(a.name),cm(a.id),cm(a.type),d,e,f].join(" ");return c.every(c=>{if("favorite"===c||"favourite"===c||"fav"===c)return!!a.meta.favorite;let d=cf[c];return d?b===d:g.includes(c)})})),{parsed:a,preTextFiltered:e,results:g}},[f,l,aZ,a$]),a0=a_.results,a1=(0,e.useMemo)(()=>ac(a0,A,l.search),[a0,A,l.search]),a2=(0,e.useMemo)(()=>{let a=l.search.trim();if(!a||a.includes(":")||a0.length>0)return[];let b=cm(a);return a_.preTextFiltered.some(a=>cm(a.name).includes(b))?[]:ch.map(b=>`${b}:${a}`)},[l.search,a0.length,a_.preTextFiltered]),a3=(0,e.useMemo)(()=>{let a=aZ(f).filter(a=>ci(a)===l.lifecycle);if(l.tag){let b=l.tag;a=a.filter(a=>a.meta.tags?.includes(b))}return l.favoritesOnly&&(a=a.filter(a=>a.meta.favorite)),{all:a.length,login:a.filter(a=>"login"===a.type).length,card:a.filter(a=>"card"===a.type).length,note:a.filter(a=>"note"===a.type).length,plain_note:a.filter(a=>"plain_note"===a.type).length,hot_wallet:a.filter(a=>"hot_wallet"===a.type).length,api:a.filter(a=>"api"===a.type).length,apikey:a.filter(a=>"apikey"===a.type).length,custom:a.filter(a=>"custom"===a.type).length,passkey:a.filter(a=>"passkey"===a.type).length,oauth2:a.filter(a=>"oauth2"===a.type).length,ssh:a.filter(a=>"ssh"===a.type).length,gpg:a.filter(a=>"gpg"===a.type).length}},[f,l.lifecycle,l.tag,l.favoritesOnly,aZ]),a4=(0,e.useMemo)(()=>{let a=new Set;return aZ(f).filter(a=>ci(a)===l.lifecycle).forEach(b=>b.meta.tags?.forEach(b=>a.add(b))),Array.from(a).sort()},[f,l.lifecycle,aZ]),a5=(0,e.useMemo)(()=>aZ(f).filter(a=>ci(a)===l.lifecycle).filter(a=>a.meta.favorite).length,[f,l.lifecycle,aZ]),a6=(0,e.useMemo)(()=>f.find(a=>a.id===j)||null,[f,j]),a7=(0,e.useMemo)(()=>{if(!a6)return"";let a=h.find(a=>a.id===a6.vaultId);return a?a.name||(a.isPrimary?"Primary":a.id.slice(0,8)):"primary"===a6.vaultId?"Primary":a6.vaultId.slice(0,8)},[a6,h]),a8=(0,e.useMemo)(()=>a6?ci(a6):l.lifecycle,[a6,l.lifecycle]),a9=(0,e.useMemo)(()=>[...f].sort((a,b)=>ck(b,t)-ck(a,t)).slice(0,8),[f,t]),ba=(0,e.useCallback)((a=120)=>{aQ.current&&clearTimeout(aQ.current),aQ.current=setTimeout(()=>{E||D(!1),aQ.current=null},a)},[E]),bb=(0,e.useMemo)(()=>ar?ar.name||(ar.isPrimary?"Primary":`Vault ${ar.id.slice(0,6)}`):"Vault",[ar]),bc=(0,e.useMemo)(()=>az?az.name||(az.isPrimary?"Primary":`Vault ${az.id.slice(0,6)}`):"Vault",[az]),bd=(0,e.useMemo)(()=>null!==l.vaultId||"all"!==l.category||null!==l.tag||""!==l.search.trim()||l.favoritesOnly,[l]),be=(0,e.useCallback)(a=>{m(b=>({...b,...a}))},[]),bf=(0,e.useCallback)(()=>{m(cc)},[]),bg=(0,e.useCallback)(async()=>{try{await s.FH.post(s.jI.Wallet,"/lock",{})}catch(a){console.error("[CredentialVault] lock error:",a)}I(),a()},[a,I]);(0,e.useCallback)(a=>{as(a),au(""),ay(null)},[]);let bh=(0,e.useCallback)(()=>{as(null),au(""),ay(null)},[]),bi=(0,e.useCallback)(async()=>{if(ar&&at){aw(!0),ay(null);try{let a=await (0,s.WE)(at,ar.id);a.token&&J(a.token),await aT(),m(a=>({...a,vaultId:ar.id,lifecycle:"active",tag:null})),bh()}catch(a){ay(a.message||"Failed to unlock vault")}finally{aw(!1)}}},[at,ar,J,aT,bh]),bj=(0,e.useCallback)(async a=>{try{await s.FH.post(s.jI.Wallet,`/vaults/credential/${encodeURIComponent(a)}/lock`,{}),await aT()}catch(a){console.error("[CredentialVault] lock vault error:",a)}},[aT]),bk=(0,e.useCallback)(a=>{aA(a),aE(null)},[]),bl=(0,e.useCallback)(()=>{aB||(aA(null),aE(null))},[aB]),bm=(0,e.useCallback)(async()=>{if(az){aC(!0),aE(null);try{await s.FH.delete(s.jI.Wallet,`/vaults/credential/${encodeURIComponent(az.id)}`),m(a=>a.vaultId===az.id?{...a,vaultId:null,lifecycle:"active",tag:null}:a),a6?.vaultId===az.id&&(k(null),N(!1)),await aT(),aA(null)}catch(a){aE(a.message||"Failed to delete vault")}finally{aC(!1)}}},[az,aT,a6]),bn=(0,e.useCallback)(async()=>{if(j)try{let a=encodeURIComponent(a8);await s.FH.delete(s.jI.Wallet,`/credentials/${j}?location=${a}`),k(null),N(!1),aT()}catch(a){console.error("[CredentialVault] delete error:",a)}},[j,a8,aT]),bo=(0,e.useCallback)(async()=>{if(j&&"active"!==a8)try{await s.FH.post(s.jI.Wallet,`/credentials/${j}/restore`,{from:a8}),k(null),N(!1),aT()}catch(a){console.error("[CredentialVault] restore error:",a)}},[j,a8,aT]),bp=(0,e.useCallback)(async()=>{if(j)try{let a=await s.FH.post(s.jI.Wallet,`/credentials/${j}/duplicate`);await aT(),a.credential&&k(a.credential.id)}catch(a){console.error("[CredentialVault] duplicate error:",a)}},[j,aT]),bq=(0,e.useCallback)(()=>{$(""),aa("independent"),ae(""),ag("")},[]),br=(0,e.useCallback)(()=>{Y(!1),ao(!1),bq()},[bq]),bs=(0,e.useCallback)(async()=>{if(Z.trim()&&("independent"!==_||!(af.length<8))&&("linked"!==_||ab)){ai(!0);try{let a={name:Z.trim(),mode:_};if("linked"===_)a.parentVaultId=ab;else{let b=await s.FH.get(s.jI.Wallet,"/auth/connect");a.encrypted=await (0,x.X)(af,b.publicKey)}let b=await s.FH.post(s.jI.Wallet,"/vaults/credential",a),c=b?.vault?.id;an&&c&&am(c),Y(!1),ao(!1),bq(),await aT()}catch(a){console.error("[CredentialVault] create vault error:",a)}finally{ai(!1)}}},[Z,_,ab,af,an,aT,bq]),bt=(0,e.useCallback)(a=>{a?(aa("linked"),ae(a)):(aa("independent"),ae(""),ag("")),Y(!0)},[]),bu=(0,e.useCallback)(()=>{am(aW||h[0]?.id||"primary"),ak(!0)},[aW,h]),bv=(0,e.useCallback)(()=>{ao(!0),bt()},[bt]),bw=(0,e.useCallback)((a="api-key-form",b)=>{let c={},d=l.vaultId||aW||h[0]?.id;d&&(c.vaultId=d),b?.applyFilters?(l.tag&&(c.tags=[l.tag]),b.prefillType?c.type=b.prefillType:l.category&&"all"!==l.category&&(c.type=l.category)):b?.prefillType&&(c.type=b.prefillType),V(null),R(a),T(Object.keys(c).length>0?c:null),P(!0)},[l,aW,h]),bx=(0,e.useCallback)(async a=>{P(!1),V(null),T(null),await aT(),a&&(k(a),aU(a),aR&&N(!0))},[aT,aR,aU]),by=(0,e.useCallback)(a=>{k(a),aU(a),aR&&N(!0)},[aR,aU]),bz=(0,e.useCallback)(a=>{be({search:a}),D(!1),requestAnimationFrame(()=>aN.current?.focus())},[be]),bA=(0,e.useCallback)(a=>{be({search:a.name}),by(a.id),D(!1)},[be,by]),bE=(0,e.useMemo)(()=>l.search.trim()?[]:["tag:work","type:login","vault:primary","favorite","archived","recently_deleted"],[l.search]),bF=(C||E)&&""===l.search.trim();return(!function({filteredCredentials:a,selectedId:b,isMobile:c,searchRef:d,onCreateCredential:e,setSelectedId:f,setMobileDetailOpen:g}){}({filteredCredentials:a1,selectedId:j,isMobile:aR,searchRef:aN,onCreateCredential:()=>bw("api-key-form"),setSelectedId:k,setMobileDetailOpen:N}),n)?(0,d.jsxs)("div",{className:"h-screen w-screen flex items-center justify-center bg-[var(--color-background,#f4f4f5)] relative isolate vault-surface",children:[(0,d.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,d.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"})]}),(0,d.jsxs)("div",{className:"flex flex-col items-center relative z-10",children:[(0,d.jsx)("div",{className:"w-6 h-6 border-2 border-[var(--color-border,#d4d4d8)] border-t-[var(--color-text,#0a0a0a)] animate-spin"}),(0,d.jsx)("div",{className:"mt-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest",children:"LOADING VAULT"})]})]}):(0,d.jsxs)("div",{className:"relative isolate h-screen w-screen overflow-hidden flex flex-col bg-[var(--color-background,#f4f4f5)] vault-surface",children:[(0,d.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,d.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"}),(0,d.jsx)("div",{className:"absolute bottom-[5%] right-[5%] opacity-[0.03] select-none",children:(0,d.jsx)("div",{className:"text-[12vw] font-black leading-none text-[var(--color-text,#0a0a0a)] font-mono tracking-tighter text-right",children:"AURAMAXX"})}),(0,d.jsx)("div",{className:"absolute top-10 left-[200px] w-24 h-24 border-l-4 border-t-4 border-[var(--color-text,#0a0a0a)] opacity-10",children:(0,d.jsx)("div",{className:"absolute top-2 left-2 w-3 h-3 bg-[var(--color-text,#0a0a0a)]"})}),(0,d.jsx)("div",{className:"absolute bottom-10 right-10 w-24 h-24 border-r-4 border-b-4 border-[var(--color-text,#0a0a0a)] opacity-10 flex items-end justify-end",children:(0,d.jsx)("div",{className:"absolute bottom-2 right-2 w-3 h-3 bg-[var(--color-text,#0a0a0a)]"})})]}),(0,d.jsxs)("div",{className:"relative z-10 flex-1 flex overflow-hidden",children:[!aR&&!aS&&(0,d.jsx)(X,{vaults:h,filters:l,categoryCounts:a3,tags:a4,favoritesCount:a5,onFilterChange:be,onLock:bg,onLockVault:bj,onCreateCredential:(a,b)=>bw("type-picker"===a?"type-picker":"api-key-form",b?{prefillType:b}:void 0),onCreateVault:bt,mode:"desktop",notifications:aG,onDismissNotification:aH,pendingActionCount:aG.filter(a=>"pending"===a.status&&"notify"!==a.type).length,surface:p,onSurfaceChange:q,onSettings:b,onDeleteVault:bk}),aS&&(0,d.jsxs)("div",{className:"h-full w-12 shrink-0 border-r border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#f4f4f2)] flex flex-col items-center pt-3 gap-3 relative z-10",children:[(0,d.jsx)("img",{src:"/logo.webp",alt:"Aura",className:"w-6 h-6 object-contain"}),(0,d.jsx)("button",{type:"button",onClick:()=>L(!0),className:"flex items-center justify-center w-7 h-7 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors rounded","aria-label":"Open sidebar",title:"Open sidebar",children:(0,d.jsx)(u,{size:14})})]}),"audit"===p?(0,d.jsx)("div",{className:"flex-1 h-full overflow-hidden",children:(0,d.jsx)(b$,{})}):"apiKeys"===p?(0,d.jsx)("div",{className:"flex-1 h-full overflow-hidden",children:(0,d.jsx)(b9,{requests:aF,activeTokens:aK,inactiveTokens:aL,actionLoading:aM,onResolveAction:aI,onRevokeToken:aJ,vaults:h})}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ad,{credentials:a0,latestAccessById:A,selectedId:j,searchQuery:l.search,onSearchChange:a=>be({search:a}),onSelect:by,onAdd:()=>bw("api-key-form"),onCreateWithFilter:bd?()=>bw("api-key-form",{applyFilters:!0}):void 0,canAdd:"active"===l.lifecycle,onImport:bu,canImport:"active"===l.lifecycle,onOpenGenerator:()=>aq(!0),onClearFilters:bf,hasActiveFilters:bd,fieldSearchSuggestions:a2,onApplySearchSuggestion:bz,searchInputRef:aN,showSearch:!1,className:aR?"flex-1 h-full flex flex-col pb-14 min-w-0":"w-[300px] h-full flex flex-col pb-14 border-r border-[var(--color-border,#d4d4d8)]",leadingAction:aR?(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",icon:(0,d.jsx)(u,{size:12}),onClick:()=>L(!0),className:"!px-1.5 !h-8 !w-8","aria-label":"Open sidebar",title:"Open sidebar"}):void 0}),!aR&&(0,d.jsx)("div",{className:"flex-1 h-full overflow-y-auto pb-14",children:a6?(0,d.jsx)(bB,{credential:a6,vaultName:a7,lifecycle:a8,onEdit:()=>V(a6.id),onDelete:bn,onRestore:bo,onDuplicate:bp}):(0,d.jsx)(bC,{variant:"active"!==l.lifecycle?"empty-lifecycle":0===f.filter(a=>"active"===ci(a)).length?"empty-vault":"no-selection",onAdd:"active"===l.lifecycle?()=>bw("api-key-form"):void 0})})]}),"credentials"===p&&(0,d.jsx)("div",{className:`absolute bottom-0 z-30 border-t border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#ffffff)]/95 backdrop-blur-sm ${aR?"left-0 right-0 w-full":`${aS?"left-12":"left-[200px]"} right-0`}`,children:(0,d.jsx)("div",{className:"w-full px-3 py-2.5",children:(0,d.jsxs)("div",{ref:aO,className:"relative w-full",children:[bF&&(0,d.jsxs)("div",{"data-testid":"search-dock-panel",className:"absolute bottom-full left-0 w-full mb-1 bg-[var(--color-surface,#ffffff)] border border-[var(--color-border-focus,#0a0a0a)] shadow-mech max-h-56 overflow-y-auto z-20",children:[a9.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"px-3 py-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] border-b border-[var(--color-border-muted,#e5e7eb)] flex items-center gap-1.5",children:[(0,d.jsx)(v,{size:11}),"Recently Accessed"]}),a9.map(a=>(0,d.jsxs)("button",{type:"button",className:"w-full text-left px-4 py-2.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] font-mono text-xs border-b border-[var(--color-border-muted,#e5e5e5)] last:border-0",onMouseDown:b=>{b.preventDefault(),bA(a)},children:[(0,d.jsx)("div",{className:"text-[var(--color-text,#0a0a0a)] truncate",children:a.name}),(0,d.jsxs)("div",{className:"text-[9px] uppercase tracking-wider truncate",children:[a$.get(a.vaultId)||a.vaultId," \xb7 ",ci(a)]})]},a.id))]}),0===a9.length&&(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"px-3 py-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] border-b border-[var(--color-border-muted,#e5e7eb)]",children:"Try Structured Search"}),bE.map(a=>(0,d.jsxs)("button",{type:"button",className:"w-full text-left px-4 py-2.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] font-mono text-xs border-b border-[var(--color-border-muted,#e5e5e5)] last:border-0 flex items-center gap-2 group/item",onMouseDown:b=>{b.preventDefault(),bz(a)},children:[(0,d.jsx)("div",{className:"w-1.5 h-1.5 flex-shrink-0 bg-[var(--color-border,#d4d4d8)] group-hover/item:bg-[var(--color-text,#0a0a0a)]"}),(0,d.jsx)("span",{className:"min-w-0 flex-1 truncate",children:a})]},a))]})]}),(0,d.jsx)(z.ks,{compact:!0,leftElement:(0,d.jsx)(w.A,{size:12}),placeholder:"Search...",value:l.search,onChange:a=>be({search:a.target.value}),inputRef:aN,onFocus:()=>{F(!0)},onClick:()=>{aQ.current&&(clearTimeout(aQ.current),aQ.current=null),D(!0)},onBlur:()=>{F(!1),ba()}})]})})})]}),(0,d.jsx)(ca.Z,{requests:aF,resolveAction:aI,actionLoading:aM}),aR&&(0,d.jsx)(z._s,{isOpen:M&&null!=a6,onClose:()=>N(!1),title:a6?.name||"Credential",subtitle:a7||"Credential_Detail",width:"full",children:a6?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(z.$n,{variant:"ghost",size:"sm",onClick:()=>N(!1),className:"mb-3",children:"BACK"}),(0,d.jsx)(bB,{credential:a6,vaultName:a7,lifecycle:a8,onEdit:()=>V(a6.id),onDelete:bn,onRestore:bo,onDuplicate:bp})]}):(0,d.jsx)(bC,{variant:"active"!==l.lifecycle?"empty-lifecycle":0===f.length?"empty-vault":"no-selection",onAdd:"active"===l.lifecycle?()=>bw("api-key-form"):void 0})}),(aR||aS)&&K&&(0,d.jsxs)("div",{className:"absolute inset-0 z-40",children:[(0,d.jsx)("button",{type:"button","aria-label":"Close sidebar",onClick:()=>L(!1),className:"absolute inset-0 bg-[var(--color-text,#0a0a0a)]/20"}),(0,d.jsx)("div",{className:"absolute left-0 top-0 h-full",children:(0,d.jsx)(X,{vaults:h,filters:l,categoryCounts:a3,tags:a4,favoritesCount:a5,onFilterChange:be,onLock:bg,onLockVault:bj,onCreateCredential:(a,b)=>bw("type-picker"===a?"type-picker":"api-key-form",b?{prefillType:b}:void 0),onCreateVault:bt,mode:"mobile",onNavigate:()=>L(!1),notifications:aG,onDismissNotification:aH,pendingActionCount:aG.filter(a=>"pending"===a.status&&"notify"!==a.type).length,surface:p,onSurfaceChange:q,onSettings:b,onDeleteVault:bk})})]}),(0,d.jsx)(z.aF,{isOpen:null!=az,onClose:bl,title:`Delete ${bc}?`,size:"sm",footer:(0,d.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:bl,disabled:aB,children:"CANCEL"}),(0,d.jsx)(z.$n,{variant:"danger",size:"sm",onClick:bm,loading:aB,children:"DELETE"})]}),children:(0,d.jsxs)("div",{className:"space-y-3",children:[(0,d.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"This will permanently delete the vault and its credentials."}),aD&&(0,d.jsx)("div",{className:"text-[10px] text-[var(--color-danger,#ef4444)] border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 px-3 py-2",children:aD})]})}),(0,d.jsx)(z.aF,{isOpen:null!=ar,onClose:bh,title:`Unlock ${bb}`,size:"sm",footer:(0,d.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:bh,children:"CANCEL"}),(0,d.jsx)(z.$n,{size:"sm",onClick:bi,loading:av,disabled:!at,children:"UNLOCK"})]}),children:(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)(z.ks,{label:"Vault Password",type:"password",placeholder:"Enter vault password",value:at,onChange:a=>au(a.target.value),autoFocus:!0}),ax&&(0,d.jsx)("div",{className:"text-[10px] text-[var(--color-danger,#ef4444)] border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 px-3 py-2",children:ax})]})}),(0,d.jsx)(bD.i,{isOpen:O||!!U,onClose:()=>{P(!1),V(null),T(null)},onSaved:bx,editCredentialId:U??void 0,vaults:h,createStartStep:"type-picker"===Q?"type":"form",createStartType:"type-picker"===Q?void 0:"apikey",createPrefill:S??void 0}),(0,d.jsx)(bI,{isOpen:aj,onClose:()=>ak(!1),onComplete:aT,vaults:h,selectedVaultId:al,onSelectedVaultIdChange:am,onAddVault:bv,walletBaseUrl:(0,s.au)()}),(0,d.jsx)(bJ.p,{isOpen:ap,onClose:()=>aq(!1),onUse:a=>{aq(!1),navigator.clipboard.writeText(a).catch(()=>{})}}),(0,d.jsx)(z.aF,{isOpen:W,onClose:br,title:"New Vault",size:"md",footer:(0,d.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,d.jsx)(z.$n,{variant:"secondary",size:"sm",onClick:br,children:"CANCEL"}),(0,d.jsx)(z.$n,{size:"sm",onClick:bs,loading:ah,disabled:!Z.trim()||"linked"===_&&!ab||"independent"===_&&af.length<8,children:"CREATE"})]}),children:(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsx)(z.ks,{label:"Vault Name",placeholder:"e.g. Work, Personal",value:Z,onChange:a=>$(a.target.value),autoFocus:!0}),(0,d.jsx)(z.UM,{label:"Vault Type",options:cd,value:_,onChange:a=>{aa(a),"independent"!==a&&ag("")},compact:!0}),"linked"===_&&(0,d.jsx)(z.UM,{label:"Parent Vault",options:aX,value:ab,onChange:ae,disabled:0===aX.length,compact:!0}),"independent"===_&&(0,d.jsx)(z.ks,{label:"Vault Password",type:"password",placeholder:"At least 8 characters",value:af,onChange:a=>ag(a.target.value)})]})})]})};var cq=c(93535),cr=c(60125),cs=c(71287),ct=c(24328);function cu(){let{updateAvailable:a,current:b,latest:c,updating:e,updateError:f,updateOutput:g,runUpdate:h,apiServerDown:i,restartingServer:j,restartError:k,runRestart:l}=(0,ct.e)();return i||k||a||g||f?i||k?(0,d.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[9999] px-4 py-2.5 font-mono text-[11px] flex items-center justify-between gap-3",style:{background:"var(--color-warning, #ff4d00)",color:"#fff"},children:[(0,d.jsx)("span",{children:"API SERVER OFFLINE. RUN: auramaxx restart"}),(0,d.jsx)(z.$n,{type:"button",onClick:()=>{l()},loading:j,variant:"primary",size:"sm",children:"RESTART NOW"}),k&&(0,d.jsx)("span",{className:"text-[10px]",style:{color:"#fff",opacity:.9},children:k})]}):g&&!a?(0,d.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[100] px-3 py-2 border text-[9px] font-mono tracking-widest flex items-center justify-center gap-3",style:{color:"var(--color-accent-foreground, #0a0a0a)",borderColor:"var(--color-accent, #ccff00)",background:"var(--color-accent, #ccff00)"},children:[(0,d.jsxs)("span",{children:["UPDATE COMPLETE — AURAMAXX ",c," READY"]}),(0,d.jsx)(z.$n,{type:"button",size:"sm",variant:"primary",onClick:()=>{window.location.reload()},children:"RESTART"})]}):(0,d.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[9999] px-4 py-2.5 font-mono text-[11px] flex items-center justify-between gap-3",style:{background:"var(--color-warning, #ff4d00)",color:"#fff"},children:[(0,d.jsxs)("span",{children:["UPDATE AVAILABLE: ",b," → ",c]}),(0,d.jsx)(z.$n,{type:"button",onClick:()=>{h()},loading:e,variant:"primary",size:"sm",children:"UPDATE NOW"}),f&&(0,d.jsx)("span",{className:"text-[10px]",style:{color:"#fff",opacity:.9},children:f})]}):null}var cv=c(68225);let cw=["strict","dev","admin"],cx=["auto","strict","off"],cy=[{value:"strict",label:"strict",description:"Minimal local token scope with explicit allowlists."},{value:"dev",label:"dev",description:"Balanced local automation with scoped defaults."},{value:"admin",label:"admin (dangerous)",description:"Broad token scope. Use only in tightly controlled local environments."}],cz=[{value:"auto",label:"auto (recommended)",description:"Uses `.aura` when present and safely falls back to token scope when missing."},{value:"strict",label:"strict (require .aura)",description:"Requires explicit `.aura` mappings for secret access."},{value:"off",label:"off (disable project allowlist)",description:"Disables project allowlist checks for local token access."}],cA=[{value:"dev",label:"mid (dev)",description:"Access to most things. Human approval for stuff like CVV."},{value:"strict",label:"sus (local)",description:"Most locked down. Every request needs manual approval."},{value:"admin",label:"maxx (admin)",description:"Full access. Use only when you fully trust the agent."}],cB=[{value:"light",label:"Light"},{value:"dark",label:"Dark"}],cC=[{value:"normal",label:"Normal"},{value:"big",label:"Big"}],cD="auramaxx_admin_token",cE=new Set(f.Yu.english.map(a=>a.toLowerCase())),cF=a=>a.trim().toLowerCase().split(/\s+/).filter(Boolean);function cG(){let{token:a,setToken:b,clearToken:c}=(0,r.A)(),{colorMode:g,uiScale:p,setColorMode:u,setUiScale:v}=(0,cv.D)(),[w,x]=(0,e.useState)("loading"),[y,A]=(0,e.useState)(""),[B,C]=(0,e.useState)(!0),[D,E]=(0,e.useState)(!1),[F,G]=(0,e.useState)(null),[H,I]=(0,e.useState)(null),[J,K]=(0,e.useState)(!1),[L,M]=(0,e.useState)(null),[N,O]=(0,e.useState)(null),[P,Q]=(0,e.useState)(!1),[R,S]=(0,e.useState)("dev"),[T,U]=(0,e.useState)("seed"),[V,W]=(0,e.useState)(null),[X,Y]=(0,e.useState)(!1),[Z,$]=(0,e.useState)(!1),{notifications:_,dismissNotification:aa}=(0,cb.S)({autoFetch:!!a}),[ab,ac]=(0,e.useState)(!1),[ad,ae]=(0,e.useState)(!1),[af,ag]=(0,e.useState)(null),[ah,ai]=(0,e.useState)(null),[aj,ak]=(0,e.useState)({profile:"dev",profileVersion:"v1",autoApprove:!0,projectScopeMode:"auto"}),[al,am]=(0,e.useState)(null),[an,ao]=(0,e.useState)(null),[ap,aq]=(0,e.useState)({}),[ar,as]=(0,e.useState)(null),[at,au]=(0,e.useState)(!1),[av,aw]=(0,e.useState)(!1),[ax,ay]=(0,e.useState)(!1),[az,aA]=(0,e.useState)(!1),[aB,aC]=(0,e.useState)(!0),[aD,aE]=(0,e.useState)(!1),[aF,aG]=(0,e.useState)(!1),[aH,aI]=(0,e.useState)(!1),[aJ,aK]=(0,e.useState)(!1),[aL,aM]=(0,e.useState)([]),[aN,aO]=(0,e.useState)(!1),[aP,aQ]=(0,e.useState)(!1),[aR,aS]=(0,e.useState)(null),[aT,aU]=(0,e.useState)(!1),[aV,aW]=(0,e.useState)(null),[aX,aY]=(0,e.useState)(null),[aZ,a$]=(0,e.useState)(!1),[a_,a0]=(0,e.useState)(""),[a1,a2]=(0,e.useState)(""),[a3,a4]=(0,e.useState)(""),[a5,a6]=(0,e.useState)(null),[a7,a8]=(0,e.useState)(null),[a9,ba]=(0,e.useState)(!1),[bb,bc]=(0,e.useState)(!1),[bd,be]=(0,e.useState)(12),[bf,bg]=(0,e.useState)(Array(12).fill("")),[bh,bi]=(0,e.useState)(!1),[bj,bk]=(0,e.useState)(!1),[bl]=(0,e.useState)(()=>"ready to auramaxx and mog prompt peasants?"),[bm,bn]=(0,e.useState)(""),[bo,bp]=(0,e.useState)(null),[bq,br]=(0,e.useState)(!1),bs=(0,e.useRef)("loading"),bt=(0,e.useRef)(null),bu=(0,e.useRef)(null),bv=(0,e.useRef)(!0),bw=(0,e.useRef)(0),bx=(0,e.useRef)(null),by=(0,e.useMemo)(()=>!!H,[H]),bz=(0,e.useMemo)(()=>bf.filter(a=>a.length>0).length,[bf]),bA=(0,e.useMemo)(()=>bf.map(a=>a.trim().toLowerCase()).join(" ").trim(),[bf]),bB=(0,e.useMemo)(()=>{let a=new Set;return bf.forEach((b,c)=>{b&&(cE.has(b.trim().toLowerCase())||a.add(c))}),a},[bf]),bC=(0,e.useMemo)(()=>bz===bd&&!(bB.size>0)&&f.JB(bA),[bB.size,bA,bd,bz]),bD=(0,e.useCallback)(a=>"admin"===a.profile,[]),bE=(0,e.useMemo)(()=>!!ah&&JSON.stringify(ah)!==JSON.stringify(aj),[aj,ah]),bF=(0,e.useCallback)(a=>{let b=bs.current;if("loading"===b||"transition"===b){if(bu.current===a)return;bu.current=a,Q(!0),bt.current&&clearTimeout(bt.current),bt.current=setTimeout(()=>{Q(!1),bu.current=null,x(a)},220);return}bt.current&&(clearTimeout(bt.current),bt.current=null),bu.current=null,Q(!1),x(a)},[]),bG=(0,e.useCallback)(()=>{bt.current&&(clearTimeout(bt.current),bt.current=null),bu.current=null,Q(!1),x("transition")},[]),bH=(0,e.useCallback)(async()=>{let d=++bw.current,e=()=>bv.current&&d===bw.current,f=a;if(f&&!(0,t.Xo)())try{bx.current||(bx.current=(async()=>{let{publicKeyBase64:a}=await (0,t.T5)();return(0,s.fP)(a)})().finally(()=>{bx.current=null}));let a=await bx.current;if(!e())return;a.token&&(b(a.token),f=a.token)}catch{if(!e())return;c(),f=null}try{let[a,c]=await Promise.all([s.FH.get(s.jI.Wallet,"/setup"),s.FH.get(s.jI.Wallet,"/setup/vaults")]);if(!e())return;if(!(a.hasWallet||c.vaults&&c.vaults.some(a=>a.isPrimary))||by)return void bF("setup");let d="loading"===bs.current||"transition"===bs.current;if(a.unlocked&&!f&&d)try{if(await new Promise(a=>setTimeout(a,120)),!e())return;let a=window.localStorage.getItem(cD),c=window.sessionStorage.getItem(cD),d=a||c;if(d)return void b(d,{persist:a?"local":"session"})}catch{if(!e())return}if(!a.unlocked&&f&&d)try{if(await new Promise(a=>setTimeout(a,450)),!e())return;let a=await s.FH.get(s.jI.Wallet,"/setup");if(!e())return;if(a.unlocked)return void bF("unlocked")}catch{if(!e())return}if(!a.unlocked||!f)return void bF("locked");bF("unlocked")}catch{if(!e())return;bF("setup")}},[a,c,by,bF,b]),bI=(0,e.useCallback)(async()=>{if(!a)return void am("Unlock vault first to manage local socket policy.");au(!0),am(null),ao(null),as(null);try{let b={Authorization:`Bearer ${a}`},c=s.FH.getBaseUrl(s.jI.Wallet),d=await fetch(`${c}/defaults`,{headers:b});if(!d.ok)throw Error("Failed to load canonical trust policy defaults.");let e=await d.json();if(!1===e.success)throw Error("Failed to load canonical trust policy defaults.");let f=Object.values(e.defaults||{}).flat(),g=a=>f.find(b=>b.key===a)?.value,h=String(g("trust.localProfile")??"").trim();if(!cw.includes(h))throw Error(`Unknown persisted local profile: ${h||"(empty)"}`);let i=String(g("trust.localProfileVersion")??"v1").trim();if("v1"!==i)throw Error("Unknown local profile version; refusing to edit settings.");let j=String(g("trust.projectScopeMode")??"auto").trim();if(!cx.includes(j))throw Error(`Unknown persisted project scope mode: ${j||"(empty)"}`);let k={profile:h,profileVersion:"v1",autoApprove:!!g("trust.localAutoApprove"),projectScopeMode:j};ai(k),ak(k)}catch(a){am(a.message||"Failed to load policy settings"),ai(null)}finally{au(!1)}},[a]),bJ=(0,e.useCallback)(async()=>{if(!a)throw Error("Missing auth token for save.");if(!cw.includes(aj.profile))throw Error("Unknown profile selected; refusing to persist.");if(!cx.includes(aj.projectScopeMode))throw Error("Unknown project scope mode selected; refusing to persist.");let b=s.FH.getBaseUrl(s.jI.Wallet),c={"Content-Type":"application/json",Authorization:`Bearer ${a}`},d=[["trust.localProfile",aj.profile],["trust.localProfileVersion","v1"],["trust.localAutoApprove",aj.autoApprove],["trust.projectScopeMode",aj.projectScopeMode]];if(!(await Promise.all(d.map(async([a,d])=>(await fetch(`${b}/defaults/${a}`,{method:"PATCH",headers:c,body:JSON.stringify({value:d})})).ok))).every(Boolean))throw Error("Failed to save canonical trust policy defaults.");return{...aj,profileVersion:"v1"}},[aj,a]),bK=(0,e.useCallback)(async()=>{if(ah&&!at&&!av){if(!bD(ah)&&bD(aj)&&!ax)return void ay(!0);aw(!0),ao(null),as(null);try{let a=await bJ();ai(a),ak(a),ay(!1),as("Local trust policy saved. Changes apply to newly issued local tokens only.")}catch(b){let a=b.message||"Failed to save policy settings";ay(!1),a.includes("Unknown profile selected")||a.includes("Unknown project scope mode selected")?ao(a):(await bI(),ao(`${a} Server values were reloaded.`))}finally{aw(!1)}}},[ax,bD,bI,bJ,aj,at,av,ah]),bL=(0,e.useCallback)(()=>{a$(!1),a0(""),a2(""),a4(""),a6(null),ba(!1)},[]),bM=(0,e.useCallback)(async a=>{if(a.preventDefault(),a6(null),a8(null),a1.length<8)return void a6("New password must be at least 8 characters.");if(a1!==a3)return void a6("New password and confirmation do not match.");ba(!0);try{await (0,s.g4)(a_,a1),a8("Primary vault password updated."),bL()}catch(a){a6(a.message||"Failed to change primary password.")}finally{ba(!1)}},[bL,a3,a_,a1]),bN=(0,e.useCallback)((a,b)=>{let c=b.trim().toLowerCase();if(c.includes(" ")){let b=cF(c);if(b.length>1){let c=[...bf];b.forEach((b,d)=>{let e=a+d;e<c.length&&(c[e]=b)}),bg(c),bp(null);return}}let d=[...bf];d[a]=c,bg(d),bp(null)},[bf]),bO=(0,e.useCallback)((a,b)=>{let c=cF(b);if(c.length<=1)return!1;let d=c.length>12?24:bd;if(d!==bd){be(d);let a=Array(d).fill("");return c.slice(0,d).forEach((b,c)=>{a[c]=b}),bg(a),bp(null),!0}let e=[...bf];return c.forEach((b,c)=>{let d=a+c;d<e.length&&(e[d]=b)}),bg(e),bp(null),!0},[bd,bf]),bP=(0,e.useCallback)(async a=>{if(a.preventDefault(),bp(null),bm.length<8)return void bp("New password must be at least 8 characters.");if(!bC)return void bp("Enter a valid 12 or 24-word BIP-39 seed phrase.");br(!0);try{let{publicKeyBase64:a}=await (0,t.T5)(),c=await (0,s.OW)(bA,bm,a);c.token&&b(c.token,{persist:B?"local":"session"}),A(""),bn(""),bg(Array(bd).fill("")),bG(),bV()}catch(a){bp(a.message||"Recovery failed.")}finally{br(!1)}},[bG,bC,bA,bm,bd,b,B]),bQ=async a=>{if(a.preventDefault(),y){E(!0),G(null);try{let{publicKeyBase64:a}=await (0,t.T5)(),c=await (0,s.WE)(y,void 0,a);c.token&&b(c.token,{persist:B?"local":"session"}),A(""),bG(),bV()}catch(a){G(a.message||"Unlock failed")}finally{E(!1)}}},bR=async a=>{if(a.preventDefault(),!(y.length<8)){E(!0),G(null);try{let{publicKeyBase64:a}=await (0,t.T5)(),c=await (0,s.ne)(y,a);c.token&&(b(c.token,{persist:B?"local":"session"}),W(c.token)),c.mnemonic&&(I(c.mnemonic),K(!1),U("seed"),M(null),O(null)),A(""),c.mnemonic||bH()}catch(a){G(a.message||"Setup failed")}finally{E(!1)}}},bS=(0,e.useCallback)(async()=>{if(!H)return;let a=!1;if("undefined"!=typeof navigator&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(H),a=!0}catch{a=!1}if(a)return void O("copied");let b=document.createElement("textarea");b.value=H,b.setAttribute("readonly","true"),b.style.position="fixed",b.style.left="-9999px",document.body.appendChild(b),b.focus(),b.select();let c=!1;try{c=document.execCommand("copy")}catch{c=!1}finally{b.remove()}O(c?"copied":"copy-failed")},[H]),bT=(0,e.useCallback)(()=>{if(!H)return;let a=new Date().toISOString().slice(0,10),b=H.split(" ").map((a,b)=>`${b+1}. ${a}`).join("\n"),c=`# Aura Vault Seed Phrase Backup
60
60
 
61
61
  **Date:** ${a}
62
62
  **WARNING:** Keep this file safe and private. Anyone with this phrase can access your vault.